Cleanup deps
authornegativeExponent <negativeExponent@users.noreply.github.com>
Tue, 20 Apr 2021 23:16:35 +0000 (07:16 +0800)
committernegativeExponent <negativeExponent@users.noreply.github.com>
Tue, 20 Apr 2021 23:48:38 +0000 (07:48 +0800)
207 files changed:
deps/crypto/README.md [deleted file]
deps/crypto/aes.c [deleted file]
deps/crypto/aes.h [deleted file]
deps/crypto/aes_test.c [deleted file]
deps/crypto/arcfour.c [deleted file]
deps/crypto/arcfour.h [deleted file]
deps/crypto/arcfour_test.c [deleted file]
deps/crypto/base64.c [deleted file]
deps/crypto/base64.h [deleted file]
deps/crypto/base64_test.c [deleted file]
deps/crypto/blowfish.c [deleted file]
deps/crypto/blowfish.h [deleted file]
deps/crypto/blowfish_test.c [deleted file]
deps/crypto/crypto_types.h [deleted file]
deps/crypto/des.c [deleted file]
deps/crypto/des.h [deleted file]
deps/crypto/des_test.c [deleted file]
deps/crypto/md2.c [deleted file]
deps/crypto/md2.h [deleted file]
deps/crypto/md2_test.c [deleted file]
deps/crypto/md5.c [deleted file]
deps/crypto/md5.h [deleted file]
deps/crypto/md5_test.c [deleted file]
deps/crypto/rot-13.c [deleted file]
deps/crypto/rot-13.h [deleted file]
deps/crypto/rot-13_test.c [deleted file]
deps/crypto/sha1.c [deleted file]
deps/crypto/sha1.h [deleted file]
deps/crypto/sha1_test.c [deleted file]
deps/crypto/sha256.c [deleted file]
deps/crypto/sha256.h [deleted file]
deps/crypto/sha256_test.c [deleted file]
deps/libchdr/LICENSE.txt [deleted file]
deps/libchdr/README.md [deleted file]
deps/libchdr/include/dr_libs/dr_flac.h [deleted file]
deps/libchdr/include/libchdr/bitstream.h [deleted file]
deps/libchdr/include/libchdr/cdrom.h [deleted file]
deps/libchdr/include/libchdr/chd.h [deleted file]
deps/libchdr/include/libchdr/chdconfig.h [deleted file]
deps/libchdr/include/libchdr/coretypes.h [deleted file]
deps/libchdr/include/libchdr/flac.h [deleted file]
deps/libchdr/include/libchdr/huffman.h [deleted file]
deps/libchdr/src/libchdr_bitstream.c [deleted file]
deps/libchdr/src/libchdr_cdrom.c [deleted file]
deps/libchdr/src/libchdr_chd.c [deleted file]
deps/libchdr/src/libchdr_flac.c [deleted file]
deps/libchdr/src/libchdr_huffman.c [deleted file]
deps/lzma-16.04/C/7z.h [deleted file]
deps/lzma-16.04/C/7zAlloc.c [deleted file]
deps/lzma-16.04/C/7zAlloc.h [deleted file]
deps/lzma-16.04/C/7zArcIn.c [deleted file]
deps/lzma-16.04/C/7zBuf.c [deleted file]
deps/lzma-16.04/C/7zBuf.h [deleted file]
deps/lzma-16.04/C/7zBuf2.c [deleted file]
deps/lzma-16.04/C/7zCrc.c [deleted file]
deps/lzma-16.04/C/7zCrc.h [deleted file]
deps/lzma-16.04/C/7zCrcOpt.c [deleted file]
deps/lzma-16.04/C/7zDec.c [deleted file]
deps/lzma-16.04/C/7zFile.c [deleted file]
deps/lzma-16.04/C/7zFile.h [deleted file]
deps/lzma-16.04/C/7zStream.c [deleted file]
deps/lzma-16.04/C/7zTypes.h [deleted file]
deps/lzma-16.04/C/7zVersion.h [deleted file]
deps/lzma-16.04/C/7zVersion.rc [deleted file]
deps/lzma-16.04/C/Aes.c [deleted file]
deps/lzma-16.04/C/Aes.h [deleted file]
deps/lzma-16.04/C/AesOpt.c [deleted file]
deps/lzma-16.04/C/Alloc.c [deleted file]
deps/lzma-16.04/C/Alloc.h [deleted file]
deps/lzma-16.04/C/Bcj2.c [deleted file]
deps/lzma-16.04/C/Bcj2.h [deleted file]
deps/lzma-16.04/C/Bcj2Enc.c [deleted file]
deps/lzma-16.04/C/Bra.c [deleted file]
deps/lzma-16.04/C/Bra.h [deleted file]
deps/lzma-16.04/C/Bra86.c [deleted file]
deps/lzma-16.04/C/BraIA64.c [deleted file]
deps/lzma-16.04/C/Compiler.h [deleted file]
deps/lzma-16.04/C/CpuArch.c [deleted file]
deps/lzma-16.04/C/CpuArch.h [deleted file]
deps/lzma-16.04/C/Delta.c [deleted file]
deps/lzma-16.04/C/Delta.h [deleted file]
deps/lzma-16.04/C/DllSecur.c [deleted file]
deps/lzma-16.04/C/DllSecur.h [deleted file]
deps/lzma-16.04/C/LzFind.c [deleted file]
deps/lzma-16.04/C/LzFind.h [deleted file]
deps/lzma-16.04/C/LzFindMt.c [deleted file]
deps/lzma-16.04/C/LzFindMt.h [deleted file]
deps/lzma-16.04/C/LzHash.h [deleted file]
deps/lzma-16.04/C/Lzma2Dec.c [deleted file]
deps/lzma-16.04/C/Lzma2Dec.h [deleted file]
deps/lzma-16.04/C/Lzma2Enc.c [deleted file]
deps/lzma-16.04/C/Lzma2Enc.h [deleted file]
deps/lzma-16.04/C/Lzma86.h [deleted file]
deps/lzma-16.04/C/Lzma86Dec.c [deleted file]
deps/lzma-16.04/C/Lzma86Enc.c [deleted file]
deps/lzma-16.04/C/LzmaDec.c [deleted file]
deps/lzma-16.04/C/LzmaDec.h [deleted file]
deps/lzma-16.04/C/LzmaEnc.c [deleted file]
deps/lzma-16.04/C/LzmaEnc.h [deleted file]
deps/lzma-16.04/C/LzmaLib.c [deleted file]
deps/lzma-16.04/C/LzmaLib.h [deleted file]
deps/lzma-16.04/C/MtCoder.c [deleted file]
deps/lzma-16.04/C/MtCoder.h [deleted file]
deps/lzma-16.04/C/Ppmd.h [deleted file]
deps/lzma-16.04/C/Ppmd7.c [deleted file]
deps/lzma-16.04/C/Ppmd7.h [deleted file]
deps/lzma-16.04/C/Ppmd7Dec.c [deleted file]
deps/lzma-16.04/C/Ppmd7Enc.c [deleted file]
deps/lzma-16.04/C/Precomp.h [deleted file]
deps/lzma-16.04/C/RotateDefs.h [deleted file]
deps/lzma-16.04/C/Sha256.c [deleted file]
deps/lzma-16.04/C/Sha256.h [deleted file]
deps/lzma-16.04/C/Sort.c [deleted file]
deps/lzma-16.04/C/Sort.h [deleted file]
deps/lzma-16.04/C/Threads.c [deleted file]
deps/lzma-16.04/C/Threads.h [deleted file]
deps/lzma-16.04/C/Util/7z/7z.dsp [deleted file]
deps/lzma-16.04/C/Util/7z/7z.dsw [deleted file]
deps/lzma-16.04/C/Util/7z/7zMain.c [deleted file]
deps/lzma-16.04/C/Util/7z/Precomp.c [deleted file]
deps/lzma-16.04/C/Util/7z/Precomp.h [deleted file]
deps/lzma-16.04/C/Util/7z/makefile [deleted file]
deps/lzma-16.04/C/Util/7z/makefile.gcc [deleted file]
deps/lzma-16.04/C/Util/Lzma/LzmaUtil.c [deleted file]
deps/lzma-16.04/C/Util/Lzma/LzmaUtil.dsp [deleted file]
deps/lzma-16.04/C/Util/Lzma/LzmaUtil.dsw [deleted file]
deps/lzma-16.04/C/Util/Lzma/makefile [deleted file]
deps/lzma-16.04/C/Util/Lzma/makefile.gcc [deleted file]
deps/lzma-16.04/C/Util/LzmaLib/LzmaLib.def [deleted file]
deps/lzma-16.04/C/Util/LzmaLib/LzmaLib.dsp [deleted file]
deps/lzma-16.04/C/Util/LzmaLib/LzmaLib.dsw [deleted file]
deps/lzma-16.04/C/Util/LzmaLib/LzmaLibExports.c [deleted file]
deps/lzma-16.04/C/Util/LzmaLib/makefile [deleted file]
deps/lzma-16.04/C/Util/LzmaLib/resource.rc [deleted file]
deps/lzma-16.04/C/Util/SfxSetup/Precomp.c [deleted file]
deps/lzma-16.04/C/Util/SfxSetup/Precomp.h [deleted file]
deps/lzma-16.04/C/Util/SfxSetup/SfxSetup.c [deleted file]
deps/lzma-16.04/C/Util/SfxSetup/SfxSetup.dsp [deleted file]
deps/lzma-16.04/C/Util/SfxSetup/SfxSetup.dsw [deleted file]
deps/lzma-16.04/C/Util/SfxSetup/makefile [deleted file]
deps/lzma-16.04/C/Util/SfxSetup/makefile_con [deleted file]
deps/lzma-16.04/C/Util/SfxSetup/resource.rc [deleted file]
deps/lzma-16.04/C/Util/SfxSetup/setup.ico [deleted file]
deps/lzma-16.04/C/Xz.c [deleted file]
deps/lzma-16.04/C/Xz.h [deleted file]
deps/lzma-16.04/C/XzCrc64.c [deleted file]
deps/lzma-16.04/C/XzCrc64.h [deleted file]
deps/lzma-16.04/C/XzCrc64Opt.c [deleted file]
deps/lzma-16.04/C/XzDec.c [deleted file]
deps/lzma-16.04/C/XzEnc.c [deleted file]
deps/lzma-16.04/C/XzEnc.h [deleted file]
deps/lzma-16.04/C/XzIn.c [deleted file]
deps/lzma-16.04/DOC/7zC.txt [deleted file]
deps/lzma-16.04/DOC/7zFormat.txt [deleted file]
deps/lzma-16.04/DOC/Methods.txt [deleted file]
deps/lzma-16.04/DOC/installer.txt [deleted file]
deps/lzma-16.04/DOC/lzma-history.txt [deleted file]
deps/lzma-16.04/DOC/lzma-sdk.txt [deleted file]
deps/lzma-16.04/DOC/lzma-specification.txt [deleted file]
deps/lzma-16.04/DOC/lzma.txt [deleted file]
deps/mman/.gitignore [deleted file]
deps/mman/.gitrepo [deleted file]
deps/mman/.vs/mman/v14/.suo [deleted file]
deps/mman/CMakeLists.txt [deleted file]
deps/mman/Makefile [deleted file]
deps/mman/README.md [deleted file]
deps/mman/UpgradeLog.htm [deleted file]
deps/mman/configure [deleted file]
deps/mman/mman-win32.pro [deleted file]
deps/mman/mman.c [deleted file]
deps/mman/mman.h [deleted file]
deps/mman/mman.sln [deleted file]
deps/mman/mman.vcxproj [deleted file]
deps/mman/mman.vcxproj.filters [deleted file]
deps/mman/mman.vcxproj.user [deleted file]
deps/mman/test.c [deleted file]
deps/zlib/adler32.c [deleted file]
deps/zlib/compress.c [deleted file]
deps/zlib/crc32.c [deleted file]
deps/zlib/deflate.c [deleted file]
deps/zlib/deflate.h [deleted file]
deps/zlib/gzclose.c [deleted file]
deps/zlib/gzfile.h [deleted file]
deps/zlib/gzguts.h [deleted file]
deps/zlib/gzlib.c [deleted file]
deps/zlib/gzread.c [deleted file]
deps/zlib/gzwrite.c [deleted file]
deps/zlib/infback.c [deleted file]
deps/zlib/inffast.c [deleted file]
deps/zlib/inffast.h [deleted file]
deps/zlib/inffixed.h [deleted file]
deps/zlib/inflate.c [deleted file]
deps/zlib/inflate.h [deleted file]
deps/zlib/inftrees.c [deleted file]
deps/zlib/inftrees.h [deleted file]
deps/zlib/ioapi.c [deleted file]
deps/zlib/ioapi.h [deleted file]
deps/zlib/trees.c [deleted file]
deps/zlib/trees.h [deleted file]
deps/zlib/uncompr.c [deleted file]
deps/zlib/unzip.c [deleted file]
deps/zlib/unzip.h [deleted file]
deps/zlib/zconf.h [deleted file]
deps/zlib/zconf.h.in [deleted file]
deps/zlib/zlib.h [deleted file]
deps/zlib/zutil.c [deleted file]
deps/zlib/zutil.h [deleted file]

diff --git a/deps/crypto/README.md b/deps/crypto/README.md
deleted file mode 100644 (file)
index 64eafd2..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-crypto-algorithms
-=================
-
-
-About
----
-These are basic implementations of standard cryptography algorithms, written by Brad Conte (brad@bradconte.com) from scratch and without any cross-licensing. They exist to provide publically accessible, restriction-free implementations of popular cryptographic algorithms, like AES and SHA-1. These are primarily intended for educational and pragmatic purposes (such as comparing a specification to actual implementation code, or for building an internal application that computes test vectors for a product). The algorithms have been tested against standard test vectors.
-
-This code is released into the public domain free of any restrictions. The author requests acknowledgement if the code is used, but does not require it. This code is provided free of any liability and without any quality claims by the author.
-
-Note that these are *not* cryptographically secure implementations. They have no resistence to side-channel attacks and should not be used in contexts that need cryptographically secure implementations.
-
-These algorithms are not optimized for speed or space. They are primarily designed to be easy to read, although some basic optimization techniques have been employed.
-
-Building
----
-The source code for each algorithm will come in a pair of a source code file and a header file. There should be no inter-header file dependencies, no additional libraries, no platform-specific header files, or any other complicating matters. Compiling them should be as easy as adding the relevent source code to the project.
\ No newline at end of file
diff --git a/deps/crypto/aes.c b/deps/crypto/aes.c
deleted file mode 100644 (file)
index c572839..0000000
+++ /dev/null
@@ -1,1095 +0,0 @@
-/*********************************************************************
-* Filename:   aes.c
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    This code is the implementation of the AES algorithm and
-              the CTR, CBC, and CCM modes of operation it can be used in.
-               AES is, specified by the NIST in in publication FIPS PUB 197,
-              availible at:
-               * http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf .
-              The CBC and CTR modes of operation are specified by
-              NIST SP 800-38 A, available at:
-               * http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf .
-              The CCM mode of operation is specified by NIST SP80-38 C, available at:
-               * http://csrc.nist.gov/publications/nistpubs/800-38C/SP800-38C_updated-July20_2007.pdf
-*********************************************************************/
-
-/*************************** HEADER FILES ***************************/
-#include <stdlib.h>
-#include <string.h>
-#include "aes.h"
-
-#include <stdio.h>
-
-/****************************** MACROS ******************************/
-// The least significant byte of the word is rotated to the end.
-#define KE_ROTWORD(x) (((x) << 8) | ((x) >> 24))
-
-#define TRUE  1
-#define FALSE 0
-
-/**************************** DATA TYPES ****************************/
-#define AES_128_ROUNDS 10
-#define AES_192_ROUNDS 12
-#define AES_256_ROUNDS 14
-
-/*********************** FUNCTION DECLARATIONS **********************/
-void ccm_prepare_first_ctr_blk(BYTE counter[], const BYTE nonce[], int nonce_len, int payload_len_store_size);
-void ccm_prepare_first_format_blk(BYTE buf[], int assoc_len, int payload_len, int payload_len_store_size, int mac_len, const BYTE nonce[], int nonce_len);
-void ccm_format_assoc_data(BYTE buf[], int *end_of_buf, const BYTE assoc[], int assoc_len);
-void ccm_format_payload_data(BYTE buf[], int *end_of_buf, const BYTE payload[], int payload_len);
-
-/**************************** VARIABLES *****************************/
-// This is the specified AES SBox. To look up a substitution value, put the first
-// nibble in the first index (row) and the second nibble in the second index (column).
-static const BYTE aes_sbox[16][16] = {
-       {0x63,0x7C,0x77,0x7B,0xF2,0x6B,0x6F,0xC5,0x30,0x01,0x67,0x2B,0xFE,0xD7,0xAB,0x76},
-       {0xCA,0x82,0xC9,0x7D,0xFA,0x59,0x47,0xF0,0xAD,0xD4,0xA2,0xAF,0x9C,0xA4,0x72,0xC0},
-       {0xB7,0xFD,0x93,0x26,0x36,0x3F,0xF7,0xCC,0x34,0xA5,0xE5,0xF1,0x71,0xD8,0x31,0x15},
-       {0x04,0xC7,0x23,0xC3,0x18,0x96,0x05,0x9A,0x07,0x12,0x80,0xE2,0xEB,0x27,0xB2,0x75},
-       {0x09,0x83,0x2C,0x1A,0x1B,0x6E,0x5A,0xA0,0x52,0x3B,0xD6,0xB3,0x29,0xE3,0x2F,0x84},
-       {0x53,0xD1,0x00,0xED,0x20,0xFC,0xB1,0x5B,0x6A,0xCB,0xBE,0x39,0x4A,0x4C,0x58,0xCF},
-       {0xD0,0xEF,0xAA,0xFB,0x43,0x4D,0x33,0x85,0x45,0xF9,0x02,0x7F,0x50,0x3C,0x9F,0xA8},
-       {0x51,0xA3,0x40,0x8F,0x92,0x9D,0x38,0xF5,0xBC,0xB6,0xDA,0x21,0x10,0xFF,0xF3,0xD2},
-       {0xCD,0x0C,0x13,0xEC,0x5F,0x97,0x44,0x17,0xC4,0xA7,0x7E,0x3D,0x64,0x5D,0x19,0x73},
-       {0x60,0x81,0x4F,0xDC,0x22,0x2A,0x90,0x88,0x46,0xEE,0xB8,0x14,0xDE,0x5E,0x0B,0xDB},
-       {0xE0,0x32,0x3A,0x0A,0x49,0x06,0x24,0x5C,0xC2,0xD3,0xAC,0x62,0x91,0x95,0xE4,0x79},
-       {0xE7,0xC8,0x37,0x6D,0x8D,0xD5,0x4E,0xA9,0x6C,0x56,0xF4,0xEA,0x65,0x7A,0xAE,0x08},
-       {0xBA,0x78,0x25,0x2E,0x1C,0xA6,0xB4,0xC6,0xE8,0xDD,0x74,0x1F,0x4B,0xBD,0x8B,0x8A},
-       {0x70,0x3E,0xB5,0x66,0x48,0x03,0xF6,0x0E,0x61,0x35,0x57,0xB9,0x86,0xC1,0x1D,0x9E},
-       {0xE1,0xF8,0x98,0x11,0x69,0xD9,0x8E,0x94,0x9B,0x1E,0x87,0xE9,0xCE,0x55,0x28,0xDF},
-       {0x8C,0xA1,0x89,0x0D,0xBF,0xE6,0x42,0x68,0x41,0x99,0x2D,0x0F,0xB0,0x54,0xBB,0x16}
-};
-
-static const BYTE aes_invsbox[16][16] = {
-       {0x52,0x09,0x6A,0xD5,0x30,0x36,0xA5,0x38,0xBF,0x40,0xA3,0x9E,0x81,0xF3,0xD7,0xFB},
-       {0x7C,0xE3,0x39,0x82,0x9B,0x2F,0xFF,0x87,0x34,0x8E,0x43,0x44,0xC4,0xDE,0xE9,0xCB},
-       {0x54,0x7B,0x94,0x32,0xA6,0xC2,0x23,0x3D,0xEE,0x4C,0x95,0x0B,0x42,0xFA,0xC3,0x4E},
-       {0x08,0x2E,0xA1,0x66,0x28,0xD9,0x24,0xB2,0x76,0x5B,0xA2,0x49,0x6D,0x8B,0xD1,0x25},
-       {0x72,0xF8,0xF6,0x64,0x86,0x68,0x98,0x16,0xD4,0xA4,0x5C,0xCC,0x5D,0x65,0xB6,0x92},
-       {0x6C,0x70,0x48,0x50,0xFD,0xED,0xB9,0xDA,0x5E,0x15,0x46,0x57,0xA7,0x8D,0x9D,0x84},
-       {0x90,0xD8,0xAB,0x00,0x8C,0xBC,0xD3,0x0A,0xF7,0xE4,0x58,0x05,0xB8,0xB3,0x45,0x06},
-       {0xD0,0x2C,0x1E,0x8F,0xCA,0x3F,0x0F,0x02,0xC1,0xAF,0xBD,0x03,0x01,0x13,0x8A,0x6B},
-       {0x3A,0x91,0x11,0x41,0x4F,0x67,0xDC,0xEA,0x97,0xF2,0xCF,0xCE,0xF0,0xB4,0xE6,0x73},
-       {0x96,0xAC,0x74,0x22,0xE7,0xAD,0x35,0x85,0xE2,0xF9,0x37,0xE8,0x1C,0x75,0xDF,0x6E},
-       {0x47,0xF1,0x1A,0x71,0x1D,0x29,0xC5,0x89,0x6F,0xB7,0x62,0x0E,0xAA,0x18,0xBE,0x1B},
-       {0xFC,0x56,0x3E,0x4B,0xC6,0xD2,0x79,0x20,0x9A,0xDB,0xC0,0xFE,0x78,0xCD,0x5A,0xF4},
-       {0x1F,0xDD,0xA8,0x33,0x88,0x07,0xC7,0x31,0xB1,0x12,0x10,0x59,0x27,0x80,0xEC,0x5F},
-       {0x60,0x51,0x7F,0xA9,0x19,0xB5,0x4A,0x0D,0x2D,0xE5,0x7A,0x9F,0x93,0xC9,0x9C,0xEF},
-       {0xA0,0xE0,0x3B,0x4D,0xAE,0x2A,0xF5,0xB0,0xC8,0xEB,0xBB,0x3C,0x83,0x53,0x99,0x61},
-       {0x17,0x2B,0x04,0x7E,0xBA,0x77,0xD6,0x26,0xE1,0x69,0x14,0x63,0x55,0x21,0x0C,0x7D}
-};
-
-// This table stores pre-calculated values for all possible GF(2^8) calculations.This
-// table is only used by the (Inv)MixColumns steps.
-// USAGE: The second index (column) is the coefficient of multiplication. Only 7 different
-// coefficients are used: 0x01, 0x02, 0x03, 0x09, 0x0b, 0x0d, 0x0e, but multiplication by
-// 1 is negligible leaving only 6 coefficients. Each column of the table is devoted to one
-// of these coefficients, in the ascending order of value, from values 0x00 to 0xFF.
-static const BYTE gf_mul[256][6] = {
-       {0x00,0x00,0x00,0x00,0x00,0x00},{0x02,0x03,0x09,0x0b,0x0d,0x0e},
-       {0x04,0x06,0x12,0x16,0x1a,0x1c},{0x06,0x05,0x1b,0x1d,0x17,0x12},
-       {0x08,0x0c,0x24,0x2c,0x34,0x38},{0x0a,0x0f,0x2d,0x27,0x39,0x36},
-       {0x0c,0x0a,0x36,0x3a,0x2e,0x24},{0x0e,0x09,0x3f,0x31,0x23,0x2a},
-       {0x10,0x18,0x48,0x58,0x68,0x70},{0x12,0x1b,0x41,0x53,0x65,0x7e},
-       {0x14,0x1e,0x5a,0x4e,0x72,0x6c},{0x16,0x1d,0x53,0x45,0x7f,0x62},
-       {0x18,0x14,0x6c,0x74,0x5c,0x48},{0x1a,0x17,0x65,0x7f,0x51,0x46},
-       {0x1c,0x12,0x7e,0x62,0x46,0x54},{0x1e,0x11,0x77,0x69,0x4b,0x5a},
-       {0x20,0x30,0x90,0xb0,0xd0,0xe0},{0x22,0x33,0x99,0xbb,0xdd,0xee},
-       {0x24,0x36,0x82,0xa6,0xca,0xfc},{0x26,0x35,0x8b,0xad,0xc7,0xf2},
-       {0x28,0x3c,0xb4,0x9c,0xe4,0xd8},{0x2a,0x3f,0xbd,0x97,0xe9,0xd6},
-       {0x2c,0x3a,0xa6,0x8a,0xfe,0xc4},{0x2e,0x39,0xaf,0x81,0xf3,0xca},
-       {0x30,0x28,0xd8,0xe8,0xb8,0x90},{0x32,0x2b,0xd1,0xe3,0xb5,0x9e},
-       {0x34,0x2e,0xca,0xfe,0xa2,0x8c},{0x36,0x2d,0xc3,0xf5,0xaf,0x82},
-       {0x38,0x24,0xfc,0xc4,0x8c,0xa8},{0x3a,0x27,0xf5,0xcf,0x81,0xa6},
-       {0x3c,0x22,0xee,0xd2,0x96,0xb4},{0x3e,0x21,0xe7,0xd9,0x9b,0xba},
-       {0x40,0x60,0x3b,0x7b,0xbb,0xdb},{0x42,0x63,0x32,0x70,0xb6,0xd5},
-       {0x44,0x66,0x29,0x6d,0xa1,0xc7},{0x46,0x65,0x20,0x66,0xac,0xc9},
-       {0x48,0x6c,0x1f,0x57,0x8f,0xe3},{0x4a,0x6f,0x16,0x5c,0x82,0xed},
-       {0x4c,0x6a,0x0d,0x41,0x95,0xff},{0x4e,0x69,0x04,0x4a,0x98,0xf1},
-       {0x50,0x78,0x73,0x23,0xd3,0xab},{0x52,0x7b,0x7a,0x28,0xde,0xa5},
-       {0x54,0x7e,0x61,0x35,0xc9,0xb7},{0x56,0x7d,0x68,0x3e,0xc4,0xb9},
-       {0x58,0x74,0x57,0x0f,0xe7,0x93},{0x5a,0x77,0x5e,0x04,0xea,0x9d},
-       {0x5c,0x72,0x45,0x19,0xfd,0x8f},{0x5e,0x71,0x4c,0x12,0xf0,0x81},
-       {0x60,0x50,0xab,0xcb,0x6b,0x3b},{0x62,0x53,0xa2,0xc0,0x66,0x35},
-       {0x64,0x56,0xb9,0xdd,0x71,0x27},{0x66,0x55,0xb0,0xd6,0x7c,0x29},
-       {0x68,0x5c,0x8f,0xe7,0x5f,0x03},{0x6a,0x5f,0x86,0xec,0x52,0x0d},
-       {0x6c,0x5a,0x9d,0xf1,0x45,0x1f},{0x6e,0x59,0x94,0xfa,0x48,0x11},
-       {0x70,0x48,0xe3,0x93,0x03,0x4b},{0x72,0x4b,0xea,0x98,0x0e,0x45},
-       {0x74,0x4e,0xf1,0x85,0x19,0x57},{0x76,0x4d,0xf8,0x8e,0x14,0x59},
-       {0x78,0x44,0xc7,0xbf,0x37,0x73},{0x7a,0x47,0xce,0xb4,0x3a,0x7d},
-       {0x7c,0x42,0xd5,0xa9,0x2d,0x6f},{0x7e,0x41,0xdc,0xa2,0x20,0x61},
-       {0x80,0xc0,0x76,0xf6,0x6d,0xad},{0x82,0xc3,0x7f,0xfd,0x60,0xa3},
-       {0x84,0xc6,0x64,0xe0,0x77,0xb1},{0x86,0xc5,0x6d,0xeb,0x7a,0xbf},
-       {0x88,0xcc,0x52,0xda,0x59,0x95},{0x8a,0xcf,0x5b,0xd1,0x54,0x9b},
-       {0x8c,0xca,0x40,0xcc,0x43,0x89},{0x8e,0xc9,0x49,0xc7,0x4e,0x87},
-       {0x90,0xd8,0x3e,0xae,0x05,0xdd},{0x92,0xdb,0x37,0xa5,0x08,0xd3},
-       {0x94,0xde,0x2c,0xb8,0x1f,0xc1},{0x96,0xdd,0x25,0xb3,0x12,0xcf},
-       {0x98,0xd4,0x1a,0x82,0x31,0xe5},{0x9a,0xd7,0x13,0x89,0x3c,0xeb},
-       {0x9c,0xd2,0x08,0x94,0x2b,0xf9},{0x9e,0xd1,0x01,0x9f,0x26,0xf7},
-       {0xa0,0xf0,0xe6,0x46,0xbd,0x4d},{0xa2,0xf3,0xef,0x4d,0xb0,0x43},
-       {0xa4,0xf6,0xf4,0x50,0xa7,0x51},{0xa6,0xf5,0xfd,0x5b,0xaa,0x5f},
-       {0xa8,0xfc,0xc2,0x6a,0x89,0x75},{0xaa,0xff,0xcb,0x61,0x84,0x7b},
-       {0xac,0xfa,0xd0,0x7c,0x93,0x69},{0xae,0xf9,0xd9,0x77,0x9e,0x67},
-       {0xb0,0xe8,0xae,0x1e,0xd5,0x3d},{0xb2,0xeb,0xa7,0x15,0xd8,0x33},
-       {0xb4,0xee,0xbc,0x08,0xcf,0x21},{0xb6,0xed,0xb5,0x03,0xc2,0x2f},
-       {0xb8,0xe4,0x8a,0x32,0xe1,0x05},{0xba,0xe7,0x83,0x39,0xec,0x0b},
-       {0xbc,0xe2,0x98,0x24,0xfb,0x19},{0xbe,0xe1,0x91,0x2f,0xf6,0x17},
-       {0xc0,0xa0,0x4d,0x8d,0xd6,0x76},{0xc2,0xa3,0x44,0x86,0xdb,0x78},
-       {0xc4,0xa6,0x5f,0x9b,0xcc,0x6a},{0xc6,0xa5,0x56,0x90,0xc1,0x64},
-       {0xc8,0xac,0x69,0xa1,0xe2,0x4e},{0xca,0xaf,0x60,0xaa,0xef,0x40},
-       {0xcc,0xaa,0x7b,0xb7,0xf8,0x52},{0xce,0xa9,0x72,0xbc,0xf5,0x5c},
-       {0xd0,0xb8,0x05,0xd5,0xbe,0x06},{0xd2,0xbb,0x0c,0xde,0xb3,0x08},
-       {0xd4,0xbe,0x17,0xc3,0xa4,0x1a},{0xd6,0xbd,0x1e,0xc8,0xa9,0x14},
-       {0xd8,0xb4,0x21,0xf9,0x8a,0x3e},{0xda,0xb7,0x28,0xf2,0x87,0x30},
-       {0xdc,0xb2,0x33,0xef,0x90,0x22},{0xde,0xb1,0x3a,0xe4,0x9d,0x2c},
-       {0xe0,0x90,0xdd,0x3d,0x06,0x96},{0xe2,0x93,0xd4,0x36,0x0b,0x98},
-       {0xe4,0x96,0xcf,0x2b,0x1c,0x8a},{0xe6,0x95,0xc6,0x20,0x11,0x84},
-       {0xe8,0x9c,0xf9,0x11,0x32,0xae},{0xea,0x9f,0xf0,0x1a,0x3f,0xa0},
-       {0xec,0x9a,0xeb,0x07,0x28,0xb2},{0xee,0x99,0xe2,0x0c,0x25,0xbc},
-       {0xf0,0x88,0x95,0x65,0x6e,0xe6},{0xf2,0x8b,0x9c,0x6e,0x63,0xe8},
-       {0xf4,0x8e,0x87,0x73,0x74,0xfa},{0xf6,0x8d,0x8e,0x78,0x79,0xf4},
-       {0xf8,0x84,0xb1,0x49,0x5a,0xde},{0xfa,0x87,0xb8,0x42,0x57,0xd0},
-       {0xfc,0x82,0xa3,0x5f,0x40,0xc2},{0xfe,0x81,0xaa,0x54,0x4d,0xcc},
-       {0x1b,0x9b,0xec,0xf7,0xda,0x41},{0x19,0x98,0xe5,0xfc,0xd7,0x4f},
-       {0x1f,0x9d,0xfe,0xe1,0xc0,0x5d},{0x1d,0x9e,0xf7,0xea,0xcd,0x53},
-       {0x13,0x97,0xc8,0xdb,0xee,0x79},{0x11,0x94,0xc1,0xd0,0xe3,0x77},
-       {0x17,0x91,0xda,0xcd,0xf4,0x65},{0x15,0x92,0xd3,0xc6,0xf9,0x6b},
-       {0x0b,0x83,0xa4,0xaf,0xb2,0x31},{0x09,0x80,0xad,0xa4,0xbf,0x3f},
-       {0x0f,0x85,0xb6,0xb9,0xa8,0x2d},{0x0d,0x86,0xbf,0xb2,0xa5,0x23},
-       {0x03,0x8f,0x80,0x83,0x86,0x09},{0x01,0x8c,0x89,0x88,0x8b,0x07},
-       {0x07,0x89,0x92,0x95,0x9c,0x15},{0x05,0x8a,0x9b,0x9e,0x91,0x1b},
-       {0x3b,0xab,0x7c,0x47,0x0a,0xa1},{0x39,0xa8,0x75,0x4c,0x07,0xaf},
-       {0x3f,0xad,0x6e,0x51,0x10,0xbd},{0x3d,0xae,0x67,0x5a,0x1d,0xb3},
-       {0x33,0xa7,0x58,0x6b,0x3e,0x99},{0x31,0xa4,0x51,0x60,0x33,0x97},
-       {0x37,0xa1,0x4a,0x7d,0x24,0x85},{0x35,0xa2,0x43,0x76,0x29,0x8b},
-       {0x2b,0xb3,0x34,0x1f,0x62,0xd1},{0x29,0xb0,0x3d,0x14,0x6f,0xdf},
-       {0x2f,0xb5,0x26,0x09,0x78,0xcd},{0x2d,0xb6,0x2f,0x02,0x75,0xc3},
-       {0x23,0xbf,0x10,0x33,0x56,0xe9},{0x21,0xbc,0x19,0x38,0x5b,0xe7},
-       {0x27,0xb9,0x02,0x25,0x4c,0xf5},{0x25,0xba,0x0b,0x2e,0x41,0xfb},
-       {0x5b,0xfb,0xd7,0x8c,0x61,0x9a},{0x59,0xf8,0xde,0x87,0x6c,0x94},
-       {0x5f,0xfd,0xc5,0x9a,0x7b,0x86},{0x5d,0xfe,0xcc,0x91,0x76,0x88},
-       {0x53,0xf7,0xf3,0xa0,0x55,0xa2},{0x51,0xf4,0xfa,0xab,0x58,0xac},
-       {0x57,0xf1,0xe1,0xb6,0x4f,0xbe},{0x55,0xf2,0xe8,0xbd,0x42,0xb0},
-       {0x4b,0xe3,0x9f,0xd4,0x09,0xea},{0x49,0xe0,0x96,0xdf,0x04,0xe4},
-       {0x4f,0xe5,0x8d,0xc2,0x13,0xf6},{0x4d,0xe6,0x84,0xc9,0x1e,0xf8},
-       {0x43,0xef,0xbb,0xf8,0x3d,0xd2},{0x41,0xec,0xb2,0xf3,0x30,0xdc},
-       {0x47,0xe9,0xa9,0xee,0x27,0xce},{0x45,0xea,0xa0,0xe5,0x2a,0xc0},
-       {0x7b,0xcb,0x47,0x3c,0xb1,0x7a},{0x79,0xc8,0x4e,0x37,0xbc,0x74},
-       {0x7f,0xcd,0x55,0x2a,0xab,0x66},{0x7d,0xce,0x5c,0x21,0xa6,0x68},
-       {0x73,0xc7,0x63,0x10,0x85,0x42},{0x71,0xc4,0x6a,0x1b,0x88,0x4c},
-       {0x77,0xc1,0x71,0x06,0x9f,0x5e},{0x75,0xc2,0x78,0x0d,0x92,0x50},
-       {0x6b,0xd3,0x0f,0x64,0xd9,0x0a},{0x69,0xd0,0x06,0x6f,0xd4,0x04},
-       {0x6f,0xd5,0x1d,0x72,0xc3,0x16},{0x6d,0xd6,0x14,0x79,0xce,0x18},
-       {0x63,0xdf,0x2b,0x48,0xed,0x32},{0x61,0xdc,0x22,0x43,0xe0,0x3c},
-       {0x67,0xd9,0x39,0x5e,0xf7,0x2e},{0x65,0xda,0x30,0x55,0xfa,0x20},
-       {0x9b,0x5b,0x9a,0x01,0xb7,0xec},{0x99,0x58,0x93,0x0a,0xba,0xe2},
-       {0x9f,0x5d,0x88,0x17,0xad,0xf0},{0x9d,0x5e,0x81,0x1c,0xa0,0xfe},
-       {0x93,0x57,0xbe,0x2d,0x83,0xd4},{0x91,0x54,0xb7,0x26,0x8e,0xda},
-       {0x97,0x51,0xac,0x3b,0x99,0xc8},{0x95,0x52,0xa5,0x30,0x94,0xc6},
-       {0x8b,0x43,0xd2,0x59,0xdf,0x9c},{0x89,0x40,0xdb,0x52,0xd2,0x92},
-       {0x8f,0x45,0xc0,0x4f,0xc5,0x80},{0x8d,0x46,0xc9,0x44,0xc8,0x8e},
-       {0x83,0x4f,0xf6,0x75,0xeb,0xa4},{0x81,0x4c,0xff,0x7e,0xe6,0xaa},
-       {0x87,0x49,0xe4,0x63,0xf1,0xb8},{0x85,0x4a,0xed,0x68,0xfc,0xb6},
-       {0xbb,0x6b,0x0a,0xb1,0x67,0x0c},{0xb9,0x68,0x03,0xba,0x6a,0x02},
-       {0xbf,0x6d,0x18,0xa7,0x7d,0x10},{0xbd,0x6e,0x11,0xac,0x70,0x1e},
-       {0xb3,0x67,0x2e,0x9d,0x53,0x34},{0xb1,0x64,0x27,0x96,0x5e,0x3a},
-       {0xb7,0x61,0x3c,0x8b,0x49,0x28},{0xb5,0x62,0x35,0x80,0x44,0x26},
-       {0xab,0x73,0x42,0xe9,0x0f,0x7c},{0xa9,0x70,0x4b,0xe2,0x02,0x72},
-       {0xaf,0x75,0x50,0xff,0x15,0x60},{0xad,0x76,0x59,0xf4,0x18,0x6e},
-       {0xa3,0x7f,0x66,0xc5,0x3b,0x44},{0xa1,0x7c,0x6f,0xce,0x36,0x4a},
-       {0xa7,0x79,0x74,0xd3,0x21,0x58},{0xa5,0x7a,0x7d,0xd8,0x2c,0x56},
-       {0xdb,0x3b,0xa1,0x7a,0x0c,0x37},{0xd9,0x38,0xa8,0x71,0x01,0x39},
-       {0xdf,0x3d,0xb3,0x6c,0x16,0x2b},{0xdd,0x3e,0xba,0x67,0x1b,0x25},
-       {0xd3,0x37,0x85,0x56,0x38,0x0f},{0xd1,0x34,0x8c,0x5d,0x35,0x01},
-       {0xd7,0x31,0x97,0x40,0x22,0x13},{0xd5,0x32,0x9e,0x4b,0x2f,0x1d},
-       {0xcb,0x23,0xe9,0x22,0x64,0x47},{0xc9,0x20,0xe0,0x29,0x69,0x49},
-       {0xcf,0x25,0xfb,0x34,0x7e,0x5b},{0xcd,0x26,0xf2,0x3f,0x73,0x55},
-       {0xc3,0x2f,0xcd,0x0e,0x50,0x7f},{0xc1,0x2c,0xc4,0x05,0x5d,0x71},
-       {0xc7,0x29,0xdf,0x18,0x4a,0x63},{0xc5,0x2a,0xd6,0x13,0x47,0x6d},
-       {0xfb,0x0b,0x31,0xca,0xdc,0xd7},{0xf9,0x08,0x38,0xc1,0xd1,0xd9},
-       {0xff,0x0d,0x23,0xdc,0xc6,0xcb},{0xfd,0x0e,0x2a,0xd7,0xcb,0xc5},
-       {0xf3,0x07,0x15,0xe6,0xe8,0xef},{0xf1,0x04,0x1c,0xed,0xe5,0xe1},
-       {0xf7,0x01,0x07,0xf0,0xf2,0xf3},{0xf5,0x02,0x0e,0xfb,0xff,0xfd},
-       {0xeb,0x13,0x79,0x92,0xb4,0xa7},{0xe9,0x10,0x70,0x99,0xb9,0xa9},
-       {0xef,0x15,0x6b,0x84,0xae,0xbb},{0xed,0x16,0x62,0x8f,0xa3,0xb5},
-       {0xe3,0x1f,0x5d,0xbe,0x80,0x9f},{0xe1,0x1c,0x54,0xb5,0x8d,0x91},
-       {0xe7,0x19,0x4f,0xa8,0x9a,0x83},{0xe5,0x1a,0x46,0xa3,0x97,0x8d}
-};
-
-/*********************** FUNCTION DEFINITIONS ***********************/
-// XORs the in and out buffers, storing the result in out. Length is in bytes.
-void xor_buf(const BYTE in[], BYTE out[], size_t len)
-{
-       size_t idx;
-
-       for (idx = 0; idx < len; idx++)
-               out[idx] ^= in[idx];
-}
-
-/*******************
-* AES - CBC
-*******************/
-int aes_encrypt_cbc(const BYTE in[], size_t in_len, BYTE out[], const WORD key[], int keysize, const BYTE iv[])
-{
-       BYTE buf_in[AES_BLOCK_SIZE], buf_out[AES_BLOCK_SIZE], iv_buf[AES_BLOCK_SIZE];
-       int blocks, idx;
-
-       if (in_len % AES_BLOCK_SIZE != 0)
-               return(FALSE);
-
-       blocks = in_len / AES_BLOCK_SIZE;
-
-       memcpy(iv_buf, iv, AES_BLOCK_SIZE);
-
-       for (idx = 0; idx < blocks; idx++) {
-               memcpy(buf_in, &in[idx * AES_BLOCK_SIZE], AES_BLOCK_SIZE);
-               xor_buf(iv_buf, buf_in, AES_BLOCK_SIZE);
-               aes_encrypt(buf_in, buf_out, key, keysize);
-               memcpy(&out[idx * AES_BLOCK_SIZE], buf_out, AES_BLOCK_SIZE);
-               memcpy(iv_buf, buf_out, AES_BLOCK_SIZE);
-       }
-
-       return(TRUE);
-}
-
-int aes_encrypt_cbc_mac(const BYTE in[], size_t in_len, BYTE out[], const WORD key[], int keysize, const BYTE iv[])
-{
-       BYTE buf_in[AES_BLOCK_SIZE], buf_out[AES_BLOCK_SIZE], iv_buf[AES_BLOCK_SIZE];
-       int blocks, idx;
-
-       if (in_len % AES_BLOCK_SIZE != 0)
-               return(FALSE);
-
-       blocks = in_len / AES_BLOCK_SIZE;
-
-       memcpy(iv_buf, iv, AES_BLOCK_SIZE);
-
-       for (idx = 0; idx < blocks; idx++) {
-               memcpy(buf_in, &in[idx * AES_BLOCK_SIZE], AES_BLOCK_SIZE);
-               xor_buf(iv_buf, buf_in, AES_BLOCK_SIZE);
-               aes_encrypt(buf_in, buf_out, key, keysize);
-               memcpy(iv_buf, buf_out, AES_BLOCK_SIZE);
-               // Do not output all encrypted blocks.
-       }
-
-       memcpy(out, buf_out, AES_BLOCK_SIZE);   // Only output the last block.
-
-       return(TRUE);
-}
-
-int aes_decrypt_cbc(const BYTE in[], size_t in_len, BYTE out[], const WORD key[], int keysize, const BYTE iv[])
-{
-       BYTE buf_in[AES_BLOCK_SIZE], buf_out[AES_BLOCK_SIZE], iv_buf[AES_BLOCK_SIZE];
-       int blocks, idx;
-
-       if (in_len % AES_BLOCK_SIZE != 0)
-               return(FALSE);
-
-       blocks = in_len / AES_BLOCK_SIZE;
-
-       memcpy(iv_buf, iv, AES_BLOCK_SIZE);
-
-       for (idx = 0; idx < blocks; idx++) {
-               memcpy(buf_in, &in[idx * AES_BLOCK_SIZE], AES_BLOCK_SIZE);
-               aes_decrypt(buf_in, buf_out, key, keysize);
-               xor_buf(iv_buf, buf_out, AES_BLOCK_SIZE);
-               memcpy(&out[idx * AES_BLOCK_SIZE], buf_out, AES_BLOCK_SIZE);
-               memcpy(iv_buf, buf_in, AES_BLOCK_SIZE);
-       }
-
-       return(TRUE);
-}
-
-/*******************
-* AES - CTR
-*******************/
-void increment_iv(BYTE iv[], int counter_size)
-{
-       int idx;
-
-       // Use counter_size bytes at the end of the IV as the big-endian integer to increment.
-       for (idx = AES_BLOCK_SIZE - 1; idx >= AES_BLOCK_SIZE - counter_size; idx--) {
-               iv[idx]++;
-               if (iv[idx] != 0 || idx == AES_BLOCK_SIZE - counter_size)
-                       break;
-       }
-}
-
-// Performs the encryption in-place, the input and output buffers may be the same.
-// Input may be an arbitrary length (in bytes).
-void aes_encrypt_ctr(const BYTE in[], size_t in_len, BYTE out[], const WORD key[], int keysize, const BYTE iv[])
-{
-       size_t idx = 0, last_block_length;
-       BYTE iv_buf[AES_BLOCK_SIZE], out_buf[AES_BLOCK_SIZE];
-
-       if (in != out)
-               memcpy(out, in, in_len);
-
-       memcpy(iv_buf, iv, AES_BLOCK_SIZE);
-       last_block_length = in_len - AES_BLOCK_SIZE;
-
-       if (in_len > AES_BLOCK_SIZE) {
-               for (idx = 0; idx < last_block_length; idx += AES_BLOCK_SIZE) {
-                       aes_encrypt(iv_buf, out_buf, key, keysize);
-                       xor_buf(out_buf, &out[idx], AES_BLOCK_SIZE);
-                       increment_iv(iv_buf, AES_BLOCK_SIZE);
-               }
-       }
-
-       aes_encrypt(iv_buf, out_buf, key, keysize);
-       xor_buf(out_buf, &out[idx], in_len - idx);   // Use the Most Significant bytes.
-}
-
-void aes_decrypt_ctr(const BYTE in[], size_t in_len, BYTE out[], const WORD key[], int keysize, const BYTE iv[])
-{
-       // CTR encryption is its own inverse function.
-       aes_encrypt_ctr(in, in_len, out, key, keysize, iv);
-}
-
-/*******************
-* AES - CCM
-*******************/
-// out_len = payload_len + assoc_len
-int aes_encrypt_ccm(const BYTE payload[], WORD payload_len, const BYTE assoc[], unsigned short assoc_len,
-                    const BYTE nonce[], unsigned short nonce_len, BYTE out[], WORD *out_len,
-                    WORD mac_len, const BYTE key_str[], int keysize)
-{
-       BYTE temp_iv[AES_BLOCK_SIZE], counter[AES_BLOCK_SIZE], mac[16], *buf;
-       int end_of_buf, payload_len_store_size;
-       WORD key[60];
-
-       if (mac_len != 4 && mac_len != 6 && mac_len != 8 && mac_len != 10 &&
-          mac_len != 12 && mac_len != 14 && mac_len != 16)
-               return(FALSE);
-
-       if (nonce_len < 7 || nonce_len > 13)
-               return(FALSE);
-
-       if (assoc_len > 32768 /* = 2^15 */)
-               return(FALSE);
-
-       buf = (BYTE*)malloc(payload_len + assoc_len + 48 /*Round both payload and associated data up a block size and add an extra block.*/);
-       if (! buf)
-               return(FALSE);
-
-       // Prepare the key for usage.
-       aes_key_setup(key_str, key, keysize);
-
-       // Format the first block of the formatted data.
-       payload_len_store_size = AES_BLOCK_SIZE - 1 - nonce_len;
-       ccm_prepare_first_format_blk(buf, assoc_len, payload_len, payload_len_store_size, mac_len, nonce, nonce_len);
-       end_of_buf = AES_BLOCK_SIZE;
-
-       // Format the Associated Data, aka, assoc[].
-       ccm_format_assoc_data(buf, &end_of_buf, assoc, assoc_len);
-
-       // Format the Payload, aka payload[].
-       ccm_format_payload_data(buf, &end_of_buf, payload, payload_len);
-
-       // Create the first counter block.
-       ccm_prepare_first_ctr_blk(counter, nonce, nonce_len, payload_len_store_size);
-
-       // Perform the CBC operation with an IV of zeros on the formatted buffer to calculate the MAC.
-       memset(temp_iv, 0, AES_BLOCK_SIZE);
-       aes_encrypt_cbc_mac(buf, end_of_buf, mac, key, keysize, temp_iv);
-
-       // Copy the Payload and MAC to the output buffer.
-       memcpy(out, payload, payload_len);
-       memcpy(&out[payload_len], mac, mac_len);
-
-       // Encrypt the Payload with CTR mode with a counter starting at 1.
-       memcpy(temp_iv, counter, AES_BLOCK_SIZE);
-       increment_iv(temp_iv, AES_BLOCK_SIZE - 1 - mac_len);   // Last argument is the byte size of the counting portion of the counter block. /*BUG?*/
-       aes_encrypt_ctr(out, payload_len, out, key, keysize, temp_iv);
-
-       // Encrypt the MAC with CTR mode with a counter starting at 0.
-       aes_encrypt_ctr(&out[payload_len], mac_len, &out[payload_len], key, keysize, counter);
-
-       free(buf);
-       *out_len = payload_len + mac_len;
-
-       return(TRUE);
-}
-
-// plaintext_len = ciphertext_len - mac_len
-// Needs a flag for whether the MAC matches.
-int aes_decrypt_ccm(const BYTE ciphertext[], WORD ciphertext_len, const BYTE assoc[], unsigned short assoc_len,
-                    const BYTE nonce[], unsigned short nonce_len, BYTE plaintext[], WORD *plaintext_len,
-                    WORD mac_len, int *mac_auth, const BYTE key_str[], int keysize)
-{
-       BYTE temp_iv[AES_BLOCK_SIZE], counter[AES_BLOCK_SIZE], mac[16], mac_buf[16], *buf;
-       int end_of_buf, plaintext_len_store_size;
-       WORD key[60];
-
-       if (ciphertext_len <= mac_len)
-               return(FALSE);
-
-       buf = (BYTE*)malloc(assoc_len + ciphertext_len /*ciphertext_len = plaintext_len + mac_len*/ + 48);
-       if (! buf)
-               return(FALSE);
-
-       // Prepare the key for usage.
-       aes_key_setup(key_str, key, keysize);
-
-       // Copy the plaintext and MAC to the output buffers.
-       *plaintext_len = ciphertext_len - mac_len;
-       plaintext_len_store_size = AES_BLOCK_SIZE - 1 - nonce_len;
-       memcpy(plaintext, ciphertext, *plaintext_len);
-       memcpy(mac, &ciphertext[*plaintext_len], mac_len);
-
-       // Prepare the first counter block for use in decryption.
-       ccm_prepare_first_ctr_blk(counter, nonce, nonce_len, plaintext_len_store_size);
-
-       // Decrypt the Payload with CTR mode with a counter starting at 1.
-       memcpy(temp_iv, counter, AES_BLOCK_SIZE);
-       increment_iv(temp_iv, AES_BLOCK_SIZE - 1 - mac_len);   // (AES_BLOCK_SIZE - 1 - mac_len) is the byte size of the counting portion of the counter block.
-       aes_decrypt_ctr(plaintext, *plaintext_len, plaintext, key, keysize, temp_iv);
-
-       // Setting mac_auth to NULL disables the authentication check.
-       if (mac_auth != NULL) {
-               // Decrypt the MAC with CTR mode with a counter starting at 0.
-               aes_decrypt_ctr(mac, mac_len, mac, key, keysize, counter);
-
-               // Format the first block of the formatted data.
-               plaintext_len_store_size = AES_BLOCK_SIZE - 1 - nonce_len;
-               ccm_prepare_first_format_blk(buf, assoc_len, *plaintext_len, plaintext_len_store_size, mac_len, nonce, nonce_len);
-               end_of_buf = AES_BLOCK_SIZE;
-
-               // Format the Associated Data into the authentication buffer.
-               ccm_format_assoc_data(buf, &end_of_buf, assoc, assoc_len);
-
-               // Format the Payload into the authentication buffer.
-               ccm_format_payload_data(buf, &end_of_buf, plaintext, *plaintext_len);
-
-               // Perform the CBC operation with an IV of zeros on the formatted buffer to calculate the MAC.
-               memset(temp_iv, 0, AES_BLOCK_SIZE);
-               aes_encrypt_cbc_mac(buf, end_of_buf, mac_buf, key, keysize, temp_iv);
-
-               // Compare the calculated MAC against the MAC embedded in the ciphertext to see if they are the same.
-               if (! memcmp(mac, mac_buf, mac_len)) {
-                       *mac_auth = TRUE;
-               }
-               else {
-                       *mac_auth = FALSE;
-                       memset(plaintext, 0, *plaintext_len);
-               }
-       }
-
-       free(buf);
-
-       return(TRUE);
-}
-
-// Creates the first counter block. First byte is flags, then the nonce, then the incremented part.
-void ccm_prepare_first_ctr_blk(BYTE counter[], const BYTE nonce[], int nonce_len, int payload_len_store_size)
-{
-       memset(counter, 0, AES_BLOCK_SIZE);
-       counter[0] = (payload_len_store_size - 1) & 0x07;
-       memcpy(&counter[1], nonce, nonce_len);
-}
-
-void ccm_prepare_first_format_blk(BYTE buf[], int assoc_len, int payload_len, int payload_len_store_size, int mac_len, const BYTE nonce[], int nonce_len)
-{
-       // Set the flags for the first byte of the first block.
-       buf[0] = ((((mac_len - 2) / 2) & 0x07) << 3) | ((payload_len_store_size - 1) & 0x07);
-       if (assoc_len > 0)
-               buf[0] += 0x40;
-       // Format the rest of the first block, storing the nonce and the size of the payload.
-       memcpy(&buf[1], nonce, nonce_len);
-       memset(&buf[1 + nonce_len], 0, AES_BLOCK_SIZE - 1 - nonce_len);
-       buf[15] = payload_len & 0x000000FF;
-       buf[14] = (payload_len >> 8) & 0x000000FF;
-}
-
-void ccm_format_assoc_data(BYTE buf[], int *end_of_buf, const BYTE assoc[], int assoc_len)
-{
-       int pad;
-
-       buf[*end_of_buf + 1] = assoc_len & 0x00FF;
-       buf[*end_of_buf] = (assoc_len >> 8) & 0x00FF;
-       *end_of_buf += 2;
-       memcpy(&buf[*end_of_buf], assoc, assoc_len);
-       *end_of_buf += assoc_len;
-       pad = AES_BLOCK_SIZE - (*end_of_buf % AES_BLOCK_SIZE); /*BUG?*/
-       memset(&buf[*end_of_buf], 0, pad);
-       *end_of_buf += pad;
-}
-
-void ccm_format_payload_data(BYTE buf[], int *end_of_buf, const BYTE payload[], int payload_len)
-{
-       int pad;
-
-       memcpy(&buf[*end_of_buf], payload, payload_len);
-       *end_of_buf += payload_len;
-       pad = *end_of_buf % AES_BLOCK_SIZE;
-       if (pad != 0)
-               pad = AES_BLOCK_SIZE - pad;
-       memset(&buf[*end_of_buf], 0, pad);
-       *end_of_buf += pad;
-}
-
-/*******************
-* AES
-*******************/
-/////////////////
-// KEY EXPANSION
-/////////////////
-
-// Substitutes a word using the AES S-Box.
-WORD SubWord(WORD word)
-{
-       unsigned int result;
-
-       result = (int)aes_sbox[(word >> 4) & 0x0000000F][word & 0x0000000F];
-       result += (int)aes_sbox[(word >> 12) & 0x0000000F][(word >> 8) & 0x0000000F] << 8;
-       result += (int)aes_sbox[(word >> 20) & 0x0000000F][(word >> 16) & 0x0000000F] << 16;
-       result += (int)aes_sbox[(word >> 28) & 0x0000000F][(word >> 24) & 0x0000000F] << 24;
-       return(result);
-}
-
-// Performs the action of generating the keys that will be used in every round of
-// encryption. "key" is the user-supplied input key, "w" is the output key schedule,
-// "keysize" is the length in bits of "key", must be 128, 192, or 256.
-void aes_key_setup(const BYTE key[], WORD w[], int keysize)
-{
-       int Nb=4,Nr,Nk,idx;
-       WORD temp,Rcon[]={0x01000000,0x02000000,0x04000000,0x08000000,0x10000000,0x20000000,
-                         0x40000000,0x80000000,0x1b000000,0x36000000,0x6c000000,0xd8000000,
-                         0xab000000,0x4d000000,0x9a000000};
-
-       switch (keysize) {
-               case 128: Nr = 10; Nk = 4; break;
-               case 192: Nr = 12; Nk = 6; break;
-               case 256: Nr = 14; Nk = 8; break;
-               default: return;
-       }
-
-       for (idx=0; idx < Nk; ++idx) {
-               w[idx] = ((key[4 * idx]) << 24) | ((key[4 * idx + 1]) << 16) |
-                                  ((key[4 * idx + 2]) << 8) | ((key[4 * idx + 3]));
-       }
-
-       for (idx = Nk; idx < Nb * (Nr+1); ++idx) {
-               temp = w[idx - 1];
-               if ((idx % Nk) == 0)
-                       temp = SubWord(KE_ROTWORD(temp)) ^ Rcon[(idx-1)/Nk];
-               else if (Nk > 6 && (idx % Nk) == 4)
-                       temp = SubWord(temp);
-               w[idx] = w[idx-Nk] ^ temp;
-       }
-}
-
-/////////////////
-// ADD ROUND KEY
-/////////////////
-
-// Performs the AddRoundKey step. Each round has its own pre-generated 16-byte key in the
-// form of 4 integers (the "w" array). Each integer is XOR'd by one column of the state.
-// Also performs the job of InvAddRoundKey(); since the function is a simple XOR process,
-// it is its own inverse.
-void AddRoundKey(BYTE state[][4], const WORD w[])
-{
-       BYTE subkey[4];
-
-       // memcpy(subkey,&w[idx],4); // Not accurate for big endian machines
-       // Subkey 1
-       subkey[0] = w[0] >> 24;
-       subkey[1] = w[0] >> 16;
-       subkey[2] = w[0] >> 8;
-       subkey[3] = w[0];
-       state[0][0] ^= subkey[0];
-       state[1][0] ^= subkey[1];
-       state[2][0] ^= subkey[2];
-       state[3][0] ^= subkey[3];
-       // Subkey 2
-       subkey[0] = w[1] >> 24;
-       subkey[1] = w[1] >> 16;
-       subkey[2] = w[1] >> 8;
-       subkey[3] = w[1];
-       state[0][1] ^= subkey[0];
-       state[1][1] ^= subkey[1];
-       state[2][1] ^= subkey[2];
-       state[3][1] ^= subkey[3];
-       // Subkey 3
-       subkey[0] = w[2] >> 24;
-       subkey[1] = w[2] >> 16;
-       subkey[2] = w[2] >> 8;
-       subkey[3] = w[2];
-       state[0][2] ^= subkey[0];
-       state[1][2] ^= subkey[1];
-       state[2][2] ^= subkey[2];
-       state[3][2] ^= subkey[3];
-       // Subkey 4
-       subkey[0] = w[3] >> 24;
-       subkey[1] = w[3] >> 16;
-       subkey[2] = w[3] >> 8;
-       subkey[3] = w[3];
-       state[0][3] ^= subkey[0];
-       state[1][3] ^= subkey[1];
-       state[2][3] ^= subkey[2];
-       state[3][3] ^= subkey[3];
-}
-
-/////////////////
-// (Inv)SubBytes
-/////////////////
-
-// Performs the SubBytes step. All bytes in the state are substituted with a
-// pre-calculated value from a lookup table.
-void SubBytes(BYTE state[][4])
-{
-       state[0][0] = aes_sbox[state[0][0] >> 4][state[0][0] & 0x0F];
-       state[0][1] = aes_sbox[state[0][1] >> 4][state[0][1] & 0x0F];
-       state[0][2] = aes_sbox[state[0][2] >> 4][state[0][2] & 0x0F];
-       state[0][3] = aes_sbox[state[0][3] >> 4][state[0][3] & 0x0F];
-       state[1][0] = aes_sbox[state[1][0] >> 4][state[1][0] & 0x0F];
-       state[1][1] = aes_sbox[state[1][1] >> 4][state[1][1] & 0x0F];
-       state[1][2] = aes_sbox[state[1][2] >> 4][state[1][2] & 0x0F];
-       state[1][3] = aes_sbox[state[1][3] >> 4][state[1][3] & 0x0F];
-       state[2][0] = aes_sbox[state[2][0] >> 4][state[2][0] & 0x0F];
-       state[2][1] = aes_sbox[state[2][1] >> 4][state[2][1] & 0x0F];
-       state[2][2] = aes_sbox[state[2][2] >> 4][state[2][2] & 0x0F];
-       state[2][3] = aes_sbox[state[2][3] >> 4][state[2][3] & 0x0F];
-       state[3][0] = aes_sbox[state[3][0] >> 4][state[3][0] & 0x0F];
-       state[3][1] = aes_sbox[state[3][1] >> 4][state[3][1] & 0x0F];
-       state[3][2] = aes_sbox[state[3][2] >> 4][state[3][2] & 0x0F];
-       state[3][3] = aes_sbox[state[3][3] >> 4][state[3][3] & 0x0F];
-}
-
-void InvSubBytes(BYTE state[][4])
-{
-       state[0][0] = aes_invsbox[state[0][0] >> 4][state[0][0] & 0x0F];
-       state[0][1] = aes_invsbox[state[0][1] >> 4][state[0][1] & 0x0F];
-       state[0][2] = aes_invsbox[state[0][2] >> 4][state[0][2] & 0x0F];
-       state[0][3] = aes_invsbox[state[0][3] >> 4][state[0][3] & 0x0F];
-       state[1][0] = aes_invsbox[state[1][0] >> 4][state[1][0] & 0x0F];
-       state[1][1] = aes_invsbox[state[1][1] >> 4][state[1][1] & 0x0F];
-       state[1][2] = aes_invsbox[state[1][2] >> 4][state[1][2] & 0x0F];
-       state[1][3] = aes_invsbox[state[1][3] >> 4][state[1][3] & 0x0F];
-       state[2][0] = aes_invsbox[state[2][0] >> 4][state[2][0] & 0x0F];
-       state[2][1] = aes_invsbox[state[2][1] >> 4][state[2][1] & 0x0F];
-       state[2][2] = aes_invsbox[state[2][2] >> 4][state[2][2] & 0x0F];
-       state[2][3] = aes_invsbox[state[2][3] >> 4][state[2][3] & 0x0F];
-       state[3][0] = aes_invsbox[state[3][0] >> 4][state[3][0] & 0x0F];
-       state[3][1] = aes_invsbox[state[3][1] >> 4][state[3][1] & 0x0F];
-       state[3][2] = aes_invsbox[state[3][2] >> 4][state[3][2] & 0x0F];
-       state[3][3] = aes_invsbox[state[3][3] >> 4][state[3][3] & 0x0F];
-}
-
-/////////////////
-// (Inv)ShiftRows
-/////////////////
-
-// Performs the ShiftRows step. All rows are shifted cylindrically to the left.
-void ShiftRows(BYTE state[][4])
-{
-       int t;
-
-       // Shift left by 1
-       t = state[1][0];
-       state[1][0] = state[1][1];
-       state[1][1] = state[1][2];
-       state[1][2] = state[1][3];
-       state[1][3] = t;
-       // Shift left by 2
-       t = state[2][0];
-       state[2][0] = state[2][2];
-       state[2][2] = t;
-       t = state[2][1];
-       state[2][1] = state[2][3];
-       state[2][3] = t;
-       // Shift left by 3
-       t = state[3][0];
-       state[3][0] = state[3][3];
-       state[3][3] = state[3][2];
-       state[3][2] = state[3][1];
-       state[3][1] = t;
-}
-
-// All rows are shifted cylindrically to the right.
-void InvShiftRows(BYTE state[][4])
-{
-       int t;
-
-       // Shift right by 1
-       t = state[1][3];
-       state[1][3] = state[1][2];
-       state[1][2] = state[1][1];
-       state[1][1] = state[1][0];
-       state[1][0] = t;
-       // Shift right by 2
-       t = state[2][3];
-       state[2][3] = state[2][1];
-       state[2][1] = t;
-       t = state[2][2];
-       state[2][2] = state[2][0];
-       state[2][0] = t;
-       // Shift right by 3
-       t = state[3][3];
-       state[3][3] = state[3][0];
-       state[3][0] = state[3][1];
-       state[3][1] = state[3][2];
-       state[3][2] = t;
-}
-
-/////////////////
-// (Inv)MixColumns
-/////////////////
-
-// Performs the MixColums step. The state is multiplied by itself using matrix
-// multiplication in a Galios Field 2^8. All multiplication is pre-computed in a table.
-// Addition is equivilent to XOR. (Must always make a copy of the column as the original
-// values will be destoyed.)
-void MixColumns(BYTE state[][4])
-{
-       BYTE col[4];
-
-       // Column 1
-       col[0] = state[0][0];
-       col[1] = state[1][0];
-       col[2] = state[2][0];
-       col[3] = state[3][0];
-       state[0][0] = gf_mul[col[0]][0];
-       state[0][0] ^= gf_mul[col[1]][1];
-       state[0][0] ^= col[2];
-       state[0][0] ^= col[3];
-       state[1][0] = col[0];
-       state[1][0] ^= gf_mul[col[1]][0];
-       state[1][0] ^= gf_mul[col[2]][1];
-       state[1][0] ^= col[3];
-       state[2][0] = col[0];
-       state[2][0] ^= col[1];
-       state[2][0] ^= gf_mul[col[2]][0];
-       state[2][0] ^= gf_mul[col[3]][1];
-       state[3][0] = gf_mul[col[0]][1];
-       state[3][0] ^= col[1];
-       state[3][0] ^= col[2];
-       state[3][0] ^= gf_mul[col[3]][0];
-       // Column 2
-       col[0] = state[0][1];
-       col[1] = state[1][1];
-       col[2] = state[2][1];
-       col[3] = state[3][1];
-       state[0][1] = gf_mul[col[0]][0];
-       state[0][1] ^= gf_mul[col[1]][1];
-       state[0][1] ^= col[2];
-       state[0][1] ^= col[3];
-       state[1][1] = col[0];
-       state[1][1] ^= gf_mul[col[1]][0];
-       state[1][1] ^= gf_mul[col[2]][1];
-       state[1][1] ^= col[3];
-       state[2][1] = col[0];
-       state[2][1] ^= col[1];
-       state[2][1] ^= gf_mul[col[2]][0];
-       state[2][1] ^= gf_mul[col[3]][1];
-       state[3][1] = gf_mul[col[0]][1];
-       state[3][1] ^= col[1];
-       state[3][1] ^= col[2];
-       state[3][1] ^= gf_mul[col[3]][0];
-       // Column 3
-       col[0] = state[0][2];
-       col[1] = state[1][2];
-       col[2] = state[2][2];
-       col[3] = state[3][2];
-       state[0][2] = gf_mul[col[0]][0];
-       state[0][2] ^= gf_mul[col[1]][1];
-       state[0][2] ^= col[2];
-       state[0][2] ^= col[3];
-       state[1][2] = col[0];
-       state[1][2] ^= gf_mul[col[1]][0];
-       state[1][2] ^= gf_mul[col[2]][1];
-       state[1][2] ^= col[3];
-       state[2][2] = col[0];
-       state[2][2] ^= col[1];
-       state[2][2] ^= gf_mul[col[2]][0];
-       state[2][2] ^= gf_mul[col[3]][1];
-       state[3][2] = gf_mul[col[0]][1];
-       state[3][2] ^= col[1];
-       state[3][2] ^= col[2];
-       state[3][2] ^= gf_mul[col[3]][0];
-       // Column 4
-       col[0] = state[0][3];
-       col[1] = state[1][3];
-       col[2] = state[2][3];
-       col[3] = state[3][3];
-       state[0][3] = gf_mul[col[0]][0];
-       state[0][3] ^= gf_mul[col[1]][1];
-       state[0][3] ^= col[2];
-       state[0][3] ^= col[3];
-       state[1][3] = col[0];
-       state[1][3] ^= gf_mul[col[1]][0];
-       state[1][3] ^= gf_mul[col[2]][1];
-       state[1][3] ^= col[3];
-       state[2][3] = col[0];
-       state[2][3] ^= col[1];
-       state[2][3] ^= gf_mul[col[2]][0];
-       state[2][3] ^= gf_mul[col[3]][1];
-       state[3][3] = gf_mul[col[0]][1];
-       state[3][3] ^= col[1];
-       state[3][3] ^= col[2];
-       state[3][3] ^= gf_mul[col[3]][0];
-}
-
-void InvMixColumns(BYTE state[][4])
-{
-       BYTE col[4];
-
-       // Column 1
-       col[0] = state[0][0];
-       col[1] = state[1][0];
-       col[2] = state[2][0];
-       col[3] = state[3][0];
-       state[0][0] = gf_mul[col[0]][5];
-       state[0][0] ^= gf_mul[col[1]][3];
-       state[0][0] ^= gf_mul[col[2]][4];
-       state[0][0] ^= gf_mul[col[3]][2];
-       state[1][0] = gf_mul[col[0]][2];
-       state[1][0] ^= gf_mul[col[1]][5];
-       state[1][0] ^= gf_mul[col[2]][3];
-       state[1][0] ^= gf_mul[col[3]][4];
-       state[2][0] = gf_mul[col[0]][4];
-       state[2][0] ^= gf_mul[col[1]][2];
-       state[2][0] ^= gf_mul[col[2]][5];
-       state[2][0] ^= gf_mul[col[3]][3];
-       state[3][0] = gf_mul[col[0]][3];
-       state[3][0] ^= gf_mul[col[1]][4];
-       state[3][0] ^= gf_mul[col[2]][2];
-       state[3][0] ^= gf_mul[col[3]][5];
-       // Column 2
-       col[0] = state[0][1];
-       col[1] = state[1][1];
-       col[2] = state[2][1];
-       col[3] = state[3][1];
-       state[0][1] = gf_mul[col[0]][5];
-       state[0][1] ^= gf_mul[col[1]][3];
-       state[0][1] ^= gf_mul[col[2]][4];
-       state[0][1] ^= gf_mul[col[3]][2];
-       state[1][1] = gf_mul[col[0]][2];
-       state[1][1] ^= gf_mul[col[1]][5];
-       state[1][1] ^= gf_mul[col[2]][3];
-       state[1][1] ^= gf_mul[col[3]][4];
-       state[2][1] = gf_mul[col[0]][4];
-       state[2][1] ^= gf_mul[col[1]][2];
-       state[2][1] ^= gf_mul[col[2]][5];
-       state[2][1] ^= gf_mul[col[3]][3];
-       state[3][1] = gf_mul[col[0]][3];
-       state[3][1] ^= gf_mul[col[1]][4];
-       state[3][1] ^= gf_mul[col[2]][2];
-       state[3][1] ^= gf_mul[col[3]][5];
-       // Column 3
-       col[0] = state[0][2];
-       col[1] = state[1][2];
-       col[2] = state[2][2];
-       col[3] = state[3][2];
-       state[0][2] = gf_mul[col[0]][5];
-       state[0][2] ^= gf_mul[col[1]][3];
-       state[0][2] ^= gf_mul[col[2]][4];
-       state[0][2] ^= gf_mul[col[3]][2];
-       state[1][2] = gf_mul[col[0]][2];
-       state[1][2] ^= gf_mul[col[1]][5];
-       state[1][2] ^= gf_mul[col[2]][3];
-       state[1][2] ^= gf_mul[col[3]][4];
-       state[2][2] = gf_mul[col[0]][4];
-       state[2][2] ^= gf_mul[col[1]][2];
-       state[2][2] ^= gf_mul[col[2]][5];
-       state[2][2] ^= gf_mul[col[3]][3];
-       state[3][2] = gf_mul[col[0]][3];
-       state[3][2] ^= gf_mul[col[1]][4];
-       state[3][2] ^= gf_mul[col[2]][2];
-       state[3][2] ^= gf_mul[col[3]][5];
-       // Column 4
-       col[0] = state[0][3];
-       col[1] = state[1][3];
-       col[2] = state[2][3];
-       col[3] = state[3][3];
-       state[0][3] = gf_mul[col[0]][5];
-       state[0][3] ^= gf_mul[col[1]][3];
-       state[0][3] ^= gf_mul[col[2]][4];
-       state[0][3] ^= gf_mul[col[3]][2];
-       state[1][3] = gf_mul[col[0]][2];
-       state[1][3] ^= gf_mul[col[1]][5];
-       state[1][3] ^= gf_mul[col[2]][3];
-       state[1][3] ^= gf_mul[col[3]][4];
-       state[2][3] = gf_mul[col[0]][4];
-       state[2][3] ^= gf_mul[col[1]][2];
-       state[2][3] ^= gf_mul[col[2]][5];
-       state[2][3] ^= gf_mul[col[3]][3];
-       state[3][3] = gf_mul[col[0]][3];
-       state[3][3] ^= gf_mul[col[1]][4];
-       state[3][3] ^= gf_mul[col[2]][2];
-       state[3][3] ^= gf_mul[col[3]][5];
-}
-
-/////////////////
-// (En/De)Crypt
-/////////////////
-
-void aes_encrypt(const BYTE in[], BYTE out[], const WORD key[], int keysize)
-{
-       BYTE state[4][4];
-
-       // Copy input array (should be 16 bytes long) to a matrix (sequential bytes are ordered
-       // by row, not col) called "state" for processing.
-       // *** Implementation note: The official AES documentation references the state by
-       // column, then row. Accessing an element in C requires row then column. Thus, all state
-       // references in AES must have the column and row indexes reversed for C implementation.
-       state[0][0] = in[0];
-       state[1][0] = in[1];
-       state[2][0] = in[2];
-       state[3][0] = in[3];
-       state[0][1] = in[4];
-       state[1][1] = in[5];
-       state[2][1] = in[6];
-       state[3][1] = in[7];
-       state[0][2] = in[8];
-       state[1][2] = in[9];
-       state[2][2] = in[10];
-       state[3][2] = in[11];
-       state[0][3] = in[12];
-       state[1][3] = in[13];
-       state[2][3] = in[14];
-       state[3][3] = in[15];
-
-       // Perform the necessary number of rounds. The round key is added first.
-       // The last round does not perform the MixColumns step.
-       AddRoundKey(state,&key[0]);
-       SubBytes(state); ShiftRows(state); MixColumns(state); AddRoundKey(state,&key[4]);
-       SubBytes(state); ShiftRows(state); MixColumns(state); AddRoundKey(state,&key[8]);
-       SubBytes(state); ShiftRows(state); MixColumns(state); AddRoundKey(state,&key[12]);
-       SubBytes(state); ShiftRows(state); MixColumns(state); AddRoundKey(state,&key[16]);
-       SubBytes(state); ShiftRows(state); MixColumns(state); AddRoundKey(state,&key[20]);
-       SubBytes(state); ShiftRows(state); MixColumns(state); AddRoundKey(state,&key[24]);
-       SubBytes(state); ShiftRows(state); MixColumns(state); AddRoundKey(state,&key[28]);
-       SubBytes(state); ShiftRows(state); MixColumns(state); AddRoundKey(state,&key[32]);
-       SubBytes(state); ShiftRows(state); MixColumns(state); AddRoundKey(state,&key[36]);
-       if (keysize != 128) {
-               SubBytes(state); ShiftRows(state); MixColumns(state); AddRoundKey(state,&key[40]);
-               SubBytes(state); ShiftRows(state); MixColumns(state); AddRoundKey(state,&key[44]);
-               if (keysize != 192) {
-                       SubBytes(state); ShiftRows(state); MixColumns(state); AddRoundKey(state,&key[48]);
-                       SubBytes(state); ShiftRows(state); MixColumns(state); AddRoundKey(state,&key[52]);
-                       SubBytes(state); ShiftRows(state); AddRoundKey(state,&key[56]);
-               }
-               else {
-                       SubBytes(state); ShiftRows(state); AddRoundKey(state,&key[48]);
-               }
-       }
-       else {
-               SubBytes(state); ShiftRows(state); AddRoundKey(state,&key[40]);
-       }
-
-       // Copy the state to the output array.
-       out[0] = state[0][0];
-       out[1] = state[1][0];
-       out[2] = state[2][0];
-       out[3] = state[3][0];
-       out[4] = state[0][1];
-       out[5] = state[1][1];
-       out[6] = state[2][1];
-       out[7] = state[3][1];
-       out[8] = state[0][2];
-       out[9] = state[1][2];
-       out[10] = state[2][2];
-       out[11] = state[3][2];
-       out[12] = state[0][3];
-       out[13] = state[1][3];
-       out[14] = state[2][3];
-       out[15] = state[3][3];
-}
-
-void aes_decrypt(const BYTE in[], BYTE out[], const WORD key[], int keysize)
-{
-       BYTE state[4][4];
-
-       // Copy the input to the state.
-       state[0][0] = in[0];
-       state[1][0] = in[1];
-       state[2][0] = in[2];
-       state[3][0] = in[3];
-       state[0][1] = in[4];
-       state[1][1] = in[5];
-       state[2][1] = in[6];
-       state[3][1] = in[7];
-       state[0][2] = in[8];
-       state[1][2] = in[9];
-       state[2][2] = in[10];
-       state[3][2] = in[11];
-       state[0][3] = in[12];
-       state[1][3] = in[13];
-       state[2][3] = in[14];
-       state[3][3] = in[15];
-
-       // Perform the necessary number of rounds. The round key is added first.
-       // The last round does not perform the MixColumns step.
-       if (keysize > 128) {
-               if (keysize > 192) {
-                       AddRoundKey(state,&key[56]);
-                       InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[52]);InvMixColumns(state);
-                       InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[48]);InvMixColumns(state);
-               }
-               else {
-                       AddRoundKey(state,&key[48]);
-               }
-               InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[44]);InvMixColumns(state);
-               InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[40]);InvMixColumns(state);
-       }
-       else {
-               AddRoundKey(state,&key[40]);
-       }
-       InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[36]);InvMixColumns(state);
-       InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[32]);InvMixColumns(state);
-       InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[28]);InvMixColumns(state);
-       InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[24]);InvMixColumns(state);
-       InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[20]);InvMixColumns(state);
-       InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[16]);InvMixColumns(state);
-       InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[12]);InvMixColumns(state);
-       InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[8]);InvMixColumns(state);
-       InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[4]);InvMixColumns(state);
-       InvShiftRows(state);InvSubBytes(state);AddRoundKey(state,&key[0]);
-
-       // Copy the state to the output array.
-       out[0] = state[0][0];
-       out[1] = state[1][0];
-       out[2] = state[2][0];
-       out[3] = state[3][0];
-       out[4] = state[0][1];
-       out[5] = state[1][1];
-       out[6] = state[2][1];
-       out[7] = state[3][1];
-       out[8] = state[0][2];
-       out[9] = state[1][2];
-       out[10] = state[2][2];
-       out[11] = state[3][2];
-       out[12] = state[0][3];
-       out[13] = state[1][3];
-       out[14] = state[2][3];
-       out[15] = state[3][3];
-}
-
-/*******************
-** AES DEBUGGING FUNCTIONS
-*******************/
-/*
-// This prints the "state" grid as a linear hex string.
-void print_state(BYTE state[][4])
-{
-       int idx,idx2;
-
-       for (idx=0; idx < 4; idx++)
-               for (idx2=0; idx2 < 4; idx2++)
-                       printf("%02x",state[idx2][idx]);
-       printf("\n");
-}
-
-// This prints the key (4 consecutive ints) used for a given round as a linear hex string.
-void print_rnd_key(WORD key[])
-{
-       int idx;
-
-       for (idx=0; idx < 4; idx++)
-               printf("%08x",key[idx]);
-       printf("\n");
-}
-*/
diff --git a/deps/crypto/aes.h b/deps/crypto/aes.h
deleted file mode 100644 (file)
index 25721c8..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/*********************************************************************\r
-* Filename:   aes.h\r
-* Author:     Brad Conte (brad AT bradconte.com)\r
-* Copyright:\r
-* Disclaimer: This code is presented "as is" without any guarantees.\r
-* Details:    Defines the API for the corresponding AES implementation.\r
-*********************************************************************/\r
-\r
-#ifndef AES_H\r
-#define AES_H\r
-\r
-/*************************** HEADER FILES ***************************/\r
-#include <stddef.h>\r
-\r
-/****************************** MACROS ******************************/\r
-#define AES_BLOCK_SIZE 16               // AES operates on 16 bytes at a time\r
-\r
-/**************************** DATA TYPES ****************************/\r
-typedef unsigned char BYTE;            // 8-bit byte\r
-typedef unsigned int WORD;             // 32-bit word, change to "long" for 16-bit machines\r
-\r
-/*********************** FUNCTION DECLARATIONS **********************/\r
-///////////////////\r
-// AES\r
-///////////////////\r
-// Key setup must be done before any AES en/de-cryption functions can be used.\r
-void aes_key_setup(const BYTE key[],          // The key, must be 128, 192, or 256 bits\r
-                   WORD w[],                  // Output key schedule to be used later\r
-                   int keysize);              // Bit length of the key, 128, 192, or 256\r
-\r
-void aes_encrypt(const BYTE in[],             // 16 bytes of plaintext\r
-                 BYTE out[],                  // 16 bytes of ciphertext\r
-                 const WORD key[],            // From the key setup\r
-                 int keysize);                // Bit length of the key, 128, 192, or 256\r
-\r
-void aes_decrypt(const BYTE in[],             // 16 bytes of ciphertext\r
-                 BYTE out[],                  // 16 bytes of plaintext\r
-                 const WORD key[],            // From the key setup\r
-                 int keysize);                // Bit length of the key, 128, 192, or 256\r
-\r
-///////////////////\r
-// AES - CBC\r
-///////////////////\r
-int aes_encrypt_cbc(const BYTE in[],          // Plaintext\r
-                    size_t in_len,            // Must be a multiple of AES_BLOCK_SIZE\r
-                    BYTE out[],               // Ciphertext, same length as plaintext\r
-                    const WORD key[],         // From the key setup\r
-                    int keysize,              // Bit length of the key, 128, 192, or 256\r
-                    const BYTE iv[]);         // IV, must be AES_BLOCK_SIZE bytes long\r
-\r
-// Only output the CBC-MAC of the input.\r
-int aes_encrypt_cbc_mac(const BYTE in[],      // plaintext\r
-                        size_t in_len,        // Must be a multiple of AES_BLOCK_SIZE\r
-                        BYTE out[],           // Output MAC\r
-                        const WORD key[],     // From the key setup\r
-                        int keysize,          // Bit length of the key, 128, 192, or 256\r
-                        const BYTE iv[]);     // IV, must be AES_BLOCK_SIZE bytes long\r
-\r
-///////////////////\r
-// AES - CTR\r
-///////////////////\r
-void increment_iv(BYTE iv[],                  // Must be a multiple of AES_BLOCK_SIZE\r
-                  int counter_size);          // Bytes of the IV used for counting (low end)\r
-\r
-void aes_encrypt_ctr(const BYTE in[],         // Plaintext\r
-                     size_t in_len,           // Any byte length\r
-                     BYTE out[],              // Ciphertext, same length as plaintext\r
-                     const WORD key[],        // From the key setup\r
-                     int keysize,             // Bit length of the key, 128, 192, or 256\r
-                     const BYTE iv[]);        // IV, must be AES_BLOCK_SIZE bytes long\r
-\r
-void aes_decrypt_ctr(const BYTE in[],         // Ciphertext\r
-                     size_t in_len,           // Any byte length\r
-                     BYTE out[],              // Plaintext, same length as ciphertext\r
-                     const WORD key[],        // From the key setup\r
-                     int keysize,             // Bit length of the key, 128, 192, or 256\r
-                     const BYTE iv[]);        // IV, must be AES_BLOCK_SIZE bytes long\r
-\r
-///////////////////\r
-// AES - CCM\r
-///////////////////\r
-// Returns True if the input parameters do not violate any constraint.\r
-int aes_encrypt_ccm(const BYTE plaintext[],              // IN  - Plaintext.\r
-                    WORD plaintext_len,                  // IN  - Plaintext length.\r
-                    const BYTE associated_data[],        // IN  - Associated Data included in authentication, but not encryption.\r
-                    unsigned short associated_data_len,  // IN  - Associated Data length in bytes.\r
-                    const BYTE nonce[],                  // IN  - The Nonce to be used for encryption.\r
-                    unsigned short nonce_len,            // IN  - Nonce length in bytes.\r
-                    BYTE ciphertext[],                   // OUT - Ciphertext, a concatination of the plaintext and the MAC.\r
-                    WORD *ciphertext_len,                // OUT - The length of the ciphertext, always plaintext_len + mac_len.\r
-                    WORD mac_len,                        // IN  - The desired length of the MAC, must be 4, 6, 8, 10, 12, 14, or 16.\r
-                    const BYTE key[],                    // IN  - The AES key for encryption.\r
-                    int keysize);                        // IN  - The length of the key in bits. Valid values are 128, 192, 256.\r
-\r
-// Returns True if the input parameters do not violate any constraint.\r
-// Use mac_auth to ensure decryption/validation was preformed correctly.\r
-// If authentication does not succeed, the plaintext is zeroed out. To overwride\r
-// this, call with mac_auth = NULL. The proper proceedure is to decrypt with\r
-// authentication enabled (mac_auth != NULL) and make a second call to that\r
-// ignores authentication explicitly if the first call failes.\r
-int aes_decrypt_ccm(const BYTE ciphertext[],             // IN  - Ciphertext, the concatination of encrypted plaintext and MAC.\r
-                    WORD ciphertext_len,                 // IN  - Ciphertext length in bytes.\r
-                    const BYTE assoc[],                  // IN  - The Associated Data, required for authentication.\r
-                    unsigned short assoc_len,            // IN  - Associated Data length in bytes.\r
-                    const BYTE nonce[],                  // IN  - The Nonce to use for decryption, same one as for encryption.\r
-                    unsigned short nonce_len,            // IN  - Nonce length in bytes.\r
-                    BYTE plaintext[],                    // OUT - The plaintext that was decrypted. Will need to be large enough to hold ciphertext_len - mac_len.\r
-                    WORD *plaintext_len,                 // OUT - Length in bytes of the output plaintext, always ciphertext_len - mac_len .\r
-                    WORD mac_len,                        // IN  - The length of the MAC that was calculated.\r
-                    int *mac_auth,                       // OUT - TRUE if authentication succeeded, FALSE if it did not. NULL pointer will ignore the authentication.\r
-                    const BYTE key[],                    // IN  - The AES key for decryption.\r
-                    int keysize);                        // IN  - The length of the key in BITS. Valid values are 128, 192, 256.\r
-\r
-///////////////////\r
-// Test functions\r
-///////////////////\r
-int aes_test();\r
-int aes_ecb_test();\r
-int aes_cbc_test();\r
-int aes_ctr_test();\r
-int aes_ccm_test();\r
-\r
-#endif   // AES_H\r
diff --git a/deps/crypto/aes_test.c b/deps/crypto/aes_test.c
deleted file mode 100644 (file)
index b8da963..0000000
+++ /dev/null
@@ -1,285 +0,0 @@
-/*********************************************************************\r
-* Filename:   aes_test.c\r
-* Author:     Brad Conte (brad AT bradconte.com)\r
-* Copyright:\r
-* Disclaimer: This code is presented "as is" without any guarantees.\r
-* Details:    Performs known-answer tests on the corresponding AES\r
-              implementation. These tests do not encompass the full\r
-              range of available test vectors and are not sufficient\r
-              for FIPS-140 certification. However, if the tests pass\r
-              it is very, very likely that the code is correct and was\r
-              compiled properly. This code also serves as\r
-                 example usage of the functions.\r
-*********************************************************************/\r
-\r
-/*************************** HEADER FILES ***************************/\r
-#include <stdio.h>\r
-#include <memory.h>\r
-#include "aes.h"\r
-\r
-/*********************** FUNCTION DEFINITIONS ***********************/\r
-void print_hex(BYTE str[], int len)\r
-{\r
-       int idx;\r
-\r
-       for(idx = 0; idx < len; idx++)\r
-               printf("%02x", str[idx]);\r
-}\r
-\r
-int aes_ecb_test()\r
-{\r
-       WORD key_schedule[60], idx;\r
-       BYTE enc_buf[128];\r
-       BYTE plaintext[2][16] = {\r
-               {0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96,0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a},\r
-               {0xae,0x2d,0x8a,0x57,0x1e,0x03,0xac,0x9c,0x9e,0xb7,0x6f,0xac,0x45,0xaf,0x8e,0x51}\r
-       };\r
-       BYTE ciphertext[2][16] = {\r
-               {0xf3,0xee,0xd1,0xbd,0xb5,0xd2,0xa0,0x3c,0x06,0x4b,0x5a,0x7e,0x3d,0xb1,0x81,0xf8},\r
-               {0x59,0x1c,0xcb,0x10,0xd4,0x10,0xed,0x26,0xdc,0x5b,0xa7,0x4a,0x31,0x36,0x28,0x70}\r
-       };\r
-       BYTE key[1][32] = {\r
-               {0x60,0x3d,0xeb,0x10,0x15,0xca,0x71,0xbe,0x2b,0x73,0xae,0xf0,0x85,0x7d,0x77,0x81,0x1f,0x35,0x2c,0x07,0x3b,0x61,0x08,0xd7,0x2d,0x98,0x10,0xa3,0x09,0x14,0xdf,0xf4}\r
-       };\r
-       int pass = 1;\r
-\r
-       // Raw ECB mode.\r
-       //printf("* ECB mode:\n");\r
-       aes_key_setup(key[0], key_schedule, 256);\r
-       //printf(  "Key          : ");\r
-       //print_hex(key[0], 32);\r
-\r
-       for(idx = 0; idx < 2; idx++) {\r
-               aes_encrypt(plaintext[idx], enc_buf, key_schedule, 256);\r
-               //printf("\nPlaintext    : ");\r
-               //print_hex(plaintext[idx], 16);\r
-               //printf("\n-encrypted to: ");\r
-               //print_hex(enc_buf, 16);\r
-               pass = pass && !memcmp(enc_buf, ciphertext[idx], 16);\r
-\r
-               aes_decrypt(ciphertext[idx], enc_buf, key_schedule, 256);\r
-               //printf("\nCiphertext   : ");\r
-               //print_hex(ciphertext[idx], 16);\r
-               //printf("\n-decrypted to: ");\r
-               //print_hex(enc_buf, 16);\r
-               pass = pass && !memcmp(enc_buf, plaintext[idx], 16);\r
-\r
-               //printf("\n\n");\r
-       }\r
-\r
-       return(pass);\r
-}\r
-\r
-int aes_cbc_test()\r
-{\r
-       WORD key_schedule[60];\r
-       BYTE enc_buf[128];\r
-       BYTE plaintext[1][32] = {\r
-               {0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96,0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a,0xae,0x2d,0x8a,0x57,0x1e,0x03,0xac,0x9c,0x9e,0xb7,0x6f,0xac,0x45,0xaf,0x8e,0x51}\r
-       };\r
-       BYTE ciphertext[1][32] = {\r
-               {0xf5,0x8c,0x4c,0x04,0xd6,0xe5,0xf1,0xba,0x77,0x9e,0xab,0xfb,0x5f,0x7b,0xfb,0xd6,0x9c,0xfc,0x4e,0x96,0x7e,0xdb,0x80,0x8d,0x67,0x9f,0x77,0x7b,0xc6,0x70,0x2c,0x7d}\r
-       };\r
-       BYTE iv[1][16] = {\r
-               {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}\r
-       };\r
-       BYTE key[1][32] = {\r
-               {0x60,0x3d,0xeb,0x10,0x15,0xca,0x71,0xbe,0x2b,0x73,0xae,0xf0,0x85,0x7d,0x77,0x81,0x1f,0x35,0x2c,0x07,0x3b,0x61,0x08,0xd7,0x2d,0x98,0x10,0xa3,0x09,0x14,0xdf,0xf4}\r
-       };\r
-       int pass = 1;\r
-\r
-       //printf("* CBC mode:\n");\r
-       aes_key_setup(key[0], key_schedule, 256);\r
-\r
-       //printf(  "Key          : ");\r
-       //print_hex(key[0], 32);\r
-       //printf("\nIV           : ");\r
-       //print_hex(iv[0], 16);\r
-\r
-       aes_encrypt_cbc(plaintext[0], 32, enc_buf, key_schedule, 256, iv[0]);\r
-       //printf("\nPlaintext    : ");\r
-       //print_hex(plaintext[0], 32);\r
-       //printf("\n-encrypted to: ");\r
-       //print_hex(enc_buf, 32);\r
-       //printf("\nCiphertext   : ");\r
-       //print_hex(ciphertext[0], 32);\r
-       pass = pass && !memcmp(enc_buf, ciphertext[0], 32);\r
-\r
-       aes_decrypt_cbc(ciphertext[0], 32, enc_buf, key_schedule, 256, iv[0]);\r
-       //printf("\nCiphertext   : ");\r
-       //print_hex(ciphertext[0], 32);\r
-       //printf("\n-decrypted to: ");\r
-       //print_hex(enc_buf, 32);\r
-       //printf("\nPlaintext   : ");\r
-       //print_hex(plaintext[0], 32);\r
-       pass = pass && !memcmp(enc_buf, plaintext[0], 32);\r
-\r
-       //printf("\n\n");\r
-       return(pass);\r
-}\r
-\r
-int aes_ctr_test()\r
-{\r
-       WORD key_schedule[60];\r
-       BYTE enc_buf[128];\r
-       BYTE plaintext[1][32] = {\r
-               {0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96,0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a,0xae,0x2d,0x8a,0x57,0x1e,0x03,0xac,0x9c,0x9e,0xb7,0x6f,0xac,0x45,0xaf,0x8e,0x51}\r
-       };\r
-       BYTE ciphertext[1][32] = {\r
-               {0x60,0x1e,0xc3,0x13,0x77,0x57,0x89,0xa5,0xb7,0xa7,0xf5,0x04,0xbb,0xf3,0xd2,0x28,0xf4,0x43,0xe3,0xca,0x4d,0x62,0xb5,0x9a,0xca,0x84,0xe9,0x90,0xca,0xca,0xf5,0xc5}\r
-       };\r
-       BYTE iv[1][16] = {\r
-               {0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff},\r
-       };\r
-       BYTE key[1][32] = {\r
-               {0x60,0x3d,0xeb,0x10,0x15,0xca,0x71,0xbe,0x2b,0x73,0xae,0xf0,0x85,0x7d,0x77,0x81,0x1f,0x35,0x2c,0x07,0x3b,0x61,0x08,0xd7,0x2d,0x98,0x10,0xa3,0x09,0x14,0xdf,0xf4}\r
-       };\r
-       int pass = 1;\r
-\r
-       //printf("* CTR mode:\n");\r
-       aes_key_setup(key[0], key_schedule, 256);\r
-\r
-       //printf(  "Key          : ");\r
-       //print_hex(key[0], 32);\r
-       //printf("\nIV           : ");\r
-       //print_hex(iv[0], 16);\r
-\r
-       aes_encrypt_ctr(plaintext[0], 32, enc_buf, key_schedule, 256, iv[0]);\r
-       //printf("\nPlaintext    : ");\r
-       //print_hex(plaintext[0], 32);\r
-       //printf("\n-encrypted to: ");\r
-       //print_hex(enc_buf, 32);\r
-       pass = pass && !memcmp(enc_buf, ciphertext[0], 32);\r
-\r
-       aes_decrypt_ctr(ciphertext[0], 32, enc_buf, key_schedule, 256, iv[0]);\r
-       //printf("\nCiphertext   : ");\r
-       //print_hex(ciphertext[0], 32);\r
-       //printf("\n-decrypted to: ");\r
-       //print_hex(enc_buf, 32);\r
-       pass = pass && !memcmp(enc_buf, plaintext[0], 32);\r
-\r
-       //printf("\n\n");\r
-       return(pass);\r
-}\r
-\r
-int aes_ccm_test()\r
-{\r
-       int mac_auth;\r
-       WORD enc_buf_len;\r
-       BYTE enc_buf[128];\r
-       BYTE plaintext[3][32] = {\r
-               {0x20,0x21,0x22,0x23},\r
-               {0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f},\r
-               {0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37}\r
-       };\r
-       BYTE assoc[3][32] = {\r
-               {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07},\r
-               {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f},\r
-               {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13}\r
-       };\r
-       BYTE ciphertext[3][32 + 16] = {\r
-               {0x71,0x62,0x01,0x5b,0x4d,0xac,0x25,0x5d},\r
-               {0xd2,0xa1,0xf0,0xe0,0x51,0xea,0x5f,0x62,0x08,0x1a,0x77,0x92,0x07,0x3d,0x59,0x3d,0x1f,0xc6,0x4f,0xbf,0xac,0xcd},\r
-               {0xe3,0xb2,0x01,0xa9,0xf5,0xb7,0x1a,0x7a,0x9b,0x1c,0xea,0xec,0xcd,0x97,0xe7,0x0b,0x61,0x76,0xaa,0xd9,0xa4,0x42,0x8a,0xa5,0x48,0x43,0x92,0xfb,0xc1,0xb0,0x99,0x51}\r
-       };\r
-       BYTE iv[3][16] = {\r
-               {0x10,0x11,0x12,0x13,0x14,0x15,0x16},\r
-               {0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17},\r
-               {0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b}\r
-       };\r
-       BYTE key[1][32] = {\r
-               {0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f}\r
-       };\r
-       int pass = 1;\r
-\r
-       //printf("* CCM mode:\n");\r
-       //printf("Key           : ");\r
-       //print_hex(key[0], 16);\r
-\r
-       //print_hex(plaintext[0], 4);\r
-       //print_hex(assoc[0], 8);\r
-       //print_hex(ciphertext[0], 8);\r
-       //print_hex(iv[0], 7);\r
-       //print_hex(key[0], 16);\r
-\r
-       aes_encrypt_ccm(plaintext[0], 4, assoc[0], 8, iv[0], 7, enc_buf, &enc_buf_len, 4, key[0], 128);\r
-       //printf("\nNONCE        : ");\r
-       //print_hex(iv[0], 7);\r
-       //printf("\nAssoc. Data  : ");\r
-       //print_hex(assoc[0], 8);\r
-       //printf("\nPayload       : ");\r
-       //print_hex(plaintext[0], 4);\r
-       //printf("\n-encrypted to: ");\r
-       //print_hex(enc_buf, enc_buf_len);\r
-       pass = pass && !memcmp(enc_buf, ciphertext[0], enc_buf_len);\r
-\r
-       aes_decrypt_ccm(ciphertext[0], 8, assoc[0], 8, iv[0], 7, enc_buf, &enc_buf_len, 4, &mac_auth, key[0], 128);\r
-       //printf("\n-Ciphertext  : ");\r
-       //print_hex(ciphertext[0], 8);\r
-       //printf("\n-decrypted to: ");\r
-       //print_hex(enc_buf, enc_buf_len);\r
-       //printf("\nAuthenticated: %d ", mac_auth);\r
-       pass = pass && !memcmp(enc_buf, plaintext[0], enc_buf_len) && mac_auth;\r
-\r
-\r
-       aes_encrypt_ccm(plaintext[1], 16, assoc[1], 16, iv[1], 8, enc_buf, &enc_buf_len, 6, key[0], 128);\r
-       //printf("\n\nNONCE        : ");\r
-       //print_hex(iv[1], 8);\r
-       //printf("\nAssoc. Data  : ");\r
-       //print_hex(assoc[1], 16);\r
-       //printf("\nPayload      : ");\r
-       //print_hex(plaintext[1], 16);\r
-       //printf("\n-encrypted to: ");\r
-       //print_hex(enc_buf, enc_buf_len);\r
-       pass = pass && !memcmp(enc_buf, ciphertext[1], enc_buf_len);\r
-\r
-       aes_decrypt_ccm(ciphertext[1], 22, assoc[1], 16, iv[1], 8, enc_buf, &enc_buf_len, 6, &mac_auth, key[0], 128);\r
-       //printf("\n-Ciphertext  : ");\r
-       //print_hex(ciphertext[1], 22);\r
-       //printf("\n-decrypted to: ");\r
-       //print_hex(enc_buf, enc_buf_len);\r
-       //printf("\nAuthenticated: %d ", mac_auth);\r
-       pass = pass && !memcmp(enc_buf, plaintext[1], enc_buf_len) && mac_auth;\r
-\r
-\r
-       aes_encrypt_ccm(plaintext[2], 24, assoc[2], 20, iv[2], 12, enc_buf, &enc_buf_len, 8, key[0], 128);\r
-       //printf("\n\nNONCE        : ");\r
-       //print_hex(iv[2], 12);\r
-       //printf("\nAssoc. Data  : ");\r
-       //print_hex(assoc[2], 20);\r
-       //printf("\nPayload      : ");\r
-       //print_hex(plaintext[2], 24);\r
-       //printf("\n-encrypted to: ");\r
-       //print_hex(enc_buf, enc_buf_len);\r
-       pass = pass && !memcmp(enc_buf, ciphertext[2], enc_buf_len);\r
-\r
-       aes_decrypt_ccm(ciphertext[2], 32, assoc[2], 20, iv[2], 12, enc_buf, &enc_buf_len, 8, &mac_auth, key[0], 128);\r
-       //printf("\n-Ciphertext  : ");\r
-       //print_hex(ciphertext[2], 32);\r
-       //printf("\n-decrypted to: ");\r
-       //print_hex(enc_buf, enc_buf_len);\r
-       //printf("\nAuthenticated: %d ", mac_auth);\r
-       pass = pass && !memcmp(enc_buf, plaintext[2], enc_buf_len) && mac_auth;\r
-\r
-       //printf("\n\n");\r
-       return(pass);\r
-}\r
-\r
-int aes_test()\r
-{\r
-       int pass = 1;\r
-\r
-       pass = pass && aes_ecb_test();\r
-       pass = pass && aes_cbc_test();\r
-       pass = pass && aes_ctr_test();\r
-       pass = pass && aes_ccm_test();\r
-\r
-       return(pass);\r
-}\r
-\r
-int main(int argc, char *argv[])\r
-{\r
-       printf("AES Tests: %s\n", aes_test() ? "SUCCEEDED" : "FAILED");\r
-\r
-       return(0);\r
-}\r
diff --git a/deps/crypto/arcfour.c b/deps/crypto/arcfour.c
deleted file mode 100644 (file)
index 37a88e1..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*********************************************************************
-* Filename:   arcfour.c
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Implementation of the ARCFOUR encryption algorithm.
-              Algorithm specification can be found here:
-               * http://en.wikipedia.org/wiki/RC4
-*********************************************************************/
-
-/*************************** HEADER FILES ***************************/
-#include <stdlib.h>
-#include "arcfour.h"
-
-/*********************** FUNCTION DEFINITIONS ***********************/
-void arcfour_key_setup(BYTE state[], const BYTE key[], int len)
-{
-       int i, j;
-       BYTE t;
-
-       for (i = 0; i < 256; ++i)
-               state[i] = i;
-       for (i = 0, j = 0; i < 256; ++i) {
-               j = (j + state[i] + key[i % len]) % 256;
-               t = state[i];
-               state[i] = state[j];
-               state[j] = t;
-       }
-}
-
-// This does not hold state between calls. It always generates the
-// stream starting from the first  output byte.
-void arcfour_generate_stream(BYTE state[], BYTE out[], size_t len)
-{
-       int i, j;
-       size_t idx;
-       BYTE t;
-
-       for (idx = 0, i = 0, j = 0; idx < len; ++idx)  {
-               i = (i + 1) % 256;
-               j = (j + state[i]) % 256;
-               t = state[i];
-               state[i] = state[j];
-               state[j] = t;
-               out[idx] = state[(state[i] + state[j]) % 256];
-       }
-}
diff --git a/deps/crypto/arcfour.h b/deps/crypto/arcfour.h
deleted file mode 100644 (file)
index f9f1e87..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*********************************************************************
-* Filename:   arcfour.h
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Defines the API for the corresponding ARCFOUR implementation.
-*********************************************************************/
-
-#ifndef ARCFOUR_H
-#define ARCFOUR_H
-
-/*************************** HEADER FILES ***************************/
-#include <stddef.h>
-
-/**************************** DATA TYPES ****************************/
-typedef unsigned char BYTE;             // 8-bit byte
-
-/*********************** FUNCTION DECLARATIONS **********************/
-// Input: state - the state used to generate the keystream
-//        key - Key to use to initialize the state
-//        len - length of key in bytes (valid lenth is 1 to 256)
-void arcfour_key_setup(BYTE state[], const BYTE key[], int len);
-
-// Pseudo-Random Generator Algorithm
-// Input: state - the state used to generate the keystream
-//        out - Must be allocated to be of at least "len" length
-//        len - number of bytes to generate
-void arcfour_generate_stream(BYTE state[], BYTE out[], size_t len);
-
-#endif   // ARCFOUR_H
diff --git a/deps/crypto/arcfour_test.c b/deps/crypto/arcfour_test.c
deleted file mode 100644 (file)
index 985f8a7..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*********************************************************************
-* Filename:   arcfour_test.c
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Performs known-answer tests on the corresponding ARCFOUR
-                 implementation. These tests do not encompass the full
-                 range of available test vectors, however, if the tests
-                 pass it is very, very likely that the code is correct
-                 and was compiled properly. This code also serves as
-                 example usage of the functions.
-*********************************************************************/
-
-/*************************** HEADER FILES ***************************/
-#include <stdio.h>
-#include <memory.h>
-#include "arcfour.h"
-
-/*********************** FUNCTION DEFINITIONS ***********************/
-int rc4_test()
-{
-       BYTE state[256];
-       BYTE key[3][10] = {{"Key"}, {"Wiki"}, {"Secret"}};
-       BYTE stream[3][10] = {{0xEB,0x9F,0x77,0x81,0xB7,0x34,0xCA,0x72,0xA7,0x19},
-                             {0x60,0x44,0xdb,0x6d,0x41,0xb7},
-                             {0x04,0xd4,0x6b,0x05,0x3c,0xa8,0x7b,0x59}};
-       int stream_len[3] = {10,6,8};
-       BYTE buf[1024];
-       int idx;
-       int pass = 1;
-
-       // Only test the output stream. Note that the state can be reused.
-       for (idx = 0; idx < 3; idx++) {
-               arcfour_key_setup(state, key[idx], strlen(key[idx]));
-               arcfour_generate_stream(state, buf, stream_len[idx]);
-               pass = pass && !memcmp(stream[idx], buf, stream_len[idx]);
-       }
-
-       return(pass);
-}
-
-int main()
-{
-       printf("ARCFOUR tests: %s\n", rc4_test() ? "SUCCEEDED" : "FAILED");
-
-       return(0);
-}
diff --git a/deps/crypto/base64.c b/deps/crypto/base64.c
deleted file mode 100644 (file)
index 5e89808..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*********************************************************************
-* Filename:   base64.c
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Implementation of the Base64 encoding algorithm.
-*********************************************************************/
-
-/*************************** HEADER FILES ***************************/
-#include <stdlib.h>
-#include "base64.h"
-
-/****************************** MACROS ******************************/
-#define NEWLINE_INVL 76
-
-/**************************** VARIABLES *****************************/
-// Note: To change the charset to a URL encoding, replace the '+' and '/' with '*' and '-'
-static const BYTE charset[]={"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"};
-
-/*********************** FUNCTION DEFINITIONS ***********************/
-BYTE revchar(char ch)
-{
-       if (ch >= 'A' && ch <= 'Z')
-               ch -= 'A';
-       else if (ch >= 'a' && ch <='z')
-               ch = ch - 'a' + 26;
-       else if (ch >= '0' && ch <='9')
-               ch = ch - '0' + 52;
-       else if (ch == '+')
-               ch = 62;
-       else if (ch == '/')
-               ch = 63;
-
-       return(ch);
-}
-
-size_t base64_encode(const BYTE in[], BYTE out[], size_t len, int newline_flag)
-{
-       size_t idx, idx2, blks, blk_ceiling, left_over, newline_count = 0;
-
-       blks = (len / 3);
-       left_over = len % 3;
-
-       if (out == NULL) {
-               idx2 = blks * 4 ;
-               if (left_over)
-                       idx2 += 4;
-               if (newline_flag)
-                       idx2 += len / 57;   // (NEWLINE_INVL / 4) * 3 = 57. One newline per 57 input bytes.
-       }
-       else {
-               // Since 3 input bytes = 4 output bytes, determine out how many even sets of
-               // 3 bytes the input has.
-               blk_ceiling = blks * 3;
-               for (idx = 0, idx2 = 0; idx < blk_ceiling; idx += 3, idx2 += 4) {
-                       out[idx2]     = charset[in[idx] >> 2];
-                       out[idx2 + 1] = charset[((in[idx] & 0x03) << 4) | (in[idx + 1] >> 4)];
-                       out[idx2 + 2] = charset[((in[idx + 1] & 0x0f) << 2) | (in[idx + 2] >> 6)];
-                       out[idx2 + 3] = charset[in[idx + 2] & 0x3F];
-                       // The offical standard requires a newline every 76 characters.
-                       // (Eg, first newline is character 77 of the output.)
-                       if (((idx2 - newline_count + 4) % NEWLINE_INVL == 0) && newline_flag) {
-                               out[idx2 + 4] = '\n';
-                               idx2++;
-                               newline_count++;
-                       }
-               }
-
-               if (left_over == 1) {
-                       out[idx2]     = charset[in[idx] >> 2];
-                       out[idx2 + 1] = charset[(in[idx] & 0x03) << 4];
-                       out[idx2 + 2] = '=';
-                       out[idx2 + 3] = '=';
-                       idx2 += 4;
-               }
-               else if (left_over == 2) {
-                       out[idx2]     = charset[in[idx] >> 2];
-                       out[idx2 + 1] = charset[((in[idx] & 0x03) << 4) | (in[idx + 1] >> 4)];
-                       out[idx2 + 2] = charset[(in[idx + 1] & 0x0F) << 2];
-                       out[idx2 + 3] = '=';
-                       idx2 += 4;
-               }
-       }
-
-       return(idx2);
-}
-
-size_t base64_decode(const BYTE in[], BYTE out[], size_t len)
-{
-       BYTE ch;
-       size_t idx, idx2, blks, blk_ceiling, left_over;
-
-       if (in[len - 1] == '=')
-               len--;
-       if (in[len - 1] == '=')
-               len--;
-
-       blks = len / 4;
-       left_over = len % 4;
-
-       if (out == NULL) {
-               if (len >= 77 && in[NEWLINE_INVL] == '\n')   // Verify that newlines where used.
-                       len -= len / (NEWLINE_INVL + 1);
-               blks = len / 4;
-               left_over = len % 4;
-
-               idx = blks * 3;
-               if (left_over == 2)
-                       idx ++;
-               else if (left_over == 3)
-                       idx += 2;
-       }
-       else {
-               blk_ceiling = blks * 4;
-               for (idx = 0, idx2 = 0; idx2 < blk_ceiling; idx += 3, idx2 += 4) {
-                       if (in[idx2] == '\n')
-                               idx2++;
-                       out[idx]     = (revchar(in[idx2]) << 2) | ((revchar(in[idx2 + 1]) & 0x30) >> 4);
-                       out[idx + 1] = (revchar(in[idx2 + 1]) << 4) | (revchar(in[idx2 + 2]) >> 2);
-                       out[idx + 2] = (revchar(in[idx2 + 2]) << 6) | revchar(in[idx2 + 3]);
-               }
-
-               if (left_over == 2) {
-                       out[idx]     = (revchar(in[idx2]) << 2) | ((revchar(in[idx2 + 1]) & 0x30) >> 4);
-                       idx++;
-               }
-               else if (left_over == 3) {
-                       out[idx]     = (revchar(in[idx2]) << 2) | ((revchar(in[idx2 + 1]) & 0x30) >> 4);
-                       out[idx + 1] = (revchar(in[idx2 + 1]) << 4) | (revchar(in[idx2 + 2]) >> 2);
-                       idx += 2;
-               }
-       }
-
-       return(idx);
-}
diff --git a/deps/crypto/base64.h b/deps/crypto/base64.h
deleted file mode 100644 (file)
index e35c6c7..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*********************************************************************
-* Filename:   base64.h
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Defines the API for the corresponding Base64 implementation.
-*********************************************************************/
-
-#ifndef BASE64_H
-#define BASE64_H
-
-/*************************** HEADER FILES ***************************/
-#include <stddef.h>
-
-/**************************** DATA TYPES ****************************/
-typedef unsigned char BYTE;             // 8-bit byte
-
-/*********************** FUNCTION DECLARATIONS **********************/
-// Returns the size of the output. If called with out = NULL, will just return
-// the size of what the output would have been (without a terminating NULL).
-size_t base64_encode(const BYTE in[], BYTE out[], size_t len, int newline_flag);
-
-// Returns the size of the output. If called with out = NULL, will just return
-// the size of what the output would have been (without a terminating NULL).
-size_t base64_decode(const BYTE in[], BYTE out[], size_t len);
-
-#endif   // BASE64_H
diff --git a/deps/crypto/base64_test.c b/deps/crypto/base64_test.c
deleted file mode 100644 (file)
index c59cc98..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*********************************************************************
-* Filename:   blowfish_test.c
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Performs known-answer tests on the corresponding Base64
-                 implementation. These tests do not encompass the full
-                 range of available test vectors, however, if the tests
-                 pass it is very, very likely that the code is correct
-                 and was compiled properly. This code also serves as
-                 example usage of the functions.
-*********************************************************************/
-
-/*************************** HEADER FILES ***************************/
-#include <stdio.h>
-#include <memory.h>
-#include "base64.h"
-
-/*********************** FUNCTION DEFINITIONS ***********************/
-int base64_test()
-{
-       BYTE text[3][1024] = {{"fo"},
-                             {"foobar"},
-                             {"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."}};
-       BYTE code[3][1024] = {{"Zm8="},
-                             {"Zm9vYmFy"},
-                             {"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz\nIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2Yg\ndGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu\ndWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRo\nZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="}};
-       BYTE buf[1024];
-       size_t buf_len;
-       int pass = 1;
-       int idx;
-
-       for (idx = 0; idx < 3; idx++) {
-               buf_len = base64_encode(text[idx], buf, strlen(text[idx]), 1);
-               pass = pass && ((buf_len == strlen(code[idx])) &&
-                                (buf_len == base64_encode(text[idx], NULL, strlen(text[idx]), 1)));
-               pass = pass && !strcmp(code[idx], buf);
-
-               memset(buf, 0, sizeof(buf));
-               buf_len = base64_decode(code[idx], buf, strlen(code[idx]));
-               pass = pass && ((buf_len == strlen(text[idx])) &&
-                               (buf_len == base64_decode(code[idx], NULL, strlen(code[idx]))));
-               pass = pass && !strcmp(text[idx], buf);
-       }
-
-       return(pass);
-}
-
-int main()
-{
-       printf("Base64 tests: %s\n", base64_test() ? "PASSED" : "FAILED");
-
-       return 0;
-}
diff --git a/deps/crypto/blowfish.c b/deps/crypto/blowfish.c
deleted file mode 100644 (file)
index 8de91dd..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-/*********************************************************************
-* Filename:   blowfish.c
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Implementation of the Blowfish encryption algorithm.
-              Modes of operation (such as CBC) are not included.
-              Algorithm specification can be found here:
-               * http://www.schneier.com/blowfish.html
-*********************************************************************/
-
-/*************************** HEADER FILES ***************************/
-#include <stdlib.h>
-#include <string.h>
-#include "blowfish.h"
-
-/****************************** MACROS ******************************/
-#define F(x,t) t = keystruct->s[0][(x) >> 24]; \
-               t += keystruct->s[1][((x) >> 16) & 0xff]; \
-               t ^= keystruct->s[2][((x) >> 8) & 0xff]; \
-               t += keystruct->s[3][(x) & 0xff];
-#define swap(r,l,t) t = l; l = r; r = t;
-#define ITERATION(l,r,t,pval) l ^= keystruct->p[pval]; F(l,t); r^= t; swap(r,l,t);
-
-/**************************** VARIABLES *****************************/
-static const WORD p_perm[18] = {
-   0x243F6A88,0x85A308D3,0x13198A2E,0x03707344,0xA4093822,0x299F31D0,0x082EFA98,
-   0xEC4E6C89,0x452821E6,0x38D01377,0xBE5466CF,0x34E90C6C,0xC0AC29B7,0xC97C50DD,
-   0x3F84D5B5,0xB5470917,0x9216D5D9,0x8979FB1B
-};
-
-static const WORD s_perm[4][256] = { {
-   0xD1310BA6,0x98DFB5AC,0x2FFD72DB,0xD01ADFB7,0xB8E1AFED,0x6A267E96,0xBA7C9045,0xF12C7F99,
-   0x24A19947,0xB3916CF7,0x0801F2E2,0x858EFC16,0x636920D8,0x71574E69,0xA458FEA3,0xF4933D7E,
-   0x0D95748F,0x728EB658,0x718BCD58,0x82154AEE,0x7B54A41D,0xC25A59B5,0x9C30D539,0x2AF26013,
-   0xC5D1B023,0x286085F0,0xCA417918,0xB8DB38EF,0x8E79DCB0,0x603A180E,0x6C9E0E8B,0xB01E8A3E,
-   0xD71577C1,0xBD314B27,0x78AF2FDA,0x55605C60,0xE65525F3,0xAA55AB94,0x57489862,0x63E81440,
-   0x55CA396A,0x2AAB10B6,0xB4CC5C34,0x1141E8CE,0xA15486AF,0x7C72E993,0xB3EE1411,0x636FBC2A,
-   0x2BA9C55D,0x741831F6,0xCE5C3E16,0x9B87931E,0xAFD6BA33,0x6C24CF5C,0x7A325381,0x28958677,
-   0x3B8F4898,0x6B4BB9AF,0xC4BFE81B,0x66282193,0x61D809CC,0xFB21A991,0x487CAC60,0x5DEC8032,
-   0xEF845D5D,0xE98575B1,0xDC262302,0xEB651B88,0x23893E81,0xD396ACC5,0x0F6D6FF3,0x83F44239,
-   0x2E0B4482,0xA4842004,0x69C8F04A,0x9E1F9B5E,0x21C66842,0xF6E96C9A,0x670C9C61,0xABD388F0,
-   0x6A51A0D2,0xD8542F68,0x960FA728,0xAB5133A3,0x6EEF0B6C,0x137A3BE4,0xBA3BF050,0x7EFB2A98,
-   0xA1F1651D,0x39AF0176,0x66CA593E,0x82430E88,0x8CEE8619,0x456F9FB4,0x7D84A5C3,0x3B8B5EBE,
-   0xE06F75D8,0x85C12073,0x401A449F,0x56C16AA6,0x4ED3AA62,0x363F7706,0x1BFEDF72,0x429B023D,
-   0x37D0D724,0xD00A1248,0xDB0FEAD3,0x49F1C09B,0x075372C9,0x80991B7B,0x25D479D8,0xF6E8DEF7,
-   0xE3FE501A,0xB6794C3B,0x976CE0BD,0x04C006BA,0xC1A94FB6,0x409F60C4,0x5E5C9EC2,0x196A2463,
-   0x68FB6FAF,0x3E6C53B5,0x1339B2EB,0x3B52EC6F,0x6DFC511F,0x9B30952C,0xCC814544,0xAF5EBD09,
-   0xBEE3D004,0xDE334AFD,0x660F2807,0x192E4BB3,0xC0CBA857,0x45C8740F,0xD20B5F39,0xB9D3FBDB,
-   0x5579C0BD,0x1A60320A,0xD6A100C6,0x402C7279,0x679F25FE,0xFB1FA3CC,0x8EA5E9F8,0xDB3222F8,
-   0x3C7516DF,0xFD616B15,0x2F501EC8,0xAD0552AB,0x323DB5FA,0xFD238760,0x53317B48,0x3E00DF82,
-   0x9E5C57BB,0xCA6F8CA0,0x1A87562E,0xDF1769DB,0xD542A8F6,0x287EFFC3,0xAC6732C6,0x8C4F5573,
-   0x695B27B0,0xBBCA58C8,0xE1FFA35D,0xB8F011A0,0x10FA3D98,0xFD2183B8,0x4AFCB56C,0x2DD1D35B,
-   0x9A53E479,0xB6F84565,0xD28E49BC,0x4BFB9790,0xE1DDF2DA,0xA4CB7E33,0x62FB1341,0xCEE4C6E8,
-   0xEF20CADA,0x36774C01,0xD07E9EFE,0x2BF11FB4,0x95DBDA4D,0xAE909198,0xEAAD8E71,0x6B93D5A0,
-   0xD08ED1D0,0xAFC725E0,0x8E3C5B2F,0x8E7594B7,0x8FF6E2FB,0xF2122B64,0x8888B812,0x900DF01C,
-   0x4FAD5EA0,0x688FC31C,0xD1CFF191,0xB3A8C1AD,0x2F2F2218,0xBE0E1777,0xEA752DFE,0x8B021FA1,
-   0xE5A0CC0F,0xB56F74E8,0x18ACF3D6,0xCE89E299,0xB4A84FE0,0xFD13E0B7,0x7CC43B81,0xD2ADA8D9,
-   0x165FA266,0x80957705,0x93CC7314,0x211A1477,0xE6AD2065,0x77B5FA86,0xC75442F5,0xFB9D35CF,
-   0xEBCDAF0C,0x7B3E89A0,0xD6411BD3,0xAE1E7E49,0x00250E2D,0x2071B35E,0x226800BB,0x57B8E0AF,
-   0x2464369B,0xF009B91E,0x5563911D,0x59DFA6AA,0x78C14389,0xD95A537F,0x207D5BA2,0x02E5B9C5,
-   0x83260376,0x6295CFA9,0x11C81968,0x4E734A41,0xB3472DCA,0x7B14A94A,0x1B510052,0x9A532915,
-   0xD60F573F,0xBC9BC6E4,0x2B60A476,0x81E67400,0x08BA6FB5,0x571BE91F,0xF296EC6B,0x2A0DD915,
-   0xB6636521,0xE7B9F9B6,0xFF34052E,0xC5855664,0x53B02D5D,0xA99F8FA1,0x08BA4799,0x6E85076A
-},{
-   0x4B7A70E9,0xB5B32944,0xDB75092E,0xC4192623,0xAD6EA6B0,0x49A7DF7D,0x9CEE60B8,0x8FEDB266,
-   0xECAA8C71,0x699A17FF,0x5664526C,0xC2B19EE1,0x193602A5,0x75094C29,0xA0591340,0xE4183A3E,
-   0x3F54989A,0x5B429D65,0x6B8FE4D6,0x99F73FD6,0xA1D29C07,0xEFE830F5,0x4D2D38E6,0xF0255DC1,
-   0x4CDD2086,0x8470EB26,0x6382E9C6,0x021ECC5E,0x09686B3F,0x3EBAEFC9,0x3C971814,0x6B6A70A1,
-   0x687F3584,0x52A0E286,0xB79C5305,0xAA500737,0x3E07841C,0x7FDEAE5C,0x8E7D44EC,0x5716F2B8,
-   0xB03ADA37,0xF0500C0D,0xF01C1F04,0x0200B3FF,0xAE0CF51A,0x3CB574B2,0x25837A58,0xDC0921BD,
-   0xD19113F9,0x7CA92FF6,0x94324773,0x22F54701,0x3AE5E581,0x37C2DADC,0xC8B57634,0x9AF3DDA7,
-   0xA9446146,0x0FD0030E,0xECC8C73E,0xA4751E41,0xE238CD99,0x3BEA0E2F,0x3280BBA1,0x183EB331,
-   0x4E548B38,0x4F6DB908,0x6F420D03,0xF60A04BF,0x2CB81290,0x24977C79,0x5679B072,0xBCAF89AF,
-   0xDE9A771F,0xD9930810,0xB38BAE12,0xDCCF3F2E,0x5512721F,0x2E6B7124,0x501ADDE6,0x9F84CD87,
-   0x7A584718,0x7408DA17,0xBC9F9ABC,0xE94B7D8C,0xEC7AEC3A,0xDB851DFA,0x63094366,0xC464C3D2,
-   0xEF1C1847,0x3215D908,0xDD433B37,0x24C2BA16,0x12A14D43,0x2A65C451,0x50940002,0x133AE4DD,
-   0x71DFF89E,0x10314E55,0x81AC77D6,0x5F11199B,0x043556F1,0xD7A3C76B,0x3C11183B,0x5924A509,
-   0xF28FE6ED,0x97F1FBFA,0x9EBABF2C,0x1E153C6E,0x86E34570,0xEAE96FB1,0x860E5E0A,0x5A3E2AB3,
-   0x771FE71C,0x4E3D06FA,0x2965DCB9,0x99E71D0F,0x803E89D6,0x5266C825,0x2E4CC978,0x9C10B36A,
-   0xC6150EBA,0x94E2EA78,0xA5FC3C53,0x1E0A2DF4,0xF2F74EA7,0x361D2B3D,0x1939260F,0x19C27960,
-   0x5223A708,0xF71312B6,0xEBADFE6E,0xEAC31F66,0xE3BC4595,0xA67BC883,0xB17F37D1,0x018CFF28,
-   0xC332DDEF,0xBE6C5AA5,0x65582185,0x68AB9802,0xEECEA50F,0xDB2F953B,0x2AEF7DAD,0x5B6E2F84,
-   0x1521B628,0x29076170,0xECDD4775,0x619F1510,0x13CCA830,0xEB61BD96,0x0334FE1E,0xAA0363CF,
-   0xB5735C90,0x4C70A239,0xD59E9E0B,0xCBAADE14,0xEECC86BC,0x60622CA7,0x9CAB5CAB,0xB2F3846E,
-   0x648B1EAF,0x19BDF0CA,0xA02369B9,0x655ABB50,0x40685A32,0x3C2AB4B3,0x319EE9D5,0xC021B8F7,
-   0x9B540B19,0x875FA099,0x95F7997E,0x623D7DA8,0xF837889A,0x97E32D77,0x11ED935F,0x16681281,
-   0x0E358829,0xC7E61FD6,0x96DEDFA1,0x7858BA99,0x57F584A5,0x1B227263,0x9B83C3FF,0x1AC24696,
-   0xCDB30AEB,0x532E3054,0x8FD948E4,0x6DBC3128,0x58EBF2EF,0x34C6FFEA,0xFE28ED61,0xEE7C3C73,
-   0x5D4A14D9,0xE864B7E3,0x42105D14,0x203E13E0,0x45EEE2B6,0xA3AAABEA,0xDB6C4F15,0xFACB4FD0,
-   0xC742F442,0xEF6ABBB5,0x654F3B1D,0x41CD2105,0xD81E799E,0x86854DC7,0xE44B476A,0x3D816250,
-   0xCF62A1F2,0x5B8D2646,0xFC8883A0,0xC1C7B6A3,0x7F1524C3,0x69CB7492,0x47848A0B,0x5692B285,
-   0x095BBF00,0xAD19489D,0x1462B174,0x23820E00,0x58428D2A,0x0C55F5EA,0x1DADF43E,0x233F7061,
-   0x3372F092,0x8D937E41,0xD65FECF1,0x6C223BDB,0x7CDE3759,0xCBEE7460,0x4085F2A7,0xCE77326E,
-   0xA6078084,0x19F8509E,0xE8EFD855,0x61D99735,0xA969A7AA,0xC50C06C2,0x5A04ABFC,0x800BCADC,
-   0x9E447A2E,0xC3453484,0xFDD56705,0x0E1E9EC9,0xDB73DBD3,0x105588CD,0x675FDA79,0xE3674340,
-   0xC5C43465,0x713E38D8,0x3D28F89E,0xF16DFF20,0x153E21E7,0x8FB03D4A,0xE6E39F2B,0xDB83ADF7
-},{
-   0xE93D5A68,0x948140F7,0xF64C261C,0x94692934,0x411520F7,0x7602D4F7,0xBCF46B2E,0xD4A20068,
-   0xD4082471,0x3320F46A,0x43B7D4B7,0x500061AF,0x1E39F62E,0x97244546,0x14214F74,0xBF8B8840,
-   0x4D95FC1D,0x96B591AF,0x70F4DDD3,0x66A02F45,0xBFBC09EC,0x03BD9785,0x7FAC6DD0,0x31CB8504,
-   0x96EB27B3,0x55FD3941,0xDA2547E6,0xABCA0A9A,0x28507825,0x530429F4,0x0A2C86DA,0xE9B66DFB,
-   0x68DC1462,0xD7486900,0x680EC0A4,0x27A18DEE,0x4F3FFEA2,0xE887AD8C,0xB58CE006,0x7AF4D6B6,
-   0xAACE1E7C,0xD3375FEC,0xCE78A399,0x406B2A42,0x20FE9E35,0xD9F385B9,0xEE39D7AB,0x3B124E8B,
-   0x1DC9FAF7,0x4B6D1856,0x26A36631,0xEAE397B2,0x3A6EFA74,0xDD5B4332,0x6841E7F7,0xCA7820FB,
-   0xFB0AF54E,0xD8FEB397,0x454056AC,0xBA489527,0x55533A3A,0x20838D87,0xFE6BA9B7,0xD096954B,
-   0x55A867BC,0xA1159A58,0xCCA92963,0x99E1DB33,0xA62A4A56,0x3F3125F9,0x5EF47E1C,0x9029317C,
-   0xFDF8E802,0x04272F70,0x80BB155C,0x05282CE3,0x95C11548,0xE4C66D22,0x48C1133F,0xC70F86DC,
-   0x07F9C9EE,0x41041F0F,0x404779A4,0x5D886E17,0x325F51EB,0xD59BC0D1,0xF2BCC18F,0x41113564,
-   0x257B7834,0x602A9C60,0xDFF8E8A3,0x1F636C1B,0x0E12B4C2,0x02E1329E,0xAF664FD1,0xCAD18115,
-   0x6B2395E0,0x333E92E1,0x3B240B62,0xEEBEB922,0x85B2A20E,0xE6BA0D99,0xDE720C8C,0x2DA2F728,
-   0xD0127845,0x95B794FD,0x647D0862,0xE7CCF5F0,0x5449A36F,0x877D48FA,0xC39DFD27,0xF33E8D1E,
-   0x0A476341,0x992EFF74,0x3A6F6EAB,0xF4F8FD37,0xA812DC60,0xA1EBDDF8,0x991BE14C,0xDB6E6B0D,
-   0xC67B5510,0x6D672C37,0x2765D43B,0xDCD0E804,0xF1290DC7,0xCC00FFA3,0xB5390F92,0x690FED0B,
-   0x667B9FFB,0xCEDB7D9C,0xA091CF0B,0xD9155EA3,0xBB132F88,0x515BAD24,0x7B9479BF,0x763BD6EB,
-   0x37392EB3,0xCC115979,0x8026E297,0xF42E312D,0x6842ADA7,0xC66A2B3B,0x12754CCC,0x782EF11C,
-   0x6A124237,0xB79251E7,0x06A1BBE6,0x4BFB6350,0x1A6B1018,0x11CAEDFA,0x3D25BDD8,0xE2E1C3C9,
-   0x44421659,0x0A121386,0xD90CEC6E,0xD5ABEA2A,0x64AF674E,0xDA86A85F,0xBEBFE988,0x64E4C3FE,
-   0x9DBC8057,0xF0F7C086,0x60787BF8,0x6003604D,0xD1FD8346,0xF6381FB0,0x7745AE04,0xD736FCCC,
-   0x83426B33,0xF01EAB71,0xB0804187,0x3C005E5F,0x77A057BE,0xBDE8AE24,0x55464299,0xBF582E61,
-   0x4E58F48F,0xF2DDFDA2,0xF474EF38,0x8789BDC2,0x5366F9C3,0xC8B38E74,0xB475F255,0x46FCD9B9,
-   0x7AEB2661,0x8B1DDF84,0x846A0E79,0x915F95E2,0x466E598E,0x20B45770,0x8CD55591,0xC902DE4C,
-   0xB90BACE1,0xBB8205D0,0x11A86248,0x7574A99E,0xB77F19B6,0xE0A9DC09,0x662D09A1,0xC4324633,
-   0xE85A1F02,0x09F0BE8C,0x4A99A025,0x1D6EFE10,0x1AB93D1D,0x0BA5A4DF,0xA186F20F,0x2868F169,
-   0xDCB7DA83,0x573906FE,0xA1E2CE9B,0x4FCD7F52,0x50115E01,0xA70683FA,0xA002B5C4,0x0DE6D027,
-   0x9AF88C27,0x773F8641,0xC3604C06,0x61A806B5,0xF0177A28,0xC0F586E0,0x006058AA,0x30DC7D62,
-   0x11E69ED7,0x2338EA63,0x53C2DD94,0xC2C21634,0xBBCBEE56,0x90BCB6DE,0xEBFC7DA1,0xCE591D76,
-   0x6F05E409,0x4B7C0188,0x39720A3D,0x7C927C24,0x86E3725F,0x724D9DB9,0x1AC15BB4,0xD39EB8FC,
-   0xED545578,0x08FCA5B5,0xD83D7CD3,0x4DAD0FC4,0x1E50EF5E,0xB161E6F8,0xA28514D9,0x6C51133C,
-   0x6FD5C7E7,0x56E14EC4,0x362ABFCE,0xDDC6C837,0xD79A3234,0x92638212,0x670EFA8E,0x406000E0
-},{
-   0x3A39CE37,0xD3FAF5CF,0xABC27737,0x5AC52D1B,0x5CB0679E,0x4FA33742,0xD3822740,0x99BC9BBE,
-   0xD5118E9D,0xBF0F7315,0xD62D1C7E,0xC700C47B,0xB78C1B6B,0x21A19045,0xB26EB1BE,0x6A366EB4,
-   0x5748AB2F,0xBC946E79,0xC6A376D2,0x6549C2C8,0x530FF8EE,0x468DDE7D,0xD5730A1D,0x4CD04DC6,
-   0x2939BBDB,0xA9BA4650,0xAC9526E8,0xBE5EE304,0xA1FAD5F0,0x6A2D519A,0x63EF8CE2,0x9A86EE22,
-   0xC089C2B8,0x43242EF6,0xA51E03AA,0x9CF2D0A4,0x83C061BA,0x9BE96A4D,0x8FE51550,0xBA645BD6,
-   0x2826A2F9,0xA73A3AE1,0x4BA99586,0xEF5562E9,0xC72FEFD3,0xF752F7DA,0x3F046F69,0x77FA0A59,
-   0x80E4A915,0x87B08601,0x9B09E6AD,0x3B3EE593,0xE990FD5A,0x9E34D797,0x2CF0B7D9,0x022B8B51,
-   0x96D5AC3A,0x017DA67D,0xD1CF3ED6,0x7C7D2D28,0x1F9F25CF,0xADF2B89B,0x5AD6B472,0x5A88F54C,
-   0xE029AC71,0xE019A5E6,0x47B0ACFD,0xED93FA9B,0xE8D3C48D,0x283B57CC,0xF8D56629,0x79132E28,
-   0x785F0191,0xED756055,0xF7960E44,0xE3D35E8C,0x15056DD4,0x88F46DBA,0x03A16125,0x0564F0BD,
-   0xC3EB9E15,0x3C9057A2,0x97271AEC,0xA93A072A,0x1B3F6D9B,0x1E6321F5,0xF59C66FB,0x26DCF319,
-   0x7533D928,0xB155FDF5,0x03563482,0x8ABA3CBB,0x28517711,0xC20AD9F8,0xABCC5167,0xCCAD925F,
-   0x4DE81751,0x3830DC8E,0x379D5862,0x9320F991,0xEA7A90C2,0xFB3E7BCE,0x5121CE64,0x774FBE32,
-   0xA8B6E37E,0xC3293D46,0x48DE5369,0x6413E680,0xA2AE0810,0xDD6DB224,0x69852DFD,0x09072166,
-   0xB39A460A,0x6445C0DD,0x586CDECF,0x1C20C8AE,0x5BBEF7DD,0x1B588D40,0xCCD2017F,0x6BB4E3BB,
-   0xDDA26A7E,0x3A59FF45,0x3E350A44,0xBCB4CDD5,0x72EACEA8,0xFA6484BB,0x8D6612AE,0xBF3C6F47,
-   0xD29BE463,0x542F5D9E,0xAEC2771B,0xF64E6370,0x740E0D8D,0xE75B1357,0xF8721671,0xAF537D5D,
-   0x4040CB08,0x4EB4E2CC,0x34D2466A,0x0115AF84,0xE1B00428,0x95983A1D,0x06B89FB4,0xCE6EA048,
-   0x6F3F3B82,0x3520AB82,0x011A1D4B,0x277227F8,0x611560B1,0xE7933FDC,0xBB3A792B,0x344525BD,
-   0xA08839E1,0x51CE794B,0x2F32C9B7,0xA01FBAC9,0xE01CC87E,0xBCC7D1F6,0xCF0111C3,0xA1E8AAC7,
-   0x1A908749,0xD44FBD9A,0xD0DADECB,0xD50ADA38,0x0339C32A,0xC6913667,0x8DF9317C,0xE0B12B4F,
-   0xF79E59B7,0x43F5BB3A,0xF2D519FF,0x27D9459C,0xBF97222C,0x15E6FC2A,0x0F91FC71,0x9B941525,
-   0xFAE59361,0xCEB69CEB,0xC2A86459,0x12BAA8D1,0xB6C1075E,0xE3056A0C,0x10D25065,0xCB03A442,
-   0xE0EC6E0E,0x1698DB3B,0x4C98A0BE,0x3278E964,0x9F1F9532,0xE0D392DF,0xD3A0342B,0x8971F21E,
-   0x1B0A7441,0x4BA3348C,0xC5BE7120,0xC37632D8,0xDF359F8D,0x9B992F2E,0xE60B6F47,0x0FE3F11D,
-   0xE54CDA54,0x1EDAD891,0xCE6279CF,0xCD3E7E6F,0x1618B166,0xFD2C1D05,0x848FD2C5,0xF6FB2299,
-   0xF523F357,0xA6327623,0x93A83531,0x56CCCD02,0xACF08162,0x5A75EBB5,0x6E163697,0x88D273CC,
-   0xDE966292,0x81B949D0,0x4C50901B,0x71C65614,0xE6C6C7BD,0x327A140A,0x45E1D006,0xC3F27B9A,
-   0xC9AA53FD,0x62A80F00,0xBB25BFE2,0x35BDD2F6,0x71126905,0xB2040222,0xB6CBCF7C,0xCD769C2B,
-   0x53113EC0,0x1640E3D3,0x38ABBD60,0x2547ADF0,0xBA38209C,0xF746CE76,0x77AFA1C5,0x20756060,
-   0x85CBFE4E,0x8AE88DD8,0x7AAAF9B0,0x4CF9AA7E,0x1948C25C,0x02FB8A8C,0x01C36AE4,0xD6EBE1F9,
-   0x90D4F869,0xA65CDEA0,0x3F09252D,0xC208E69F,0xB74E6132,0xCE77E25B,0x578FDFE3,0x3AC372E6
-} };
-
-/*********************** FUNCTION DEFINITIONS ***********************/
-void blowfish_encrypt(const BYTE in[], BYTE out[], const BLOWFISH_KEY *keystruct)
-{
-   WORD l,r,t; //,i;
-
-   l = (in[0] << 24) | (in[1] << 16) | (in[2] << 8) | (in[3]);
-   r = (in[4] << 24) | (in[5] << 16) | (in[6] << 8) | (in[7]);
-
-   ITERATION(l,r,t,0);
-   ITERATION(l,r,t,1);
-   ITERATION(l,r,t,2);
-   ITERATION(l,r,t,3);
-   ITERATION(l,r,t,4);
-   ITERATION(l,r,t,5);
-   ITERATION(l,r,t,6);
-   ITERATION(l,r,t,7);
-   ITERATION(l,r,t,8);
-   ITERATION(l,r,t,9);
-   ITERATION(l,r,t,10);
-   ITERATION(l,r,t,11);
-   ITERATION(l,r,t,12);
-   ITERATION(l,r,t,13);
-   ITERATION(l,r,t,14);
-   l ^= keystruct->p[15]; F(l,t); r^= t; //Last iteration has no swap()
-   r ^= keystruct->p[16];
-   l ^= keystruct->p[17];
-
-   out[0] = l >> 24;
-   out[1] = l >> 16;
-   out[2] = l >> 8;
-   out[3] = l;
-   out[4] = r >> 24;
-   out[5] = r >> 16;
-   out[6] = r >> 8;
-   out[7] = r;
-}
-
-void blowfish_decrypt(const BYTE in[], BYTE out[], const BLOWFISH_KEY *keystruct)
-{
-   WORD l,r,t; //,i;
-
-   l = (in[0] << 24) | (in[1] << 16) | (in[2] << 8) | (in[3]);
-   r = (in[4] << 24) | (in[5] << 16) | (in[6] << 8) | (in[7]);
-
-   ITERATION(l,r,t,17);
-   ITERATION(l,r,t,16);
-   ITERATION(l,r,t,15);
-   ITERATION(l,r,t,14);
-   ITERATION(l,r,t,13);
-   ITERATION(l,r,t,12);
-   ITERATION(l,r,t,11);
-   ITERATION(l,r,t,10);
-   ITERATION(l,r,t,9);
-   ITERATION(l,r,t,8);
-   ITERATION(l,r,t,7);
-   ITERATION(l,r,t,6);
-   ITERATION(l,r,t,5);
-   ITERATION(l,r,t,4);
-   ITERATION(l,r,t,3);
-   l ^= keystruct->p[2]; F(l,t); r^= t; //Last iteration has no swap()
-   r ^= keystruct->p[1];
-   l ^= keystruct->p[0];
-
-   out[0] = l >> 24;
-   out[1] = l >> 16;
-   out[2] = l >> 8;
-   out[3] = l;
-   out[4] = r >> 24;
-   out[5] = r >> 16;
-   out[6] = r >> 8;
-   out[7] = r;
-}
-
-void blowfish_key_setup(const BYTE user_key[], BLOWFISH_KEY *keystruct, size_t len)
-{
-   BYTE block[8];
-   int idx,idx2;
-
-   // Copy over the constant init array vals (so the originals aren't destroyed).
-   memcpy(keystruct->p,p_perm,sizeof(WORD) * 18);
-   memcpy(keystruct->s,s_perm,sizeof(WORD) * 1024);
-
-   // Combine the key with the P box. Assume key is standard 448 bits (56 bytes) or less.
-   for (idx = 0, idx2 = 0; idx < 18; ++idx, idx2 += 4)
-      keystruct->p[idx] ^= (user_key[idx2 % len] << 24) | (user_key[(idx2+1) % len] << 16)
-                           | (user_key[(idx2+2) % len] << 8) | (user_key[(idx2+3) % len]);
-   // Re-calculate the P box.
-   memset(block, 0, 8);
-   for (idx = 0; idx < 18; idx += 2) {
-      blowfish_encrypt(block,block,keystruct);
-      keystruct->p[idx] = (block[0] << 24) | (block[1] << 16) | (block[2] << 8) | block[3];
-      keystruct->p[idx+1]=(block[4] << 24) | (block[5] << 16) | (block[6] << 8) | block[7];
-   }
-   // Recalculate the S-boxes.
-   for (idx = 0; idx < 4; ++idx) {
-      for (idx2 = 0; idx2 < 256; idx2 += 2) {
-         blowfish_encrypt(block,block,keystruct);
-         keystruct->s[idx][idx2] = (block[0] << 24) | (block[1] << 16) |
-                                   (block[2] << 8) | block[3];
-         keystruct->s[idx][idx2+1] = (block[4] << 24) | (block[5] << 16) |
-                                     (block[6] << 8) | block[7];
-      }
-   }
-}
diff --git a/deps/crypto/blowfish.h b/deps/crypto/blowfish.h
deleted file mode 100644 (file)
index d8e9d4a..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*********************************************************************
-* Filename:   blowfish.h
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Defines the API for the corresponding Blowfish implementation.
-*********************************************************************/
-
-#ifndef BLOWFISH_H
-#define BLOWFISH_H
-
-/*************************** HEADER FILES ***************************/
-#include <stddef.h>
-
-/****************************** MACROS ******************************/
-#define BLOWFISH_BLOCK_SIZE 8           // Blowfish operates on 8 bytes at a time
-
-/**************************** DATA TYPES ****************************/
-typedef unsigned char BYTE;             // 8-bit byte
-typedef unsigned int  WORD;             // 32-bit word, change to "long" for 16-bit machines
-
-typedef struct {
-   WORD p[18];
-   WORD s[4][256];
-} BLOWFISH_KEY;
-
-/*********************** FUNCTION DECLARATIONS **********************/
-void blowfish_key_setup(const BYTE user_key[], BLOWFISH_KEY *keystruct, size_t len);
-void blowfish_encrypt(const BYTE in[], BYTE out[], const BLOWFISH_KEY *keystruct);
-void blowfish_decrypt(const BYTE in[], BYTE out[], const BLOWFISH_KEY *keystruct);
-
-#endif   // BLOWFISH_H
diff --git a/deps/crypto/blowfish_test.c b/deps/crypto/blowfish_test.c
deleted file mode 100644 (file)
index 0f0aa38..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*********************************************************************
-* Filename:   blowfish_test.c
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Performs known-answer tests on the corresponding Blowfish
-                 implementation. These tests do not encompass the full
-                 range of available test vectors, however, if the tests
-                 pass it is very, very likely that the code is correct
-                 and was compiled properly. This code also serves as
-                 example usage of the functions.
-*********************************************************************/
-
-/*************************** HEADER FILES ***************************/
-#include <stdio.h>
-#include <memory.h>
-#include "blowfish.h"
-
-/*********************** FUNCTION DEFINITIONS ***********************/
-int blowfish_test()
-{
-       BYTE key1[8]  = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-       BYTE key2[8]  = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
-       BYTE key3[24] = {0xF0,0xE1,0xD2,0xC3,0xB4,0xA5,0x96,0x87,
-                        0x78,0x69,0x5A,0x4B,0x3C,0x2D,0x1E,0x0F,
-                        0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77};
-       BYTE p1[BLOWFISH_BLOCK_SIZE] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-       BYTE p2[BLOWFISH_BLOCK_SIZE] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
-       BYTE p3[BLOWFISH_BLOCK_SIZE] = {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10};
-
-       BYTE c1[BLOWFISH_BLOCK_SIZE] = {0x4e,0xf9,0x97,0x45,0x61,0x98,0xdd,0x78};
-       BYTE c2[BLOWFISH_BLOCK_SIZE] = {0x51,0x86,0x6f,0xd5,0xb8,0x5e,0xcb,0x8a};
-       BYTE c3[BLOWFISH_BLOCK_SIZE] = {0x05,0x04,0x4b,0x62,0xfa,0x52,0xd0,0x80};
-
-       BYTE enc_buf[BLOWFISH_BLOCK_SIZE];
-       BLOWFISH_KEY key;
-       int pass = 1;
-
-       // Test vector 1.
-       blowfish_key_setup(key1, &key, BLOWFISH_BLOCK_SIZE);
-       blowfish_encrypt(p1, enc_buf, &key);
-       pass = pass && !memcmp(c1, enc_buf, BLOWFISH_BLOCK_SIZE);
-       blowfish_decrypt(c1, enc_buf, &key);
-       pass = pass && !memcmp(p1, enc_buf, BLOWFISH_BLOCK_SIZE);
-
-       // Test vector 2.
-       blowfish_key_setup(key2, &key, BLOWFISH_BLOCK_SIZE);
-       blowfish_encrypt(p2, enc_buf, &key);
-       pass = pass && !memcmp(c2, enc_buf, BLOWFISH_BLOCK_SIZE);
-       blowfish_decrypt(c2, enc_buf, &key);
-       pass = pass && !memcmp(p2, enc_buf, BLOWFISH_BLOCK_SIZE);
-
-       // Test vector 3.
-       blowfish_key_setup(key3, &key, 24);
-       blowfish_encrypt(p3, enc_buf, &key);
-       pass = pass && !memcmp(c3, enc_buf, BLOWFISH_BLOCK_SIZE);
-       blowfish_decrypt(c3, enc_buf, &key);
-       pass = pass && !memcmp(p3, enc_buf, BLOWFISH_BLOCK_SIZE);
-
-       return(pass);
-}
-
-int main()
-{
-       printf("Blowfish tests: %s\n", blowfish_test() ? "SUCCEEDED" : "FAILED");
-
-       return(0);
-}
diff --git a/deps/crypto/crypto_types.h b/deps/crypto/crypto_types.h
deleted file mode 100644 (file)
index 697c983..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*********************************************************************\r
-* Filename:   crypto_types.h\r
-* Author:     Brad Conte (brad AT bradconte.com)\r
-* Copyright:\r
-* Disclaimer: This code is presented "as is" without any guarantees.\r
-* Details:    Defines the API for the corresponding AES implementation.\r
-*********************************************************************/\r
-\r
-#ifndef CRYPTO_TYPES_H\r
-#define CRYPTO_TYPES_H\r
-\r
-typedef unsigned char BYTE;             // 8-bit byte\r
-typedef unsigned int  WORD;             // 32-bit word, change to "long" for 16-bit machines\r
-\r
-#endif\r
diff --git a/deps/crypto/des.c b/deps/crypto/des.c
deleted file mode 100644 (file)
index 1118eb3..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-/*********************************************************************
-* Filename:   des.c
-* Author:     Brad Conte (brad AT radconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Implementation of the DES encryption algorithm.
-              Modes of operation (such as CBC) are not included.
-              The formal NIST algorithm specification can be found here:
-               * http://csrc.nist.gov/publications/fips/fips46-3/fips46-3.pdf
-*********************************************************************/
-
-/*************************** HEADER FILES ***************************/
-#include <stdlib.h>
-#include <string.h>
-#include "des.h"
-
-/****************************** MACROS ******************************/
-// Obtain bit "b" from the left and shift it "c" places from the right
-#define BITNUM(a,b,c) (((a[(b)/8] >> (7 - (b%8))) & 0x01) << (c))
-#define BITNUMINTR(a,b,c) ((((a) >> (31 - (b))) & 0x00000001) << (c))
-#define BITNUMINTL(a,b,c) ((((a) << (b)) & 0x80000000) >> (c))
-
-// This macro converts a 6 bit block with the S-Box row defined as the first and last
-// bits to a 6 bit block with the row defined by the first two bits.
-#define SBOXBIT(a) (((a) & 0x20) | (((a) & 0x1f) >> 1) | (((a) & 0x01) << 4))
-
-/**************************** VARIABLES *****************************/
-static const BYTE sbox1[64] = {
-       14,  4,  13,  1,   2, 15,  11,  8,   3, 10,   6, 12,   5,  9,   0,  7,
-        0, 15,   7,  4,  14,  2,  13,  1,  10,  6,  12, 11,   9,  5,   3,  8,
-        4,  1,  14,  8,  13,  6,   2, 11,  15, 12,   9,  7,   3, 10,   5,  0,
-       15, 12,   8,  2,   4,  9,   1,  7,   5, 11,   3, 14,  10,  0,   6, 13
-};
-static const BYTE sbox2[64] = {
-       15,  1,   8, 14,   6, 11,   3,  4,   9,  7,   2, 13,  12,  0,   5, 10,
-        3, 13,   4,  7,  15,  2,   8, 14,  12,  0,   1, 10,   6,  9,  11,  5,
-        0, 14,   7, 11,  10,  4,  13,  1,   5,  8,  12,  6,   9,  3,   2, 15,
-       13,  8,  10,  1,   3, 15,   4,  2,  11,  6,   7, 12,   0,  5,  14,  9
-};
-static const BYTE sbox3[64] = {
-       10,  0,   9, 14,   6,  3,  15,  5,   1, 13,  12,  7,  11,  4,   2,  8,
-       13,  7,   0,  9,   3,  4,   6, 10,   2,  8,   5, 14,  12, 11,  15,  1,
-       13,  6,   4,  9,   8, 15,   3,  0,  11,  1,   2, 12,   5, 10,  14,  7,
-        1, 10,  13,  0,   6,  9,   8,  7,   4, 15,  14,  3,  11,  5,   2, 12
-};
-static const BYTE sbox4[64] = {
-        7, 13,  14,  3,   0,  6,   9, 10,   1,  2,   8,  5,  11, 12,   4, 15,
-       13,  8,  11,  5,   6, 15,   0,  3,   4,  7,   2, 12,   1, 10,  14,  9,
-       10,  6,   9,  0,  12, 11,   7, 13,  15,  1,   3, 14,   5,  2,   8,  4,
-        3, 15,   0,  6,  10,  1,  13,  8,   9,  4,   5, 11,  12,  7,   2, 14
-};
-static const BYTE sbox5[64] = {
-        2, 12,   4,  1,   7, 10,  11,  6,   8,  5,   3, 15,  13,  0,  14,  9,
-       14, 11,   2, 12,   4,  7,  13,  1,   5,  0,  15, 10,   3,  9,   8,  6,
-        4,  2,   1, 11,  10, 13,   7,  8,  15,  9,  12,  5,   6,  3,   0, 14,
-       11,  8,  12,  7,   1, 14,   2, 13,   6, 15,   0,  9,  10,  4,   5,  3
-};
-static const BYTE sbox6[64] = {
-       12,  1,  10, 15,   9,  2,   6,  8,   0, 13,   3,  4,  14,  7,   5, 11,
-       10, 15,   4,  2,   7, 12,   9,  5,   6,  1,  13, 14,   0, 11,   3,  8,
-        9, 14,  15,  5,   2,  8,  12,  3,   7,  0,   4, 10,   1, 13,  11,  6,
-        4,  3,   2, 12,   9,  5,  15, 10,  11, 14,   1,  7,   6,  0,   8, 13
-};
-static const BYTE sbox7[64] = {
-        4, 11,   2, 14,  15,  0,   8, 13,   3, 12,   9,  7,   5, 10,   6,  1,
-       13,  0,  11,  7,   4,  9,   1, 10,  14,  3,   5, 12,   2, 15,   8,  6,
-        1,  4,  11, 13,  12,  3,   7, 14,  10, 15,   6,  8,   0,  5,   9,  2,
-        6, 11,  13,  8,   1,  4,  10,  7,   9,  5,   0, 15,  14,  2,   3, 12
-};
-static const BYTE sbox8[64] = {
-       13,  2,   8,  4,   6, 15,  11,  1,  10,  9,   3, 14,   5,  0,  12,  7,
-        1, 15,  13,  8,  10,  3,   7,  4,  12,  5,   6, 11,   0, 14,   9,  2,
-        7, 11,   4,  1,   9, 12,  14,  2,   0,  6,  10, 13,  15,  3,   5,  8,
-        2,  1,  14,  7,   4, 10,   8, 13,  15, 12,   9,  0,   3,  5,   6, 11
-};
-
-/*********************** FUNCTION DEFINITIONS ***********************/
-// Initial (Inv)Permutation step
-void IP(WORD state[], const BYTE in[])
-{
-       state[0] = BITNUM(in,57,31) | BITNUM(in,49,30) | BITNUM(in,41,29) | BITNUM(in,33,28) |
-                                 BITNUM(in,25,27) | BITNUM(in,17,26) | BITNUM(in,9,25) | BITNUM(in,1,24) |
-                                 BITNUM(in,59,23) | BITNUM(in,51,22) | BITNUM(in,43,21) | BITNUM(in,35,20) |
-                                 BITNUM(in,27,19) | BITNUM(in,19,18) | BITNUM(in,11,17) | BITNUM(in,3,16) |
-                                 BITNUM(in,61,15) | BITNUM(in,53,14) | BITNUM(in,45,13) | BITNUM(in,37,12) |
-                                 BITNUM(in,29,11) | BITNUM(in,21,10) | BITNUM(in,13,9) | BITNUM(in,5,8) |
-                                 BITNUM(in,63,7) | BITNUM(in,55,6) | BITNUM(in,47,5) | BITNUM(in,39,4) |
-                                 BITNUM(in,31,3) | BITNUM(in,23,2) | BITNUM(in,15,1) | BITNUM(in,7,0);
-
-       state[1] = BITNUM(in,56,31) | BITNUM(in,48,30) | BITNUM(in,40,29) | BITNUM(in,32,28) |
-                                 BITNUM(in,24,27) | BITNUM(in,16,26) | BITNUM(in,8,25) | BITNUM(in,0,24) |
-                                 BITNUM(in,58,23) | BITNUM(in,50,22) | BITNUM(in,42,21) | BITNUM(in,34,20) |
-                                 BITNUM(in,26,19) | BITNUM(in,18,18) | BITNUM(in,10,17) | BITNUM(in,2,16) |
-                                 BITNUM(in,60,15) | BITNUM(in,52,14) | BITNUM(in,44,13) | BITNUM(in,36,12) |
-                                 BITNUM(in,28,11) | BITNUM(in,20,10) | BITNUM(in,12,9) | BITNUM(in,4,8) |
-                                 BITNUM(in,62,7) | BITNUM(in,54,6) | BITNUM(in,46,5) | BITNUM(in,38,4) |
-                                 BITNUM(in,30,3) | BITNUM(in,22,2) | BITNUM(in,14,1) | BITNUM(in,6,0);
-}
-
-void InvIP(WORD state[], BYTE in[])
-{
-       in[0] = BITNUMINTR(state[1],7,7) | BITNUMINTR(state[0],7,6) | BITNUMINTR(state[1],15,5) |
-                         BITNUMINTR(state[0],15,4) | BITNUMINTR(state[1],23,3) | BITNUMINTR(state[0],23,2) |
-                         BITNUMINTR(state[1],31,1) | BITNUMINTR(state[0],31,0);
-
-       in[1] = BITNUMINTR(state[1],6,7) | BITNUMINTR(state[0],6,6) | BITNUMINTR(state[1],14,5) |
-                         BITNUMINTR(state[0],14,4) | BITNUMINTR(state[1],22,3) | BITNUMINTR(state[0],22,2) |
-                         BITNUMINTR(state[1],30,1) | BITNUMINTR(state[0],30,0);
-
-       in[2] = BITNUMINTR(state[1],5,7) | BITNUMINTR(state[0],5,6) | BITNUMINTR(state[1],13,5) |
-                         BITNUMINTR(state[0],13,4) | BITNUMINTR(state[1],21,3) | BITNUMINTR(state[0],21,2) |
-                         BITNUMINTR(state[1],29,1) | BITNUMINTR(state[0],29,0);
-
-       in[3] = BITNUMINTR(state[1],4,7) | BITNUMINTR(state[0],4,6) | BITNUMINTR(state[1],12,5) |
-                         BITNUMINTR(state[0],12,4) | BITNUMINTR(state[1],20,3) | BITNUMINTR(state[0],20,2) |
-                         BITNUMINTR(state[1],28,1) | BITNUMINTR(state[0],28,0);
-
-       in[4] = BITNUMINTR(state[1],3,7) | BITNUMINTR(state[0],3,6) | BITNUMINTR(state[1],11,5) |
-                         BITNUMINTR(state[0],11,4) | BITNUMINTR(state[1],19,3) | BITNUMINTR(state[0],19,2) |
-                         BITNUMINTR(state[1],27,1) | BITNUMINTR(state[0],27,0);
-
-       in[5] = BITNUMINTR(state[1],2,7) | BITNUMINTR(state[0],2,6) | BITNUMINTR(state[1],10,5) |
-                         BITNUMINTR(state[0],10,4) | BITNUMINTR(state[1],18,3) | BITNUMINTR(state[0],18,2) |
-                         BITNUMINTR(state[1],26,1) | BITNUMINTR(state[0],26,0);
-
-       in[6] = BITNUMINTR(state[1],1,7) | BITNUMINTR(state[0],1,6) | BITNUMINTR(state[1],9,5) |
-                         BITNUMINTR(state[0],9,4) | BITNUMINTR(state[1],17,3) | BITNUMINTR(state[0],17,2) |
-                         BITNUMINTR(state[1],25,1) | BITNUMINTR(state[0],25,0);
-
-       in[7] = BITNUMINTR(state[1],0,7) | BITNUMINTR(state[0],0,6) | BITNUMINTR(state[1],8,5) |
-                         BITNUMINTR(state[0],8,4) | BITNUMINTR(state[1],16,3) | BITNUMINTR(state[0],16,2) |
-                         BITNUMINTR(state[1],24,1) | BITNUMINTR(state[0],24,0);
-}
-
-WORD f(WORD state, const BYTE key[])
-{
-       BYTE lrgstate[6]; //,i;
-       WORD t1,t2;
-
-       // Expantion Permutation
-       t1 = BITNUMINTL(state,31,0) | ((state & 0xf0000000) >> 1) | BITNUMINTL(state,4,5) |
-                 BITNUMINTL(state,3,6) | ((state & 0x0f000000) >> 3) | BITNUMINTL(state,8,11) |
-                 BITNUMINTL(state,7,12) | ((state & 0x00f00000) >> 5) | BITNUMINTL(state,12,17) |
-                 BITNUMINTL(state,11,18) | ((state & 0x000f0000) >> 7) | BITNUMINTL(state,16,23);
-
-       t2 = BITNUMINTL(state,15,0) | ((state & 0x0000f000) << 15) | BITNUMINTL(state,20,5) |
-                 BITNUMINTL(state,19,6) | ((state & 0x00000f00) << 13) | BITNUMINTL(state,24,11) |
-                 BITNUMINTL(state,23,12) | ((state & 0x000000f0) << 11) | BITNUMINTL(state,28,17) |
-                 BITNUMINTL(state,27,18) | ((state & 0x0000000f) << 9) | BITNUMINTL(state,0,23);
-
-       lrgstate[0] = (t1 >> 24) & 0x000000ff;
-       lrgstate[1] = (t1 >> 16) & 0x000000ff;
-       lrgstate[2] = (t1 >> 8) & 0x000000ff;
-       lrgstate[3] = (t2 >> 24) & 0x000000ff;
-       lrgstate[4] = (t2 >> 16) & 0x000000ff;
-       lrgstate[5] = (t2 >> 8) & 0x000000ff;
-
-       // Key XOR
-       lrgstate[0] ^= key[0];
-       lrgstate[1] ^= key[1];
-       lrgstate[2] ^= key[2];
-       lrgstate[3] ^= key[3];
-       lrgstate[4] ^= key[4];
-       lrgstate[5] ^= key[5];
-
-       // S-Box Permutation
-       state = (sbox1[SBOXBIT(lrgstate[0] >> 2)] << 28) |
-                         (sbox2[SBOXBIT(((lrgstate[0] & 0x03) << 4) | (lrgstate[1] >> 4))] << 24) |
-                         (sbox3[SBOXBIT(((lrgstate[1] & 0x0f) << 2) | (lrgstate[2] >> 6))] << 20) |
-                         (sbox4[SBOXBIT(lrgstate[2] & 0x3f)] << 16) |
-                         (sbox5[SBOXBIT(lrgstate[3] >> 2)] << 12) |
-                         (sbox6[SBOXBIT(((lrgstate[3] & 0x03) << 4) | (lrgstate[4] >> 4))] << 8) |
-                         (sbox7[SBOXBIT(((lrgstate[4] & 0x0f) << 2) | (lrgstate[5] >> 6))] << 4) |
-                               sbox8[SBOXBIT(lrgstate[5] & 0x3f)];
-
-       // P-Box Permutation
-       state = BITNUMINTL(state,15,0) | BITNUMINTL(state,6,1) | BITNUMINTL(state,19,2) |
-                         BITNUMINTL(state,20,3) | BITNUMINTL(state,28,4) | BITNUMINTL(state,11,5) |
-                         BITNUMINTL(state,27,6) | BITNUMINTL(state,16,7) | BITNUMINTL(state,0,8) |
-                         BITNUMINTL(state,14,9) | BITNUMINTL(state,22,10) | BITNUMINTL(state,25,11) |
-                         BITNUMINTL(state,4,12) | BITNUMINTL(state,17,13) | BITNUMINTL(state,30,14) |
-                         BITNUMINTL(state,9,15) | BITNUMINTL(state,1,16) | BITNUMINTL(state,7,17) |
-                         BITNUMINTL(state,23,18) | BITNUMINTL(state,13,19) | BITNUMINTL(state,31,20) |
-                         BITNUMINTL(state,26,21) | BITNUMINTL(state,2,22) | BITNUMINTL(state,8,23) |
-                         BITNUMINTL(state,18,24) | BITNUMINTL(state,12,25) | BITNUMINTL(state,29,26) |
-                         BITNUMINTL(state,5,27) | BITNUMINTL(state,21,28) | BITNUMINTL(state,10,29) |
-                         BITNUMINTL(state,3,30) | BITNUMINTL(state,24,31);
-
-       // Return the final state value
-       return(state);
-}
-
-void des_key_setup(const BYTE key[], BYTE schedule[][6], DES_MODE mode)
-{
-       WORD i, j, to_gen, C, D;
-       const WORD key_rnd_shift[16] = {1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1};
-       const WORD key_perm_c[28] = {56,48,40,32,24,16,8,0,57,49,41,33,25,17,
-                                    9,1,58,50,42,34,26,18,10,2,59,51,43,35};
-       const WORD key_perm_d[28] = {62,54,46,38,30,22,14,6,61,53,45,37,29,21,
-                                    13,5,60,52,44,36,28,20,12,4,27,19,11,3};
-       const WORD key_compression[48] = {13,16,10,23,0,4,2,27,14,5,20,9,
-                                         22,18,11,3,25,7,15,6,26,19,12,1,
-                                         40,51,30,36,46,54,29,39,50,44,32,47,
-                                         43,48,38,55,33,52,45,41,49,35,28,31};
-
-       // Permutated Choice #1 (copy the key in, ignoring parity bits).
-       for (i = 0, j = 31, C = 0; i < 28; ++i, --j)
-               C |= BITNUM(key,key_perm_c[i],j);
-       for (i = 0, j = 31, D = 0; i < 28; ++i, --j)
-               D |= BITNUM(key,key_perm_d[i],j);
-
-       // Generate the 16 subkeys.
-       for (i = 0; i < 16; ++i) {
-               C = ((C << key_rnd_shift[i]) | (C >> (28-key_rnd_shift[i]))) & 0xfffffff0;
-               D = ((D << key_rnd_shift[i]) | (D >> (28-key_rnd_shift[i]))) & 0xfffffff0;
-
-               // Decryption subkeys are reverse order of encryption subkeys so
-               // generate them in reverse if the key schedule is for decryption useage.
-               if (mode == DES_DECRYPT)
-                       to_gen = 15 - i;
-               else /*(if mode == DES_ENCRYPT)*/
-                       to_gen = i;
-               // Initialize the array
-               for (j = 0; j < 6; ++j)
-                       schedule[to_gen][j] = 0;
-               for (j = 0; j < 24; ++j)
-                       schedule[to_gen][j/8] |= BITNUMINTR(C,key_compression[j],7 - (j%8));
-               for ( ; j < 48; ++j)
-                       schedule[to_gen][j/8] |= BITNUMINTR(D,key_compression[j] - 28,7 - (j%8));
-       }
-}
-
-void des_crypt(const BYTE in[], BYTE out[], const BYTE key[][6])
-{
-       WORD state[2],idx,t;
-
-       IP(state,in);
-
-       for (idx=0; idx < 15; ++idx) {
-               t = state[1];
-               state[1] = f(state[1],key[idx]) ^ state[0];
-               state[0] = t;
-       }
-       // Perform the final loop manually as it doesn't switch sides
-       state[0] = f(state[1],key[15]) ^ state[0];
-
-       InvIP(state,out);
-}
-
-void three_des_key_setup(const BYTE key[], BYTE schedule[][16][6], DES_MODE mode)
-{
-       if (mode == DES_ENCRYPT) {
-               des_key_setup(&key[0],schedule[0],mode);
-               des_key_setup(&key[8],schedule[1],!mode);
-               des_key_setup(&key[16],schedule[2],mode);
-       }
-       else /*if (mode == DES_DECRYPT*/ {
-               des_key_setup(&key[16],schedule[0],mode);
-               des_key_setup(&key[8],schedule[1],!mode);
-               des_key_setup(&key[0],schedule[2],mode);
-       }
-}
-
-void three_des_crypt(const BYTE in[], BYTE out[], const BYTE key[][16][6])
-{
-       des_crypt(in,out,key[0]);
-       des_crypt(out,out,key[1]);
-       des_crypt(out,out,key[2]);
-}
diff --git a/deps/crypto/des.h b/deps/crypto/des.h
deleted file mode 100644 (file)
index 1503772..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*********************************************************************
-* Filename:   des.h
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Defines the API for the corresponding DES implementation.
-              Note that encryption and decryption are defined by how
-              the key setup is performed, the actual en/de-cryption is
-              performed by the same function.
-*********************************************************************/
-
-#ifndef DES_H
-#define DESH
-
-/*************************** HEADER FILES ***************************/
-#include <stddef.h>
-
-/****************************** MACROS ******************************/
-#define DES_BLOCK_SIZE 8                // DES operates on 8 bytes at a time
-
-/**************************** DATA TYPES ****************************/
-typedef unsigned char BYTE;             // 8-bit byte
-typedef unsigned int  WORD;             // 32-bit word, change to "long" for 16-bit machines
-
-typedef enum {
-       DES_ENCRYPT,
-       DES_DECRYPT
-} DES_MODE;
-
-/*********************** FUNCTION DECLARATIONS **********************/
-void des_key_setup(const BYTE key[], BYTE schedule[][6], DES_MODE mode);
-void des_crypt(const BYTE in[], BYTE out[], const BYTE key[][6]);
-
-void three_des_key_setup(const BYTE key[], BYTE schedule[][16][6], DES_MODE mode);
-void three_des_crypt(const BYTE in[], BYTE out[], const BYTE key[][16][6]);
-
-#endif   // DES_H
diff --git a/deps/crypto/des_test.c b/deps/crypto/des_test.c
deleted file mode 100644 (file)
index 3e46134..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*********************************************************************
-* Filename:   des_test.c
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Performs known-answer tests on the corresponding DES
-                 implementation. These tests do not encompass the full
-                 range of available test vectors, however, if the tests
-                 pass it is very, very likely that the code is correct
-                 and was compiled properly. This code also serves as
-                 example usage of the functions.
-*********************************************************************/
-
-/*************************** HEADER FILES ***************************/
-#include <stdio.h>
-#include <memory.h>
-#include "des.h"
-
-/*********************** FUNCTION DEFINITIONS ***********************/
-int des_test()
-{
-       BYTE pt1[DES_BLOCK_SIZE] = {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xE7};
-       BYTE pt2[DES_BLOCK_SIZE] = {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF};
-       BYTE pt3[DES_BLOCK_SIZE] = {0x54,0x68,0x65,0x20,0x71,0x75,0x66,0x63};
-       BYTE ct1[DES_BLOCK_SIZE] = {0xc9,0x57,0x44,0x25,0x6a,0x5e,0xd3,0x1d};
-       BYTE ct2[DES_BLOCK_SIZE] = {0x85,0xe8,0x13,0x54,0x0f,0x0a,0xb4,0x05};
-       BYTE ct3[DES_BLOCK_SIZE] = {0xc9,0x57,0x44,0x25,0x6a,0x5e,0xd3,0x1d};
-       BYTE ct4[DES_BLOCK_SIZE] = {0xA8,0x26,0xFD,0x8C,0xE5,0x3B,0x85,0x5F};
-       BYTE key1[DES_BLOCK_SIZE] = {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF};
-       BYTE key2[DES_BLOCK_SIZE] = {0x13,0x34,0x57,0x79,0x9B,0xBC,0xDF,0xF1};
-       BYTE three_key1[DES_BLOCK_SIZE * 3] = {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
-                                              0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
-                                              0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF};
-       BYTE three_key2[DES_BLOCK_SIZE * 3] = {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
-                                              0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,0x01,
-                                              0x45,0x67,0x89,0xAB,0xCD,0xEF,0x01,0x23};
-
-       BYTE schedule[16][6];
-       BYTE three_schedule[3][16][6];
-       BYTE buf[DES_BLOCK_SIZE];
-       int pass = 1;
-
-       des_key_setup(key1, schedule, DES_ENCRYPT);
-       des_crypt(pt1, buf, schedule);
-       pass = pass && !memcmp(ct1, buf, DES_BLOCK_SIZE);
-
-       des_key_setup(key1, schedule, DES_DECRYPT);
-       des_crypt(ct1, buf, schedule);
-       pass = pass && !memcmp(pt1, buf, DES_BLOCK_SIZE);
-
-       des_key_setup(key2, schedule, DES_ENCRYPT);
-       des_crypt(pt2, buf, schedule);
-       pass = pass && !memcmp(ct2, buf, DES_BLOCK_SIZE);
-
-       des_key_setup(key2, schedule, DES_DECRYPT);
-       des_crypt(ct2, buf, schedule);
-       pass = pass && !memcmp(pt2, buf, DES_BLOCK_SIZE);
-
-       three_des_key_setup(three_key1, three_schedule, DES_ENCRYPT);
-       three_des_crypt(pt1, buf, three_schedule);
-       pass = pass && !memcmp(ct3, buf, DES_BLOCK_SIZE);
-
-       three_des_key_setup(three_key1, three_schedule, DES_DECRYPT);
-       three_des_crypt(ct3, buf, three_schedule);
-       pass = pass && !memcmp(pt1, buf, DES_BLOCK_SIZE);
-
-       three_des_key_setup(three_key2, three_schedule, DES_ENCRYPT);
-       three_des_crypt(pt3, buf, three_schedule);
-       pass = pass && !memcmp(ct4, buf, DES_BLOCK_SIZE);
-
-       three_des_key_setup(three_key2, three_schedule, DES_DECRYPT);
-       three_des_crypt(ct4, buf, three_schedule);
-       pass = pass && !memcmp(pt3, buf, DES_BLOCK_SIZE);
-
-       return(pass);
-}
-
-int main()
-{
-       printf("DES test: %s\n", des_test() ? "SUCCEEDED" : "FAILED");
-
-       return(0);
-}
diff --git a/deps/crypto/md2.c b/deps/crypto/md2.c
deleted file mode 100644 (file)
index e66d667..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*********************************************************************
-* Filename:   md2.c
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Implementation of the MD2 hashing algorithm.
-                                 Algorithm specification can be found here:
-                                  * http://tools.ietf.org/html/rfc1319 .
-              Input is  little endian byte order.
-*********************************************************************/
-
-/*************************** HEADER FILES ***************************/
-#include <stdlib.h>
-#include <string.h>
-#include "md2.h"
-
-/**************************** VARIABLES *****************************/
-static const BYTE s[256] = {
-       41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6,
-       19, 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188,
-       76, 130, 202, 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24,
-       138, 23, 229, 18, 190, 78, 196, 214, 218, 158, 222, 73, 160, 251,
-       245, 142, 187, 47, 238, 122, 169, 104, 121, 145, 21, 178, 7, 63,
-       148, 194, 16, 137, 11, 34, 95, 33, 128, 127, 93, 154, 90, 144, 50,
-       39, 53, 62, 204, 231, 191, 247, 151, 3, 255, 25, 48, 179, 72, 165,
-       181, 209, 215, 94, 146, 42, 172, 86, 170, 198, 79, 184, 56, 210,
-       150, 164, 125, 182, 118, 252, 107, 226, 156, 116, 4, 241, 69, 157,
-       112, 89, 100, 113, 135, 32, 134, 91, 207, 101, 230, 45, 168, 2, 27,
-       96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15,
-       85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197,
-       234, 38, 44, 83, 13, 110, 133, 40, 132, 9, 211, 223, 205, 244, 65,
-       129, 77, 82, 106, 220, 55, 200, 108, 193, 171, 250, 36, 225, 123,
-       8, 12, 189, 177, 74, 120, 136, 149, 139, 227, 99, 232, 109, 233,
-       203, 213, 254, 59, 0, 29, 57, 242, 239, 183, 14, 102, 88, 208, 228,
-       166, 119, 114, 248, 235, 117, 75, 10, 49, 68, 80, 180, 143, 237,
-       31, 26, 219, 153, 141, 51, 159, 17, 131, 20
-};
-
-/*********************** FUNCTION DEFINITIONS ***********************/
-void md2_transform(MD2_CTX *ctx, BYTE data[])
-{
-       int j,k,t;
-
-       //memcpy(&ctx->state[16], data);
-       for (j=0; j < 16; ++j) {
-               ctx->state[j + 16] = data[j];
-               ctx->state[j + 32] = (ctx->state[j+16] ^ ctx->state[j]);
-       }
-
-       t = 0;
-       for (j = 0; j < 18; ++j) {
-               for (k = 0; k < 48; ++k) {
-                       ctx->state[k] ^= s[t];
-                       t = ctx->state[k];
-               }
-               t = (t+j) & 0xFF;
-       }
-
-       t = ctx->checksum[15];
-       for (j=0; j < 16; ++j) {
-               ctx->checksum[j] ^= s[data[j] ^ t];
-               t = ctx->checksum[j];
-       }
-}
-
-void md2_init(MD2_CTX *ctx)
-{
-       int i;
-
-       for (i=0; i < 48; ++i)
-               ctx->state[i] = 0;
-       for (i=0; i < 16; ++i)
-               ctx->checksum[i] = 0;
-       ctx->len = 0;
-}
-
-void md2_update(MD2_CTX *ctx, const BYTE data[], size_t len)
-{
-       size_t i;
-
-       for (i = 0; i < len; ++i) {
-               ctx->data[ctx->len] = data[i];
-               ctx->len++;
-               if (ctx->len == MD2_BLOCK_SIZE) {
-                       md2_transform(ctx, ctx->data);
-                       ctx->len = 0;
-               }
-       }
-}
-
-void md2_final(MD2_CTX *ctx, BYTE hash[])
-{
-       int to_pad;
-
-       to_pad = MD2_BLOCK_SIZE - ctx->len;
-
-       while (ctx->len < MD2_BLOCK_SIZE)
-               ctx->data[ctx->len++] = to_pad;
-
-       md2_transform(ctx, ctx->data);
-       md2_transform(ctx, ctx->checksum);
-
-       memcpy(hash, ctx->state, MD2_BLOCK_SIZE);
-}
diff --git a/deps/crypto/md2.h b/deps/crypto/md2.h
deleted file mode 100644 (file)
index 97706af..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*********************************************************************
-* Filename:   md2.h
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Defines the API for the corresponding MD2 implementation.
-*********************************************************************/
-
-#ifndef MD2_H
-#define MD2_H
-
-/*************************** HEADER FILES ***************************/
-#include <stddef.h>
-
-/****************************** MACROS ******************************/
-#define MD2_BLOCK_SIZE 16
-
-/**************************** DATA TYPES ****************************/
-typedef unsigned char BYTE;             // 8-bit byte
-
-typedef struct {
-   BYTE data[16];
-   BYTE state[48];
-   BYTE checksum[16];
-   int len;
-} MD2_CTX;
-
-/*********************** FUNCTION DECLARATIONS **********************/
-void md2_init(MD2_CTX *ctx);
-void md2_update(MD2_CTX *ctx, const BYTE data[], size_t len);
-void md2_final(MD2_CTX *ctx, BYTE hash[]);   // size of hash must be MD2_BLOCK_SIZE
-
-#endif   // MD2_H
diff --git a/deps/crypto/md2_test.c b/deps/crypto/md2_test.c
deleted file mode 100644 (file)
index 883f20a..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*********************************************************************
-* Filename:   md2_test.c
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Performs known-answer tests on the corresponding MD2
-                 implementation. These tests do not encompass the full
-                 range of available test vectors, however, if the tests
-                 pass it is very, very likely that the code is correct
-                 and was compiled properly. This code also serves as
-                 example usage of the functions.
-*********************************************************************/
-
-/*************************** HEADER FILES ***************************/
-#include <stdio.h>
-#include <string.h>
-#include <memory.h>
-#include "md2.h"
-
-/*********************** FUNCTION DEFINITIONS ***********************/
-int md2_test()
-{
-       BYTE text1[] = {"abc"};
-       BYTE text2[] = {"abcdefghijklmnopqrstuvwxyz"};
-       BYTE text3_1[] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZabcde"};
-       BYTE text3_2[] = {"fghijklmnopqrstuvwxyz0123456789"};
-       BYTE hash1[MD2_BLOCK_SIZE] = {0xda,0x85,0x3b,0x0d,0x3f,0x88,0xd9,0x9b,0x30,0x28,0x3a,0x69,0xe6,0xde,0xd6,0xbb};
-       BYTE hash2[MD2_BLOCK_SIZE] = {0x4e,0x8d,0xdf,0xf3,0x65,0x02,0x92,0xab,0x5a,0x41,0x08,0xc3,0xaa,0x47,0x94,0x0b};
-       BYTE hash3[MD2_BLOCK_SIZE] = {0xda,0x33,0xde,0xf2,0xa4,0x2d,0xf1,0x39,0x75,0x35,0x28,0x46,0xc3,0x03,0x38,0xcd};
-       BYTE buf[16];
-       MD2_CTX ctx;
-       int pass = 1;
-
-       md2_init(&ctx);
-       md2_update(&ctx, text1, strlen(text1));
-       md2_final(&ctx, buf);
-       pass = pass && !memcmp(hash1, buf, MD2_BLOCK_SIZE);
-
-       // Note that the MD2 object can be re-used.
-       md2_init(&ctx);
-       md2_update(&ctx, text2, strlen(text2));
-       md2_final(&ctx, buf);
-       pass = pass && !memcmp(hash2, buf, MD2_BLOCK_SIZE);
-
-       // Note that the data is added in two chunks.
-       md2_init(&ctx);
-       md2_update(&ctx, text3_1, strlen(text3_1));
-       md2_update(&ctx, text3_2, strlen(text3_2));
-       md2_final(&ctx, buf);
-       pass = pass && !memcmp(hash3, buf, MD2_BLOCK_SIZE);
-
-       return(pass);
-}
-
-int main()
-{
-       printf("MD2 tests: %s\n", md2_test() ? "SUCCEEDED" : "FAILED");
-}
diff --git a/deps/crypto/md5.c b/deps/crypto/md5.c
deleted file mode 100644 (file)
index 769199e..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-/*********************************************************************
-* Filename:   md5.c
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Implementation of the MD5 hashing algorithm.
-                                 Algorithm specification can be found here:
-                                  * http://tools.ietf.org/html/rfc1321
-                                 This implementation uses little endian byte order.
-*********************************************************************/
-
-/*************************** HEADER FILES ***************************/
-#include <stdlib.h>
-#include <string.h>
-#include "md5.h"
-
-/****************************** MACROS ******************************/
-#define ROTLEFT(a,b) ((a << b) | (a >> (32-b)))
-
-#define F(x,y,z) ((x & y) | (~x & z))
-#define G(x,y,z) ((x & z) | (y & ~z))
-#define H(x,y,z) (x ^ y ^ z)
-#define I(x,y,z) (y ^ (x | ~z))
-
-#define FF(a,b,c,d,m,s,t) { a += F(b,c,d) + m + t; \
-                            a = b + ROTLEFT(a,s); }
-#define GG(a,b,c,d,m,s,t) { a += G(b,c,d) + m + t; \
-                            a = b + ROTLEFT(a,s); }
-#define HH(a,b,c,d,m,s,t) { a += H(b,c,d) + m + t; \
-                            a = b + ROTLEFT(a,s); }
-#define II(a,b,c,d,m,s,t) { a += I(b,c,d) + m + t; \
-                            a = b + ROTLEFT(a,s); }
-
-/*********************** FUNCTION DEFINITIONS ***********************/
-void md5_transform(MD5_CTX *ctx, const BYTE data[])
-{
-       WORD a, b, c, d, m[16], i, j;
-
-       // MD5 specifies big endian byte order, but this implementation assumes a little
-       // endian byte order CPU. Reverse all the bytes upon input, and re-reverse them
-       // on output (in md5_final()).
-       for (i = 0, j = 0; i < 16; ++i, j += 4)
-               m[i] = (data[j]) + (data[j + 1] << 8) + (data[j + 2] << 16) + (data[j + 3] << 24);
-
-       a = ctx->state[0];
-       b = ctx->state[1];
-       c = ctx->state[2];
-       d = ctx->state[3];
-
-       FF(a,b,c,d,m[0],  7,0xd76aa478);
-       FF(d,a,b,c,m[1], 12,0xe8c7b756);
-       FF(c,d,a,b,m[2], 17,0x242070db);
-       FF(b,c,d,a,m[3], 22,0xc1bdceee);
-       FF(a,b,c,d,m[4],  7,0xf57c0faf);
-       FF(d,a,b,c,m[5], 12,0x4787c62a);
-       FF(c,d,a,b,m[6], 17,0xa8304613);
-       FF(b,c,d,a,m[7], 22,0xfd469501);
-       FF(a,b,c,d,m[8],  7,0x698098d8);
-       FF(d,a,b,c,m[9], 12,0x8b44f7af);
-       FF(c,d,a,b,m[10],17,0xffff5bb1);
-       FF(b,c,d,a,m[11],22,0x895cd7be);
-       FF(a,b,c,d,m[12], 7,0x6b901122);
-       FF(d,a,b,c,m[13],12,0xfd987193);
-       FF(c,d,a,b,m[14],17,0xa679438e);
-       FF(b,c,d,a,m[15],22,0x49b40821);
-
-       GG(a,b,c,d,m[1],  5,0xf61e2562);
-       GG(d,a,b,c,m[6],  9,0xc040b340);
-       GG(c,d,a,b,m[11],14,0x265e5a51);
-       GG(b,c,d,a,m[0], 20,0xe9b6c7aa);
-       GG(a,b,c,d,m[5],  5,0xd62f105d);
-       GG(d,a,b,c,m[10], 9,0x02441453);
-       GG(c,d,a,b,m[15],14,0xd8a1e681);
-       GG(b,c,d,a,m[4], 20,0xe7d3fbc8);
-       GG(a,b,c,d,m[9],  5,0x21e1cde6);
-       GG(d,a,b,c,m[14], 9,0xc33707d6);
-       GG(c,d,a,b,m[3], 14,0xf4d50d87);
-       GG(b,c,d,a,m[8], 20,0x455a14ed);
-       GG(a,b,c,d,m[13], 5,0xa9e3e905);
-       GG(d,a,b,c,m[2],  9,0xfcefa3f8);
-       GG(c,d,a,b,m[7], 14,0x676f02d9);
-       GG(b,c,d,a,m[12],20,0x8d2a4c8a);
-
-       HH(a,b,c,d,m[5],  4,0xfffa3942);
-       HH(d,a,b,c,m[8], 11,0x8771f681);
-       HH(c,d,a,b,m[11],16,0x6d9d6122);
-       HH(b,c,d,a,m[14],23,0xfde5380c);
-       HH(a,b,c,d,m[1],  4,0xa4beea44);
-       HH(d,a,b,c,m[4], 11,0x4bdecfa9);
-       HH(c,d,a,b,m[7], 16,0xf6bb4b60);
-       HH(b,c,d,a,m[10],23,0xbebfbc70);
-       HH(a,b,c,d,m[13], 4,0x289b7ec6);
-       HH(d,a,b,c,m[0], 11,0xeaa127fa);
-       HH(c,d,a,b,m[3], 16,0xd4ef3085);
-       HH(b,c,d,a,m[6], 23,0x04881d05);
-       HH(a,b,c,d,m[9],  4,0xd9d4d039);
-       HH(d,a,b,c,m[12],11,0xe6db99e5);
-       HH(c,d,a,b,m[15],16,0x1fa27cf8);
-       HH(b,c,d,a,m[2], 23,0xc4ac5665);
-
-       II(a,b,c,d,m[0],  6,0xf4292244);
-       II(d,a,b,c,m[7], 10,0x432aff97);
-       II(c,d,a,b,m[14],15,0xab9423a7);
-       II(b,c,d,a,m[5], 21,0xfc93a039);
-       II(a,b,c,d,m[12], 6,0x655b59c3);
-       II(d,a,b,c,m[3], 10,0x8f0ccc92);
-       II(c,d,a,b,m[10],15,0xffeff47d);
-       II(b,c,d,a,m[1], 21,0x85845dd1);
-       II(a,b,c,d,m[8],  6,0x6fa87e4f);
-       II(d,a,b,c,m[15],10,0xfe2ce6e0);
-       II(c,d,a,b,m[6], 15,0xa3014314);
-       II(b,c,d,a,m[13],21,0x4e0811a1);
-       II(a,b,c,d,m[4],  6,0xf7537e82);
-       II(d,a,b,c,m[11],10,0xbd3af235);
-       II(c,d,a,b,m[2], 15,0x2ad7d2bb);
-       II(b,c,d,a,m[9], 21,0xeb86d391);
-
-       ctx->state[0] += a;
-       ctx->state[1] += b;
-       ctx->state[2] += c;
-       ctx->state[3] += d;
-}
-
-void md5_init(MD5_CTX *ctx)
-{
-       ctx->datalen = 0;
-       ctx->bitlen = 0;
-       ctx->state[0] = 0x67452301;
-       ctx->state[1] = 0xEFCDAB89;
-       ctx->state[2] = 0x98BADCFE;
-       ctx->state[3] = 0x10325476;
-}
-
-void md5_update(MD5_CTX *ctx, const BYTE data[], size_t len)
-{
-       size_t i;
-
-       for (i = 0; i < len; ++i) {
-               ctx->data[ctx->datalen] = data[i];
-               ctx->datalen++;
-               if (ctx->datalen == 64) {
-                       md5_transform(ctx, ctx->data);
-                       ctx->bitlen += 512;
-                       ctx->datalen = 0;
-               }
-       }
-}
-
-void md5_final(MD5_CTX *ctx, BYTE hash[])
-{
-       size_t i;
-
-       i = ctx->datalen;
-
-       // Pad whatever data is left in the buffer.
-       if (ctx->datalen < 56) {
-               ctx->data[i++] = 0x80;
-               while (i < 56)
-                       ctx->data[i++] = 0x00;
-       }
-       else if (ctx->datalen >= 56) {
-               ctx->data[i++] = 0x80;
-               while (i < 64)
-                       ctx->data[i++] = 0x00;
-               md5_transform(ctx, ctx->data);
-               memset(ctx->data, 0, 56);
-       }
-
-       // Append to the padding the total message's length in bits and transform.
-       ctx->bitlen += ctx->datalen * 8;
-       ctx->data[56] = ctx->bitlen;
-       ctx->data[57] = ctx->bitlen >> 8;
-       ctx->data[58] = ctx->bitlen >> 16;
-       ctx->data[59] = ctx->bitlen >> 24;
-       ctx->data[60] = ctx->bitlen >> 32;
-       ctx->data[61] = ctx->bitlen >> 40;
-       ctx->data[62] = ctx->bitlen >> 48;
-       ctx->data[63] = ctx->bitlen >> 56;
-       md5_transform(ctx, ctx->data);
-
-       // Since this implementation uses little endian byte ordering and MD uses big endian,
-       // reverse all the bytes when copying the final state to the output hash.
-       for (i = 0; i < 4; ++i) {
-               hash[i]      = (ctx->state[0] >> (i * 8)) & 0x000000ff;
-               hash[i + 4]  = (ctx->state[1] >> (i * 8)) & 0x000000ff;
-               hash[i + 8]  = (ctx->state[2] >> (i * 8)) & 0x000000ff;
-               hash[i + 12] = (ctx->state[3] >> (i * 8)) & 0x000000ff;
-       }
-}
diff --git a/deps/crypto/md5.h b/deps/crypto/md5.h
deleted file mode 100644 (file)
index e5b4490..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*********************************************************************
-* Filename:   md5.h
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Defines the API for the corresponding MD5 implementation.
-*********************************************************************/
-
-#ifndef MD5_H
-#define MD5_H
-
-/*************************** HEADER FILES ***************************/
-#include <stddef.h>
-#include "crypto_types.h"
-
-/****************************** MACROS ******************************/
-#define MD5_BLOCK_SIZE 16               // MD5 outputs a 16 byte digest
-
-/**************************** DATA TYPES ****************************/
-
-typedef struct {
-   BYTE data[64];
-   WORD datalen;
-   unsigned long long bitlen;
-   WORD state[4];
-} MD5_CTX;
-
-/*********************** FUNCTION DECLARATIONS **********************/
-void md5_init(MD5_CTX *ctx);
-void md5_update(MD5_CTX *ctx, const BYTE data[], size_t len);
-void md5_final(MD5_CTX *ctx, BYTE hash[]);
-
-#endif   // MD5_H
diff --git a/deps/crypto/md5_test.c b/deps/crypto/md5_test.c
deleted file mode 100644 (file)
index e945c8b..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*********************************************************************
-* Filename:   md5_test.c
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Performs known-answer tests on the corresponding MD5
-                 implementation. These tests do not encompass the full
-                 range of available test vectors, however, if the tests
-                 pass it is very, very likely that the code is correct
-                 and was compiled properly. This code also serves as
-                 example usage of the functions.
-*********************************************************************/
-
-/*************************** HEADER FILES ***************************/
-#include <stdio.h>
-#include <memory.h>
-#include <string.h>
-#include "md5.h"
-
-/*********************** FUNCTION DEFINITIONS ***********************/
-int md5_test()
-{
-       BYTE text1[] = {""};
-       BYTE text2[] = {"abc"};
-       BYTE text3_1[] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZabcde"};
-       BYTE text3_2[] = {"fghijklmnopqrstuvwxyz0123456789"};
-       BYTE hash1[MD5_BLOCK_SIZE] = {0xd4,0x1d,0x8c,0xd9,0x8f,0x00,0xb2,0x04,0xe9,0x80,0x09,0x98,0xec,0xf8,0x42,0x7e};
-       BYTE hash2[MD5_BLOCK_SIZE] = {0x90,0x01,0x50,0x98,0x3c,0xd2,0x4f,0xb0,0xd6,0x96,0x3f,0x7d,0x28,0xe1,0x7f,0x72};
-       BYTE hash3[MD5_BLOCK_SIZE] = {0xd1,0x74,0xab,0x98,0xd2,0x77,0xd9,0xf5,0xa5,0x61,0x1c,0x2c,0x9f,0x41,0x9d,0x9f};
-       BYTE buf[16];
-       MD5_CTX ctx;
-       int pass = 1;
-
-       md5_init(&ctx);
-       md5_update(&ctx, text1, strlen(text1));
-       md5_final(&ctx, buf);
-       pass = pass && !memcmp(hash1, buf, MD5_BLOCK_SIZE);
-
-       // Note the MD5 object can be reused.
-       md5_init(&ctx);
-       md5_update(&ctx, text2, strlen(text2));
-       md5_final(&ctx, buf);
-       pass = pass && !memcmp(hash2, buf, MD5_BLOCK_SIZE);
-
-       // Note the data is being added in two chunks.
-       md5_init(&ctx);
-       md5_update(&ctx, text3_1, strlen(text3_1));
-       md5_update(&ctx, text3_2, strlen(text3_2));
-       md5_final(&ctx, buf);
-       pass = pass && !memcmp(hash3, buf, MD5_BLOCK_SIZE);
-
-       return(pass);
-}
-
-int main()
-{
-       printf("MD5 tests: %s\n", md5_test() ? "SUCCEEDED" : "FAILED");
-
-       return(0);
-}
diff --git a/deps/crypto/rot-13.c b/deps/crypto/rot-13.c
deleted file mode 100644 (file)
index 0ab8497..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*********************************************************************
-* Filename:   rot-13.c
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Implementation of the ROT-13 encryption algorithm.
-                                 Algorithm specification can be found here:
-                                  *
-                                 This implementation uses little endian byte order.
-*********************************************************************/
-
-/*************************** HEADER FILES ***************************/
-#include <string.h>
-#include "rot-13.h"
-
-/*********************** FUNCTION DEFINITIONS ***********************/
-void rot13(char str[])
-{
-   int case_type, idx, len;
-
-   for (idx = 0, len = strlen(str); idx < len; idx++) {
-      // Only process alphabetic characters.
-      if (str[idx] < 'A' || (str[idx] > 'Z' && str[idx] < 'a') || str[idx] > 'z')
-         continue;
-      // Determine if the char is upper or lower case.
-      if (str[idx] >= 'a')
-         case_type = 'a';
-      else
-         case_type = 'A';
-      // Rotate the char's value, ensuring it doesn't accidentally "fall off" the end.
-      str[idx] = (str[idx] + 13) % (case_type + 26);
-      if (str[idx] < 26)
-         str[idx] += case_type;
-   }
-}
diff --git a/deps/crypto/rot-13.h b/deps/crypto/rot-13.h
deleted file mode 100644 (file)
index 4c581c3..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*********************************************************************
-* Filename:   rot-13.h
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Defines the API for the corresponding ROT-13 implementation.
-*********************************************************************/
-
-#ifndef ROT13_H
-#define ROT13_H
-
-/*************************** HEADER FILES ***************************/
-#include <stddef.h>
-
-/*********************** FUNCTION DECLARATIONS **********************/
-// Performs IN PLACE rotation of the input. Assumes input is NULL terminated.
-// Preserves each charcter's case. Ignores non alphabetic characters.
-void rot13(char str[]);
-
-#endif   // ROT13_H
diff --git a/deps/crypto/rot-13_test.c b/deps/crypto/rot-13_test.c
deleted file mode 100644 (file)
index a6fd01d..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*********************************************************************
-* Filename:   rot-13_test.c
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Performs known-answer tests on the corresponding ROT-13
-                 implementation. These tests do not encompass the full
-                 range of available test vectors, however, if the tests
-                 pass it is very, very likely that the code is correct
-                 and was compiled properly. This code also serves as
-                 example usage of the functions.
-*********************************************************************/
-
-/*************************** HEADER FILES ***************************/
-#include <stdio.h>
-#include <string.h>
-#include "rot-13.h"
-
-/*********************** FUNCTION DEFINITIONS ***********************/
-int rot13_test()
-{
-       char text[] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"};
-       char code[] = {"NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm"};
-       char buf[1024];
-       int pass = 1;
-
-       // To encode, just apply ROT-13.
-       strcpy(buf, text);
-       rot13(buf);
-       pass = pass && !strcmp(code, buf);
-
-       // To decode, just re-apply ROT-13.
-       rot13(buf);
-       pass = pass && !strcmp(text, buf);
-
-       return(pass);
-}
-
-int main()
-{
-       printf("ROT-13 tests: %s\n", rot13_test() ? "SUCCEEDED" : "FAILED");
-
-       return(0);
-}
diff --git a/deps/crypto/sha1.c b/deps/crypto/sha1.c
deleted file mode 100644 (file)
index eb0bda0..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-/*********************************************************************
-* Filename:   sha1.c
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Implementation of the SHA1 hashing algorithm.
-              Algorithm specification can be found here:
-               * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf
-              This implementation uses little endian byte order.
-*********************************************************************/
-
-/*************************** HEADER FILES ***************************/
-#include <stdlib.h>
-#include <string.h>
-#include "sha1.h"
-
-/****************************** MACROS ******************************/
-#define ROTLEFT(a, b) ((a << b) | (a >> (32 - b)))
-
-/*********************** FUNCTION DEFINITIONS ***********************/
-void sha1_transform(SHA1_CTX *ctx, const BYTE data[])
-{
-       WORD a, b, c, d, e, i, j, t, m[80];
-
-       for (i = 0, j = 0; i < 16; ++i, j += 4)
-               m[i] = (data[j] << 24) + (data[j + 1] << 16) + (data[j + 2] << 8) + (data[j + 3]);
-       for ( ; i < 80; ++i) {
-               m[i] = (m[i - 3] ^ m[i - 8] ^ m[i - 14] ^ m[i - 16]);
-               m[i] = (m[i] << 1) | (m[i] >> 31);
-       }
-
-       a = ctx->state[0];
-       b = ctx->state[1];
-       c = ctx->state[2];
-       d = ctx->state[3];
-       e = ctx->state[4];
-
-       for (i = 0; i < 20; ++i) {
-               t = ROTLEFT(a, 5) + ((b & c) ^ (~b & d)) + e + ctx->k[0] + m[i];
-               e = d;
-               d = c;
-               c = ROTLEFT(b, 30);
-               b = a;
-               a = t;
-       }
-       for ( ; i < 40; ++i) {
-               t = ROTLEFT(a, 5) + (b ^ c ^ d) + e + ctx->k[1] + m[i];
-               e = d;
-               d = c;
-               c = ROTLEFT(b, 30);
-               b = a;
-               a = t;
-       }
-       for ( ; i < 60; ++i) {
-               t = ROTLEFT(a, 5) + ((b & c) ^ (b & d) ^ (c & d))  + e + ctx->k[2] + m[i];
-               e = d;
-               d = c;
-               c = ROTLEFT(b, 30);
-               b = a;
-               a = t;
-       }
-       for ( ; i < 80; ++i) {
-               t = ROTLEFT(a, 5) + (b ^ c ^ d) + e + ctx->k[3] + m[i];
-               e = d;
-               d = c;
-               c = ROTLEFT(b, 30);
-               b = a;
-               a = t;
-       }
-
-       ctx->state[0] += a;
-       ctx->state[1] += b;
-       ctx->state[2] += c;
-       ctx->state[3] += d;
-       ctx->state[4] += e;
-}
-
-void sha1_init(SHA1_CTX *ctx)
-{
-       ctx->datalen = 0;
-       ctx->bitlen = 0;
-       ctx->state[0] = 0x67452301;
-       ctx->state[1] = 0xEFCDAB89;
-       ctx->state[2] = 0x98BADCFE;
-       ctx->state[3] = 0x10325476;
-       ctx->state[4] = 0xc3d2e1f0;
-       ctx->k[0] = 0x5a827999;
-       ctx->k[1] = 0x6ed9eba1;
-       ctx->k[2] = 0x8f1bbcdc;
-       ctx->k[3] = 0xca62c1d6;
-}
-
-void sha1_update(SHA1_CTX *ctx, const BYTE data[], size_t len)
-{
-       size_t i;
-
-       for (i = 0; i < len; ++i) {
-               ctx->data[ctx->datalen] = data[i];
-               ctx->datalen++;
-               if (ctx->datalen == 64) {
-                       sha1_transform(ctx, ctx->data);
-                       ctx->bitlen += 512;
-                       ctx->datalen = 0;
-               }
-       }
-}
-
-void sha1_final(SHA1_CTX *ctx, BYTE hash[])
-{
-       WORD i;
-
-       i = ctx->datalen;
-
-       // Pad whatever data is left in the buffer.
-       if (ctx->datalen < 56) {
-               ctx->data[i++] = 0x80;
-               while (i < 56)
-                       ctx->data[i++] = 0x00;
-       }
-       else {
-               ctx->data[i++] = 0x80;
-               while (i < 64)
-                       ctx->data[i++] = 0x00;
-               sha1_transform(ctx, ctx->data);
-               memset(ctx->data, 0, 56);
-       }
-
-       // Append to the padding the total message's length in bits and transform.
-       ctx->bitlen += ctx->datalen * 8;
-       ctx->data[63] = ctx->bitlen;
-       ctx->data[62] = ctx->bitlen >> 8;
-       ctx->data[61] = ctx->bitlen >> 16;
-       ctx->data[60] = ctx->bitlen >> 24;
-       ctx->data[59] = ctx->bitlen >> 32;
-       ctx->data[58] = ctx->bitlen >> 40;
-       ctx->data[57] = ctx->bitlen >> 48;
-       ctx->data[56] = ctx->bitlen >> 56;
-       sha1_transform(ctx, ctx->data);
-
-       // Since this implementation uses little endian byte ordering and MD uses big endian,
-       // reverse all the bytes when copying the final state to the output hash.
-       for (i = 0; i < 4; ++i) {
-               hash[i]      = (ctx->state[0] >> (24 - i * 8)) & 0x000000ff;
-               hash[i + 4]  = (ctx->state[1] >> (24 - i * 8)) & 0x000000ff;
-               hash[i + 8]  = (ctx->state[2] >> (24 - i * 8)) & 0x000000ff;
-               hash[i + 12] = (ctx->state[3] >> (24 - i * 8)) & 0x000000ff;
-               hash[i + 16] = (ctx->state[4] >> (24 - i * 8)) & 0x000000ff;
-       }
-}
diff --git a/deps/crypto/sha1.h b/deps/crypto/sha1.h
deleted file mode 100644 (file)
index e4c7869..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*********************************************************************
-* Filename:   sha1.h
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Defines the API for the corresponding SHA1 implementation.
-*********************************************************************/
-
-#ifndef SHA1_H
-#define SHA1_H
-
-/*************************** HEADER FILES ***************************/
-#include <stddef.h>
-
-#include "crypto_types.h"
-
-/****************************** MACROS ******************************/
-#define SHA1_BLOCK_SIZE 20              // SHA1 outputs a 20 byte digest
-
-/**************************** DATA TYPES ****************************/
-typedef struct {
-       BYTE data[64];
-       WORD datalen;
-       unsigned long long bitlen;
-       WORD state[5];
-       WORD k[4];
-} SHA1_CTX;
-
-/*********************** FUNCTION DECLARATIONS **********************/
-void sha1_init(SHA1_CTX *ctx);
-void sha1_update(SHA1_CTX *ctx, const BYTE data[], size_t len);
-void sha1_final(SHA1_CTX *ctx, BYTE hash[]);
-
-#endif   // SHA1_H
diff --git a/deps/crypto/sha1_test.c b/deps/crypto/sha1_test.c
deleted file mode 100644 (file)
index 6c78f7d..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*********************************************************************
-* Filename:   sha1_test.c
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Performs known-answer tests on the corresponding SHA1
-                 implementation. These tests do not encompass the full
-                 range of available test vectors, however, if the tests
-                 pass it is very, very likely that the code is correct
-                 and was compiled properly. This code also serves as
-                 example usage of the functions.
-*********************************************************************/
-
-/*************************** HEADER FILES ***************************/
-#include <stdio.h>
-#include <memory.h>
-#include <string.h>
-#include "sha1.h"
-
-/*********************** FUNCTION DEFINITIONS ***********************/
-int sha1_test()
-{
-       BYTE text1[] = {"abc"};
-       BYTE text2[] = {"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"};
-       BYTE text3[] = {"aaaaaaaaaa"};
-       BYTE hash1[SHA1_BLOCK_SIZE] = {0xa9,0x99,0x3e,0x36,0x47,0x06,0x81,0x6a,0xba,0x3e,0x25,0x71,0x78,0x50,0xc2,0x6c,0x9c,0xd0,0xd8,0x9d};
-       BYTE hash2[SHA1_BLOCK_SIZE] = {0x84,0x98,0x3e,0x44,0x1c,0x3b,0xd2,0x6e,0xba,0xae,0x4a,0xa1,0xf9,0x51,0x29,0xe5,0xe5,0x46,0x70,0xf1};
-       BYTE hash3[SHA1_BLOCK_SIZE] = {0x34,0xaa,0x97,0x3c,0xd4,0xc4,0xda,0xa4,0xf6,0x1e,0xeb,0x2b,0xdb,0xad,0x27,0x31,0x65,0x34,0x01,0x6f};
-       BYTE buf[SHA1_BLOCK_SIZE];
-       int idx;
-       SHA1_CTX ctx;
-       int pass = 1;
-
-       sha1_init(&ctx);
-       sha1_update(&ctx, text1, strlen(text1));
-       sha1_final(&ctx, buf);
-       pass = pass && !memcmp(hash1, buf, SHA1_BLOCK_SIZE);
-
-       sha1_init(&ctx);
-       sha1_update(&ctx, text2, strlen(text2));
-       sha1_final(&ctx, buf);
-       pass = pass && !memcmp(hash2, buf, SHA1_BLOCK_SIZE);
-
-       sha1_init(&ctx);
-       for (idx = 0; idx < 100000; ++idx)
-          sha1_update(&ctx, text3, strlen(text3));
-       sha1_final(&ctx, buf);
-       pass = pass && !memcmp(hash3, buf, SHA1_BLOCK_SIZE);
-
-       return(pass);
-}
-
-int main()
-{
-       printf("SHA1 tests: %s\n", sha1_test() ? "SUCCEEDED" : "FAILED");
-
-       return(0);
-}
diff --git a/deps/crypto/sha256.c b/deps/crypto/sha256.c
deleted file mode 100644 (file)
index d644d2d..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-/*********************************************************************
-* Filename:   sha256.c
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Implementation of the SHA-256 hashing algorithm.
-              SHA-256 is one of the three algorithms in the SHA2
-              specification. The others, SHA-384 and SHA-512, are not
-              offered in this implementation.
-              Algorithm specification can be found here:
-               * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf
-              This implementation uses little endian byte order.
-*********************************************************************/
-
-/*************************** HEADER FILES ***************************/
-#include <stdlib.h>
-#include <string.h>
-#include "sha256.h"
-
-/****************************** MACROS ******************************/
-#define ROTLEFT(a,b) (((a) << (b)) | ((a) >> (32-(b))))
-#define ROTRIGHT(a,b) (((a) >> (b)) | ((a) << (32-(b))))
-
-#define CH(x,y,z) (((x) & (y)) ^ (~(x) & (z)))
-#define MAJ(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
-#define EP0(x) (ROTRIGHT(x,2) ^ ROTRIGHT(x,13) ^ ROTRIGHT(x,22))
-#define EP1(x) (ROTRIGHT(x,6) ^ ROTRIGHT(x,11) ^ ROTRIGHT(x,25))
-#define SIG0(x) (ROTRIGHT(x,7) ^ ROTRIGHT(x,18) ^ ((x) >> 3))
-#define SIG1(x) (ROTRIGHT(x,17) ^ ROTRIGHT(x,19) ^ ((x) >> 10))
-
-/**************************** VARIABLES *****************************/
-static const WORD k[64] = {
-       0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,
-       0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,
-       0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,
-       0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967,
-       0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,
-       0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,
-       0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,
-       0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2
-};
-
-/*********************** FUNCTION DEFINITIONS ***********************/
-void sha256_transform(SHA256_CTX *ctx, const BYTE data[])
-{
-       WORD a, b, c, d, e, f, g, h, i, j, t1, t2, m[64];
-
-       for (i = 0, j = 0; i < 16; ++i, j += 4)
-               m[i] = (data[j] << 24) | (data[j + 1] << 16) | (data[j + 2] << 8) | (data[j + 3]);
-       for ( ; i < 64; ++i)
-               m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
-
-       a = ctx->state[0];
-       b = ctx->state[1];
-       c = ctx->state[2];
-       d = ctx->state[3];
-       e = ctx->state[4];
-       f = ctx->state[5];
-       g = ctx->state[6];
-       h = ctx->state[7];
-
-       for (i = 0; i < 64; ++i) {
-               t1 = h + EP1(e) + CH(e,f,g) + k[i] + m[i];
-               t2 = EP0(a) + MAJ(a,b,c);
-               h = g;
-               g = f;
-               f = e;
-               e = d + t1;
-               d = c;
-               c = b;
-               b = a;
-               a = t1 + t2;
-       }
-
-       ctx->state[0] += a;
-       ctx->state[1] += b;
-       ctx->state[2] += c;
-       ctx->state[3] += d;
-       ctx->state[4] += e;
-       ctx->state[5] += f;
-       ctx->state[6] += g;
-       ctx->state[7] += h;
-}
-
-void sha256_init(SHA256_CTX *ctx)
-{
-       ctx->datalen = 0;
-       ctx->bitlen = 0;
-       ctx->state[0] = 0x6a09e667;
-       ctx->state[1] = 0xbb67ae85;
-       ctx->state[2] = 0x3c6ef372;
-       ctx->state[3] = 0xa54ff53a;
-       ctx->state[4] = 0x510e527f;
-       ctx->state[5] = 0x9b05688c;
-       ctx->state[6] = 0x1f83d9ab;
-       ctx->state[7] = 0x5be0cd19;
-}
-
-void sha256_update(SHA256_CTX *ctx, const BYTE data[], size_t len)
-{
-       WORD i;
-
-       for (i = 0; i < len; ++i) {
-               ctx->data[ctx->datalen] = data[i];
-               ctx->datalen++;
-               if (ctx->datalen == 64) {
-                       sha256_transform(ctx, ctx->data);
-                       ctx->bitlen += 512;
-                       ctx->datalen = 0;
-               }
-       }
-}
-
-void sha256_final(SHA256_CTX *ctx, BYTE hash[])
-{
-       WORD i;
-
-       i = ctx->datalen;
-
-       // Pad whatever data is left in the buffer.
-       if (ctx->datalen < 56) {
-               ctx->data[i++] = 0x80;
-               while (i < 56)
-                       ctx->data[i++] = 0x00;
-       }
-       else {
-               ctx->data[i++] = 0x80;
-               while (i < 64)
-                       ctx->data[i++] = 0x00;
-               sha256_transform(ctx, ctx->data);
-               memset(ctx->data, 0, 56);
-       }
-
-       // Append to the padding the total message's length in bits and transform.
-       ctx->bitlen += ctx->datalen * 8;
-       ctx->data[63] = ctx->bitlen;
-       ctx->data[62] = ctx->bitlen >> 8;
-       ctx->data[61] = ctx->bitlen >> 16;
-       ctx->data[60] = ctx->bitlen >> 24;
-       ctx->data[59] = ctx->bitlen >> 32;
-       ctx->data[58] = ctx->bitlen >> 40;
-       ctx->data[57] = ctx->bitlen >> 48;
-       ctx->data[56] = ctx->bitlen >> 56;
-       sha256_transform(ctx, ctx->data);
-
-       // Since this implementation uses little endian byte ordering and SHA uses big endian,
-       // reverse all the bytes when copying the final state to the output hash.
-       for (i = 0; i < 4; ++i) {
-               hash[i]      = (ctx->state[0] >> (24 - i * 8)) & 0x000000ff;
-               hash[i + 4]  = (ctx->state[1] >> (24 - i * 8)) & 0x000000ff;
-               hash[i + 8]  = (ctx->state[2] >> (24 - i * 8)) & 0x000000ff;
-               hash[i + 12] = (ctx->state[3] >> (24 - i * 8)) & 0x000000ff;
-               hash[i + 16] = (ctx->state[4] >> (24 - i * 8)) & 0x000000ff;
-               hash[i + 20] = (ctx->state[5] >> (24 - i * 8)) & 0x000000ff;
-               hash[i + 24] = (ctx->state[6] >> (24 - i * 8)) & 0x000000ff;
-               hash[i + 28] = (ctx->state[7] >> (24 - i * 8)) & 0x000000ff;
-       }
-}
diff --git a/deps/crypto/sha256.h b/deps/crypto/sha256.h
deleted file mode 100644 (file)
index 7123a30..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*********************************************************************
-* Filename:   sha256.h
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Defines the API for the corresponding SHA1 implementation.
-*********************************************************************/
-
-#ifndef SHA256_H
-#define SHA256_H
-
-/*************************** HEADER FILES ***************************/
-#include <stddef.h>
-
-/****************************** MACROS ******************************/
-#define SHA256_BLOCK_SIZE 32            // SHA256 outputs a 32 byte digest
-
-/**************************** DATA TYPES ****************************/
-typedef unsigned char BYTE;             // 8-bit byte
-typedef unsigned int  WORD;             // 32-bit word, change to "long" for 16-bit machines
-
-typedef struct {
-       BYTE data[64];
-       WORD datalen;
-       unsigned long long bitlen;
-       WORD state[8];
-} SHA256_CTX;
-
-/*********************** FUNCTION DECLARATIONS **********************/
-void sha256_init(SHA256_CTX *ctx);
-void sha256_update(SHA256_CTX *ctx, const BYTE data[], size_t len);
-void sha256_final(SHA256_CTX *ctx, BYTE hash[]);
-
-#endif   // SHA256_H
diff --git a/deps/crypto/sha256_test.c b/deps/crypto/sha256_test.c
deleted file mode 100644 (file)
index 726a668..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*********************************************************************
-* Filename:   sha256.c
-* Author:     Brad Conte (brad AT bradconte.com)
-* Copyright:
-* Disclaimer: This code is presented "as is" without any guarantees.
-* Details:    Performs known-answer tests on the corresponding SHA1
-                 implementation. These tests do not encompass the full
-                 range of available test vectors, however, if the tests
-                 pass it is very, very likely that the code is correct
-                 and was compiled properly. This code also serves as
-                 example usage of the functions.
-*********************************************************************/
-
-/*************************** HEADER FILES ***************************/
-#include <stdio.h>
-#include <memory.h>
-#include <string.h>
-#include "sha256.h"
-
-/*********************** FUNCTION DEFINITIONS ***********************/
-int sha256_test()
-{
-       BYTE text1[] = {"abc"};
-       BYTE text2[] = {"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"};
-       BYTE text3[] = {"aaaaaaaaaa"};
-       BYTE hash1[SHA256_BLOCK_SIZE] = {0xba,0x78,0x16,0xbf,0x8f,0x01,0xcf,0xea,0x41,0x41,0x40,0xde,0x5d,0xae,0x22,0x23,
-                                        0xb0,0x03,0x61,0xa3,0x96,0x17,0x7a,0x9c,0xb4,0x10,0xff,0x61,0xf2,0x00,0x15,0xad};
-       BYTE hash2[SHA256_BLOCK_SIZE] = {0x24,0x8d,0x6a,0x61,0xd2,0x06,0x38,0xb8,0xe5,0xc0,0x26,0x93,0x0c,0x3e,0x60,0x39,
-                                        0xa3,0x3c,0xe4,0x59,0x64,0xff,0x21,0x67,0xf6,0xec,0xed,0xd4,0x19,0xdb,0x06,0xc1};
-       BYTE hash3[SHA256_BLOCK_SIZE] = {0xcd,0xc7,0x6e,0x5c,0x99,0x14,0xfb,0x92,0x81,0xa1,0xc7,0xe2,0x84,0xd7,0x3e,0x67,
-                                        0xf1,0x80,0x9a,0x48,0xa4,0x97,0x20,0x0e,0x04,0x6d,0x39,0xcc,0xc7,0x11,0x2c,0xd0};
-       BYTE buf[SHA256_BLOCK_SIZE];
-       SHA256_CTX ctx;
-       int idx;
-       int pass = 1;
-
-       sha256_init(&ctx);
-       sha256_update(&ctx, text1, strlen(text1));
-       sha256_final(&ctx, buf);
-       pass = pass && !memcmp(hash1, buf, SHA256_BLOCK_SIZE);
-
-       sha256_init(&ctx);
-       sha256_update(&ctx, text2, strlen(text2));
-       sha256_final(&ctx, buf);
-       pass = pass && !memcmp(hash2, buf, SHA256_BLOCK_SIZE);
-
-       sha256_init(&ctx);
-       for (idx = 0; idx < 100000; ++idx)
-          sha256_update(&ctx, text3, strlen(text3));
-       sha256_final(&ctx, buf);
-       pass = pass && !memcmp(hash3, buf, SHA256_BLOCK_SIZE);
-
-       return(pass);
-}
-
-int main()
-{
-       printf("SHA-256 tests: %s\n", sha256_test() ? "SUCCEEDED" : "FAILED");
-
-       return(0);
-}
diff --git a/deps/libchdr/LICENSE.txt b/deps/libchdr/LICENSE.txt
deleted file mode 100644 (file)
index 1c36e5b..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-Copyright Romain Tisserand
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-    * Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-    * Redistributions in binary form must reproduce the above copyright
-      notice, this list of conditions and the following disclaimer in the
-      documentation and/or other materials provided with the distribution.
-    * Neither the name of the <organization> nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/deps/libchdr/README.md b/deps/libchdr/README.md
deleted file mode 100644 (file)
index 940920a..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# libchdr
-
-libchdr is a standalone library for reading MAME's CHDv1-v5 formats.
-
-The code is based off of MAME's old C codebase which read up to CHDv4 with OS-dependent features removed, and CHDv5 support backported from MAME's current C++ codebase.
-
-libchdr is licensed under the BSD 3-Clause (see [LICENSE.txt](LICENSE.txt)) and uses third party libraries that are each distributed under their own terms (see each library's license in [deps/](deps/)).
diff --git a/deps/libchdr/include/dr_libs/dr_flac.h b/deps/libchdr/include/dr_libs/dr_flac.h
deleted file mode 100644 (file)
index 2dcddb5..0000000
+++ /dev/null
@@ -1,12214 +0,0 @@
-/*
-FLAC audio decoder. Choice of public domain or MIT-0. See license statements at the end of this file.
-dr_flac - v0.12.28 - 2021-02-21
-
-David Reid - mackron@gmail.com
-
-GitHub: https://github.com/mackron/dr_libs
-*/
-
-/*
-RELEASE NOTES - v0.12.0
-=======================
-Version 0.12.0 has breaking API changes including changes to the existing API and the removal of deprecated APIs.
-
-
-Improved Client-Defined Memory Allocation
------------------------------------------
-The main change with this release is the addition of a more flexible way of implementing custom memory allocation routines. The
-existing system of DRFLAC_MALLOC, DRFLAC_REALLOC and DRFLAC_FREE are still in place and will be used by default when no custom
-allocation callbacks are specified.
-
-To use the new system, you pass in a pointer to a drflac_allocation_callbacks object to drflac_open() and family, like this:
-
-    void* my_malloc(size_t sz, void* pUserData)
-    {
-        return malloc(sz);
-    }
-    void* my_realloc(void* p, size_t sz, void* pUserData)
-    {
-        return realloc(p, sz);
-    }
-    void my_free(void* p, void* pUserData)
-    {
-        free(p);
-    }
-
-    ...
-
-    drflac_allocation_callbacks allocationCallbacks;
-    allocationCallbacks.pUserData = &myData;
-    allocationCallbacks.onMalloc  = my_malloc;
-    allocationCallbacks.onRealloc = my_realloc;
-    allocationCallbacks.onFree    = my_free;
-    drflac* pFlac = drflac_open_file("my_file.flac", &allocationCallbacks);
-
-The advantage of this new system is that it allows you to specify user data which will be passed in to the allocation routines.
-
-Passing in null for the allocation callbacks object will cause dr_flac to use defaults which is the same as DRFLAC_MALLOC,
-DRFLAC_REALLOC and DRFLAC_FREE and the equivalent of how it worked in previous versions.
-
-Every API that opens a drflac object now takes this extra parameter. These include the following:
-
-    drflac_open()
-    drflac_open_relaxed()
-    drflac_open_with_metadata()
-    drflac_open_with_metadata_relaxed()
-    drflac_open_file()
-    drflac_open_file_with_metadata()
-    drflac_open_memory()
-    drflac_open_memory_with_metadata()
-    drflac_open_and_read_pcm_frames_s32()
-    drflac_open_and_read_pcm_frames_s16()
-    drflac_open_and_read_pcm_frames_f32()
-    drflac_open_file_and_read_pcm_frames_s32()
-    drflac_open_file_and_read_pcm_frames_s16()
-    drflac_open_file_and_read_pcm_frames_f32()
-    drflac_open_memory_and_read_pcm_frames_s32()
-    drflac_open_memory_and_read_pcm_frames_s16()
-    drflac_open_memory_and_read_pcm_frames_f32()
-
-
-
-Optimizations
--------------
-Seeking performance has been greatly improved. A new binary search based seeking algorithm has been introduced which significantly
-improves performance over the brute force method which was used when no seek table was present. Seek table based seeking also takes
-advantage of the new binary search seeking system to further improve performance there as well. Note that this depends on CRC which
-means it will be disabled when DR_FLAC_NO_CRC is used.
-
-The SSE4.1 pipeline has been cleaned up and optimized. You should see some improvements with decoding speed of 24-bit files in
-particular. 16-bit streams should also see some improvement.
-
-drflac_read_pcm_frames_s16() has been optimized. Previously this sat on top of drflac_read_pcm_frames_s32() and performed it's s32
-to s16 conversion in a second pass. This is now all done in a single pass. This includes SSE2 and ARM NEON optimized paths.
-
-A minor optimization has been implemented for drflac_read_pcm_frames_s32(). This will now use an SSE2 optimized pipeline for stereo
-channel reconstruction which is the last part of the decoding process.
-
-The ARM build has seen a few improvements. The CLZ (count leading zeroes) and REV (byte swap) instructions are now used when
-compiling with GCC and Clang which is achieved using inline assembly. The CLZ instruction requires ARM architecture version 5 at
-compile time and the REV instruction requires ARM architecture version 6.
-
-An ARM NEON optimized pipeline has been implemented. To enable this you'll need to add -mfpu=neon to the command line when compiling.
-
-
-Removed APIs
-------------
-The following APIs were deprecated in version 0.11.0 and have been completely removed in version 0.12.0:
-
-    drflac_read_s32()                   -> drflac_read_pcm_frames_s32()
-    drflac_read_s16()                   -> drflac_read_pcm_frames_s16()
-    drflac_read_f32()                   -> drflac_read_pcm_frames_f32()
-    drflac_seek_to_sample()             -> drflac_seek_to_pcm_frame()
-    drflac_open_and_decode_s32()        -> drflac_open_and_read_pcm_frames_s32()
-    drflac_open_and_decode_s16()        -> drflac_open_and_read_pcm_frames_s16()
-    drflac_open_and_decode_f32()        -> drflac_open_and_read_pcm_frames_f32()
-    drflac_open_and_decode_file_s32()   -> drflac_open_file_and_read_pcm_frames_s32()
-    drflac_open_and_decode_file_s16()   -> drflac_open_file_and_read_pcm_frames_s16()
-    drflac_open_and_decode_file_f32()   -> drflac_open_file_and_read_pcm_frames_f32()
-    drflac_open_and_decode_memory_s32() -> drflac_open_memory_and_read_pcm_frames_s32()
-    drflac_open_and_decode_memory_s16() -> drflac_open_memory_and_read_pcm_frames_s16()
-    drflac_open_and_decode_memory_f32() -> drflac_open_memroy_and_read_pcm_frames_f32()
-
-Prior versions of dr_flac operated on a per-sample basis whereas now it operates on PCM frames. The removed APIs all relate
-to the old per-sample APIs. You now need to use the "pcm_frame" versions.
-*/
-
-
-/*
-Introduction
-============
-dr_flac is a single file library. To use it, do something like the following in one .c file.
-
-    ```c
-    #define DR_FLAC_IMPLEMENTATION
-    #include "dr_flac.h"
-    ```
-
-You can then #include this file in other parts of the program as you would with any other header file. To decode audio data, do something like the following:
-
-    ```c
-    drflac* pFlac = drflac_open_file("MySong.flac", NULL);
-    if (pFlac == NULL) {
-        // Failed to open FLAC file
-    }
-
-    drflac_int32* pSamples = malloc(pFlac->totalPCMFrameCount * pFlac->channels * sizeof(drflac_int32));
-    drflac_uint64 numberOfInterleavedSamplesActuallyRead = drflac_read_pcm_frames_s32(pFlac, pFlac->totalPCMFrameCount, pSamples);
-    ```
-
-The drflac object represents the decoder. It is a transparent type so all the information you need, such as the number of channels and the bits per sample,
-should be directly accessible - just make sure you don't change their values. Samples are always output as interleaved signed 32-bit PCM. In the example above
-a native FLAC stream was opened, however dr_flac has seamless support for Ogg encapsulated FLAC streams as well.
-
-You do not need to decode the entire stream in one go - you just specify how many samples you'd like at any given time and the decoder will give you as many
-samples as it can, up to the amount requested. Later on when you need the next batch of samples, just call it again. Example:
-
-    ```c
-    while (drflac_read_pcm_frames_s32(pFlac, chunkSizeInPCMFrames, pChunkSamples) > 0) {
-        do_something();
-    }
-    ```
-
-You can seek to a specific PCM frame with `drflac_seek_to_pcm_frame()`.
-
-If you just want to quickly decode an entire FLAC file in one go you can do something like this:
-
-    ```c
-    unsigned int channels;
-    unsigned int sampleRate;
-    drflac_uint64 totalPCMFrameCount;
-    drflac_int32* pSampleData = drflac_open_file_and_read_pcm_frames_s32("MySong.flac", &channels, &sampleRate, &totalPCMFrameCount, NULL);
-    if (pSampleData == NULL) {
-        // Failed to open and decode FLAC file.
-    }
-
-    ...
-
-    drflac_free(pSampleData, NULL);
-    ```
-
-You can read samples as signed 16-bit integer and 32-bit floating-point PCM with the *_s16() and *_f32() family of APIs respectively, but note that these
-should be considered lossy.
-
-
-If you need access to metadata (album art, etc.), use `drflac_open_with_metadata()`, `drflac_open_file_with_metdata()` or `drflac_open_memory_with_metadata()`.
-The rationale for keeping these APIs separate is that they're slightly slower than the normal versions and also just a little bit harder to use. dr_flac
-reports metadata to the application through the use of a callback, and every metadata block is reported before `drflac_open_with_metdata()` returns.
-
-The main opening APIs (`drflac_open()`, etc.) will fail if the header is not present. The presents a problem in certain scenarios such as broadcast style
-streams or internet radio where the header may not be present because the user has started playback mid-stream. To handle this, use the relaxed APIs:
-    
-    `drflac_open_relaxed()`
-    `drflac_open_with_metadata_relaxed()`
-
-It is not recommended to use these APIs for file based streams because a missing header would usually indicate a corrupt or perverse file. In addition, these
-APIs can take a long time to initialize because they may need to spend a lot of time finding the first frame.
-
-
-
-Build Options
-=============
-#define these options before including this file.
-
-#define DR_FLAC_NO_STDIO
-  Disable `drflac_open_file()` and family.
-
-#define DR_FLAC_NO_OGG
-  Disables support for Ogg/FLAC streams.
-
-#define DR_FLAC_BUFFER_SIZE <number>
-  Defines the size of the internal buffer to store data from onRead(). This buffer is used to reduce the number of calls back to the client for more data.
-  Larger values means more memory, but better performance. My tests show diminishing returns after about 4KB (which is the default). Consider reducing this if
-  you have a very efficient implementation of onRead(), or increase it if it's very inefficient. Must be a multiple of 8.
-
-#define DR_FLAC_NO_CRC
-  Disables CRC checks. This will offer a performance boost when CRC is unnecessary. This will disable binary search seeking. When seeking, the seek table will
-  be used if available. Otherwise the seek will be performed using brute force.
-
-#define DR_FLAC_NO_SIMD
-  Disables SIMD optimizations (SSE on x86/x64 architectures, NEON on ARM architectures). Use this if you are having compatibility issues with your compiler.
-
-
-
-Notes
-=====
-- dr_flac does not support changing the sample rate nor channel count mid stream.
-- dr_flac is not thread-safe, but its APIs can be called from any thread so long as you do your own synchronization.
-- When using Ogg encapsulation, a corrupted metadata block will result in `drflac_open_with_metadata()` and `drflac_open()` returning inconsistent samples due
-  to differences in corrupted stream recorvery logic between the two APIs.
-*/
-
-#ifndef dr_flac_h
-#define dr_flac_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define DRFLAC_STRINGIFY(x)      #x
-#define DRFLAC_XSTRINGIFY(x)     DRFLAC_STRINGIFY(x)
-
-#define DRFLAC_VERSION_MAJOR     0
-#define DRFLAC_VERSION_MINOR     12
-#define DRFLAC_VERSION_REVISION  28
-#define DRFLAC_VERSION_STRING    DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MAJOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MINOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_REVISION)
-
-#include <stddef.h> /* For size_t. */
-
-/* Sized types. */
-typedef   signed char           drflac_int8;
-typedef unsigned char           drflac_uint8;
-typedef   signed short          drflac_int16;
-typedef unsigned short          drflac_uint16;
-typedef   signed int            drflac_int32;
-typedef unsigned int            drflac_uint32;
-#if defined(_MSC_VER)
-    typedef   signed __int64    drflac_int64;
-    typedef unsigned __int64    drflac_uint64;
-#else
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic push
-        #pragma GCC diagnostic ignored "-Wlong-long"
-        #if defined(__clang__)
-            #pragma GCC diagnostic ignored "-Wc++11-long-long"
-        #endif
-    #endif
-    typedef   signed long long  drflac_int64;
-    typedef unsigned long long  drflac_uint64;
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic pop
-    #endif
-#endif
-#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
-    typedef drflac_uint64       drflac_uintptr;
-#else
-    typedef drflac_uint32       drflac_uintptr;
-#endif
-typedef drflac_uint8            drflac_bool8;
-typedef drflac_uint32           drflac_bool32;
-#define DRFLAC_TRUE             1
-#define DRFLAC_FALSE            0
-
-#if !defined(DRFLAC_API)
-    #if defined(DRFLAC_DLL)
-        #if defined(_WIN32)
-            #define DRFLAC_DLL_IMPORT  __declspec(dllimport)
-            #define DRFLAC_DLL_EXPORT  __declspec(dllexport)
-            #define DRFLAC_DLL_PRIVATE static
-        #else
-            #if defined(__GNUC__) && __GNUC__ >= 4
-                #define DRFLAC_DLL_IMPORT  __attribute__((visibility("default")))
-                #define DRFLAC_DLL_EXPORT  __attribute__((visibility("default")))
-                #define DRFLAC_DLL_PRIVATE __attribute__((visibility("hidden")))
-            #else
-                #define DRFLAC_DLL_IMPORT
-                #define DRFLAC_DLL_EXPORT
-                #define DRFLAC_DLL_PRIVATE static
-            #endif
-        #endif
-
-        #if defined(DR_FLAC_IMPLEMENTATION) || defined(DRFLAC_IMPLEMENTATION)
-            #define DRFLAC_API  DRFLAC_DLL_EXPORT
-        #else
-            #define DRFLAC_API  DRFLAC_DLL_IMPORT
-        #endif
-        #define DRFLAC_PRIVATE DRFLAC_DLL_PRIVATE
-    #else
-        #define DRFLAC_API extern
-        #define DRFLAC_PRIVATE static
-    #endif
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER >= 1700   /* Visual Studio 2012 */
-    #define DRFLAC_DEPRECATED       __declspec(deprecated)
-#elif (defined(__GNUC__) && __GNUC__ >= 4)  /* GCC 4 */
-    #define DRFLAC_DEPRECATED       __attribute__((deprecated))
-#elif defined(__has_feature)                /* Clang */
-    #if __has_feature(attribute_deprecated)
-        #define DRFLAC_DEPRECATED   __attribute__((deprecated))
-    #else
-        #define DRFLAC_DEPRECATED
-    #endif
-#else
-    #define DRFLAC_DEPRECATED
-#endif
-
-DRFLAC_API void drflac_version(drflac_uint32* pMajor, drflac_uint32* pMinor, drflac_uint32* pRevision);
-DRFLAC_API const char* drflac_version_string(void);
-
-/*
-As data is read from the client it is placed into an internal buffer for fast access. This controls the size of that buffer. Larger values means more speed,
-but also more memory. In my testing there is diminishing returns after about 4KB, but you can fiddle with this to suit your own needs. Must be a multiple of 8.
-*/
-#ifndef DR_FLAC_BUFFER_SIZE
-#define DR_FLAC_BUFFER_SIZE   4096
-#endif
-
-/* Check if we can enable 64-bit optimizations. */
-#if defined(_WIN64) || defined(_LP64) || defined(__LP64__)
-#define DRFLAC_64BIT
-#endif
-
-#ifdef DRFLAC_64BIT
-typedef drflac_uint64 drflac_cache_t;
-#else
-typedef drflac_uint32 drflac_cache_t;
-#endif
-
-/* The various metadata block types. */
-#define DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO       0
-#define DRFLAC_METADATA_BLOCK_TYPE_PADDING          1
-#define DRFLAC_METADATA_BLOCK_TYPE_APPLICATION      2
-#define DRFLAC_METADATA_BLOCK_TYPE_SEEKTABLE        3
-#define DRFLAC_METADATA_BLOCK_TYPE_VORBIS_COMMENT   4
-#define DRFLAC_METADATA_BLOCK_TYPE_CUESHEET         5
-#define DRFLAC_METADATA_BLOCK_TYPE_PICTURE          6
-#define DRFLAC_METADATA_BLOCK_TYPE_INVALID          127
-
-/* The various picture types specified in the PICTURE block. */
-#define DRFLAC_PICTURE_TYPE_OTHER                   0
-#define DRFLAC_PICTURE_TYPE_FILE_ICON               1
-#define DRFLAC_PICTURE_TYPE_OTHER_FILE_ICON         2
-#define DRFLAC_PICTURE_TYPE_COVER_FRONT             3
-#define DRFLAC_PICTURE_TYPE_COVER_BACK              4
-#define DRFLAC_PICTURE_TYPE_LEAFLET_PAGE            5
-#define DRFLAC_PICTURE_TYPE_MEDIA                   6
-#define DRFLAC_PICTURE_TYPE_LEAD_ARTIST             7
-#define DRFLAC_PICTURE_TYPE_ARTIST                  8
-#define DRFLAC_PICTURE_TYPE_CONDUCTOR               9
-#define DRFLAC_PICTURE_TYPE_BAND                    10
-#define DRFLAC_PICTURE_TYPE_COMPOSER                11
-#define DRFLAC_PICTURE_TYPE_LYRICIST                12
-#define DRFLAC_PICTURE_TYPE_RECORDING_LOCATION      13
-#define DRFLAC_PICTURE_TYPE_DURING_RECORDING        14
-#define DRFLAC_PICTURE_TYPE_DURING_PERFORMANCE      15
-#define DRFLAC_PICTURE_TYPE_SCREEN_CAPTURE          16
-#define DRFLAC_PICTURE_TYPE_BRIGHT_COLORED_FISH     17
-#define DRFLAC_PICTURE_TYPE_ILLUSTRATION            18
-#define DRFLAC_PICTURE_TYPE_BAND_LOGOTYPE           19
-#define DRFLAC_PICTURE_TYPE_PUBLISHER_LOGOTYPE      20
-
-typedef enum
-{
-    drflac_container_native,
-    drflac_container_ogg,
-    drflac_container_unknown
-} drflac_container;
-
-typedef enum
-{
-    drflac_seek_origin_start,
-    drflac_seek_origin_current
-} drflac_seek_origin;
-
-/* Packing is important on this structure because we map this directly to the raw data within the SEEKTABLE metadata block. */
-#pragma pack(2)
-typedef struct
-{
-    drflac_uint64 firstPCMFrame;
-    drflac_uint64 flacFrameOffset;   /* The offset from the first byte of the header of the first frame. */
-    drflac_uint16 pcmFrameCount;
-} drflac_seekpoint;
-#pragma pack()
-
-typedef struct
-{
-    drflac_uint16 minBlockSizeInPCMFrames;
-    drflac_uint16 maxBlockSizeInPCMFrames;
-    drflac_uint32 minFrameSizeInPCMFrames;
-    drflac_uint32 maxFrameSizeInPCMFrames;
-    drflac_uint32 sampleRate;
-    drflac_uint8  channels;
-    drflac_uint8  bitsPerSample;
-    drflac_uint64 totalPCMFrameCount;
-    drflac_uint8  md5[16];
-} drflac_streaminfo;
-
-typedef struct
-{
-    /*
-    The metadata type. Use this to know how to interpret the data below. Will be set to one of the
-    DRFLAC_METADATA_BLOCK_TYPE_* tokens.
-    */
-    drflac_uint32 type;
-
-    /*
-    A pointer to the raw data. This points to a temporary buffer so don't hold on to it. It's best to
-    not modify the contents of this buffer. Use the structures below for more meaningful and structured
-    information about the metadata. It's possible for this to be null.
-    */
-    const void* pRawData;
-
-    /* The size in bytes of the block and the buffer pointed to by pRawData if it's non-NULL. */
-    drflac_uint32 rawDataSize;
-
-    union
-    {
-        drflac_streaminfo streaminfo;
-
-        struct
-        {
-            int unused;
-        } padding;
-
-        struct
-        {
-            drflac_uint32 id;
-            const void* pData;
-            drflac_uint32 dataSize;
-        } application;
-
-        struct
-        {
-            drflac_uint32 seekpointCount;
-            const drflac_seekpoint* pSeekpoints;
-        } seektable;
-
-        struct
-        {
-            drflac_uint32 vendorLength;
-            const char* vendor;
-            drflac_uint32 commentCount;
-            const void* pComments;
-        } vorbis_comment;
-
-        struct
-        {
-            char catalog[128];
-            drflac_uint64 leadInSampleCount;
-            drflac_bool32 isCD;
-            drflac_uint8 trackCount;
-            const void* pTrackData;
-        } cuesheet;
-
-        struct
-        {
-            drflac_uint32 type;
-            drflac_uint32 mimeLength;
-            const char* mime;
-            drflac_uint32 descriptionLength;
-            const char* description;
-            drflac_uint32 width;
-            drflac_uint32 height;
-            drflac_uint32 colorDepth;
-            drflac_uint32 indexColorCount;
-            drflac_uint32 pictureDataSize;
-            const drflac_uint8* pPictureData;
-        } picture;
-    } data;
-} drflac_metadata;
-
-
-/*
-Callback for when data needs to be read from the client.
-
-
-Parameters
-----------
-pUserData (in)
-    The user data that was passed to drflac_open() and family.
-
-pBufferOut (out)
-    The output buffer.
-
-bytesToRead (in)
-    The number of bytes to read.
-
-
-Return Value
-------------
-The number of bytes actually read.
-
-
-Remarks
--------
-A return value of less than bytesToRead indicates the end of the stream. Do _not_ return from this callback until either the entire bytesToRead is filled or
-you have reached the end of the stream.
-*/
-typedef size_t (* drflac_read_proc)(void* pUserData, void* pBufferOut, size_t bytesToRead);
-
-/*
-Callback for when data needs to be seeked.
-
-
-Parameters
-----------
-pUserData (in)
-    The user data that was passed to drflac_open() and family.
-
-offset (in)
-    The number of bytes to move, relative to the origin. Will never be negative.
-
-origin (in)
-    The origin of the seek - the current position or the start of the stream.
-
-
-Return Value
-------------
-Whether or not the seek was successful.
-
-
-Remarks
--------
-The offset will never be negative. Whether or not it is relative to the beginning or current position is determined by the "origin" parameter which will be
-either drflac_seek_origin_start or drflac_seek_origin_current.
-
-When seeking to a PCM frame using drflac_seek_to_pcm_frame(), dr_flac may call this with an offset beyond the end of the FLAC stream. This needs to be detected
-and handled by returning DRFLAC_FALSE.
-*/
-typedef drflac_bool32 (* drflac_seek_proc)(void* pUserData, int offset, drflac_seek_origin origin);
-
-/*
-Callback for when a metadata block is read.
-
-
-Parameters
-----------
-pUserData (in)
-    The user data that was passed to drflac_open() and family.
-
-pMetadata (in)
-    A pointer to a structure containing the data of the metadata block.
-
-
-Remarks
--------
-Use pMetadata->type to determine which metadata block is being handled and how to read the data. This
-will be set to one of the DRFLAC_METADATA_BLOCK_TYPE_* tokens.
-*/
-typedef void (* drflac_meta_proc)(void* pUserData, drflac_metadata* pMetadata);
-
-
-typedef struct
-{
-    void* pUserData;
-    void* (* onMalloc)(size_t sz, void* pUserData);
-    void* (* onRealloc)(void* p, size_t sz, void* pUserData);
-    void  (* onFree)(void* p, void* pUserData);
-} drflac_allocation_callbacks;
-
-/* Structure for internal use. Only used for decoders opened with drflac_open_memory. */
-typedef struct
-{
-    const drflac_uint8* data;
-    size_t dataSize;
-    size_t currentReadPos;
-} drflac__memory_stream;
-
-/* Structure for internal use. Used for bit streaming. */
-typedef struct
-{
-    /* The function to call when more data needs to be read. */
-    drflac_read_proc onRead;
-
-    /* The function to call when the current read position needs to be moved. */
-    drflac_seek_proc onSeek;
-
-    /* The user data to pass around to onRead and onSeek. */
-    void* pUserData;
-
-
-    /*
-    The number of unaligned bytes in the L2 cache. This will always be 0 until the end of the stream is hit. At the end of the
-    stream there will be a number of bytes that don't cleanly fit in an L1 cache line, so we use this variable to know whether
-    or not the bistreamer needs to run on a slower path to read those last bytes. This will never be more than sizeof(drflac_cache_t).
-    */
-    size_t unalignedByteCount;
-
-    /* The content of the unaligned bytes. */
-    drflac_cache_t unalignedCache;
-
-    /* The index of the next valid cache line in the "L2" cache. */
-    drflac_uint32 nextL2Line;
-
-    /* The number of bits that have been consumed by the cache. This is used to determine how many valid bits are remaining. */
-    drflac_uint32 consumedBits;
-
-    /*
-    The cached data which was most recently read from the client. There are two levels of cache. Data flows as such:
-    Client -> L2 -> L1. The L2 -> L1 movement is aligned and runs on a fast path in just a few instructions.
-    */
-    drflac_cache_t cacheL2[DR_FLAC_BUFFER_SIZE/sizeof(drflac_cache_t)];
-    drflac_cache_t cache;
-
-    /*
-    CRC-16. This is updated whenever bits are read from the bit stream. Manually set this to 0 to reset the CRC. For FLAC, this
-    is reset to 0 at the beginning of each frame.
-    */
-    drflac_uint16 crc16;
-    drflac_cache_t crc16Cache;              /* A cache for optimizing CRC calculations. This is filled when when the L1 cache is reloaded. */
-    drflac_uint32 crc16CacheIgnoredBytes;   /* The number of bytes to ignore when updating the CRC-16 from the CRC-16 cache. */
-} drflac_bs;
-
-typedef struct
-{
-    /* The type of the subframe: SUBFRAME_CONSTANT, SUBFRAME_VERBATIM, SUBFRAME_FIXED or SUBFRAME_LPC. */
-    drflac_uint8 subframeType;
-
-    /* The number of wasted bits per sample as specified by the sub-frame header. */
-    drflac_uint8 wastedBitsPerSample;
-
-    /* The order to use for the prediction stage for SUBFRAME_FIXED and SUBFRAME_LPC. */
-    drflac_uint8 lpcOrder;
-
-    /* A pointer to the buffer containing the decoded samples in the subframe. This pointer is an offset from drflac::pExtraData. */
-    drflac_int32* pSamplesS32;
-} drflac_subframe;
-
-typedef struct
-{
-    /*
-    If the stream uses variable block sizes, this will be set to the index of the first PCM frame. If fixed block sizes are used, this will
-    always be set to 0. This is 64-bit because the decoded PCM frame number will be 36 bits.
-    */
-    drflac_uint64 pcmFrameNumber;
-
-    /*
-    If the stream uses fixed block sizes, this will be set to the frame number. If variable block sizes are used, this will always be 0. This
-    is 32-bit because in fixed block sizes, the maximum frame number will be 31 bits.
-    */
-    drflac_uint32 flacFrameNumber;
-
-    /* The sample rate of this frame. */
-    drflac_uint32 sampleRate;
-
-    /* The number of PCM frames in each sub-frame within this frame. */
-    drflac_uint16 blockSizeInPCMFrames;
-
-    /*
-    The channel assignment of this frame. This is not always set to the channel count. If interchannel decorrelation is being used this
-    will be set to DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE, DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE or DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE.
-    */
-    drflac_uint8 channelAssignment;
-
-    /* The number of bits per sample within this frame. */
-    drflac_uint8 bitsPerSample;
-
-    /* The frame's CRC. */
-    drflac_uint8 crc8;
-} drflac_frame_header;
-
-typedef struct
-{
-    /* The header. */
-    drflac_frame_header header;
-
-    /*
-    The number of PCM frames left to be read in this FLAC frame. This is initially set to the block size. As PCM frames are read,
-    this will be decremented. When it reaches 0, the decoder will see this frame as fully consumed and load the next frame.
-    */
-    drflac_uint32 pcmFramesRemaining;
-
-    /* The list of sub-frames within the frame. There is one sub-frame for each channel, and there's a maximum of 8 channels. */
-    drflac_subframe subframes[8];
-} drflac_frame;
-
-typedef struct
-{
-    /* The function to call when a metadata block is read. */
-    drflac_meta_proc onMeta;
-
-    /* The user data posted to the metadata callback function. */
-    void* pUserDataMD;
-
-    /* Memory allocation callbacks. */
-    drflac_allocation_callbacks allocationCallbacks;
-
-
-    /* The sample rate. Will be set to something like 44100. */
-    drflac_uint32 sampleRate;
-
-    /*
-    The number of channels. This will be set to 1 for monaural streams, 2 for stereo, etc. Maximum 8. This is set based on the
-    value specified in the STREAMINFO block.
-    */
-    drflac_uint8 channels;
-
-    /* The bits per sample. Will be set to something like 16, 24, etc. */
-    drflac_uint8 bitsPerSample;
-
-    /* The maximum block size, in samples. This number represents the number of samples in each channel (not combined). */
-    drflac_uint16 maxBlockSizeInPCMFrames;
-
-    /*
-    The total number of PCM Frames making up the stream. Can be 0 in which case it's still a valid stream, but just means
-    the total PCM frame count is unknown. Likely the case with streams like internet radio.
-    */
-    drflac_uint64 totalPCMFrameCount;
-
-
-    /* The container type. This is set based on whether or not the decoder was opened from a native or Ogg stream. */
-    drflac_container container;
-
-    /* The number of seekpoints in the seektable. */
-    drflac_uint32 seekpointCount;
-
-
-    /* Information about the frame the decoder is currently sitting on. */
-    drflac_frame currentFLACFrame;
-
-
-    /* The index of the PCM frame the decoder is currently sitting on. This is only used for seeking. */
-    drflac_uint64 currentPCMFrame;
-
-    /* The position of the first FLAC frame in the stream. This is only ever used for seeking. */
-    drflac_uint64 firstFLACFramePosInBytes;
-
-
-    /* A hack to avoid a malloc() when opening a decoder with drflac_open_memory(). */
-    drflac__memory_stream memoryStream;
-
-
-    /* A pointer to the decoded sample data. This is an offset of pExtraData. */
-    drflac_int32* pDecodedSamples;
-
-    /* A pointer to the seek table. This is an offset of pExtraData, or NULL if there is no seek table. */
-    drflac_seekpoint* pSeekpoints;
-
-    /* Internal use only. Only used with Ogg containers. Points to a drflac_oggbs object. This is an offset of pExtraData. */
-    void* _oggbs;
-
-    /* Internal use only. Used for profiling and testing different seeking modes. */
-    drflac_bool32 _noSeekTableSeek    : 1;
-    drflac_bool32 _noBinarySearchSeek : 1;
-    drflac_bool32 _noBruteForceSeek   : 1;
-
-    /* The bit streamer. The raw FLAC data is fed through this object. */
-    drflac_bs bs;
-
-    /* Variable length extra data. We attach this to the end of the object so we can avoid unnecessary mallocs. */
-    drflac_uint8 pExtraData[1];
-} drflac;
-
-
-/*
-Opens a FLAC decoder.
-
-
-Parameters
-----------
-onRead (in)
-    The function to call when data needs to be read from the client.
-
-onSeek (in)
-    The function to call when the read position of the client data needs to move.
-
-pUserData (in, optional)
-    A pointer to application defined data that will be passed to onRead and onSeek.
-
-pAllocationCallbacks (in, optional)
-    A pointer to application defined callbacks for managing memory allocations.
-
-
-Return Value
-------------
-Returns a pointer to an object representing the decoder.
-
-
-Remarks
--------
-Close the decoder with `drflac_close()`.
-
-`pAllocationCallbacks` can be NULL in which case it will use `DRFLAC_MALLOC`, `DRFLAC_REALLOC` and `DRFLAC_FREE`.
-
-This function will automatically detect whether or not you are attempting to open a native or Ogg encapsulated FLAC, both of which should work seamlessly
-without any manual intervention. Ogg encapsulation also works with multiplexed streams which basically means it can play FLAC encoded audio tracks in videos.
-
-This is the lowest level function for opening a FLAC stream. You can also use `drflac_open_file()` and `drflac_open_memory()` to open the stream from a file or
-from a block of memory respectively.
-
-The STREAMINFO block must be present for this to succeed. Use `drflac_open_relaxed()` to open a FLAC stream where the header may not be present.
-
-Use `drflac_open_with_metadata()` if you need access to metadata.
-
-
-Seek Also
----------
-drflac_open_file()
-drflac_open_memory()
-drflac_open_with_metadata()
-drflac_close()
-*/
-DRFLAC_API drflac* drflac_open(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Opens a FLAC stream with relaxed validation of the header block.
-
-
-Parameters
-----------
-onRead (in)
-    The function to call when data needs to be read from the client.
-
-onSeek (in)
-    The function to call when the read position of the client data needs to move.
-
-container (in)
-    Whether or not the FLAC stream is encapsulated using standard FLAC encapsulation or Ogg encapsulation.
-
-pUserData (in, optional)
-    A pointer to application defined data that will be passed to onRead and onSeek.
-
-pAllocationCallbacks (in, optional)
-    A pointer to application defined callbacks for managing memory allocations.
-
-
-Return Value
-------------
-A pointer to an object representing the decoder.
-
-
-Remarks
--------
-The same as drflac_open(), except attempts to open the stream even when a header block is not present.
-
-Because the header is not necessarily available, the caller must explicitly define the container (Native or Ogg). Do not set this to `drflac_container_unknown`
-as that is for internal use only.
-
-Opening in relaxed mode will continue reading data from onRead until it finds a valid frame. If a frame is never found it will continue forever. To abort,
-force your `onRead` callback to return 0, which dr_flac will use as an indicator that the end of the stream was found.
-
-Use `drflac_open_with_metadata_relaxed()` if you need access to metadata.
-*/
-DRFLAC_API drflac* drflac_open_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Opens a FLAC decoder and notifies the caller of the metadata chunks (album art, etc.).
-
-
-Parameters
-----------
-onRead (in)
-    The function to call when data needs to be read from the client.
-
-onSeek (in)
-    The function to call when the read position of the client data needs to move.
-
-onMeta (in)
-    The function to call for every metadata block.
-
-pUserData (in, optional)
-    A pointer to application defined data that will be passed to onRead, onSeek and onMeta.
-
-pAllocationCallbacks (in, optional)
-    A pointer to application defined callbacks for managing memory allocations.
-
-
-Return Value
-------------
-A pointer to an object representing the decoder.
-
-
-Remarks
--------
-Close the decoder with `drflac_close()`.
-
-`pAllocationCallbacks` can be NULL in which case it will use `DRFLAC_MALLOC`, `DRFLAC_REALLOC` and `DRFLAC_FREE`.
-
-This is slower than `drflac_open()`, so avoid this one if you don't need metadata. Internally, this will allocate and free memory on the heap for every
-metadata block except for STREAMINFO and PADDING blocks.
-
-The caller is notified of the metadata via the `onMeta` callback. All metadata blocks will be handled before the function returns. This callback takes a
-pointer to a `drflac_metadata` object which is a union containing the data of all relevant metadata blocks. Use the `type` member to discriminate against
-the different metadata types.
-
-The STREAMINFO block must be present for this to succeed. Use `drflac_open_with_metadata_relaxed()` to open a FLAC stream where the header may not be present.
-
-Note that this will behave inconsistently with `drflac_open()` if the stream is an Ogg encapsulated stream and a metadata block is corrupted. This is due to
-the way the Ogg stream recovers from corrupted pages. When `drflac_open_with_metadata()` is being used, the open routine will try to read the contents of the
-metadata block, whereas `drflac_open()` will simply seek past it (for the sake of efficiency). This inconsistency can result in different samples being
-returned depending on whether or not the stream is being opened with metadata.
-
-
-Seek Also
----------
-drflac_open_file_with_metadata()
-drflac_open_memory_with_metadata()
-drflac_open()
-drflac_close()
-*/
-DRFLAC_API drflac* drflac_open_with_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/*
-The same as drflac_open_with_metadata(), except attempts to open the stream even when a header block is not present.
-
-See Also
---------
-drflac_open_with_metadata()
-drflac_open_relaxed()
-*/
-DRFLAC_API drflac* drflac_open_with_metadata_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Closes the given FLAC decoder.
-
-
-Parameters
-----------
-pFlac (in)
-    The decoder to close.
-
-
-Remarks
--------
-This will destroy the decoder object.
-
-
-See Also
---------
-drflac_open()
-drflac_open_with_metadata()
-drflac_open_file()
-drflac_open_file_w()
-drflac_open_file_with_metadata()
-drflac_open_file_with_metadata_w()
-drflac_open_memory()
-drflac_open_memory_with_metadata()
-*/
-DRFLAC_API void drflac_close(drflac* pFlac);
-
-
-/*
-Reads sample data from the given FLAC decoder, output as interleaved signed 32-bit PCM.
-
-
-Parameters
-----------
-pFlac (in)
-    The decoder.
-
-framesToRead (in)
-    The number of PCM frames to read.
-
-pBufferOut (out, optional)
-    A pointer to the buffer that will receive the decoded samples.
-
-
-Return Value
-------------
-Returns the number of PCM frames actually read. If the return value is less than `framesToRead` it has reached the end.
-
-
-Remarks
--------
-pBufferOut can be null, in which case the call will act as a seek, and the return value will be the number of frames seeked.
-*/
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s32(drflac* pFlac, drflac_uint64 framesToRead, drflac_int32* pBufferOut);
-
-
-/*
-Reads sample data from the given FLAC decoder, output as interleaved signed 16-bit PCM.
-
-
-Parameters
-----------
-pFlac (in)
-    The decoder.
-
-framesToRead (in)
-    The number of PCM frames to read.
-
-pBufferOut (out, optional)
-    A pointer to the buffer that will receive the decoded samples.
-
-
-Return Value
-------------
-Returns the number of PCM frames actually read. If the return value is less than `framesToRead` it has reached the end.
-
-
-Remarks
--------
-pBufferOut can be null, in which case the call will act as a seek, and the return value will be the number of frames seeked.
-
-Note that this is lossy for streams where the bits per sample is larger than 16.
-*/
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s16(drflac* pFlac, drflac_uint64 framesToRead, drflac_int16* pBufferOut);
-
-/*
-Reads sample data from the given FLAC decoder, output as interleaved 32-bit floating point PCM.
-
-
-Parameters
-----------
-pFlac (in)
-    The decoder.
-
-framesToRead (in)
-    The number of PCM frames to read.
-
-pBufferOut (out, optional)
-    A pointer to the buffer that will receive the decoded samples.
-
-
-Return Value
-------------
-Returns the number of PCM frames actually read. If the return value is less than `framesToRead` it has reached the end.
-
-
-Remarks
--------
-pBufferOut can be null, in which case the call will act as a seek, and the return value will be the number of frames seeked.
-
-Note that this should be considered lossy due to the nature of floating point numbers not being able to exactly represent every possible number.
-*/
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_f32(drflac* pFlac, drflac_uint64 framesToRead, float* pBufferOut);
-
-/*
-Seeks to the PCM frame at the given index.
-
-
-Parameters
-----------
-pFlac (in)
-    The decoder.
-
-pcmFrameIndex (in)
-    The index of the PCM frame to seek to. See notes below.
-
-
-Return Value
--------------
-`DRFLAC_TRUE` if successful; `DRFLAC_FALSE` otherwise.
-*/
-DRFLAC_API drflac_bool32 drflac_seek_to_pcm_frame(drflac* pFlac, drflac_uint64 pcmFrameIndex);
-
-
-
-#ifndef DR_FLAC_NO_STDIO
-/*
-Opens a FLAC decoder from the file at the given path.
-
-
-Parameters
-----------
-pFileName (in)
-    The path of the file to open, either absolute or relative to the current directory.
-
-pAllocationCallbacks (in, optional)
-    A pointer to application defined callbacks for managing memory allocations.
-
-
-Return Value
-------------
-A pointer to an object representing the decoder.
-
-
-Remarks
--------
-Close the decoder with drflac_close().
-
-
-Remarks
--------
-This will hold a handle to the file until the decoder is closed with drflac_close(). Some platforms will restrict the number of files a process can have open
-at any given time, so keep this mind if you have many decoders open at the same time.
-
-
-See Also
---------
-drflac_open_file_with_metadata()
-drflac_open()
-drflac_close()
-*/
-DRFLAC_API drflac* drflac_open_file(const char* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac* drflac_open_file_w(const wchar_t* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Opens a FLAC decoder from the file at the given path and notifies the caller of the metadata chunks (album art, etc.)
-
-
-Parameters
-----------
-pFileName (in)
-    The path of the file to open, either absolute or relative to the current directory.
-
-pAllocationCallbacks (in, optional)
-    A pointer to application defined callbacks for managing memory allocations.
-
-onMeta (in)
-    The callback to fire for each metadata block.
-
-pUserData (in)
-    A pointer to the user data to pass to the metadata callback.
-
-pAllocationCallbacks (in)
-    A pointer to application defined callbacks for managing memory allocations.
-
-
-Remarks
--------
-Look at the documentation for drflac_open_with_metadata() for more information on how metadata is handled.
-
-
-See Also
---------
-drflac_open_with_metadata()
-drflac_open()
-drflac_close()
-*/
-DRFLAC_API drflac* drflac_open_file_with_metadata(const char* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac* drflac_open_file_with_metadata_w(const wchar_t* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-#endif
-
-/*
-Opens a FLAC decoder from a pre-allocated block of memory
-
-
-Parameters
-----------
-pData (in)
-    A pointer to the raw encoded FLAC data.
-
-dataSize (in)
-    The size in bytes of `data`.
-
-pAllocationCallbacks (in)
-    A pointer to application defined callbacks for managing memory allocations.
-
-
-Return Value
-------------
-A pointer to an object representing the decoder.
-
-
-Remarks
--------
-This does not create a copy of the data. It is up to the application to ensure the buffer remains valid for the lifetime of the decoder.
-
-
-See Also
---------
-drflac_open()
-drflac_close()
-*/
-DRFLAC_API drflac* drflac_open_memory(const void* pData, size_t dataSize, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Opens a FLAC decoder from a pre-allocated block of memory and notifies the caller of the metadata chunks (album art, etc.)
-
-
-Parameters
-----------
-pData (in)
-    A pointer to the raw encoded FLAC data.
-
-dataSize (in)
-    The size in bytes of `data`.
-
-onMeta (in)
-    The callback to fire for each metadata block.
-
-pUserData (in)
-    A pointer to the user data to pass to the metadata callback.
-
-pAllocationCallbacks (in)
-    A pointer to application defined callbacks for managing memory allocations.
-
-
-Remarks
--------
-Look at the documentation for drflac_open_with_metadata() for more information on how metadata is handled.
-
-
-See Also
--------
-drflac_open_with_metadata()
-drflac_open()
-drflac_close()
-*/
-DRFLAC_API drflac* drflac_open_memory_with_metadata(const void* pData, size_t dataSize, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-
-
-/* High Level APIs */
-
-/*
-Opens a FLAC stream from the given callbacks and fully decodes it in a single operation. The return value is a
-pointer to the sample data as interleaved signed 32-bit PCM. The returned data must be freed with drflac_free().
-
-You can pass in custom memory allocation callbacks via the pAllocationCallbacks parameter. This can be NULL in which
-case it will use DRFLAC_MALLOC, DRFLAC_REALLOC and DRFLAC_FREE.
-
-Sometimes a FLAC file won't keep track of the total sample count. In this situation the function will continuously
-read samples into a dynamically sized buffer on the heap until no samples are left.
-
-Do not call this function on a broadcast type of stream (like internet radio streams and whatnot).
-*/
-DRFLAC_API drflac_int32* drflac_open_and_read_pcm_frames_s32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/* Same as drflac_open_and_read_pcm_frames_s32(), except returns signed 16-bit integer samples. */
-DRFLAC_API drflac_int16* drflac_open_and_read_pcm_frames_s16(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/* Same as drflac_open_and_read_pcm_frames_s32(), except returns 32-bit floating-point samples. */
-DRFLAC_API float* drflac_open_and_read_pcm_frames_f32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-#ifndef DR_FLAC_NO_STDIO
-/* Same as drflac_open_and_read_pcm_frames_s32() except opens the decoder from a file. */
-DRFLAC_API drflac_int32* drflac_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/* Same as drflac_open_file_and_read_pcm_frames_s32(), except returns signed 16-bit integer samples. */
-DRFLAC_API drflac_int16* drflac_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/* Same as drflac_open_file_and_read_pcm_frames_s32(), except returns 32-bit floating-point samples. */
-DRFLAC_API float* drflac_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-#endif
-
-/* Same as drflac_open_and_read_pcm_frames_s32() except opens the decoder from a block of memory. */
-DRFLAC_API drflac_int32* drflac_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/* Same as drflac_open_memory_and_read_pcm_frames_s32(), except returns signed 16-bit integer samples. */
-DRFLAC_API drflac_int16* drflac_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/* Same as drflac_open_memory_and_read_pcm_frames_s32(), except returns 32-bit floating-point samples. */
-DRFLAC_API float* drflac_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Frees memory that was allocated internally by dr_flac.
-
-Set pAllocationCallbacks to the same object that was passed to drflac_open_*_and_read_pcm_frames_*(). If you originally passed in NULL, pass in NULL for this.
-*/
-DRFLAC_API void drflac_free(void* p, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-
-/* Structure representing an iterator for vorbis comments in a VORBIS_COMMENT metadata block. */
-typedef struct
-{
-    drflac_uint32 countRemaining;
-    const char* pRunningData;
-} drflac_vorbis_comment_iterator;
-
-/*
-Initializes a vorbis comment iterator. This can be used for iterating over the vorbis comments in a VORBIS_COMMENT
-metadata block.
-*/
-DRFLAC_API void drflac_init_vorbis_comment_iterator(drflac_vorbis_comment_iterator* pIter, drflac_uint32 commentCount, const void* pComments);
-
-/*
-Goes to the next vorbis comment in the given iterator. If null is returned it means there are no more comments. The
-returned string is NOT null terminated.
-*/
-DRFLAC_API const char* drflac_next_vorbis_comment(drflac_vorbis_comment_iterator* pIter, drflac_uint32* pCommentLengthOut);
-
-
-/* Structure representing an iterator for cuesheet tracks in a CUESHEET metadata block. */
-typedef struct
-{
-    drflac_uint32 countRemaining;
-    const char* pRunningData;
-} drflac_cuesheet_track_iterator;
-
-/* Packing is important on this structure because we map this directly to the raw data within the CUESHEET metadata block. */
-#pragma pack(4)
-typedef struct
-{
-    drflac_uint64 offset;
-    drflac_uint8 index;
-    drflac_uint8 reserved[3];
-} drflac_cuesheet_track_index;
-#pragma pack()
-
-typedef struct
-{
-    drflac_uint64 offset;
-    drflac_uint8 trackNumber;
-    char ISRC[12];
-    drflac_bool8 isAudio;
-    drflac_bool8 preEmphasis;
-    drflac_uint8 indexCount;
-    const drflac_cuesheet_track_index* pIndexPoints;
-} drflac_cuesheet_track;
-
-/*
-Initializes a cuesheet track iterator. This can be used for iterating over the cuesheet tracks in a CUESHEET metadata
-block.
-*/
-DRFLAC_API void drflac_init_cuesheet_track_iterator(drflac_cuesheet_track_iterator* pIter, drflac_uint32 trackCount, const void* pTrackData);
-
-/* Goes to the next cuesheet track in the given iterator. If DRFLAC_FALSE is returned it means there are no more comments. */
-DRFLAC_API drflac_bool32 drflac_next_cuesheet_track(drflac_cuesheet_track_iterator* pIter, drflac_cuesheet_track* pCuesheetTrack);
-
-
-#ifdef __cplusplus
-}
-#endif
-#endif  /* dr_flac_h */
-
-
-/************************************************************************************************************************************************************
- ************************************************************************************************************************************************************
-
- IMPLEMENTATION
-
- ************************************************************************************************************************************************************
- ************************************************************************************************************************************************************/
-#if defined(DR_FLAC_IMPLEMENTATION) || defined(DRFLAC_IMPLEMENTATION)
-#ifndef dr_flac_c
-#define dr_flac_c
-
-/* Disable some annoying warnings. */
-#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-    #pragma GCC diagnostic push
-    #if __GNUC__ >= 7
-    #pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
-    #endif
-#endif
-
-#ifdef __linux__
-    #ifndef _BSD_SOURCE
-        #define _BSD_SOURCE
-    #endif
-    #ifndef _DEFAULT_SOURCE
-        #define _DEFAULT_SOURCE
-    #endif
-    #ifndef __USE_BSD
-        #define __USE_BSD
-    #endif
-    #include <endian.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef _MSC_VER
-    #define DRFLAC_INLINE __forceinline
-#elif defined(__GNUC__)
-    /*
-    I've had a bug report where GCC is emitting warnings about functions possibly not being inlineable. This warning happens when
-    the __attribute__((always_inline)) attribute is defined without an "inline" statement. I think therefore there must be some
-    case where "__inline__" is not always defined, thus the compiler emitting these warnings. When using -std=c89 or -ansi on the
-    command line, we cannot use the "inline" keyword and instead need to use "__inline__". In an attempt to work around this issue
-    I am using "__inline__" only when we're compiling in strict ANSI mode.
-    */
-    #if defined(__STRICT_ANSI__)
-        #define DRFLAC_INLINE __inline__ __attribute__((always_inline))
-    #else
-        #define DRFLAC_INLINE inline __attribute__((always_inline))
-    #endif
-#elif defined(__WATCOMC__)
-    #define DRFLAC_INLINE __inline
-#else
-    #define DRFLAC_INLINE
-#endif
-
-/* CPU architecture. */
-#if defined(__x86_64__) || defined(_M_X64)
-    #define DRFLAC_X64
-#elif defined(__i386) || defined(_M_IX86)
-    #define DRFLAC_X86
-#elif defined(__arm__) || defined(_M_ARM) || defined(_M_ARM64)
-    #define DRFLAC_ARM
-#endif
-
-/*
-Intrinsics Support
-
-There's a bug in GCC 4.2.x which results in an incorrect compilation error when using _mm_slli_epi32() where it complains with
-
-    "error: shift must be an immediate"
-
-Unfortuantely dr_flac depends on this for a few things so we're just going to disable SSE on GCC 4.2 and below.
-*/
-#if !defined(DR_FLAC_NO_SIMD)
-    #if defined(DRFLAC_X64) || defined(DRFLAC_X86)
-        #if defined(_MSC_VER) && !defined(__clang__)
-            /* MSVC. */
-            #if _MSC_VER >= 1400 && !defined(DRFLAC_NO_SSE2)    /* 2005 */
-                #define DRFLAC_SUPPORT_SSE2
-            #endif
-            #if _MSC_VER >= 1600 && !defined(DRFLAC_NO_SSE41)   /* 2010 */
-                #define DRFLAC_SUPPORT_SSE41
-            #endif
-        #elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
-            /* Assume GNUC-style. */
-            #if defined(__SSE2__) && !defined(DRFLAC_NO_SSE2)
-                #define DRFLAC_SUPPORT_SSE2
-            #endif
-            #if defined(__SSE4_1__) && !defined(DRFLAC_NO_SSE41)
-                #define DRFLAC_SUPPORT_SSE41
-            #endif
-        #endif
-
-        /* If at this point we still haven't determined compiler support for the intrinsics just fall back to __has_include. */
-        #if !defined(__GNUC__) && !defined(__clang__) && defined(__has_include)
-            #if !defined(DRFLAC_SUPPORT_SSE2) && !defined(DRFLAC_NO_SSE2) && __has_include(<emmintrin.h>)
-                #define DRFLAC_SUPPORT_SSE2
-            #endif
-            #if !defined(DRFLAC_SUPPORT_SSE41) && !defined(DRFLAC_NO_SSE41) && __has_include(<smmintrin.h>)
-                #define DRFLAC_SUPPORT_SSE41
-            #endif
-        #endif
-
-        #if defined(DRFLAC_SUPPORT_SSE41)
-            #include <smmintrin.h>
-        #elif defined(DRFLAC_SUPPORT_SSE2)
-            #include <emmintrin.h>
-        #endif
-    #endif
-
-    #if defined(DRFLAC_ARM)
-        #if !defined(DRFLAC_NO_NEON) && (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64))
-            #define DRFLAC_SUPPORT_NEON
-        #endif
-
-        /* Fall back to looking for the #include file. */
-        #if !defined(__GNUC__) && !defined(__clang__) && defined(__has_include)
-            #if !defined(DRFLAC_SUPPORT_NEON) && !defined(DRFLAC_NO_NEON) && __has_include(<arm_neon.h>)
-                #define DRFLAC_SUPPORT_NEON
-            #endif
-        #endif
-
-        #if defined(DRFLAC_SUPPORT_NEON)
-            #include <arm_neon.h>
-        #endif
-    #endif
-#endif
-
-/* Compile-time CPU feature support. */
-#if !defined(DR_FLAC_NO_SIMD) && (defined(DRFLAC_X86) || defined(DRFLAC_X64))
-    #if defined(_MSC_VER) && !defined(__clang__)
-        #if _MSC_VER >= 1400
-            #include <intrin.h>
-            static void drflac__cpuid(int info[4], int fid)
-            {
-                __cpuid(info, fid);
-            }
-        #else
-            #define DRFLAC_NO_CPUID
-        #endif
-    #else
-        #if defined(__GNUC__) || defined(__clang__)
-            static void drflac__cpuid(int info[4], int fid)
-            {
-                /*
-                It looks like the -fPIC option uses the ebx register which GCC complains about. We can work around this by just using a different register, the
-                specific register of which I'm letting the compiler decide on. The "k" prefix is used to specify a 32-bit register. The {...} syntax is for
-                supporting different assembly dialects.
-
-                What's basically happening is that we're saving and restoring the ebx register manually.
-                */
-                #if defined(DRFLAC_X86) && defined(__PIC__)
-                    __asm__ __volatile__ (
-                        "xchg{l} {%%}ebx, %k1;"
-                        "cpuid;"
-                        "xchg{l} {%%}ebx, %k1;"
-                        : "=a"(info[0]), "=&r"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0)
-                    );
-                #else
-                    __asm__ __volatile__ (
-                        "cpuid" : "=a"(info[0]), "=b"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0)
-                    );
-                #endif
-            }
-        #else
-            #define DRFLAC_NO_CPUID
-        #endif
-    #endif
-#else
-    #define DRFLAC_NO_CPUID
-#endif
-
-static DRFLAC_INLINE drflac_bool32 drflac_has_sse2(void)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    #if (defined(DRFLAC_X64) || defined(DRFLAC_X86)) && !defined(DRFLAC_NO_SSE2)
-        #if defined(DRFLAC_X64)
-            return DRFLAC_TRUE;    /* 64-bit targets always support SSE2. */
-        #elif (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE2__)
-            return DRFLAC_TRUE;    /* If the compiler is allowed to freely generate SSE2 code we can assume support. */
-        #else
-            #if defined(DRFLAC_NO_CPUID)
-                return DRFLAC_FALSE;
-            #else
-                int info[4];
-                drflac__cpuid(info, 1);
-                return (info[3] & (1 << 26)) != 0;
-            #endif
-        #endif
-    #else
-        return DRFLAC_FALSE;       /* SSE2 is only supported on x86 and x64 architectures. */
-    #endif
-#else
-    return DRFLAC_FALSE;           /* No compiler support. */
-#endif
-}
-
-static DRFLAC_INLINE drflac_bool32 drflac_has_sse41(void)
-{
-#if defined(DRFLAC_SUPPORT_SSE41)
-    #if (defined(DRFLAC_X64) || defined(DRFLAC_X86)) && !defined(DRFLAC_NO_SSE41)
-        #if defined(DRFLAC_X64)
-            return DRFLAC_TRUE;    /* 64-bit targets always support SSE4.1. */
-        #elif (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE4_1__)
-            return DRFLAC_TRUE;    /* If the compiler is allowed to freely generate SSE41 code we can assume support. */
-        #else
-            #if defined(DRFLAC_NO_CPUID)
-                return DRFLAC_FALSE;
-            #else
-                int info[4];
-                drflac__cpuid(info, 1);
-                return (info[2] & (1 << 19)) != 0;
-            #endif
-        #endif
-    #else
-        return DRFLAC_FALSE;       /* SSE41 is only supported on x86 and x64 architectures. */
-    #endif
-#else
-    return DRFLAC_FALSE;           /* No compiler support. */
-#endif
-}
-
-
-#if defined(_MSC_VER) && _MSC_VER >= 1500 && (defined(DRFLAC_X86) || defined(DRFLAC_X64)) && !defined(__clang__)
-    #define DRFLAC_HAS_LZCNT_INTRINSIC
-#elif (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)))
-    #define DRFLAC_HAS_LZCNT_INTRINSIC
-#elif defined(__clang__)
-    #if defined(__has_builtin)
-        #if __has_builtin(__builtin_clzll) || __has_builtin(__builtin_clzl)
-            #define DRFLAC_HAS_LZCNT_INTRINSIC
-        #endif
-    #endif
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(__clang__)
-    #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
-    #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
-    #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
-#elif defined(__clang__)
-    #if defined(__has_builtin)
-        #if __has_builtin(__builtin_bswap16)
-            #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
-        #endif
-        #if __has_builtin(__builtin_bswap32)
-            #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
-        #endif
-        #if __has_builtin(__builtin_bswap64)
-            #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
-        #endif
-    #endif
-#elif defined(__GNUC__)
-    #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
-        #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
-        #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
-    #endif
-    #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
-        #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
-    #endif
-#endif
-
-
-/* Standard library stuff. */
-#ifndef DRFLAC_ASSERT
-#include <assert.h>
-#define DRFLAC_ASSERT(expression)           assert(expression)
-#endif
-#ifndef DRFLAC_MALLOC
-#define DRFLAC_MALLOC(sz)                   malloc((sz))
-#endif
-#ifndef DRFLAC_REALLOC
-#define DRFLAC_REALLOC(p, sz)               realloc((p), (sz))
-#endif
-#ifndef DRFLAC_FREE
-#define DRFLAC_FREE(p)                      free((p))
-#endif
-#ifndef DRFLAC_COPY_MEMORY
-#define DRFLAC_COPY_MEMORY(dst, src, sz)    memcpy((dst), (src), (sz))
-#endif
-#ifndef DRFLAC_ZERO_MEMORY
-#define DRFLAC_ZERO_MEMORY(p, sz)           memset((p), 0, (sz))
-#endif
-#ifndef DRFLAC_ZERO_OBJECT
-#define DRFLAC_ZERO_OBJECT(p)               DRFLAC_ZERO_MEMORY((p), sizeof(*(p)))
-#endif
-
-#define DRFLAC_MAX_SIMD_VECTOR_SIZE                     64  /* 64 for AVX-512 in the future. */
-
-typedef drflac_int32 drflac_result;
-#define DRFLAC_SUCCESS                                   0
-#define DRFLAC_ERROR                                    -1   /* A generic error. */
-#define DRFLAC_INVALID_ARGS                             -2
-#define DRFLAC_INVALID_OPERATION                        -3
-#define DRFLAC_OUT_OF_MEMORY                            -4
-#define DRFLAC_OUT_OF_RANGE                             -5
-#define DRFLAC_ACCESS_DENIED                            -6
-#define DRFLAC_DOES_NOT_EXIST                           -7
-#define DRFLAC_ALREADY_EXISTS                           -8
-#define DRFLAC_TOO_MANY_OPEN_FILES                      -9
-#define DRFLAC_INVALID_FILE                             -10
-#define DRFLAC_TOO_BIG                                  -11
-#define DRFLAC_PATH_TOO_LONG                            -12
-#define DRFLAC_NAME_TOO_LONG                            -13
-#define DRFLAC_NOT_DIRECTORY                            -14
-#define DRFLAC_IS_DIRECTORY                             -15
-#define DRFLAC_DIRECTORY_NOT_EMPTY                      -16
-#define DRFLAC_END_OF_FILE                              -17
-#define DRFLAC_NO_SPACE                                 -18
-#define DRFLAC_BUSY                                     -19
-#define DRFLAC_IO_ERROR                                 -20
-#define DRFLAC_INTERRUPT                                -21
-#define DRFLAC_UNAVAILABLE                              -22
-#define DRFLAC_ALREADY_IN_USE                           -23
-#define DRFLAC_BAD_ADDRESS                              -24
-#define DRFLAC_BAD_SEEK                                 -25
-#define DRFLAC_BAD_PIPE                                 -26
-#define DRFLAC_DEADLOCK                                 -27
-#define DRFLAC_TOO_MANY_LINKS                           -28
-#define DRFLAC_NOT_IMPLEMENTED                          -29
-#define DRFLAC_NO_MESSAGE                               -30
-#define DRFLAC_BAD_MESSAGE                              -31
-#define DRFLAC_NO_DATA_AVAILABLE                        -32
-#define DRFLAC_INVALID_DATA                             -33
-#define DRFLAC_TIMEOUT                                  -34
-#define DRFLAC_NO_NETWORK                               -35
-#define DRFLAC_NOT_UNIQUE                               -36
-#define DRFLAC_NOT_SOCKET                               -37
-#define DRFLAC_NO_ADDRESS                               -38
-#define DRFLAC_BAD_PROTOCOL                             -39
-#define DRFLAC_PROTOCOL_UNAVAILABLE                     -40
-#define DRFLAC_PROTOCOL_NOT_SUPPORTED                   -41
-#define DRFLAC_PROTOCOL_FAMILY_NOT_SUPPORTED            -42
-#define DRFLAC_ADDRESS_FAMILY_NOT_SUPPORTED             -43
-#define DRFLAC_SOCKET_NOT_SUPPORTED                     -44
-#define DRFLAC_CONNECTION_RESET                         -45
-#define DRFLAC_ALREADY_CONNECTED                        -46
-#define DRFLAC_NOT_CONNECTED                            -47
-#define DRFLAC_CONNECTION_REFUSED                       -48
-#define DRFLAC_NO_HOST                                  -49
-#define DRFLAC_IN_PROGRESS                              -50
-#define DRFLAC_CANCELLED                                -51
-#define DRFLAC_MEMORY_ALREADY_MAPPED                    -52
-#define DRFLAC_AT_END                                   -53
-#define DRFLAC_CRC_MISMATCH                             -128
-
-#define DRFLAC_SUBFRAME_CONSTANT                        0
-#define DRFLAC_SUBFRAME_VERBATIM                        1
-#define DRFLAC_SUBFRAME_FIXED                           8
-#define DRFLAC_SUBFRAME_LPC                             32
-#define DRFLAC_SUBFRAME_RESERVED                        255
-
-#define DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE  0
-#define DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2 1
-
-#define DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT           0
-#define DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE             8
-#define DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE            9
-#define DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE              10
-
-#define drflac_align(x, a)                              ((((x) + (a) - 1) / (a)) * (a))
-
-
-DRFLAC_API void drflac_version(drflac_uint32* pMajor, drflac_uint32* pMinor, drflac_uint32* pRevision)
-{
-    if (pMajor) {
-        *pMajor = DRFLAC_VERSION_MAJOR;
-    }
-
-    if (pMinor) {
-        *pMinor = DRFLAC_VERSION_MINOR;
-    }
-
-    if (pRevision) {
-        *pRevision = DRFLAC_VERSION_REVISION;
-    }
-}
-
-DRFLAC_API const char* drflac_version_string(void)
-{
-    return DRFLAC_VERSION_STRING;
-}
-
-
-/* CPU caps. */
-#if defined(__has_feature)
-    #if __has_feature(thread_sanitizer)
-        #define DRFLAC_NO_THREAD_SANITIZE __attribute__((no_sanitize("thread")))
-    #else
-        #define DRFLAC_NO_THREAD_SANITIZE
-    #endif
-#else
-    #define DRFLAC_NO_THREAD_SANITIZE
-#endif
-
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC)
-static drflac_bool32 drflac__gIsLZCNTSupported = DRFLAC_FALSE;
-#endif
-
-#ifndef DRFLAC_NO_CPUID
-static drflac_bool32 drflac__gIsSSE2Supported  = DRFLAC_FALSE;
-static drflac_bool32 drflac__gIsSSE41Supported = DRFLAC_FALSE;
-
-/*
-I've had a bug report that Clang's ThreadSanitizer presents a warning in this function. Having reviewed this, this does
-actually make sense. However, since CPU caps should never differ for a running process, I don't think the trade off of
-complicating internal API's by passing around CPU caps versus just disabling the warnings is worthwhile. I'm therefore
-just going to disable these warnings. This is disabled via the DRFLAC_NO_THREAD_SANITIZE attribute.
-*/
-DRFLAC_NO_THREAD_SANITIZE static void drflac__init_cpu_caps(void)
-{
-    static drflac_bool32 isCPUCapsInitialized = DRFLAC_FALSE;
-
-    if (!isCPUCapsInitialized) {
-        /* LZCNT */
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC)
-        int info[4] = {0};
-        drflac__cpuid(info, 0x80000001);
-        drflac__gIsLZCNTSupported = (info[2] & (1 << 5)) != 0;
-#endif
-
-        /* SSE2 */
-        drflac__gIsSSE2Supported = drflac_has_sse2();
-
-        /* SSE4.1 */
-        drflac__gIsSSE41Supported = drflac_has_sse41();
-
-        /* Initialized. */
-        isCPUCapsInitialized = DRFLAC_TRUE;
-    }
-}
-#else
-static drflac_bool32 drflac__gIsNEONSupported  = DRFLAC_FALSE;
-
-static DRFLAC_INLINE drflac_bool32 drflac__has_neon(void)
-{
-#if defined(DRFLAC_SUPPORT_NEON)
-    #if defined(DRFLAC_ARM) && !defined(DRFLAC_NO_NEON)
-        #if (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64))
-            return DRFLAC_TRUE;    /* If the compiler is allowed to freely generate NEON code we can assume support. */
-        #else
-            /* TODO: Runtime check. */
-            return DRFLAC_FALSE;
-        #endif
-    #else
-        return DRFLAC_FALSE;       /* NEON is only supported on ARM architectures. */
-    #endif
-#else
-    return DRFLAC_FALSE;           /* No compiler support. */
-#endif
-}
-
-DRFLAC_NO_THREAD_SANITIZE static void drflac__init_cpu_caps(void)
-{
-    drflac__gIsNEONSupported = drflac__has_neon();
-
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC) && defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5)
-    drflac__gIsLZCNTSupported = DRFLAC_TRUE;
-#endif
-}
-#endif
-
-
-/* Endian Management */
-static DRFLAC_INLINE drflac_bool32 drflac__is_little_endian(void)
-{
-#if defined(DRFLAC_X86) || defined(DRFLAC_X64)
-    return DRFLAC_TRUE;
-#elif defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN
-    return DRFLAC_TRUE;
-#else
-    int n = 1;
-    return (*(char*)&n) == 1;
-#endif
-}
-
-static DRFLAC_INLINE drflac_uint16 drflac__swap_endian_uint16(drflac_uint16 n)
-{
-#ifdef DRFLAC_HAS_BYTESWAP16_INTRINSIC
-    #if defined(_MSC_VER) && !defined(__clang__)
-        return _byteswap_ushort(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        return __builtin_bswap16(n);
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & 0xFF00) >> 8) |
-           ((n & 0x00FF) << 8);
-#endif
-}
-
-static DRFLAC_INLINE drflac_uint32 drflac__swap_endian_uint32(drflac_uint32 n)
-{
-#ifdef DRFLAC_HAS_BYTESWAP32_INTRINSIC
-    #if defined(_MSC_VER) && !defined(__clang__)
-        return _byteswap_ulong(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        #if defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 6) && !defined(DRFLAC_64BIT)   /* <-- 64-bit inline assembly has not been tested, so disabling for now. */
-            /* Inline assembly optimized implementation for ARM. In my testing, GCC does not generate optimized code with __builtin_bswap32(). */
-            drflac_uint32 r;
-            __asm__ __volatile__ (
-            #if defined(DRFLAC_64BIT)
-                "rev %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(n)   /* <-- This is untested. If someone in the community could test this, that would be appreciated! */
-            #else
-                "rev %[out], %[in]" : [out]"=r"(r) : [in]"r"(n)
-            #endif
-            );
-            return r;
-        #else
-            return __builtin_bswap32(n);
-        #endif
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & 0xFF000000) >> 24) |
-           ((n & 0x00FF0000) >>  8) |
-           ((n & 0x0000FF00) <<  8) |
-           ((n & 0x000000FF) << 24);
-#endif
-}
-
-static DRFLAC_INLINE drflac_uint64 drflac__swap_endian_uint64(drflac_uint64 n)
-{
-#ifdef DRFLAC_HAS_BYTESWAP64_INTRINSIC
-    #if defined(_MSC_VER) && !defined(__clang__)
-        return _byteswap_uint64(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        return __builtin_bswap64(n);
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    /* Weird "<< 32" bitshift is required for C89 because it doesn't support 64-bit constants. Should be optimized out by a good compiler. */
-    return ((n & ((drflac_uint64)0xFF000000 << 32)) >> 56) |
-           ((n & ((drflac_uint64)0x00FF0000 << 32)) >> 40) |
-           ((n & ((drflac_uint64)0x0000FF00 << 32)) >> 24) |
-           ((n & ((drflac_uint64)0x000000FF << 32)) >>  8) |
-           ((n & ((drflac_uint64)0xFF000000      )) <<  8) |
-           ((n & ((drflac_uint64)0x00FF0000      )) << 24) |
-           ((n & ((drflac_uint64)0x0000FF00      )) << 40) |
-           ((n & ((drflac_uint64)0x000000FF      )) << 56);
-#endif
-}
-
-
-static DRFLAC_INLINE drflac_uint16 drflac__be2host_16(drflac_uint16 n)
-{
-    if (drflac__is_little_endian()) {
-        return drflac__swap_endian_uint16(n);
-    }
-
-    return n;
-}
-
-static DRFLAC_INLINE drflac_uint32 drflac__be2host_32(drflac_uint32 n)
-{
-    if (drflac__is_little_endian()) {
-        return drflac__swap_endian_uint32(n);
-    }
-
-    return n;
-}
-
-static DRFLAC_INLINE drflac_uint64 drflac__be2host_64(drflac_uint64 n)
-{
-    if (drflac__is_little_endian()) {
-        return drflac__swap_endian_uint64(n);
-    }
-
-    return n;
-}
-
-
-static DRFLAC_INLINE drflac_uint32 drflac__le2host_32(drflac_uint32 n)
-{
-    if (!drflac__is_little_endian()) {
-        return drflac__swap_endian_uint32(n);
-    }
-
-    return n;
-}
-
-
-static DRFLAC_INLINE drflac_uint32 drflac__unsynchsafe_32(drflac_uint32 n)
-{
-    drflac_uint32 result = 0;
-    result |= (n & 0x7F000000) >> 3;
-    result |= (n & 0x007F0000) >> 2;
-    result |= (n & 0x00007F00) >> 1;
-    result |= (n & 0x0000007F) >> 0;
-
-    return result;
-}
-
-
-
-/* The CRC code below is based on this document: http://zlib.net/crc_v3.txt */
-static drflac_uint8 drflac__crc8_table[] = {
-    0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D,
-    0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65, 0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D,
-    0xE0, 0xE7, 0xEE, 0xE9, 0xFC, 0xFB, 0xF2, 0xF5, 0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD,
-    0x90, 0x97, 0x9E, 0x99, 0x8C, 0x8B, 0x82, 0x85, 0xA8, 0xAF, 0xA6, 0xA1, 0xB4, 0xB3, 0xBA, 0xBD,
-    0xC7, 0xC0, 0xC9, 0xCE, 0xDB, 0xDC, 0xD5, 0xD2, 0xFF, 0xF8, 0xF1, 0xF6, 0xE3, 0xE4, 0xED, 0xEA,
-    0xB7, 0xB0, 0xB9, 0xBE, 0xAB, 0xAC, 0xA5, 0xA2, 0x8F, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9D, 0x9A,
-    0x27, 0x20, 0x29, 0x2E, 0x3B, 0x3C, 0x35, 0x32, 0x1F, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0D, 0x0A,
-    0x57, 0x50, 0x59, 0x5E, 0x4B, 0x4C, 0x45, 0x42, 0x6F, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7D, 0x7A,
-    0x89, 0x8E, 0x87, 0x80, 0x95, 0x92, 0x9B, 0x9C, 0xB1, 0xB6, 0xBF, 0xB8, 0xAD, 0xAA, 0xA3, 0xA4,
-    0xF9, 0xFE, 0xF7, 0xF0, 0xE5, 0xE2, 0xEB, 0xEC, 0xC1, 0xC6, 0xCF, 0xC8, 0xDD, 0xDA, 0xD3, 0xD4,
-    0x69, 0x6E, 0x67, 0x60, 0x75, 0x72, 0x7B, 0x7C, 0x51, 0x56, 0x5F, 0x58, 0x4D, 0x4A, 0x43, 0x44,
-    0x19, 0x1E, 0x17, 0x10, 0x05, 0x02, 0x0B, 0x0C, 0x21, 0x26, 0x2F, 0x28, 0x3D, 0x3A, 0x33, 0x34,
-    0x4E, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5C, 0x5B, 0x76, 0x71, 0x78, 0x7F, 0x6A, 0x6D, 0x64, 0x63,
-    0x3E, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2C, 0x2B, 0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13,
-    0xAE, 0xA9, 0xA0, 0xA7, 0xB2, 0xB5, 0xBC, 0xBB, 0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83,
-    0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 0xE6, 0xE1, 0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3
-};
-
-static drflac_uint16 drflac__crc16_table[] = {
-    0x0000, 0x8005, 0x800F, 0x000A, 0x801B, 0x001E, 0x0014, 0x8011,
-    0x8033, 0x0036, 0x003C, 0x8039, 0x0028, 0x802D, 0x8027, 0x0022,
-    0x8063, 0x0066, 0x006C, 0x8069, 0x0078, 0x807D, 0x8077, 0x0072,
-    0x0050, 0x8055, 0x805F, 0x005A, 0x804B, 0x004E, 0x0044, 0x8041,
-    0x80C3, 0x00C6, 0x00CC, 0x80C9, 0x00D8, 0x80DD, 0x80D7, 0x00D2,
-    0x00F0, 0x80F5, 0x80FF, 0x00FA, 0x80EB, 0x00EE, 0x00E4, 0x80E1,
-    0x00A0, 0x80A5, 0x80AF, 0x00AA, 0x80BB, 0x00BE, 0x00B4, 0x80B1,
-    0x8093, 0x0096, 0x009C, 0x8099, 0x0088, 0x808D, 0x8087, 0x0082,
-    0x8183, 0x0186, 0x018C, 0x8189, 0x0198, 0x819D, 0x8197, 0x0192,
-    0x01B0, 0x81B5, 0x81BF, 0x01BA, 0x81AB, 0x01AE, 0x01A4, 0x81A1,
-    0x01E0, 0x81E5, 0x81EF, 0x01EA, 0x81FB, 0x01FE, 0x01F4, 0x81F1,
-    0x81D3, 0x01D6, 0x01DC, 0x81D9, 0x01C8, 0x81CD, 0x81C7, 0x01C2,
-    0x0140, 0x8145, 0x814F, 0x014A, 0x815B, 0x015E, 0x0154, 0x8151,
-    0x8173, 0x0176, 0x017C, 0x8179, 0x0168, 0x816D, 0x8167, 0x0162,
-    0x8123, 0x0126, 0x012C, 0x8129, 0x0138, 0x813D, 0x8137, 0x0132,
-    0x0110, 0x8115, 0x811F, 0x011A, 0x810B, 0x010E, 0x0104, 0x8101,
-    0x8303, 0x0306, 0x030C, 0x8309, 0x0318, 0x831D, 0x8317, 0x0312,
-    0x0330, 0x8335, 0x833F, 0x033A, 0x832B, 0x032E, 0x0324, 0x8321,
-    0x0360, 0x8365, 0x836F, 0x036A, 0x837B, 0x037E, 0x0374, 0x8371,
-    0x8353, 0x0356, 0x035C, 0x8359, 0x0348, 0x834D, 0x8347, 0x0342,
-    0x03C0, 0x83C5, 0x83CF, 0x03CA, 0x83DB, 0x03DE, 0x03D4, 0x83D1,
-    0x83F3, 0x03F6, 0x03FC, 0x83F9, 0x03E8, 0x83ED, 0x83E7, 0x03E2,
-    0x83A3, 0x03A6, 0x03AC, 0x83A9, 0x03B8, 0x83BD, 0x83B7, 0x03B2,
-    0x0390, 0x8395, 0x839F, 0x039A, 0x838B, 0x038E, 0x0384, 0x8381,
-    0x0280, 0x8285, 0x828F, 0x028A, 0x829B, 0x029E, 0x0294, 0x8291,
-    0x82B3, 0x02B6, 0x02BC, 0x82B9, 0x02A8, 0x82AD, 0x82A7, 0x02A2,
-    0x82E3, 0x02E6, 0x02EC, 0x82E9, 0x02F8, 0x82FD, 0x82F7, 0x02F2,
-    0x02D0, 0x82D5, 0x82DF, 0x02DA, 0x82CB, 0x02CE, 0x02C4, 0x82C1,
-    0x8243, 0x0246, 0x024C, 0x8249, 0x0258, 0x825D, 0x8257, 0x0252,
-    0x0270, 0x8275, 0x827F, 0x027A, 0x826B, 0x026E, 0x0264, 0x8261,
-    0x0220, 0x8225, 0x822F, 0x022A, 0x823B, 0x023E, 0x0234, 0x8231,
-    0x8213, 0x0216, 0x021C, 0x8219, 0x0208, 0x820D, 0x8207, 0x0202
-};
-
-static DRFLAC_INLINE drflac_uint8 drflac_crc8_byte(drflac_uint8 crc, drflac_uint8 data)
-{
-    return drflac__crc8_table[crc ^ data];
-}
-
-static DRFLAC_INLINE drflac_uint8 drflac_crc8(drflac_uint8 crc, drflac_uint32 data, drflac_uint32 count)
-{
-#ifdef DR_FLAC_NO_CRC
-    (void)crc;
-    (void)data;
-    (void)count;
-    return 0;
-#else
-#if 0
-    /* REFERENCE (use of this implementation requires an explicit flush by doing "drflac_crc8(crc, 0, 8);") */
-    drflac_uint8 p = 0x07;
-    for (int i = count-1; i >= 0; --i) {
-        drflac_uint8 bit = (data & (1 << i)) >> i;
-        if (crc & 0x80) {
-            crc = ((crc << 1) | bit) ^ p;
-        } else {
-            crc = ((crc << 1) | bit);
-        }
-    }
-    return crc;
-#else
-    drflac_uint32 wholeBytes;
-    drflac_uint32 leftoverBits;
-    drflac_uint64 leftoverDataMask;
-
-    static drflac_uint64 leftoverDataMaskTable[8] = {
-        0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F
-    };
-
-    DRFLAC_ASSERT(count <= 32);
-
-    wholeBytes = count >> 3;
-    leftoverBits = count - (wholeBytes*8);
-    leftoverDataMask = leftoverDataMaskTable[leftoverBits];
-
-    switch (wholeBytes) {
-        case 4: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0xFF000000UL << leftoverBits)) >> (24 + leftoverBits)));
-        case 3: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0x00FF0000UL << leftoverBits)) >> (16 + leftoverBits)));
-        case 2: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0x0000FF00UL << leftoverBits)) >> ( 8 + leftoverBits)));
-        case 1: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0x000000FFUL << leftoverBits)) >> ( 0 + leftoverBits)));
-        case 0: if (leftoverBits > 0) crc = (drflac_uint8)((crc << leftoverBits) ^ drflac__crc8_table[(crc >> (8 - leftoverBits)) ^ (data & leftoverDataMask)]);
-    }
-    return crc;
-#endif
-#endif
-}
-
-static DRFLAC_INLINE drflac_uint16 drflac_crc16_byte(drflac_uint16 crc, drflac_uint8 data)
-{
-    return (crc << 8) ^ drflac__crc16_table[(drflac_uint8)(crc >> 8) ^ data];
-}
-
-static DRFLAC_INLINE drflac_uint16 drflac_crc16_cache(drflac_uint16 crc, drflac_cache_t data)
-{
-#ifdef DRFLAC_64BIT
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 56) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 48) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 40) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 32) & 0xFF));
-#endif
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 24) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 16) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >>  8) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >>  0) & 0xFF));
-
-    return crc;
-}
-
-static DRFLAC_INLINE drflac_uint16 drflac_crc16_bytes(drflac_uint16 crc, drflac_cache_t data, drflac_uint32 byteCount)
-{
-    switch (byteCount)
-    {
-#ifdef DRFLAC_64BIT
-    case 8: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 56) & 0xFF));
-    case 7: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 48) & 0xFF));
-    case 6: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 40) & 0xFF));
-    case 5: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 32) & 0xFF));
-#endif
-    case 4: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 24) & 0xFF));
-    case 3: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 16) & 0xFF));
-    case 2: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >>  8) & 0xFF));
-    case 1: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >>  0) & 0xFF));
-    }
-
-    return crc;
-}
-
-#if 0
-static DRFLAC_INLINE drflac_uint16 drflac_crc16__32bit(drflac_uint16 crc, drflac_uint32 data, drflac_uint32 count)
-{
-#ifdef DR_FLAC_NO_CRC
-    (void)crc;
-    (void)data;
-    (void)count;
-    return 0;
-#else
-#if 0
-    /* REFERENCE (use of this implementation requires an explicit flush by doing "drflac_crc16(crc, 0, 16);") */
-    drflac_uint16 p = 0x8005;
-    for (int i = count-1; i >= 0; --i) {
-        drflac_uint16 bit = (data & (1ULL << i)) >> i;
-        if (r & 0x8000) {
-            r = ((r << 1) | bit) ^ p;
-        } else {
-            r = ((r << 1) | bit);
-        }
-    }
-
-    return crc;
-#else
-    drflac_uint32 wholeBytes;
-    drflac_uint32 leftoverBits;
-    drflac_uint64 leftoverDataMask;
-
-    static drflac_uint64 leftoverDataMaskTable[8] = {
-        0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F
-    };
-
-    DRFLAC_ASSERT(count <= 64);
-
-    wholeBytes = count >> 3;
-    leftoverBits = count & 7;
-    leftoverDataMask = leftoverDataMaskTable[leftoverBits];
-
-    switch (wholeBytes) {
-        default:
-        case 4: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0xFF000000UL << leftoverBits)) >> (24 + leftoverBits)));
-        case 3: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0x00FF0000UL << leftoverBits)) >> (16 + leftoverBits)));
-        case 2: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0x0000FF00UL << leftoverBits)) >> ( 8 + leftoverBits)));
-        case 1: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0x000000FFUL << leftoverBits)) >> ( 0 + leftoverBits)));
-        case 0: if (leftoverBits > 0) crc = (crc << leftoverBits) ^ drflac__crc16_table[(crc >> (16 - leftoverBits)) ^ (data & leftoverDataMask)];
-    }
-    return crc;
-#endif
-#endif
-}
-
-static DRFLAC_INLINE drflac_uint16 drflac_crc16__64bit(drflac_uint16 crc, drflac_uint64 data, drflac_uint32 count)
-{
-#ifdef DR_FLAC_NO_CRC
-    (void)crc;
-    (void)data;
-    (void)count;
-    return 0;
-#else
-    drflac_uint32 wholeBytes;
-    drflac_uint32 leftoverBits;
-    drflac_uint64 leftoverDataMask;
-
-    static drflac_uint64 leftoverDataMaskTable[8] = {
-        0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F
-    };
-
-    DRFLAC_ASSERT(count <= 64);
-
-    wholeBytes = count >> 3;
-    leftoverBits = count & 7;
-    leftoverDataMask = leftoverDataMaskTable[leftoverBits];
-
-    switch (wholeBytes) {
-        default:
-        case 8: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0xFF000000 << 32) << leftoverBits)) >> (56 + leftoverBits)));    /* Weird "<< 32" bitshift is required for C89 because it doesn't support 64-bit constants. Should be optimized out by a good compiler. */
-        case 7: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x00FF0000 << 32) << leftoverBits)) >> (48 + leftoverBits)));
-        case 6: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x0000FF00 << 32) << leftoverBits)) >> (40 + leftoverBits)));
-        case 5: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x000000FF << 32) << leftoverBits)) >> (32 + leftoverBits)));
-        case 4: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0xFF000000      ) << leftoverBits)) >> (24 + leftoverBits)));
-        case 3: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x00FF0000      ) << leftoverBits)) >> (16 + leftoverBits)));
-        case 2: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x0000FF00      ) << leftoverBits)) >> ( 8 + leftoverBits)));
-        case 1: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x000000FF      ) << leftoverBits)) >> ( 0 + leftoverBits)));
-        case 0: if (leftoverBits > 0) crc = (crc << leftoverBits) ^ drflac__crc16_table[(crc >> (16 - leftoverBits)) ^ (data & leftoverDataMask)];
-    }
-    return crc;
-#endif
-}
-
-
-static DRFLAC_INLINE drflac_uint16 drflac_crc16(drflac_uint16 crc, drflac_cache_t data, drflac_uint32 count)
-{
-#ifdef DRFLAC_64BIT
-    return drflac_crc16__64bit(crc, data, count);
-#else
-    return drflac_crc16__32bit(crc, data, count);
-#endif
-}
-#endif
-
-
-#ifdef DRFLAC_64BIT
-#define drflac__be2host__cache_line drflac__be2host_64
-#else
-#define drflac__be2host__cache_line drflac__be2host_32
-#endif
-
-/*
-BIT READING ATTEMPT #2
-
-This uses a 32- or 64-bit bit-shifted cache - as bits are read, the cache is shifted such that the first valid bit is sitting
-on the most significant bit. It uses the notion of an L1 and L2 cache (borrowed from CPU architecture), where the L1 cache
-is a 32- or 64-bit unsigned integer (depending on whether or not a 32- or 64-bit build is being compiled) and the L2 is an
-array of "cache lines", with each cache line being the same size as the L1. The L2 is a buffer of about 4KB and is where data
-from onRead() is read into.
-*/
-#define DRFLAC_CACHE_L1_SIZE_BYTES(bs)                      (sizeof((bs)->cache))
-#define DRFLAC_CACHE_L1_SIZE_BITS(bs)                       (sizeof((bs)->cache)*8)
-#define DRFLAC_CACHE_L1_BITS_REMAINING(bs)                  (DRFLAC_CACHE_L1_SIZE_BITS(bs) - (bs)->consumedBits)
-#define DRFLAC_CACHE_L1_SELECTION_MASK(_bitCount)           (~((~(drflac_cache_t)0) >> (_bitCount)))
-#define DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, _bitCount)      (DRFLAC_CACHE_L1_SIZE_BITS(bs) - (_bitCount))
-#define DRFLAC_CACHE_L1_SELECT(bs, _bitCount)               (((bs)->cache) & DRFLAC_CACHE_L1_SELECTION_MASK(_bitCount))
-#define DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, _bitCount)     (DRFLAC_CACHE_L1_SELECT((bs), (_bitCount)) >>  DRFLAC_CACHE_L1_SELECTION_SHIFT((bs), (_bitCount)))
-#define DRFLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE(bs, _bitCount)(DRFLAC_CACHE_L1_SELECT((bs), (_bitCount)) >> (DRFLAC_CACHE_L1_SELECTION_SHIFT((bs), (_bitCount)) & (DRFLAC_CACHE_L1_SIZE_BITS(bs)-1)))
-#define DRFLAC_CACHE_L2_SIZE_BYTES(bs)                      (sizeof((bs)->cacheL2))
-#define DRFLAC_CACHE_L2_LINE_COUNT(bs)                      (DRFLAC_CACHE_L2_SIZE_BYTES(bs) / sizeof((bs)->cacheL2[0]))
-#define DRFLAC_CACHE_L2_LINES_REMAINING(bs)                 (DRFLAC_CACHE_L2_LINE_COUNT(bs) - (bs)->nextL2Line)
-
-
-#ifndef DR_FLAC_NO_CRC
-static DRFLAC_INLINE void drflac__reset_crc16(drflac_bs* bs)
-{
-    bs->crc16 = 0;
-    bs->crc16CacheIgnoredBytes = bs->consumedBits >> 3;
-}
-
-static DRFLAC_INLINE void drflac__update_crc16(drflac_bs* bs)
-{
-    if (bs->crc16CacheIgnoredBytes == 0) {
-        bs->crc16 = drflac_crc16_cache(bs->crc16, bs->crc16Cache);
-    } else {
-        bs->crc16 = drflac_crc16_bytes(bs->crc16, bs->crc16Cache, DRFLAC_CACHE_L1_SIZE_BYTES(bs) - bs->crc16CacheIgnoredBytes);
-        bs->crc16CacheIgnoredBytes = 0;
-    }
-}
-
-static DRFLAC_INLINE drflac_uint16 drflac__flush_crc16(drflac_bs* bs)
-{
-    /* We should never be flushing in a situation where we are not aligned on a byte boundary. */
-    DRFLAC_ASSERT((DRFLAC_CACHE_L1_BITS_REMAINING(bs) & 7) == 0);
-
-    /*
-    The bits that were read from the L1 cache need to be accumulated. The number of bytes needing to be accumulated is determined
-    by the number of bits that have been consumed.
-    */
-    if (DRFLAC_CACHE_L1_BITS_REMAINING(bs) == 0) {
-        drflac__update_crc16(bs);
-    } else {
-        /* We only accumulate the consumed bits. */
-        bs->crc16 = drflac_crc16_bytes(bs->crc16, bs->crc16Cache >> DRFLAC_CACHE_L1_BITS_REMAINING(bs), (bs->consumedBits >> 3) - bs->crc16CacheIgnoredBytes);
-
-        /*
-        The bits that we just accumulated should never be accumulated again. We need to keep track of how many bytes were accumulated
-        so we can handle that later.
-        */
-        bs->crc16CacheIgnoredBytes = bs->consumedBits >> 3;
-    }
-
-    return bs->crc16;
-}
-#endif
-
-static DRFLAC_INLINE drflac_bool32 drflac__reload_l1_cache_from_l2(drflac_bs* bs)
-{
-    size_t bytesRead;
-    size_t alignedL1LineCount;
-
-    /* Fast path. Try loading straight from L2. */
-    if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-        bs->cache = bs->cacheL2[bs->nextL2Line++];
-        return DRFLAC_TRUE;
-    }
-
-    /*
-    If we get here it means we've run out of data in the L2 cache. We'll need to fetch more from the client, if there's
-    any left.
-    */
-    if (bs->unalignedByteCount > 0) {
-        return DRFLAC_FALSE;   /* If we have any unaligned bytes it means there's no more aligned bytes left in the client. */
-    }
-
-    bytesRead = bs->onRead(bs->pUserData, bs->cacheL2, DRFLAC_CACHE_L2_SIZE_BYTES(bs));
-
-    bs->nextL2Line = 0;
-    if (bytesRead == DRFLAC_CACHE_L2_SIZE_BYTES(bs)) {
-        bs->cache = bs->cacheL2[bs->nextL2Line++];
-        return DRFLAC_TRUE;
-    }
-
-
-    /*
-    If we get here it means we were unable to retrieve enough data to fill the entire L2 cache. It probably
-    means we've just reached the end of the file. We need to move the valid data down to the end of the buffer
-    and adjust the index of the next line accordingly. Also keep in mind that the L2 cache must be aligned to
-    the size of the L1 so we'll need to seek backwards by any misaligned bytes.
-    */
-    alignedL1LineCount = bytesRead / DRFLAC_CACHE_L1_SIZE_BYTES(bs);
-
-    /* We need to keep track of any unaligned bytes for later use. */
-    bs->unalignedByteCount = bytesRead - (alignedL1LineCount * DRFLAC_CACHE_L1_SIZE_BYTES(bs));
-    if (bs->unalignedByteCount > 0) {
-        bs->unalignedCache = bs->cacheL2[alignedL1LineCount];
-    }
-
-    if (alignedL1LineCount > 0) {
-        size_t offset = DRFLAC_CACHE_L2_LINE_COUNT(bs) - alignedL1LineCount;
-        size_t i;
-        for (i = alignedL1LineCount; i > 0; --i) {
-            bs->cacheL2[i-1 + offset] = bs->cacheL2[i-1];
-        }
-
-        bs->nextL2Line = (drflac_uint32)offset;
-        bs->cache = bs->cacheL2[bs->nextL2Line++];
-        return DRFLAC_TRUE;
-    } else {
-        /* If we get into this branch it means we weren't able to load any L1-aligned data. */
-        bs->nextL2Line = DRFLAC_CACHE_L2_LINE_COUNT(bs);
-        return DRFLAC_FALSE;
-    }
-}
-
-static drflac_bool32 drflac__reload_cache(drflac_bs* bs)
-{
-    size_t bytesRead;
-
-#ifndef DR_FLAC_NO_CRC
-    drflac__update_crc16(bs);
-#endif
-
-    /* Fast path. Try just moving the next value in the L2 cache to the L1 cache. */
-    if (drflac__reload_l1_cache_from_l2(bs)) {
-        bs->cache = drflac__be2host__cache_line(bs->cache);
-        bs->consumedBits = 0;
-#ifndef DR_FLAC_NO_CRC
-        bs->crc16Cache = bs->cache;
-#endif
-        return DRFLAC_TRUE;
-    }
-
-    /* Slow path. */
-
-    /*
-    If we get here it means we have failed to load the L1 cache from the L2. Likely we've just reached the end of the stream and the last
-    few bytes did not meet the alignment requirements for the L2 cache. In this case we need to fall back to a slower path and read the
-    data from the unaligned cache.
-    */
-    bytesRead = bs->unalignedByteCount;
-    if (bytesRead == 0) {
-        bs->consumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs);   /* <-- The stream has been exhausted, so marked the bits as consumed. */
-        return DRFLAC_FALSE;
-    }
-
-    DRFLAC_ASSERT(bytesRead < DRFLAC_CACHE_L1_SIZE_BYTES(bs));
-    bs->consumedBits = (drflac_uint32)(DRFLAC_CACHE_L1_SIZE_BYTES(bs) - bytesRead) * 8;
-
-    bs->cache = drflac__be2host__cache_line(bs->unalignedCache);
-    bs->cache &= DRFLAC_CACHE_L1_SELECTION_MASK(DRFLAC_CACHE_L1_BITS_REMAINING(bs));    /* <-- Make sure the consumed bits are always set to zero. Other parts of the library depend on this property. */
-    bs->unalignedByteCount = 0;     /* <-- At this point the unaligned bytes have been moved into the cache and we thus have no more unaligned bytes. */
-
-#ifndef DR_FLAC_NO_CRC
-    bs->crc16Cache = bs->cache >> bs->consumedBits;
-    bs->crc16CacheIgnoredBytes = bs->consumedBits >> 3;
-#endif
-    return DRFLAC_TRUE;
-}
-
-static void drflac__reset_cache(drflac_bs* bs)
-{
-    bs->nextL2Line   = DRFLAC_CACHE_L2_LINE_COUNT(bs);  /* <-- This clears the L2 cache. */
-    bs->consumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs);   /* <-- This clears the L1 cache. */
-    bs->cache = 0;
-    bs->unalignedByteCount = 0;                         /* <-- This clears the trailing unaligned bytes. */
-    bs->unalignedCache = 0;
-
-#ifndef DR_FLAC_NO_CRC
-    bs->crc16Cache = 0;
-    bs->crc16CacheIgnoredBytes = 0;
-#endif
-}
-
-
-static DRFLAC_INLINE drflac_bool32 drflac__read_uint32(drflac_bs* bs, unsigned int bitCount, drflac_uint32* pResultOut)
-{
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResultOut != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 32);
-
-    if (bs->consumedBits == DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
-        if (!drflac__reload_cache(bs)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    if (bitCount <= DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
-        /*
-        If we want to load all 32-bits from a 32-bit cache we need to do it slightly differently because we can't do
-        a 32-bit shift on a 32-bit integer. This will never be the case on 64-bit caches, so we can have a slightly
-        more optimal solution for this.
-        */
-#ifdef DRFLAC_64BIT
-        *pResultOut = (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCount);
-        bs->consumedBits += bitCount;
-        bs->cache <<= bitCount;
-#else
-        if (bitCount < DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
-            *pResultOut = (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCount);
-            bs->consumedBits += bitCount;
-            bs->cache <<= bitCount;
-        } else {
-            /* Cannot shift by 32-bits, so need to do it differently. */
-            *pResultOut = (drflac_uint32)bs->cache;
-            bs->consumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs);
-            bs->cache = 0;
-        }
-#endif
-
-        return DRFLAC_TRUE;
-    } else {
-        /* It straddles the cached data. It will never cover more than the next chunk. We just read the number in two parts and combine them. */
-        drflac_uint32 bitCountHi = DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        drflac_uint32 bitCountLo = bitCount - bitCountHi;
-        drflac_uint32 resultHi;
-
-        DRFLAC_ASSERT(bitCountHi > 0);
-        DRFLAC_ASSERT(bitCountHi < 32);
-        resultHi = (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCountHi);
-
-        if (!drflac__reload_cache(bs)) {
-            return DRFLAC_FALSE;
-        }
-
-        *pResultOut = (resultHi << bitCountLo) | (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCountLo);
-        bs->consumedBits += bitCountLo;
-        bs->cache <<= bitCountLo;
-        return DRFLAC_TRUE;
-    }
-}
-
-static drflac_bool32 drflac__read_int32(drflac_bs* bs, unsigned int bitCount, drflac_int32* pResult)
-{
-    drflac_uint32 result;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 32);
-
-    if (!drflac__read_uint32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Do not attempt to shift by 32 as it's undefined. */
-    if (bitCount < 32) {
-        drflac_uint32 signbit;
-        signbit = ((result >> (bitCount-1)) & 0x01);
-        result |= (~signbit + 1) << bitCount;
-    }
-
-    *pResult = (drflac_int32)result;
-    return DRFLAC_TRUE;
-}
-
-#ifdef DRFLAC_64BIT
-static drflac_bool32 drflac__read_uint64(drflac_bs* bs, unsigned int bitCount, drflac_uint64* pResultOut)
-{
-    drflac_uint32 resultHi;
-    drflac_uint32 resultLo;
-
-    DRFLAC_ASSERT(bitCount <= 64);
-    DRFLAC_ASSERT(bitCount >  32);
-
-    if (!drflac__read_uint32(bs, bitCount - 32, &resultHi)) {
-        return DRFLAC_FALSE;
-    }
-
-    if (!drflac__read_uint32(bs, 32, &resultLo)) {
-        return DRFLAC_FALSE;
-    }
-
-    *pResultOut = (((drflac_uint64)resultHi) << 32) | ((drflac_uint64)resultLo);
-    return DRFLAC_TRUE;
-}
-#endif
-
-/* Function below is unused, but leaving it here in case I need to quickly add it again. */
-#if 0
-static drflac_bool32 drflac__read_int64(drflac_bs* bs, unsigned int bitCount, drflac_int64* pResultOut)
-{
-    drflac_uint64 result;
-    drflac_uint64 signbit;
-
-    DRFLAC_ASSERT(bitCount <= 64);
-
-    if (!drflac__read_uint64(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-
-    signbit = ((result >> (bitCount-1)) & 0x01);
-    result |= (~signbit + 1) << bitCount;
-
-    *pResultOut = (drflac_int64)result;
-    return DRFLAC_TRUE;
-}
-#endif
-
-static drflac_bool32 drflac__read_uint16(drflac_bs* bs, unsigned int bitCount, drflac_uint16* pResult)
-{
-    drflac_uint32 result;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 16);
-
-    if (!drflac__read_uint32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-
-    *pResult = (drflac_uint16)result;
-    return DRFLAC_TRUE;
-}
-
-#if 0
-static drflac_bool32 drflac__read_int16(drflac_bs* bs, unsigned int bitCount, drflac_int16* pResult)
-{
-    drflac_int32 result;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 16);
-
-    if (!drflac__read_int32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-
-    *pResult = (drflac_int16)result;
-    return DRFLAC_TRUE;
-}
-#endif
-
-static drflac_bool32 drflac__read_uint8(drflac_bs* bs, unsigned int bitCount, drflac_uint8* pResult)
-{
-    drflac_uint32 result;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 8);
-
-    if (!drflac__read_uint32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-
-    *pResult = (drflac_uint8)result;
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__read_int8(drflac_bs* bs, unsigned int bitCount, drflac_int8* pResult)
-{
-    drflac_int32 result;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 8);
-
-    if (!drflac__read_int32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-
-    *pResult = (drflac_int8)result;
-    return DRFLAC_TRUE;
-}
-
-
-static drflac_bool32 drflac__seek_bits(drflac_bs* bs, size_t bitsToSeek)
-{
-    if (bitsToSeek <= DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
-        bs->consumedBits += (drflac_uint32)bitsToSeek;
-        bs->cache <<= bitsToSeek;
-        return DRFLAC_TRUE;
-    } else {
-        /* It straddles the cached data. This function isn't called too frequently so I'm favouring simplicity here. */
-        bitsToSeek       -= DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        bs->consumedBits += DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        bs->cache         = 0;
-
-        /* Simple case. Seek in groups of the same number as bits that fit within a cache line. */
-#ifdef DRFLAC_64BIT
-        while (bitsToSeek >= DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
-            drflac_uint64 bin;
-            if (!drflac__read_uint64(bs, DRFLAC_CACHE_L1_SIZE_BITS(bs), &bin)) {
-                return DRFLAC_FALSE;
-            }
-            bitsToSeek -= DRFLAC_CACHE_L1_SIZE_BITS(bs);
-        }
-#else
-        while (bitsToSeek >= DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
-            drflac_uint32 bin;
-            if (!drflac__read_uint32(bs, DRFLAC_CACHE_L1_SIZE_BITS(bs), &bin)) {
-                return DRFLAC_FALSE;
-            }
-            bitsToSeek -= DRFLAC_CACHE_L1_SIZE_BITS(bs);
-        }
-#endif
-
-        /* Whole leftover bytes. */
-        while (bitsToSeek >= 8) {
-            drflac_uint8 bin;
-            if (!drflac__read_uint8(bs, 8, &bin)) {
-                return DRFLAC_FALSE;
-            }
-            bitsToSeek -= 8;
-        }
-
-        /* Leftover bits. */
-        if (bitsToSeek > 0) {
-            drflac_uint8 bin;
-            if (!drflac__read_uint8(bs, (drflac_uint32)bitsToSeek, &bin)) {
-                return DRFLAC_FALSE;
-            }
-            bitsToSeek = 0; /* <-- Necessary for the assert below. */
-        }
-
-        DRFLAC_ASSERT(bitsToSeek == 0);
-        return DRFLAC_TRUE;
-    }
-}
-
-
-/* This function moves the bit streamer to the first bit after the sync code (bit 15 of the of the frame header). It will also update the CRC-16. */
-static drflac_bool32 drflac__find_and_seek_to_next_sync_code(drflac_bs* bs)
-{
-    DRFLAC_ASSERT(bs != NULL);
-
-    /*
-    The sync code is always aligned to 8 bits. This is convenient for us because it means we can do byte-aligned movements. The first
-    thing to do is align to the next byte.
-    */
-    if (!drflac__seek_bits(bs, DRFLAC_CACHE_L1_BITS_REMAINING(bs) & 7)) {
-        return DRFLAC_FALSE;
-    }
-
-    for (;;) {
-        drflac_uint8 hi;
-
-#ifndef DR_FLAC_NO_CRC
-        drflac__reset_crc16(bs);
-#endif
-
-        if (!drflac__read_uint8(bs, 8, &hi)) {
-            return DRFLAC_FALSE;
-        }
-
-        if (hi == 0xFF) {
-            drflac_uint8 lo;
-            if (!drflac__read_uint8(bs, 6, &lo)) {
-                return DRFLAC_FALSE;
-            }
-
-            if (lo == 0x3E) {
-                return DRFLAC_TRUE;
-            } else {
-                if (!drflac__seek_bits(bs, DRFLAC_CACHE_L1_BITS_REMAINING(bs) & 7)) {
-                    return DRFLAC_FALSE;
-                }
-            }
-        }
-    }
-
-    /* Should never get here. */
-    /*return DRFLAC_FALSE;*/
-}
-
-
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC)
-#define DRFLAC_IMPLEMENT_CLZ_LZCNT
-#endif
-#if  defined(_MSC_VER) && _MSC_VER >= 1400 && (defined(DRFLAC_X64) || defined(DRFLAC_X86)) && !defined(__clang__)
-#define DRFLAC_IMPLEMENT_CLZ_MSVC
-#endif
-
-static DRFLAC_INLINE drflac_uint32 drflac__clz_software(drflac_cache_t x)
-{
-    drflac_uint32 n;
-    static drflac_uint32 clz_table_4[] = {
-        0,
-        4,
-        3, 3,
-        2, 2, 2, 2,
-        1, 1, 1, 1, 1, 1, 1, 1
-    };
-
-    if (x == 0) {
-        return sizeof(x)*8;
-    }
-
-    n = clz_table_4[x >> (sizeof(x)*8 - 4)];
-    if (n == 0) {
-#ifdef DRFLAC_64BIT
-        if ((x & ((drflac_uint64)0xFFFFFFFF << 32)) == 0) { n  = 32; x <<= 32; }
-        if ((x & ((drflac_uint64)0xFFFF0000 << 32)) == 0) { n += 16; x <<= 16; }
-        if ((x & ((drflac_uint64)0xFF000000 << 32)) == 0) { n += 8;  x <<= 8;  }
-        if ((x & ((drflac_uint64)0xF0000000 << 32)) == 0) { n += 4;  x <<= 4;  }
-#else
-        if ((x & 0xFFFF0000) == 0) { n  = 16; x <<= 16; }
-        if ((x & 0xFF000000) == 0) { n += 8;  x <<= 8;  }
-        if ((x & 0xF0000000) == 0) { n += 4;  x <<= 4;  }
-#endif
-        n += clz_table_4[x >> (sizeof(x)*8 - 4)];
-    }
-
-    return n - 1;
-}
-
-#ifdef DRFLAC_IMPLEMENT_CLZ_LZCNT
-static DRFLAC_INLINE drflac_bool32 drflac__is_lzcnt_supported(void)
-{
-    /* Fast compile time check for ARM. */
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC) && defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5)
-    return DRFLAC_TRUE;
-#else
-    /* If the compiler itself does not support the intrinsic then we'll need to return false. */
-    #ifdef DRFLAC_HAS_LZCNT_INTRINSIC
-        return drflac__gIsLZCNTSupported;
-    #else
-        return DRFLAC_FALSE;
-    #endif
-#endif
-}
-
-static DRFLAC_INLINE drflac_uint32 drflac__clz_lzcnt(drflac_cache_t x)
-{
-    /*
-    It's critical for competitive decoding performance that this function be highly optimal. With MSVC we can use the __lzcnt64() and __lzcnt() intrinsics
-    to achieve good performance, however on GCC and Clang it's a little bit more annoying. The __builtin_clzl() and __builtin_clzll() intrinsics leave
-    it undefined as to the return value when `x` is 0. We need this to be well defined as returning 32 or 64, depending on whether or not it's a 32- or
-    64-bit build. To work around this we would need to add a conditional to check for the x = 0 case, but this creates unnecessary inefficiency. To work
-    around this problem I have written some inline assembly to emit the LZCNT (x86) or CLZ (ARM) instruction directly which removes the need to include
-    the conditional. This has worked well in the past, but for some reason Clang's MSVC compatible driver, clang-cl, does not seem to be handling this
-    in the same way as the normal Clang driver. It seems that `clang-cl` is just outputting the wrong results sometimes, maybe due to some register
-    getting clobbered?
-
-    I'm not sure if this is a bug with dr_flac's inlined assembly (most likely), a bug in `clang-cl` or just a misunderstanding on my part with inline
-    assembly rules for `clang-cl`. If somebody can identify an error in dr_flac's inlined assembly I'm happy to get that fixed.
-
-    Fortunately there is an easy workaround for this. Clang implements MSVC-specific intrinsics for compatibility. It also defines _MSC_VER for extra
-    compatibility. We can therefore just check for _MSC_VER and use the MSVC intrinsic which, fortunately for us, Clang supports. It would still be nice
-    to know how to fix the inlined assembly for correctness sake, however.
-    */
-
-#if defined(_MSC_VER) /*&& !defined(__clang__)*/    /* <-- Intentionally wanting Clang to use the MSVC __lzcnt64/__lzcnt intrinsics due to above ^. */
-    #ifdef DRFLAC_64BIT
-        return (drflac_uint32)__lzcnt64(x);
-    #else
-        return (drflac_uint32)__lzcnt(x);
-    #endif
-#else
-    #if defined(__GNUC__) || defined(__clang__)
-        #if defined(DRFLAC_X64)
-            {
-                drflac_uint64 r;
-                __asm__ __volatile__ (
-                    "lzcnt{ %1, %0| %0, %1}" : "=r"(r) : "r"(x) : "cc"
-                );
-
-                return (drflac_uint32)r;
-            }
-        #elif defined(DRFLAC_X86)
-            {
-                drflac_uint32 r;
-                __asm__ __volatile__ (
-                    "lzcnt{l %1, %0| %0, %1}" : "=r"(r) : "r"(x) : "cc"
-                );
-
-                return r;
-            }
-        #elif defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5) && !defined(DRFLAC_64BIT)   /* <-- I haven't tested 64-bit inline assembly, so only enabling this for the 32-bit build for now. */
-            {
-                unsigned int r;
-                __asm__ __volatile__ (
-                #if defined(DRFLAC_64BIT)
-                    "clz %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(x)   /* <-- This is untested. If someone in the community could test this, that would be appreciated! */
-                #else
-                    "clz %[out], %[in]" : [out]"=r"(r) : [in]"r"(x)
-                #endif
-                );
-
-                return r;
-            }
-        #else
-            if (x == 0) {
-                return sizeof(x)*8;
-            }
-            #ifdef DRFLAC_64BIT
-                return (drflac_uint32)__builtin_clzll((drflac_uint64)x);
-            #else
-                return (drflac_uint32)__builtin_clzl((drflac_uint32)x);
-            #endif
-        #endif
-    #else
-        /* Unsupported compiler. */
-        #error "This compiler does not support the lzcnt intrinsic."
-    #endif
-#endif
-}
-#endif
-
-#ifdef DRFLAC_IMPLEMENT_CLZ_MSVC
-#include <intrin.h> /* For BitScanReverse(). */
-
-static DRFLAC_INLINE drflac_uint32 drflac__clz_msvc(drflac_cache_t x)
-{
-    drflac_uint32 n;
-
-    if (x == 0) {
-        return sizeof(x)*8;
-    }
-
-#ifdef DRFLAC_64BIT
-    _BitScanReverse64((unsigned long*)&n, x);
-#else
-    _BitScanReverse((unsigned long*)&n, x);
-#endif
-    return sizeof(x)*8 - n - 1;
-}
-#endif
-
-static DRFLAC_INLINE drflac_uint32 drflac__clz(drflac_cache_t x)
-{
-#ifdef DRFLAC_IMPLEMENT_CLZ_LZCNT
-    if (drflac__is_lzcnt_supported()) {
-        return drflac__clz_lzcnt(x);
-    } else
-#endif
-    {
-#ifdef DRFLAC_IMPLEMENT_CLZ_MSVC
-        return drflac__clz_msvc(x);
-#else
-        return drflac__clz_software(x);
-#endif
-    }
-}
-
-
-static DRFLAC_INLINE drflac_bool32 drflac__seek_past_next_set_bit(drflac_bs* bs, unsigned int* pOffsetOut)
-{
-    drflac_uint32 zeroCounter = 0;
-    drflac_uint32 setBitOffsetPlus1;
-
-    while (bs->cache == 0) {
-        zeroCounter += (drflac_uint32)DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        if (!drflac__reload_cache(bs)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    setBitOffsetPlus1 = drflac__clz(bs->cache);
-    setBitOffsetPlus1 += 1;
-
-    bs->consumedBits += setBitOffsetPlus1;
-    bs->cache <<= setBitOffsetPlus1;
-
-    *pOffsetOut = zeroCounter + setBitOffsetPlus1 - 1;
-    return DRFLAC_TRUE;
-}
-
-
-
-static drflac_bool32 drflac__seek_to_byte(drflac_bs* bs, drflac_uint64 offsetFromStart)
-{
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(offsetFromStart > 0);
-
-    /*
-    Seeking from the start is not quite as trivial as it sounds because the onSeek callback takes a signed 32-bit integer (which
-    is intentional because it simplifies the implementation of the onSeek callbacks), however offsetFromStart is unsigned 64-bit.
-    To resolve we just need to do an initial seek from the start, and then a series of offset seeks to make up the remainder.
-    */
-    if (offsetFromStart > 0x7FFFFFFF) {
-        drflac_uint64 bytesRemaining = offsetFromStart;
-        if (!bs->onSeek(bs->pUserData, 0x7FFFFFFF, drflac_seek_origin_start)) {
-            return DRFLAC_FALSE;
-        }
-        bytesRemaining -= 0x7FFFFFFF;
-
-        while (bytesRemaining > 0x7FFFFFFF) {
-            if (!bs->onSeek(bs->pUserData, 0x7FFFFFFF, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-            bytesRemaining -= 0x7FFFFFFF;
-        }
-
-        if (bytesRemaining > 0) {
-            if (!bs->onSeek(bs->pUserData, (int)bytesRemaining, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-        }
-    } else {
-        if (!bs->onSeek(bs->pUserData, (int)offsetFromStart, drflac_seek_origin_start)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    /* The cache should be reset to force a reload of fresh data from the client. */
-    drflac__reset_cache(bs);
-    return DRFLAC_TRUE;
-}
-
-
-static drflac_result drflac__read_utf8_coded_number(drflac_bs* bs, drflac_uint64* pNumberOut, drflac_uint8* pCRCOut)
-{
-    drflac_uint8 crc;
-    drflac_uint64 result;
-    drflac_uint8 utf8[7] = {0};
-    int byteCount;
-    int i;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pNumberOut != NULL);
-    DRFLAC_ASSERT(pCRCOut != NULL);
-
-    crc = *pCRCOut;
-
-    if (!drflac__read_uint8(bs, 8, utf8)) {
-        *pNumberOut = 0;
-        return DRFLAC_AT_END;
-    }
-    crc = drflac_crc8(crc, utf8[0], 8);
-
-    if ((utf8[0] & 0x80) == 0) {
-        *pNumberOut = utf8[0];
-        *pCRCOut = crc;
-        return DRFLAC_SUCCESS;
-    }
-
-    /*byteCount = 1;*/
-    if ((utf8[0] & 0xE0) == 0xC0) {
-        byteCount = 2;
-    } else if ((utf8[0] & 0xF0) == 0xE0) {
-        byteCount = 3;
-    } else if ((utf8[0] & 0xF8) == 0xF0) {
-        byteCount = 4;
-    } else if ((utf8[0] & 0xFC) == 0xF8) {
-        byteCount = 5;
-    } else if ((utf8[0] & 0xFE) == 0xFC) {
-        byteCount = 6;
-    } else if ((utf8[0] & 0xFF) == 0xFE) {
-        byteCount = 7;
-    } else {
-        *pNumberOut = 0;
-        return DRFLAC_CRC_MISMATCH;     /* Bad UTF-8 encoding. */
-    }
-
-    /* Read extra bytes. */
-    DRFLAC_ASSERT(byteCount > 1);
-
-    result = (drflac_uint64)(utf8[0] & (0xFF >> (byteCount + 1)));
-    for (i = 1; i < byteCount; ++i) {
-        if (!drflac__read_uint8(bs, 8, utf8 + i)) {
-            *pNumberOut = 0;
-            return DRFLAC_AT_END;
-        }
-        crc = drflac_crc8(crc, utf8[i], 8);
-
-        result = (result << 6) | (utf8[i] & 0x3F);
-    }
-
-    *pNumberOut = result;
-    *pCRCOut = crc;
-    return DRFLAC_SUCCESS;
-}
-
-
-
-/*
-The next two functions are responsible for calculating the prediction.
-
-When the bits per sample is >16 we need to use 64-bit integer arithmetic because otherwise we'll run out of precision. It's
-safe to assume this will be slower on 32-bit platforms so we use a more optimal solution when the bits per sample is <=16.
-*/
-static DRFLAC_INLINE drflac_int32 drflac__calculate_prediction_32(drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
-{
-    drflac_int32 prediction = 0;
-
-    DRFLAC_ASSERT(order <= 32);
-
-    /* 32-bit version. */
-
-    /* VC++ optimizes this to a single jmp. I've not yet verified this for other compilers. */
-    switch (order)
-    {
-    case 32: prediction += coefficients[31] * pDecodedSamples[-32];
-    case 31: prediction += coefficients[30] * pDecodedSamples[-31];
-    case 30: prediction += coefficients[29] * pDecodedSamples[-30];
-    case 29: prediction += coefficients[28] * pDecodedSamples[-29];
-    case 28: prediction += coefficients[27] * pDecodedSamples[-28];
-    case 27: prediction += coefficients[26] * pDecodedSamples[-27];
-    case 26: prediction += coefficients[25] * pDecodedSamples[-26];
-    case 25: prediction += coefficients[24] * pDecodedSamples[-25];
-    case 24: prediction += coefficients[23] * pDecodedSamples[-24];
-    case 23: prediction += coefficients[22] * pDecodedSamples[-23];
-    case 22: prediction += coefficients[21] * pDecodedSamples[-22];
-    case 21: prediction += coefficients[20] * pDecodedSamples[-21];
-    case 20: prediction += coefficients[19] * pDecodedSamples[-20];
-    case 19: prediction += coefficients[18] * pDecodedSamples[-19];
-    case 18: prediction += coefficients[17] * pDecodedSamples[-18];
-    case 17: prediction += coefficients[16] * pDecodedSamples[-17];
-    case 16: prediction += coefficients[15] * pDecodedSamples[-16];
-    case 15: prediction += coefficients[14] * pDecodedSamples[-15];
-    case 14: prediction += coefficients[13] * pDecodedSamples[-14];
-    case 13: prediction += coefficients[12] * pDecodedSamples[-13];
-    case 12: prediction += coefficients[11] * pDecodedSamples[-12];
-    case 11: prediction += coefficients[10] * pDecodedSamples[-11];
-    case 10: prediction += coefficients[ 9] * pDecodedSamples[-10];
-    case  9: prediction += coefficients[ 8] * pDecodedSamples[- 9];
-    case  8: prediction += coefficients[ 7] * pDecodedSamples[- 8];
-    case  7: prediction += coefficients[ 6] * pDecodedSamples[- 7];
-    case  6: prediction += coefficients[ 5] * pDecodedSamples[- 6];
-    case  5: prediction += coefficients[ 4] * pDecodedSamples[- 5];
-    case  4: prediction += coefficients[ 3] * pDecodedSamples[- 4];
-    case  3: prediction += coefficients[ 2] * pDecodedSamples[- 3];
-    case  2: prediction += coefficients[ 1] * pDecodedSamples[- 2];
-    case  1: prediction += coefficients[ 0] * pDecodedSamples[- 1];
-    }
-
-    return (drflac_int32)(prediction >> shift);
-}
-
-static DRFLAC_INLINE drflac_int32 drflac__calculate_prediction_64(drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
-{
-    drflac_int64 prediction;
-
-    DRFLAC_ASSERT(order <= 32);
-
-    /* 64-bit version. */
-
-    /* This method is faster on the 32-bit build when compiling with VC++. See note below. */
-#ifndef DRFLAC_64BIT
-    if (order == 8)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5] * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6] * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7] * (drflac_int64)pDecodedSamples[-8];
-    }
-    else if (order == 7)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5] * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6] * (drflac_int64)pDecodedSamples[-7];
-    }
-    else if (order == 3)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-    }
-    else if (order == 6)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5] * (drflac_int64)pDecodedSamples[-6];
-    }
-    else if (order == 5)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
-    }
-    else if (order == 4)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-    }
-    else if (order == 12)
-    {
-        prediction  = coefficients[0]  * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1]  * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2]  * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3]  * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4]  * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5]  * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6]  * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7]  * (drflac_int64)pDecodedSamples[-8];
-        prediction += coefficients[8]  * (drflac_int64)pDecodedSamples[-9];
-        prediction += coefficients[9]  * (drflac_int64)pDecodedSamples[-10];
-        prediction += coefficients[10] * (drflac_int64)pDecodedSamples[-11];
-        prediction += coefficients[11] * (drflac_int64)pDecodedSamples[-12];
-    }
-    else if (order == 2)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-    }
-    else if (order == 1)
-    {
-        prediction = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-    }
-    else if (order == 10)
-    {
-        prediction  = coefficients[0]  * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1]  * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2]  * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3]  * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4]  * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5]  * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6]  * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7]  * (drflac_int64)pDecodedSamples[-8];
-        prediction += coefficients[8]  * (drflac_int64)pDecodedSamples[-9];
-        prediction += coefficients[9]  * (drflac_int64)pDecodedSamples[-10];
-    }
-    else if (order == 9)
-    {
-        prediction  = coefficients[0]  * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1]  * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2]  * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3]  * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4]  * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5]  * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6]  * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7]  * (drflac_int64)pDecodedSamples[-8];
-        prediction += coefficients[8]  * (drflac_int64)pDecodedSamples[-9];
-    }
-    else if (order == 11)
-    {
-        prediction  = coefficients[0]  * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1]  * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2]  * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3]  * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4]  * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5]  * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6]  * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7]  * (drflac_int64)pDecodedSamples[-8];
-        prediction += coefficients[8]  * (drflac_int64)pDecodedSamples[-9];
-        prediction += coefficients[9]  * (drflac_int64)pDecodedSamples[-10];
-        prediction += coefficients[10] * (drflac_int64)pDecodedSamples[-11];
-    }
-    else
-    {
-        int j;
-
-        prediction = 0;
-        for (j = 0; j < (int)order; ++j) {
-            prediction += coefficients[j] * (drflac_int64)pDecodedSamples[-j-1];
-        }
-    }
-#endif
-
-    /*
-    VC++ optimizes this to a single jmp instruction, but only the 64-bit build. The 32-bit build generates less efficient code for some
-    reason. The ugly version above is faster so we'll just switch between the two depending on the target platform.
-    */
-#ifdef DRFLAC_64BIT
-    prediction = 0;
-    switch (order)
-    {
-    case 32: prediction += coefficients[31] * (drflac_int64)pDecodedSamples[-32];
-    case 31: prediction += coefficients[30] * (drflac_int64)pDecodedSamples[-31];
-    case 30: prediction += coefficients[29] * (drflac_int64)pDecodedSamples[-30];
-    case 29: prediction += coefficients[28] * (drflac_int64)pDecodedSamples[-29];
-    case 28: prediction += coefficients[27] * (drflac_int64)pDecodedSamples[-28];
-    case 27: prediction += coefficients[26] * (drflac_int64)pDecodedSamples[-27];
-    case 26: prediction += coefficients[25] * (drflac_int64)pDecodedSamples[-26];
-    case 25: prediction += coefficients[24] * (drflac_int64)pDecodedSamples[-25];
-    case 24: prediction += coefficients[23] * (drflac_int64)pDecodedSamples[-24];
-    case 23: prediction += coefficients[22] * (drflac_int64)pDecodedSamples[-23];
-    case 22: prediction += coefficients[21] * (drflac_int64)pDecodedSamples[-22];
-    case 21: prediction += coefficients[20] * (drflac_int64)pDecodedSamples[-21];
-    case 20: prediction += coefficients[19] * (drflac_int64)pDecodedSamples[-20];
-    case 19: prediction += coefficients[18] * (drflac_int64)pDecodedSamples[-19];
-    case 18: prediction += coefficients[17] * (drflac_int64)pDecodedSamples[-18];
-    case 17: prediction += coefficients[16] * (drflac_int64)pDecodedSamples[-17];
-    case 16: prediction += coefficients[15] * (drflac_int64)pDecodedSamples[-16];
-    case 15: prediction += coefficients[14] * (drflac_int64)pDecodedSamples[-15];
-    case 14: prediction += coefficients[13] * (drflac_int64)pDecodedSamples[-14];
-    case 13: prediction += coefficients[12] * (drflac_int64)pDecodedSamples[-13];
-    case 12: prediction += coefficients[11] * (drflac_int64)pDecodedSamples[-12];
-    case 11: prediction += coefficients[10] * (drflac_int64)pDecodedSamples[-11];
-    case 10: prediction += coefficients[ 9] * (drflac_int64)pDecodedSamples[-10];
-    case  9: prediction += coefficients[ 8] * (drflac_int64)pDecodedSamples[- 9];
-    case  8: prediction += coefficients[ 7] * (drflac_int64)pDecodedSamples[- 8];
-    case  7: prediction += coefficients[ 6] * (drflac_int64)pDecodedSamples[- 7];
-    case  6: prediction += coefficients[ 5] * (drflac_int64)pDecodedSamples[- 6];
-    case  5: prediction += coefficients[ 4] * (drflac_int64)pDecodedSamples[- 5];
-    case  4: prediction += coefficients[ 3] * (drflac_int64)pDecodedSamples[- 4];
-    case  3: prediction += coefficients[ 2] * (drflac_int64)pDecodedSamples[- 3];
-    case  2: prediction += coefficients[ 1] * (drflac_int64)pDecodedSamples[- 2];
-    case  1: prediction += coefficients[ 0] * (drflac_int64)pDecodedSamples[- 1];
-    }
-#endif
-
-    return (drflac_int32)(prediction >> shift);
-}
-
-
-#if 0
-/*
-Reference implementation for reading and decoding samples with residual. This is intentionally left unoptimized for the
-sake of readability and should only be used as a reference.
-*/
-static drflac_bool32 drflac__decode_samples_with_residual__rice__reference(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    drflac_uint32 i;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(count > 0);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-
-    for (i = 0; i < count; ++i) {
-        drflac_uint32 zeroCounter = 0;
-        for (;;) {
-            drflac_uint8 bit;
-            if (!drflac__read_uint8(bs, 1, &bit)) {
-                return DRFLAC_FALSE;
-            }
-
-            if (bit == 0) {
-                zeroCounter += 1;
-            } else {
-                break;
-            }
-        }
-
-        drflac_uint32 decodedRice;
-        if (riceParam > 0) {
-            if (!drflac__read_uint32(bs, riceParam, &decodedRice)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            decodedRice = 0;
-        }
-
-        decodedRice |= (zeroCounter << riceParam);
-        if ((decodedRice & 0x01)) {
-            decodedRice = ~(decodedRice >> 1);
-        } else {
-            decodedRice =  (decodedRice >> 1);
-        }
-
-
-        if (bitsPerSample+shift >= 32) {
-            pSamplesOut[i] = decodedRice + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + i);
-        } else {
-            pSamplesOut[i] = decodedRice + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + i);
-        }
-    }
-
-    return DRFLAC_TRUE;
-}
-#endif
-
-#if 0
-static drflac_bool32 drflac__read_rice_parts__reference(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
-{
-    drflac_uint32 zeroCounter = 0;
-    drflac_uint32 decodedRice;
-
-    for (;;) {
-        drflac_uint8 bit;
-        if (!drflac__read_uint8(bs, 1, &bit)) {
-            return DRFLAC_FALSE;
-        }
-
-        if (bit == 0) {
-            zeroCounter += 1;
-        } else {
-            break;
-        }
-    }
-
-    if (riceParam > 0) {
-        if (!drflac__read_uint32(bs, riceParam, &decodedRice)) {
-            return DRFLAC_FALSE;
-        }
-    } else {
-        decodedRice = 0;
-    }
-
-    *pZeroCounterOut = zeroCounter;
-    *pRiceParamPartOut = decodedRice;
-    return DRFLAC_TRUE;
-}
-#endif
-
-#if 0
-static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
-{
-    drflac_cache_t riceParamMask;
-    drflac_uint32 zeroCounter;
-    drflac_uint32 setBitOffsetPlus1;
-    drflac_uint32 riceParamPart;
-    drflac_uint32 riceLength;
-
-    DRFLAC_ASSERT(riceParam > 0);   /* <-- riceParam should never be 0. drflac__read_rice_parts__param_equals_zero() should be used instead for this case. */
-
-    riceParamMask = DRFLAC_CACHE_L1_SELECTION_MASK(riceParam);
-
-    zeroCounter = 0;
-    while (bs->cache == 0) {
-        zeroCounter += (drflac_uint32)DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        if (!drflac__reload_cache(bs)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    setBitOffsetPlus1 = drflac__clz(bs->cache);
-    zeroCounter += setBitOffsetPlus1;
-    setBitOffsetPlus1 += 1;
-
-    riceLength = setBitOffsetPlus1 + riceParam;
-    if (riceLength < DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
-        riceParamPart = (drflac_uint32)((bs->cache & (riceParamMask >> setBitOffsetPlus1)) >> DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, riceLength));
-
-        bs->consumedBits += riceLength;
-        bs->cache <<= riceLength;
-    } else {
-        drflac_uint32 bitCountLo;
-        drflac_cache_t resultHi;
-
-        bs->consumedBits += riceLength;
-        bs->cache <<= setBitOffsetPlus1 & (DRFLAC_CACHE_L1_SIZE_BITS(bs)-1);    /* <-- Equivalent to "if (setBitOffsetPlus1 < DRFLAC_CACHE_L1_SIZE_BITS(bs)) { bs->cache <<= setBitOffsetPlus1; }" */
-
-        /* It straddles the cached data. It will never cover more than the next chunk. We just read the number in two parts and combine them. */
-        bitCountLo = bs->consumedBits - DRFLAC_CACHE_L1_SIZE_BITS(bs);
-        resultHi = DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, riceParam);  /* <-- Use DRFLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE() if ever this function allows riceParam=0. */
-
-        if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-#ifndef DR_FLAC_NO_CRC
-            drflac__update_crc16(bs);
-#endif
-            bs->cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-            bs->consumedBits = 0;
-#ifndef DR_FLAC_NO_CRC
-            bs->crc16Cache = bs->cache;
-#endif
-        } else {
-            /* Slow path. We need to fetch more data from the client. */
-            if (!drflac__reload_cache(bs)) {
-                return DRFLAC_FALSE;
-            }
-        }
-
-        riceParamPart = (drflac_uint32)(resultHi | DRFLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE(bs, bitCountLo));
-
-        bs->consumedBits += bitCountLo;
-        bs->cache <<= bitCountLo;
-    }
-
-    pZeroCounterOut[0] = zeroCounter;
-    pRiceParamPartOut[0] = riceParamPart;
-
-    return DRFLAC_TRUE;
-}
-#endif
-
-static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts_x1(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
-{
-    drflac_uint32  riceParamPlus1 = riceParam + 1;
-    /*drflac_cache_t riceParamPlus1Mask  = DRFLAC_CACHE_L1_SELECTION_MASK(riceParamPlus1);*/
-    drflac_uint32  riceParamPlus1Shift = DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, riceParamPlus1);
-    drflac_uint32  riceParamPlus1MaxConsumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs) - riceParamPlus1;
-
-    /*
-    The idea here is to use local variables for the cache in an attempt to encourage the compiler to store them in registers. I have
-    no idea how this will work in practice...
-    */
-    drflac_cache_t bs_cache = bs->cache;
-    drflac_uint32  bs_consumedBits = bs->consumedBits;
-
-    /* The first thing to do is find the first unset bit. Most likely a bit will be set in the current cache line. */
-    drflac_uint32  lzcount = drflac__clz(bs_cache);
-    if (lzcount < sizeof(bs_cache)*8) {
-        pZeroCounterOut[0] = lzcount;
-
-        /*
-        It is most likely that the riceParam part (which comes after the zero counter) is also on this cache line. When extracting
-        this, we include the set bit from the unary coded part because it simplifies cache management. This bit will be handled
-        outside of this function at a higher level.
-        */
-    extract_rice_param_part:
-        bs_cache       <<= lzcount;
-        bs_consumedBits += lzcount;
-
-        if (bs_consumedBits <= riceParamPlus1MaxConsumedBits) {
-            /* Getting here means the rice parameter part is wholly contained within the current cache line. */
-            pRiceParamPartOut[0] = (drflac_uint32)(bs_cache >> riceParamPlus1Shift);
-            bs_cache       <<= riceParamPlus1;
-            bs_consumedBits += riceParamPlus1;
-        } else {
-            drflac_uint32 riceParamPartHi;
-            drflac_uint32 riceParamPartLo;
-            drflac_uint32 riceParamPartLoBitCount;
-
-            /*
-            Getting here means the rice parameter part straddles the cache line. We need to read from the tail of the current cache
-            line, reload the cache, and then combine it with the head of the next cache line.
-            */
-
-            /* Grab the high part of the rice parameter part. */
-            riceParamPartHi = (drflac_uint32)(bs_cache >> riceParamPlus1Shift);
-
-            /* Before reloading the cache we need to grab the size in bits of the low part. */
-            riceParamPartLoBitCount = bs_consumedBits - riceParamPlus1MaxConsumedBits;
-            DRFLAC_ASSERT(riceParamPartLoBitCount > 0 && riceParamPartLoBitCount < 32);
-
-            /* Now reload the cache. */
-            if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-            #ifndef DR_FLAC_NO_CRC
-                drflac__update_crc16(bs);
-            #endif
-                bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-                bs_consumedBits = riceParamPartLoBitCount;
-            #ifndef DR_FLAC_NO_CRC
-                bs->crc16Cache = bs_cache;
-            #endif
-            } else {
-                /* Slow path. We need to fetch more data from the client. */
-                if (!drflac__reload_cache(bs)) {
-                    return DRFLAC_FALSE;
-                }
-
-                bs_cache = bs->cache;
-                bs_consumedBits = bs->consumedBits + riceParamPartLoBitCount;
-            }
-
-            /* We should now have enough information to construct the rice parameter part. */
-            riceParamPartLo = (drflac_uint32)(bs_cache >> (DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, riceParamPartLoBitCount)));
-            pRiceParamPartOut[0] = riceParamPartHi | riceParamPartLo;
-
-            bs_cache <<= riceParamPartLoBitCount;
-        }
-    } else {
-        /*
-        Getting here means there are no bits set on the cache line. This is a less optimal case because we just wasted a call
-        to drflac__clz() and we need to reload the cache.
-        */
-        drflac_uint32 zeroCounter = (drflac_uint32)(DRFLAC_CACHE_L1_SIZE_BITS(bs) - bs_consumedBits);
-        for (;;) {
-            if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-            #ifndef DR_FLAC_NO_CRC
-                drflac__update_crc16(bs);
-            #endif
-                bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-                bs_consumedBits = 0;
-            #ifndef DR_FLAC_NO_CRC
-                bs->crc16Cache = bs_cache;
-            #endif
-            } else {
-                /* Slow path. We need to fetch more data from the client. */
-                if (!drflac__reload_cache(bs)) {
-                    return DRFLAC_FALSE;
-                }
-
-                bs_cache = bs->cache;
-                bs_consumedBits = bs->consumedBits;
-            }
-
-            lzcount = drflac__clz(bs_cache);
-            zeroCounter += lzcount;
-
-            if (lzcount < sizeof(bs_cache)*8) {
-                break;
-            }
-        }
-
-        pZeroCounterOut[0] = zeroCounter;
-        goto extract_rice_param_part;
-    }
-
-    /* Make sure the cache is restored at the end of it all. */
-    bs->cache = bs_cache;
-    bs->consumedBits = bs_consumedBits;
-
-    return DRFLAC_TRUE;
-}
-
-static DRFLAC_INLINE drflac_bool32 drflac__seek_rice_parts(drflac_bs* bs, drflac_uint8 riceParam)
-{
-    drflac_uint32  riceParamPlus1 = riceParam + 1;
-    drflac_uint32  riceParamPlus1MaxConsumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs) - riceParamPlus1;
-
-    /*
-    The idea here is to use local variables for the cache in an attempt to encourage the compiler to store them in registers. I have
-    no idea how this will work in practice...
-    */
-    drflac_cache_t bs_cache = bs->cache;
-    drflac_uint32  bs_consumedBits = bs->consumedBits;
-
-    /* The first thing to do is find the first unset bit. Most likely a bit will be set in the current cache line. */
-    drflac_uint32  lzcount = drflac__clz(bs_cache);
-    if (lzcount < sizeof(bs_cache)*8) {
-        /*
-        It is most likely that the riceParam part (which comes after the zero counter) is also on this cache line. When extracting
-        this, we include the set bit from the unary coded part because it simplifies cache management. This bit will be handled
-        outside of this function at a higher level.
-        */
-    extract_rice_param_part:
-        bs_cache       <<= lzcount;
-        bs_consumedBits += lzcount;
-
-        if (bs_consumedBits <= riceParamPlus1MaxConsumedBits) {
-            /* Getting here means the rice parameter part is wholly contained within the current cache line. */
-            bs_cache       <<= riceParamPlus1;
-            bs_consumedBits += riceParamPlus1;
-        } else {
-            /*
-            Getting here means the rice parameter part straddles the cache line. We need to read from the tail of the current cache
-            line, reload the cache, and then combine it with the head of the next cache line.
-            */
-
-            /* Before reloading the cache we need to grab the size in bits of the low part. */
-            drflac_uint32 riceParamPartLoBitCount = bs_consumedBits - riceParamPlus1MaxConsumedBits;
-            DRFLAC_ASSERT(riceParamPartLoBitCount > 0 && riceParamPartLoBitCount < 32);
-
-            /* Now reload the cache. */
-            if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-            #ifndef DR_FLAC_NO_CRC
-                drflac__update_crc16(bs);
-            #endif
-                bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-                bs_consumedBits = riceParamPartLoBitCount;
-            #ifndef DR_FLAC_NO_CRC
-                bs->crc16Cache = bs_cache;
-            #endif
-            } else {
-                /* Slow path. We need to fetch more data from the client. */
-                if (!drflac__reload_cache(bs)) {
-                    return DRFLAC_FALSE;
-                }
-
-                bs_cache = bs->cache;
-                bs_consumedBits = bs->consumedBits + riceParamPartLoBitCount;
-            }
-
-            bs_cache <<= riceParamPartLoBitCount;
-        }
-    } else {
-        /*
-        Getting here means there are no bits set on the cache line. This is a less optimal case because we just wasted a call
-        to drflac__clz() and we need to reload the cache.
-        */
-        for (;;) {
-            if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-            #ifndef DR_FLAC_NO_CRC
-                drflac__update_crc16(bs);
-            #endif
-                bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-                bs_consumedBits = 0;
-            #ifndef DR_FLAC_NO_CRC
-                bs->crc16Cache = bs_cache;
-            #endif
-            } else {
-                /* Slow path. We need to fetch more data from the client. */
-                if (!drflac__reload_cache(bs)) {
-                    return DRFLAC_FALSE;
-                }
-
-                bs_cache = bs->cache;
-                bs_consumedBits = bs->consumedBits;
-            }
-
-            lzcount = drflac__clz(bs_cache);
-            if (lzcount < sizeof(bs_cache)*8) {
-                break;
-            }
-        }
-
-        goto extract_rice_param_part;
-    }
-
-    /* Make sure the cache is restored at the end of it all. */
-    bs->cache = bs_cache;
-    bs->consumedBits = bs_consumedBits;
-
-    return DRFLAC_TRUE;
-}
-
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar_zeroorder(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-    drflac_uint32 zeroCountPart0;
-    drflac_uint32 riceParamPart0;
-    drflac_uint32 riceParamMask;
-    drflac_uint32 i;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(count > 0);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-
-    (void)bitsPerSample;
-    (void)order;
-    (void)shift;
-    (void)coefficients;
-
-    riceParamMask  = (drflac_uint32)~((~0UL) << riceParam);
-
-    i = 0;
-    while (i < count) {
-        /* Rice extraction. */
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0)) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Rice reconstruction. */
-        riceParamPart0 &= riceParamMask;
-        riceParamPart0 |= (zeroCountPart0 << riceParam);
-        riceParamPart0  = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
-
-        pSamplesOut[i] = riceParamPart0;
-
-        i += 1;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-    drflac_uint32 zeroCountPart0 = 0;
-    drflac_uint32 zeroCountPart1 = 0;
-    drflac_uint32 zeroCountPart2 = 0;
-    drflac_uint32 zeroCountPart3 = 0;
-    drflac_uint32 riceParamPart0 = 0;
-    drflac_uint32 riceParamPart1 = 0;
-    drflac_uint32 riceParamPart2 = 0;
-    drflac_uint32 riceParamPart3 = 0;
-    drflac_uint32 riceParamMask;
-    const drflac_int32* pSamplesOutEnd;
-    drflac_uint32 i;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(count > 0);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-
-    if (order == 0) {
-        return drflac__decode_samples_with_residual__rice__scalar_zeroorder(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    }
-
-    riceParamMask  = (drflac_uint32)~((~0UL) << riceParam);
-    pSamplesOutEnd = pSamplesOut + (count & ~3);
-
-    if (bitsPerSample+shift > 32) {
-        while (pSamplesOut < pSamplesOutEnd) {
-            /*
-            Rice extraction. It's faster to do this one at a time against local variables than it is to use the x4 version
-            against an array. Not sure why, but perhaps it's making more efficient use of registers?
-            */
-            if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart1, &riceParamPart1) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart2, &riceParamPart2) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart3, &riceParamPart3)) {
-                return DRFLAC_FALSE;
-            }
-
-            riceParamPart0 &= riceParamMask;
-            riceParamPart1 &= riceParamMask;
-            riceParamPart2 &= riceParamMask;
-            riceParamPart3 &= riceParamMask;
-
-            riceParamPart0 |= (zeroCountPart0 << riceParam);
-            riceParamPart1 |= (zeroCountPart1 << riceParam);
-            riceParamPart2 |= (zeroCountPart2 << riceParam);
-            riceParamPart3 |= (zeroCountPart3 << riceParam);
-
-            riceParamPart0  = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
-            riceParamPart1  = (riceParamPart1 >> 1) ^ t[riceParamPart1 & 0x01];
-            riceParamPart2  = (riceParamPart2 >> 1) ^ t[riceParamPart2 & 0x01];
-            riceParamPart3  = (riceParamPart3 >> 1) ^ t[riceParamPart3 & 0x01];
-
-            pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 0);
-            pSamplesOut[1] = riceParamPart1 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 1);
-            pSamplesOut[2] = riceParamPart2 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 2);
-            pSamplesOut[3] = riceParamPart3 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 3);
-
-            pSamplesOut += 4;
-        }
-    } else {
-        while (pSamplesOut < pSamplesOutEnd) {
-            if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart1, &riceParamPart1) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart2, &riceParamPart2) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart3, &riceParamPart3)) {
-                return DRFLAC_FALSE;
-            }
-
-            riceParamPart0 &= riceParamMask;
-            riceParamPart1 &= riceParamMask;
-            riceParamPart2 &= riceParamMask;
-            riceParamPart3 &= riceParamMask;
-
-            riceParamPart0 |= (zeroCountPart0 << riceParam);
-            riceParamPart1 |= (zeroCountPart1 << riceParam);
-            riceParamPart2 |= (zeroCountPart2 << riceParam);
-            riceParamPart3 |= (zeroCountPart3 << riceParam);
-
-            riceParamPart0  = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
-            riceParamPart1  = (riceParamPart1 >> 1) ^ t[riceParamPart1 & 0x01];
-            riceParamPart2  = (riceParamPart2 >> 1) ^ t[riceParamPart2 & 0x01];
-            riceParamPart3  = (riceParamPart3 >> 1) ^ t[riceParamPart3 & 0x01];
-
-            pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 0);
-            pSamplesOut[1] = riceParamPart1 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 1);
-            pSamplesOut[2] = riceParamPart2 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 2);
-            pSamplesOut[3] = riceParamPart3 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 3);
-
-            pSamplesOut += 4;
-        }
-    }
-
-    i = (count & ~3);
-    while (i < count) {
-        /* Rice extraction. */
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0)) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Rice reconstruction. */
-        riceParamPart0 &= riceParamMask;
-        riceParamPart0 |= (zeroCountPart0 << riceParam);
-        riceParamPart0  = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
-        /*riceParamPart0  = (riceParamPart0 >> 1) ^ (~(riceParamPart0 & 0x01) + 1);*/
-
-        /* Sample reconstruction. */
-        if (bitsPerSample+shift > 32) {
-            pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 0);
-        } else {
-            pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 0);
-        }
-
-        i += 1;
-        pSamplesOut += 1;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE __m128i drflac__mm_packs_interleaved_epi32(__m128i a, __m128i b)
-{
-    __m128i r;
-
-    /* Pack. */
-    r = _mm_packs_epi32(a, b);
-
-    /* a3a2 a1a0 b3b2 b1b0 -> a3a2 b3b2 a1a0 b1b0 */
-    r = _mm_shuffle_epi32(r, _MM_SHUFFLE(3, 1, 2, 0));
-
-    /* a3a2 b3b2 a1a0 b1b0 -> a3b3 a2b2 a1b1 a0b0 */
-    r = _mm_shufflehi_epi16(r, _MM_SHUFFLE(3, 1, 2, 0));
-    r = _mm_shufflelo_epi16(r, _MM_SHUFFLE(3, 1, 2, 0));
-
-    return r;
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_SSE41)
-static DRFLAC_INLINE __m128i drflac__mm_not_si128(__m128i a)
-{
-    return _mm_xor_si128(a, _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128()));
-}
-
-static DRFLAC_INLINE __m128i drflac__mm_hadd_epi32(__m128i x)
-{
-    __m128i x64 = _mm_add_epi32(x, _mm_shuffle_epi32(x, _MM_SHUFFLE(1, 0, 3, 2)));
-    __m128i x32 = _mm_shufflelo_epi16(x64, _MM_SHUFFLE(1, 0, 3, 2));
-    return _mm_add_epi32(x64, x32);
-}
-
-static DRFLAC_INLINE __m128i drflac__mm_hadd_epi64(__m128i x)
-{
-    return _mm_add_epi64(x, _mm_shuffle_epi32(x, _MM_SHUFFLE(1, 0, 3, 2)));
-}
-
-static DRFLAC_INLINE __m128i drflac__mm_srai_epi64(__m128i x, int count)
-{
-    /*
-    To simplify this we are assuming count < 32. This restriction allows us to work on a low side and a high side. The low side
-    is shifted with zero bits, whereas the right side is shifted with sign bits.
-    */
-    __m128i lo = _mm_srli_epi64(x, count);
-    __m128i hi = _mm_srai_epi32(x, count);
-
-    hi = _mm_and_si128(hi, _mm_set_epi32(0xFFFFFFFF, 0, 0xFFFFFFFF, 0));    /* The high part needs to have the low part cleared. */
-
-    return _mm_or_si128(lo, hi);
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41_32(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    int i;
-    drflac_uint32 riceParamMask;
-    drflac_int32* pDecodedSamples    = pSamplesOut;
-    drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
-    drflac_uint32 zeroCountParts0 = 0;
-    drflac_uint32 zeroCountParts1 = 0;
-    drflac_uint32 zeroCountParts2 = 0;
-    drflac_uint32 zeroCountParts3 = 0;
-    drflac_uint32 riceParamParts0 = 0;
-    drflac_uint32 riceParamParts1 = 0;
-    drflac_uint32 riceParamParts2 = 0;
-    drflac_uint32 riceParamParts3 = 0;
-    __m128i coefficients128_0;
-    __m128i coefficients128_4;
-    __m128i coefficients128_8;
-    __m128i samples128_0;
-    __m128i samples128_4;
-    __m128i samples128_8;
-    __m128i riceParamMask128;
-
-    const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-
-    riceParamMask    = (drflac_uint32)~((~0UL) << riceParam);
-    riceParamMask128 = _mm_set1_epi32(riceParamMask);
-
-    /* Pre-load. */
-    coefficients128_0 = _mm_setzero_si128();
-    coefficients128_4 = _mm_setzero_si128();
-    coefficients128_8 = _mm_setzero_si128();
-
-    samples128_0 = _mm_setzero_si128();
-    samples128_4 = _mm_setzero_si128();
-    samples128_8 = _mm_setzero_si128();
-
-    /*
-    Pre-loading the coefficients and prior samples is annoying because we need to ensure we don't try reading more than
-    what's available in the input buffers. It would be convenient to use a fall-through switch to do this, but this results
-    in strict aliasing warnings with GCC. To work around this I'm just doing something hacky. This feels a bit convoluted
-    so I think there's opportunity for this to be simplified.
-    */
-#if 1
-    {
-        int runningOrder = order;
-
-        /* 0 - 3. */
-        if (runningOrder >= 4) {
-            coefficients128_0 = _mm_loadu_si128((const __m128i*)(coefficients + 0));
-            samples128_0      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 4));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_0 = _mm_set_epi32(0, coefficients[2], coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], pSamplesOut[-3], 0); break;
-                case 2: coefficients128_0 = _mm_set_epi32(0, 0,               coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], 0,               0); break;
-                case 1: coefficients128_0 = _mm_set_epi32(0, 0,               0,               coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], 0,               0,               0); break;
-            }
-            runningOrder = 0;
-        }
-
-        /* 4 - 7 */
-        if (runningOrder >= 4) {
-            coefficients128_4 = _mm_loadu_si128((const __m128i*)(coefficients + 4));
-            samples128_4      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 8));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_4 = _mm_set_epi32(0, coefficients[6], coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], pSamplesOut[-7], 0); break;
-                case 2: coefficients128_4 = _mm_set_epi32(0, 0,               coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], 0,               0); break;
-                case 1: coefficients128_4 = _mm_set_epi32(0, 0,               0,               coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], 0,               0,               0); break;
-            }
-            runningOrder = 0;
-        }
-
-        /* 8 - 11 */
-        if (runningOrder == 4) {
-            coefficients128_8 = _mm_loadu_si128((const __m128i*)(coefficients + 8));
-            samples128_8      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 12));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_8 = _mm_set_epi32(0, coefficients[10], coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], pSamplesOut[-11], 0); break;
-                case 2: coefficients128_8 = _mm_set_epi32(0, 0,                coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], 0,                0); break;
-                case 1: coefficients128_8 = _mm_set_epi32(0, 0,                0,               coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], 0,                0,                0); break;
-            }
-            runningOrder = 0;
-        }
-
-        /* Coefficients need to be shuffled for our streaming algorithm below to work. Samples are already in the correct order from the loading routine above. */
-        coefficients128_0 = _mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(0, 1, 2, 3));
-        coefficients128_4 = _mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(0, 1, 2, 3));
-        coefficients128_8 = _mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(0, 1, 2, 3));
-    }
-#else
-    /* This causes strict-aliasing warnings with GCC. */
-    switch (order)
-    {
-    case 12: ((drflac_int32*)&coefficients128_8)[0] = coefficients[11]; ((drflac_int32*)&samples128_8)[0] = pDecodedSamples[-12];
-    case 11: ((drflac_int32*)&coefficients128_8)[1] = coefficients[10]; ((drflac_int32*)&samples128_8)[1] = pDecodedSamples[-11];
-    case 10: ((drflac_int32*)&coefficients128_8)[2] = coefficients[ 9]; ((drflac_int32*)&samples128_8)[2] = pDecodedSamples[-10];
-    case 9:  ((drflac_int32*)&coefficients128_8)[3] = coefficients[ 8]; ((drflac_int32*)&samples128_8)[3] = pDecodedSamples[- 9];
-    case 8:  ((drflac_int32*)&coefficients128_4)[0] = coefficients[ 7]; ((drflac_int32*)&samples128_4)[0] = pDecodedSamples[- 8];
-    case 7:  ((drflac_int32*)&coefficients128_4)[1] = coefficients[ 6]; ((drflac_int32*)&samples128_4)[1] = pDecodedSamples[- 7];
-    case 6:  ((drflac_int32*)&coefficients128_4)[2] = coefficients[ 5]; ((drflac_int32*)&samples128_4)[2] = pDecodedSamples[- 6];
-    case 5:  ((drflac_int32*)&coefficients128_4)[3] = coefficients[ 4]; ((drflac_int32*)&samples128_4)[3] = pDecodedSamples[- 5];
-    case 4:  ((drflac_int32*)&coefficients128_0)[0] = coefficients[ 3]; ((drflac_int32*)&samples128_0)[0] = pDecodedSamples[- 4];
-    case 3:  ((drflac_int32*)&coefficients128_0)[1] = coefficients[ 2]; ((drflac_int32*)&samples128_0)[1] = pDecodedSamples[- 3];
-    case 2:  ((drflac_int32*)&coefficients128_0)[2] = coefficients[ 1]; ((drflac_int32*)&samples128_0)[2] = pDecodedSamples[- 2];
-    case 1:  ((drflac_int32*)&coefficients128_0)[3] = coefficients[ 0]; ((drflac_int32*)&samples128_0)[3] = pDecodedSamples[- 1];
-    }
-#endif
-
-    /* For this version we are doing one sample at a time. */
-    while (pDecodedSamples < pDecodedSamplesEnd) {
-        __m128i prediction128;
-        __m128i zeroCountPart128;
-        __m128i riceParamPart128;
-
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts1, &riceParamParts1) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts2, &riceParamParts2) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts3, &riceParamParts3)) {
-            return DRFLAC_FALSE;
-        }
-
-        zeroCountPart128 = _mm_set_epi32(zeroCountParts3, zeroCountParts2, zeroCountParts1, zeroCountParts0);
-        riceParamPart128 = _mm_set_epi32(riceParamParts3, riceParamParts2, riceParamParts1, riceParamParts0);
-
-        riceParamPart128 = _mm_and_si128(riceParamPart128, riceParamMask128);
-        riceParamPart128 = _mm_or_si128(riceParamPart128, _mm_slli_epi32(zeroCountPart128, riceParam));
-        riceParamPart128 = _mm_xor_si128(_mm_srli_epi32(riceParamPart128, 1), _mm_add_epi32(drflac__mm_not_si128(_mm_and_si128(riceParamPart128, _mm_set1_epi32(0x01))), _mm_set1_epi32(0x01)));  /* <-- SSE2 compatible */
-        /*riceParamPart128 = _mm_xor_si128(_mm_srli_epi32(riceParamPart128, 1), _mm_mullo_epi32(_mm_and_si128(riceParamPart128, _mm_set1_epi32(0x01)), _mm_set1_epi32(0xFFFFFFFF)));*/   /* <-- Only supported from SSE4.1 and is slower in my testing... */
-
-        if (order <= 4) {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 = _mm_mullo_epi32(coefficients128_0, samples128_0);
-
-                /* Horizontal add and shift. */
-                prediction128 = drflac__mm_hadd_epi32(prediction128);
-                prediction128 = _mm_srai_epi32(prediction128, shift);
-                prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
-
-                samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
-                riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
-            }
-        } else if (order <= 8) {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 =                              _mm_mullo_epi32(coefficients128_4, samples128_4);
-                prediction128 = _mm_add_epi32(prediction128, _mm_mullo_epi32(coefficients128_0, samples128_0));
-
-                /* Horizontal add and shift. */
-                prediction128 = drflac__mm_hadd_epi32(prediction128);
-                prediction128 = _mm_srai_epi32(prediction128, shift);
-                prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
-
-                samples128_4 = _mm_alignr_epi8(samples128_0,  samples128_4, 4);
-                samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
-                riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
-            }
-        } else {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 =                              _mm_mullo_epi32(coefficients128_8, samples128_8);
-                prediction128 = _mm_add_epi32(prediction128, _mm_mullo_epi32(coefficients128_4, samples128_4));
-                prediction128 = _mm_add_epi32(prediction128, _mm_mullo_epi32(coefficients128_0, samples128_0));
-
-                /* Horizontal add and shift. */
-                prediction128 = drflac__mm_hadd_epi32(prediction128);
-                prediction128 = _mm_srai_epi32(prediction128, shift);
-                prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
-
-                samples128_8 = _mm_alignr_epi8(samples128_4,  samples128_8, 4);
-                samples128_4 = _mm_alignr_epi8(samples128_0,  samples128_4, 4);
-                samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
-                riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
-            }
-        }
-
-        /* We store samples in groups of 4. */
-        _mm_storeu_si128((__m128i*)pDecodedSamples, samples128_0);
-        pDecodedSamples += 4;
-    }
-
-    /* Make sure we process the last few samples. */
-    i = (count & ~3);
-    while (i < (int)count) {
-        /* Rice extraction. */
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0)) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Rice reconstruction. */
-        riceParamParts0 &= riceParamMask;
-        riceParamParts0 |= (zeroCountParts0 << riceParam);
-        riceParamParts0  = (riceParamParts0 >> 1) ^ t[riceParamParts0 & 0x01];
-
-        /* Sample reconstruction. */
-        pDecodedSamples[0] = riceParamParts0 + drflac__calculate_prediction_32(order, shift, coefficients, pDecodedSamples);
-
-        i += 1;
-        pDecodedSamples += 1;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41_64(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    int i;
-    drflac_uint32 riceParamMask;
-    drflac_int32* pDecodedSamples    = pSamplesOut;
-    drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
-    drflac_uint32 zeroCountParts0 = 0;
-    drflac_uint32 zeroCountParts1 = 0;
-    drflac_uint32 zeroCountParts2 = 0;
-    drflac_uint32 zeroCountParts3 = 0;
-    drflac_uint32 riceParamParts0 = 0;
-    drflac_uint32 riceParamParts1 = 0;
-    drflac_uint32 riceParamParts2 = 0;
-    drflac_uint32 riceParamParts3 = 0;
-    __m128i coefficients128_0;
-    __m128i coefficients128_4;
-    __m128i coefficients128_8;
-    __m128i samples128_0;
-    __m128i samples128_4;
-    __m128i samples128_8;
-    __m128i prediction128;
-    __m128i riceParamMask128;
-
-    const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-
-    DRFLAC_ASSERT(order <= 12);
-
-    riceParamMask    = (drflac_uint32)~((~0UL) << riceParam);
-    riceParamMask128 = _mm_set1_epi32(riceParamMask);
-
-    prediction128 = _mm_setzero_si128();
-
-    /* Pre-load. */
-    coefficients128_0  = _mm_setzero_si128();
-    coefficients128_4  = _mm_setzero_si128();
-    coefficients128_8  = _mm_setzero_si128();
-
-    samples128_0  = _mm_setzero_si128();
-    samples128_4  = _mm_setzero_si128();
-    samples128_8  = _mm_setzero_si128();
-
-#if 1
-    {
-        int runningOrder = order;
-
-        /* 0 - 3. */
-        if (runningOrder >= 4) {
-            coefficients128_0 = _mm_loadu_si128((const __m128i*)(coefficients + 0));
-            samples128_0      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 4));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_0 = _mm_set_epi32(0, coefficients[2], coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], pSamplesOut[-3], 0); break;
-                case 2: coefficients128_0 = _mm_set_epi32(0, 0,               coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], 0,               0); break;
-                case 1: coefficients128_0 = _mm_set_epi32(0, 0,               0,               coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], 0,               0,               0); break;
-            }
-            runningOrder = 0;
-        }
-
-        /* 4 - 7 */
-        if (runningOrder >= 4) {
-            coefficients128_4 = _mm_loadu_si128((const __m128i*)(coefficients + 4));
-            samples128_4      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 8));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_4 = _mm_set_epi32(0, coefficients[6], coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], pSamplesOut[-7], 0); break;
-                case 2: coefficients128_4 = _mm_set_epi32(0, 0,               coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], 0,               0); break;
-                case 1: coefficients128_4 = _mm_set_epi32(0, 0,               0,               coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], 0,               0,               0); break;
-            }
-            runningOrder = 0;
-        }
-
-        /* 8 - 11 */
-        if (runningOrder == 4) {
-            coefficients128_8 = _mm_loadu_si128((const __m128i*)(coefficients + 8));
-            samples128_8      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 12));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_8 = _mm_set_epi32(0, coefficients[10], coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], pSamplesOut[-11], 0); break;
-                case 2: coefficients128_8 = _mm_set_epi32(0, 0,                coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], 0,                0); break;
-                case 1: coefficients128_8 = _mm_set_epi32(0, 0,                0,               coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], 0,                0,                0); break;
-            }
-            runningOrder = 0;
-        }
-
-        /* Coefficients need to be shuffled for our streaming algorithm below to work. Samples are already in the correct order from the loading routine above. */
-        coefficients128_0 = _mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(0, 1, 2, 3));
-        coefficients128_4 = _mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(0, 1, 2, 3));
-        coefficients128_8 = _mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(0, 1, 2, 3));
-    }
-#else
-    switch (order)
-    {
-    case 12: ((drflac_int32*)&coefficients128_8)[0] = coefficients[11]; ((drflac_int32*)&samples128_8)[0] = pDecodedSamples[-12];
-    case 11: ((drflac_int32*)&coefficients128_8)[1] = coefficients[10]; ((drflac_int32*)&samples128_8)[1] = pDecodedSamples[-11];
-    case 10: ((drflac_int32*)&coefficients128_8)[2] = coefficients[ 9]; ((drflac_int32*)&samples128_8)[2] = pDecodedSamples[-10];
-    case 9:  ((drflac_int32*)&coefficients128_8)[3] = coefficients[ 8]; ((drflac_int32*)&samples128_8)[3] = pDecodedSamples[- 9];
-    case 8:  ((drflac_int32*)&coefficients128_4)[0] = coefficients[ 7]; ((drflac_int32*)&samples128_4)[0] = pDecodedSamples[- 8];
-    case 7:  ((drflac_int32*)&coefficients128_4)[1] = coefficients[ 6]; ((drflac_int32*)&samples128_4)[1] = pDecodedSamples[- 7];
-    case 6:  ((drflac_int32*)&coefficients128_4)[2] = coefficients[ 5]; ((drflac_int32*)&samples128_4)[2] = pDecodedSamples[- 6];
-    case 5:  ((drflac_int32*)&coefficients128_4)[3] = coefficients[ 4]; ((drflac_int32*)&samples128_4)[3] = pDecodedSamples[- 5];
-    case 4:  ((drflac_int32*)&coefficients128_0)[0] = coefficients[ 3]; ((drflac_int32*)&samples128_0)[0] = pDecodedSamples[- 4];
-    case 3:  ((drflac_int32*)&coefficients128_0)[1] = coefficients[ 2]; ((drflac_int32*)&samples128_0)[1] = pDecodedSamples[- 3];
-    case 2:  ((drflac_int32*)&coefficients128_0)[2] = coefficients[ 1]; ((drflac_int32*)&samples128_0)[2] = pDecodedSamples[- 2];
-    case 1:  ((drflac_int32*)&coefficients128_0)[3] = coefficients[ 0]; ((drflac_int32*)&samples128_0)[3] = pDecodedSamples[- 1];
-    }
-#endif
-
-    /* For this version we are doing one sample at a time. */
-    while (pDecodedSamples < pDecodedSamplesEnd) {
-        __m128i zeroCountPart128;
-        __m128i riceParamPart128;
-
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts1, &riceParamParts1) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts2, &riceParamParts2) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts3, &riceParamParts3)) {
-            return DRFLAC_FALSE;
-        }
-
-        zeroCountPart128 = _mm_set_epi32(zeroCountParts3, zeroCountParts2, zeroCountParts1, zeroCountParts0);
-        riceParamPart128 = _mm_set_epi32(riceParamParts3, riceParamParts2, riceParamParts1, riceParamParts0);
-
-        riceParamPart128 = _mm_and_si128(riceParamPart128, riceParamMask128);
-        riceParamPart128 = _mm_or_si128(riceParamPart128, _mm_slli_epi32(zeroCountPart128, riceParam));
-        riceParamPart128 = _mm_xor_si128(_mm_srli_epi32(riceParamPart128, 1), _mm_add_epi32(drflac__mm_not_si128(_mm_and_si128(riceParamPart128, _mm_set1_epi32(1))), _mm_set1_epi32(1)));
-
-        for (i = 0; i < 4; i += 1) {
-            prediction128 = _mm_xor_si128(prediction128, prediction128);    /* Reset to 0. */
-
-            switch (order)
-            {
-            case 12:
-            case 11: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(1, 1, 0, 0)), _mm_shuffle_epi32(samples128_8, _MM_SHUFFLE(1, 1, 0, 0))));
-            case 10:
-            case  9: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(3, 3, 2, 2)), _mm_shuffle_epi32(samples128_8, _MM_SHUFFLE(3, 3, 2, 2))));
-            case  8:
-            case  7: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(1, 1, 0, 0)), _mm_shuffle_epi32(samples128_4, _MM_SHUFFLE(1, 1, 0, 0))));
-            case  6:
-            case  5: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(3, 3, 2, 2)), _mm_shuffle_epi32(samples128_4, _MM_SHUFFLE(3, 3, 2, 2))));
-            case  4:
-            case  3: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(1, 1, 0, 0)), _mm_shuffle_epi32(samples128_0, _MM_SHUFFLE(1, 1, 0, 0))));
-            case  2:
-            case  1: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(3, 3, 2, 2)), _mm_shuffle_epi32(samples128_0, _MM_SHUFFLE(3, 3, 2, 2))));
-            }
-
-            /* Horizontal add and shift. */
-            prediction128 = drflac__mm_hadd_epi64(prediction128);
-            prediction128 = drflac__mm_srai_epi64(prediction128, shift);
-            prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
-
-            /* Our value should be sitting in prediction128[0]. We need to combine this with our SSE samples. */
-            samples128_8 = _mm_alignr_epi8(samples128_4,  samples128_8, 4);
-            samples128_4 = _mm_alignr_epi8(samples128_0,  samples128_4, 4);
-            samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
-
-            /* Slide our rice parameter down so that the value in position 0 contains the next one to process. */
-            riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
-        }
-
-        /* We store samples in groups of 4. */
-        _mm_storeu_si128((__m128i*)pDecodedSamples, samples128_0);
-        pDecodedSamples += 4;
-    }
-
-    /* Make sure we process the last few samples. */
-    i = (count & ~3);
-    while (i < (int)count) {
-        /* Rice extraction. */
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0)) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Rice reconstruction. */
-        riceParamParts0 &= riceParamMask;
-        riceParamParts0 |= (zeroCountParts0 << riceParam);
-        riceParamParts0  = (riceParamParts0 >> 1) ^ t[riceParamParts0 & 0x01];
-
-        /* Sample reconstruction. */
-        pDecodedSamples[0] = riceParamParts0 + drflac__calculate_prediction_64(order, shift, coefficients, pDecodedSamples);
-
-        i += 1;
-        pDecodedSamples += 1;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(count > 0);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-
-    /* In my testing the order is rarely > 12, so in this case I'm going to simplify the SSE implementation by only handling order <= 12. */
-    if (order > 0 && order <= 12) {
-        if (bitsPerSample+shift > 32) {
-            return drflac__decode_samples_with_residual__rice__sse41_64(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
-        } else {
-            return drflac__decode_samples_with_residual__rice__sse41_32(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
-        }
-    } else {
-        return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac__vst2q_s32(drflac_int32* p, int32x4x2_t x)
-{
-    vst1q_s32(p+0, x.val[0]);
-    vst1q_s32(p+4, x.val[1]);
-}
-
-static DRFLAC_INLINE void drflac__vst2q_u32(drflac_uint32* p, uint32x4x2_t x)
-{
-    vst1q_u32(p+0, x.val[0]);
-    vst1q_u32(p+4, x.val[1]);
-}
-
-static DRFLAC_INLINE void drflac__vst2q_f32(float* p, float32x4x2_t x)
-{
-    vst1q_f32(p+0, x.val[0]);
-    vst1q_f32(p+4, x.val[1]);
-}
-
-static DRFLAC_INLINE void drflac__vst2q_s16(drflac_int16* p, int16x4x2_t x)
-{
-    vst1q_s16(p, vcombine_s16(x.val[0], x.val[1]));
-}
-
-static DRFLAC_INLINE void drflac__vst2q_u16(drflac_uint16* p, uint16x4x2_t x)
-{
-    vst1q_u16(p, vcombine_u16(x.val[0], x.val[1]));
-}
-
-static DRFLAC_INLINE int32x4_t drflac__vdupq_n_s32x4(drflac_int32 x3, drflac_int32 x2, drflac_int32 x1, drflac_int32 x0)
-{
-    drflac_int32 x[4];
-    x[3] = x3;
-    x[2] = x2;
-    x[1] = x1;
-    x[0] = x0;
-    return vld1q_s32(x);
-}
-
-static DRFLAC_INLINE int32x4_t drflac__valignrq_s32_1(int32x4_t a, int32x4_t b)
-{
-    /* Equivalent to SSE's _mm_alignr_epi8(a, b, 4) */
-
-    /* Reference */
-    /*return drflac__vdupq_n_s32x4(
-        vgetq_lane_s32(a, 0),
-        vgetq_lane_s32(b, 3),
-        vgetq_lane_s32(b, 2),
-        vgetq_lane_s32(b, 1)
-    );*/
-
-    return vextq_s32(b, a, 1);
-}
-
-static DRFLAC_INLINE uint32x4_t drflac__valignrq_u32_1(uint32x4_t a, uint32x4_t b)
-{
-    /* Equivalent to SSE's _mm_alignr_epi8(a, b, 4) */
-
-    /* Reference */
-    /*return drflac__vdupq_n_s32x4(
-        vgetq_lane_s32(a, 0),
-        vgetq_lane_s32(b, 3),
-        vgetq_lane_s32(b, 2),
-        vgetq_lane_s32(b, 1)
-    );*/
-
-    return vextq_u32(b, a, 1);
-}
-
-static DRFLAC_INLINE int32x2_t drflac__vhaddq_s32(int32x4_t x)
-{
-    /* The sum must end up in position 0. */
-
-    /* Reference */
-    /*return vdupq_n_s32(
-        vgetq_lane_s32(x, 3) +
-        vgetq_lane_s32(x, 2) +
-        vgetq_lane_s32(x, 1) +
-        vgetq_lane_s32(x, 0)
-    );*/
-
-    int32x2_t r = vadd_s32(vget_high_s32(x), vget_low_s32(x));
-    return vpadd_s32(r, r);
-}
-
-static DRFLAC_INLINE int64x1_t drflac__vhaddq_s64(int64x2_t x)
-{
-    return vadd_s64(vget_high_s64(x), vget_low_s64(x));
-}
-
-static DRFLAC_INLINE int32x4_t drflac__vrevq_s32(int32x4_t x)
-{
-    /* Reference */
-    /*return drflac__vdupq_n_s32x4(
-        vgetq_lane_s32(x, 0),
-        vgetq_lane_s32(x, 1),
-        vgetq_lane_s32(x, 2),
-        vgetq_lane_s32(x, 3)
-    );*/
-
-    return vrev64q_s32(vcombine_s32(vget_high_s32(x), vget_low_s32(x)));
-}
-
-static DRFLAC_INLINE int32x4_t drflac__vnotq_s32(int32x4_t x)
-{
-    return veorq_s32(x, vdupq_n_s32(0xFFFFFFFF));
-}
-
-static DRFLAC_INLINE uint32x4_t drflac__vnotq_u32(uint32x4_t x)
-{
-    return veorq_u32(x, vdupq_n_u32(0xFFFFFFFF));
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_32(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    int i;
-    drflac_uint32 riceParamMask;
-    drflac_int32* pDecodedSamples    = pSamplesOut;
-    drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
-    drflac_uint32 zeroCountParts[4];
-    drflac_uint32 riceParamParts[4];
-    int32x4_t coefficients128_0;
-    int32x4_t coefficients128_4;
-    int32x4_t coefficients128_8;
-    int32x4_t samples128_0;
-    int32x4_t samples128_4;
-    int32x4_t samples128_8;
-    uint32x4_t riceParamMask128;
-    int32x4_t riceParam128;
-    int32x2_t shift64;
-    uint32x4_t one128;
-
-    const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-
-    riceParamMask    = ~((~0UL) << riceParam);
-    riceParamMask128 = vdupq_n_u32(riceParamMask);
-
-    riceParam128 = vdupq_n_s32(riceParam);
-    shift64 = vdup_n_s32(-shift); /* Negate the shift because we'll be doing a variable shift using vshlq_s32(). */
-    one128 = vdupq_n_u32(1);
-
-    /*
-    Pre-loading the coefficients and prior samples is annoying because we need to ensure we don't try reading more than
-    what's available in the input buffers. It would be conenient to use a fall-through switch to do this, but this results
-    in strict aliasing warnings with GCC. To work around this I'm just doing something hacky. This feels a bit convoluted
-    so I think there's opportunity for this to be simplified.
-    */
-    {
-        int runningOrder = order;
-        drflac_int32 tempC[4] = {0, 0, 0, 0};
-        drflac_int32 tempS[4] = {0, 0, 0, 0};
-
-        /* 0 - 3. */
-        if (runningOrder >= 4) {
-            coefficients128_0 = vld1q_s32(coefficients + 0);
-            samples128_0      = vld1q_s32(pSamplesOut  - 4);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[2]; tempS[1] = pSamplesOut[-3]; /* fallthrough */
-                case 2: tempC[1] = coefficients[1]; tempS[2] = pSamplesOut[-2]; /* fallthrough */
-                case 1: tempC[0] = coefficients[0]; tempS[3] = pSamplesOut[-1]; /* fallthrough */
-            }
-
-            coefficients128_0 = vld1q_s32(tempC);
-            samples128_0      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-
-        /* 4 - 7 */
-        if (runningOrder >= 4) {
-            coefficients128_4 = vld1q_s32(coefficients + 4);
-            samples128_4      = vld1q_s32(pSamplesOut  - 8);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[6]; tempS[1] = pSamplesOut[-7]; /* fallthrough */
-                case 2: tempC[1] = coefficients[5]; tempS[2] = pSamplesOut[-6]; /* fallthrough */
-                case 1: tempC[0] = coefficients[4]; tempS[3] = pSamplesOut[-5]; /* fallthrough */
-            }
-
-            coefficients128_4 = vld1q_s32(tempC);
-            samples128_4      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-
-        /* 8 - 11 */
-        if (runningOrder == 4) {
-            coefficients128_8 = vld1q_s32(coefficients + 8);
-            samples128_8      = vld1q_s32(pSamplesOut  - 12);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[10]; tempS[1] = pSamplesOut[-11]; /* fallthrough */
-                case 2: tempC[1] = coefficients[ 9]; tempS[2] = pSamplesOut[-10]; /* fallthrough */
-                case 1: tempC[0] = coefficients[ 8]; tempS[3] = pSamplesOut[- 9]; /* fallthrough */
-            }
-
-            coefficients128_8 = vld1q_s32(tempC);
-            samples128_8      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-
-        /* Coefficients need to be shuffled for our streaming algorithm below to work. Samples are already in the correct order from the loading routine above. */
-        coefficients128_0 = drflac__vrevq_s32(coefficients128_0);
-        coefficients128_4 = drflac__vrevq_s32(coefficients128_4);
-        coefficients128_8 = drflac__vrevq_s32(coefficients128_8);
-    }
-
-    /* For this version we are doing one sample at a time. */
-    while (pDecodedSamples < pDecodedSamplesEnd) {
-        int32x4_t prediction128;
-        int32x2_t prediction64;
-        uint32x4_t zeroCountPart128;
-        uint32x4_t riceParamPart128;
-
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[1], &riceParamParts[1]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[2], &riceParamParts[2]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[3], &riceParamParts[3])) {
-            return DRFLAC_FALSE;
-        }
-
-        zeroCountPart128 = vld1q_u32(zeroCountParts);
-        riceParamPart128 = vld1q_u32(riceParamParts);
-
-        riceParamPart128 = vandq_u32(riceParamPart128, riceParamMask128);
-        riceParamPart128 = vorrq_u32(riceParamPart128, vshlq_u32(zeroCountPart128, riceParam128));
-        riceParamPart128 = veorq_u32(vshrq_n_u32(riceParamPart128, 1), vaddq_u32(drflac__vnotq_u32(vandq_u32(riceParamPart128, one128)), one128));
-
-        if (order <= 4) {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 = vmulq_s32(coefficients128_0, samples128_0);
-
-                /* Horizontal add and shift. */
-                prediction64 = drflac__vhaddq_s32(prediction128);
-                prediction64 = vshl_s32(prediction64, shift64);
-                prediction64 = vadd_s32(prediction64, vget_low_s32(vreinterpretq_s32_u32(riceParamPart128)));
-
-                samples128_0 = drflac__valignrq_s32_1(vcombine_s32(prediction64, vdup_n_s32(0)), samples128_0);
-                riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
-            }
-        } else if (order <= 8) {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 =                vmulq_s32(coefficients128_4, samples128_4);
-                prediction128 = vmlaq_s32(prediction128, coefficients128_0, samples128_0);
-
-                /* Horizontal add and shift. */
-                prediction64 = drflac__vhaddq_s32(prediction128);
-                prediction64 = vshl_s32(prediction64, shift64);
-                prediction64 = vadd_s32(prediction64, vget_low_s32(vreinterpretq_s32_u32(riceParamPart128)));
-
-                samples128_4 = drflac__valignrq_s32_1(samples128_0, samples128_4);
-                samples128_0 = drflac__valignrq_s32_1(vcombine_s32(prediction64, vdup_n_s32(0)), samples128_0);
-                riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
-            }
-        } else {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 =                vmulq_s32(coefficients128_8, samples128_8);
-                prediction128 = vmlaq_s32(prediction128, coefficients128_4, samples128_4);
-                prediction128 = vmlaq_s32(prediction128, coefficients128_0, samples128_0);
-
-                /* Horizontal add and shift. */
-                prediction64 = drflac__vhaddq_s32(prediction128);
-                prediction64 = vshl_s32(prediction64, shift64);
-                prediction64 = vadd_s32(prediction64, vget_low_s32(vreinterpretq_s32_u32(riceParamPart128)));
-
-                samples128_8 = drflac__valignrq_s32_1(samples128_4, samples128_8);
-                samples128_4 = drflac__valignrq_s32_1(samples128_0, samples128_4);
-                samples128_0 = drflac__valignrq_s32_1(vcombine_s32(prediction64, vdup_n_s32(0)), samples128_0);
-                riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
-            }
-        }
-
-        /* We store samples in groups of 4. */
-        vst1q_s32(pDecodedSamples, samples128_0);
-        pDecodedSamples += 4;
-    }
-
-    /* Make sure we process the last few samples. */
-    i = (count & ~3);
-    while (i < (int)count) {
-        /* Rice extraction. */
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0])) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Rice reconstruction. */
-        riceParamParts[0] &= riceParamMask;
-        riceParamParts[0] |= (zeroCountParts[0] << riceParam);
-        riceParamParts[0]  = (riceParamParts[0] >> 1) ^ t[riceParamParts[0] & 0x01];
-
-        /* Sample reconstruction. */
-        pDecodedSamples[0] = riceParamParts[0] + drflac__calculate_prediction_32(order, shift, coefficients, pDecodedSamples);
-
-        i += 1;
-        pDecodedSamples += 1;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_64(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    int i;
-    drflac_uint32 riceParamMask;
-    drflac_int32* pDecodedSamples    = pSamplesOut;
-    drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
-    drflac_uint32 zeroCountParts[4];
-    drflac_uint32 riceParamParts[4];
-    int32x4_t coefficients128_0;
-    int32x4_t coefficients128_4;
-    int32x4_t coefficients128_8;
-    int32x4_t samples128_0;
-    int32x4_t samples128_4;
-    int32x4_t samples128_8;
-    uint32x4_t riceParamMask128;
-    int32x4_t riceParam128;
-    int64x1_t shift64;
-    uint32x4_t one128;
-
-    const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-
-    riceParamMask    = ~((~0UL) << riceParam);
-    riceParamMask128 = vdupq_n_u32(riceParamMask);
-
-    riceParam128 = vdupq_n_s32(riceParam);
-    shift64 = vdup_n_s64(-shift); /* Negate the shift because we'll be doing a variable shift using vshlq_s32(). */
-    one128 = vdupq_n_u32(1);
-
-    /*
-    Pre-loading the coefficients and prior samples is annoying because we need to ensure we don't try reading more than
-    what's available in the input buffers. It would be conenient to use a fall-through switch to do this, but this results
-    in strict aliasing warnings with GCC. To work around this I'm just doing something hacky. This feels a bit convoluted
-    so I think there's opportunity for this to be simplified.
-    */
-    {
-        int runningOrder = order;
-        drflac_int32 tempC[4] = {0, 0, 0, 0};
-        drflac_int32 tempS[4] = {0, 0, 0, 0};
-
-        /* 0 - 3. */
-        if (runningOrder >= 4) {
-            coefficients128_0 = vld1q_s32(coefficients + 0);
-            samples128_0      = vld1q_s32(pSamplesOut  - 4);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[2]; tempS[1] = pSamplesOut[-3]; /* fallthrough */
-                case 2: tempC[1] = coefficients[1]; tempS[2] = pSamplesOut[-2]; /* fallthrough */
-                case 1: tempC[0] = coefficients[0]; tempS[3] = pSamplesOut[-1]; /* fallthrough */
-            }
-
-            coefficients128_0 = vld1q_s32(tempC);
-            samples128_0      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-
-        /* 4 - 7 */
-        if (runningOrder >= 4) {
-            coefficients128_4 = vld1q_s32(coefficients + 4);
-            samples128_4      = vld1q_s32(pSamplesOut  - 8);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[6]; tempS[1] = pSamplesOut[-7]; /* fallthrough */
-                case 2: tempC[1] = coefficients[5]; tempS[2] = pSamplesOut[-6]; /* fallthrough */
-                case 1: tempC[0] = coefficients[4]; tempS[3] = pSamplesOut[-5]; /* fallthrough */
-            }
-
-            coefficients128_4 = vld1q_s32(tempC);
-            samples128_4      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-
-        /* 8 - 11 */
-        if (runningOrder == 4) {
-            coefficients128_8 = vld1q_s32(coefficients + 8);
-            samples128_8      = vld1q_s32(pSamplesOut  - 12);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[10]; tempS[1] = pSamplesOut[-11]; /* fallthrough */
-                case 2: tempC[1] = coefficients[ 9]; tempS[2] = pSamplesOut[-10]; /* fallthrough */
-                case 1: tempC[0] = coefficients[ 8]; tempS[3] = pSamplesOut[- 9]; /* fallthrough */
-            }
-
-            coefficients128_8 = vld1q_s32(tempC);
-            samples128_8      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-
-        /* Coefficients need to be shuffled for our streaming algorithm below to work. Samples are already in the correct order from the loading routine above. */
-        coefficients128_0 = drflac__vrevq_s32(coefficients128_0);
-        coefficients128_4 = drflac__vrevq_s32(coefficients128_4);
-        coefficients128_8 = drflac__vrevq_s32(coefficients128_8);
-    }
-
-    /* For this version we are doing one sample at a time. */
-    while (pDecodedSamples < pDecodedSamplesEnd) {
-        int64x2_t prediction128;
-        uint32x4_t zeroCountPart128;
-        uint32x4_t riceParamPart128;
-
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[1], &riceParamParts[1]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[2], &riceParamParts[2]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[3], &riceParamParts[3])) {
-            return DRFLAC_FALSE;
-        }
-
-        zeroCountPart128 = vld1q_u32(zeroCountParts);
-        riceParamPart128 = vld1q_u32(riceParamParts);
-
-        riceParamPart128 = vandq_u32(riceParamPart128, riceParamMask128);
-        riceParamPart128 = vorrq_u32(riceParamPart128, vshlq_u32(zeroCountPart128, riceParam128));
-        riceParamPart128 = veorq_u32(vshrq_n_u32(riceParamPart128, 1), vaddq_u32(drflac__vnotq_u32(vandq_u32(riceParamPart128, one128)), one128));
-
-        for (i = 0; i < 4; i += 1) {
-            int64x1_t prediction64;
-
-            prediction128 = veorq_s64(prediction128, prediction128);    /* Reset to 0. */
-            switch (order)
-            {
-            case 12:
-            case 11: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_low_s32(coefficients128_8), vget_low_s32(samples128_8)));
-            case 10:
-            case  9: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_high_s32(coefficients128_8), vget_high_s32(samples128_8)));
-            case  8:
-            case  7: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_low_s32(coefficients128_4), vget_low_s32(samples128_4)));
-            case  6:
-            case  5: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_high_s32(coefficients128_4), vget_high_s32(samples128_4)));
-            case  4:
-            case  3: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_low_s32(coefficients128_0), vget_low_s32(samples128_0)));
-            case  2:
-            case  1: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_high_s32(coefficients128_0), vget_high_s32(samples128_0)));
-            }
-
-            /* Horizontal add and shift. */
-            prediction64 = drflac__vhaddq_s64(prediction128);
-            prediction64 = vshl_s64(prediction64, shift64);
-            prediction64 = vadd_s64(prediction64, vdup_n_s64(vgetq_lane_u32(riceParamPart128, 0)));
-
-            /* Our value should be sitting in prediction64[0]. We need to combine this with our SSE samples. */
-            samples128_8 = drflac__valignrq_s32_1(samples128_4, samples128_8);
-            samples128_4 = drflac__valignrq_s32_1(samples128_0, samples128_4);
-            samples128_0 = drflac__valignrq_s32_1(vcombine_s32(vreinterpret_s32_s64(prediction64), vdup_n_s32(0)), samples128_0);
-
-            /* Slide our rice parameter down so that the value in position 0 contains the next one to process. */
-            riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
-        }
-
-        /* We store samples in groups of 4. */
-        vst1q_s32(pDecodedSamples, samples128_0);
-        pDecodedSamples += 4;
-    }
-
-    /* Make sure we process the last few samples. */
-    i = (count & ~3);
-    while (i < (int)count) {
-        /* Rice extraction. */
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0])) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Rice reconstruction. */
-        riceParamParts[0] &= riceParamMask;
-        riceParamParts[0] |= (zeroCountParts[0] << riceParam);
-        riceParamParts[0]  = (riceParamParts[0] >> 1) ^ t[riceParamParts[0] & 0x01];
-
-        /* Sample reconstruction. */
-        pDecodedSamples[0] = riceParamParts[0] + drflac__calculate_prediction_64(order, shift, coefficients, pDecodedSamples);
-
-        i += 1;
-        pDecodedSamples += 1;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__neon(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(count > 0);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-
-    /* In my testing the order is rarely > 12, so in this case I'm going to simplify the NEON implementation by only handling order <= 12. */
-    if (order > 0 && order <= 12) {
-        if (bitsPerSample+shift > 32) {
-            return drflac__decode_samples_with_residual__rice__neon_64(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
-        } else {
-            return drflac__decode_samples_with_residual__rice__neon_32(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
-        }
-    } else {
-        return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    }
-}
-#endif
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-#if defined(DRFLAC_SUPPORT_SSE41)
-    if (drflac__gIsSSE41Supported) {
-        return drflac__decode_samples_with_residual__rice__sse41(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported) {
-        return drflac__decode_samples_with_residual__rice__neon(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-    #if 0
-        return drflac__decode_samples_with_residual__rice__reference(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    #else
-        return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    #endif
-    }
-}
-
-/* Reads and seeks past a string of residual values as Rice codes. The decoder should be sitting on the first bit of the Rice codes. */
-static drflac_bool32 drflac__read_and_seek_residual__rice(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam)
-{
-    drflac_uint32 i;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(count > 0);
-
-    for (i = 0; i < count; ++i) {
-        if (!drflac__seek_rice_parts(bs, riceParam)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__unencoded(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 unencodedBitsPerSample, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    drflac_uint32 i;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(count > 0);
-    DRFLAC_ASSERT(unencodedBitsPerSample <= 31);    /* <-- unencodedBitsPerSample is a 5 bit number, so cannot exceed 31. */
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-
-    for (i = 0; i < count; ++i) {
-        if (unencodedBitsPerSample > 0) {
-            if (!drflac__read_int32(bs, unencodedBitsPerSample, pSamplesOut + i)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            pSamplesOut[i] = 0;
-        }
-
-        if (bitsPerSample >= 24) {
-            pSamplesOut[i] += drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + i);
-        } else {
-            pSamplesOut[i] += drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + i);
-        }
-    }
-
-    return DRFLAC_TRUE;
-}
-
-
-/*
-Reads and decodes the residual for the sub-frame the decoder is currently sitting on. This function should be called
-when the decoder is sitting at the very start of the RESIDUAL block. The first <order> residuals will be ignored. The
-<blockSize> and <order> parameters are used to determine how many residual values need to be decoded.
-*/
-static drflac_bool32 drflac__decode_samples_with_residual(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 blockSize, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
-{
-    drflac_uint8 residualMethod;
-    drflac_uint8 partitionOrder;
-    drflac_uint32 samplesInPartition;
-    drflac_uint32 partitionsRemaining;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(blockSize != 0);
-    DRFLAC_ASSERT(pDecodedSamples != NULL);       /* <-- Should we allow NULL, in which case we just seek past the residual rather than do a full decode? */
-
-    if (!drflac__read_uint8(bs, 2, &residualMethod)) {
-        return DRFLAC_FALSE;
-    }
-
-    if (residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE && residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
-        return DRFLAC_FALSE;    /* Unknown or unsupported residual coding method. */
-    }
-
-    /* Ignore the first <order> values. */
-    pDecodedSamples += order;
-
-    if (!drflac__read_uint8(bs, 4, &partitionOrder)) {
-        return DRFLAC_FALSE;
-    }
-
-    /*
-    From the FLAC spec:
-      The Rice partition order in a Rice-coded residual section must be less than or equal to 8.
-    */
-    if (partitionOrder > 8) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Validation check. */
-    if ((blockSize / (1 << partitionOrder)) <= order) {
-        return DRFLAC_FALSE;
-    }
-
-    samplesInPartition = (blockSize / (1 << partitionOrder)) - order;
-    partitionsRemaining = (1 << partitionOrder);
-    for (;;) {
-        drflac_uint8 riceParam = 0;
-        if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE) {
-            if (!drflac__read_uint8(bs, 4, &riceParam)) {
-                return DRFLAC_FALSE;
-            }
-            if (riceParam == 15) {
-                riceParam = 0xFF;
-            }
-        } else if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
-            if (!drflac__read_uint8(bs, 5, &riceParam)) {
-                return DRFLAC_FALSE;
-            }
-            if (riceParam == 31) {
-                riceParam = 0xFF;
-            }
-        }
-
-        if (riceParam != 0xFF) {
-            if (!drflac__decode_samples_with_residual__rice(bs, bitsPerSample, samplesInPartition, riceParam, order, shift, coefficients, pDecodedSamples)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            drflac_uint8 unencodedBitsPerSample = 0;
-            if (!drflac__read_uint8(bs, 5, &unencodedBitsPerSample)) {
-                return DRFLAC_FALSE;
-            }
-
-            if (!drflac__decode_samples_with_residual__unencoded(bs, bitsPerSample, samplesInPartition, unencodedBitsPerSample, order, shift, coefficients, pDecodedSamples)) {
-                return DRFLAC_FALSE;
-            }
-        }
-
-        pDecodedSamples += samplesInPartition;
-
-        if (partitionsRemaining == 1) {
-            break;
-        }
-
-        partitionsRemaining -= 1;
-
-        if (partitionOrder != 0) {
-            samplesInPartition = blockSize / (1 << partitionOrder);
-        }
-    }
-
-    return DRFLAC_TRUE;
-}
-
-/*
-Reads and seeks past the residual for the sub-frame the decoder is currently sitting on. This function should be called
-when the decoder is sitting at the very start of the RESIDUAL block. The first <order> residuals will be set to 0. The
-<blockSize> and <order> parameters are used to determine how many residual values need to be decoded.
-*/
-static drflac_bool32 drflac__read_and_seek_residual(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 order)
-{
-    drflac_uint8 residualMethod;
-    drflac_uint8 partitionOrder;
-    drflac_uint32 samplesInPartition;
-    drflac_uint32 partitionsRemaining;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(blockSize != 0);
-
-    if (!drflac__read_uint8(bs, 2, &residualMethod)) {
-        return DRFLAC_FALSE;
-    }
-
-    if (residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE && residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
-        return DRFLAC_FALSE;    /* Unknown or unsupported residual coding method. */
-    }
-
-    if (!drflac__read_uint8(bs, 4, &partitionOrder)) {
-        return DRFLAC_FALSE;
-    }
-
-    /*
-    From the FLAC spec:
-      The Rice partition order in a Rice-coded residual section must be less than or equal to 8.
-    */
-    if (partitionOrder > 8) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Validation check. */
-    if ((blockSize / (1 << partitionOrder)) <= order) {
-        return DRFLAC_FALSE;
-    }
-
-    samplesInPartition = (blockSize / (1 << partitionOrder)) - order;
-    partitionsRemaining = (1 << partitionOrder);
-    for (;;)
-    {
-        drflac_uint8 riceParam = 0;
-        if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE) {
-            if (!drflac__read_uint8(bs, 4, &riceParam)) {
-                return DRFLAC_FALSE;
-            }
-            if (riceParam == 15) {
-                riceParam = 0xFF;
-            }
-        } else if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
-            if (!drflac__read_uint8(bs, 5, &riceParam)) {
-                return DRFLAC_FALSE;
-            }
-            if (riceParam == 31) {
-                riceParam = 0xFF;
-            }
-        }
-
-        if (riceParam != 0xFF) {
-            if (!drflac__read_and_seek_residual__rice(bs, samplesInPartition, riceParam)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            drflac_uint8 unencodedBitsPerSample = 0;
-            if (!drflac__read_uint8(bs, 5, &unencodedBitsPerSample)) {
-                return DRFLAC_FALSE;
-            }
-
-            if (!drflac__seek_bits(bs, unencodedBitsPerSample * samplesInPartition)) {
-                return DRFLAC_FALSE;
-            }
-        }
-
-
-        if (partitionsRemaining == 1) {
-            break;
-        }
-
-        partitionsRemaining -= 1;
-        samplesInPartition = blockSize / (1 << partitionOrder);
-    }
-
-    return DRFLAC_TRUE;
-}
-
-
-static drflac_bool32 drflac__decode_samples__constant(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 subframeBitsPerSample, drflac_int32* pDecodedSamples)
-{
-    drflac_uint32 i;
-
-    /* Only a single sample needs to be decoded here. */
-    drflac_int32 sample;
-    if (!drflac__read_int32(bs, subframeBitsPerSample, &sample)) {
-        return DRFLAC_FALSE;
-    }
-
-    /*
-    We don't really need to expand this, but it does simplify the process of reading samples. If this becomes a performance issue (unlikely)
-    we'll want to look at a more efficient way.
-    */
-    for (i = 0; i < blockSize; ++i) {
-        pDecodedSamples[i] = sample;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples__verbatim(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 subframeBitsPerSample, drflac_int32* pDecodedSamples)
-{
-    drflac_uint32 i;
-
-    for (i = 0; i < blockSize; ++i) {
-        drflac_int32 sample;
-        if (!drflac__read_int32(bs, subframeBitsPerSample, &sample)) {
-            return DRFLAC_FALSE;
-        }
-
-        pDecodedSamples[i] = sample;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples__fixed(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 subframeBitsPerSample, drflac_uint8 lpcOrder, drflac_int32* pDecodedSamples)
-{
-    drflac_uint32 i;
-
-    static drflac_int32 lpcCoefficientsTable[5][4] = {
-        {0,  0, 0,  0},
-        {1,  0, 0,  0},
-        {2, -1, 0,  0},
-        {3, -3, 1,  0},
-        {4, -6, 4, -1}
-    };
-
-    /* Warm up samples and coefficients. */
-    for (i = 0; i < lpcOrder; ++i) {
-        drflac_int32 sample;
-        if (!drflac__read_int32(bs, subframeBitsPerSample, &sample)) {
-            return DRFLAC_FALSE;
-        }
-
-        pDecodedSamples[i] = sample;
-    }
-
-    if (!drflac__decode_samples_with_residual(bs, subframeBitsPerSample, blockSize, lpcOrder, 0, lpcCoefficientsTable[lpcOrder], pDecodedSamples)) {
-        return DRFLAC_FALSE;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples__lpc(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 bitsPerSample, drflac_uint8 lpcOrder, drflac_int32* pDecodedSamples)
-{
-    drflac_uint8 i;
-    drflac_uint8 lpcPrecision;
-    drflac_int8 lpcShift;
-    drflac_int32 coefficients[32];
-
-    /* Warm up samples. */
-    for (i = 0; i < lpcOrder; ++i) {
-        drflac_int32 sample;
-        if (!drflac__read_int32(bs, bitsPerSample, &sample)) {
-            return DRFLAC_FALSE;
-        }
-
-        pDecodedSamples[i] = sample;
-    }
-
-    if (!drflac__read_uint8(bs, 4, &lpcPrecision)) {
-        return DRFLAC_FALSE;
-    }
-    if (lpcPrecision == 15) {
-        return DRFLAC_FALSE;    /* Invalid. */
-    }
-    lpcPrecision += 1;
-
-    if (!drflac__read_int8(bs, 5, &lpcShift)) {
-        return DRFLAC_FALSE;
-    }
-
-    /*
-    From the FLAC specification:
-
-        Quantized linear predictor coefficient shift needed in bits (NOTE: this number is signed two's-complement)
-
-    Emphasis on the "signed two's-complement". In practice there does not seem to be any encoders nor decoders supporting negative shifts. For now dr_flac is
-    not going to support negative shifts as I don't have any reference files. However, when a reference file comes through I will consider adding support.
-    */
-    if (lpcShift < 0) {
-        return DRFLAC_FALSE;
-    }
-
-    DRFLAC_ZERO_MEMORY(coefficients, sizeof(coefficients));
-    for (i = 0; i < lpcOrder; ++i) {
-        if (!drflac__read_int32(bs, lpcPrecision, coefficients + i)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    if (!drflac__decode_samples_with_residual(bs, bitsPerSample, blockSize, lpcOrder, lpcShift, coefficients, pDecodedSamples)) {
-        return DRFLAC_FALSE;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-
-static drflac_bool32 drflac__read_next_flac_frame_header(drflac_bs* bs, drflac_uint8 streaminfoBitsPerSample, drflac_frame_header* header)
-{
-    const drflac_uint32 sampleRateTable[12]  = {0, 88200, 176400, 192000, 8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000};
-    const drflac_uint8 bitsPerSampleTable[8] = {0, 8, 12, (drflac_uint8)-1, 16, 20, 24, (drflac_uint8)-1};   /* -1 = reserved. */
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(header != NULL);
-
-    /* Keep looping until we find a valid sync code. */
-    for (;;) {
-        drflac_uint8 crc8 = 0xCE; /* 0xCE = drflac_crc8(0, 0x3FFE, 14); */
-        drflac_uint8 reserved = 0;
-        drflac_uint8 blockingStrategy = 0;
-        drflac_uint8 blockSize = 0;
-        drflac_uint8 sampleRate = 0;
-        drflac_uint8 channelAssignment = 0;
-        drflac_uint8 bitsPerSample = 0;
-        drflac_bool32 isVariableBlockSize;
-
-        if (!drflac__find_and_seek_to_next_sync_code(bs)) {
-            return DRFLAC_FALSE;
-        }
-
-        if (!drflac__read_uint8(bs, 1, &reserved)) {
-            return DRFLAC_FALSE;
-        }
-        if (reserved == 1) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, reserved, 1);
-
-        if (!drflac__read_uint8(bs, 1, &blockingStrategy)) {
-            return DRFLAC_FALSE;
-        }
-        crc8 = drflac_crc8(crc8, blockingStrategy, 1);
-
-        if (!drflac__read_uint8(bs, 4, &blockSize)) {
-            return DRFLAC_FALSE;
-        }
-        if (blockSize == 0) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, blockSize, 4);
-
-        if (!drflac__read_uint8(bs, 4, &sampleRate)) {
-            return DRFLAC_FALSE;
-        }
-        crc8 = drflac_crc8(crc8, sampleRate, 4);
-
-        if (!drflac__read_uint8(bs, 4, &channelAssignment)) {
-            return DRFLAC_FALSE;
-        }
-        if (channelAssignment > 10) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, channelAssignment, 4);
-
-        if (!drflac__read_uint8(bs, 3, &bitsPerSample)) {
-            return DRFLAC_FALSE;
-        }
-        if (bitsPerSample == 3 || bitsPerSample == 7) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, bitsPerSample, 3);
-
-
-        if (!drflac__read_uint8(bs, 1, &reserved)) {
-            return DRFLAC_FALSE;
-        }
-        if (reserved == 1) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, reserved, 1);
-
-
-        isVariableBlockSize = blockingStrategy == 1;
-        if (isVariableBlockSize) {
-            drflac_uint64 pcmFrameNumber;
-            drflac_result result = drflac__read_utf8_coded_number(bs, &pcmFrameNumber, &crc8);
-            if (result != DRFLAC_SUCCESS) {
-                if (result == DRFLAC_AT_END) {
-                    return DRFLAC_FALSE;
-                } else {
-                    continue;
-                }
-            }
-            header->flacFrameNumber  = 0;
-            header->pcmFrameNumber = pcmFrameNumber;
-        } else {
-            drflac_uint64 flacFrameNumber = 0;
-            drflac_result result = drflac__read_utf8_coded_number(bs, &flacFrameNumber, &crc8);
-            if (result != DRFLAC_SUCCESS) {
-                if (result == DRFLAC_AT_END) {
-                    return DRFLAC_FALSE;
-                } else {
-                    continue;
-                }
-            }
-            header->flacFrameNumber  = (drflac_uint32)flacFrameNumber;   /* <-- Safe cast. */
-            header->pcmFrameNumber = 0;
-        }
-
-
-        DRFLAC_ASSERT(blockSize > 0);
-        if (blockSize == 1) {
-            header->blockSizeInPCMFrames = 192;
-        } else if (blockSize <= 5) {
-            DRFLAC_ASSERT(blockSize >= 2);
-            header->blockSizeInPCMFrames = 576 * (1 << (blockSize - 2));
-        } else if (blockSize == 6) {
-            if (!drflac__read_uint16(bs, 8, &header->blockSizeInPCMFrames)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->blockSizeInPCMFrames, 8);
-            header->blockSizeInPCMFrames += 1;
-        } else if (blockSize == 7) {
-            if (!drflac__read_uint16(bs, 16, &header->blockSizeInPCMFrames)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->blockSizeInPCMFrames, 16);
-            header->blockSizeInPCMFrames += 1;
-        } else {
-            DRFLAC_ASSERT(blockSize >= 8);
-            header->blockSizeInPCMFrames = 256 * (1 << (blockSize - 8));
-        }
-
-
-        if (sampleRate <= 11) {
-            header->sampleRate = sampleRateTable[sampleRate];
-        } else if (sampleRate == 12) {
-            if (!drflac__read_uint32(bs, 8, &header->sampleRate)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->sampleRate, 8);
-            header->sampleRate *= 1000;
-        } else if (sampleRate == 13) {
-            if (!drflac__read_uint32(bs, 16, &header->sampleRate)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->sampleRate, 16);
-        } else if (sampleRate == 14) {
-            if (!drflac__read_uint32(bs, 16, &header->sampleRate)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->sampleRate, 16);
-            header->sampleRate *= 10;
-        } else {
-            continue;  /* Invalid. Assume an invalid block. */
-        }
-
-
-        header->channelAssignment = channelAssignment;
-
-        header->bitsPerSample = bitsPerSampleTable[bitsPerSample];
-        if (header->bitsPerSample == 0) {
-            header->bitsPerSample = streaminfoBitsPerSample;
-        }
-
-        if (!drflac__read_uint8(bs, 8, &header->crc8)) {
-            return DRFLAC_FALSE;
-        }
-
-#ifndef DR_FLAC_NO_CRC
-        if (header->crc8 != crc8) {
-            continue;    /* CRC mismatch. Loop back to the top and find the next sync code. */
-        }
-#endif
-        return DRFLAC_TRUE;
-    }
-}
-
-static drflac_bool32 drflac__read_subframe_header(drflac_bs* bs, drflac_subframe* pSubframe)
-{
-    drflac_uint8 header;
-    int type;
-
-    if (!drflac__read_uint8(bs, 8, &header)) {
-        return DRFLAC_FALSE;
-    }
-
-    /* First bit should always be 0. */
-    if ((header & 0x80) != 0) {
-        return DRFLAC_FALSE;
-    }
-
-    type = (header & 0x7E) >> 1;
-    if (type == 0) {
-        pSubframe->subframeType = DRFLAC_SUBFRAME_CONSTANT;
-    } else if (type == 1) {
-        pSubframe->subframeType = DRFLAC_SUBFRAME_VERBATIM;
-    } else {
-        if ((type & 0x20) != 0) {
-            pSubframe->subframeType = DRFLAC_SUBFRAME_LPC;
-            pSubframe->lpcOrder = (drflac_uint8)(type & 0x1F) + 1;
-        } else if ((type & 0x08) != 0) {
-            pSubframe->subframeType = DRFLAC_SUBFRAME_FIXED;
-            pSubframe->lpcOrder = (drflac_uint8)(type & 0x07);
-            if (pSubframe->lpcOrder > 4) {
-                pSubframe->subframeType = DRFLAC_SUBFRAME_RESERVED;
-                pSubframe->lpcOrder = 0;
-            }
-        } else {
-            pSubframe->subframeType = DRFLAC_SUBFRAME_RESERVED;
-        }
-    }
-
-    if (pSubframe->subframeType == DRFLAC_SUBFRAME_RESERVED) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Wasted bits per sample. */
-    pSubframe->wastedBitsPerSample = 0;
-    if ((header & 0x01) == 1) {
-        unsigned int wastedBitsPerSample;
-        if (!drflac__seek_past_next_set_bit(bs, &wastedBitsPerSample)) {
-            return DRFLAC_FALSE;
-        }
-        pSubframe->wastedBitsPerSample = (drflac_uint8)wastedBitsPerSample + 1;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_subframe(drflac_bs* bs, drflac_frame* frame, int subframeIndex, drflac_int32* pDecodedSamplesOut)
-{
-    drflac_subframe* pSubframe;
-    drflac_uint32 subframeBitsPerSample;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(frame != NULL);
-
-    pSubframe = frame->subframes + subframeIndex;
-    if (!drflac__read_subframe_header(bs, pSubframe)) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Side channels require an extra bit per sample. Took a while to figure that one out... */
-    subframeBitsPerSample = frame->header.bitsPerSample;
-    if ((frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE || frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE) && subframeIndex == 1) {
-        subframeBitsPerSample += 1;
-    } else if (frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE && subframeIndex == 0) {
-        subframeBitsPerSample += 1;
-    }
-
-    /* Need to handle wasted bits per sample. */
-    if (pSubframe->wastedBitsPerSample >= subframeBitsPerSample) {
-        return DRFLAC_FALSE;
-    }
-    subframeBitsPerSample -= pSubframe->wastedBitsPerSample;
-
-    pSubframe->pSamplesS32 = pDecodedSamplesOut;
-
-    switch (pSubframe->subframeType)
-    {
-        case DRFLAC_SUBFRAME_CONSTANT:
-        {
-            drflac__decode_samples__constant(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->pSamplesS32);
-        } break;
-
-        case DRFLAC_SUBFRAME_VERBATIM:
-        {
-            drflac__decode_samples__verbatim(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->pSamplesS32);
-        } break;
-
-        case DRFLAC_SUBFRAME_FIXED:
-        {
-            drflac__decode_samples__fixed(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->lpcOrder, pSubframe->pSamplesS32);
-        } break;
-
-        case DRFLAC_SUBFRAME_LPC:
-        {
-            drflac__decode_samples__lpc(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->lpcOrder, pSubframe->pSamplesS32);
-        } break;
-
-        default: return DRFLAC_FALSE;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__seek_subframe(drflac_bs* bs, drflac_frame* frame, int subframeIndex)
-{
-    drflac_subframe* pSubframe;
-    drflac_uint32 subframeBitsPerSample;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(frame != NULL);
-
-    pSubframe = frame->subframes + subframeIndex;
-    if (!drflac__read_subframe_header(bs, pSubframe)) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Side channels require an extra bit per sample. Took a while to figure that one out... */
-    subframeBitsPerSample = frame->header.bitsPerSample;
-    if ((frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE || frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE) && subframeIndex == 1) {
-        subframeBitsPerSample += 1;
-    } else if (frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE && subframeIndex == 0) {
-        subframeBitsPerSample += 1;
-    }
-
-    /* Need to handle wasted bits per sample. */
-    if (pSubframe->wastedBitsPerSample >= subframeBitsPerSample) {
-        return DRFLAC_FALSE;
-    }
-    subframeBitsPerSample -= pSubframe->wastedBitsPerSample;
-
-    pSubframe->pSamplesS32 = NULL;
-
-    switch (pSubframe->subframeType)
-    {
-        case DRFLAC_SUBFRAME_CONSTANT:
-        {
-            if (!drflac__seek_bits(bs, subframeBitsPerSample)) {
-                return DRFLAC_FALSE;
-            }
-        } break;
-
-        case DRFLAC_SUBFRAME_VERBATIM:
-        {
-            unsigned int bitsToSeek = frame->header.blockSizeInPCMFrames * subframeBitsPerSample;
-            if (!drflac__seek_bits(bs, bitsToSeek)) {
-                return DRFLAC_FALSE;
-            }
-        } break;
-
-        case DRFLAC_SUBFRAME_FIXED:
-        {
-            unsigned int bitsToSeek = pSubframe->lpcOrder * subframeBitsPerSample;
-            if (!drflac__seek_bits(bs, bitsToSeek)) {
-                return DRFLAC_FALSE;
-            }
-
-            if (!drflac__read_and_seek_residual(bs, frame->header.blockSizeInPCMFrames, pSubframe->lpcOrder)) {
-                return DRFLAC_FALSE;
-            }
-        } break;
-
-        case DRFLAC_SUBFRAME_LPC:
-        {
-            drflac_uint8 lpcPrecision;
-
-            unsigned int bitsToSeek = pSubframe->lpcOrder * subframeBitsPerSample;
-            if (!drflac__seek_bits(bs, bitsToSeek)) {
-                return DRFLAC_FALSE;
-            }
-
-            if (!drflac__read_uint8(bs, 4, &lpcPrecision)) {
-                return DRFLAC_FALSE;
-            }
-            if (lpcPrecision == 15) {
-                return DRFLAC_FALSE;    /* Invalid. */
-            }
-            lpcPrecision += 1;
-
-
-            bitsToSeek = (pSubframe->lpcOrder * lpcPrecision) + 5;    /* +5 for shift. */
-            if (!drflac__seek_bits(bs, bitsToSeek)) {
-                return DRFLAC_FALSE;
-            }
-
-            if (!drflac__read_and_seek_residual(bs, frame->header.blockSizeInPCMFrames, pSubframe->lpcOrder)) {
-                return DRFLAC_FALSE;
-            }
-        } break;
-
-        default: return DRFLAC_FALSE;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-
-static DRFLAC_INLINE drflac_uint8 drflac__get_channel_count_from_channel_assignment(drflac_int8 channelAssignment)
-{
-    drflac_uint8 lookup[] = {1, 2, 3, 4, 5, 6, 7, 8, 2, 2, 2};
-
-    DRFLAC_ASSERT(channelAssignment <= 10);
-    return lookup[channelAssignment];
-}
-
-static drflac_result drflac__decode_flac_frame(drflac* pFlac)
-{
-    int channelCount;
-    int i;
-    drflac_uint8 paddingSizeInBits;
-    drflac_uint16 desiredCRC16;
-#ifndef DR_FLAC_NO_CRC
-    drflac_uint16 actualCRC16;
-#endif
-
-    /* This function should be called while the stream is sitting on the first byte after the frame header. */
-    DRFLAC_ZERO_MEMORY(pFlac->currentFLACFrame.subframes, sizeof(pFlac->currentFLACFrame.subframes));
-
-    /* The frame block size must never be larger than the maximum block size defined by the FLAC stream. */
-    if (pFlac->currentFLACFrame.header.blockSizeInPCMFrames > pFlac->maxBlockSizeInPCMFrames) {
-        return DRFLAC_ERROR;
-    }
-
-    /* The number of channels in the frame must match the channel count from the STREAMINFO block. */
-    channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-    if (channelCount != (int)pFlac->channels) {
-        return DRFLAC_ERROR;
-    }
-
-    for (i = 0; i < channelCount; ++i) {
-        if (!drflac__decode_subframe(&pFlac->bs, &pFlac->currentFLACFrame, i, pFlac->pDecodedSamples + (pFlac->currentFLACFrame.header.blockSizeInPCMFrames * i))) {
-            return DRFLAC_ERROR;
-        }
-    }
-
-    paddingSizeInBits = (drflac_uint8)(DRFLAC_CACHE_L1_BITS_REMAINING(&pFlac->bs) & 7);
-    if (paddingSizeInBits > 0) {
-        drflac_uint8 padding = 0;
-        if (!drflac__read_uint8(&pFlac->bs, paddingSizeInBits, &padding)) {
-            return DRFLAC_AT_END;
-        }
-    }
-
-#ifndef DR_FLAC_NO_CRC
-    actualCRC16 = drflac__flush_crc16(&pFlac->bs);
-#endif
-    if (!drflac__read_uint16(&pFlac->bs, 16, &desiredCRC16)) {
-        return DRFLAC_AT_END;
-    }
-
-#ifndef DR_FLAC_NO_CRC
-    if (actualCRC16 != desiredCRC16) {
-        return DRFLAC_CRC_MISMATCH;    /* CRC mismatch. */
-    }
-#endif
-
-    pFlac->currentFLACFrame.pcmFramesRemaining = pFlac->currentFLACFrame.header.blockSizeInPCMFrames;
-
-    return DRFLAC_SUCCESS;
-}
-
-static drflac_result drflac__seek_flac_frame(drflac* pFlac)
-{
-    int channelCount;
-    int i;
-    drflac_uint16 desiredCRC16;
-#ifndef DR_FLAC_NO_CRC
-    drflac_uint16 actualCRC16;
-#endif
-
-    channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-    for (i = 0; i < channelCount; ++i) {
-        if (!drflac__seek_subframe(&pFlac->bs, &pFlac->currentFLACFrame, i)) {
-            return DRFLAC_ERROR;
-        }
-    }
-
-    /* Padding. */
-    if (!drflac__seek_bits(&pFlac->bs, DRFLAC_CACHE_L1_BITS_REMAINING(&pFlac->bs) & 7)) {
-        return DRFLAC_ERROR;
-    }
-
-    /* CRC. */
-#ifndef DR_FLAC_NO_CRC
-    actualCRC16 = drflac__flush_crc16(&pFlac->bs);
-#endif
-    if (!drflac__read_uint16(&pFlac->bs, 16, &desiredCRC16)) {
-        return DRFLAC_AT_END;
-    }
-
-#ifndef DR_FLAC_NO_CRC
-    if (actualCRC16 != desiredCRC16) {
-        return DRFLAC_CRC_MISMATCH;    /* CRC mismatch. */
-    }
-#endif
-
-    return DRFLAC_SUCCESS;
-}
-
-static drflac_bool32 drflac__read_and_decode_next_flac_frame(drflac* pFlac)
-{
-    DRFLAC_ASSERT(pFlac != NULL);
-
-    for (;;) {
-        drflac_result result;
-
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-
-        result = drflac__decode_flac_frame(pFlac);
-        if (result != DRFLAC_SUCCESS) {
-            if (result == DRFLAC_CRC_MISMATCH) {
-                continue;   /* CRC mismatch. Skip to the next frame. */
-            } else {
-                return DRFLAC_FALSE;
-            }
-        }
-
-        return DRFLAC_TRUE;
-    }
-}
-
-static void drflac__get_pcm_frame_range_of_current_flac_frame(drflac* pFlac, drflac_uint64* pFirstPCMFrame, drflac_uint64* pLastPCMFrame)
-{
-    drflac_uint64 firstPCMFrame;
-    drflac_uint64 lastPCMFrame;
-
-    DRFLAC_ASSERT(pFlac != NULL);
-
-    firstPCMFrame = pFlac->currentFLACFrame.header.pcmFrameNumber;
-    if (firstPCMFrame == 0) {
-        firstPCMFrame = ((drflac_uint64)pFlac->currentFLACFrame.header.flacFrameNumber) * pFlac->maxBlockSizeInPCMFrames;
-    }
-
-    lastPCMFrame = firstPCMFrame + pFlac->currentFLACFrame.header.blockSizeInPCMFrames;
-    if (lastPCMFrame > 0) {
-        lastPCMFrame -= 1; /* Needs to be zero based. */
-    }
-
-    if (pFirstPCMFrame) {
-        *pFirstPCMFrame = firstPCMFrame;
-    }
-    if (pLastPCMFrame) {
-        *pLastPCMFrame = lastPCMFrame;
-    }
-}
-
-static drflac_bool32 drflac__seek_to_first_frame(drflac* pFlac)
-{
-    drflac_bool32 result;
-
-    DRFLAC_ASSERT(pFlac != NULL);
-
-    result = drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes);
-
-    DRFLAC_ZERO_MEMORY(&pFlac->currentFLACFrame, sizeof(pFlac->currentFLACFrame));
-    pFlac->currentPCMFrame = 0;
-
-    return result;
-}
-
-static DRFLAC_INLINE drflac_result drflac__seek_to_next_flac_frame(drflac* pFlac)
-{
-    /* This function should only ever be called while the decoder is sitting on the first byte past the FRAME_HEADER section. */
-    DRFLAC_ASSERT(pFlac != NULL);
-    return drflac__seek_flac_frame(pFlac);
-}
-
-
-static drflac_uint64 drflac__seek_forward_by_pcm_frames(drflac* pFlac, drflac_uint64 pcmFramesToSeek)
-{
-    drflac_uint64 pcmFramesRead = 0;
-    while (pcmFramesToSeek > 0) {
-        if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                break;  /* Couldn't read the next frame, so just break from the loop and return. */
-            }
-        } else {
-            if (pFlac->currentFLACFrame.pcmFramesRemaining > pcmFramesToSeek) {
-                pcmFramesRead   += pcmFramesToSeek;
-                pFlac->currentFLACFrame.pcmFramesRemaining -= (drflac_uint32)pcmFramesToSeek;   /* <-- Safe cast. Will always be < currentFrame.pcmFramesRemaining < 65536. */
-                pcmFramesToSeek  = 0;
-            } else {
-                pcmFramesRead   += pFlac->currentFLACFrame.pcmFramesRemaining;
-                pcmFramesToSeek -= pFlac->currentFLACFrame.pcmFramesRemaining;
-                pFlac->currentFLACFrame.pcmFramesRemaining = 0;
-            }
-        }
-    }
-
-    pFlac->currentPCMFrame += pcmFramesRead;
-    return pcmFramesRead;
-}
-
-
-static drflac_bool32 drflac__seek_to_pcm_frame__brute_force(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    drflac_bool32 isMidFrame = DRFLAC_FALSE;
-    drflac_uint64 runningPCMFrameCount;
-
-    DRFLAC_ASSERT(pFlac != NULL);
-
-    /* If we are seeking forward we start from the current position. Otherwise we need to start all the way from the start of the file. */
-    if (pcmFrameIndex >= pFlac->currentPCMFrame) {
-        /* Seeking forward. Need to seek from the current position. */
-        runningPCMFrameCount = pFlac->currentPCMFrame;
-
-        /* The frame header for the first frame may not yet have been read. We need to do that if necessary. */
-        if (pFlac->currentPCMFrame == 0 && pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            isMidFrame = DRFLAC_TRUE;
-        }
-    } else {
-        /* Seeking backwards. Need to seek from the start of the file. */
-        runningPCMFrameCount = 0;
-
-        /* Move back to the start. */
-        if (!drflac__seek_to_first_frame(pFlac)) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Decode the first frame in preparation for sample-exact seeking below. */
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    /*
-    We need to as quickly as possible find the frame that contains the target sample. To do this, we iterate over each frame and inspect its
-    header. If based on the header we can determine that the frame contains the sample, we do a full decode of that frame.
-    */
-    for (;;) {
-        drflac_uint64 pcmFrameCountInThisFLACFrame;
-        drflac_uint64 firstPCMFrameInFLACFrame = 0;
-        drflac_uint64 lastPCMFrameInFLACFrame = 0;
-
-        drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &firstPCMFrameInFLACFrame, &lastPCMFrameInFLACFrame);
-
-        pcmFrameCountInThisFLACFrame = (lastPCMFrameInFLACFrame - firstPCMFrameInFLACFrame) + 1;
-        if (pcmFrameIndex < (runningPCMFrameCount + pcmFrameCountInThisFLACFrame)) {
-            /*
-            The sample should be in this frame. We need to fully decode it, however if it's an invalid frame (a CRC mismatch), we need to pretend
-            it never existed and keep iterating.
-            */
-            drflac_uint64 pcmFramesToDecode = pcmFrameIndex - runningPCMFrameCount;
-
-            if (!isMidFrame) {
-                drflac_result result = drflac__decode_flac_frame(pFlac);
-                if (result == DRFLAC_SUCCESS) {
-                    /* The frame is valid. We just need to skip over some samples to ensure it's sample-exact. */
-                    return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;  /* <-- If this fails, something bad has happened (it should never fail). */
-                } else {
-                    if (result == DRFLAC_CRC_MISMATCH) {
-                        goto next_iteration;   /* CRC mismatch. Pretend this frame never existed. */
-                    } else {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                /* We started seeking mid-frame which means we need to skip the frame decoding part. */
-                return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;
-            }
-        } else {
-            /*
-            It's not in this frame. We need to seek past the frame, but check if there was a CRC mismatch. If so, we pretend this
-            frame never existed and leave the running sample count untouched.
-            */
-            if (!isMidFrame) {
-                drflac_result result = drflac__seek_to_next_flac_frame(pFlac);
-                if (result == DRFLAC_SUCCESS) {
-                    runningPCMFrameCount += pcmFrameCountInThisFLACFrame;
-                } else {
-                    if (result == DRFLAC_CRC_MISMATCH) {
-                        goto next_iteration;   /* CRC mismatch. Pretend this frame never existed. */
-                    } else {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                /*
-                We started seeking mid-frame which means we need to seek by reading to the end of the frame instead of with
-                drflac__seek_to_next_flac_frame() which only works if the decoder is sitting on the byte just after the frame header.
-                */
-                runningPCMFrameCount += pFlac->currentFLACFrame.pcmFramesRemaining;
-                pFlac->currentFLACFrame.pcmFramesRemaining = 0;
-                isMidFrame = DRFLAC_FALSE;
-            }
-
-            /* If we are seeking to the end of the file and we've just hit it, we're done. */
-            if (pcmFrameIndex == pFlac->totalPCMFrameCount && runningPCMFrameCount == pFlac->totalPCMFrameCount) {
-                return DRFLAC_TRUE;
-            }
-        }
-
-    next_iteration:
-        /* Grab the next frame in preparation for the next iteration. */
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-    }
-}
-
-
-#if !defined(DR_FLAC_NO_CRC)
-/*
-We use an average compression ratio to determine our approximate start location. FLAC files are generally about 50%-70% the size of their
-uncompressed counterparts so we'll use this as a basis. I'm going to split the middle and use a factor of 0.6 to determine the starting
-location.
-*/
-#define DRFLAC_BINARY_SEARCH_APPROX_COMPRESSION_RATIO 0.6f
-
-static drflac_bool32 drflac__seek_to_approximate_flac_frame_to_byte(drflac* pFlac, drflac_uint64 targetByte, drflac_uint64 rangeLo, drflac_uint64 rangeHi, drflac_uint64* pLastSuccessfulSeekOffset)
-{
-    DRFLAC_ASSERT(pFlac != NULL);
-    DRFLAC_ASSERT(pLastSuccessfulSeekOffset != NULL);
-    DRFLAC_ASSERT(targetByte >= rangeLo);
-    DRFLAC_ASSERT(targetByte <= rangeHi);
-
-    *pLastSuccessfulSeekOffset = pFlac->firstFLACFramePosInBytes;
-
-    for (;;) {
-        /* After rangeLo == rangeHi == targetByte fails, we need to break out. */
-        drflac_uint64 lastTargetByte = targetByte;
-
-        /* When seeking to a byte, failure probably means we've attempted to seek beyond the end of the stream. To counter this we just halve it each attempt. */
-        if (!drflac__seek_to_byte(&pFlac->bs, targetByte)) {
-            /* If we couldn't even seek to the first byte in the stream we have a problem. Just abandon the whole thing. */
-            if (targetByte == 0) {
-                drflac__seek_to_first_frame(pFlac); /* Try to recover. */
-                return DRFLAC_FALSE;
-            }
-
-            /* Halve the byte location and continue. */
-            targetByte = rangeLo + ((rangeHi - rangeLo)/2);
-            rangeHi = targetByte;
-        } else {
-            /* Getting here should mean that we have seeked to an appropriate byte. */
-
-            /* Clear the details of the FLAC frame so we don't misreport data. */
-            DRFLAC_ZERO_MEMORY(&pFlac->currentFLACFrame, sizeof(pFlac->currentFLACFrame));
-
-            /*
-            Now seek to the next FLAC frame. We need to decode the entire frame (not just the header) because it's possible for the header to incorrectly pass the
-            CRC check and return bad data. We need to decode the entire frame to be more certain. Although this seems unlikely, this has happened to me in testing
-            so it needs to stay this way for now.
-            */
-#if 1
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                /* Halve the byte location and continue. */
-                targetByte = rangeLo + ((rangeHi - rangeLo)/2);
-                rangeHi = targetByte;
-            } else {
-                break;
-            }
-#else
-            if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                /* Halve the byte location and continue. */
-                targetByte = rangeLo + ((rangeHi - rangeLo)/2);
-                rangeHi = targetByte;
-            } else {
-                break;
-            }
-#endif
-        }
-
-        /* We already tried this byte and there are no more to try, break out. */
-        if(targetByte == lastTargetByte) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    /* The current PCM frame needs to be updated based on the frame we just seeked to. */
-    drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &pFlac->currentPCMFrame, NULL);
-
-    DRFLAC_ASSERT(targetByte <= rangeHi);
-
-    *pLastSuccessfulSeekOffset = targetByte;
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(drflac* pFlac, drflac_uint64 offset)
-{
-    /* This section of code would be used if we were only decoding the FLAC frame header when calling drflac__seek_to_approximate_flac_frame_to_byte(). */
-#if 0
-    if (drflac__decode_flac_frame(pFlac) != DRFLAC_SUCCESS) {
-        /* We failed to decode this frame which may be due to it being corrupt. We'll just use the next valid FLAC frame. */
-        if (drflac__read_and_decode_next_flac_frame(pFlac) == DRFLAC_FALSE) {
-            return DRFLAC_FALSE;
-        }
-    }
-#endif
-
-    return drflac__seek_forward_by_pcm_frames(pFlac, offset) == offset;
-}
-
-
-static drflac_bool32 drflac__seek_to_pcm_frame__binary_search_internal(drflac* pFlac, drflac_uint64 pcmFrameIndex, drflac_uint64 byteRangeLo, drflac_uint64 byteRangeHi)
-{
-    /* This assumes pFlac->currentPCMFrame is sitting on byteRangeLo upon entry. */
-
-    drflac_uint64 targetByte;
-    drflac_uint64 pcmRangeLo = pFlac->totalPCMFrameCount;
-    drflac_uint64 pcmRangeHi = 0;
-    drflac_uint64 lastSuccessfulSeekOffset = (drflac_uint64)-1;
-    drflac_uint64 closestSeekOffsetBeforeTargetPCMFrame = byteRangeLo;
-    drflac_uint32 seekForwardThreshold = (pFlac->maxBlockSizeInPCMFrames != 0) ? pFlac->maxBlockSizeInPCMFrames*2 : 4096;
-
-    targetByte = byteRangeLo + (drflac_uint64)(((drflac_int64)((pcmFrameIndex - pFlac->currentPCMFrame) * pFlac->channels * pFlac->bitsPerSample)/8.0f) * DRFLAC_BINARY_SEARCH_APPROX_COMPRESSION_RATIO);
-    if (targetByte > byteRangeHi) {
-        targetByte = byteRangeHi;
-    }
-
-    for (;;) {
-        if (drflac__seek_to_approximate_flac_frame_to_byte(pFlac, targetByte, byteRangeLo, byteRangeHi, &lastSuccessfulSeekOffset)) {
-            /* We found a FLAC frame. We need to check if it contains the sample we're looking for. */
-            drflac_uint64 newPCMRangeLo;
-            drflac_uint64 newPCMRangeHi;
-            drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &newPCMRangeLo, &newPCMRangeHi);
-
-            /* If we selected the same frame, it means we should be pretty close. Just decode the rest. */
-            if (pcmRangeLo == newPCMRangeLo) {
-                if (!drflac__seek_to_approximate_flac_frame_to_byte(pFlac, closestSeekOffsetBeforeTargetPCMFrame, closestSeekOffsetBeforeTargetPCMFrame, byteRangeHi, &lastSuccessfulSeekOffset)) {
-                    break;  /* Failed to seek to closest frame. */
-                }
-
-                if (drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(pFlac, pcmFrameIndex - pFlac->currentPCMFrame)) {
-                    return DRFLAC_TRUE;
-                } else {
-                    break;  /* Failed to seek forward. */
-                }
-            }
-
-            pcmRangeLo = newPCMRangeLo;
-            pcmRangeHi = newPCMRangeHi;
-
-            if (pcmRangeLo <= pcmFrameIndex && pcmRangeHi >= pcmFrameIndex) {
-                /* The target PCM frame is in this FLAC frame. */
-                if (drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(pFlac, pcmFrameIndex - pFlac->currentPCMFrame) ) {
-                    return DRFLAC_TRUE;
-                } else {
-                    break;  /* Failed to seek to FLAC frame. */
-                }
-            } else {
-                const float approxCompressionRatio = (drflac_int64)(lastSuccessfulSeekOffset - pFlac->firstFLACFramePosInBytes) / ((drflac_int64)(pcmRangeLo * pFlac->channels * pFlac->bitsPerSample)/8.0f);
-
-                if (pcmRangeLo > pcmFrameIndex) {
-                    /* We seeked too far forward. We need to move our target byte backward and try again. */
-                    byteRangeHi = lastSuccessfulSeekOffset;
-                    if (byteRangeLo > byteRangeHi) {
-                        byteRangeLo = byteRangeHi;
-                    }
-
-                    targetByte = byteRangeLo + ((byteRangeHi - byteRangeLo) / 2);
-                    if (targetByte < byteRangeLo) {
-                        targetByte = byteRangeLo;
-                    }
-                } else /*if (pcmRangeHi < pcmFrameIndex)*/ {
-                    /* We didn't seek far enough. We need to move our target byte forward and try again. */
-
-                    /* If we're close enough we can just seek forward. */
-                    if ((pcmFrameIndex - pcmRangeLo) < seekForwardThreshold) {
-                        if (drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(pFlac, pcmFrameIndex - pFlac->currentPCMFrame)) {
-                            return DRFLAC_TRUE;
-                        } else {
-                            break;  /* Failed to seek to FLAC frame. */
-                        }
-                    } else {
-                        byteRangeLo = lastSuccessfulSeekOffset;
-                        if (byteRangeHi < byteRangeLo) {
-                            byteRangeHi = byteRangeLo;
-                        }
-
-                        targetByte = lastSuccessfulSeekOffset + (drflac_uint64)(((drflac_int64)((pcmFrameIndex-pcmRangeLo) * pFlac->channels * pFlac->bitsPerSample)/8.0f) * approxCompressionRatio);
-                        if (targetByte > byteRangeHi) {
-                            targetByte = byteRangeHi;
-                        }
-
-                        if (closestSeekOffsetBeforeTargetPCMFrame < lastSuccessfulSeekOffset) {
-                            closestSeekOffsetBeforeTargetPCMFrame = lastSuccessfulSeekOffset;
-                        }
-                    }
-                }
-            }
-        } else {
-            /* Getting here is really bad. We just recover as best we can, but moving to the first frame in the stream, and then abort. */
-            break;
-        }
-    }
-
-    drflac__seek_to_first_frame(pFlac); /* <-- Try to recover. */
-    return DRFLAC_FALSE;
-}
-
-static drflac_bool32 drflac__seek_to_pcm_frame__binary_search(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    drflac_uint64 byteRangeLo;
-    drflac_uint64 byteRangeHi;
-    drflac_uint32 seekForwardThreshold = (pFlac->maxBlockSizeInPCMFrames != 0) ? pFlac->maxBlockSizeInPCMFrames*2 : 4096;
-
-    /* Our algorithm currently assumes the FLAC stream is currently sitting at the start. */
-    if (drflac__seek_to_first_frame(pFlac) == DRFLAC_FALSE) {
-        return DRFLAC_FALSE;
-    }
-
-    /* If we're close enough to the start, just move to the start and seek forward. */
-    if (pcmFrameIndex < seekForwardThreshold) {
-        return drflac__seek_forward_by_pcm_frames(pFlac, pcmFrameIndex) == pcmFrameIndex;
-    }
-
-    /*
-    Our starting byte range is the byte position of the first FLAC frame and the approximate end of the file as if it were completely uncompressed. This ensures
-    the entire file is included, even though most of the time it'll exceed the end of the actual stream. This is OK as the frame searching logic will handle it.
-    */
-    byteRangeLo = pFlac->firstFLACFramePosInBytes;
-    byteRangeHi = pFlac->firstFLACFramePosInBytes + (drflac_uint64)((drflac_int64)(pFlac->totalPCMFrameCount * pFlac->channels * pFlac->bitsPerSample)/8.0f);
-
-    return drflac__seek_to_pcm_frame__binary_search_internal(pFlac, pcmFrameIndex, byteRangeLo, byteRangeHi);
-}
-#endif  /* !DR_FLAC_NO_CRC */
-
-static drflac_bool32 drflac__seek_to_pcm_frame__seek_table(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    drflac_uint32 iClosestSeekpoint = 0;
-    drflac_bool32 isMidFrame = DRFLAC_FALSE;
-    drflac_uint64 runningPCMFrameCount;
-    drflac_uint32 iSeekpoint;
-
-
-    DRFLAC_ASSERT(pFlac != NULL);
-
-    if (pFlac->pSeekpoints == NULL || pFlac->seekpointCount == 0) {
-        return DRFLAC_FALSE;
-    }
-
-    for (iSeekpoint = 0; iSeekpoint < pFlac->seekpointCount; ++iSeekpoint) {
-        if (pFlac->pSeekpoints[iSeekpoint].firstPCMFrame >= pcmFrameIndex) {
-            break;
-        }
-
-        iClosestSeekpoint = iSeekpoint;
-    }
-
-    /* There's been cases where the seek table contains only zeros. We need to do some basic validation on the closest seekpoint. */
-    if (pFlac->pSeekpoints[iClosestSeekpoint].pcmFrameCount == 0 || pFlac->pSeekpoints[iClosestSeekpoint].pcmFrameCount > pFlac->maxBlockSizeInPCMFrames) {
-        return DRFLAC_FALSE;
-    }
-    if (pFlac->pSeekpoints[iClosestSeekpoint].firstPCMFrame > pFlac->totalPCMFrameCount && pFlac->totalPCMFrameCount > 0) {
-        return DRFLAC_FALSE;
-    }
-
-#if !defined(DR_FLAC_NO_CRC)
-    /* At this point we should know the closest seek point. We can use a binary search for this. We need to know the total sample count for this. */
-    if (pFlac->totalPCMFrameCount > 0) {
-        drflac_uint64 byteRangeLo;
-        drflac_uint64 byteRangeHi;
-
-        byteRangeHi = pFlac->firstFLACFramePosInBytes + (drflac_uint64)((drflac_int64)(pFlac->totalPCMFrameCount * pFlac->channels * pFlac->bitsPerSample)/8.0f);
-        byteRangeLo = pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset;
-
-        /*
-        If our closest seek point is not the last one, we only need to search between it and the next one. The section below calculates an appropriate starting
-        value for byteRangeHi which will clamp it appropriately.
-
-        Note that the next seekpoint must have an offset greater than the closest seekpoint because otherwise our binary search algorithm will break down. There
-        have been cases where a seektable consists of seek points where every byte offset is set to 0 which causes problems. If this happens we need to abort.
-        */
-        if (iClosestSeekpoint < pFlac->seekpointCount-1) {
-            drflac_uint32 iNextSeekpoint = iClosestSeekpoint + 1;
-
-            /* Basic validation on the seekpoints to ensure they're usable. */
-            if (pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset >= pFlac->pSeekpoints[iNextSeekpoint].flacFrameOffset || pFlac->pSeekpoints[iNextSeekpoint].pcmFrameCount == 0) {
-                return DRFLAC_FALSE;    /* The next seekpoint doesn't look right. The seek table cannot be trusted from here. Abort. */
-            }
-
-            if (pFlac->pSeekpoints[iNextSeekpoint].firstPCMFrame != (((drflac_uint64)0xFFFFFFFF << 32) | 0xFFFFFFFF)) { /* Make sure it's not a placeholder seekpoint. */
-                byteRangeHi = pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iNextSeekpoint].flacFrameOffset - 1; /* byteRangeHi must be zero based. */
-            }
-        }
-
-        if (drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset)) {
-            if (drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &pFlac->currentPCMFrame, NULL);
-
-                if (drflac__seek_to_pcm_frame__binary_search_internal(pFlac, pcmFrameIndex, byteRangeLo, byteRangeHi)) {
-                    return DRFLAC_TRUE;
-                }
-            }
-        }
-    }
-#endif  /* !DR_FLAC_NO_CRC */
-
-    /* Getting here means we need to use a slower algorithm because the binary search method failed or cannot be used. */
-
-    /*
-    If we are seeking forward and the closest seekpoint is _before_ the current sample, we just seek forward from where we are. Otherwise we start seeking
-    from the seekpoint's first sample.
-    */
-    if (pcmFrameIndex >= pFlac->currentPCMFrame && pFlac->pSeekpoints[iClosestSeekpoint].firstPCMFrame <= pFlac->currentPCMFrame) {
-        /* Optimized case. Just seek forward from where we are. */
-        runningPCMFrameCount = pFlac->currentPCMFrame;
-
-        /* The frame header for the first frame may not yet have been read. We need to do that if necessary. */
-        if (pFlac->currentPCMFrame == 0 && pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            isMidFrame = DRFLAC_TRUE;
-        }
-    } else {
-        /* Slower case. Seek to the start of the seekpoint and then seek forward from there. */
-        runningPCMFrameCount = pFlac->pSeekpoints[iClosestSeekpoint].firstPCMFrame;
-
-        if (!drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset)) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Grab the frame the seekpoint is sitting on in preparation for the sample-exact seeking below. */
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    for (;;) {
-        drflac_uint64 pcmFrameCountInThisFLACFrame;
-        drflac_uint64 firstPCMFrameInFLACFrame = 0;
-        drflac_uint64 lastPCMFrameInFLACFrame = 0;
-
-        drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &firstPCMFrameInFLACFrame, &lastPCMFrameInFLACFrame);
-
-        pcmFrameCountInThisFLACFrame = (lastPCMFrameInFLACFrame - firstPCMFrameInFLACFrame) + 1;
-        if (pcmFrameIndex < (runningPCMFrameCount + pcmFrameCountInThisFLACFrame)) {
-            /*
-            The sample should be in this frame. We need to fully decode it, but if it's an invalid frame (a CRC mismatch) we need to pretend
-            it never existed and keep iterating.
-            */
-            drflac_uint64 pcmFramesToDecode = pcmFrameIndex - runningPCMFrameCount;
-
-            if (!isMidFrame) {
-                drflac_result result = drflac__decode_flac_frame(pFlac);
-                if (result == DRFLAC_SUCCESS) {
-                    /* The frame is valid. We just need to skip over some samples to ensure it's sample-exact. */
-                    return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;  /* <-- If this fails, something bad has happened (it should never fail). */
-                } else {
-                    if (result == DRFLAC_CRC_MISMATCH) {
-                        goto next_iteration;   /* CRC mismatch. Pretend this frame never existed. */
-                    } else {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                /* We started seeking mid-frame which means we need to skip the frame decoding part. */
-                return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;
-            }
-        } else {
-            /*
-            It's not in this frame. We need to seek past the frame, but check if there was a CRC mismatch. If so, we pretend this
-            frame never existed and leave the running sample count untouched.
-            */
-            if (!isMidFrame) {
-                drflac_result result = drflac__seek_to_next_flac_frame(pFlac);
-                if (result == DRFLAC_SUCCESS) {
-                    runningPCMFrameCount += pcmFrameCountInThisFLACFrame;
-                } else {
-                    if (result == DRFLAC_CRC_MISMATCH) {
-                        goto next_iteration;   /* CRC mismatch. Pretend this frame never existed. */
-                    } else {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                /*
-                We started seeking mid-frame which means we need to seek by reading to the end of the frame instead of with
-                drflac__seek_to_next_flac_frame() which only works if the decoder is sitting on the byte just after the frame header.
-                */
-                runningPCMFrameCount += pFlac->currentFLACFrame.pcmFramesRemaining;
-                pFlac->currentFLACFrame.pcmFramesRemaining = 0;
-                isMidFrame = DRFLAC_FALSE;
-            }
-
-            /* If we are seeking to the end of the file and we've just hit it, we're done. */
-            if (pcmFrameIndex == pFlac->totalPCMFrameCount && runningPCMFrameCount == pFlac->totalPCMFrameCount) {
-                return DRFLAC_TRUE;
-            }
-        }
-
-    next_iteration:
-        /* Grab the next frame in preparation for the next iteration. */
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-    }
-}
-
-
-#ifndef DR_FLAC_NO_OGG
-typedef struct
-{
-    drflac_uint8 capturePattern[4];  /* Should be "OggS" */
-    drflac_uint8 structureVersion;   /* Always 0. */
-    drflac_uint8 headerType;
-    drflac_uint64 granulePosition;
-    drflac_uint32 serialNumber;
-    drflac_uint32 sequenceNumber;
-    drflac_uint32 checksum;
-    drflac_uint8 segmentCount;
-    drflac_uint8 segmentTable[255];
-} drflac_ogg_page_header;
-#endif
-
-typedef struct
-{
-    drflac_read_proc onRead;
-    drflac_seek_proc onSeek;
-    drflac_meta_proc onMeta;
-    drflac_container container;
-    void* pUserData;
-    void* pUserDataMD;
-    drflac_uint32 sampleRate;
-    drflac_uint8  channels;
-    drflac_uint8  bitsPerSample;
-    drflac_uint64 totalPCMFrameCount;
-    drflac_uint16 maxBlockSizeInPCMFrames;
-    drflac_uint64 runningFilePos;
-    drflac_bool32 hasStreamInfoBlock;
-    drflac_bool32 hasMetadataBlocks;
-    drflac_bs bs;                           /* <-- A bit streamer is required for loading data during initialization. */
-    drflac_frame_header firstFrameHeader;   /* <-- The header of the first frame that was read during relaxed initalization. Only set if there is no STREAMINFO block. */
-
-#ifndef DR_FLAC_NO_OGG
-    drflac_uint32 oggSerial;
-    drflac_uint64 oggFirstBytePos;
-    drflac_ogg_page_header oggBosHeader;
-#endif
-} drflac_init_info;
-
-static DRFLAC_INLINE void drflac__decode_block_header(drflac_uint32 blockHeader, drflac_uint8* isLastBlock, drflac_uint8* blockType, drflac_uint32* blockSize)
-{
-    blockHeader = drflac__be2host_32(blockHeader);
-    *isLastBlock = (drflac_uint8)((blockHeader & 0x80000000UL) >> 31);
-    *blockType   = (drflac_uint8)((blockHeader & 0x7F000000UL) >> 24);
-    *blockSize   =                (blockHeader & 0x00FFFFFFUL);
-}
-
-static DRFLAC_INLINE drflac_bool32 drflac__read_and_decode_block_header(drflac_read_proc onRead, void* pUserData, drflac_uint8* isLastBlock, drflac_uint8* blockType, drflac_uint32* blockSize)
-{
-    drflac_uint32 blockHeader;
-
-    *blockSize = 0;
-    if (onRead(pUserData, &blockHeader, 4) != 4) {
-        return DRFLAC_FALSE;
-    }
-
-    drflac__decode_block_header(blockHeader, isLastBlock, blockType, blockSize);
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__read_streaminfo(drflac_read_proc onRead, void* pUserData, drflac_streaminfo* pStreamInfo)
-{
-    drflac_uint32 blockSizes;
-    drflac_uint64 frameSizes = 0;
-    drflac_uint64 importantProps;
-    drflac_uint8 md5[16];
-
-    /* min/max block size. */
-    if (onRead(pUserData, &blockSizes, 4) != 4) {
-        return DRFLAC_FALSE;
-    }
-
-    /* min/max frame size. */
-    if (onRead(pUserData, &frameSizes, 6) != 6) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Sample rate, channels, bits per sample and total sample count. */
-    if (onRead(pUserData, &importantProps, 8) != 8) {
-        return DRFLAC_FALSE;
-    }
-
-    /* MD5 */
-    if (onRead(pUserData, md5, sizeof(md5)) != sizeof(md5)) {
-        return DRFLAC_FALSE;
-    }
-
-    blockSizes     = drflac__be2host_32(blockSizes);
-    frameSizes     = drflac__be2host_64(frameSizes);
-    importantProps = drflac__be2host_64(importantProps);
-
-    pStreamInfo->minBlockSizeInPCMFrames = (drflac_uint16)((blockSizes & 0xFFFF0000) >> 16);
-    pStreamInfo->maxBlockSizeInPCMFrames = (drflac_uint16) (blockSizes & 0x0000FFFF);
-    pStreamInfo->minFrameSizeInPCMFrames = (drflac_uint32)((frameSizes     &  (((drflac_uint64)0x00FFFFFF << 16) << 24)) >> 40);
-    pStreamInfo->maxFrameSizeInPCMFrames = (drflac_uint32)((frameSizes     &  (((drflac_uint64)0x00FFFFFF << 16) <<  0)) >> 16);
-    pStreamInfo->sampleRate              = (drflac_uint32)((importantProps &  (((drflac_uint64)0x000FFFFF << 16) << 28)) >> 44);
-    pStreamInfo->channels                = (drflac_uint8 )((importantProps &  (((drflac_uint64)0x0000000E << 16) << 24)) >> 41) + 1;
-    pStreamInfo->bitsPerSample           = (drflac_uint8 )((importantProps &  (((drflac_uint64)0x0000001F << 16) << 20)) >> 36) + 1;
-    pStreamInfo->totalPCMFrameCount      =                ((importantProps & ((((drflac_uint64)0x0000000F << 16) << 16) | 0xFFFFFFFF)));
-    DRFLAC_COPY_MEMORY(pStreamInfo->md5, md5, sizeof(md5));
-
-    return DRFLAC_TRUE;
-}
-
-
-static void* drflac__malloc_default(size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRFLAC_MALLOC(sz);
-}
-
-static void* drflac__realloc_default(void* p, size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRFLAC_REALLOC(p, sz);
-}
-
-static void drflac__free_default(void* p, void* pUserData)
-{
-    (void)pUserData;
-    DRFLAC_FREE(p);
-}
-
-
-static void* drflac__malloc_from_callbacks(size_t sz, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-
-    if (pAllocationCallbacks->onMalloc != NULL) {
-        return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData);
-    }
-
-    /* Try using realloc(). */
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData);
-    }
-
-    return NULL;
-}
-
-static void* drflac__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData);
-    }
-
-    /* Try emulating realloc() in terms of malloc()/free(). */
-    if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) {
-        void* p2;
-
-        p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData);
-        if (p2 == NULL) {
-            return NULL;
-        }
-
-        if (p != NULL) {
-            DRFLAC_COPY_MEMORY(p2, p, szOld);
-            pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-        }
-
-        return p2;
-    }
-
-    return NULL;
-}
-
-static void drflac__free_from_callbacks(void* p, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (p == NULL || pAllocationCallbacks == NULL) {
-        return;
-    }
-
-    if (pAllocationCallbacks->onFree != NULL) {
-        pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-    }
-}
-
-
-static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_uint64* pFirstFramePos, drflac_uint64* pSeektablePos, drflac_uint32* pSeektableSize, drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    /*
-    We want to keep track of the byte position in the stream of the seektable. At the time of calling this function we know that
-    we'll be sitting on byte 42.
-    */
-    drflac_uint64 runningFilePos = 42;
-    drflac_uint64 seektablePos   = 0;
-    drflac_uint32 seektableSize  = 0;
-
-    for (;;) {
-        drflac_metadata metadata;
-        drflac_uint8 isLastBlock = 0;
-        drflac_uint8 blockType;
-        drflac_uint32 blockSize;
-        if (drflac__read_and_decode_block_header(onRead, pUserData, &isLastBlock, &blockType, &blockSize) == DRFLAC_FALSE) {
-            return DRFLAC_FALSE;
-        }
-        runningFilePos += 4;
-
-        metadata.type = blockType;
-        metadata.pRawData = NULL;
-        metadata.rawDataSize = 0;
-
-        switch (blockType)
-        {
-            case DRFLAC_METADATA_BLOCK_TYPE_APPLICATION:
-            {
-                if (blockSize < 4) {
-                    return DRFLAC_FALSE;
-                }
-
-                if (onMeta) {
-                    void* pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-                    metadata.data.application.id       = drflac__be2host_32(*(drflac_uint32*)pRawData);
-                    metadata.data.application.pData    = (const void*)((drflac_uint8*)pRawData + sizeof(drflac_uint32));
-                    metadata.data.application.dataSize = blockSize - sizeof(drflac_uint32);
-                    onMeta(pUserDataMD, &metadata);
-
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-
-            case DRFLAC_METADATA_BLOCK_TYPE_SEEKTABLE:
-            {
-                seektablePos  = runningFilePos;
-                seektableSize = blockSize;
-
-                if (onMeta) {
-                    drflac_uint32 iSeekpoint;
-                    void* pRawData;
-
-                    pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-                    metadata.data.seektable.seekpointCount = blockSize/sizeof(drflac_seekpoint);
-                    metadata.data.seektable.pSeekpoints = (const drflac_seekpoint*)pRawData;
-
-                    /* Endian swap. */
-                    for (iSeekpoint = 0; iSeekpoint < metadata.data.seektable.seekpointCount; ++iSeekpoint) {
-                        drflac_seekpoint* pSeekpoint = (drflac_seekpoint*)pRawData + iSeekpoint;
-                        pSeekpoint->firstPCMFrame   = drflac__be2host_64(pSeekpoint->firstPCMFrame);
-                        pSeekpoint->flacFrameOffset = drflac__be2host_64(pSeekpoint->flacFrameOffset);
-                        pSeekpoint->pcmFrameCount   = drflac__be2host_16(pSeekpoint->pcmFrameCount);
-                    }
-
-                    onMeta(pUserDataMD, &metadata);
-
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-
-            case DRFLAC_METADATA_BLOCK_TYPE_VORBIS_COMMENT:
-            {
-                if (blockSize < 8) {
-                    return DRFLAC_FALSE;
-                }
-
-                if (onMeta) {
-                    void* pRawData;
-                    const char* pRunningData;
-                    const char* pRunningDataEnd;
-                    drflac_uint32 i;
-
-                    pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-
-                    pRunningData    = (const char*)pRawData;
-                    pRunningDataEnd = (const char*)pRawData + blockSize;
-
-                    metadata.data.vorbis_comment.vendorLength = drflac__le2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-
-                    /* Need space for the rest of the block */
-                    if ((pRunningDataEnd - pRunningData) - 4 < (drflac_int64)metadata.data.vorbis_comment.vendorLength) { /* <-- Note the order of operations to avoid overflow to a valid value */
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.data.vorbis_comment.vendor       = pRunningData;                                            pRunningData += metadata.data.vorbis_comment.vendorLength;
-                    metadata.data.vorbis_comment.commentCount = drflac__le2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-
-                    /* Need space for 'commentCount' comments after the block, which at minimum is a drflac_uint32 per comment */
-                    if ((pRunningDataEnd - pRunningData) / sizeof(drflac_uint32) < metadata.data.vorbis_comment.commentCount) { /* <-- Note the order of operations to avoid overflow to a valid value */
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.data.vorbis_comment.pComments    = pRunningData;
-
-                    /* Check that the comments section is valid before passing it to the callback */
-                    for (i = 0; i < metadata.data.vorbis_comment.commentCount; ++i) {
-                        drflac_uint32 commentLength;
-
-                        if (pRunningDataEnd - pRunningData < 4) {
-                            drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                            return DRFLAC_FALSE;
-                        }
-
-                        commentLength = drflac__le2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                        if (pRunningDataEnd - pRunningData < (drflac_int64)commentLength) { /* <-- Note the order of operations to avoid overflow to a valid value */
-                            drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                            return DRFLAC_FALSE;
-                        }
-                        pRunningData += commentLength;
-                    }
-
-                    onMeta(pUserDataMD, &metadata);
-
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-
-            case DRFLAC_METADATA_BLOCK_TYPE_CUESHEET:
-            {
-                if (blockSize < 396) {
-                    return DRFLAC_FALSE;
-                }
-
-                if (onMeta) {
-                    void* pRawData;
-                    const char* pRunningData;
-                    const char* pRunningDataEnd;
-                    drflac_uint8 iTrack;
-                    drflac_uint8 iIndex;
-
-                    pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-
-                    pRunningData    = (const char*)pRawData;
-                    pRunningDataEnd = (const char*)pRawData + blockSize;
-
-                    DRFLAC_COPY_MEMORY(metadata.data.cuesheet.catalog, pRunningData, 128);                              pRunningData += 128;
-                    metadata.data.cuesheet.leadInSampleCount = drflac__be2host_64(*(const drflac_uint64*)pRunningData); pRunningData += 8;
-                    metadata.data.cuesheet.isCD              = (pRunningData[0] & 0x80) != 0;                           pRunningData += 259;
-                    metadata.data.cuesheet.trackCount        = pRunningData[0];                                         pRunningData += 1;
-                    metadata.data.cuesheet.pTrackData        = pRunningData;
-
-                    /* Check that the cuesheet tracks are valid before passing it to the callback */
-                    for (iTrack = 0; iTrack < metadata.data.cuesheet.trackCount; ++iTrack) {
-                        drflac_uint8 indexCount;
-                        drflac_uint32 indexPointSize;
-
-                        if (pRunningDataEnd - pRunningData < 36) {
-                            drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                            return DRFLAC_FALSE;
-                        }
-
-                        /* Skip to the index point count */
-                        pRunningData += 35;
-                        indexCount = pRunningData[0]; pRunningData += 1;
-                        indexPointSize = indexCount * sizeof(drflac_cuesheet_track_index);
-                        if (pRunningDataEnd - pRunningData < (drflac_int64)indexPointSize) {
-                            drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                            return DRFLAC_FALSE;
-                        }
-
-                        /* Endian swap. */
-                        for (iIndex = 0; iIndex < indexCount; ++iIndex) {
-                            drflac_cuesheet_track_index* pTrack = (drflac_cuesheet_track_index*)pRunningData;
-                            pRunningData += sizeof(drflac_cuesheet_track_index);
-                            pTrack->offset = drflac__be2host_64(pTrack->offset);
-                        }
-                    }
-
-                    onMeta(pUserDataMD, &metadata);
-
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-
-            case DRFLAC_METADATA_BLOCK_TYPE_PICTURE:
-            {
-                if (blockSize < 32) {
-                    return DRFLAC_FALSE;
-                }
-
-                if (onMeta) {
-                    void* pRawData;
-                    const char* pRunningData;
-                    const char* pRunningDataEnd;
-
-                    pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-
-                    pRunningData    = (const char*)pRawData;
-                    pRunningDataEnd = (const char*)pRawData + blockSize;
-
-                    metadata.data.picture.type       = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.mimeLength = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-
-                    /* Need space for the rest of the block */
-                    if ((pRunningDataEnd - pRunningData) - 24 < (drflac_int64)metadata.data.picture.mimeLength) { /* <-- Note the order of operations to avoid overflow to a valid value */
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.data.picture.mime              = pRunningData;                                            pRunningData += metadata.data.picture.mimeLength;
-                    metadata.data.picture.descriptionLength = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-
-                    /* Need space for the rest of the block */
-                    if ((pRunningDataEnd - pRunningData) - 20 < (drflac_int64)metadata.data.picture.descriptionLength) { /* <-- Note the order of operations to avoid overflow to a valid value */
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.data.picture.description     = pRunningData;                                            pRunningData += metadata.data.picture.descriptionLength;
-                    metadata.data.picture.width           = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.height          = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.colorDepth      = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.indexColorCount = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.pictureDataSize = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.pPictureData    = (const drflac_uint8*)pRunningData;
-
-                    /* Need space for the picture after the block */
-                    if (pRunningDataEnd - pRunningData < (drflac_int64)metadata.data.picture.pictureDataSize) { /* <-- Note the order of operations to avoid overflow to a valid value */
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-
-                    onMeta(pUserDataMD, &metadata);
-
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-
-            case DRFLAC_METADATA_BLOCK_TYPE_PADDING:
-            {
-                if (onMeta) {
-                    metadata.data.padding.unused = 0;
-
-                    /* Padding doesn't have anything meaningful in it, so just skip over it, but make sure the caller is aware of it by firing the callback. */
-                    if (!onSeek(pUserData, blockSize, drflac_seek_origin_current)) {
-                        isLastBlock = DRFLAC_TRUE;  /* An error occurred while seeking. Attempt to recover by treating this as the last block which will in turn terminate the loop. */
-                    } else {
-                        onMeta(pUserDataMD, &metadata);
-                    }
-                }
-            } break;
-
-            case DRFLAC_METADATA_BLOCK_TYPE_INVALID:
-            {
-                /* Invalid chunk. Just skip over this one. */
-                if (onMeta) {
-                    if (!onSeek(pUserData, blockSize, drflac_seek_origin_current)) {
-                        isLastBlock = DRFLAC_TRUE;  /* An error occurred while seeking. Attempt to recover by treating this as the last block which will in turn terminate the loop. */
-                    }
-                }
-            } break;
-
-            default:
-            {
-                /*
-                It's an unknown chunk, but not necessarily invalid. There's a chance more metadata blocks might be defined later on, so we
-                can at the very least report the chunk to the application and let it look at the raw data.
-                */
-                if (onMeta) {
-                    void* pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-                    onMeta(pUserDataMD, &metadata);
-
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-        }
-
-        /* If we're not handling metadata, just skip over the block. If we are, it will have been handled earlier in the switch statement above. */
-        if (onMeta == NULL && blockSize > 0) {
-            if (!onSeek(pUserData, blockSize, drflac_seek_origin_current)) {
-                isLastBlock = DRFLAC_TRUE;
-            }
-        }
-
-        runningFilePos += blockSize;
-        if (isLastBlock) {
-            break;
-        }
-    }
-
-    *pSeektablePos = seektablePos;
-    *pSeektableSize = seektableSize;
-    *pFirstFramePos = runningFilePos;
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__init_private__native(drflac_init_info* pInit, drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_bool32 relaxed)
-{
-    /* Pre Condition: The bit stream should be sitting just past the 4-byte id header. */
-
-    drflac_uint8 isLastBlock;
-    drflac_uint8 blockType;
-    drflac_uint32 blockSize;
-
-    (void)onSeek;
-
-    pInit->container = drflac_container_native;
-
-    /* The first metadata block should be the STREAMINFO block. */
-    if (!drflac__read_and_decode_block_header(onRead, pUserData, &isLastBlock, &blockType, &blockSize)) {
-        return DRFLAC_FALSE;
-    }
-
-    if (blockType != DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO || blockSize != 34) {
-        if (!relaxed) {
-            /* We're opening in strict mode and the first block is not the STREAMINFO block. Error. */
-            return DRFLAC_FALSE;
-        } else {
-            /*
-            Relaxed mode. To open from here we need to just find the first frame and set the sample rate, etc. to whatever is defined
-            for that frame.
-            */
-            pInit->hasStreamInfoBlock = DRFLAC_FALSE;
-            pInit->hasMetadataBlocks  = DRFLAC_FALSE;
-
-            if (!drflac__read_next_flac_frame_header(&pInit->bs, 0, &pInit->firstFrameHeader)) {
-                return DRFLAC_FALSE;    /* Couldn't find a frame. */
-            }
-
-            if (pInit->firstFrameHeader.bitsPerSample == 0) {
-                return DRFLAC_FALSE;    /* Failed to initialize because the first frame depends on the STREAMINFO block, which does not exist. */
-            }
-
-            pInit->sampleRate              = pInit->firstFrameHeader.sampleRate;
-            pInit->channels                = drflac__get_channel_count_from_channel_assignment(pInit->firstFrameHeader.channelAssignment);
-            pInit->bitsPerSample           = pInit->firstFrameHeader.bitsPerSample;
-            pInit->maxBlockSizeInPCMFrames = 65535;   /* <-- See notes here: https://xiph.org/flac/format.html#metadata_block_streaminfo */
-            return DRFLAC_TRUE;
-        }
-    } else {
-        drflac_streaminfo streaminfo;
-        if (!drflac__read_streaminfo(onRead, pUserData, &streaminfo)) {
-            return DRFLAC_FALSE;
-        }
-
-        pInit->hasStreamInfoBlock      = DRFLAC_TRUE;
-        pInit->sampleRate              = streaminfo.sampleRate;
-        pInit->channels                = streaminfo.channels;
-        pInit->bitsPerSample           = streaminfo.bitsPerSample;
-        pInit->totalPCMFrameCount      = streaminfo.totalPCMFrameCount;
-        pInit->maxBlockSizeInPCMFrames = streaminfo.maxBlockSizeInPCMFrames;    /* Don't care about the min block size - only the max (used for determining the size of the memory allocation). */
-        pInit->hasMetadataBlocks       = !isLastBlock;
-
-        if (onMeta) {
-            drflac_metadata metadata;
-            metadata.type = DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO;
-            metadata.pRawData = NULL;
-            metadata.rawDataSize = 0;
-            metadata.data.streaminfo = streaminfo;
-            onMeta(pUserDataMD, &metadata);
-        }
-
-        return DRFLAC_TRUE;
-    }
-}
-
-#ifndef DR_FLAC_NO_OGG
-#define DRFLAC_OGG_MAX_PAGE_SIZE            65307
-#define DRFLAC_OGG_CAPTURE_PATTERN_CRC32    1605413199  /* CRC-32 of "OggS". */
-
-typedef enum
-{
-    drflac_ogg_recover_on_crc_mismatch,
-    drflac_ogg_fail_on_crc_mismatch
-} drflac_ogg_crc_mismatch_recovery;
-
-#ifndef DR_FLAC_NO_CRC
-static drflac_uint32 drflac__crc32_table[] = {
-    0x00000000L, 0x04C11DB7L, 0x09823B6EL, 0x0D4326D9L,
-    0x130476DCL, 0x17C56B6BL, 0x1A864DB2L, 0x1E475005L,
-    0x2608EDB8L, 0x22C9F00FL, 0x2F8AD6D6L, 0x2B4BCB61L,
-    0x350C9B64L, 0x31CD86D3L, 0x3C8EA00AL, 0x384FBDBDL,
-    0x4C11DB70L, 0x48D0C6C7L, 0x4593E01EL, 0x4152FDA9L,
-    0x5F15ADACL, 0x5BD4B01BL, 0x569796C2L, 0x52568B75L,
-    0x6A1936C8L, 0x6ED82B7FL, 0x639B0DA6L, 0x675A1011L,
-    0x791D4014L, 0x7DDC5DA3L, 0x709F7B7AL, 0x745E66CDL,
-    0x9823B6E0L, 0x9CE2AB57L, 0x91A18D8EL, 0x95609039L,
-    0x8B27C03CL, 0x8FE6DD8BL, 0x82A5FB52L, 0x8664E6E5L,
-    0xBE2B5B58L, 0xBAEA46EFL, 0xB7A96036L, 0xB3687D81L,
-    0xAD2F2D84L, 0xA9EE3033L, 0xA4AD16EAL, 0xA06C0B5DL,
-    0xD4326D90L, 0xD0F37027L, 0xDDB056FEL, 0xD9714B49L,
-    0xC7361B4CL, 0xC3F706FBL, 0xCEB42022L, 0xCA753D95L,
-    0xF23A8028L, 0xF6FB9D9FL, 0xFBB8BB46L, 0xFF79A6F1L,
-    0xE13EF6F4L, 0xE5FFEB43L, 0xE8BCCD9AL, 0xEC7DD02DL,
-    0x34867077L, 0x30476DC0L, 0x3D044B19L, 0x39C556AEL,
-    0x278206ABL, 0x23431B1CL, 0x2E003DC5L, 0x2AC12072L,
-    0x128E9DCFL, 0x164F8078L, 0x1B0CA6A1L, 0x1FCDBB16L,
-    0x018AEB13L, 0x054BF6A4L, 0x0808D07DL, 0x0CC9CDCAL,
-    0x7897AB07L, 0x7C56B6B0L, 0x71159069L, 0x75D48DDEL,
-    0x6B93DDDBL, 0x6F52C06CL, 0x6211E6B5L, 0x66D0FB02L,
-    0x5E9F46BFL, 0x5A5E5B08L, 0x571D7DD1L, 0x53DC6066L,
-    0x4D9B3063L, 0x495A2DD4L, 0x44190B0DL, 0x40D816BAL,
-    0xACA5C697L, 0xA864DB20L, 0xA527FDF9L, 0xA1E6E04EL,
-    0xBFA1B04BL, 0xBB60ADFCL, 0xB6238B25L, 0xB2E29692L,
-    0x8AAD2B2FL, 0x8E6C3698L, 0x832F1041L, 0x87EE0DF6L,
-    0x99A95DF3L, 0x9D684044L, 0x902B669DL, 0x94EA7B2AL,
-    0xE0B41DE7L, 0xE4750050L, 0xE9362689L, 0xEDF73B3EL,
-    0xF3B06B3BL, 0xF771768CL, 0xFA325055L, 0xFEF34DE2L,
-    0xC6BCF05FL, 0xC27DEDE8L, 0xCF3ECB31L, 0xCBFFD686L,
-    0xD5B88683L, 0xD1799B34L, 0xDC3ABDEDL, 0xD8FBA05AL,
-    0x690CE0EEL, 0x6DCDFD59L, 0x608EDB80L, 0x644FC637L,
-    0x7A089632L, 0x7EC98B85L, 0x738AAD5CL, 0x774BB0EBL,
-    0x4F040D56L, 0x4BC510E1L, 0x46863638L, 0x42472B8FL,
-    0x5C007B8AL, 0x58C1663DL, 0x558240E4L, 0x51435D53L,
-    0x251D3B9EL, 0x21DC2629L, 0x2C9F00F0L, 0x285E1D47L,
-    0x36194D42L, 0x32D850F5L, 0x3F9B762CL, 0x3B5A6B9BL,
-    0x0315D626L, 0x07D4CB91L, 0x0A97ED48L, 0x0E56F0FFL,
-    0x1011A0FAL, 0x14D0BD4DL, 0x19939B94L, 0x1D528623L,
-    0xF12F560EL, 0xF5EE4BB9L, 0xF8AD6D60L, 0xFC6C70D7L,
-    0xE22B20D2L, 0xE6EA3D65L, 0xEBA91BBCL, 0xEF68060BL,
-    0xD727BBB6L, 0xD3E6A601L, 0xDEA580D8L, 0xDA649D6FL,
-    0xC423CD6AL, 0xC0E2D0DDL, 0xCDA1F604L, 0xC960EBB3L,
-    0xBD3E8D7EL, 0xB9FF90C9L, 0xB4BCB610L, 0xB07DABA7L,
-    0xAE3AFBA2L, 0xAAFBE615L, 0xA7B8C0CCL, 0xA379DD7BL,
-    0x9B3660C6L, 0x9FF77D71L, 0x92B45BA8L, 0x9675461FL,
-    0x8832161AL, 0x8CF30BADL, 0x81B02D74L, 0x857130C3L,
-    0x5D8A9099L, 0x594B8D2EL, 0x5408ABF7L, 0x50C9B640L,
-    0x4E8EE645L, 0x4A4FFBF2L, 0x470CDD2BL, 0x43CDC09CL,
-    0x7B827D21L, 0x7F436096L, 0x7200464FL, 0x76C15BF8L,
-    0x68860BFDL, 0x6C47164AL, 0x61043093L, 0x65C52D24L,
-    0x119B4BE9L, 0x155A565EL, 0x18197087L, 0x1CD86D30L,
-    0x029F3D35L, 0x065E2082L, 0x0B1D065BL, 0x0FDC1BECL,
-    0x3793A651L, 0x3352BBE6L, 0x3E119D3FL, 0x3AD08088L,
-    0x2497D08DL, 0x2056CD3AL, 0x2D15EBE3L, 0x29D4F654L,
-    0xC5A92679L, 0xC1683BCEL, 0xCC2B1D17L, 0xC8EA00A0L,
-    0xD6AD50A5L, 0xD26C4D12L, 0xDF2F6BCBL, 0xDBEE767CL,
-    0xE3A1CBC1L, 0xE760D676L, 0xEA23F0AFL, 0xEEE2ED18L,
-    0xF0A5BD1DL, 0xF464A0AAL, 0xF9278673L, 0xFDE69BC4L,
-    0x89B8FD09L, 0x8D79E0BEL, 0x803AC667L, 0x84FBDBD0L,
-    0x9ABC8BD5L, 0x9E7D9662L, 0x933EB0BBL, 0x97FFAD0CL,
-    0xAFB010B1L, 0xAB710D06L, 0xA6322BDFL, 0xA2F33668L,
-    0xBCB4666DL, 0xB8757BDAL, 0xB5365D03L, 0xB1F740B4L
-};
-#endif
-
-static DRFLAC_INLINE drflac_uint32 drflac_crc32_byte(drflac_uint32 crc32, drflac_uint8 data)
-{
-#ifndef DR_FLAC_NO_CRC
-    return (crc32 << 8) ^ drflac__crc32_table[(drflac_uint8)((crc32 >> 24) & 0xFF) ^ data];
-#else
-    (void)data;
-    return crc32;
-#endif
-}
-
-#if 0
-static DRFLAC_INLINE drflac_uint32 drflac_crc32_uint32(drflac_uint32 crc32, drflac_uint32 data)
-{
-    crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >> 24) & 0xFF));
-    crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >> 16) & 0xFF));
-    crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >>  8) & 0xFF));
-    crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >>  0) & 0xFF));
-    return crc32;
-}
-
-static DRFLAC_INLINE drflac_uint32 drflac_crc32_uint64(drflac_uint32 crc32, drflac_uint64 data)
-{
-    crc32 = drflac_crc32_uint32(crc32, (drflac_uint32)((data >> 32) & 0xFFFFFFFF));
-    crc32 = drflac_crc32_uint32(crc32, (drflac_uint32)((data >>  0) & 0xFFFFFFFF));
-    return crc32;
-}
-#endif
-
-static DRFLAC_INLINE drflac_uint32 drflac_crc32_buffer(drflac_uint32 crc32, drflac_uint8* pData, drflac_uint32 dataSize)
-{
-    /* This can be optimized. */
-    drflac_uint32 i;
-    for (i = 0; i < dataSize; ++i) {
-        crc32 = drflac_crc32_byte(crc32, pData[i]);
-    }
-    return crc32;
-}
-
-
-static DRFLAC_INLINE drflac_bool32 drflac_ogg__is_capture_pattern(drflac_uint8 pattern[4])
-{
-    return pattern[0] == 'O' && pattern[1] == 'g' && pattern[2] == 'g' && pattern[3] == 'S';
-}
-
-static DRFLAC_INLINE drflac_uint32 drflac_ogg__get_page_header_size(drflac_ogg_page_header* pHeader)
-{
-    return 27 + pHeader->segmentCount;
-}
-
-static DRFLAC_INLINE drflac_uint32 drflac_ogg__get_page_body_size(drflac_ogg_page_header* pHeader)
-{
-    drflac_uint32 pageBodySize = 0;
-    int i;
-
-    for (i = 0; i < pHeader->segmentCount; ++i) {
-        pageBodySize += pHeader->segmentTable[i];
-    }
-
-    return pageBodySize;
-}
-
-static drflac_result drflac_ogg__read_page_header_after_capture_pattern(drflac_read_proc onRead, void* pUserData, drflac_ogg_page_header* pHeader, drflac_uint32* pBytesRead, drflac_uint32* pCRC32)
-{
-    drflac_uint8 data[23];
-    drflac_uint32 i;
-
-    DRFLAC_ASSERT(*pCRC32 == DRFLAC_OGG_CAPTURE_PATTERN_CRC32);
-
-    if (onRead(pUserData, data, 23) != 23) {
-        return DRFLAC_AT_END;
-    }
-    *pBytesRead += 23;
-
-    /*
-    It's not actually used, but set the capture pattern to 'OggS' for completeness. Not doing this will cause static analysers to complain about
-    us trying to access uninitialized data. We could alternatively just comment out this member of the drflac_ogg_page_header structure, but I
-    like to have it map to the structure of the underlying data.
-    */
-    pHeader->capturePattern[0] = 'O';
-    pHeader->capturePattern[1] = 'g';
-    pHeader->capturePattern[2] = 'g';
-    pHeader->capturePattern[3] = 'S';
-
-    pHeader->structureVersion = data[0];
-    pHeader->headerType       = data[1];
-    DRFLAC_COPY_MEMORY(&pHeader->granulePosition, &data[ 2], 8);
-    DRFLAC_COPY_MEMORY(&pHeader->serialNumber,    &data[10], 4);
-    DRFLAC_COPY_MEMORY(&pHeader->sequenceNumber,  &data[14], 4);
-    DRFLAC_COPY_MEMORY(&pHeader->checksum,        &data[18], 4);
-    pHeader->segmentCount     = data[22];
-
-    /* Calculate the CRC. Note that for the calculation the checksum part of the page needs to be set to 0. */
-    data[18] = 0;
-    data[19] = 0;
-    data[20] = 0;
-    data[21] = 0;
-
-    for (i = 0; i < 23; ++i) {
-        *pCRC32 = drflac_crc32_byte(*pCRC32, data[i]);
-    }
-
-
-    if (onRead(pUserData, pHeader->segmentTable, pHeader->segmentCount) != pHeader->segmentCount) {
-        return DRFLAC_AT_END;
-    }
-    *pBytesRead += pHeader->segmentCount;
-
-    for (i = 0; i < pHeader->segmentCount; ++i) {
-        *pCRC32 = drflac_crc32_byte(*pCRC32, pHeader->segmentTable[i]);
-    }
-
-    return DRFLAC_SUCCESS;
-}
-
-static drflac_result drflac_ogg__read_page_header(drflac_read_proc onRead, void* pUserData, drflac_ogg_page_header* pHeader, drflac_uint32* pBytesRead, drflac_uint32* pCRC32)
-{
-    drflac_uint8 id[4];
-
-    *pBytesRead = 0;
-
-    if (onRead(pUserData, id, 4) != 4) {
-        return DRFLAC_AT_END;
-    }
-    *pBytesRead += 4;
-
-    /* We need to read byte-by-byte until we find the OggS capture pattern. */
-    for (;;) {
-        if (drflac_ogg__is_capture_pattern(id)) {
-            drflac_result result;
-
-            *pCRC32 = DRFLAC_OGG_CAPTURE_PATTERN_CRC32;
-
-            result = drflac_ogg__read_page_header_after_capture_pattern(onRead, pUserData, pHeader, pBytesRead, pCRC32);
-            if (result == DRFLAC_SUCCESS) {
-                return DRFLAC_SUCCESS;
-            } else {
-                if (result == DRFLAC_CRC_MISMATCH) {
-                    continue;
-                } else {
-                    return result;
-                }
-            }
-        } else {
-            /* The first 4 bytes did not equal the capture pattern. Read the next byte and try again. */
-            id[0] = id[1];
-            id[1] = id[2];
-            id[2] = id[3];
-            if (onRead(pUserData, &id[3], 1) != 1) {
-                return DRFLAC_AT_END;
-            }
-            *pBytesRead += 1;
-        }
-    }
-}
-
-
-/*
-The main part of the Ogg encapsulation is the conversion from the physical Ogg bitstream to the native FLAC bitstream. It works
-in three general stages: Ogg Physical Bitstream -> Ogg/FLAC Logical Bitstream -> FLAC Native Bitstream. dr_flac is designed
-in such a way that the core sections assume everything is delivered in native format. Therefore, for each encapsulation type
-dr_flac is supporting there needs to be a layer sitting on top of the onRead and onSeek callbacks that ensures the bits read from
-the physical Ogg bitstream are converted and delivered in native FLAC format.
-*/
-typedef struct
-{
-    drflac_read_proc onRead;                /* The original onRead callback from drflac_open() and family. */
-    drflac_seek_proc onSeek;                /* The original onSeek callback from drflac_open() and family. */
-    void* pUserData;                        /* The user data passed on onRead and onSeek. This is the user data that was passed on drflac_open() and family. */
-    drflac_uint64 currentBytePos;           /* The position of the byte we are sitting on in the physical byte stream. Used for efficient seeking. */
-    drflac_uint64 firstBytePos;             /* The position of the first byte in the physical bitstream. Points to the start of the "OggS" identifier of the FLAC bos page. */
-    drflac_uint32 serialNumber;             /* The serial number of the FLAC audio pages. This is determined by the initial header page that was read during initialization. */
-    drflac_ogg_page_header bosPageHeader;   /* Used for seeking. */
-    drflac_ogg_page_header currentPageHeader;
-    drflac_uint32 bytesRemainingInPage;
-    drflac_uint32 pageDataSize;
-    drflac_uint8 pageData[DRFLAC_OGG_MAX_PAGE_SIZE];
-} drflac_oggbs; /* oggbs = Ogg Bitstream */
-
-static size_t drflac_oggbs__read_physical(drflac_oggbs* oggbs, void* bufferOut, size_t bytesToRead)
-{
-    size_t bytesActuallyRead = oggbs->onRead(oggbs->pUserData, bufferOut, bytesToRead);
-    oggbs->currentBytePos += bytesActuallyRead;
-
-    return bytesActuallyRead;
-}
-
-static drflac_bool32 drflac_oggbs__seek_physical(drflac_oggbs* oggbs, drflac_uint64 offset, drflac_seek_origin origin)
-{
-    if (origin == drflac_seek_origin_start) {
-        if (offset <= 0x7FFFFFFF) {
-            if (!oggbs->onSeek(oggbs->pUserData, (int)offset, drflac_seek_origin_start)) {
-                return DRFLAC_FALSE;
-            }
-            oggbs->currentBytePos = offset;
-
-            return DRFLAC_TRUE;
-        } else {
-            if (!oggbs->onSeek(oggbs->pUserData, 0x7FFFFFFF, drflac_seek_origin_start)) {
-                return DRFLAC_FALSE;
-            }
-            oggbs->currentBytePos = offset;
-
-            return drflac_oggbs__seek_physical(oggbs, offset - 0x7FFFFFFF, drflac_seek_origin_current);
-        }
-    } else {
-        while (offset > 0x7FFFFFFF) {
-            if (!oggbs->onSeek(oggbs->pUserData, 0x7FFFFFFF, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-            oggbs->currentBytePos += 0x7FFFFFFF;
-            offset -= 0x7FFFFFFF;
-        }
-
-        if (!oggbs->onSeek(oggbs->pUserData, (int)offset, drflac_seek_origin_current)) {    /* <-- Safe cast thanks to the loop above. */
-            return DRFLAC_FALSE;
-        }
-        oggbs->currentBytePos += offset;
-
-        return DRFLAC_TRUE;
-    }
-}
-
-static drflac_bool32 drflac_oggbs__goto_next_page(drflac_oggbs* oggbs, drflac_ogg_crc_mismatch_recovery recoveryMethod)
-{
-    drflac_ogg_page_header header;
-    for (;;) {
-        drflac_uint32 crc32 = 0;
-        drflac_uint32 bytesRead;
-        drflac_uint32 pageBodySize;
-#ifndef DR_FLAC_NO_CRC
-        drflac_uint32 actualCRC32;
-#endif
-
-        if (drflac_ogg__read_page_header(oggbs->onRead, oggbs->pUserData, &header, &bytesRead, &crc32) != DRFLAC_SUCCESS) {
-            return DRFLAC_FALSE;
-        }
-        oggbs->currentBytePos += bytesRead;
-
-        pageBodySize = drflac_ogg__get_page_body_size(&header);
-        if (pageBodySize > DRFLAC_OGG_MAX_PAGE_SIZE) {
-            continue;   /* Invalid page size. Assume it's corrupted and just move to the next page. */
-        }
-
-        if (header.serialNumber != oggbs->serialNumber) {
-            /* It's not a FLAC page. Skip it. */
-            if (pageBodySize > 0 && !drflac_oggbs__seek_physical(oggbs, pageBodySize, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-            continue;
-        }
-
-
-        /* We need to read the entire page and then do a CRC check on it. If there's a CRC mismatch we need to skip this page. */
-        if (drflac_oggbs__read_physical(oggbs, oggbs->pageData, pageBodySize) != pageBodySize) {
-            return DRFLAC_FALSE;
-        }
-        oggbs->pageDataSize = pageBodySize;
-
-#ifndef DR_FLAC_NO_CRC
-        actualCRC32 = drflac_crc32_buffer(crc32, oggbs->pageData, oggbs->pageDataSize);
-        if (actualCRC32 != header.checksum) {
-            if (recoveryMethod == drflac_ogg_recover_on_crc_mismatch) {
-                continue;   /* CRC mismatch. Skip this page. */
-            } else {
-                /*
-                Even though we are failing on a CRC mismatch, we still want our stream to be in a good state. Therefore we
-                go to the next valid page to ensure we're in a good state, but return false to let the caller know that the
-                seek did not fully complete.
-                */
-                drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch);
-                return DRFLAC_FALSE;
-            }
-        }
-#else
-        (void)recoveryMethod;   /* <-- Silence a warning. */
-#endif
-
-        oggbs->currentPageHeader = header;
-        oggbs->bytesRemainingInPage = pageBodySize;
-        return DRFLAC_TRUE;
-    }
-}
-
-/* Function below is unused at the moment, but I might be re-adding it later. */
-#if 0
-static drflac_uint8 drflac_oggbs__get_current_segment_index(drflac_oggbs* oggbs, drflac_uint8* pBytesRemainingInSeg)
-{
-    drflac_uint32 bytesConsumedInPage = drflac_ogg__get_page_body_size(&oggbs->currentPageHeader) - oggbs->bytesRemainingInPage;
-    drflac_uint8 iSeg = 0;
-    drflac_uint32 iByte = 0;
-    while (iByte < bytesConsumedInPage) {
-        drflac_uint8 segmentSize = oggbs->currentPageHeader.segmentTable[iSeg];
-        if (iByte + segmentSize > bytesConsumedInPage) {
-            break;
-        } else {
-            iSeg += 1;
-            iByte += segmentSize;
-        }
-    }
-
-    *pBytesRemainingInSeg = oggbs->currentPageHeader.segmentTable[iSeg] - (drflac_uint8)(bytesConsumedInPage - iByte);
-    return iSeg;
-}
-
-static drflac_bool32 drflac_oggbs__seek_to_next_packet(drflac_oggbs* oggbs)
-{
-    /* The current packet ends when we get to the segment with a lacing value of < 255 which is not at the end of a page. */
-    for (;;) {
-        drflac_bool32 atEndOfPage = DRFLAC_FALSE;
-
-        drflac_uint8 bytesRemainingInSeg;
-        drflac_uint8 iFirstSeg = drflac_oggbs__get_current_segment_index(oggbs, &bytesRemainingInSeg);
-
-        drflac_uint32 bytesToEndOfPacketOrPage = bytesRemainingInSeg;
-        for (drflac_uint8 iSeg = iFirstSeg; iSeg < oggbs->currentPageHeader.segmentCount; ++iSeg) {
-            drflac_uint8 segmentSize = oggbs->currentPageHeader.segmentTable[iSeg];
-            if (segmentSize < 255) {
-                if (iSeg == oggbs->currentPageHeader.segmentCount-1) {
-                    atEndOfPage = DRFLAC_TRUE;
-                }
-
-                break;
-            }
-
-            bytesToEndOfPacketOrPage += segmentSize;
-        }
-
-        /*
-        At this point we will have found either the packet or the end of the page. If were at the end of the page we'll
-        want to load the next page and keep searching for the end of the packet.
-        */
-        drflac_oggbs__seek_physical(oggbs, bytesToEndOfPacketOrPage, drflac_seek_origin_current);
-        oggbs->bytesRemainingInPage -= bytesToEndOfPacketOrPage;
-
-        if (atEndOfPage) {
-            /*
-            We're potentially at the next packet, but we need to check the next page first to be sure because the packet may
-            straddle pages.
-            */
-            if (!drflac_oggbs__goto_next_page(oggbs)) {
-                return DRFLAC_FALSE;
-            }
-
-            /* If it's a fresh packet it most likely means we're at the next packet. */
-            if ((oggbs->currentPageHeader.headerType & 0x01) == 0) {
-                return DRFLAC_TRUE;
-            }
-        } else {
-            /* We're at the next packet. */
-            return DRFLAC_TRUE;
-        }
-    }
-}
-
-static drflac_bool32 drflac_oggbs__seek_to_next_frame(drflac_oggbs* oggbs)
-{
-    /* The bitstream should be sitting on the first byte just after the header of the frame. */
-
-    /* What we're actually doing here is seeking to the start of the next packet. */
-    return drflac_oggbs__seek_to_next_packet(oggbs);
-}
-#endif
-
-static size_t drflac__on_read_ogg(void* pUserData, void* bufferOut, size_t bytesToRead)
-{
-    drflac_oggbs* oggbs = (drflac_oggbs*)pUserData;
-    drflac_uint8* pRunningBufferOut = (drflac_uint8*)bufferOut;
-    size_t bytesRead = 0;
-
-    DRFLAC_ASSERT(oggbs != NULL);
-    DRFLAC_ASSERT(pRunningBufferOut != NULL);
-
-    /* Reading is done page-by-page. If we've run out of bytes in the page we need to move to the next one. */
-    while (bytesRead < bytesToRead) {
-        size_t bytesRemainingToRead = bytesToRead - bytesRead;
-
-        if (oggbs->bytesRemainingInPage >= bytesRemainingToRead) {
-            DRFLAC_COPY_MEMORY(pRunningBufferOut, oggbs->pageData + (oggbs->pageDataSize - oggbs->bytesRemainingInPage), bytesRemainingToRead);
-            bytesRead += bytesRemainingToRead;
-            oggbs->bytesRemainingInPage -= (drflac_uint32)bytesRemainingToRead;
-            break;
-        }
-
-        /* If we get here it means some of the requested data is contained in the next pages. */
-        if (oggbs->bytesRemainingInPage > 0) {
-            DRFLAC_COPY_MEMORY(pRunningBufferOut, oggbs->pageData + (oggbs->pageDataSize - oggbs->bytesRemainingInPage), oggbs->bytesRemainingInPage);
-            bytesRead += oggbs->bytesRemainingInPage;
-            pRunningBufferOut += oggbs->bytesRemainingInPage;
-            oggbs->bytesRemainingInPage = 0;
-        }
-
-        DRFLAC_ASSERT(bytesRemainingToRead > 0);
-        if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch)) {
-            break;  /* Failed to go to the next page. Might have simply hit the end of the stream. */
-        }
-    }
-
-    return bytesRead;
-}
-
-static drflac_bool32 drflac__on_seek_ogg(void* pUserData, int offset, drflac_seek_origin origin)
-{
-    drflac_oggbs* oggbs = (drflac_oggbs*)pUserData;
-    int bytesSeeked = 0;
-
-    DRFLAC_ASSERT(oggbs != NULL);
-    DRFLAC_ASSERT(offset >= 0);  /* <-- Never seek backwards. */
-
-    /* Seeking is always forward which makes things a lot simpler. */
-    if (origin == drflac_seek_origin_start) {
-        if (!drflac_oggbs__seek_physical(oggbs, (int)oggbs->firstBytePos, drflac_seek_origin_start)) {
-            return DRFLAC_FALSE;
-        }
-
-        if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_fail_on_crc_mismatch)) {
-            return DRFLAC_FALSE;
-        }
-
-        return drflac__on_seek_ogg(pUserData, offset, drflac_seek_origin_current);
-    }
-
-    DRFLAC_ASSERT(origin == drflac_seek_origin_current);
-
-    while (bytesSeeked < offset) {
-        int bytesRemainingToSeek = offset - bytesSeeked;
-        DRFLAC_ASSERT(bytesRemainingToSeek >= 0);
-
-        if (oggbs->bytesRemainingInPage >= (size_t)bytesRemainingToSeek) {
-            bytesSeeked += bytesRemainingToSeek;
-            (void)bytesSeeked;  /* <-- Silence a dead store warning emitted by Clang Static Analyzer. */
-            oggbs->bytesRemainingInPage -= bytesRemainingToSeek;
-            break;
-        }
-
-        /* If we get here it means some of the requested data is contained in the next pages. */
-        if (oggbs->bytesRemainingInPage > 0) {
-            bytesSeeked += (int)oggbs->bytesRemainingInPage;
-            oggbs->bytesRemainingInPage = 0;
-        }
-
-        DRFLAC_ASSERT(bytesRemainingToSeek > 0);
-        if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_fail_on_crc_mismatch)) {
-            /* Failed to go to the next page. We either hit the end of the stream or had a CRC mismatch. */
-            return DRFLAC_FALSE;
-        }
-    }
-
-    return DRFLAC_TRUE;
-}
-
-
-static drflac_bool32 drflac_ogg__seek_to_pcm_frame(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
-    drflac_uint64 originalBytePos;
-    drflac_uint64 runningGranulePosition;
-    drflac_uint64 runningFrameBytePos;
-    drflac_uint64 runningPCMFrameCount;
-
-    DRFLAC_ASSERT(oggbs != NULL);
-
-    originalBytePos = oggbs->currentBytePos;   /* For recovery. Points to the OggS identifier. */
-
-    /* First seek to the first frame. */
-    if (!drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes)) {
-        return DRFLAC_FALSE;
-    }
-    oggbs->bytesRemainingInPage = 0;
-
-    runningGranulePosition = 0;
-    for (;;) {
-        if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch)) {
-            drflac_oggbs__seek_physical(oggbs, originalBytePos, drflac_seek_origin_start);
-            return DRFLAC_FALSE;   /* Never did find that sample... */
-        }
-
-        runningFrameBytePos = oggbs->currentBytePos - drflac_ogg__get_page_header_size(&oggbs->currentPageHeader) - oggbs->pageDataSize;
-        if (oggbs->currentPageHeader.granulePosition >= pcmFrameIndex) {
-            break; /* The sample is somewhere in the previous page. */
-        }
-
-        /*
-        At this point we know the sample is not in the previous page. It could possibly be in this page. For simplicity we
-        disregard any pages that do not begin a fresh packet.
-        */
-        if ((oggbs->currentPageHeader.headerType & 0x01) == 0) {    /* <-- Is it a fresh page? */
-            if (oggbs->currentPageHeader.segmentTable[0] >= 2) {
-                drflac_uint8 firstBytesInPage[2];
-                firstBytesInPage[0] = oggbs->pageData[0];
-                firstBytesInPage[1] = oggbs->pageData[1];
-
-                if ((firstBytesInPage[0] == 0xFF) && (firstBytesInPage[1] & 0xFC) == 0xF8) {    /* <-- Does the page begin with a frame's sync code? */
-                    runningGranulePosition = oggbs->currentPageHeader.granulePosition;
-                }
-
-                continue;
-            }
-        }
-    }
-
-    /*
-    We found the page that that is closest to the sample, so now we need to find it. The first thing to do is seek to the
-    start of that page. In the loop above we checked that it was a fresh page which means this page is also the start of
-    a new frame. This property means that after we've seeked to the page we can immediately start looping over frames until
-    we find the one containing the target sample.
-    */
-    if (!drflac_oggbs__seek_physical(oggbs, runningFrameBytePos, drflac_seek_origin_start)) {
-        return DRFLAC_FALSE;
-    }
-    if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch)) {
-        return DRFLAC_FALSE;
-    }
-
-    /*
-    At this point we'll be sitting on the first byte of the frame header of the first frame in the page. We just keep
-    looping over these frames until we find the one containing the sample we're after.
-    */
-    runningPCMFrameCount = runningGranulePosition;
-    for (;;) {
-        /*
-        There are two ways to find the sample and seek past irrelevant frames:
-          1) Use the native FLAC decoder.
-          2) Use Ogg's framing system.
-
-        Both of these options have their own pros and cons. Using the native FLAC decoder is slower because it needs to
-        do a full decode of the frame. Using Ogg's framing system is faster, but more complicated and involves some code
-        duplication for the decoding of frame headers.
-
-        Another thing to consider is that using the Ogg framing system will perform direct seeking of the physical Ogg
-        bitstream. This is important to consider because it means we cannot read data from the drflac_bs object using the
-        standard drflac__*() APIs because that will read in extra data for its own internal caching which in turn breaks
-        the positioning of the read pointer of the physical Ogg bitstream. Therefore, anything that would normally be read
-        using the native FLAC decoding APIs, such as drflac__read_next_flac_frame_header(), need to be re-implemented so as to
-        avoid the use of the drflac_bs object.
-
-        Considering these issues, I have decided to use the slower native FLAC decoding method for the following reasons:
-          1) Seeking is already partially accelerated using Ogg's paging system in the code block above.
-          2) Seeking in an Ogg encapsulated FLAC stream is probably quite uncommon.
-          3) Simplicity.
-        */
-        drflac_uint64 firstPCMFrameInFLACFrame = 0;
-        drflac_uint64 lastPCMFrameInFLACFrame = 0;
-        drflac_uint64 pcmFrameCountInThisFrame;
-
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-
-        drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &firstPCMFrameInFLACFrame, &lastPCMFrameInFLACFrame);
-
-        pcmFrameCountInThisFrame = (lastPCMFrameInFLACFrame - firstPCMFrameInFLACFrame) + 1;
-
-        /* If we are seeking to the end of the file and we've just hit it, we're done. */
-        if (pcmFrameIndex == pFlac->totalPCMFrameCount && (runningPCMFrameCount + pcmFrameCountInThisFrame) == pFlac->totalPCMFrameCount) {
-            drflac_result result = drflac__decode_flac_frame(pFlac);
-            if (result == DRFLAC_SUCCESS) {
-                pFlac->currentPCMFrame = pcmFrameIndex;
-                pFlac->currentFLACFrame.pcmFramesRemaining = 0;
-                return DRFLAC_TRUE;
-            } else {
-                return DRFLAC_FALSE;
-            }
-        }
-
-        if (pcmFrameIndex < (runningPCMFrameCount + pcmFrameCountInThisFrame)) {
-            /*
-            The sample should be in this FLAC frame. We need to fully decode it, however if it's an invalid frame (a CRC mismatch), we need to pretend
-            it never existed and keep iterating.
-            */
-            drflac_result result = drflac__decode_flac_frame(pFlac);
-            if (result == DRFLAC_SUCCESS) {
-                /* The frame is valid. We just need to skip over some samples to ensure it's sample-exact. */
-                drflac_uint64 pcmFramesToDecode = (size_t)(pcmFrameIndex - runningPCMFrameCount);    /* <-- Safe cast because the maximum number of samples in a frame is 65535. */
-                if (pcmFramesToDecode == 0) {
-                    return DRFLAC_TRUE;
-                }
-
-                pFlac->currentPCMFrame = runningPCMFrameCount;
-
-                return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;  /* <-- If this fails, something bad has happened (it should never fail). */
-            } else {
-                if (result == DRFLAC_CRC_MISMATCH) {
-                    continue;   /* CRC mismatch. Pretend this frame never existed. */
-                } else {
-                    return DRFLAC_FALSE;
-                }
-            }
-        } else {
-            /*
-            It's not in this frame. We need to seek past the frame, but check if there was a CRC mismatch. If so, we pretend this
-            frame never existed and leave the running sample count untouched.
-            */
-            drflac_result result = drflac__seek_to_next_flac_frame(pFlac);
-            if (result == DRFLAC_SUCCESS) {
-                runningPCMFrameCount += pcmFrameCountInThisFrame;
-            } else {
-                if (result == DRFLAC_CRC_MISMATCH) {
-                    continue;   /* CRC mismatch. Pretend this frame never existed. */
-                } else {
-                    return DRFLAC_FALSE;
-                }
-            }
-        }
-    }
-}
-
-
-
-static drflac_bool32 drflac__init_private__ogg(drflac_init_info* pInit, drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_bool32 relaxed)
-{
-    drflac_ogg_page_header header;
-    drflac_uint32 crc32 = DRFLAC_OGG_CAPTURE_PATTERN_CRC32;
-    drflac_uint32 bytesRead = 0;
-
-    /* Pre Condition: The bit stream should be sitting just past the 4-byte OggS capture pattern. */
-    (void)relaxed;
-
-    pInit->container = drflac_container_ogg;
-    pInit->oggFirstBytePos = 0;
-
-    /*
-    We'll get here if the first 4 bytes of the stream were the OggS capture pattern, however it doesn't necessarily mean the
-    stream includes FLAC encoded audio. To check for this we need to scan the beginning-of-stream page markers and check if
-    any match the FLAC specification. Important to keep in mind that the stream may be multiplexed.
-    */
-    if (drflac_ogg__read_page_header_after_capture_pattern(onRead, pUserData, &header, &bytesRead, &crc32) != DRFLAC_SUCCESS) {
-        return DRFLAC_FALSE;
-    }
-    pInit->runningFilePos += bytesRead;
-
-    for (;;) {
-        int pageBodySize;
-
-        /* Break if we're past the beginning of stream page. */
-        if ((header.headerType & 0x02) == 0) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Check if it's a FLAC header. */
-        pageBodySize = drflac_ogg__get_page_body_size(&header);
-        if (pageBodySize == 51) {   /* 51 = the lacing value of the FLAC header packet. */
-            /* It could be a FLAC page... */
-            drflac_uint32 bytesRemainingInPage = pageBodySize;
-            drflac_uint8 packetType;
-
-            if (onRead(pUserData, &packetType, 1) != 1) {
-                return DRFLAC_FALSE;
-            }
-
-            bytesRemainingInPage -= 1;
-            if (packetType == 0x7F) {
-                /* Increasingly more likely to be a FLAC page... */
-                drflac_uint8 sig[4];
-                if (onRead(pUserData, sig, 4) != 4) {
-                    return DRFLAC_FALSE;
-                }
-
-                bytesRemainingInPage -= 4;
-                if (sig[0] == 'F' && sig[1] == 'L' && sig[2] == 'A' && sig[3] == 'C') {
-                    /* Almost certainly a FLAC page... */
-                    drflac_uint8 mappingVersion[2];
-                    if (onRead(pUserData, mappingVersion, 2) != 2) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (mappingVersion[0] != 1) {
-                        return DRFLAC_FALSE;   /* Only supporting version 1.x of the Ogg mapping. */
-                    }
-
-                    /*
-                    The next 2 bytes are the non-audio packets, not including this one. We don't care about this because we're going to
-                    be handling it in a generic way based on the serial number and packet types.
-                    */
-                    if (!onSeek(pUserData, 2, drflac_seek_origin_current)) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    /* Expecting the native FLAC signature "fLaC". */
-                    if (onRead(pUserData, sig, 4) != 4) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (sig[0] == 'f' && sig[1] == 'L' && sig[2] == 'a' && sig[3] == 'C') {
-                        /* The remaining data in the page should be the STREAMINFO block. */
-                        drflac_streaminfo streaminfo;
-                        drflac_uint8 isLastBlock;
-                        drflac_uint8 blockType;
-                        drflac_uint32 blockSize;
-                        if (!drflac__read_and_decode_block_header(onRead, pUserData, &isLastBlock, &blockType, &blockSize)) {
-                            return DRFLAC_FALSE;
-                        }
-
-                        if (blockType != DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO || blockSize != 34) {
-                            return DRFLAC_FALSE;    /* Invalid block type. First block must be the STREAMINFO block. */
-                        }
-
-                        if (drflac__read_streaminfo(onRead, pUserData, &streaminfo)) {
-                            /* Success! */
-                            pInit->hasStreamInfoBlock      = DRFLAC_TRUE;
-                            pInit->sampleRate              = streaminfo.sampleRate;
-                            pInit->channels                = streaminfo.channels;
-                            pInit->bitsPerSample           = streaminfo.bitsPerSample;
-                            pInit->totalPCMFrameCount      = streaminfo.totalPCMFrameCount;
-                            pInit->maxBlockSizeInPCMFrames = streaminfo.maxBlockSizeInPCMFrames;
-                            pInit->hasMetadataBlocks       = !isLastBlock;
-
-                            if (onMeta) {
-                                drflac_metadata metadata;
-                                metadata.type = DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO;
-                                metadata.pRawData = NULL;
-                                metadata.rawDataSize = 0;
-                                metadata.data.streaminfo = streaminfo;
-                                onMeta(pUserDataMD, &metadata);
-                            }
-
-                            pInit->runningFilePos  += pageBodySize;
-                            pInit->oggFirstBytePos  = pInit->runningFilePos - 79;   /* Subtracting 79 will place us right on top of the "OggS" identifier of the FLAC bos page. */
-                            pInit->oggSerial        = header.serialNumber;
-                            pInit->oggBosHeader     = header;
-                            break;
-                        } else {
-                            /* Failed to read STREAMINFO block. Aww, so close... */
-                            return DRFLAC_FALSE;
-                        }
-                    } else {
-                        /* Invalid file. */
-                        return DRFLAC_FALSE;
-                    }
-                } else {
-                    /* Not a FLAC header. Skip it. */
-                    if (!onSeek(pUserData, bytesRemainingInPage, drflac_seek_origin_current)) {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                /* Not a FLAC header. Seek past the entire page and move on to the next. */
-                if (!onSeek(pUserData, bytesRemainingInPage, drflac_seek_origin_current)) {
-                    return DRFLAC_FALSE;
-                }
-            }
-        } else {
-            if (!onSeek(pUserData, pageBodySize, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-        }
-
-        pInit->runningFilePos += pageBodySize;
-
-
-        /* Read the header of the next page. */
-        if (drflac_ogg__read_page_header(onRead, pUserData, &header, &bytesRead, &crc32) != DRFLAC_SUCCESS) {
-            return DRFLAC_FALSE;
-        }
-        pInit->runningFilePos += bytesRead;
-    }
-
-    /*
-    If we get here it means we found a FLAC audio stream. We should be sitting on the first byte of the header of the next page. The next
-    packets in the FLAC logical stream contain the metadata. The only thing left to do in the initialization phase for Ogg is to create the
-    Ogg bistream object.
-    */
-    pInit->hasMetadataBlocks = DRFLAC_TRUE;    /* <-- Always have at least VORBIS_COMMENT metadata block. */
-    return DRFLAC_TRUE;
-}
-#endif
-
-static drflac_bool32 drflac__init_private(drflac_init_info* pInit, drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, void* pUserDataMD)
-{
-    drflac_bool32 relaxed;
-    drflac_uint8 id[4];
-
-    if (pInit == NULL || onRead == NULL || onSeek == NULL) {
-        return DRFLAC_FALSE;
-    }
-
-    DRFLAC_ZERO_MEMORY(pInit, sizeof(*pInit));
-    pInit->onRead       = onRead;
-    pInit->onSeek       = onSeek;
-    pInit->onMeta       = onMeta;
-    pInit->container    = container;
-    pInit->pUserData    = pUserData;
-    pInit->pUserDataMD  = pUserDataMD;
-
-    pInit->bs.onRead    = onRead;
-    pInit->bs.onSeek    = onSeek;
-    pInit->bs.pUserData = pUserData;
-    drflac__reset_cache(&pInit->bs);
-
-
-    /* If the container is explicitly defined then we can try opening in relaxed mode. */
-    relaxed = container != drflac_container_unknown;
-
-    /* Skip over any ID3 tags. */
-    for (;;) {
-        if (onRead(pUserData, id, 4) != 4) {
-            return DRFLAC_FALSE;    /* Ran out of data. */
-        }
-        pInit->runningFilePos += 4;
-
-        if (id[0] == 'I' && id[1] == 'D' && id[2] == '3') {
-            drflac_uint8 header[6];
-            drflac_uint8 flags;
-            drflac_uint32 headerSize;
-
-            if (onRead(pUserData, header, 6) != 6) {
-                return DRFLAC_FALSE;    /* Ran out of data. */
-            }
-            pInit->runningFilePos += 6;
-
-            flags = header[1];
-
-            DRFLAC_COPY_MEMORY(&headerSize, header+2, 4);
-            headerSize = drflac__unsynchsafe_32(drflac__be2host_32(headerSize));
-            if (flags & 0x10) {
-                headerSize += 10;
-            }
-
-            if (!onSeek(pUserData, headerSize, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;    /* Failed to seek past the tag. */
-            }
-            pInit->runningFilePos += headerSize;
-        } else {
-            break;
-        }
-    }
-
-    if (id[0] == 'f' && id[1] == 'L' && id[2] == 'a' && id[3] == 'C') {
-        return drflac__init_private__native(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
-    }
-#ifndef DR_FLAC_NO_OGG
-    if (id[0] == 'O' && id[1] == 'g' && id[2] == 'g' && id[3] == 'S') {
-        return drflac__init_private__ogg(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
-    }
-#endif
-
-    /* If we get here it means we likely don't have a header. Try opening in relaxed mode, if applicable. */
-    if (relaxed) {
-        if (container == drflac_container_native) {
-            return drflac__init_private__native(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
-        }
-#ifndef DR_FLAC_NO_OGG
-        if (container == drflac_container_ogg) {
-            return drflac__init_private__ogg(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
-        }
-#endif
-    }
-
-    /* Unsupported container. */
-    return DRFLAC_FALSE;
-}
-
-static void drflac__init_from_info(drflac* pFlac, const drflac_init_info* pInit)
-{
-    DRFLAC_ASSERT(pFlac != NULL);
-    DRFLAC_ASSERT(pInit != NULL);
-
-    DRFLAC_ZERO_MEMORY(pFlac, sizeof(*pFlac));
-    pFlac->bs                      = pInit->bs;
-    pFlac->onMeta                  = pInit->onMeta;
-    pFlac->pUserDataMD             = pInit->pUserDataMD;
-    pFlac->maxBlockSizeInPCMFrames = pInit->maxBlockSizeInPCMFrames;
-    pFlac->sampleRate              = pInit->sampleRate;
-    pFlac->channels                = (drflac_uint8)pInit->channels;
-    pFlac->bitsPerSample           = (drflac_uint8)pInit->bitsPerSample;
-    pFlac->totalPCMFrameCount      = pInit->totalPCMFrameCount;
-    pFlac->container               = pInit->container;
-}
-
-
-static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, void* pUserDataMD, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac_init_info init;
-    drflac_uint32 allocationSize;
-    drflac_uint32 wholeSIMDVectorCountPerChannel;
-    drflac_uint32 decodedSamplesAllocationSize;
-#ifndef DR_FLAC_NO_OGG
-    drflac_oggbs oggbs;
-#endif
-    drflac_uint64 firstFramePos;
-    drflac_uint64 seektablePos;
-    drflac_uint32 seektableSize;
-    drflac_allocation_callbacks allocationCallbacks;
-    drflac* pFlac;
-
-    /* CPU support first. */
-    drflac__init_cpu_caps();
-
-    if (!drflac__init_private(&init, onRead, onSeek, onMeta, container, pUserData, pUserDataMD)) {
-        return NULL;
-    }
-
-    if (pAllocationCallbacks != NULL) {
-        allocationCallbacks = *pAllocationCallbacks;
-        if (allocationCallbacks.onFree == NULL || (allocationCallbacks.onMalloc == NULL && allocationCallbacks.onRealloc == NULL)) {
-            return NULL;    /* Invalid allocation callbacks. */
-        }
-    } else {
-        allocationCallbacks.pUserData = NULL;
-        allocationCallbacks.onMalloc  = drflac__malloc_default;
-        allocationCallbacks.onRealloc = drflac__realloc_default;
-        allocationCallbacks.onFree    = drflac__free_default;
-    }
-
-
-    /*
-    The size of the allocation for the drflac object needs to be large enough to fit the following:
-      1) The main members of the drflac structure
-      2) A block of memory large enough to store the decoded samples of the largest frame in the stream
-      3) If the container is Ogg, a drflac_oggbs object
-
-    The complicated part of the allocation is making sure there's enough room the decoded samples, taking into consideration
-    the different SIMD instruction sets.
-    */
-    allocationSize = sizeof(drflac);
-
-    /*
-    The allocation size for decoded frames depends on the number of 32-bit integers that fit inside the largest SIMD vector
-    we are supporting.
-    */
-    if ((init.maxBlockSizeInPCMFrames % (DRFLAC_MAX_SIMD_VECTOR_SIZE / sizeof(drflac_int32))) == 0) {
-        wholeSIMDVectorCountPerChannel = (init.maxBlockSizeInPCMFrames / (DRFLAC_MAX_SIMD_VECTOR_SIZE / sizeof(drflac_int32)));
-    } else {
-        wholeSIMDVectorCountPerChannel = (init.maxBlockSizeInPCMFrames / (DRFLAC_MAX_SIMD_VECTOR_SIZE / sizeof(drflac_int32))) + 1;
-    }
-
-    decodedSamplesAllocationSize = wholeSIMDVectorCountPerChannel * DRFLAC_MAX_SIMD_VECTOR_SIZE * init.channels;
-
-    allocationSize += decodedSamplesAllocationSize;
-    allocationSize += DRFLAC_MAX_SIMD_VECTOR_SIZE;  /* Allocate extra bytes to ensure we have enough for alignment. */
-
-#ifndef DR_FLAC_NO_OGG
-    /* There's additional data required for Ogg streams. */
-    if (init.container == drflac_container_ogg) {
-        allocationSize += sizeof(drflac_oggbs);
-    }
-
-    DRFLAC_ZERO_MEMORY(&oggbs, sizeof(oggbs));
-    if (init.container == drflac_container_ogg) {
-        oggbs.onRead = onRead;
-        oggbs.onSeek = onSeek;
-        oggbs.pUserData = pUserData;
-        oggbs.currentBytePos = init.oggFirstBytePos;
-        oggbs.firstBytePos = init.oggFirstBytePos;
-        oggbs.serialNumber = init.oggSerial;
-        oggbs.bosPageHeader = init.oggBosHeader;
-        oggbs.bytesRemainingInPage = 0;
-    }
-#endif
-
-    /*
-    This part is a bit awkward. We need to load the seektable so that it can be referenced in-memory, but I want the drflac object to
-    consist of only a single heap allocation. To this, the size of the seek table needs to be known, which we determine when reading
-    and decoding the metadata.
-    */
-    firstFramePos = 42;   /* <-- We know we are at byte 42 at this point. */
-    seektablePos  = 0;
-    seektableSize = 0;
-    if (init.hasMetadataBlocks) {
-        drflac_read_proc onReadOverride = onRead;
-        drflac_seek_proc onSeekOverride = onSeek;
-        void* pUserDataOverride = pUserData;
-
-#ifndef DR_FLAC_NO_OGG
-        if (init.container == drflac_container_ogg) {
-            onReadOverride = drflac__on_read_ogg;
-            onSeekOverride = drflac__on_seek_ogg;
-            pUserDataOverride = (void*)&oggbs;
-        }
-#endif
-
-        if (!drflac__read_and_decode_metadata(onReadOverride, onSeekOverride, onMeta, pUserDataOverride, pUserDataMD, &firstFramePos, &seektablePos, &seektableSize, &allocationCallbacks)) {
-            return NULL;
-        }
-
-        allocationSize += seektableSize;
-    }
-
-
-    pFlac = (drflac*)drflac__malloc_from_callbacks(allocationSize, &allocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    drflac__init_from_info(pFlac, &init);
-    pFlac->allocationCallbacks = allocationCallbacks;
-    pFlac->pDecodedSamples = (drflac_int32*)drflac_align((size_t)pFlac->pExtraData, DRFLAC_MAX_SIMD_VECTOR_SIZE);
-
-#ifndef DR_FLAC_NO_OGG
-    if (init.container == drflac_container_ogg) {
-        drflac_oggbs* pInternalOggbs = (drflac_oggbs*)((drflac_uint8*)pFlac->pDecodedSamples + decodedSamplesAllocationSize + seektableSize);
-        *pInternalOggbs = oggbs;
-
-        /* The Ogg bistream needs to be layered on top of the original bitstream. */
-        pFlac->bs.onRead = drflac__on_read_ogg;
-        pFlac->bs.onSeek = drflac__on_seek_ogg;
-        pFlac->bs.pUserData = (void*)pInternalOggbs;
-        pFlac->_oggbs = (void*)pInternalOggbs;
-    }
-#endif
-
-    pFlac->firstFLACFramePosInBytes = firstFramePos;
-
-    /* NOTE: Seektables are not currently compatible with Ogg encapsulation (Ogg has its own accelerated seeking system). I may change this later, so I'm leaving this here for now. */
-#ifndef DR_FLAC_NO_OGG
-    if (init.container == drflac_container_ogg)
-    {
-        pFlac->pSeekpoints = NULL;
-        pFlac->seekpointCount = 0;
-    }
-    else
-#endif
-    {
-        /* If we have a seektable we need to load it now, making sure we move back to where we were previously. */
-        if (seektablePos != 0) {
-            pFlac->seekpointCount = seektableSize / sizeof(*pFlac->pSeekpoints);
-            pFlac->pSeekpoints = (drflac_seekpoint*)((drflac_uint8*)pFlac->pDecodedSamples + decodedSamplesAllocationSize);
-
-            DRFLAC_ASSERT(pFlac->bs.onSeek != NULL);
-            DRFLAC_ASSERT(pFlac->bs.onRead != NULL);
-
-            /* Seek to the seektable, then just read directly into our seektable buffer. */
-            if (pFlac->bs.onSeek(pFlac->bs.pUserData, (int)seektablePos, drflac_seek_origin_start)) {
-                if (pFlac->bs.onRead(pFlac->bs.pUserData, pFlac->pSeekpoints, seektableSize) == seektableSize) {
-                    /* Endian swap. */
-                    drflac_uint32 iSeekpoint;
-                    for (iSeekpoint = 0; iSeekpoint < pFlac->seekpointCount; ++iSeekpoint) {
-                        pFlac->pSeekpoints[iSeekpoint].firstPCMFrame   = drflac__be2host_64(pFlac->pSeekpoints[iSeekpoint].firstPCMFrame);
-                        pFlac->pSeekpoints[iSeekpoint].flacFrameOffset = drflac__be2host_64(pFlac->pSeekpoints[iSeekpoint].flacFrameOffset);
-                        pFlac->pSeekpoints[iSeekpoint].pcmFrameCount   = drflac__be2host_16(pFlac->pSeekpoints[iSeekpoint].pcmFrameCount);
-                    }
-                } else {
-                    /* Failed to read the seektable. Pretend we don't have one. */
-                    pFlac->pSeekpoints = NULL;
-                    pFlac->seekpointCount = 0;
-                }
-
-                /* We need to seek back to where we were. If this fails it's a critical error. */
-                if (!pFlac->bs.onSeek(pFlac->bs.pUserData, (int)pFlac->firstFLACFramePosInBytes, drflac_seek_origin_start)) {
-                    drflac__free_from_callbacks(pFlac, &allocationCallbacks);
-                    return NULL;
-                }
-            } else {
-                /* Failed to seek to the seektable. Ominous sign, but for now we can just pretend we don't have one. */
-                pFlac->pSeekpoints = NULL;
-                pFlac->seekpointCount = 0;
-            }
-        }
-    }
-
-
-    /*
-    If we get here, but don't have a STREAMINFO block, it means we've opened the stream in relaxed mode and need to decode
-    the first frame.
-    */
-    if (!init.hasStreamInfoBlock) {
-        pFlac->currentFLACFrame.header = init.firstFrameHeader;
-        for (;;) {
-            drflac_result result = drflac__decode_flac_frame(pFlac);
-            if (result == DRFLAC_SUCCESS) {
-                break;
-            } else {
-                if (result == DRFLAC_CRC_MISMATCH) {
-                    if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                        drflac__free_from_callbacks(pFlac, &allocationCallbacks);
-                        return NULL;
-                    }
-                    continue;
-                } else {
-                    drflac__free_from_callbacks(pFlac, &allocationCallbacks);
-                    return NULL;
-                }
-            }
-        }
-    }
-
-    return pFlac;
-}
-
-
-
-#ifndef DR_FLAC_NO_STDIO
-#include <stdio.h>
-#include <wchar.h>      /* For wcslen(), wcsrtombs() */
-
-/* drflac_result_from_errno() is only used for fopen() and wfopen() so putting it inside DR_WAV_NO_STDIO for now. If something else needs this later we can move it out. */
-#include <errno.h>
-static drflac_result drflac_result_from_errno(int e)
-{
-    switch (e)
-    {
-        case 0: return DRFLAC_SUCCESS;
-    #ifdef EPERM
-        case EPERM: return DRFLAC_INVALID_OPERATION;
-    #endif
-    #ifdef ENOENT
-        case ENOENT: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef ESRCH
-        case ESRCH: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef EINTR
-        case EINTR: return DRFLAC_INTERRUPT;
-    #endif
-    #ifdef EIO
-        case EIO: return DRFLAC_IO_ERROR;
-    #endif
-    #ifdef ENXIO
-        case ENXIO: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef E2BIG
-        case E2BIG: return DRFLAC_INVALID_ARGS;
-    #endif
-    #ifdef ENOEXEC
-        case ENOEXEC: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef EBADF
-        case EBADF: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef ECHILD
-        case ECHILD: return DRFLAC_ERROR;
-    #endif
-    #ifdef EAGAIN
-        case EAGAIN: return DRFLAC_UNAVAILABLE;
-    #endif
-    #ifdef ENOMEM
-        case ENOMEM: return DRFLAC_OUT_OF_MEMORY;
-    #endif
-    #ifdef EACCES
-        case EACCES: return DRFLAC_ACCESS_DENIED;
-    #endif
-    #ifdef EFAULT
-        case EFAULT: return DRFLAC_BAD_ADDRESS;
-    #endif
-    #ifdef ENOTBLK
-        case ENOTBLK: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBUSY
-        case EBUSY: return DRFLAC_BUSY;
-    #endif
-    #ifdef EEXIST
-        case EEXIST: return DRFLAC_ALREADY_EXISTS;
-    #endif
-    #ifdef EXDEV
-        case EXDEV: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENODEV
-        case ENODEV: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef ENOTDIR
-        case ENOTDIR: return DRFLAC_NOT_DIRECTORY;
-    #endif
-    #ifdef EISDIR
-        case EISDIR: return DRFLAC_IS_DIRECTORY;
-    #endif
-    #ifdef EINVAL
-        case EINVAL: return DRFLAC_INVALID_ARGS;
-    #endif
-    #ifdef ENFILE
-        case ENFILE: return DRFLAC_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef EMFILE
-        case EMFILE: return DRFLAC_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef ENOTTY
-        case ENOTTY: return DRFLAC_INVALID_OPERATION;
-    #endif
-    #ifdef ETXTBSY
-        case ETXTBSY: return DRFLAC_BUSY;
-    #endif
-    #ifdef EFBIG
-        case EFBIG: return DRFLAC_TOO_BIG;
-    #endif
-    #ifdef ENOSPC
-        case ENOSPC: return DRFLAC_NO_SPACE;
-    #endif
-    #ifdef ESPIPE
-        case ESPIPE: return DRFLAC_BAD_SEEK;
-    #endif
-    #ifdef EROFS
-        case EROFS: return DRFLAC_ACCESS_DENIED;
-    #endif
-    #ifdef EMLINK
-        case EMLINK: return DRFLAC_TOO_MANY_LINKS;
-    #endif
-    #ifdef EPIPE
-        case EPIPE: return DRFLAC_BAD_PIPE;
-    #endif
-    #ifdef EDOM
-        case EDOM: return DRFLAC_OUT_OF_RANGE;
-    #endif
-    #ifdef ERANGE
-        case ERANGE: return DRFLAC_OUT_OF_RANGE;
-    #endif
-    #ifdef EDEADLK
-        case EDEADLK: return DRFLAC_DEADLOCK;
-    #endif
-    #ifdef ENAMETOOLONG
-        case ENAMETOOLONG: return DRFLAC_PATH_TOO_LONG;
-    #endif
-    #ifdef ENOLCK
-        case ENOLCK: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOSYS
-        case ENOSYS: return DRFLAC_NOT_IMPLEMENTED;
-    #endif
-    #ifdef ENOTEMPTY
-        case ENOTEMPTY: return DRFLAC_DIRECTORY_NOT_EMPTY;
-    #endif
-    #ifdef ELOOP
-        case ELOOP: return DRFLAC_TOO_MANY_LINKS;
-    #endif
-    #ifdef ENOMSG
-        case ENOMSG: return DRFLAC_NO_MESSAGE;
-    #endif
-    #ifdef EIDRM
-        case EIDRM: return DRFLAC_ERROR;
-    #endif
-    #ifdef ECHRNG
-        case ECHRNG: return DRFLAC_ERROR;
-    #endif
-    #ifdef EL2NSYNC
-        case EL2NSYNC: return DRFLAC_ERROR;
-    #endif
-    #ifdef EL3HLT
-        case EL3HLT: return DRFLAC_ERROR;
-    #endif
-    #ifdef EL3RST
-        case EL3RST: return DRFLAC_ERROR;
-    #endif
-    #ifdef ELNRNG
-        case ELNRNG: return DRFLAC_OUT_OF_RANGE;
-    #endif
-    #ifdef EUNATCH
-        case EUNATCH: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOCSI
-        case ENOCSI: return DRFLAC_ERROR;
-    #endif
-    #ifdef EL2HLT
-        case EL2HLT: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADE
-        case EBADE: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADR
-        case EBADR: return DRFLAC_ERROR;
-    #endif
-    #ifdef EXFULL
-        case EXFULL: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOANO
-        case ENOANO: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADRQC
-        case EBADRQC: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADSLT
-        case EBADSLT: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBFONT
-        case EBFONT: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef ENOSTR
-        case ENOSTR: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENODATA
-        case ENODATA: return DRFLAC_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ETIME
-        case ETIME: return DRFLAC_TIMEOUT;
-    #endif
-    #ifdef ENOSR
-        case ENOSR: return DRFLAC_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ENONET
-        case ENONET: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ENOPKG
-        case ENOPKG: return DRFLAC_ERROR;
-    #endif
-    #ifdef EREMOTE
-        case EREMOTE: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOLINK
-        case ENOLINK: return DRFLAC_ERROR;
-    #endif
-    #ifdef EADV
-        case EADV: return DRFLAC_ERROR;
-    #endif
-    #ifdef ESRMNT
-        case ESRMNT: return DRFLAC_ERROR;
-    #endif
-    #ifdef ECOMM
-        case ECOMM: return DRFLAC_ERROR;
-    #endif
-    #ifdef EPROTO
-        case EPROTO: return DRFLAC_ERROR;
-    #endif
-    #ifdef EMULTIHOP
-        case EMULTIHOP: return DRFLAC_ERROR;
-    #endif
-    #ifdef EDOTDOT
-        case EDOTDOT: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADMSG
-        case EBADMSG: return DRFLAC_BAD_MESSAGE;
-    #endif
-    #ifdef EOVERFLOW
-        case EOVERFLOW: return DRFLAC_TOO_BIG;
-    #endif
-    #ifdef ENOTUNIQ
-        case ENOTUNIQ: return DRFLAC_NOT_UNIQUE;
-    #endif
-    #ifdef EBADFD
-        case EBADFD: return DRFLAC_ERROR;
-    #endif
-    #ifdef EREMCHG
-        case EREMCHG: return DRFLAC_ERROR;
-    #endif
-    #ifdef ELIBACC
-        case ELIBACC: return DRFLAC_ACCESS_DENIED;
-    #endif
-    #ifdef ELIBBAD
-        case ELIBBAD: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef ELIBSCN
-        case ELIBSCN: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef ELIBMAX
-        case ELIBMAX: return DRFLAC_ERROR;
-    #endif
-    #ifdef ELIBEXEC
-        case ELIBEXEC: return DRFLAC_ERROR;
-    #endif
-    #ifdef EILSEQ
-        case EILSEQ: return DRFLAC_INVALID_DATA;
-    #endif
-    #ifdef ERESTART
-        case ERESTART: return DRFLAC_ERROR;
-    #endif
-    #ifdef ESTRPIPE
-        case ESTRPIPE: return DRFLAC_ERROR;
-    #endif
-    #ifdef EUSERS
-        case EUSERS: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOTSOCK
-        case ENOTSOCK: return DRFLAC_NOT_SOCKET;
-    #endif
-    #ifdef EDESTADDRREQ
-        case EDESTADDRREQ: return DRFLAC_NO_ADDRESS;
-    #endif
-    #ifdef EMSGSIZE
-        case EMSGSIZE: return DRFLAC_TOO_BIG;
-    #endif
-    #ifdef EPROTOTYPE
-        case EPROTOTYPE: return DRFLAC_BAD_PROTOCOL;
-    #endif
-    #ifdef ENOPROTOOPT
-        case ENOPROTOOPT: return DRFLAC_PROTOCOL_UNAVAILABLE;
-    #endif
-    #ifdef EPROTONOSUPPORT
-        case EPROTONOSUPPORT: return DRFLAC_PROTOCOL_NOT_SUPPORTED;
-    #endif
-    #ifdef ESOCKTNOSUPPORT
-        case ESOCKTNOSUPPORT: return DRFLAC_SOCKET_NOT_SUPPORTED;
-    #endif
-    #ifdef EOPNOTSUPP
-        case EOPNOTSUPP: return DRFLAC_INVALID_OPERATION;
-    #endif
-    #ifdef EPFNOSUPPORT
-        case EPFNOSUPPORT: return DRFLAC_PROTOCOL_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EAFNOSUPPORT
-        case EAFNOSUPPORT: return DRFLAC_ADDRESS_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EADDRINUSE
-        case EADDRINUSE: return DRFLAC_ALREADY_IN_USE;
-    #endif
-    #ifdef EADDRNOTAVAIL
-        case EADDRNOTAVAIL: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENETDOWN
-        case ENETDOWN: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ENETUNREACH
-        case ENETUNREACH: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ENETRESET
-        case ENETRESET: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ECONNABORTED
-        case ECONNABORTED: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ECONNRESET
-        case ECONNRESET: return DRFLAC_CONNECTION_RESET;
-    #endif
-    #ifdef ENOBUFS
-        case ENOBUFS: return DRFLAC_NO_SPACE;
-    #endif
-    #ifdef EISCONN
-        case EISCONN: return DRFLAC_ALREADY_CONNECTED;
-    #endif
-    #ifdef ENOTCONN
-        case ENOTCONN: return DRFLAC_NOT_CONNECTED;
-    #endif
-    #ifdef ESHUTDOWN
-        case ESHUTDOWN: return DRFLAC_ERROR;
-    #endif
-    #ifdef ETOOMANYREFS
-        case ETOOMANYREFS: return DRFLAC_ERROR;
-    #endif
-    #ifdef ETIMEDOUT
-        case ETIMEDOUT: return DRFLAC_TIMEOUT;
-    #endif
-    #ifdef ECONNREFUSED
-        case ECONNREFUSED: return DRFLAC_CONNECTION_REFUSED;
-    #endif
-    #ifdef EHOSTDOWN
-        case EHOSTDOWN: return DRFLAC_NO_HOST;
-    #endif
-    #ifdef EHOSTUNREACH
-        case EHOSTUNREACH: return DRFLAC_NO_HOST;
-    #endif
-    #ifdef EALREADY
-        case EALREADY: return DRFLAC_IN_PROGRESS;
-    #endif
-    #ifdef EINPROGRESS
-        case EINPROGRESS: return DRFLAC_IN_PROGRESS;
-    #endif
-    #ifdef ESTALE
-        case ESTALE: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef EUCLEAN
-        case EUCLEAN: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOTNAM
-        case ENOTNAM: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENAVAIL
-        case ENAVAIL: return DRFLAC_ERROR;
-    #endif
-    #ifdef EISNAM
-        case EISNAM: return DRFLAC_ERROR;
-    #endif
-    #ifdef EREMOTEIO
-        case EREMOTEIO: return DRFLAC_IO_ERROR;
-    #endif
-    #ifdef EDQUOT
-        case EDQUOT: return DRFLAC_NO_SPACE;
-    #endif
-    #ifdef ENOMEDIUM
-        case ENOMEDIUM: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef EMEDIUMTYPE
-        case EMEDIUMTYPE: return DRFLAC_ERROR;
-    #endif
-    #ifdef ECANCELED
-        case ECANCELED: return DRFLAC_CANCELLED;
-    #endif
-    #ifdef ENOKEY
-        case ENOKEY: return DRFLAC_ERROR;
-    #endif
-    #ifdef EKEYEXPIRED
-        case EKEYEXPIRED: return DRFLAC_ERROR;
-    #endif
-    #ifdef EKEYREVOKED
-        case EKEYREVOKED: return DRFLAC_ERROR;
-    #endif
-    #ifdef EKEYREJECTED
-        case EKEYREJECTED: return DRFLAC_ERROR;
-    #endif
-    #ifdef EOWNERDEAD
-        case EOWNERDEAD: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOTRECOVERABLE
-        case ENOTRECOVERABLE: return DRFLAC_ERROR;
-    #endif
-    #ifdef ERFKILL
-        case ERFKILL: return DRFLAC_ERROR;
-    #endif
-    #ifdef EHWPOISON
-        case EHWPOISON: return DRFLAC_ERROR;
-    #endif
-        default: return DRFLAC_ERROR;
-    }
-}
-
-static drflac_result drflac_fopen(FILE** ppFile, const char* pFilePath, const char* pOpenMode)
-{
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    errno_t err;
-#endif
-
-    if (ppFile != NULL) {
-        *ppFile = NULL;  /* Safety. */
-    }
-
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRFLAC_INVALID_ARGS;
-    }
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    err = fopen_s(ppFile, pFilePath, pOpenMode);
-    if (err != 0) {
-        return drflac_result_from_errno(err);
-    }
-#else
-#if defined(_WIN32) || defined(__APPLE__)
-    *ppFile = fopen(pFilePath, pOpenMode);
-#else
-    #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && defined(_LARGEFILE64_SOURCE)
-        *ppFile = fopen64(pFilePath, pOpenMode);
-    #else
-        *ppFile = fopen(pFilePath, pOpenMode);
-    #endif
-#endif
-    if (*ppFile == NULL) {
-        drflac_result result = drflac_result_from_errno(errno);
-        if (result == DRFLAC_SUCCESS) {
-            result = DRFLAC_ERROR;   /* Just a safety check to make sure we never ever return success when pFile == NULL. */
-        }
-
-        return result;
-    }
-#endif
-
-    return DRFLAC_SUCCESS;
-}
-
-/*
-_wfopen() isn't always available in all compilation environments.
-
-    * Windows only.
-    * MSVC seems to support it universally as far back as VC6 from what I can tell (haven't checked further back).
-    * MinGW-64 (both 32- and 64-bit) seems to support it.
-    * MinGW wraps it in !defined(__STRICT_ANSI__).
-    * OpenWatcom wraps it in !defined(_NO_EXT_KEYS).
-
-This can be reviewed as compatibility issues arise. The preference is to use _wfopen_s() and _wfopen() as opposed to the wcsrtombs()
-fallback, so if you notice your compiler not detecting this properly I'm happy to look at adding support.
-*/
-#if defined(_WIN32)
-    #if defined(_MSC_VER) || defined(__MINGW64__) || (!defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
-        #define DRFLAC_HAS_WFOPEN
-    #endif
-#endif
-
-static drflac_result drflac_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (ppFile != NULL) {
-        *ppFile = NULL;  /* Safety. */
-    }
-
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRFLAC_INVALID_ARGS;
-    }
-
-#if defined(DRFLAC_HAS_WFOPEN)
-    {
-        /* Use _wfopen() on Windows. */
-    #if defined(_MSC_VER) && _MSC_VER >= 1400
-        errno_t err = _wfopen_s(ppFile, pFilePath, pOpenMode);
-        if (err != 0) {
-            return drflac_result_from_errno(err);
-        }
-    #else
-        *ppFile = _wfopen(pFilePath, pOpenMode);
-        if (*ppFile == NULL) {
-            return drflac_result_from_errno(errno);
-        }
-    #endif
-        (void)pAllocationCallbacks;
-    }
-#else
-    /*
-    Use fopen() on anything other than Windows. Requires a conversion. This is annoying because fopen() is locale specific. The only real way I can
-    think of to do this is with wcsrtombs(). Note that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for
-    maintaining state. I've checked this with -std=c89 and it works, but if somebody get's a compiler error I'll look into improving compatibility.
-    */
-    {
-        mbstate_t mbs;
-        size_t lenMB;
-        const wchar_t* pFilePathTemp = pFilePath;
-        char* pFilePathMB = NULL;
-        char pOpenModeMB[32] = {0};
-
-        /* Get the length first. */
-        DRFLAC_ZERO_OBJECT(&mbs);
-        lenMB = wcsrtombs(NULL, &pFilePathTemp, 0, &mbs);
-        if (lenMB == (size_t)-1) {
-            return drflac_result_from_errno(errno);
-        }
-
-        pFilePathMB = (char*)drflac__malloc_from_callbacks(lenMB + 1, pAllocationCallbacks);
-        if (pFilePathMB == NULL) {
-            return DRFLAC_OUT_OF_MEMORY;
-        }
-
-        pFilePathTemp = pFilePath;
-        DRFLAC_ZERO_OBJECT(&mbs);
-        wcsrtombs(pFilePathMB, &pFilePathTemp, lenMB + 1, &mbs);
-
-        /* The open mode should always consist of ASCII characters so we should be able to do a trivial conversion. */
-        {
-            size_t i = 0;
-            for (;;) {
-                if (pOpenMode[i] == 0) {
-                    pOpenModeMB[i] = '\0';
-                    break;
-                }
-
-                pOpenModeMB[i] = (char)pOpenMode[i];
-                i += 1;
-            }
-        }
-
-        *ppFile = fopen(pFilePathMB, pOpenModeMB);
-
-        drflac__free_from_callbacks(pFilePathMB, pAllocationCallbacks);
-    }
-
-    if (*ppFile == NULL) {
-        return DRFLAC_ERROR;
-    }
-#endif
-
-    return DRFLAC_SUCCESS;
-}
-
-static size_t drflac__on_read_stdio(void* pUserData, void* bufferOut, size_t bytesToRead)
-{
-    return fread(bufferOut, 1, bytesToRead, (FILE*)pUserData);
-}
-
-static drflac_bool32 drflac__on_seek_stdio(void* pUserData, int offset, drflac_seek_origin origin)
-{
-    DRFLAC_ASSERT(offset >= 0);  /* <-- Never seek backwards. */
-
-    return fseek((FILE*)pUserData, offset, (origin == drflac_seek_origin_current) ? SEEK_CUR : SEEK_SET) == 0;
-}
-
-
-DRFLAC_API drflac* drflac_open_file(const char* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    FILE* pFile;
-
-    if (drflac_fopen(&pFile, pFileName, "rb") != DRFLAC_SUCCESS) {
-        return NULL;
-    }
-
-    pFlac = drflac_open(drflac__on_read_stdio, drflac__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        fclose(pFile);
-        return NULL;
-    }
-
-    return pFlac;
-}
-
-DRFLAC_API drflac* drflac_open_file_w(const wchar_t* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    FILE* pFile;
-
-    if (drflac_wfopen(&pFile, pFileName, L"rb", pAllocationCallbacks) != DRFLAC_SUCCESS) {
-        return NULL;
-    }
-
-    pFlac = drflac_open(drflac__on_read_stdio, drflac__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        fclose(pFile);
-        return NULL;
-    }
-
-    return pFlac;
-}
-
-DRFLAC_API drflac* drflac_open_file_with_metadata(const char* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    FILE* pFile;
-
-    if (drflac_fopen(&pFile, pFileName, "rb") != DRFLAC_SUCCESS) {
-        return NULL;
-    }
-
-    pFlac = drflac_open_with_metadata_private(drflac__on_read_stdio, drflac__on_seek_stdio, onMeta, drflac_container_unknown, (void*)pFile, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        fclose(pFile);
-        return pFlac;
-    }
-
-    return pFlac;
-}
-
-DRFLAC_API drflac* drflac_open_file_with_metadata_w(const wchar_t* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    FILE* pFile;
-
-    if (drflac_wfopen(&pFile, pFileName, L"rb", pAllocationCallbacks) != DRFLAC_SUCCESS) {
-        return NULL;
-    }
-
-    pFlac = drflac_open_with_metadata_private(drflac__on_read_stdio, drflac__on_seek_stdio, onMeta, drflac_container_unknown, (void*)pFile, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        fclose(pFile);
-        return pFlac;
-    }
-
-    return pFlac;
-}
-#endif  /* DR_FLAC_NO_STDIO */
-
-static size_t drflac__on_read_memory(void* pUserData, void* bufferOut, size_t bytesToRead)
-{
-    drflac__memory_stream* memoryStream = (drflac__memory_stream*)pUserData;
-    size_t bytesRemaining;
-
-    DRFLAC_ASSERT(memoryStream != NULL);
-    DRFLAC_ASSERT(memoryStream->dataSize >= memoryStream->currentReadPos);
-
-    bytesRemaining = memoryStream->dataSize - memoryStream->currentReadPos;
-    if (bytesToRead > bytesRemaining) {
-        bytesToRead = bytesRemaining;
-    }
-
-    if (bytesToRead > 0) {
-        DRFLAC_COPY_MEMORY(bufferOut, memoryStream->data + memoryStream->currentReadPos, bytesToRead);
-        memoryStream->currentReadPos += bytesToRead;
-    }
-
-    return bytesToRead;
-}
-
-static drflac_bool32 drflac__on_seek_memory(void* pUserData, int offset, drflac_seek_origin origin)
-{
-    drflac__memory_stream* memoryStream = (drflac__memory_stream*)pUserData;
-
-    DRFLAC_ASSERT(memoryStream != NULL);
-    DRFLAC_ASSERT(offset >= 0); /* <-- Never seek backwards. */
-
-    if (offset > (drflac_int64)memoryStream->dataSize) {
-        return DRFLAC_FALSE;
-    }
-
-    if (origin == drflac_seek_origin_current) {
-        if (memoryStream->currentReadPos + offset <= memoryStream->dataSize) {
-            memoryStream->currentReadPos += offset;
-        } else {
-            return DRFLAC_FALSE;  /* Trying to seek too far forward. */
-        }
-    } else {
-        if ((drflac_uint32)offset <= memoryStream->dataSize) {
-            memoryStream->currentReadPos = offset;
-        } else {
-            return DRFLAC_FALSE;  /* Trying to seek too far forward. */
-        }
-    }
-
-    return DRFLAC_TRUE;
-}
-
-DRFLAC_API drflac* drflac_open_memory(const void* pData, size_t dataSize, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac__memory_stream memoryStream;
-    drflac* pFlac;
-
-    memoryStream.data = (const drflac_uint8*)pData;
-    memoryStream.dataSize = dataSize;
-    memoryStream.currentReadPos = 0;
-    pFlac = drflac_open(drflac__on_read_memory, drflac__on_seek_memory, &memoryStream, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    pFlac->memoryStream = memoryStream;
-
-    /* This is an awful hack... */
-#ifndef DR_FLAC_NO_OGG
-    if (pFlac->container == drflac_container_ogg)
-    {
-        drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
-        oggbs->pUserData = &pFlac->memoryStream;
-    }
-    else
-#endif
-    {
-        pFlac->bs.pUserData = &pFlac->memoryStream;
-    }
-
-    return pFlac;
-}
-
-DRFLAC_API drflac* drflac_open_memory_with_metadata(const void* pData, size_t dataSize, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac__memory_stream memoryStream;
-    drflac* pFlac;
-
-    memoryStream.data = (const drflac_uint8*)pData;
-    memoryStream.dataSize = dataSize;
-    memoryStream.currentReadPos = 0;
-    pFlac = drflac_open_with_metadata_private(drflac__on_read_memory, drflac__on_seek_memory, onMeta, drflac_container_unknown, &memoryStream, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    pFlac->memoryStream = memoryStream;
-
-    /* This is an awful hack... */
-#ifndef DR_FLAC_NO_OGG
-    if (pFlac->container == drflac_container_ogg)
-    {
-        drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
-        oggbs->pUserData = &pFlac->memoryStream;
-    }
-    else
-#endif
-    {
-        pFlac->bs.pUserData = &pFlac->memoryStream;
-    }
-
-    return pFlac;
-}
-
-
-
-DRFLAC_API drflac* drflac_open(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    return drflac_open_with_metadata_private(onRead, onSeek, NULL, drflac_container_unknown, pUserData, pUserData, pAllocationCallbacks);
-}
-DRFLAC_API drflac* drflac_open_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    return drflac_open_with_metadata_private(onRead, onSeek, NULL, container, pUserData, pUserData, pAllocationCallbacks);
-}
-
-DRFLAC_API drflac* drflac_open_with_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    return drflac_open_with_metadata_private(onRead, onSeek, onMeta, drflac_container_unknown, pUserData, pUserData, pAllocationCallbacks);
-}
-DRFLAC_API drflac* drflac_open_with_metadata_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    return drflac_open_with_metadata_private(onRead, onSeek, onMeta, container, pUserData, pUserData, pAllocationCallbacks);
-}
-
-DRFLAC_API void drflac_close(drflac* pFlac)
-{
-    if (pFlac == NULL) {
-        return;
-    }
-
-#ifndef DR_FLAC_NO_STDIO
-    /*
-    If we opened the file with drflac_open_file() we will want to close the file handle. We can know whether or not drflac_open_file()
-    was used by looking at the callbacks.
-    */
-    if (pFlac->bs.onRead == drflac__on_read_stdio) {
-        fclose((FILE*)pFlac->bs.pUserData);
-    }
-
-#ifndef DR_FLAC_NO_OGG
-    /* Need to clean up Ogg streams a bit differently due to the way the bit streaming is chained. */
-    if (pFlac->container == drflac_container_ogg) {
-        drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
-        DRFLAC_ASSERT(pFlac->bs.onRead == drflac__on_read_ogg);
-
-        if (oggbs->onRead == drflac__on_read_stdio) {
-            fclose((FILE*)oggbs->pUserData);
-        }
-    }
-#endif
-#endif
-
-    drflac__free_from_callbacks(pFlac, &pFlac->allocationCallbacks);
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 left  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 side  = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 left0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 left1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 left2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 left3 = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 side0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 side1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 side2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 side3 = pInputSamples1U32[i*4+3] << shift1;
-
-        drflac_uint32 right0 = left0 - side0;
-        drflac_uint32 right1 = left1 - side1;
-        drflac_uint32 right2 = left2 - side2;
-        drflac_uint32 right3 = left3 - side3;
-
-        pOutputSamples[i*8+0] = (drflac_int32)left0;
-        pOutputSamples[i*8+1] = (drflac_int32)right0;
-        pOutputSamples[i*8+2] = (drflac_int32)left1;
-        pOutputSamples[i*8+3] = (drflac_int32)right1;
-        pOutputSamples[i*8+4] = (drflac_int32)left2;
-        pOutputSamples[i*8+5] = (drflac_int32)right2;
-        pOutputSamples[i*8+6] = (drflac_int32)left3;
-        pOutputSamples[i*8+7] = (drflac_int32)right3;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i right = _mm_sub_epi32(left, side);
-
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t left;
-        uint32x4_t side;
-        uint32x4_t right;
-
-        left  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        right = vsubq_u32(left, side);
-
-        drflac__vst2q_u32((drflac_uint32*)pOutputSamples + i*8, vzipq_u32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_left_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_left_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s32__decode_left_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s32__decode_left_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 side  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 right = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 side0  = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 side1  = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 side2  = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 side3  = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 right0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 right1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 right2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 right3 = pInputSamples1U32[i*4+3] << shift1;
-
-        drflac_uint32 left0 = right0 + side0;
-        drflac_uint32 left1 = right1 + side1;
-        drflac_uint32 left2 = right2 + side2;
-        drflac_uint32 left3 = right3 + side3;
-
-        pOutputSamples[i*8+0] = (drflac_int32)left0;
-        pOutputSamples[i*8+1] = (drflac_int32)right0;
-        pOutputSamples[i*8+2] = (drflac_int32)left1;
-        pOutputSamples[i*8+3] = (drflac_int32)right1;
-        pOutputSamples[i*8+4] = (drflac_int32)left2;
-        pOutputSamples[i*8+5] = (drflac_int32)right2;
-        pOutputSamples[i*8+6] = (drflac_int32)left3;
-        pOutputSamples[i*8+7] = (drflac_int32)right3;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i left  = _mm_add_epi32(right, side);
-
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t side;
-        uint32x4_t right;
-        uint32x4_t left;
-
-        side  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        right = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        left  = vaddq_u32(right, side);
-
-        drflac__vst2q_u32((drflac_uint32*)pOutputSamples + i*8, vzipq_u32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_right_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_right_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s32__decode_right_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s32__decode_right_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-        mid = (mid << 1) | (side & 0x01);
-
-        pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample);
-        pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_int32 shift = unusedBitsPerSample;
-
-    if (shift > 0) {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-
-            temp0L = (mid0 + side0) << shift;
-            temp1L = (mid1 + side1) << shift;
-            temp2L = (mid2 + side2) << shift;
-            temp3L = (mid3 + side3) << shift;
-
-            temp0R = (mid0 - side0) << shift;
-            temp1R = (mid1 - side1) << shift;
-            temp2R = (mid2 - side2) << shift;
-            temp3R = (mid3 - side3) << shift;
-
-            pOutputSamples[i*8+0] = (drflac_int32)temp0L;
-            pOutputSamples[i*8+1] = (drflac_int32)temp0R;
-            pOutputSamples[i*8+2] = (drflac_int32)temp1L;
-            pOutputSamples[i*8+3] = (drflac_int32)temp1R;
-            pOutputSamples[i*8+4] = (drflac_int32)temp2L;
-            pOutputSamples[i*8+5] = (drflac_int32)temp2R;
-            pOutputSamples[i*8+6] = (drflac_int32)temp3L;
-            pOutputSamples[i*8+7] = (drflac_int32)temp3R;
-        }
-    } else {
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-
-            temp0L = (drflac_uint32)((drflac_int32)(mid0 + side0) >> 1);
-            temp1L = (drflac_uint32)((drflac_int32)(mid1 + side1) >> 1);
-            temp2L = (drflac_uint32)((drflac_int32)(mid2 + side2) >> 1);
-            temp3L = (drflac_uint32)((drflac_int32)(mid3 + side3) >> 1);
-
-            temp0R = (drflac_uint32)((drflac_int32)(mid0 - side0) >> 1);
-            temp1R = (drflac_uint32)((drflac_int32)(mid1 - side1) >> 1);
-            temp2R = (drflac_uint32)((drflac_int32)(mid2 - side2) >> 1);
-            temp3R = (drflac_uint32)((drflac_int32)(mid3 - side3) >> 1);
-
-            pOutputSamples[i*8+0] = (drflac_int32)temp0L;
-            pOutputSamples[i*8+1] = (drflac_int32)temp0R;
-            pOutputSamples[i*8+2] = (drflac_int32)temp1L;
-            pOutputSamples[i*8+3] = (drflac_int32)temp1R;
-            pOutputSamples[i*8+4] = (drflac_int32)temp2L;
-            pOutputSamples[i*8+5] = (drflac_int32)temp2R;
-            pOutputSamples[i*8+6] = (drflac_int32)temp3L;
-            pOutputSamples[i*8+7] = (drflac_int32)temp3R;
-        }
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-        mid = (mid << 1) | (side & 0x01);
-
-        pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample);
-        pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample);
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_int32 shift = unusedBitsPerSample;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i left;
-            __m128i right;
-
-            mid   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-            mid   = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-
-            left  = _mm_srai_epi32(_mm_add_epi32(mid, side), 1);
-            right = _mm_srai_epi32(_mm_sub_epi32(mid, side), 1);
-
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int32)(mid + side) >> 1;
-            pOutputSamples[i*2+1] = (drflac_int32)(mid - side) >> 1;
-        }
-    } else {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i left;
-            __m128i right;
-
-            mid   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-            mid   = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-
-            left  = _mm_slli_epi32(_mm_add_epi32(mid, side), shift);
-            right = _mm_slli_epi32(_mm_sub_epi32(mid, side), shift);
-
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift);
-            pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift);
-        }
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_int32 shift = unusedBitsPerSample;
-    int32x4_t  wbpsShift0_4; /* wbps = Wasted Bits Per Sample */
-    int32x4_t  wbpsShift1_4; /* wbps = Wasted Bits Per Sample */
-    uint32x4_t one4;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    wbpsShift0_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-    wbpsShift1_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-    one4         = vdupq_n_u32(1);
-
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t left;
-            int32x4_t right;
-
-            mid   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
-            side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
-
-            mid   = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, one4));
-
-            left  = vshrq_n_s32(vreinterpretq_s32_u32(vaddq_u32(mid, side)), 1);
-            right = vshrq_n_s32(vreinterpretq_s32_u32(vsubq_u32(mid, side)), 1);
-
-            drflac__vst2q_s32(pOutputSamples + i*8, vzipq_s32(left, right));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int32)(mid + side) >> 1;
-            pOutputSamples[i*2+1] = (drflac_int32)(mid - side) >> 1;
-        }
-    } else {
-        int32x4_t shift4;
-
-        shift -= 1;
-        shift4 = vdupq_n_s32(shift);
-
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t left;
-            int32x4_t right;
-
-            mid   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
-            side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
-
-            mid   = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, one4));
-
-            left  = vreinterpretq_s32_u32(vshlq_u32(vaddq_u32(mid, side), shift4));
-            right = vreinterpretq_s32_u32(vshlq_u32(vsubq_u32(mid, side), shift4));
-
-            drflac__vst2q_s32(pOutputSamples + i*8, vzipq_s32(left, right));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift);
-            pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift);
-        }
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_mid_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_mid_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s32__decode_mid_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s32__decode_mid_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample));
-        pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample));
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 tempL0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 tempL1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 tempL2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 tempL3 = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 tempR0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 tempR1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 tempR2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 tempR3 = pInputSamples1U32[i*4+3] << shift1;
-
-        pOutputSamples[i*8+0] = (drflac_int32)tempL0;
-        pOutputSamples[i*8+1] = (drflac_int32)tempR0;
-        pOutputSamples[i*8+2] = (drflac_int32)tempL1;
-        pOutputSamples[i*8+3] = (drflac_int32)tempR1;
-        pOutputSamples[i*8+4] = (drflac_int32)tempL2;
-        pOutputSamples[i*8+5] = (drflac_int32)tempR2;
-        pOutputSamples[i*8+6] = (drflac_int32)tempL3;
-        pOutputSamples[i*8+7] = (drflac_int32)tempR3;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0);
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1);
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0);
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1);
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    int32x4_t shift4_0 = vdupq_n_s32(shift0);
-    int32x4_t shift4_1 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        int32x4_t left;
-        int32x4_t right;
-
-        left  = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift4_0));
-        right = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift4_1));
-
-        drflac__vst2q_s32(pOutputSamples + i*8, vzipq_s32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0);
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_independent_stereo__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_independent_stereo__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s32__decode_independent_stereo__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s32__decode_independent_stereo__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s32(drflac* pFlac, drflac_uint64 framesToRead, drflac_int32* pBufferOut)
-{
-    drflac_uint64 framesRead;
-    drflac_uint32 unusedBitsPerSample;
-
-    if (pFlac == NULL || framesToRead == 0) {
-        return 0;
-    }
-
-    if (pBufferOut == NULL) {
-        return drflac__seek_forward_by_pcm_frames(pFlac, framesToRead);
-    }
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 32);
-    unusedBitsPerSample = 32 - pFlac->bitsPerSample;
-
-    framesRead = 0;
-    while (framesToRead > 0) {
-        /* If we've run out of samples in this frame, go to the next. */
-        if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                break;  /* Couldn't read the next frame, so just break from the loop and return. */
-            }
-        } else {
-            unsigned int channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-            drflac_uint64 iFirstPCMFrame = pFlac->currentFLACFrame.header.blockSizeInPCMFrames - pFlac->currentFLACFrame.pcmFramesRemaining;
-            drflac_uint64 frameCountThisIteration = framesToRead;
-
-            if (frameCountThisIteration > pFlac->currentFLACFrame.pcmFramesRemaining) {
-                frameCountThisIteration = pFlac->currentFLACFrame.pcmFramesRemaining;
-            }
-
-            if (channelCount == 2) {
-                const drflac_int32* pDecodedSamples0 = pFlac->currentFLACFrame.subframes[0].pSamplesS32 + iFirstPCMFrame;
-                const drflac_int32* pDecodedSamples1 = pFlac->currentFLACFrame.subframes[1].pSamplesS32 + iFirstPCMFrame;
-
-                switch (pFlac->currentFLACFrame.header.channelAssignment)
-                {
-                    case DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE:
-                    {
-                        drflac_read_pcm_frames_s32__decode_left_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE:
-                    {
-                        drflac_read_pcm_frames_s32__decode_right_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE:
-                    {
-                        drflac_read_pcm_frames_s32__decode_mid_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT:
-                    default:
-                    {
-                        drflac_read_pcm_frames_s32__decode_independent_stereo(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                }
-            } else {
-                /* Generic interleaving. */
-                drflac_uint64 i;
-                for (i = 0; i < frameCountThisIteration; ++i) {
-                    unsigned int j;
-                    for (j = 0; j < channelCount; ++j) {
-                        pBufferOut[(i*channelCount)+j] = (drflac_int32)((drflac_uint32)(pFlac->currentFLACFrame.subframes[j].pSamplesS32[iFirstPCMFrame + i]) << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[j].wastedBitsPerSample));
-                    }
-                }
-            }
-
-            framesRead                += frameCountThisIteration;
-            pBufferOut                += frameCountThisIteration * channelCount;
-            framesToRead              -= frameCountThisIteration;
-            pFlac->currentPCMFrame    += frameCountThisIteration;
-            pFlac->currentFLACFrame.pcmFramesRemaining -= (drflac_uint32)frameCountThisIteration;
-        }
-    }
-
-    return framesRead;
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 left  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 side  = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 right = left - side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 left0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 left1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 left2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 left3 = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 side0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 side1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 side2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 side3 = pInputSamples1U32[i*4+3] << shift1;
-
-        drflac_uint32 right0 = left0 - side0;
-        drflac_uint32 right1 = left1 - side1;
-        drflac_uint32 right2 = left2 - side2;
-        drflac_uint32 right3 = left3 - side3;
-
-        left0  >>= 16;
-        left1  >>= 16;
-        left2  >>= 16;
-        left3  >>= 16;
-
-        right0 >>= 16;
-        right1 >>= 16;
-        right2 >>= 16;
-        right3 >>= 16;
-
-        pOutputSamples[i*8+0] = (drflac_int16)left0;
-        pOutputSamples[i*8+1] = (drflac_int16)right0;
-        pOutputSamples[i*8+2] = (drflac_int16)left1;
-        pOutputSamples[i*8+3] = (drflac_int16)right1;
-        pOutputSamples[i*8+4] = (drflac_int16)left2;
-        pOutputSamples[i*8+5] = (drflac_int16)right2;
-        pOutputSamples[i*8+6] = (drflac_int16)left3;
-        pOutputSamples[i*8+7] = (drflac_int16)right3;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i right = _mm_sub_epi32(left, side);
-
-        left  = _mm_srai_epi32(left,  16);
-        right = _mm_srai_epi32(right, 16);
-
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t left;
-        uint32x4_t side;
-        uint32x4_t right;
-
-        left  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        right = vsubq_u32(left, side);
-
-        left  = vshrq_n_u32(left,  16);
-        right = vshrq_n_u32(right, 16);
-
-        drflac__vst2q_u16((drflac_uint16*)pOutputSamples + i*8, vzip_u16(vmovn_u32(left), vmovn_u32(right)));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_left_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_left_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s16__decode_left_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s16__decode_left_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 side  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 right = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 left  = right + side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 side0  = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 side1  = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 side2  = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 side3  = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 right0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 right1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 right2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 right3 = pInputSamples1U32[i*4+3] << shift1;
-
-        drflac_uint32 left0 = right0 + side0;
-        drflac_uint32 left1 = right1 + side1;
-        drflac_uint32 left2 = right2 + side2;
-        drflac_uint32 left3 = right3 + side3;
-
-        left0  >>= 16;
-        left1  >>= 16;
-        left2  >>= 16;
-        left3  >>= 16;
-
-        right0 >>= 16;
-        right1 >>= 16;
-        right2 >>= 16;
-        right3 >>= 16;
-
-        pOutputSamples[i*8+0] = (drflac_int16)left0;
-        pOutputSamples[i*8+1] = (drflac_int16)right0;
-        pOutputSamples[i*8+2] = (drflac_int16)left1;
-        pOutputSamples[i*8+3] = (drflac_int16)right1;
-        pOutputSamples[i*8+4] = (drflac_int16)left2;
-        pOutputSamples[i*8+5] = (drflac_int16)right2;
-        pOutputSamples[i*8+6] = (drflac_int16)left3;
-        pOutputSamples[i*8+7] = (drflac_int16)right3;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i left  = _mm_add_epi32(right, side);
-
-        left  = _mm_srai_epi32(left,  16);
-        right = _mm_srai_epi32(right, 16);
-
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t side;
-        uint32x4_t right;
-        uint32x4_t left;
-
-        side  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        right = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        left  = vaddq_u32(right, side);
-
-        left  = vshrq_n_u32(left,  16);
-        right = vshrq_n_u32(right, 16);
-
-        drflac__vst2q_u16((drflac_uint16*)pOutputSamples + i*8, vzip_u16(vmovn_u32(left), vmovn_u32(right)));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_right_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_right_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s16__decode_right_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s16__decode_right_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        drflac_uint32 mid  = (drflac_uint32)pInputSamples0[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = (drflac_uint32)pInputSamples1[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-        mid = (mid << 1) | (side & 0x01);
-
-        pOutputSamples[i*2+0] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample) >> 16);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample;
-
-    if (shift > 0) {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-
-            temp0L = (mid0 + side0) << shift;
-            temp1L = (mid1 + side1) << shift;
-            temp2L = (mid2 + side2) << shift;
-            temp3L = (mid3 + side3) << shift;
-
-            temp0R = (mid0 - side0) << shift;
-            temp1R = (mid1 - side1) << shift;
-            temp2R = (mid2 - side2) << shift;
-            temp3R = (mid3 - side3) << shift;
-
-            temp0L >>= 16;
-            temp1L >>= 16;
-            temp2L >>= 16;
-            temp3L >>= 16;
-
-            temp0R >>= 16;
-            temp1R >>= 16;
-            temp2R >>= 16;
-            temp3R >>= 16;
-
-            pOutputSamples[i*8+0] = (drflac_int16)temp0L;
-            pOutputSamples[i*8+1] = (drflac_int16)temp0R;
-            pOutputSamples[i*8+2] = (drflac_int16)temp1L;
-            pOutputSamples[i*8+3] = (drflac_int16)temp1R;
-            pOutputSamples[i*8+4] = (drflac_int16)temp2L;
-            pOutputSamples[i*8+5] = (drflac_int16)temp2R;
-            pOutputSamples[i*8+6] = (drflac_int16)temp3L;
-            pOutputSamples[i*8+7] = (drflac_int16)temp3R;
-        }
-    } else {
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-
-            temp0L = ((drflac_int32)(mid0 + side0) >> 1);
-            temp1L = ((drflac_int32)(mid1 + side1) >> 1);
-            temp2L = ((drflac_int32)(mid2 + side2) >> 1);
-            temp3L = ((drflac_int32)(mid3 + side3) >> 1);
-
-            temp0R = ((drflac_int32)(mid0 - side0) >> 1);
-            temp1R = ((drflac_int32)(mid1 - side1) >> 1);
-            temp2R = ((drflac_int32)(mid2 - side2) >> 1);
-            temp3R = ((drflac_int32)(mid3 - side3) >> 1);
-
-            temp0L >>= 16;
-            temp1L >>= 16;
-            temp2L >>= 16;
-            temp3L >>= 16;
-
-            temp0R >>= 16;
-            temp1R >>= 16;
-            temp2R >>= 16;
-            temp3R >>= 16;
-
-            pOutputSamples[i*8+0] = (drflac_int16)temp0L;
-            pOutputSamples[i*8+1] = (drflac_int16)temp0R;
-            pOutputSamples[i*8+2] = (drflac_int16)temp1L;
-            pOutputSamples[i*8+3] = (drflac_int16)temp1R;
-            pOutputSamples[i*8+4] = (drflac_int16)temp2L;
-            pOutputSamples[i*8+5] = (drflac_int16)temp2R;
-            pOutputSamples[i*8+6] = (drflac_int16)temp3L;
-            pOutputSamples[i*8+7] = (drflac_int16)temp3R;
-        }
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-        mid = (mid << 1) | (side & 0x01);
-
-        pOutputSamples[i*2+0] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample) >> 16);
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i left;
-            __m128i right;
-
-            mid   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-            mid   = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-
-            left  = _mm_srai_epi32(_mm_add_epi32(mid, side), 1);
-            right = _mm_srai_epi32(_mm_sub_epi32(mid, side), 1);
-
-            left  = _mm_srai_epi32(left,  16);
-            right = _mm_srai_epi32(right, 16);
-
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int16)(((drflac_int32)(mid + side) >> 1) >> 16);
-            pOutputSamples[i*2+1] = (drflac_int16)(((drflac_int32)(mid - side) >> 1) >> 16);
-        }
-    } else {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i left;
-            __m128i right;
-
-            mid   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-            mid   = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-
-            left  = _mm_slli_epi32(_mm_add_epi32(mid, side), shift);
-            right = _mm_slli_epi32(_mm_sub_epi32(mid, side), shift);
-
-            left  = _mm_srai_epi32(left,  16);
-            right = _mm_srai_epi32(right, 16);
-
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int16)(((mid + side) << shift) >> 16);
-            pOutputSamples[i*2+1] = (drflac_int16)(((mid - side) << shift) >> 16);
-        }
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample;
-    int32x4_t wbpsShift0_4; /* wbps = Wasted Bits Per Sample */
-    int32x4_t wbpsShift1_4; /* wbps = Wasted Bits Per Sample */
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    wbpsShift0_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-    wbpsShift1_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t left;
-            int32x4_t right;
-
-            mid   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
-            side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
-
-            mid   = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
-
-            left  = vshrq_n_s32(vreinterpretq_s32_u32(vaddq_u32(mid, side)), 1);
-            right = vshrq_n_s32(vreinterpretq_s32_u32(vsubq_u32(mid, side)), 1);
-
-            left  = vshrq_n_s32(left,  16);
-            right = vshrq_n_s32(right, 16);
-
-            drflac__vst2q_s16(pOutputSamples + i*8, vzip_s16(vmovn_s32(left), vmovn_s32(right)));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int16)(((drflac_int32)(mid + side) >> 1) >> 16);
-            pOutputSamples[i*2+1] = (drflac_int16)(((drflac_int32)(mid - side) >> 1) >> 16);
-        }
-    } else {
-        int32x4_t shift4;
-
-        shift -= 1;
-        shift4 = vdupq_n_s32(shift);
-
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t left;
-            int32x4_t right;
-
-            mid   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
-            side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
-
-            mid   = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
-
-            left  = vreinterpretq_s32_u32(vshlq_u32(vaddq_u32(mid, side), shift4));
-            right = vreinterpretq_s32_u32(vshlq_u32(vsubq_u32(mid, side), shift4));
-
-            left  = vshrq_n_s32(left,  16);
-            right = vshrq_n_s32(right, 16);
-
-            drflac__vst2q_s16(pOutputSamples + i*8, vzip_s16(vmovn_s32(left), vmovn_s32(right)));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int16)(((mid + side) << shift) >> 16);
-            pOutputSamples[i*2+1] = (drflac_int16)(((mid - side) << shift) >> 16);
-        }
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_mid_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_mid_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s16__decode_mid_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s16__decode_mid_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int16)((drflac_int32)((drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample)) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)((drflac_int32)((drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample)) >> 16);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 tempL0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 tempL1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 tempL2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 tempL3 = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 tempR0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 tempR1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 tempR2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 tempR3 = pInputSamples1U32[i*4+3] << shift1;
-
-        tempL0 >>= 16;
-        tempL1 >>= 16;
-        tempL2 >>= 16;
-        tempL3 >>= 16;
-
-        tempR0 >>= 16;
-        tempR1 >>= 16;
-        tempR2 >>= 16;
-        tempR3 >>= 16;
-
-        pOutputSamples[i*8+0] = (drflac_int16)tempL0;
-        pOutputSamples[i*8+1] = (drflac_int16)tempR0;
-        pOutputSamples[i*8+2] = (drflac_int16)tempL1;
-        pOutputSamples[i*8+3] = (drflac_int16)tempR1;
-        pOutputSamples[i*8+4] = (drflac_int16)tempL2;
-        pOutputSamples[i*8+5] = (drflac_int16)tempR2;
-        pOutputSamples[i*8+6] = (drflac_int16)tempL3;
-        pOutputSamples[i*8+7] = (drflac_int16)tempR3;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int16)((pInputSamples0U32[i] << shift0) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)((pInputSamples1U32[i] << shift1) >> 16);
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-
-        left  = _mm_srai_epi32(left,  16);
-        right = _mm_srai_epi32(right, 16);
-
-        /* At this point we have results. We can now pack and interleave these into a single __m128i object and then store the in the output buffer. */
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int16)((pInputSamples0U32[i] << shift0) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)((pInputSamples1U32[i] << shift1) >> 16);
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    int32x4_t shift0_4 = vdupq_n_s32(shift0);
-    int32x4_t shift1_4 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        int32x4_t left;
-        int32x4_t right;
-
-        left  = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4));
-        right = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4));
-
-        left  = vshrq_n_s32(left,  16);
-        right = vshrq_n_s32(right, 16);
-
-        drflac__vst2q_s16(pOutputSamples + i*8, vzip_s16(vmovn_s32(left), vmovn_s32(right)));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int16)((pInputSamples0U32[i] << shift0) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)((pInputSamples1U32[i] << shift1) >> 16);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_independent_stereo__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_independent_stereo__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s16__decode_independent_stereo__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s16__decode_independent_stereo__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s16(drflac* pFlac, drflac_uint64 framesToRead, drflac_int16* pBufferOut)
-{
-    drflac_uint64 framesRead;
-    drflac_uint32 unusedBitsPerSample;
-
-    if (pFlac == NULL || framesToRead == 0) {
-        return 0;
-    }
-
-    if (pBufferOut == NULL) {
-        return drflac__seek_forward_by_pcm_frames(pFlac, framesToRead);
-    }
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 32);
-    unusedBitsPerSample = 32 - pFlac->bitsPerSample;
-
-    framesRead = 0;
-    while (framesToRead > 0) {
-        /* If we've run out of samples in this frame, go to the next. */
-        if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                break;  /* Couldn't read the next frame, so just break from the loop and return. */
-            }
-        } else {
-            unsigned int channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-            drflac_uint64 iFirstPCMFrame = pFlac->currentFLACFrame.header.blockSizeInPCMFrames - pFlac->currentFLACFrame.pcmFramesRemaining;
-            drflac_uint64 frameCountThisIteration = framesToRead;
-
-            if (frameCountThisIteration > pFlac->currentFLACFrame.pcmFramesRemaining) {
-                frameCountThisIteration = pFlac->currentFLACFrame.pcmFramesRemaining;
-            }
-
-            if (channelCount == 2) {
-                const drflac_int32* pDecodedSamples0 = pFlac->currentFLACFrame.subframes[0].pSamplesS32 + iFirstPCMFrame;
-                const drflac_int32* pDecodedSamples1 = pFlac->currentFLACFrame.subframes[1].pSamplesS32 + iFirstPCMFrame;
-
-                switch (pFlac->currentFLACFrame.header.channelAssignment)
-                {
-                    case DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE:
-                    {
-                        drflac_read_pcm_frames_s16__decode_left_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE:
-                    {
-                        drflac_read_pcm_frames_s16__decode_right_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE:
-                    {
-                        drflac_read_pcm_frames_s16__decode_mid_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT:
-                    default:
-                    {
-                        drflac_read_pcm_frames_s16__decode_independent_stereo(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                }
-            } else {
-                /* Generic interleaving. */
-                drflac_uint64 i;
-                for (i = 0; i < frameCountThisIteration; ++i) {
-                    unsigned int j;
-                    for (j = 0; j < channelCount; ++j) {
-                        drflac_int32 sampleS32 = (drflac_int32)((drflac_uint32)(pFlac->currentFLACFrame.subframes[j].pSamplesS32[iFirstPCMFrame + i]) << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[j].wastedBitsPerSample));
-                        pBufferOut[(i*channelCount)+j] = (drflac_int16)(sampleS32 >> 16);
-                    }
-                }
-            }
-
-            framesRead                += frameCountThisIteration;
-            pBufferOut                += frameCountThisIteration * channelCount;
-            framesToRead              -= frameCountThisIteration;
-            pFlac->currentPCMFrame    += frameCountThisIteration;
-            pFlac->currentFLACFrame.pcmFramesRemaining -= (drflac_uint32)frameCountThisIteration;
-        }
-    }
-
-    return framesRead;
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 left  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 side  = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (float)((drflac_int32)left  / 2147483648.0);
-        pOutputSamples[i*2+1] = (float)((drflac_int32)right / 2147483648.0);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    float factor = 1 / 2147483648.0;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 left0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 left1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 left2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 left3 = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 side0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 side1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 side2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 side3 = pInputSamples1U32[i*4+3] << shift1;
-
-        drflac_uint32 right0 = left0 - side0;
-        drflac_uint32 right1 = left1 - side1;
-        drflac_uint32 right2 = left2 - side2;
-        drflac_uint32 right3 = left3 - side3;
-
-        pOutputSamples[i*8+0] = (drflac_int32)left0  * factor;
-        pOutputSamples[i*8+1] = (drflac_int32)right0 * factor;
-        pOutputSamples[i*8+2] = (drflac_int32)left1  * factor;
-        pOutputSamples[i*8+3] = (drflac_int32)right1 * factor;
-        pOutputSamples[i*8+4] = (drflac_int32)left2  * factor;
-        pOutputSamples[i*8+5] = (drflac_int32)right2 * factor;
-        pOutputSamples[i*8+6] = (drflac_int32)left3  * factor;
-        pOutputSamples[i*8+7] = (drflac_int32)right3 * factor;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left  * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)right * factor;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    __m128 factor;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    factor = _mm_set1_ps(1.0f / 8388608.0f);
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i right = _mm_sub_epi32(left, side);
-        __m128 leftf  = _mm_mul_ps(_mm_cvtepi32_ps(left),  factor);
-        __m128 rightf = _mm_mul_ps(_mm_cvtepi32_ps(right), factor);
-
-        _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-        _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left  / 8388608.0f;
-        pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    float32x4_t factor4;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    factor4  = vdupq_n_f32(1.0f / 8388608.0f);
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t left;
-        uint32x4_t side;
-        uint32x4_t right;
-        float32x4_t leftf;
-        float32x4_t rightf;
-
-        left   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        side   = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        right  = vsubq_u32(left, side);
-        leftf  = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(left)),  factor4);
-        rightf = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(right)), factor4);
-
-        drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left  / 8388608.0f;
-        pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_left_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_left_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_f32__decode_left_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_f32__decode_left_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 side  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 right = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (float)((drflac_int32)left  / 2147483648.0);
-        pOutputSamples[i*2+1] = (float)((drflac_int32)right / 2147483648.0);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    float factor = 1 / 2147483648.0;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 side0  = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 side1  = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 side2  = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 side3  = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 right0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 right1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 right2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 right3 = pInputSamples1U32[i*4+3] << shift1;
-
-        drflac_uint32 left0 = right0 + side0;
-        drflac_uint32 left1 = right1 + side1;
-        drflac_uint32 left2 = right2 + side2;
-        drflac_uint32 left3 = right3 + side3;
-
-        pOutputSamples[i*8+0] = (drflac_int32)left0  * factor;
-        pOutputSamples[i*8+1] = (drflac_int32)right0 * factor;
-        pOutputSamples[i*8+2] = (drflac_int32)left1  * factor;
-        pOutputSamples[i*8+3] = (drflac_int32)right1 * factor;
-        pOutputSamples[i*8+4] = (drflac_int32)left2  * factor;
-        pOutputSamples[i*8+5] = (drflac_int32)right2 * factor;
-        pOutputSamples[i*8+6] = (drflac_int32)left3  * factor;
-        pOutputSamples[i*8+7] = (drflac_int32)right3 * factor;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left  * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)right * factor;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    __m128 factor;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    factor = _mm_set1_ps(1.0f / 8388608.0f);
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i left  = _mm_add_epi32(right, side);
-        __m128 leftf  = _mm_mul_ps(_mm_cvtepi32_ps(left),  factor);
-        __m128 rightf = _mm_mul_ps(_mm_cvtepi32_ps(right), factor);
-
-        _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-        _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left  / 8388608.0f;
-        pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    float32x4_t factor4;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    factor4  = vdupq_n_f32(1.0f / 8388608.0f);
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t side;
-        uint32x4_t right;
-        uint32x4_t left;
-        float32x4_t leftf;
-        float32x4_t rightf;
-
-        side   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        right  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        left   = vaddq_u32(right, side);
-        leftf  = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(left)),  factor4);
-        rightf = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(right)), factor4);
-
-        drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left  / 8388608.0f;
-        pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_right_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_right_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_f32__decode_right_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_f32__decode_right_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        drflac_uint32 mid  = (drflac_uint32)pInputSamples0[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = (drflac_uint32)pInputSamples1[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-        mid = (mid << 1) | (side & 0x01);
-
-        pOutputSamples[i*2+0] = (float)((((drflac_int32)(mid + side) >> 1) << (unusedBitsPerSample)) / 2147483648.0);
-        pOutputSamples[i*2+1] = (float)((((drflac_int32)(mid - side) >> 1) << (unusedBitsPerSample)) / 2147483648.0);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample;
-    float factor = 1 / 2147483648.0;
-
-    if (shift > 0) {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-
-            temp0L = (mid0 + side0) << shift;
-            temp1L = (mid1 + side1) << shift;
-            temp2L = (mid2 + side2) << shift;
-            temp3L = (mid3 + side3) << shift;
-
-            temp0R = (mid0 - side0) << shift;
-            temp1R = (mid1 - side1) << shift;
-            temp2R = (mid2 - side2) << shift;
-            temp3R = (mid3 - side3) << shift;
-
-            pOutputSamples[i*8+0] = (drflac_int32)temp0L * factor;
-            pOutputSamples[i*8+1] = (drflac_int32)temp0R * factor;
-            pOutputSamples[i*8+2] = (drflac_int32)temp1L * factor;
-            pOutputSamples[i*8+3] = (drflac_int32)temp1R * factor;
-            pOutputSamples[i*8+4] = (drflac_int32)temp2L * factor;
-            pOutputSamples[i*8+5] = (drflac_int32)temp2R * factor;
-            pOutputSamples[i*8+6] = (drflac_int32)temp3L * factor;
-            pOutputSamples[i*8+7] = (drflac_int32)temp3R * factor;
-        }
-    } else {
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-
-            temp0L = (drflac_uint32)((drflac_int32)(mid0 + side0) >> 1);
-            temp1L = (drflac_uint32)((drflac_int32)(mid1 + side1) >> 1);
-            temp2L = (drflac_uint32)((drflac_int32)(mid2 + side2) >> 1);
-            temp3L = (drflac_uint32)((drflac_int32)(mid3 + side3) >> 1);
-
-            temp0R = (drflac_uint32)((drflac_int32)(mid0 - side0) >> 1);
-            temp1R = (drflac_uint32)((drflac_int32)(mid1 - side1) >> 1);
-            temp2R = (drflac_uint32)((drflac_int32)(mid2 - side2) >> 1);
-            temp3R = (drflac_uint32)((drflac_int32)(mid3 - side3) >> 1);
-
-            pOutputSamples[i*8+0] = (drflac_int32)temp0L * factor;
-            pOutputSamples[i*8+1] = (drflac_int32)temp0R * factor;
-            pOutputSamples[i*8+2] = (drflac_int32)temp1L * factor;
-            pOutputSamples[i*8+3] = (drflac_int32)temp1R * factor;
-            pOutputSamples[i*8+4] = (drflac_int32)temp2L * factor;
-            pOutputSamples[i*8+5] = (drflac_int32)temp2R * factor;
-            pOutputSamples[i*8+6] = (drflac_int32)temp3L * factor;
-            pOutputSamples[i*8+7] = (drflac_int32)temp3R * factor;
-        }
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-        mid = (mid << 1) | (side & 0x01);
-
-        pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample) * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample) * factor;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample - 8;
-    float factor;
-    __m128 factor128;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    factor = 1.0f / 8388608.0f;
-    factor128 = _mm_set1_ps(factor);
-
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i tempL;
-            __m128i tempR;
-            __m128  leftf;
-            __m128  rightf;
-
-            mid    = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-            mid    = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-
-            tempL  = _mm_srai_epi32(_mm_add_epi32(mid, side), 1);
-            tempR  = _mm_srai_epi32(_mm_sub_epi32(mid, side), 1);
-
-            leftf  = _mm_mul_ps(_mm_cvtepi32_ps(tempL), factor128);
-            rightf = _mm_mul_ps(_mm_cvtepi32_ps(tempR), factor128);
-
-            _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-            _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = ((drflac_int32)(mid + side) >> 1) * factor;
-            pOutputSamples[i*2+1] = ((drflac_int32)(mid - side) >> 1) * factor;
-        }
-    } else {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i tempL;
-            __m128i tempR;
-            __m128 leftf;
-            __m128 rightf;
-
-            mid    = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-            mid    = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-
-            tempL  = _mm_slli_epi32(_mm_add_epi32(mid, side), shift);
-            tempR  = _mm_slli_epi32(_mm_sub_epi32(mid, side), shift);
-
-            leftf  = _mm_mul_ps(_mm_cvtepi32_ps(tempL), factor128);
-            rightf = _mm_mul_ps(_mm_cvtepi32_ps(tempR), factor128);
-
-            _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-            _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift) * factor;
-            pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift) * factor;
-        }
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample - 8;
-    float factor;
-    float32x4_t factor4;
-    int32x4_t shift4;
-    int32x4_t wbps0_4;  /* Wasted Bits Per Sample */
-    int32x4_t wbps1_4;  /* Wasted Bits Per Sample */
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    factor  = 1.0f / 8388608.0f;
-    factor4 = vdupq_n_f32(factor);
-    wbps0_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-    wbps1_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            int32x4_t lefti;
-            int32x4_t righti;
-            float32x4_t leftf;
-            float32x4_t rightf;
-
-            uint32x4_t mid  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbps0_4);
-            uint32x4_t side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbps1_4);
-
-            mid    = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
-
-            lefti  = vshrq_n_s32(vreinterpretq_s32_u32(vaddq_u32(mid, side)), 1);
-            righti = vshrq_n_s32(vreinterpretq_s32_u32(vsubq_u32(mid, side)), 1);
-
-            leftf  = vmulq_f32(vcvtq_f32_s32(lefti),  factor4);
-            rightf = vmulq_f32(vcvtq_f32_s32(righti), factor4);
-
-            drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = ((drflac_int32)(mid + side) >> 1) * factor;
-            pOutputSamples[i*2+1] = ((drflac_int32)(mid - side) >> 1) * factor;
-        }
-    } else {
-        shift -= 1;
-        shift4 = vdupq_n_s32(shift);
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t lefti;
-            int32x4_t righti;
-            float32x4_t leftf;
-            float32x4_t rightf;
-
-            mid    = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbps0_4);
-            side   = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbps1_4);
-
-            mid    = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
-
-            lefti  = vreinterpretq_s32_u32(vshlq_u32(vaddq_u32(mid, side), shift4));
-            righti = vreinterpretq_s32_u32(vshlq_u32(vsubq_u32(mid, side), shift4));
-
-            leftf  = vmulq_f32(vcvtq_f32_s32(lefti),  factor4);
-            rightf = vmulq_f32(vcvtq_f32_s32(righti), factor4);
-
-            drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift) * factor;
-            pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift) * factor;
-        }
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_mid_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_mid_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_f32__decode_mid_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_f32__decode_mid_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (float)((drflac_int32)((drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample)) / 2147483648.0);
-        pOutputSamples[i*2+1] = (float)((drflac_int32)((drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample)) / 2147483648.0);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    float factor = 1 / 2147483648.0;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 tempL0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 tempL1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 tempL2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 tempL3 = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 tempR0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 tempR1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 tempR2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 tempR3 = pInputSamples1U32[i*4+3] << shift1;
-
-        pOutputSamples[i*8+0] = (drflac_int32)tempL0 * factor;
-        pOutputSamples[i*8+1] = (drflac_int32)tempR0 * factor;
-        pOutputSamples[i*8+2] = (drflac_int32)tempL1 * factor;
-        pOutputSamples[i*8+3] = (drflac_int32)tempR1 * factor;
-        pOutputSamples[i*8+4] = (drflac_int32)tempL2 * factor;
-        pOutputSamples[i*8+5] = (drflac_int32)tempR2 * factor;
-        pOutputSamples[i*8+6] = (drflac_int32)tempL3 * factor;
-        pOutputSamples[i*8+7] = (drflac_int32)tempR3 * factor;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0) * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1) * factor;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-
-    float factor = 1.0f / 8388608.0f;
-    __m128 factor128 = _mm_set1_ps(factor);
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i lefti;
-        __m128i righti;
-        __m128 leftf;
-        __m128 rightf;
-
-        lefti  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        righti = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-
-        leftf  = _mm_mul_ps(_mm_cvtepi32_ps(lefti),  factor128);
-        rightf = _mm_mul_ps(_mm_cvtepi32_ps(righti), factor128);
-
-        _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-        _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0) * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1) * factor;
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-
-    float factor = 1.0f / 8388608.0f;
-    float32x4_t factor4 = vdupq_n_f32(factor);
-    int32x4_t shift0_4  = vdupq_n_s32(shift0);
-    int32x4_t shift1_4  = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        int32x4_t lefti;
-        int32x4_t righti;
-        float32x4_t leftf;
-        float32x4_t rightf;
-
-        lefti  = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4));
-        righti = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4));
-
-        leftf  = vmulq_f32(vcvtq_f32_s32(lefti),  factor4);
-        rightf = vmulq_f32(vcvtq_f32_s32(righti), factor4);
-
-        drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0) * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1) * factor;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_independent_stereo__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_independent_stereo__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_f32__decode_independent_stereo__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_f32__decode_independent_stereo__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_f32(drflac* pFlac, drflac_uint64 framesToRead, float* pBufferOut)
-{
-    drflac_uint64 framesRead;
-    drflac_uint32 unusedBitsPerSample;
-
-    if (pFlac == NULL || framesToRead == 0) {
-        return 0;
-    }
-
-    if (pBufferOut == NULL) {
-        return drflac__seek_forward_by_pcm_frames(pFlac, framesToRead);
-    }
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 32);
-    unusedBitsPerSample = 32 - pFlac->bitsPerSample;
-
-    framesRead = 0;
-    while (framesToRead > 0) {
-        /* If we've run out of samples in this frame, go to the next. */
-        if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                break;  /* Couldn't read the next frame, so just break from the loop and return. */
-            }
-        } else {
-            unsigned int channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-            drflac_uint64 iFirstPCMFrame = pFlac->currentFLACFrame.header.blockSizeInPCMFrames - pFlac->currentFLACFrame.pcmFramesRemaining;
-            drflac_uint64 frameCountThisIteration = framesToRead;
-
-            if (frameCountThisIteration > pFlac->currentFLACFrame.pcmFramesRemaining) {
-                frameCountThisIteration = pFlac->currentFLACFrame.pcmFramesRemaining;
-            }
-
-            if (channelCount == 2) {
-                const drflac_int32* pDecodedSamples0 = pFlac->currentFLACFrame.subframes[0].pSamplesS32 + iFirstPCMFrame;
-                const drflac_int32* pDecodedSamples1 = pFlac->currentFLACFrame.subframes[1].pSamplesS32 + iFirstPCMFrame;
-
-                switch (pFlac->currentFLACFrame.header.channelAssignment)
-                {
-                    case DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE:
-                    {
-                        drflac_read_pcm_frames_f32__decode_left_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE:
-                    {
-                        drflac_read_pcm_frames_f32__decode_right_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE:
-                    {
-                        drflac_read_pcm_frames_f32__decode_mid_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT:
-                    default:
-                    {
-                        drflac_read_pcm_frames_f32__decode_independent_stereo(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                }
-            } else {
-                /* Generic interleaving. */
-                drflac_uint64 i;
-                for (i = 0; i < frameCountThisIteration; ++i) {
-                    unsigned int j;
-                    for (j = 0; j < channelCount; ++j) {
-                        drflac_int32 sampleS32 = (drflac_int32)((drflac_uint32)(pFlac->currentFLACFrame.subframes[j].pSamplesS32[iFirstPCMFrame + i]) << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[j].wastedBitsPerSample));
-                        pBufferOut[(i*channelCount)+j] = (float)(sampleS32 / 2147483648.0);
-                    }
-                }
-            }
-
-            framesRead                += frameCountThisIteration;
-            pBufferOut                += frameCountThisIteration * channelCount;
-            framesToRead              -= frameCountThisIteration;
-            pFlac->currentPCMFrame    += frameCountThisIteration;
-            pFlac->currentFLACFrame.pcmFramesRemaining -= (unsigned int)frameCountThisIteration;
-        }
-    }
-
-    return framesRead;
-}
-
-
-DRFLAC_API drflac_bool32 drflac_seek_to_pcm_frame(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    if (pFlac == NULL) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Don't do anything if we're already on the seek point. */
-    if (pFlac->currentPCMFrame == pcmFrameIndex) {
-        return DRFLAC_TRUE;
-    }
-
-    /*
-    If we don't know where the first frame begins then we can't seek. This will happen when the STREAMINFO block was not present
-    when the decoder was opened.
-    */
-    if (pFlac->firstFLACFramePosInBytes == 0) {
-        return DRFLAC_FALSE;
-    }
-
-    if (pcmFrameIndex == 0) {
-        pFlac->currentPCMFrame = 0;
-        return drflac__seek_to_first_frame(pFlac);
-    } else {
-        drflac_bool32 wasSuccessful = DRFLAC_FALSE;
-
-        /* Clamp the sample to the end. */
-        if (pcmFrameIndex > pFlac->totalPCMFrameCount) {
-            pcmFrameIndex = pFlac->totalPCMFrameCount;
-        }
-
-        /* If the target sample and the current sample are in the same frame we just move the position forward. */
-        if (pcmFrameIndex > pFlac->currentPCMFrame) {
-            /* Forward. */
-            drflac_uint32 offset = (drflac_uint32)(pcmFrameIndex - pFlac->currentPCMFrame);
-            if (pFlac->currentFLACFrame.pcmFramesRemaining >  offset) {
-                pFlac->currentFLACFrame.pcmFramesRemaining -= offset;
-                pFlac->currentPCMFrame = pcmFrameIndex;
-                return DRFLAC_TRUE;
-            }
-        } else {
-            /* Backward. */
-            drflac_uint32 offsetAbs = (drflac_uint32)(pFlac->currentPCMFrame - pcmFrameIndex);
-            drflac_uint32 currentFLACFramePCMFrameCount = pFlac->currentFLACFrame.header.blockSizeInPCMFrames;
-            drflac_uint32 currentFLACFramePCMFramesConsumed = currentFLACFramePCMFrameCount - pFlac->currentFLACFrame.pcmFramesRemaining;
-            if (currentFLACFramePCMFramesConsumed > offsetAbs) {
-                pFlac->currentFLACFrame.pcmFramesRemaining += offsetAbs;
-                pFlac->currentPCMFrame = pcmFrameIndex;
-                return DRFLAC_TRUE;
-            }
-        }
-
-        /*
-        Different techniques depending on encapsulation. Using the native FLAC seektable with Ogg encapsulation is a bit awkward so
-        we'll instead use Ogg's natural seeking facility.
-        */
-#ifndef DR_FLAC_NO_OGG
-        if (pFlac->container == drflac_container_ogg)
-        {
-            wasSuccessful = drflac_ogg__seek_to_pcm_frame(pFlac, pcmFrameIndex);
-        }
-        else
-#endif
-        {
-            /* First try seeking via the seek table. If this fails, fall back to a brute force seek which is much slower. */
-            if (/*!wasSuccessful && */!pFlac->_noSeekTableSeek) {
-                wasSuccessful = drflac__seek_to_pcm_frame__seek_table(pFlac, pcmFrameIndex);
-            }
-
-#if !defined(DR_FLAC_NO_CRC)
-            /* Fall back to binary search if seek table seeking fails. This requires the length of the stream to be known. */
-            if (!wasSuccessful && !pFlac->_noBinarySearchSeek && pFlac->totalPCMFrameCount > 0) {
-                wasSuccessful = drflac__seek_to_pcm_frame__binary_search(pFlac, pcmFrameIndex);
-            }
-#endif
-
-            /* Fall back to brute force if all else fails. */
-            if (!wasSuccessful && !pFlac->_noBruteForceSeek) {
-                wasSuccessful = drflac__seek_to_pcm_frame__brute_force(pFlac, pcmFrameIndex);
-            }
-        }
-
-        pFlac->currentPCMFrame = pcmFrameIndex;
-        return wasSuccessful;
-    }
-}
-
-
-
-/* High Level APIs */
-
-#if defined(SIZE_MAX)
-    #define DRFLAC_SIZE_MAX  SIZE_MAX
-#else
-    #if defined(DRFLAC_64BIT)
-        #define DRFLAC_SIZE_MAX  ((drflac_uint64)0xFFFFFFFFFFFFFFFF)
-    #else
-        #define DRFLAC_SIZE_MAX  0xFFFFFFFF
-    #endif
-#endif
-
-
-/* Using a macro as the definition of the drflac__full_decode_and_close_*() API family. Sue me. */
-#define DRFLAC_DEFINE_FULL_READ_AND_CLOSE(extension, type) \
-static type* drflac__full_read_and_close_ ## extension (drflac* pFlac, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut)\
-{                                                                                                                                                                   \
-    type* pSampleData = NULL;                                                                                                                                       \
-    drflac_uint64 totalPCMFrameCount;                                                                                                                               \
-                                                                                                                                                                    \
-    DRFLAC_ASSERT(pFlac != NULL);                                                                                                                                   \
-                                                                                                                                                                    \
-    totalPCMFrameCount = pFlac->totalPCMFrameCount;                                                                                                                 \
-                                                                                                                                                                    \
-    if (totalPCMFrameCount == 0) {                                                                                                                                  \
-        type buffer[4096];                                                                                                                                          \
-        drflac_uint64 pcmFramesRead;                                                                                                                                \
-        size_t sampleDataBufferSize = sizeof(buffer);                                                                                                               \
-                                                                                                                                                                    \
-        pSampleData = (type*)drflac__malloc_from_callbacks(sampleDataBufferSize, &pFlac->allocationCallbacks);                                                      \
-        if (pSampleData == NULL) {                                                                                                                                  \
-            goto on_error;                                                                                                                                          \
-        }                                                                                                                                                           \
-                                                                                                                                                                    \
-        while ((pcmFramesRead = (drflac_uint64)drflac_read_pcm_frames_##extension(pFlac, sizeof(buffer)/sizeof(buffer[0])/pFlac->channels, buffer)) > 0) {          \
-            if (((totalPCMFrameCount + pcmFramesRead) * pFlac->channels * sizeof(type)) > sampleDataBufferSize) {                                                   \
-                type* pNewSampleData;                                                                                                                               \
-                size_t newSampleDataBufferSize;                                                                                                                     \
-                                                                                                                                                                    \
-                newSampleDataBufferSize = sampleDataBufferSize * 2;                                                                                                 \
-                pNewSampleData = (type*)drflac__realloc_from_callbacks(pSampleData, newSampleDataBufferSize, sampleDataBufferSize, &pFlac->allocationCallbacks);    \
-                if (pNewSampleData == NULL) {                                                                                                                       \
-                    drflac__free_from_callbacks(pSampleData, &pFlac->allocationCallbacks);                                                                          \
-                    goto on_error;                                                                                                                                  \
-                }                                                                                                                                                   \
-                                                                                                                                                                    \
-                sampleDataBufferSize = newSampleDataBufferSize;                                                                                                     \
-                pSampleData = pNewSampleData;                                                                                                                       \
-            }                                                                                                                                                       \
-                                                                                                                                                                    \
-            DRFLAC_COPY_MEMORY(pSampleData + (totalPCMFrameCount*pFlac->channels), buffer, (size_t)(pcmFramesRead*pFlac->channels*sizeof(type)));                   \
-            totalPCMFrameCount += pcmFramesRead;                                                                                                                    \
-        }                                                                                                                                                           \
-                                                                                                                                                                    \
-        /* At this point everything should be decoded, but we just want to fill the unused part buffer with silence - need to                                       \
-           protect those ears from random noise! */                                                                                                                 \
-        DRFLAC_ZERO_MEMORY(pSampleData + (totalPCMFrameCount*pFlac->channels), (size_t)(sampleDataBufferSize - totalPCMFrameCount*pFlac->channels*sizeof(type)));   \
-    } else {                                                                                                                                                        \
-        drflac_uint64 dataSize = totalPCMFrameCount*pFlac->channels*sizeof(type);                                                                                   \
-        if (dataSize > DRFLAC_SIZE_MAX) {                                                                                                                           \
-            goto on_error;  /* The decoded data is too big. */                                                                                                      \
-        }                                                                                                                                                           \
-                                                                                                                                                                    \
-        pSampleData = (type*)drflac__malloc_from_callbacks((size_t)dataSize, &pFlac->allocationCallbacks);    /* <-- Safe cast as per the check above. */           \
-        if (pSampleData == NULL) {                                                                                                                                  \
-            goto on_error;                                                                                                                                          \
-        }                                                                                                                                                           \
-                                                                                                                                                                    \
-        totalPCMFrameCount = drflac_read_pcm_frames_##extension(pFlac, pFlac->totalPCMFrameCount, pSampleData);                                                     \
-    }                                                                                                                                                               \
-                                                                                                                                                                    \
-    if (sampleRateOut) *sampleRateOut = pFlac->sampleRate;                                                                                                          \
-    if (channelsOut) *channelsOut = pFlac->channels;                                                                                                                \
-    if (totalPCMFrameCountOut) *totalPCMFrameCountOut = totalPCMFrameCount;                                                                                         \
-                                                                                                                                                                    \
-    drflac_close(pFlac);                                                                                                                                            \
-    return pSampleData;                                                                                                                                             \
-                                                                                                                                                                    \
-on_error:                                                                                                                                                           \
-    drflac_close(pFlac);                                                                                                                                            \
-    return NULL;                                                                                                                                                    \
-}
-
-DRFLAC_DEFINE_FULL_READ_AND_CLOSE(s32, drflac_int32)
-DRFLAC_DEFINE_FULL_READ_AND_CLOSE(s16, drflac_int16)
-DRFLAC_DEFINE_FULL_READ_AND_CLOSE(f32, float)
-
-DRFLAC_API drflac_int32* drflac_open_and_read_pcm_frames_s32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalPCMFrameCountOut) {
-        *totalPCMFrameCountOut = 0;
-    }
-
-    pFlac = drflac_open(onRead, onSeek, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_s32(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut);
-}
-
-DRFLAC_API drflac_int16* drflac_open_and_read_pcm_frames_s16(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalPCMFrameCountOut) {
-        *totalPCMFrameCountOut = 0;
-    }
-
-    pFlac = drflac_open(onRead, onSeek, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_s16(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut);
-}
-
-DRFLAC_API float* drflac_open_and_read_pcm_frames_f32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalPCMFrameCountOut) {
-        *totalPCMFrameCountOut = 0;
-    }
-
-    pFlac = drflac_open(onRead, onSeek, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_f32(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut);
-}
-
-#ifndef DR_FLAC_NO_STDIO
-DRFLAC_API drflac_int32* drflac_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-
-    pFlac = drflac_open_file(filename, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_s32(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-
-DRFLAC_API drflac_int16* drflac_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-
-    pFlac = drflac_open_file(filename, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_s16(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-
-DRFLAC_API float* drflac_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-
-    pFlac = drflac_open_file(filename, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_f32(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-#endif
-
-DRFLAC_API drflac_int32* drflac_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-
-    pFlac = drflac_open_memory(data, dataSize, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_s32(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-
-DRFLAC_API drflac_int16* drflac_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-
-    pFlac = drflac_open_memory(data, dataSize, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_s16(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-
-DRFLAC_API float* drflac_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-
-    pFlac = drflac_open_memory(data, dataSize, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_f32(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-
-
-DRFLAC_API void drflac_free(void* p, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        drflac__free_from_callbacks(p, pAllocationCallbacks);
-    } else {
-        drflac__free_default(p, NULL);
-    }
-}
-
-
-
-
-DRFLAC_API void drflac_init_vorbis_comment_iterator(drflac_vorbis_comment_iterator* pIter, drflac_uint32 commentCount, const void* pComments)
-{
-    if (pIter == NULL) {
-        return;
-    }
-
-    pIter->countRemaining = commentCount;
-    pIter->pRunningData   = (const char*)pComments;
-}
-
-DRFLAC_API const char* drflac_next_vorbis_comment(drflac_vorbis_comment_iterator* pIter, drflac_uint32* pCommentLengthOut)
-{
-    drflac_int32 length;
-    const char* pComment;
-
-    /* Safety. */
-    if (pCommentLengthOut) {
-        *pCommentLengthOut = 0;
-    }
-
-    if (pIter == NULL || pIter->countRemaining == 0 || pIter->pRunningData == NULL) {
-        return NULL;
-    }
-
-    length = drflac__le2host_32(*(const drflac_uint32*)pIter->pRunningData);
-    pIter->pRunningData += 4;
-
-    pComment = pIter->pRunningData;
-    pIter->pRunningData += length;
-    pIter->countRemaining -= 1;
-
-    if (pCommentLengthOut) {
-        *pCommentLengthOut = length;
-    }
-
-    return pComment;
-}
-
-
-
-
-DRFLAC_API void drflac_init_cuesheet_track_iterator(drflac_cuesheet_track_iterator* pIter, drflac_uint32 trackCount, const void* pTrackData)
-{
-    if (pIter == NULL) {
-        return;
-    }
-
-    pIter->countRemaining = trackCount;
-    pIter->pRunningData   = (const char*)pTrackData;
-}
-
-DRFLAC_API drflac_bool32 drflac_next_cuesheet_track(drflac_cuesheet_track_iterator* pIter, drflac_cuesheet_track* pCuesheetTrack)
-{
-    drflac_cuesheet_track cuesheetTrack;
-    const char* pRunningData;
-    drflac_uint64 offsetHi;
-    drflac_uint64 offsetLo;
-
-    if (pIter == NULL || pIter->countRemaining == 0 || pIter->pRunningData == NULL) {
-        return DRFLAC_FALSE;
-    }
-
-    pRunningData = pIter->pRunningData;
-
-    offsetHi                   = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-    offsetLo                   = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-    cuesheetTrack.offset       = offsetLo | (offsetHi << 32);
-    cuesheetTrack.trackNumber  = pRunningData[0];                                         pRunningData += 1;
-    DRFLAC_COPY_MEMORY(cuesheetTrack.ISRC, pRunningData, sizeof(cuesheetTrack.ISRC));     pRunningData += 12;
-    cuesheetTrack.isAudio      = (pRunningData[0] & 0x80) != 0;
-    cuesheetTrack.preEmphasis  = (pRunningData[0] & 0x40) != 0;                           pRunningData += 14;
-    cuesheetTrack.indexCount   = pRunningData[0];                                         pRunningData += 1;
-    cuesheetTrack.pIndexPoints = (const drflac_cuesheet_track_index*)pRunningData;        pRunningData += cuesheetTrack.indexCount * sizeof(drflac_cuesheet_track_index);
-
-    pIter->pRunningData = pRunningData;
-    pIter->countRemaining -= 1;
-
-    if (pCuesheetTrack) {
-        *pCuesheetTrack = cuesheetTrack;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-    #pragma GCC diagnostic pop
-#endif
-#endif  /* dr_flac_c */
-#endif  /* DR_FLAC_IMPLEMENTATION */
-
-
-/*
-REVISION HISTORY
-================
-v0.12.28 - 2021-02-21
-  - Fix a warning due to referencing _MSC_VER when it is undefined.
-
-v0.12.27 - 2021-01-31
-  - Fix a static analysis warning.
-
-v0.12.26 - 2021-01-17
-  - Fix a compilation warning due to _BSD_SOURCE being deprecated.
-
-v0.12.25 - 2020-12-26
-  - Update documentation.
-
-v0.12.24 - 2020-11-29
-  - Fix ARM64/NEON detection when compiling with MSVC.
-
-v0.12.23 - 2020-11-21
-  - Fix compilation with OpenWatcom.
-
-v0.12.22 - 2020-11-01
-  - Fix an error with the previous release.
-
-v0.12.21 - 2020-11-01
-  - Fix a possible deadlock when seeking.
-  - Improve compiler support for older versions of GCC.
-
-v0.12.20 - 2020-09-08
-  - Fix a compilation error on older compilers.
-
-v0.12.19 - 2020-08-30
-  - Fix a bug due to an undefined 32-bit shift.
-
-v0.12.18 - 2020-08-14
-  - Fix a crash when compiling with clang-cl.
-
-v0.12.17 - 2020-08-02
-  - Simplify sized types.
-
-v0.12.16 - 2020-07-25
-  - Fix a compilation warning.
-
-v0.12.15 - 2020-07-06
-  - Check for negative LPC shifts and return an error.
-
-v0.12.14 - 2020-06-23
-  - Add include guard for the implementation section.
-
-v0.12.13 - 2020-05-16
-  - Add compile-time and run-time version querying.
-    - DRFLAC_VERSION_MINOR
-    - DRFLAC_VERSION_MAJOR
-    - DRFLAC_VERSION_REVISION
-    - DRFLAC_VERSION_STRING
-    - drflac_version()
-    - drflac_version_string()
-
-v0.12.12 - 2020-04-30
-  - Fix compilation errors with VC6.
-
-v0.12.11 - 2020-04-19
-  - Fix some pedantic warnings.
-  - Fix some undefined behaviour warnings.
-
-v0.12.10 - 2020-04-10
-  - Fix some bugs when trying to seek with an invalid seek table.
-
-v0.12.9 - 2020-04-05
-  - Fix warnings.
-
-v0.12.8 - 2020-04-04
-  - Add drflac_open_file_w() and drflac_open_file_with_metadata_w().
-  - Fix some static analysis warnings.
-  - Minor documentation updates.
-
-v0.12.7 - 2020-03-14
-  - Fix compilation errors with VC6.
-
-v0.12.6 - 2020-03-07
-  - Fix compilation error with Visual Studio .NET 2003.
-
-v0.12.5 - 2020-01-30
-  - Silence some static analysis warnings.
-
-v0.12.4 - 2020-01-29
-  - Silence some static analysis warnings.
-
-v0.12.3 - 2019-12-02
-  - Fix some warnings when compiling with GCC and the -Og flag.
-  - Fix a crash in out-of-memory situations.
-  - Fix potential integer overflow bug.
-  - Fix some static analysis warnings.
-  - Fix a possible crash when using custom memory allocators without a custom realloc() implementation.
-  - Fix a bug with binary search seeking where the bits per sample is not a multiple of 8.
-
-v0.12.2 - 2019-10-07
-  - Internal code clean up.
-
-v0.12.1 - 2019-09-29
-  - Fix some Clang Static Analyzer warnings.
-  - Fix an unused variable warning.
-
-v0.12.0 - 2019-09-23
-  - API CHANGE: Add support for user defined memory allocation routines. This system allows the program to specify their own memory allocation
-    routines with a user data pointer for client-specific contextual data. This adds an extra parameter to the end of the following APIs:
-    - drflac_open()
-    - drflac_open_relaxed()
-    - drflac_open_with_metadata()
-    - drflac_open_with_metadata_relaxed()
-    - drflac_open_file()
-    - drflac_open_file_with_metadata()
-    - drflac_open_memory()
-    - drflac_open_memory_with_metadata()
-    - drflac_open_and_read_pcm_frames_s32()
-    - drflac_open_and_read_pcm_frames_s16()
-    - drflac_open_and_read_pcm_frames_f32()
-    - drflac_open_file_and_read_pcm_frames_s32()
-    - drflac_open_file_and_read_pcm_frames_s16()
-    - drflac_open_file_and_read_pcm_frames_f32()
-    - drflac_open_memory_and_read_pcm_frames_s32()
-    - drflac_open_memory_and_read_pcm_frames_s16()
-    - drflac_open_memory_and_read_pcm_frames_f32()
-    Set this extra parameter to NULL to use defaults which is the same as the previous behaviour. Setting this NULL will use
-    DRFLAC_MALLOC, DRFLAC_REALLOC and DRFLAC_FREE.
-  - Remove deprecated APIs:
-    - drflac_read_s32()
-    - drflac_read_s16()
-    - drflac_read_f32()
-    - drflac_seek_to_sample()
-    - drflac_open_and_decode_s32()
-    - drflac_open_and_decode_s16()
-    - drflac_open_and_decode_f32()
-    - drflac_open_and_decode_file_s32()
-    - drflac_open_and_decode_file_s16()
-    - drflac_open_and_decode_file_f32()
-    - drflac_open_and_decode_memory_s32()
-    - drflac_open_and_decode_memory_s16()
-    - drflac_open_and_decode_memory_f32()
-  - Remove drflac.totalSampleCount which is now replaced with drflac.totalPCMFrameCount. You can emulate drflac.totalSampleCount
-    by doing pFlac->totalPCMFrameCount*pFlac->channels.
-  - Rename drflac.currentFrame to drflac.currentFLACFrame to remove ambiguity with PCM frames.
-  - Fix errors when seeking to the end of a stream.
-  - Optimizations to seeking.
-  - SSE improvements and optimizations.
-  - ARM NEON optimizations.
-  - Optimizations to drflac_read_pcm_frames_s16().
-  - Optimizations to drflac_read_pcm_frames_s32().
-
-v0.11.10 - 2019-06-26
-  - Fix a compiler error.
-
-v0.11.9 - 2019-06-16
-  - Silence some ThreadSanitizer warnings.
-
-v0.11.8 - 2019-05-21
-  - Fix warnings.
-
-v0.11.7 - 2019-05-06
-  - C89 fixes.
-
-v0.11.6 - 2019-05-05
-  - Add support for C89.
-  - Fix a compiler warning when CRC is disabled.
-  - Change license to choice of public domain or MIT-0.
-
-v0.11.5 - 2019-04-19
-  - Fix a compiler error with GCC.
-
-v0.11.4 - 2019-04-17
-  - Fix some warnings with GCC when compiling with -std=c99.
-
-v0.11.3 - 2019-04-07
-  - Silence warnings with GCC.
-
-v0.11.2 - 2019-03-10
-  - Fix a warning.
-
-v0.11.1 - 2019-02-17
-  - Fix a potential bug with seeking.
-
-v0.11.0 - 2018-12-16
-  - API CHANGE: Deprecated drflac_read_s32(), drflac_read_s16() and drflac_read_f32() and replaced them with
-    drflac_read_pcm_frames_s32(), drflac_read_pcm_frames_s16() and drflac_read_pcm_frames_f32(). The new APIs take
-    and return PCM frame counts instead of sample counts. To upgrade you will need to change the input count by
-    dividing it by the channel count, and then do the same with the return value.
-  - API_CHANGE: Deprecated drflac_seek_to_sample() and replaced with drflac_seek_to_pcm_frame(). Same rules as
-    the changes to drflac_read_*() apply.
-  - API CHANGE: Deprecated drflac_open_and_decode_*() and replaced with drflac_open_*_and_read_*(). Same rules as
-    the changes to drflac_read_*() apply.
-  - Optimizations.
-
-v0.10.0 - 2018-09-11
-  - Remove the DR_FLAC_NO_WIN32_IO option and the Win32 file IO functionality. If you need to use Win32 file IO you
-    need to do it yourself via the callback API.
-  - Fix the clang build.
-  - Fix undefined behavior.
-  - Fix errors with CUESHEET metdata blocks.
-  - Add an API for iterating over each cuesheet track in the CUESHEET metadata block. This works the same way as the
-    Vorbis comment API.
-  - Other miscellaneous bug fixes, mostly relating to invalid FLAC streams.
-  - Minor optimizations.
-
-v0.9.11 - 2018-08-29
-  - Fix a bug with sample reconstruction.
-
-v0.9.10 - 2018-08-07
-  - Improve 64-bit detection.
-
-v0.9.9 - 2018-08-05
-  - Fix C++ build on older versions of GCC.
-
-v0.9.8 - 2018-07-24
-  - Fix compilation errors.
-
-v0.9.7 - 2018-07-05
-  - Fix a warning.
-
-v0.9.6 - 2018-06-29
-  - Fix some typos.
-
-v0.9.5 - 2018-06-23
-  - Fix some warnings.
-
-v0.9.4 - 2018-06-14
-  - Optimizations to seeking.
-  - Clean up.
-
-v0.9.3 - 2018-05-22
-  - Bug fix.
-
-v0.9.2 - 2018-05-12
-  - Fix a compilation error due to a missing break statement.
-
-v0.9.1 - 2018-04-29
-  - Fix compilation error with Clang.
-
-v0.9 - 2018-04-24
-  - Fix Clang build.
-  - Start using major.minor.revision versioning.
-
-v0.8g - 2018-04-19
-  - Fix build on non-x86/x64 architectures.
-
-v0.8f - 2018-02-02
-  - Stop pretending to support changing rate/channels mid stream.
-
-v0.8e - 2018-02-01
-  - Fix a crash when the block size of a frame is larger than the maximum block size defined by the FLAC stream.
-  - Fix a crash the the Rice partition order is invalid.
-
-v0.8d - 2017-09-22
-  - Add support for decoding streams with ID3 tags. ID3 tags are just skipped.
-
-v0.8c - 2017-09-07
-  - Fix warning on non-x86/x64 architectures.
-
-v0.8b - 2017-08-19
-  - Fix build on non-x86/x64 architectures.
-
-v0.8a - 2017-08-13
-  - A small optimization for the Clang build.
-
-v0.8 - 2017-08-12
-  - API CHANGE: Rename dr_* types to drflac_*.
-  - Optimizations. This brings dr_flac back to about the same class of efficiency as the reference implementation.
-  - Add support for custom implementations of malloc(), realloc(), etc.
-  - Add CRC checking to Ogg encapsulated streams.
-  - Fix VC++ 6 build. This is only for the C++ compiler. The C compiler is not currently supported.
-  - Bug fixes.
-
-v0.7 - 2017-07-23
-  - Add support for opening a stream without a header block. To do this, use drflac_open_relaxed() / drflac_open_with_metadata_relaxed().
-
-v0.6 - 2017-07-22
-  - Add support for recovering from invalid frames. With this change, dr_flac will simply skip over invalid frames as if they
-    never existed. Frames are checked against their sync code, the CRC-8 of the frame header and the CRC-16 of the whole frame.
-
-v0.5 - 2017-07-16
-  - Fix typos.
-  - Change drflac_bool* types to unsigned.
-  - Add CRC checking. This makes dr_flac slower, but can be disabled with #define DR_FLAC_NO_CRC.
-
-v0.4f - 2017-03-10
-  - Fix a couple of bugs with the bitstreaming code.
-
-v0.4e - 2017-02-17
-  - Fix some warnings.
-
-v0.4d - 2016-12-26
-  - Add support for 32-bit floating-point PCM decoding.
-  - Use drflac_int* and drflac_uint* sized types to improve compiler support.
-  - Minor improvements to documentation.
-
-v0.4c - 2016-12-26
-  - Add support for signed 16-bit integer PCM decoding.
-
-v0.4b - 2016-10-23
-  - A minor change to drflac_bool8 and drflac_bool32 types.
-
-v0.4a - 2016-10-11
-  - Rename drBool32 to drflac_bool32 for styling consistency.
-
-v0.4 - 2016-09-29
-  - API/ABI CHANGE: Use fixed size 32-bit booleans instead of the built-in bool type.
-  - API CHANGE: Rename drflac_open_and_decode*() to drflac_open_and_decode*_s32().
-  - API CHANGE: Swap the order of "channels" and "sampleRate" parameters in drflac_open_and_decode*(). Rationale for this is to
-    keep it consistent with drflac_audio.
-
-v0.3f - 2016-09-21
-  - Fix a warning with GCC.
-
-v0.3e - 2016-09-18
-  - Fixed a bug where GCC 4.3+ was not getting properly identified.
-  - Fixed a few typos.
-  - Changed date formats to ISO 8601 (YYYY-MM-DD).
-
-v0.3d - 2016-06-11
-  - Minor clean up.
-
-v0.3c - 2016-05-28
-  - Fixed compilation error.
-
-v0.3b - 2016-05-16
-  - Fixed Linux/GCC build.
-  - Updated documentation.
-
-v0.3a - 2016-05-15
-  - Minor fixes to documentation.
-
-v0.3 - 2016-05-11
-  - Optimizations. Now at about parity with the reference implementation on 32-bit builds.
-  - Lots of clean up.
-
-v0.2b - 2016-05-10
-  - Bug fixes.
-
-v0.2a - 2016-05-10
-  - Made drflac_open_and_decode() more robust.
-  - Removed an unused debugging variable
-
-v0.2 - 2016-05-09
-  - Added support for Ogg encapsulation.
-  - API CHANGE. Have the onSeek callback take a third argument which specifies whether or not the seek
-    should be relative to the start or the current position. Also changes the seeking rules such that
-    seeking offsets will never be negative.
-  - Have drflac_open_and_decode() fail gracefully if the stream has an unknown total sample count.
-
-v0.1b - 2016-05-07
-  - Properly close the file handle in drflac_open_file() and family when the decoder fails to initialize.
-  - Removed a stale comment.
-
-v0.1a - 2016-05-05
-  - Minor formatting changes.
-  - Fixed a warning on the GCC build.
-
-v0.1 - 2016-05-03
-  - Initial versioned release.
-*/
-
-/*
-This software is available as a choice of the following licenses. Choose
-whichever you prefer.
-
-===============================================================================
-ALTERNATIVE 1 - Public Domain (www.unlicense.org)
-===============================================================================
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to <http://unlicense.org/>
-
-===============================================================================
-ALTERNATIVE 2 - MIT No Attribution
-===============================================================================
-Copyright 2020 David Reid
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
diff --git a/deps/libchdr/include/libchdr/bitstream.h b/deps/libchdr/include/libchdr/bitstream.h
deleted file mode 100644 (file)
index d376373..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/* license:BSD-3-Clause
- * copyright-holders:Aaron Giles
-***************************************************************************
-
-    bitstream.h
-
-    Helper classes for reading/writing at the bit level.
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __BITSTREAM_H__
-#define __BITSTREAM_H__
-
-#include <stdint.h>
-
-/***************************************************************************
- *  TYPE DEFINITIONS
- ***************************************************************************
- */
-
-/* helper class for reading from a bit buffer */
-struct bitstream
-{
-       uint32_t          buffer;       /* current bit accumulator */
-       int               bits;         /* number of bits in the accumulator */
-       const uint8_t *   read;         /* read pointer */
-       uint32_t          doffset;      /* byte offset within the data */
-       uint32_t          dlength;      /* length of the data */
-};
-
-struct bitstream*      create_bitstream(const void *src, uint32_t srclength);
-int                            bitstream_overflow(struct bitstream* bitstream);
-uint32_t                       bitstream_read_offset(struct bitstream* bitstream);
-
-uint32_t                       bitstream_read(struct bitstream* bitstream, int numbits);
-uint32_t                       bitstream_peek(struct bitstream* bitstream, int numbits);
-void                           bitstream_remove(struct bitstream* bitstream, int numbits);
-uint32_t                       bitstream_flush(struct bitstream* bitstream);
-
-
-#endif
diff --git a/deps/libchdr/include/libchdr/cdrom.h b/deps/libchdr/include/libchdr/cdrom.h
deleted file mode 100644 (file)
index 816e6a5..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/* license:BSD-3-Clause
- * copyright-holders:Aaron Giles
-***************************************************************************
-
-    cdrom.h
-
-    Generic MAME cd-rom implementation
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __CDROM_H__
-#define __CDROM_H__
-
-#include <stdint.h>
-#include <libchdr/chdconfig.h>
-
-/***************************************************************************
-    CONSTANTS
-***************************************************************************/
-
-/* tracks are padded to a multiple of this many frames */
-#define CD_TRACK_PADDING       (4)
-#define CD_MAX_TRACKS           (99)    /* AFAIK the theoretical limit */
-#define CD_MAX_SECTOR_DATA      (2352)
-#define CD_MAX_SUBCODE_DATA     (96)
-
-#define CD_FRAME_SIZE           (CD_MAX_SECTOR_DATA + CD_MAX_SUBCODE_DATA)
-#define CD_FRAMES_PER_HUNK      (8)
-
-#define CD_METADATA_WORDS       (1+(CD_MAX_TRACKS * 6))
-
-enum
-{
-       CD_TRACK_MODE1 = 0,         /* mode 1 2048 bytes/sector */
-       CD_TRACK_MODE1_RAW,         /* mode 1 2352 bytes/sector */
-       CD_TRACK_MODE2,             /* mode 2 2336 bytes/sector */
-       CD_TRACK_MODE2_FORM1,       /* mode 2 2048 bytes/sector */
-       CD_TRACK_MODE2_FORM2,       /* mode 2 2324 bytes/sector */
-       CD_TRACK_MODE2_FORM_MIX,    /* mode 2 2336 bytes/sector */
-       CD_TRACK_MODE2_RAW,         /* mode 2 2352 bytes / sector */
-       CD_TRACK_AUDIO,         /* redbook audio track 2352 bytes/sector (588 samples) */
-
-       CD_TRACK_RAW_DONTCARE       /* special flag for cdrom_read_data: just return me whatever is there */
-};
-
-enum
-{
-       CD_SUB_NORMAL = 0,          /* "cooked" 96 bytes per sector */
-       CD_SUB_RAW,                 /* raw uninterleaved 96 bytes per sector */
-       CD_SUB_NONE                 /* no subcode data stored */
-};
-
-#define CD_FLAG_GDROM   0x00000001  /* disc is a GD-ROM, all tracks should be stored with GD-ROM metadata */
-#define CD_FLAG_GDROMLE 0x00000002  /* legacy GD-ROM, with little-endian CDDA data */
-
-/***************************************************************************
-    FUNCTION PROTOTYPES
-***************************************************************************/
-
-#ifdef WANT_RAW_DATA_SECTOR
-/* ECC utilities */
-int ecc_verify(const uint8_t *sector);
-void ecc_generate(uint8_t *sector);
-void ecc_clear(uint8_t *sector);
-#endif
-
-
-
-/***************************************************************************
-    INLINE FUNCTIONS
-***************************************************************************/
-
-static inline uint32_t msf_to_lba(uint32_t msf)
-{
-       return ( ((msf&0x00ff0000)>>16) * 60 * 75) + (((msf&0x0000ff00)>>8) * 75) + ((msf&0x000000ff)>>0);
-}
-
-static inline uint32_t lba_to_msf(uint32_t lba)
-{
-       uint8_t m, s, f;
-
-       m = lba / (60 * 75);
-       lba -= m * (60 * 75);
-       s = lba / 75;
-       f = lba % 75;
-
-       return ((m / 10) << 20) | ((m % 10) << 16) |
-                       ((s / 10) << 12) | ((s % 10) <<  8) |
-                       ((f / 10) <<  4) | ((f % 10) <<  0);
-}
-
-/**
- * segacd needs it like this.. investigate
- * Angelo also says PCE tracks often start playing at the
- * wrong address.. related?
- **/
-static inline uint32_t lba_to_msf_alt(int lba)
-{
-       uint32_t ret = 0;
-
-       ret |= ((lba / (60 * 75))&0xff)<<16;
-       ret |= (((lba / 75) % 60)&0xff)<<8;
-       ret |= ((lba % 75)&0xff)<<0;
-
-       return ret;
-}
-
-#endif  /* __CDROM_H__ */
diff --git a/deps/libchdr/include/libchdr/chd.h b/deps/libchdr/include/libchdr/chd.h
deleted file mode 100644 (file)
index 61b149d..0000000
+++ /dev/null
@@ -1,425 +0,0 @@
-/***************************************************************************
-
-    chd.h
-
-    MAME Compressed Hunks of Data file format
-
-****************************************************************************
-
-    Copyright Aaron Giles
-    All rights reserved.
-
-    Redistribution and use in source and binary forms, with or without
-    modification, are permitted provided that the following conditions are
-    met:
-
-        * Redistributions of source code must retain the above copyright
-          notice, this list of conditions and the following disclaimer.
-        * Redistributions in binary form must reproduce the above copyright
-          notice, this list of conditions and the following disclaimer in
-          the documentation and/or other materials provided with the
-          distribution.
-        * Neither the name 'MAME' nor the names of its contributors may be
-          used to endorse or promote products derived from this software
-          without specific prior written permission.
-
-    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
-    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
-    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
-    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-    POSSIBILITY OF SUCH DAMAGE.
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __CHD_H__
-#define __CHD_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <libchdr/coretypes.h>
-#include <libchdr/chdconfig.h>
-
-/***************************************************************************
-
-    Compressed Hunks of Data header format. All numbers are stored in
-    Motorola (big-endian) byte ordering. The header is 76 (V1) or 80 (V2)
-    bytes long.
-
-    V1 header:
-
-    [  0] char   tag[8];        // 'MComprHD'
-    [  8] UINT32 length;        // length of header (including tag and length fields)
-    [ 12] UINT32 version;       // drive format version
-    [ 16] UINT32 flags;         // flags (see below)
-    [ 20] UINT32 compression;   // compression type
-    [ 24] UINT32 hunksize;      // 512-byte sectors per hunk
-    [ 28] UINT32 totalhunks;    // total # of hunks represented
-    [ 32] UINT32 cylinders;     // number of cylinders on hard disk
-    [ 36] UINT32 heads;         // number of heads on hard disk
-    [ 40] UINT32 sectors;       // number of sectors on hard disk
-    [ 44] UINT8  md5[16];       // MD5 checksum of raw data
-    [ 60] UINT8  parentmd5[16]; // MD5 checksum of parent file
-    [ 76] (V1 header length)
-
-    V2 header:
-
-    [  0] char   tag[8];        // 'MComprHD'
-    [  8] UINT32 length;        // length of header (including tag and length fields)
-    [ 12] UINT32 version;       // drive format version
-    [ 16] UINT32 flags;         // flags (see below)
-    [ 20] UINT32 compression;   // compression type
-    [ 24] UINT32 hunksize;      // seclen-byte sectors per hunk
-    [ 28] UINT32 totalhunks;    // total # of hunks represented
-    [ 32] UINT32 cylinders;     // number of cylinders on hard disk
-    [ 36] UINT32 heads;         // number of heads on hard disk
-    [ 40] UINT32 sectors;       // number of sectors on hard disk
-    [ 44] UINT8  md5[16];       // MD5 checksum of raw data
-    [ 60] UINT8  parentmd5[16]; // MD5 checksum of parent file
-    [ 76] UINT32 seclen;        // number of bytes per sector
-    [ 80] (V2 header length)
-
-    V3 header:
-
-    [  0] char   tag[8];        // 'MComprHD'
-    [  8] UINT32 length;        // length of header (including tag and length fields)
-    [ 12] UINT32 version;       // drive format version
-    [ 16] UINT32 flags;         // flags (see below)
-    [ 20] UINT32 compression;   // compression type
-    [ 24] UINT32 totalhunks;    // total # of hunks represented
-    [ 28] UINT64 logicalbytes;  // logical size of the data (in bytes)
-    [ 36] UINT64 metaoffset;    // offset to the first blob of metadata
-    [ 44] UINT8  md5[16];       // MD5 checksum of raw data
-    [ 60] UINT8  parentmd5[16]; // MD5 checksum of parent file
-    [ 76] UINT32 hunkbytes;     // number of bytes per hunk
-    [ 80] UINT8  sha1[20];      // SHA1 checksum of raw data
-    [100] UINT8  parentsha1[20];// SHA1 checksum of parent file
-    [120] (V3 header length)
-
-    V4 header:
-
-    [  0] char   tag[8];        // 'MComprHD'
-    [  8] UINT32 length;        // length of header (including tag and length fields)
-    [ 12] UINT32 version;       // drive format version
-    [ 16] UINT32 flags;         // flags (see below)
-    [ 20] UINT32 compression;   // compression type
-    [ 24] UINT32 totalhunks;    // total # of hunks represented
-    [ 28] UINT64 logicalbytes;  // logical size of the data (in bytes)
-    [ 36] UINT64 metaoffset;    // offset to the first blob of metadata
-    [ 44] UINT32 hunkbytes;     // number of bytes per hunk
-    [ 48] UINT8  sha1[20];      // combined raw+meta SHA1
-    [ 68] UINT8  parentsha1[20];// combined raw+meta SHA1 of parent
-    [ 88] UINT8  rawsha1[20];   // raw data SHA1
-    [108] (V4 header length)
-
-    Flags:
-        0x00000001 - set if this drive has a parent
-        0x00000002 - set if this drive allows writes
-
-   =========================================================================
-
-    V5 header:
-
-    [  0] char   tag[8];        // 'MComprHD'
-    [  8] uint32_t length;        // length of header (including tag and length fields)
-    [ 12] uint32_t version;       // drive format version
-    [ 16] uint32_t compressors[4];// which custom compressors are used?
-    [ 32] uint64_t logicalbytes;  // logical size of the data (in bytes)
-    [ 40] uint64_t mapoffset;     // offset to the map
-    [ 48] uint64_t metaoffset;    // offset to the first blob of metadata
-    [ 56] uint32_t hunkbytes;     // number of bytes per hunk (512k maximum)
-    [ 60] uint32_t unitbytes;     // number of bytes per unit within each hunk
-    [ 64] uint8_t  rawsha1[20];   // raw data SHA1
-    [ 84] uint8_t  sha1[20];      // combined raw+meta SHA1
-    [104] uint8_t  parentsha1[20];// combined raw+meta SHA1 of parent
-    [124] (V5 header length)
-
-    If parentsha1 != 0, we have a parent (no need for flags)
-    If compressors[0] == 0, we are uncompressed (including maps)
-
-    V5 uncompressed map format:
-
-    [  0] uint32_t offset;        // starting offset / hunk size
-
-    V5 compressed map format header:
-
-    [  0] uint32_t length;        // length of compressed map
-    [  4] UINT48 datastart;     // offset of first block
-    [ 10] uint16_t crc;           // crc-16 of the map
-    [ 12] uint8_t lengthbits;     // bits used to encode complength
-    [ 13] uint8_t hunkbits;       // bits used to encode self-refs
-    [ 14] uint8_t parentunitbits; // bits used to encode parent unit refs
-    [ 15] uint8_t reserved;       // future use
-    [ 16] (compressed header length)
-
-    Each compressed map entry, once expanded, looks like:
-
-    [  0] uint8_t compression;    // compression type
-    [  1] UINT24 complength;    // compressed length
-    [  4] UINT48 offset;        // offset
-    [ 10] uint16_t crc;           // crc-16 of the data
-
-***************************************************************************/
-
-
-/***************************************************************************
-    CONSTANTS
-***************************************************************************/
-
-/* header information */
-#define CHD_HEADER_VERSION                     5
-#define CHD_V1_HEADER_SIZE                     76
-#define CHD_V2_HEADER_SIZE                     80
-#define CHD_V3_HEADER_SIZE                     120
-#define CHD_V4_HEADER_SIZE                     108
-#define CHD_V5_HEADER_SIZE          124
-
-#define CHD_MAX_HEADER_SIZE                    CHD_V5_HEADER_SIZE
-
-/* checksumming information */
-#define CHD_MD5_BYTES                          16
-#define CHD_SHA1_BYTES                         20
-
-/* CHD global flags */
-#define CHDFLAGS_HAS_PARENT                    0x00000001
-#define CHDFLAGS_IS_WRITEABLE          0x00000002
-#define CHDFLAGS_UNDEFINED                     0xfffffffc
-
-#define CHD_MAKE_TAG(a,b,c,d)       (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
-
-/* compression types */
-#define CHDCOMPRESSION_NONE                    0
-#define CHDCOMPRESSION_ZLIB                    1
-#define CHDCOMPRESSION_ZLIB_PLUS       2
-#define CHDCOMPRESSION_AV                      3
-
-#define CHD_CODEC_NONE 0
-#define CHD_CODEC_ZLIB                         CHD_MAKE_TAG('z','l','i','b')
-/* general codecs with CD frontend */
-#define CHD_CODEC_CD_ZLIB                      CHD_MAKE_TAG('c','d','z','l')
-#define CHD_CODEC_CD_LZMA                      CHD_MAKE_TAG('c','d','l','z')
-#define CHD_CODEC_CD_FLAC                      CHD_MAKE_TAG('c','d','f','l')
-
-/* A/V codec configuration parameters */
-#define AV_CODEC_COMPRESS_CONFIG       1
-#define AV_CODEC_DECOMPRESS_CONFIG     2
-
-/* metadata parameters */
-#define CHDMETATAG_WILDCARD                    0
-#define CHD_METAINDEX_APPEND           ((UINT32)-1)
-
-/* metadata flags */
-#define CHD_MDFLAGS_CHECKSUM           0x01            /* indicates data is checksummed */
-
-/* standard hard disk metadata */
-#define HARD_DISK_METADATA_TAG         CHD_MAKE_TAG('G','D','D','D')
-#define HARD_DISK_METADATA_FORMAT      "CYLS:%d,HEADS:%d,SECS:%d,BPS:%d"
-
-/* hard disk identify information */
-#define HARD_DISK_IDENT_METADATA_TAG CHD_MAKE_TAG('I','D','N','T')
-
-/* hard disk key information */
-#define HARD_DISK_KEY_METADATA_TAG     CHD_MAKE_TAG('K','E','Y',' ')
-
-/* pcmcia CIS information */
-#define PCMCIA_CIS_METADATA_TAG                CHD_MAKE_TAG('C','I','S',' ')
-
-/* standard CD-ROM metadata */
-#define CDROM_OLD_METADATA_TAG         CHD_MAKE_TAG('C','H','C','D')
-#define CDROM_TRACK_METADATA_TAG       CHD_MAKE_TAG('C','H','T','R')
-#define CDROM_TRACK_METADATA_FORMAT    "TRACK:%d TYPE:%s SUBTYPE:%s FRAMES:%d"
-#define CDROM_TRACK_METADATA2_TAG      CHD_MAKE_TAG('C','H','T','2')
-#define CDROM_TRACK_METADATA2_FORMAT   "TRACK:%d TYPE:%s SUBTYPE:%s FRAMES:%d PREGAP:%d PGTYPE:%s PGSUB:%s POSTGAP:%d"
-#define GDROM_OLD_METADATA_TAG         CHD_MAKE_TAG('C','H','G','T')
-#define GDROM_TRACK_METADATA_TAG       CHD_MAKE_TAG('C', 'H', 'G', 'D')
-#define GDROM_TRACK_METADATA_FORMAT    "TRACK:%d TYPE:%s SUBTYPE:%s FRAMES:%d PAD:%d PREGAP:%d PGTYPE:%s PGSUB:%s POSTGAP:%d"
-
-/* standard A/V metadata */
-#define AV_METADATA_TAG                                CHD_MAKE_TAG('A','V','A','V')
-#define AV_METADATA_FORMAT                     "FPS:%d.%06d WIDTH:%d HEIGHT:%d INTERLACED:%d CHANNELS:%d SAMPLERATE:%d"
-
-/* A/V laserdisc frame metadata */
-#define AV_LD_METADATA_TAG                     CHD_MAKE_TAG('A','V','L','D')
-
-/* CHD open values */
-#define CHD_OPEN_READ                          1
-#define CHD_OPEN_READWRITE                     2
-
-/* error types */
-enum _chd_error
-{
-       CHDERR_NONE,
-       CHDERR_NO_INTERFACE,
-       CHDERR_OUT_OF_MEMORY,
-       CHDERR_INVALID_FILE,
-       CHDERR_INVALID_PARAMETER,
-       CHDERR_INVALID_DATA,
-       CHDERR_FILE_NOT_FOUND,
-       CHDERR_REQUIRES_PARENT,
-       CHDERR_FILE_NOT_WRITEABLE,
-       CHDERR_READ_ERROR,
-       CHDERR_WRITE_ERROR,
-       CHDERR_CODEC_ERROR,
-       CHDERR_INVALID_PARENT,
-       CHDERR_HUNK_OUT_OF_RANGE,
-       CHDERR_DECOMPRESSION_ERROR,
-       CHDERR_COMPRESSION_ERROR,
-       CHDERR_CANT_CREATE_FILE,
-       CHDERR_CANT_VERIFY,
-       CHDERR_NOT_SUPPORTED,
-       CHDERR_METADATA_NOT_FOUND,
-       CHDERR_INVALID_METADATA_SIZE,
-       CHDERR_UNSUPPORTED_VERSION,
-       CHDERR_VERIFY_INCOMPLETE,
-       CHDERR_INVALID_METADATA,
-       CHDERR_INVALID_STATE,
-       CHDERR_OPERATION_PENDING,
-       CHDERR_NO_ASYNC_OPERATION,
-       CHDERR_UNSUPPORTED_FORMAT
-};
-typedef enum _chd_error chd_error;
-
-
-
-/***************************************************************************
-    TYPE DEFINITIONS
-***************************************************************************/
-
-/* opaque types */
-typedef struct _chd_file chd_file;
-
-
-/* extract header structure (NOT the on-disk header structure) */
-typedef struct _chd_header chd_header;
-struct _chd_header
-{
-       UINT32          length;                                         /* length of header data */
-       UINT32          version;                                        /* drive format version */
-       UINT32          flags;                                          /* flags field */
-       UINT32          compression[4];                         /* compression type */
-       UINT32          hunkbytes;                                      /* number of bytes per hunk */
-       UINT32          totalhunks;                                     /* total # of hunks represented */
-       UINT64          logicalbytes;                           /* logical size of the data */
-       UINT64          metaoffset;                                     /* offset in file of first metadata */
-       UINT64          mapoffset;                                      /* TOOD V5 */
-       UINT8           md5[CHD_MD5_BYTES];                     /* overall MD5 checksum */
-       UINT8           parentmd5[CHD_MD5_BYTES];       /* overall MD5 checksum of parent */
-       UINT8           sha1[CHD_SHA1_BYTES];           /* overall SHA1 checksum */
-       UINT8           rawsha1[CHD_SHA1_BYTES];        /* SHA1 checksum of raw data */
-       UINT8           parentsha1[CHD_SHA1_BYTES];     /* overall SHA1 checksum of parent */
-       UINT32          unitbytes;                                      /* TODO V5 */
-       UINT64          unitcount;                                      /* TODO V5 */
-    UINT32      hunkcount;                  /* TODO V5 */
-
-    /* map information */
-    UINT32      mapentrybytes;              /* length of each entry in a map (V5) */
-    UINT8*      rawmap;                     /* raw map data */
-
-       UINT32          obsolete_cylinders;                     /* obsolete field -- do not use! */
-       UINT32          obsolete_sectors;                       /* obsolete field -- do not use! */
-       UINT32          obsolete_heads;                         /* obsolete field -- do not use! */
-       UINT32          obsolete_hunksize;                      /* obsolete field -- do not use! */
-};
-
-
-/* structure for returning information about a verification pass */
-typedef struct _chd_verify_result chd_verify_result;
-struct _chd_verify_result
-{
-       UINT8           md5[CHD_MD5_BYTES];                     /* overall MD5 checksum */
-       UINT8           sha1[CHD_SHA1_BYTES];           /* overall SHA1 checksum */
-       UINT8           rawsha1[CHD_SHA1_BYTES];        /* SHA1 checksum of raw data */
-       UINT8           metasha1[CHD_SHA1_BYTES];       /* SHA1 checksum of metadata */
-};
-
-
-
-/***************************************************************************
-    FUNCTION PROTOTYPES
-***************************************************************************/
-
-#ifdef _MSC_VER
-#ifdef CHD_DLL
-#ifdef CHD_DLL_EXPORTS
-#define CHD_EXPORT __declspec(dllexport)
-#else
-#define CHD_EXPORT __declspec(dllimport)
-#endif
-#else
-#define CHD_EXPORT
-#endif
-#else
-#define CHD_EXPORT __attribute__ ((visibility("default")))
-#endif
-
-/* ----- CHD file management ----- */
-
-/* create a new CHD file fitting the given description */
-/* chd_error chd_create(const char *filename, UINT64 logicalbytes, UINT32 hunkbytes, UINT32 compression, chd_file *parent); */
-
-/* same as chd_create(), but accepts an already-opened core_file object */
-/* chd_error chd_create_file(core_file *file, UINT64 logicalbytes, UINT32 hunkbytes, UINT32 compression, chd_file *parent); */
-
-/* open an existing CHD file */
-CHD_EXPORT chd_error chd_open_file(core_file *file, int mode, chd_file *parent, chd_file **chd);
-CHD_EXPORT chd_error chd_open(const char *filename, int mode, chd_file *parent, chd_file **chd);
-
-/* precache underlying file */
-CHD_EXPORT chd_error chd_precache(chd_file *chd);
-
-/* close a CHD file */
-CHD_EXPORT void chd_close(chd_file *chd);
-
-/* return the associated core_file */
-CHD_EXPORT core_file *chd_core_file(chd_file *chd);
-
-/* return an error string for the given CHD error */
-CHD_EXPORT const char *chd_error_string(chd_error err);
-
-
-
-/* ----- CHD header management ----- */
-
-/* return a pointer to the extracted CHD header data */
-CHD_EXPORT const chd_header *chd_get_header(chd_file *chd);
-
-
-
-
-/* ----- core data read/write ----- */
-
-/* read one hunk from the CHD file */
-CHD_EXPORT chd_error chd_read(chd_file *chd, UINT32 hunknum, void *buffer);
-
-
-
-/* ----- metadata management ----- */
-
-/* get indexed metadata of a particular sort */
-CHD_EXPORT chd_error chd_get_metadata(chd_file *chd, UINT32 searchtag, UINT32 searchindex, void *output, UINT32 outputlen, UINT32 *resultlen, UINT32 *resulttag, UINT8 *resultflags);
-
-
-
-
-/* ----- codec interfaces ----- */
-
-/* set internal codec parameters */
-CHD_EXPORT chd_error chd_codec_config(chd_file *chd, int param, void *config);
-
-/* return a string description of a codec */
-CHD_EXPORT const char *chd_get_codec_name(UINT32 codec);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __CHD_H__ */
diff --git a/deps/libchdr/include/libchdr/chdconfig.h b/deps/libchdr/include/libchdr/chdconfig.h
deleted file mode 100644 (file)
index 752038b..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __CHDCONFIG_H__
-#define __CHDCONFIG_H__
-
-/* Configure CHDR features here */
-#define WANT_RAW_DATA_SECTOR    1
-#define WANT_SUBCODE            1
-#define NEED_CACHE_HUNK         1
-#define VERIFY_BLOCK_CRC        1
-
-#endif
diff --git a/deps/libchdr/include/libchdr/coretypes.h b/deps/libchdr/include/libchdr/coretypes.h
deleted file mode 100644 (file)
index 30f892f..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef __CORETYPES_H__
-#define __CORETYPES_H__
-
-#include <stdint.h>
-#include <stdio.h>
-
-#ifdef USE_LIBRETRO_VFS
-#include <streams/file_stream_transforms.h>
-#endif
-
-#define ARRAY_LENGTH(x) (sizeof(x)/sizeof(x[0]))
-
-typedef uint64_t UINT64;
-typedef uint32_t UINT32;
-typedef uint16_t UINT16;
-typedef uint8_t UINT8;
-
-typedef int64_t INT64;
-typedef int32_t INT32;
-typedef int16_t INT16;
-typedef int8_t INT8;
-
-#define core_file FILE
-#define core_fopen(file) fopen(file, "rb")
-#if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WIN64__)
-       #define core_fseek _fseeki64
-       #define core_ftell _ftelli64
-#elif defined(_LARGEFILE_SOURCE) && defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
-       #define core_fseek fseeko64
-       #define core_ftell ftello64
-#else
-       #define core_fseek fseeko
-       #define core_ftell ftello
-#endif
-#define core_fread(fc, buff, len) fread(buff, 1, len, fc)
-#define core_fclose fclose
-
-static UINT64 core_fsize(core_file *f)
-{
-    UINT64 rv;
-    UINT64 p = core_ftell(f);
-    core_fseek(f, 0, SEEK_END);
-    rv = core_ftell(f);
-    core_fseek(f, p, SEEK_SET);
-    return rv;
-}
-
-#endif
diff --git a/deps/libchdr/include/libchdr/flac.h b/deps/libchdr/include/libchdr/flac.h
deleted file mode 100644 (file)
index bff255b..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/* license:BSD-3-Clause
- * copyright-holders:Aaron Giles
- ***************************************************************************
-
-    flac.h
-
-    FLAC compression wrappers
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __FLAC_H__
-#define __FLAC_H__
-
-#include <stdint.h>
-
-/***************************************************************************
- *  TYPE DEFINITIONS
- ***************************************************************************
- */
-
-typedef struct _flac_decoder flac_decoder;
-struct _flac_decoder {
-               /* output state */
-       void *                  decoder;                                /* actual encoder */
-       uint32_t                sample_rate;                    /* decoded sample rate */
-       uint8_t                 channels;                               /* decoded number of channels */
-       uint8_t                 bits_per_sample;                /* decoded bits per sample */
-       uint32_t                compressed_offset;              /* current offset in compressed data */
-       const uint8_t *         compressed_start;               /* start of compressed data */
-       uint32_t                compressed_length;              /* length of compressed data */
-       const uint8_t *         compressed2_start;              /* start of compressed data */
-       uint32_t                compressed2_length;             /* length of compressed data */
-       int16_t *               uncompressed_start[8];  /* pointer to start of uncompressed data (up to 8 streams) */
-       uint32_t                uncompressed_offset;    /* current position in uncompressed data */
-       uint32_t                uncompressed_length;    /* length of uncompressed data */
-       int                     uncompressed_swap;              /* swap uncompressed sample data */
-       uint8_t                 custom_header[0x2a];    /* custom header */
-};
-
-/* ======================> flac_decoder */
-
-int            flac_decoder_init(flac_decoder* decoder);
-void           flac_decoder_free(flac_decoder* decoder);
-int            flac_decoder_reset(flac_decoder* decoder, uint32_t sample_rate, uint8_t num_channels, uint32_t block_size, const void *buffer, uint32_t length);
-int            flac_decoder_decode_interleaved(flac_decoder* decoder, int16_t *samples, uint32_t num_samples, int swap_endian);
-uint32_t       flac_decoder_finish(flac_decoder* decoder);
-
-#endif /* __FLAC_H__ */
diff --git a/deps/libchdr/include/libchdr/huffman.h b/deps/libchdr/include/libchdr/huffman.h
deleted file mode 100644 (file)
index 6c9f511..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/* license:BSD-3-Clause
- * copyright-holders:Aaron Giles
- ***************************************************************************
-
-    huffman.h
-
-    Static Huffman compression and decompression helpers.
-
-***************************************************************************/
-
-#pragma once
-
-#ifndef __HUFFMAN_H__
-#define __HUFFMAN_H__
-
-#include <libchdr/bitstream.h>
-
-
-/***************************************************************************
- *  CONSTANTS
- ***************************************************************************
- */
-
-enum huffman_error
-{
-       HUFFERR_NONE = 0,
-       HUFFERR_TOO_MANY_BITS,
-       HUFFERR_INVALID_DATA,
-       HUFFERR_INPUT_BUFFER_TOO_SMALL,
-       HUFFERR_OUTPUT_BUFFER_TOO_SMALL,
-       HUFFERR_INTERNAL_INCONSISTENCY,
-       HUFFERR_TOO_MANY_CONTEXTS
-};
-
-/***************************************************************************
- *  TYPE DEFINITIONS
- ***************************************************************************
- */
-
-typedef uint16_t lookup_value;
-
-/* a node in the huffman tree */
-struct node_t
-{
-       struct node_t*          parent;         /* pointer to parent node */
-       uint32_t                        count;          /* number of hits on this node */
-       uint32_t                        weight;         /* assigned weight of this node */
-       uint32_t                        bits;           /* bits used to encode the node */
-       uint8_t                         numbits;        /* number of bits needed for this node */
-};
-
-/* ======================> huffman_context_base */
-
-/* context class for decoding */
-struct huffman_decoder
-{
-       /* internal state */
-       uint32_t                        numcodes;             /* number of total codes being processed */
-       uint8_t                         maxbits;           /* maximum bits per code */
-       uint8_t                         prevdata;             /* value of the previous data (for delta-RLE encoding) */
-       int                     rleremaining;         /* number of RLE bytes remaining (for delta-RLE encoding) */
-       lookup_value *          lookup;               /* pointer to the lookup table */
-       struct node_t *     huffnode;             /* array of nodes */
-       uint32_t *              datahisto;            /* histogram of data values */
-
-       /* array versions of the info we need */
-#if 0
-       node_t*                 huffnode_array; /* [_NumCodes]; */
-       lookup_value*   lookup_array; /* [1 << _MaxBits]; */
-#endif
-};
-
-/* ======================> huffman_decoder */
-
-struct huffman_decoder* create_huffman_decoder(int numcodes, int maxbits);
-void delete_huffman_decoder(struct huffman_decoder* decoder);
-
-/* single item operations */
-uint32_t huffman_decode_one(struct huffman_decoder* decoder, struct bitstream* bitbuf);
-
-enum huffman_error huffman_import_tree_rle(struct huffman_decoder* decoder, struct bitstream* bitbuf);
-enum huffman_error huffman_import_tree_huffman(struct huffman_decoder* decoder, struct bitstream* bitbuf);
-
-int huffman_build_tree(struct huffman_decoder* decoder, uint32_t totaldata, uint32_t totalweight);
-enum huffman_error huffman_assign_canonical_codes(struct huffman_decoder* decoder);
-enum huffman_error huffman_compute_tree_from_histo(struct huffman_decoder* decoder);
-
-void huffman_build_lookup_table(struct huffman_decoder* decoder);
-
-#endif
diff --git a/deps/libchdr/src/libchdr_bitstream.c b/deps/libchdr/src/libchdr_bitstream.c
deleted file mode 100644 (file)
index c82a67d..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/* license:BSD-3-Clause
- * copyright-holders:Aaron Giles
-***************************************************************************
-
-    bitstream.c
-
-    Helper classes for reading/writing at the bit level.
-
-***************************************************************************/
-
-#include <stdlib.h>
-#include <libchdr/bitstream.h>
-
-/***************************************************************************
- *  INLINE FUNCTIONS
- ***************************************************************************
- */
-
-int bitstream_overflow(struct bitstream* bitstream) { return ((bitstream->doffset - bitstream->bits / 8) > bitstream->dlength); }
-
-/*-------------------------------------------------
- *  create_bitstream - constructor
- *-------------------------------------------------
- */
-
-struct bitstream* create_bitstream(const void *src, uint32_t srclength)
-{
-       struct bitstream* bitstream = (struct bitstream*)malloc(sizeof(struct bitstream));
-       bitstream->buffer = 0;
-       bitstream->bits = 0;
-       bitstream->read = (const uint8_t*)src;
-       bitstream->doffset = 0;
-       bitstream->dlength = srclength;
-       return bitstream;
-}
-
-
-/*-----------------------------------------------------
- *  bitstream_peek - fetch the requested number of bits
- *  but don't advance the input pointer
- *-----------------------------------------------------
- */
-
-uint32_t bitstream_peek(struct bitstream* bitstream, int numbits)
-{
-       if (numbits == 0)
-               return 0;
-
-       /* fetch data if we need more */
-       if (numbits > bitstream->bits)
-       {
-               while (bitstream->bits <= 24)
-               {
-                       if (bitstream->doffset < bitstream->dlength)
-                               bitstream->buffer |= bitstream->read[bitstream->doffset] << (24 - bitstream->bits);
-                       bitstream->doffset++;
-                       bitstream->bits += 8;
-               }
-       }
-
-       /* return the data */
-       return bitstream->buffer >> (32 - numbits);
-}
-
-
-/*-----------------------------------------------------
- *  bitstream_remove - advance the input pointer by the
- *  specified number of bits
- *-----------------------------------------------------
- */
-
-void bitstream_remove(struct bitstream* bitstream, int numbits)
-{
-       bitstream->buffer <<= numbits;
-       bitstream->bits -= numbits;
-}
-
-
-/*-----------------------------------------------------
- *  bitstream_read - fetch the requested number of bits
- *-----------------------------------------------------
- */
-
-uint32_t bitstream_read(struct bitstream* bitstream, int numbits)
-{
-       uint32_t result = bitstream_peek(bitstream, numbits);
-       bitstream_remove(bitstream, numbits);
-       return result;
-}
-
-
-/*-------------------------------------------------
- *  read_offset - return the current read offset
- *-------------------------------------------------
- */
-
-uint32_t bitstream_read_offset(struct bitstream* bitstream)
-{
-       uint32_t result = bitstream->doffset;
-       int bits = bitstream->bits;
-       while (bits >= 8)
-       {
-               result--;
-               bits -= 8;
-       }
-       return result;
-}
-
-
-/*-------------------------------------------------
- *  flush - flush to the nearest byte
- *-------------------------------------------------
- */
-
-uint32_t bitstream_flush(struct bitstream* bitstream)
-{
-       while (bitstream->bits >= 8)
-       {
-               bitstream->doffset--;
-               bitstream->bits -= 8;
-       }
-       bitstream->bits = bitstream->buffer = 0;
-       return bitstream->doffset;
-}
-
diff --git a/deps/libchdr/src/libchdr_cdrom.c b/deps/libchdr/src/libchdr_cdrom.c
deleted file mode 100644 (file)
index 58be015..0000000
+++ /dev/null
@@ -1,415 +0,0 @@
-/* license:BSD-3-Clause
- * copyright-holders:Aaron Giles
-***************************************************************************
-
-    cdrom.c
-
-    Generic MAME CD-ROM utilties - build IDE and SCSI CD-ROMs on top of this
-
-****************************************************************************
-
-    IMPORTANT:
-    "physical" block addresses are the actual addresses on the emulated CD.
-    "chd" block addresses are the block addresses in the CHD file.
-    Because we pad each track to a 4-frame boundary, these addressing
-    schemes will differ after track 1!
-
-***************************************************************************/
-#include <assert.h>
-#include <string.h>
-
-#include <libchdr/cdrom.h>
-
-#ifdef WANT_RAW_DATA_SECTOR
-
-/***************************************************************************
-    DEBUGGING
-***************************************************************************/
-
-/** @brief  The verbose. */
-#define VERBOSE (0)
-#if VERBOSE
-
-/**
- * @def LOG(x) do
- *
- * @brief   A macro that defines log.
- *
- * @param   x   The void to process.
- */
-
-#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
-
-/**
- * @fn  void CLIB_DECL logerror(const char *text, ...) ATTR_PRINTF(1,2);
- *
- * @brief   Logerrors the given text.
- *
- * @param   text    The text.
- *
- * @return  A CLIB_DECL.
- */
-
-void CLIB_DECL logerror(const char *text, ...) ATTR_PRINTF(1,2);
-#else
-
-/**
- * @def LOG(x);
- *
- * @brief   A macro that defines log.
- *
- * @param   x   The void to process.
- */
-
-#define LOG(x)
-#endif
-
-/***************************************************************************
-    CONSTANTS
-***************************************************************************/
-
-/** @brief  offset within sector. */
-#define SYNC_OFFSET 0x000
-/** @brief  12 bytes. */
-#define SYNC_NUM_BYTES 12
-
-/** @brief  offset within sector. */
-#define MODE_OFFSET 0x00f
-
-/** @brief  offset within sector. */
-#define ECC_P_OFFSET 0x81c
-/** @brief  2 lots of 86. */
-#define ECC_P_NUM_BYTES 86
-/** @brief  24 bytes each. */
-#define ECC_P_COMP 24
-
-/** @brief  The ECC q offset. */
-#define ECC_Q_OFFSET (ECC_P_OFFSET + 2 * ECC_P_NUM_BYTES)
-/** @brief  2 lots of 52. */
-#define ECC_Q_NUM_BYTES 52
-/** @brief  43 bytes each. */
-#define ECC_Q_COMP 43
-
-/**
- * @brief   -------------------------------------------------
- *            ECC lookup tables pre-calculated tables for ECC data calcs
- *          -------------------------------------------------.
- */
-
-static const uint8_t ecclow[256] =
-{
-       0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e,
-       0x20, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2c, 0x2e, 0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e,
-       0x40, 0x42, 0x44, 0x46, 0x48, 0x4a, 0x4c, 0x4e, 0x50, 0x52, 0x54, 0x56, 0x58, 0x5a, 0x5c, 0x5e,
-       0x60, 0x62, 0x64, 0x66, 0x68, 0x6a, 0x6c, 0x6e, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7a, 0x7c, 0x7e,
-       0x80, 0x82, 0x84, 0x86, 0x88, 0x8a, 0x8c, 0x8e, 0x90, 0x92, 0x94, 0x96, 0x98, 0x9a, 0x9c, 0x9e,
-       0xa0, 0xa2, 0xa4, 0xa6, 0xa8, 0xaa, 0xac, 0xae, 0xb0, 0xb2, 0xb4, 0xb6, 0xb8, 0xba, 0xbc, 0xbe,
-       0xc0, 0xc2, 0xc4, 0xc6, 0xc8, 0xca, 0xcc, 0xce, 0xd0, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc, 0xde,
-       0xe0, 0xe2, 0xe4, 0xe6, 0xe8, 0xea, 0xec, 0xee, 0xf0, 0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfc, 0xfe,
-       0x1d, 0x1f, 0x19, 0x1b, 0x15, 0x17, 0x11, 0x13, 0x0d, 0x0f, 0x09, 0x0b, 0x05, 0x07, 0x01, 0x03,
-       0x3d, 0x3f, 0x39, 0x3b, 0x35, 0x37, 0x31, 0x33, 0x2d, 0x2f, 0x29, 0x2b, 0x25, 0x27, 0x21, 0x23,
-       0x5d, 0x5f, 0x59, 0x5b, 0x55, 0x57, 0x51, 0x53, 0x4d, 0x4f, 0x49, 0x4b, 0x45, 0x47, 0x41, 0x43,
-       0x7d, 0x7f, 0x79, 0x7b, 0x75, 0x77, 0x71, 0x73, 0x6d, 0x6f, 0x69, 0x6b, 0x65, 0x67, 0x61, 0x63,
-       0x9d, 0x9f, 0x99, 0x9b, 0x95, 0x97, 0x91, 0x93, 0x8d, 0x8f, 0x89, 0x8b, 0x85, 0x87, 0x81, 0x83,
-       0xbd, 0xbf, 0xb9, 0xbb, 0xb5, 0xb7, 0xb1, 0xb3, 0xad, 0xaf, 0xa9, 0xab, 0xa5, 0xa7, 0xa1, 0xa3,
-       0xdd, 0xdf, 0xd9, 0xdb, 0xd5, 0xd7, 0xd1, 0xd3, 0xcd, 0xcf, 0xc9, 0xcb, 0xc5, 0xc7, 0xc1, 0xc3,
-       0xfd, 0xff, 0xf9, 0xfb, 0xf5, 0xf7, 0xf1, 0xf3, 0xed, 0xef, 0xe9, 0xeb, 0xe5, 0xe7, 0xe1, 0xe3
-};
-
-/** @brief  The ecchigh[ 256]. */
-static const uint8_t ecchigh[256] =
-{
-       0x00, 0xf4, 0xf5, 0x01, 0xf7, 0x03, 0x02, 0xf6, 0xf3, 0x07, 0x06, 0xf2, 0x04, 0xf0, 0xf1, 0x05,
-       0xfb, 0x0f, 0x0e, 0xfa, 0x0c, 0xf8, 0xf9, 0x0d, 0x08, 0xfc, 0xfd, 0x09, 0xff, 0x0b, 0x0a, 0xfe,
-       0xeb, 0x1f, 0x1e, 0xea, 0x1c, 0xe8, 0xe9, 0x1d, 0x18, 0xec, 0xed, 0x19, 0xef, 0x1b, 0x1a, 0xee,
-       0x10, 0xe4, 0xe5, 0x11, 0xe7, 0x13, 0x12, 0xe6, 0xe3, 0x17, 0x16, 0xe2, 0x14, 0xe0, 0xe1, 0x15,
-       0xcb, 0x3f, 0x3e, 0xca, 0x3c, 0xc8, 0xc9, 0x3d, 0x38, 0xcc, 0xcd, 0x39, 0xcf, 0x3b, 0x3a, 0xce,
-       0x30, 0xc4, 0xc5, 0x31, 0xc7, 0x33, 0x32, 0xc6, 0xc3, 0x37, 0x36, 0xc2, 0x34, 0xc0, 0xc1, 0x35,
-       0x20, 0xd4, 0xd5, 0x21, 0xd7, 0x23, 0x22, 0xd6, 0xd3, 0x27, 0x26, 0xd2, 0x24, 0xd0, 0xd1, 0x25,
-       0xdb, 0x2f, 0x2e, 0xda, 0x2c, 0xd8, 0xd9, 0x2d, 0x28, 0xdc, 0xdd, 0x29, 0xdf, 0x2b, 0x2a, 0xde,
-       0x8b, 0x7f, 0x7e, 0x8a, 0x7c, 0x88, 0x89, 0x7d, 0x78, 0x8c, 0x8d, 0x79, 0x8f, 0x7b, 0x7a, 0x8e,
-       0x70, 0x84, 0x85, 0x71, 0x87, 0x73, 0x72, 0x86, 0x83, 0x77, 0x76, 0x82, 0x74, 0x80, 0x81, 0x75,
-       0x60, 0x94, 0x95, 0x61, 0x97, 0x63, 0x62, 0x96, 0x93, 0x67, 0x66, 0x92, 0x64, 0x90, 0x91, 0x65,
-       0x9b, 0x6f, 0x6e, 0x9a, 0x6c, 0x98, 0x99, 0x6d, 0x68, 0x9c, 0x9d, 0x69, 0x9f, 0x6b, 0x6a, 0x9e,
-       0x40, 0xb4, 0xb5, 0x41, 0xb7, 0x43, 0x42, 0xb6, 0xb3, 0x47, 0x46, 0xb2, 0x44, 0xb0, 0xb1, 0x45,
-       0xbb, 0x4f, 0x4e, 0xba, 0x4c, 0xb8, 0xb9, 0x4d, 0x48, 0xbc, 0xbd, 0x49, 0xbf, 0x4b, 0x4a, 0xbe,
-       0xab, 0x5f, 0x5e, 0xaa, 0x5c, 0xa8, 0xa9, 0x5d, 0x58, 0xac, 0xad, 0x59, 0xaf, 0x5b, 0x5a, 0xae,
-       0x50, 0xa4, 0xa5, 0x51, 0xa7, 0x53, 0x52, 0xa6, 0xa3, 0x57, 0x56, 0xa2, 0x54, 0xa0, 0xa1, 0x55
-};
-
-/**
- * @brief   -------------------------------------------------
- *            poffsets - each row represents the addresses used to calculate a byte of the ECC P
- *            data 86 (*2) ECC P bytes, 24 values represented by each
- *          -------------------------------------------------.
- */
-
-static const uint16_t poffsets[ECC_P_NUM_BYTES][ECC_P_COMP] =
-{
-       { 0x000,0x056,0x0ac,0x102,0x158,0x1ae,0x204,0x25a,0x2b0,0x306,0x35c,0x3b2,0x408,0x45e,0x4b4,0x50a,0x560,0x5b6,0x60c,0x662,0x6b8,0x70e,0x764,0x7ba },
-       { 0x001,0x057,0x0ad,0x103,0x159,0x1af,0x205,0x25b,0x2b1,0x307,0x35d,0x3b3,0x409,0x45f,0x4b5,0x50b,0x561,0x5b7,0x60d,0x663,0x6b9,0x70f,0x765,0x7bb },
-       { 0x002,0x058,0x0ae,0x104,0x15a,0x1b0,0x206,0x25c,0x2b2,0x308,0x35e,0x3b4,0x40a,0x460,0x4b6,0x50c,0x562,0x5b8,0x60e,0x664,0x6ba,0x710,0x766,0x7bc },
-       { 0x003,0x059,0x0af,0x105,0x15b,0x1b1,0x207,0x25d,0x2b3,0x309,0x35f,0x3b5,0x40b,0x461,0x4b7,0x50d,0x563,0x5b9,0x60f,0x665,0x6bb,0x711,0x767,0x7bd },
-       { 0x004,0x05a,0x0b0,0x106,0x15c,0x1b2,0x208,0x25e,0x2b4,0x30a,0x360,0x3b6,0x40c,0x462,0x4b8,0x50e,0x564,0x5ba,0x610,0x666,0x6bc,0x712,0x768,0x7be },
-       { 0x005,0x05b,0x0b1,0x107,0x15d,0x1b3,0x209,0x25f,0x2b5,0x30b,0x361,0x3b7,0x40d,0x463,0x4b9,0x50f,0x565,0x5bb,0x611,0x667,0x6bd,0x713,0x769,0x7bf },
-       { 0x006,0x05c,0x0b2,0x108,0x15e,0x1b4,0x20a,0x260,0x2b6,0x30c,0x362,0x3b8,0x40e,0x464,0x4ba,0x510,0x566,0x5bc,0x612,0x668,0x6be,0x714,0x76a,0x7c0 },
-       { 0x007,0x05d,0x0b3,0x109,0x15f,0x1b5,0x20b,0x261,0x2b7,0x30d,0x363,0x3b9,0x40f,0x465,0x4bb,0x511,0x567,0x5bd,0x613,0x669,0x6bf,0x715,0x76b,0x7c1 },
-       { 0x008,0x05e,0x0b4,0x10a,0x160,0x1b6,0x20c,0x262,0x2b8,0x30e,0x364,0x3ba,0x410,0x466,0x4bc,0x512,0x568,0x5be,0x614,0x66a,0x6c0,0x716,0x76c,0x7c2 },
-       { 0x009,0x05f,0x0b5,0x10b,0x161,0x1b7,0x20d,0x263,0x2b9,0x30f,0x365,0x3bb,0x411,0x467,0x4bd,0x513,0x569,0x5bf,0x615,0x66b,0x6c1,0x717,0x76d,0x7c3 },
-       { 0x00a,0x060,0x0b6,0x10c,0x162,0x1b8,0x20e,0x264,0x2ba,0x310,0x366,0x3bc,0x412,0x468,0x4be,0x514,0x56a,0x5c0,0x616,0x66c,0x6c2,0x718,0x76e,0x7c4 },
-       { 0x00b,0x061,0x0b7,0x10d,0x163,0x1b9,0x20f,0x265,0x2bb,0x311,0x367,0x3bd,0x413,0x469,0x4bf,0x515,0x56b,0x5c1,0x617,0x66d,0x6c3,0x719,0x76f,0x7c5 },
-       { 0x00c,0x062,0x0b8,0x10e,0x164,0x1ba,0x210,0x266,0x2bc,0x312,0x368,0x3be,0x414,0x46a,0x4c0,0x516,0x56c,0x5c2,0x618,0x66e,0x6c4,0x71a,0x770,0x7c6 },
-       { 0x00d,0x063,0x0b9,0x10f,0x165,0x1bb,0x211,0x267,0x2bd,0x313,0x369,0x3bf,0x415,0x46b,0x4c1,0x517,0x56d,0x5c3,0x619,0x66f,0x6c5,0x71b,0x771,0x7c7 },
-       { 0x00e,0x064,0x0ba,0x110,0x166,0x1bc,0x212,0x268,0x2be,0x314,0x36a,0x3c0,0x416,0x46c,0x4c2,0x518,0x56e,0x5c4,0x61a,0x670,0x6c6,0x71c,0x772,0x7c8 },
-       { 0x00f,0x065,0x0bb,0x111,0x167,0x1bd,0x213,0x269,0x2bf,0x315,0x36b,0x3c1,0x417,0x46d,0x4c3,0x519,0x56f,0x5c5,0x61b,0x671,0x6c7,0x71d,0x773,0x7c9 },
-       { 0x010,0x066,0x0bc,0x112,0x168,0x1be,0x214,0x26a,0x2c0,0x316,0x36c,0x3c2,0x418,0x46e,0x4c4,0x51a,0x570,0x5c6,0x61c,0x672,0x6c8,0x71e,0x774,0x7ca },
-       { 0x011,0x067,0x0bd,0x113,0x169,0x1bf,0x215,0x26b,0x2c1,0x317,0x36d,0x3c3,0x419,0x46f,0x4c5,0x51b,0x571,0x5c7,0x61d,0x673,0x6c9,0x71f,0x775,0x7cb },
-       { 0x012,0x068,0x0be,0x114,0x16a,0x1c0,0x216,0x26c,0x2c2,0x318,0x36e,0x3c4,0x41a,0x470,0x4c6,0x51c,0x572,0x5c8,0x61e,0x674,0x6ca,0x720,0x776,0x7cc },
-       { 0x013,0x069,0x0bf,0x115,0x16b,0x1c1,0x217,0x26d,0x2c3,0x319,0x36f,0x3c5,0x41b,0x471,0x4c7,0x51d,0x573,0x5c9,0x61f,0x675,0x6cb,0x721,0x777,0x7cd },
-       { 0x014,0x06a,0x0c0,0x116,0x16c,0x1c2,0x218,0x26e,0x2c4,0x31a,0x370,0x3c6,0x41c,0x472,0x4c8,0x51e,0x574,0x5ca,0x620,0x676,0x6cc,0x722,0x778,0x7ce },
-       { 0x015,0x06b,0x0c1,0x117,0x16d,0x1c3,0x219,0x26f,0x2c5,0x31b,0x371,0x3c7,0x41d,0x473,0x4c9,0x51f,0x575,0x5cb,0x621,0x677,0x6cd,0x723,0x779,0x7cf },
-       { 0x016,0x06c,0x0c2,0x118,0x16e,0x1c4,0x21a,0x270,0x2c6,0x31c,0x372,0x3c8,0x41e,0x474,0x4ca,0x520,0x576,0x5cc,0x622,0x678,0x6ce,0x724,0x77a,0x7d0 },
-       { 0x017,0x06d,0x0c3,0x119,0x16f,0x1c5,0x21b,0x271,0x2c7,0x31d,0x373,0x3c9,0x41f,0x475,0x4cb,0x521,0x577,0x5cd,0x623,0x679,0x6cf,0x725,0x77b,0x7d1 },
-       { 0x018,0x06e,0x0c4,0x11a,0x170,0x1c6,0x21c,0x272,0x2c8,0x31e,0x374,0x3ca,0x420,0x476,0x4cc,0x522,0x578,0x5ce,0x624,0x67a,0x6d0,0x726,0x77c,0x7d2 },
-       { 0x019,0x06f,0x0c5,0x11b,0x171,0x1c7,0x21d,0x273,0x2c9,0x31f,0x375,0x3cb,0x421,0x477,0x4cd,0x523,0x579,0x5cf,0x625,0x67b,0x6d1,0x727,0x77d,0x7d3 },
-       { 0x01a,0x070,0x0c6,0x11c,0x172,0x1c8,0x21e,0x274,0x2ca,0x320,0x376,0x3cc,0x422,0x478,0x4ce,0x524,0x57a,0x5d0,0x626,0x67c,0x6d2,0x728,0x77e,0x7d4 },
-       { 0x01b,0x071,0x0c7,0x11d,0x173,0x1c9,0x21f,0x275,0x2cb,0x321,0x377,0x3cd,0x423,0x479,0x4cf,0x525,0x57b,0x5d1,0x627,0x67d,0x6d3,0x729,0x77f,0x7d5 },
-       { 0x01c,0x072,0x0c8,0x11e,0x174,0x1ca,0x220,0x276,0x2cc,0x322,0x378,0x3ce,0x424,0x47a,0x4d0,0x526,0x57c,0x5d2,0x628,0x67e,0x6d4,0x72a,0x780,0x7d6 },
-       { 0x01d,0x073,0x0c9,0x11f,0x175,0x1cb,0x221,0x277,0x2cd,0x323,0x379,0x3cf,0x425,0x47b,0x4d1,0x527,0x57d,0x5d3,0x629,0x67f,0x6d5,0x72b,0x781,0x7d7 },
-       { 0x01e,0x074,0x0ca,0x120,0x176,0x1cc,0x222,0x278,0x2ce,0x324,0x37a,0x3d0,0x426,0x47c,0x4d2,0x528,0x57e,0x5d4,0x62a,0x680,0x6d6,0x72c,0x782,0x7d8 },
-       { 0x01f,0x075,0x0cb,0x121,0x177,0x1cd,0x223,0x279,0x2cf,0x325,0x37b,0x3d1,0x427,0x47d,0x4d3,0x529,0x57f,0x5d5,0x62b,0x681,0x6d7,0x72d,0x783,0x7d9 },
-       { 0x020,0x076,0x0cc,0x122,0x178,0x1ce,0x224,0x27a,0x2d0,0x326,0x37c,0x3d2,0x428,0x47e,0x4d4,0x52a,0x580,0x5d6,0x62c,0x682,0x6d8,0x72e,0x784,0x7da },
-       { 0x021,0x077,0x0cd,0x123,0x179,0x1cf,0x225,0x27b,0x2d1,0x327,0x37d,0x3d3,0x429,0x47f,0x4d5,0x52b,0x581,0x5d7,0x62d,0x683,0x6d9,0x72f,0x785,0x7db },
-       { 0x022,0x078,0x0ce,0x124,0x17a,0x1d0,0x226,0x27c,0x2d2,0x328,0x37e,0x3d4,0x42a,0x480,0x4d6,0x52c,0x582,0x5d8,0x62e,0x684,0x6da,0x730,0x786,0x7dc },
-       { 0x023,0x079,0x0cf,0x125,0x17b,0x1d1,0x227,0x27d,0x2d3,0x329,0x37f,0x3d5,0x42b,0x481,0x4d7,0x52d,0x583,0x5d9,0x62f,0x685,0x6db,0x731,0x787,0x7dd },
-       { 0x024,0x07a,0x0d0,0x126,0x17c,0x1d2,0x228,0x27e,0x2d4,0x32a,0x380,0x3d6,0x42c,0x482,0x4d8,0x52e,0x584,0x5da,0x630,0x686,0x6dc,0x732,0x788,0x7de },
-       { 0x025,0x07b,0x0d1,0x127,0x17d,0x1d3,0x229,0x27f,0x2d5,0x32b,0x381,0x3d7,0x42d,0x483,0x4d9,0x52f,0x585,0x5db,0x631,0x687,0x6dd,0x733,0x789,0x7df },
-       { 0x026,0x07c,0x0d2,0x128,0x17e,0x1d4,0x22a,0x280,0x2d6,0x32c,0x382,0x3d8,0x42e,0x484,0x4da,0x530,0x586,0x5dc,0x632,0x688,0x6de,0x734,0x78a,0x7e0 },
-       { 0x027,0x07d,0x0d3,0x129,0x17f,0x1d5,0x22b,0x281,0x2d7,0x32d,0x383,0x3d9,0x42f,0x485,0x4db,0x531,0x587,0x5dd,0x633,0x689,0x6df,0x735,0x78b,0x7e1 },
-       { 0x028,0x07e,0x0d4,0x12a,0x180,0x1d6,0x22c,0x282,0x2d8,0x32e,0x384,0x3da,0x430,0x486,0x4dc,0x532,0x588,0x5de,0x634,0x68a,0x6e0,0x736,0x78c,0x7e2 },
-       { 0x029,0x07f,0x0d5,0x12b,0x181,0x1d7,0x22d,0x283,0x2d9,0x32f,0x385,0x3db,0x431,0x487,0x4dd,0x533,0x589,0x5df,0x635,0x68b,0x6e1,0x737,0x78d,0x7e3 },
-       { 0x02a,0x080,0x0d6,0x12c,0x182,0x1d8,0x22e,0x284,0x2da,0x330,0x386,0x3dc,0x432,0x488,0x4de,0x534,0x58a,0x5e0,0x636,0x68c,0x6e2,0x738,0x78e,0x7e4 },
-       { 0x02b,0x081,0x0d7,0x12d,0x183,0x1d9,0x22f,0x285,0x2db,0x331,0x387,0x3dd,0x433,0x489,0x4df,0x535,0x58b,0x5e1,0x637,0x68d,0x6e3,0x739,0x78f,0x7e5 },
-       { 0x02c,0x082,0x0d8,0x12e,0x184,0x1da,0x230,0x286,0x2dc,0x332,0x388,0x3de,0x434,0x48a,0x4e0,0x536,0x58c,0x5e2,0x638,0x68e,0x6e4,0x73a,0x790,0x7e6 },
-       { 0x02d,0x083,0x0d9,0x12f,0x185,0x1db,0x231,0x287,0x2dd,0x333,0x389,0x3df,0x435,0x48b,0x4e1,0x537,0x58d,0x5e3,0x639,0x68f,0x6e5,0x73b,0x791,0x7e7 },
-       { 0x02e,0x084,0x0da,0x130,0x186,0x1dc,0x232,0x288,0x2de,0x334,0x38a,0x3e0,0x436,0x48c,0x4e2,0x538,0x58e,0x5e4,0x63a,0x690,0x6e6,0x73c,0x792,0x7e8 },
-       { 0x02f,0x085,0x0db,0x131,0x187,0x1dd,0x233,0x289,0x2df,0x335,0x38b,0x3e1,0x437,0x48d,0x4e3,0x539,0x58f,0x5e5,0x63b,0x691,0x6e7,0x73d,0x793,0x7e9 },
-       { 0x030,0x086,0x0dc,0x132,0x188,0x1de,0x234,0x28a,0x2e0,0x336,0x38c,0x3e2,0x438,0x48e,0x4e4,0x53a,0x590,0x5e6,0x63c,0x692,0x6e8,0x73e,0x794,0x7ea },
-       { 0x031,0x087,0x0dd,0x133,0x189,0x1df,0x235,0x28b,0x2e1,0x337,0x38d,0x3e3,0x439,0x48f,0x4e5,0x53b,0x591,0x5e7,0x63d,0x693,0x6e9,0x73f,0x795,0x7eb },
-       { 0x032,0x088,0x0de,0x134,0x18a,0x1e0,0x236,0x28c,0x2e2,0x338,0x38e,0x3e4,0x43a,0x490,0x4e6,0x53c,0x592,0x5e8,0x63e,0x694,0x6ea,0x740,0x796,0x7ec },
-       { 0x033,0x089,0x0df,0x135,0x18b,0x1e1,0x237,0x28d,0x2e3,0x339,0x38f,0x3e5,0x43b,0x491,0x4e7,0x53d,0x593,0x5e9,0x63f,0x695,0x6eb,0x741,0x797,0x7ed },
-       { 0x034,0x08a,0x0e0,0x136,0x18c,0x1e2,0x238,0x28e,0x2e4,0x33a,0x390,0x3e6,0x43c,0x492,0x4e8,0x53e,0x594,0x5ea,0x640,0x696,0x6ec,0x742,0x798,0x7ee },
-       { 0x035,0x08b,0x0e1,0x137,0x18d,0x1e3,0x239,0x28f,0x2e5,0x33b,0x391,0x3e7,0x43d,0x493,0x4e9,0x53f,0x595,0x5eb,0x641,0x697,0x6ed,0x743,0x799,0x7ef },
-       { 0x036,0x08c,0x0e2,0x138,0x18e,0x1e4,0x23a,0x290,0x2e6,0x33c,0x392,0x3e8,0x43e,0x494,0x4ea,0x540,0x596,0x5ec,0x642,0x698,0x6ee,0x744,0x79a,0x7f0 },
-       { 0x037,0x08d,0x0e3,0x139,0x18f,0x1e5,0x23b,0x291,0x2e7,0x33d,0x393,0x3e9,0x43f,0x495,0x4eb,0x541,0x597,0x5ed,0x643,0x699,0x6ef,0x745,0x79b,0x7f1 },
-       { 0x038,0x08e,0x0e4,0x13a,0x190,0x1e6,0x23c,0x292,0x2e8,0x33e,0x394,0x3ea,0x440,0x496,0x4ec,0x542,0x598,0x5ee,0x644,0x69a,0x6f0,0x746,0x79c,0x7f2 },
-       { 0x039,0x08f,0x0e5,0x13b,0x191,0x1e7,0x23d,0x293,0x2e9,0x33f,0x395,0x3eb,0x441,0x497,0x4ed,0x543,0x599,0x5ef,0x645,0x69b,0x6f1,0x747,0x79d,0x7f3 },
-       { 0x03a,0x090,0x0e6,0x13c,0x192,0x1e8,0x23e,0x294,0x2ea,0x340,0x396,0x3ec,0x442,0x498,0x4ee,0x544,0x59a,0x5f0,0x646,0x69c,0x6f2,0x748,0x79e,0x7f4 },
-       { 0x03b,0x091,0x0e7,0x13d,0x193,0x1e9,0x23f,0x295,0x2eb,0x341,0x397,0x3ed,0x443,0x499,0x4ef,0x545,0x59b,0x5f1,0x647,0x69d,0x6f3,0x749,0x79f,0x7f5 },
-       { 0x03c,0x092,0x0e8,0x13e,0x194,0x1ea,0x240,0x296,0x2ec,0x342,0x398,0x3ee,0x444,0x49a,0x4f0,0x546,0x59c,0x5f2,0x648,0x69e,0x6f4,0x74a,0x7a0,0x7f6 },
-       { 0x03d,0x093,0x0e9,0x13f,0x195,0x1eb,0x241,0x297,0x2ed,0x343,0x399,0x3ef,0x445,0x49b,0x4f1,0x547,0x59d,0x5f3,0x649,0x69f,0x6f5,0x74b,0x7a1,0x7f7 },
-       { 0x03e,0x094,0x0ea,0x140,0x196,0x1ec,0x242,0x298,0x2ee,0x344,0x39a,0x3f0,0x446,0x49c,0x4f2,0x548,0x59e,0x5f4,0x64a,0x6a0,0x6f6,0x74c,0x7a2,0x7f8 },
-       { 0x03f,0x095,0x0eb,0x141,0x197,0x1ed,0x243,0x299,0x2ef,0x345,0x39b,0x3f1,0x447,0x49d,0x4f3,0x549,0x59f,0x5f5,0x64b,0x6a1,0x6f7,0x74d,0x7a3,0x7f9 },
-       { 0x040,0x096,0x0ec,0x142,0x198,0x1ee,0x244,0x29a,0x2f0,0x346,0x39c,0x3f2,0x448,0x49e,0x4f4,0x54a,0x5a0,0x5f6,0x64c,0x6a2,0x6f8,0x74e,0x7a4,0x7fa },
-       { 0x041,0x097,0x0ed,0x143,0x199,0x1ef,0x245,0x29b,0x2f1,0x347,0x39d,0x3f3,0x449,0x49f,0x4f5,0x54b,0x5a1,0x5f7,0x64d,0x6a3,0x6f9,0x74f,0x7a5,0x7fb },
-       { 0x042,0x098,0x0ee,0x144,0x19a,0x1f0,0x246,0x29c,0x2f2,0x348,0x39e,0x3f4,0x44a,0x4a0,0x4f6,0x54c,0x5a2,0x5f8,0x64e,0x6a4,0x6fa,0x750,0x7a6,0x7fc },
-       { 0x043,0x099,0x0ef,0x145,0x19b,0x1f1,0x247,0x29d,0x2f3,0x349,0x39f,0x3f5,0x44b,0x4a1,0x4f7,0x54d,0x5a3,0x5f9,0x64f,0x6a5,0x6fb,0x751,0x7a7,0x7fd },
-       { 0x044,0x09a,0x0f0,0x146,0x19c,0x1f2,0x248,0x29e,0x2f4,0x34a,0x3a0,0x3f6,0x44c,0x4a2,0x4f8,0x54e,0x5a4,0x5fa,0x650,0x6a6,0x6fc,0x752,0x7a8,0x7fe },
-       { 0x045,0x09b,0x0f1,0x147,0x19d,0x1f3,0x249,0x29f,0x2f5,0x34b,0x3a1,0x3f7,0x44d,0x4a3,0x4f9,0x54f,0x5a5,0x5fb,0x651,0x6a7,0x6fd,0x753,0x7a9,0x7ff },
-       { 0x046,0x09c,0x0f2,0x148,0x19e,0x1f4,0x24a,0x2a0,0x2f6,0x34c,0x3a2,0x3f8,0x44e,0x4a4,0x4fa,0x550,0x5a6,0x5fc,0x652,0x6a8,0x6fe,0x754,0x7aa,0x800 },
-       { 0x047,0x09d,0x0f3,0x149,0x19f,0x1f5,0x24b,0x2a1,0x2f7,0x34d,0x3a3,0x3f9,0x44f,0x4a5,0x4fb,0x551,0x5a7,0x5fd,0x653,0x6a9,0x6ff,0x755,0x7ab,0x801 },
-       { 0x048,0x09e,0x0f4,0x14a,0x1a0,0x1f6,0x24c,0x2a2,0x2f8,0x34e,0x3a4,0x3fa,0x450,0x4a6,0x4fc,0x552,0x5a8,0x5fe,0x654,0x6aa,0x700,0x756,0x7ac,0x802 },
-       { 0x049,0x09f,0x0f5,0x14b,0x1a1,0x1f7,0x24d,0x2a3,0x2f9,0x34f,0x3a5,0x3fb,0x451,0x4a7,0x4fd,0x553,0x5a9,0x5ff,0x655,0x6ab,0x701,0x757,0x7ad,0x803 },
-       { 0x04a,0x0a0,0x0f6,0x14c,0x1a2,0x1f8,0x24e,0x2a4,0x2fa,0x350,0x3a6,0x3fc,0x452,0x4a8,0x4fe,0x554,0x5aa,0x600,0x656,0x6ac,0x702,0x758,0x7ae,0x804 },
-       { 0x04b,0x0a1,0x0f7,0x14d,0x1a3,0x1f9,0x24f,0x2a5,0x2fb,0x351,0x3a7,0x3fd,0x453,0x4a9,0x4ff,0x555,0x5ab,0x601,0x657,0x6ad,0x703,0x759,0x7af,0x805 },
-       { 0x04c,0x0a2,0x0f8,0x14e,0x1a4,0x1fa,0x250,0x2a6,0x2fc,0x352,0x3a8,0x3fe,0x454,0x4aa,0x500,0x556,0x5ac,0x602,0x658,0x6ae,0x704,0x75a,0x7b0,0x806 },
-       { 0x04d,0x0a3,0x0f9,0x14f,0x1a5,0x1fb,0x251,0x2a7,0x2fd,0x353,0x3a9,0x3ff,0x455,0x4ab,0x501,0x557,0x5ad,0x603,0x659,0x6af,0x705,0x75b,0x7b1,0x807 },
-       { 0x04e,0x0a4,0x0fa,0x150,0x1a6,0x1fc,0x252,0x2a8,0x2fe,0x354,0x3aa,0x400,0x456,0x4ac,0x502,0x558,0x5ae,0x604,0x65a,0x6b0,0x706,0x75c,0x7b2,0x808 },
-       { 0x04f,0x0a5,0x0fb,0x151,0x1a7,0x1fd,0x253,0x2a9,0x2ff,0x355,0x3ab,0x401,0x457,0x4ad,0x503,0x559,0x5af,0x605,0x65b,0x6b1,0x707,0x75d,0x7b3,0x809 },
-       { 0x050,0x0a6,0x0fc,0x152,0x1a8,0x1fe,0x254,0x2aa,0x300,0x356,0x3ac,0x402,0x458,0x4ae,0x504,0x55a,0x5b0,0x606,0x65c,0x6b2,0x708,0x75e,0x7b4,0x80a },
-       { 0x051,0x0a7,0x0fd,0x153,0x1a9,0x1ff,0x255,0x2ab,0x301,0x357,0x3ad,0x403,0x459,0x4af,0x505,0x55b,0x5b1,0x607,0x65d,0x6b3,0x709,0x75f,0x7b5,0x80b },
-       { 0x052,0x0a8,0x0fe,0x154,0x1aa,0x200,0x256,0x2ac,0x302,0x358,0x3ae,0x404,0x45a,0x4b0,0x506,0x55c,0x5b2,0x608,0x65e,0x6b4,0x70a,0x760,0x7b6,0x80c },
-       { 0x053,0x0a9,0x0ff,0x155,0x1ab,0x201,0x257,0x2ad,0x303,0x359,0x3af,0x405,0x45b,0x4b1,0x507,0x55d,0x5b3,0x609,0x65f,0x6b5,0x70b,0x761,0x7b7,0x80d },
-       { 0x054,0x0aa,0x100,0x156,0x1ac,0x202,0x258,0x2ae,0x304,0x35a,0x3b0,0x406,0x45c,0x4b2,0x508,0x55e,0x5b4,0x60a,0x660,0x6b6,0x70c,0x762,0x7b8,0x80e },
-       { 0x055,0x0ab,0x101,0x157,0x1ad,0x203,0x259,0x2af,0x305,0x35b,0x3b1,0x407,0x45d,0x4b3,0x509,0x55f,0x5b5,0x60b,0x661,0x6b7,0x70d,0x763,0x7b9,0x80f }
-};
-
-/**
- * @brief   -------------------------------------------------
- *            qoffsets - each row represents the addresses used to calculate a byte of the ECC Q
- *            data 52 (*2) ECC Q bytes, 43 values represented by each
- *          -------------------------------------------------.
- */
-
-static const uint16_t qoffsets[ECC_Q_NUM_BYTES][ECC_Q_COMP] =
-{
-       { 0x000,0x058,0x0b0,0x108,0x160,0x1b8,0x210,0x268,0x2c0,0x318,0x370,0x3c8,0x420,0x478,0x4d0,0x528,0x580,0x5d8,0x630,0x688,0x6e0,0x738,0x790,0x7e8,0x840,0x898,0x034,0x08c,0x0e4,0x13c,0x194,0x1ec,0x244,0x29c,0x2f4,0x34c,0x3a4,0x3fc,0x454,0x4ac,0x504,0x55c,0x5b4 },
-       { 0x001,0x059,0x0b1,0x109,0x161,0x1b9,0x211,0x269,0x2c1,0x319,0x371,0x3c9,0x421,0x479,0x4d1,0x529,0x581,0x5d9,0x631,0x689,0x6e1,0x739,0x791,0x7e9,0x841,0x899,0x035,0x08d,0x0e5,0x13d,0x195,0x1ed,0x245,0x29d,0x2f5,0x34d,0x3a5,0x3fd,0x455,0x4ad,0x505,0x55d,0x5b5 },
-       { 0x056,0x0ae,0x106,0x15e,0x1b6,0x20e,0x266,0x2be,0x316,0x36e,0x3c6,0x41e,0x476,0x4ce,0x526,0x57e,0x5d6,0x62e,0x686,0x6de,0x736,0x78e,0x7e6,0x83e,0x896,0x032,0x08a,0x0e2,0x13a,0x192,0x1ea,0x242,0x29a,0x2f2,0x34a,0x3a2,0x3fa,0x452,0x4aa,0x502,0x55a,0x5b2,0x60a },
-       { 0x057,0x0af,0x107,0x15f,0x1b7,0x20f,0x267,0x2bf,0x317,0x36f,0x3c7,0x41f,0x477,0x4cf,0x527,0x57f,0x5d7,0x62f,0x687,0x6df,0x737,0x78f,0x7e7,0x83f,0x897,0x033,0x08b,0x0e3,0x13b,0x193,0x1eb,0x243,0x29b,0x2f3,0x34b,0x3a3,0x3fb,0x453,0x4ab,0x503,0x55b,0x5b3,0x60b },
-       { 0x0ac,0x104,0x15c,0x1b4,0x20c,0x264,0x2bc,0x314,0x36c,0x3c4,0x41c,0x474,0x4cc,0x524,0x57c,0x5d4,0x62c,0x684,0x6dc,0x734,0x78c,0x7e4,0x83c,0x894,0x030,0x088,0x0e0,0x138,0x190,0x1e8,0x240,0x298,0x2f0,0x348,0x3a0,0x3f8,0x450,0x4a8,0x500,0x558,0x5b0,0x608,0x660 },
-       { 0x0ad,0x105,0x15d,0x1b5,0x20d,0x265,0x2bd,0x315,0x36d,0x3c5,0x41d,0x475,0x4cd,0x525,0x57d,0x5d5,0x62d,0x685,0x6dd,0x735,0x78d,0x7e5,0x83d,0x895,0x031,0x089,0x0e1,0x139,0x191,0x1e9,0x241,0x299,0x2f1,0x349,0x3a1,0x3f9,0x451,0x4a9,0x501,0x559,0x5b1,0x609,0x661 },
-       { 0x102,0x15a,0x1b2,0x20a,0x262,0x2ba,0x312,0x36a,0x3c2,0x41a,0x472,0x4ca,0x522,0x57a,0x5d2,0x62a,0x682,0x6da,0x732,0x78a,0x7e2,0x83a,0x892,0x02e,0x086,0x0de,0x136,0x18e,0x1e6,0x23e,0x296,0x2ee,0x346,0x39e,0x3f6,0x44e,0x4a6,0x4fe,0x556,0x5ae,0x606,0x65e,0x6b6 },
-       { 0x103,0x15b,0x1b3,0x20b,0x263,0x2bb,0x313,0x36b,0x3c3,0x41b,0x473,0x4cb,0x523,0x57b,0x5d3,0x62b,0x683,0x6db,0x733,0x78b,0x7e3,0x83b,0x893,0x02f,0x087,0x0df,0x137,0x18f,0x1e7,0x23f,0x297,0x2ef,0x347,0x39f,0x3f7,0x44f,0x4a7,0x4ff,0x557,0x5af,0x607,0x65f,0x6b7 },
-       { 0x158,0x1b0,0x208,0x260,0x2b8,0x310,0x368,0x3c0,0x418,0x470,0x4c8,0x520,0x578,0x5d0,0x628,0x680,0x6d8,0x730,0x788,0x7e0,0x838,0x890,0x02c,0x084,0x0dc,0x134,0x18c,0x1e4,0x23c,0x294,0x2ec,0x344,0x39c,0x3f4,0x44c,0x4a4,0x4fc,0x554,0x5ac,0x604,0x65c,0x6b4,0x70c },
-       { 0x159,0x1b1,0x209,0x261,0x2b9,0x311,0x369,0x3c1,0x419,0x471,0x4c9,0x521,0x579,0x5d1,0x629,0x681,0x6d9,0x731,0x789,0x7e1,0x839,0x891,0x02d,0x085,0x0dd,0x135,0x18d,0x1e5,0x23d,0x295,0x2ed,0x345,0x39d,0x3f5,0x44d,0x4a5,0x4fd,0x555,0x5ad,0x605,0x65d,0x6b5,0x70d },
-       { 0x1ae,0x206,0x25e,0x2b6,0x30e,0x366,0x3be,0x416,0x46e,0x4c6,0x51e,0x576,0x5ce,0x626,0x67e,0x6d6,0x72e,0x786,0x7de,0x836,0x88e,0x02a,0x082,0x0da,0x132,0x18a,0x1e2,0x23a,0x292,0x2ea,0x342,0x39a,0x3f2,0x44a,0x4a2,0x4fa,0x552,0x5aa,0x602,0x65a,0x6b2,0x70a,0x762 },
-       { 0x1af,0x207,0x25f,0x2b7,0x30f,0x367,0x3bf,0x417,0x46f,0x4c7,0x51f,0x577,0x5cf,0x627,0x67f,0x6d7,0x72f,0x787,0x7df,0x837,0x88f,0x02b,0x083,0x0db,0x133,0x18b,0x1e3,0x23b,0x293,0x2eb,0x343,0x39b,0x3f3,0x44b,0x4a3,0x4fb,0x553,0x5ab,0x603,0x65b,0x6b3,0x70b,0x763 },
-       { 0x204,0x25c,0x2b4,0x30c,0x364,0x3bc,0x414,0x46c,0x4c4,0x51c,0x574,0x5cc,0x624,0x67c,0x6d4,0x72c,0x784,0x7dc,0x834,0x88c,0x028,0x080,0x0d8,0x130,0x188,0x1e0,0x238,0x290,0x2e8,0x340,0x398,0x3f0,0x448,0x4a0,0x4f8,0x550,0x5a8,0x600,0x658,0x6b0,0x708,0x760,0x7b8 },
-       { 0x205,0x25d,0x2b5,0x30d,0x365,0x3bd,0x415,0x46d,0x4c5,0x51d,0x575,0x5cd,0x625,0x67d,0x6d5,0x72d,0x785,0x7dd,0x835,0x88d,0x029,0x081,0x0d9,0x131,0x189,0x1e1,0x239,0x291,0x2e9,0x341,0x399,0x3f1,0x449,0x4a1,0x4f9,0x551,0x5a9,0x601,0x659,0x6b1,0x709,0x761,0x7b9 },
-       { 0x25a,0x2b2,0x30a,0x362,0x3ba,0x412,0x46a,0x4c2,0x51a,0x572,0x5ca,0x622,0x67a,0x6d2,0x72a,0x782,0x7da,0x832,0x88a,0x026,0x07e,0x0d6,0x12e,0x186,0x1de,0x236,0x28e,0x2e6,0x33e,0x396,0x3ee,0x446,0x49e,0x4f6,0x54e,0x5a6,0x5fe,0x656,0x6ae,0x706,0x75e,0x7b6,0x80e },
-       { 0x25b,0x2b3,0x30b,0x363,0x3bb,0x413,0x46b,0x4c3,0x51b,0x573,0x5cb,0x623,0x67b,0x6d3,0x72b,0x783,0x7db,0x833,0x88b,0x027,0x07f,0x0d7,0x12f,0x187,0x1df,0x237,0x28f,0x2e7,0x33f,0x397,0x3ef,0x447,0x49f,0x4f7,0x54f,0x5a7,0x5ff,0x657,0x6af,0x707,0x75f,0x7b7,0x80f },
-       { 0x2b0,0x308,0x360,0x3b8,0x410,0x468,0x4c0,0x518,0x570,0x5c8,0x620,0x678,0x6d0,0x728,0x780,0x7d8,0x830,0x888,0x024,0x07c,0x0d4,0x12c,0x184,0x1dc,0x234,0x28c,0x2e4,0x33c,0x394,0x3ec,0x444,0x49c,0x4f4,0x54c,0x5a4,0x5fc,0x654,0x6ac,0x704,0x75c,0x7b4,0x80c,0x864 },
-       { 0x2b1,0x309,0x361,0x3b9,0x411,0x469,0x4c1,0x519,0x571,0x5c9,0x621,0x679,0x6d1,0x729,0x781,0x7d9,0x831,0x889,0x025,0x07d,0x0d5,0x12d,0x185,0x1dd,0x235,0x28d,0x2e5,0x33d,0x395,0x3ed,0x445,0x49d,0x4f5,0x54d,0x5a5,0x5fd,0x655,0x6ad,0x705,0x75d,0x7b5,0x80d,0x865 },
-       { 0x306,0x35e,0x3b6,0x40e,0x466,0x4be,0x516,0x56e,0x5c6,0x61e,0x676,0x6ce,0x726,0x77e,0x7d6,0x82e,0x886,0x022,0x07a,0x0d2,0x12a,0x182,0x1da,0x232,0x28a,0x2e2,0x33a,0x392,0x3ea,0x442,0x49a,0x4f2,0x54a,0x5a2,0x5fa,0x652,0x6aa,0x702,0x75a,0x7b2,0x80a,0x862,0x8ba },
-       { 0x307,0x35f,0x3b7,0x40f,0x467,0x4bf,0x517,0x56f,0x5c7,0x61f,0x677,0x6cf,0x727,0x77f,0x7d7,0x82f,0x887,0x023,0x07b,0x0d3,0x12b,0x183,0x1db,0x233,0x28b,0x2e3,0x33b,0x393,0x3eb,0x443,0x49b,0x4f3,0x54b,0x5a3,0x5fb,0x653,0x6ab,0x703,0x75b,0x7b3,0x80b,0x863,0x8bb },
-       { 0x35c,0x3b4,0x40c,0x464,0x4bc,0x514,0x56c,0x5c4,0x61c,0x674,0x6cc,0x724,0x77c,0x7d4,0x82c,0x884,0x020,0x078,0x0d0,0x128,0x180,0x1d8,0x230,0x288,0x2e0,0x338,0x390,0x3e8,0x440,0x498,0x4f0,0x548,0x5a0,0x5f8,0x650,0x6a8,0x700,0x758,0x7b0,0x808,0x860,0x8b8,0x054 },
-       { 0x35d,0x3b5,0x40d,0x465,0x4bd,0x515,0x56d,0x5c5,0x61d,0x675,0x6cd,0x725,0x77d,0x7d5,0x82d,0x885,0x021,0x079,0x0d1,0x129,0x181,0x1d9,0x231,0x289,0x2e1,0x339,0x391,0x3e9,0x441,0x499,0x4f1,0x549,0x5a1,0x5f9,0x651,0x6a9,0x701,0x759,0x7b1,0x809,0x861,0x8b9,0x055 },
-       { 0x3b2,0x40a,0x462,0x4ba,0x512,0x56a,0x5c2,0x61a,0x672,0x6ca,0x722,0x77a,0x7d2,0x82a,0x882,0x01e,0x076,0x0ce,0x126,0x17e,0x1d6,0x22e,0x286,0x2de,0x336,0x38e,0x3e6,0x43e,0x496,0x4ee,0x546,0x59e,0x5f6,0x64e,0x6a6,0x6fe,0x756,0x7ae,0x806,0x85e,0x8b6,0x052,0x0aa },
-       { 0x3b3,0x40b,0x463,0x4bb,0x513,0x56b,0x5c3,0x61b,0x673,0x6cb,0x723,0x77b,0x7d3,0x82b,0x883,0x01f,0x077,0x0cf,0x127,0x17f,0x1d7,0x22f,0x287,0x2df,0x337,0x38f,0x3e7,0x43f,0x497,0x4ef,0x547,0x59f,0x5f7,0x64f,0x6a7,0x6ff,0x757,0x7af,0x807,0x85f,0x8b7,0x053,0x0ab },
-       { 0x408,0x460,0x4b8,0x510,0x568,0x5c0,0x618,0x670,0x6c8,0x720,0x778,0x7d0,0x828,0x880,0x01c,0x074,0x0cc,0x124,0x17c,0x1d4,0x22c,0x284,0x2dc,0x334,0x38c,0x3e4,0x43c,0x494,0x4ec,0x544,0x59c,0x5f4,0x64c,0x6a4,0x6fc,0x754,0x7ac,0x804,0x85c,0x8b4,0x050,0x0a8,0x100 },
-       { 0x409,0x461,0x4b9,0x511,0x569,0x5c1,0x619,0x671,0x6c9,0x721,0x779,0x7d1,0x829,0x881,0x01d,0x075,0x0cd,0x125,0x17d,0x1d5,0x22d,0x285,0x2dd,0x335,0x38d,0x3e5,0x43d,0x495,0x4ed,0x545,0x59d,0x5f5,0x64d,0x6a5,0x6fd,0x755,0x7ad,0x805,0x85d,0x8b5,0x051,0x0a9,0x101 },
-       { 0x45e,0x4b6,0x50e,0x566,0x5be,0x616,0x66e,0x6c6,0x71e,0x776,0x7ce,0x826,0x87e,0x01a,0x072,0x0ca,0x122,0x17a,0x1d2,0x22a,0x282,0x2da,0x332,0x38a,0x3e2,0x43a,0x492,0x4ea,0x542,0x59a,0x5f2,0x64a,0x6a2,0x6fa,0x752,0x7aa,0x802,0x85a,0x8b2,0x04e,0x0a6,0x0fe,0x156 },
-       { 0x45f,0x4b7,0x50f,0x567,0x5bf,0x617,0x66f,0x6c7,0x71f,0x777,0x7cf,0x827,0x87f,0x01b,0x073,0x0cb,0x123,0x17b,0x1d3,0x22b,0x283,0x2db,0x333,0x38b,0x3e3,0x43b,0x493,0x4eb,0x543,0x59b,0x5f3,0x64b,0x6a3,0x6fb,0x753,0x7ab,0x803,0x85b,0x8b3,0x04f,0x0a7,0x0ff,0x157 },
-       { 0x4b4,0x50c,0x564,0x5bc,0x614,0x66c,0x6c4,0x71c,0x774,0x7cc,0x824,0x87c,0x018,0x070,0x0c8,0x120,0x178,0x1d0,0x228,0x280,0x2d8,0x330,0x388,0x3e0,0x438,0x490,0x4e8,0x540,0x598,0x5f0,0x648,0x6a0,0x6f8,0x750,0x7a8,0x800,0x858,0x8b0,0x04c,0x0a4,0x0fc,0x154,0x1ac },
-       { 0x4b5,0x50d,0x565,0x5bd,0x615,0x66d,0x6c5,0x71d,0x775,0x7cd,0x825,0x87d,0x019,0x071,0x0c9,0x121,0x179,0x1d1,0x229,0x281,0x2d9,0x331,0x389,0x3e1,0x439,0x491,0x4e9,0x541,0x599,0x5f1,0x649,0x6a1,0x6f9,0x751,0x7a9,0x801,0x859,0x8b1,0x04d,0x0a5,0x0fd,0x155,0x1ad },
-       { 0x50a,0x562,0x5ba,0x612,0x66a,0x6c2,0x71a,0x772,0x7ca,0x822,0x87a,0x016,0x06e,0x0c6,0x11e,0x176,0x1ce,0x226,0x27e,0x2d6,0x32e,0x386,0x3de,0x436,0x48e,0x4e6,0x53e,0x596,0x5ee,0x646,0x69e,0x6f6,0x74e,0x7a6,0x7fe,0x856,0x8ae,0x04a,0x0a2,0x0fa,0x152,0x1aa,0x202 },
-       { 0x50b,0x563,0x5bb,0x613,0x66b,0x6c3,0x71b,0x773,0x7cb,0x823,0x87b,0x017,0x06f,0x0c7,0x11f,0x177,0x1cf,0x227,0x27f,0x2d7,0x32f,0x387,0x3df,0x437,0x48f,0x4e7,0x53f,0x597,0x5ef,0x647,0x69f,0x6f7,0x74f,0x7a7,0x7ff,0x857,0x8af,0x04b,0x0a3,0x0fb,0x153,0x1ab,0x203 },
-       { 0x560,0x5b8,0x610,0x668,0x6c0,0x718,0x770,0x7c8,0x820,0x878,0x014,0x06c,0x0c4,0x11c,0x174,0x1cc,0x224,0x27c,0x2d4,0x32c,0x384,0x3dc,0x434,0x48c,0x4e4,0x53c,0x594,0x5ec,0x644,0x69c,0x6f4,0x74c,0x7a4,0x7fc,0x854,0x8ac,0x048,0x0a0,0x0f8,0x150,0x1a8,0x200,0x258 },
-       { 0x561,0x5b9,0x611,0x669,0x6c1,0x719,0x771,0x7c9,0x821,0x879,0x015,0x06d,0x0c5,0x11d,0x175,0x1cd,0x225,0x27d,0x2d5,0x32d,0x385,0x3dd,0x435,0x48d,0x4e5,0x53d,0x595,0x5ed,0x645,0x69d,0x6f5,0x74d,0x7a5,0x7fd,0x855,0x8ad,0x049,0x0a1,0x0f9,0x151,0x1a9,0x201,0x259 },
-       { 0x5b6,0x60e,0x666,0x6be,0x716,0x76e,0x7c6,0x81e,0x876,0x012,0x06a,0x0c2,0x11a,0x172,0x1ca,0x222,0x27a,0x2d2,0x32a,0x382,0x3da,0x432,0x48a,0x4e2,0x53a,0x592,0x5ea,0x642,0x69a,0x6f2,0x74a,0x7a2,0x7fa,0x852,0x8aa,0x046,0x09e,0x0f6,0x14e,0x1a6,0x1fe,0x256,0x2ae },
-       { 0x5b7,0x60f,0x667,0x6bf,0x717,0x76f,0x7c7,0x81f,0x877,0x013,0x06b,0x0c3,0x11b,0x173,0x1cb,0x223,0x27b,0x2d3,0x32b,0x383,0x3db,0x433,0x48b,0x4e3,0x53b,0x593,0x5eb,0x643,0x69b,0x6f3,0x74b,0x7a3,0x7fb,0x853,0x8ab,0x047,0x09f,0x0f7,0x14f,0x1a7,0x1ff,0x257,0x2af },
-       { 0x60c,0x664,0x6bc,0x714,0x76c,0x7c4,0x81c,0x874,0x010,0x068,0x0c0,0x118,0x170,0x1c8,0x220,0x278,0x2d0,0x328,0x380,0x3d8,0x430,0x488,0x4e0,0x538,0x590,0x5e8,0x640,0x698,0x6f0,0x748,0x7a0,0x7f8,0x850,0x8a8,0x044,0x09c,0x0f4,0x14c,0x1a4,0x1fc,0x254,0x2ac,0x304 },
-       { 0x60d,0x665,0x6bd,0x715,0x76d,0x7c5,0x81d,0x875,0x011,0x069,0x0c1,0x119,0x171,0x1c9,0x221,0x279,0x2d1,0x329,0x381,0x3d9,0x431,0x489,0x4e1,0x539,0x591,0x5e9,0x641,0x699,0x6f1,0x749,0x7a1,0x7f9,0x851,0x8a9,0x045,0x09d,0x0f5,0x14d,0x1a5,0x1fd,0x255,0x2ad,0x305 },
-       { 0x662,0x6ba,0x712,0x76a,0x7c2,0x81a,0x872,0x00e,0x066,0x0be,0x116,0x16e,0x1c6,0x21e,0x276,0x2ce,0x326,0x37e,0x3d6,0x42e,0x486,0x4de,0x536,0x58e,0x5e6,0x63e,0x696,0x6ee,0x746,0x79e,0x7f6,0x84e,0x8a6,0x042,0x09a,0x0f2,0x14a,0x1a2,0x1fa,0x252,0x2aa,0x302,0x35a },
-       { 0x663,0x6bb,0x713,0x76b,0x7c3,0x81b,0x873,0x00f,0x067,0x0bf,0x117,0x16f,0x1c7,0x21f,0x277,0x2cf,0x327,0x37f,0x3d7,0x42f,0x487,0x4df,0x537,0x58f,0x5e7,0x63f,0x697,0x6ef,0x747,0x79f,0x7f7,0x84f,0x8a7,0x043,0x09b,0x0f3,0x14b,0x1a3,0x1fb,0x253,0x2ab,0x303,0x35b },
-       { 0x6b8,0x710,0x768,0x7c0,0x818,0x870,0x00c,0x064,0x0bc,0x114,0x16c,0x1c4,0x21c,0x274,0x2cc,0x324,0x37c,0x3d4,0x42c,0x484,0x4dc,0x534,0x58c,0x5e4,0x63c,0x694,0x6ec,0x744,0x79c,0x7f4,0x84c,0x8a4,0x040,0x098,0x0f0,0x148,0x1a0,0x1f8,0x250,0x2a8,0x300,0x358,0x3b0 },
-       { 0x6b9,0x711,0x769,0x7c1,0x819,0x871,0x00d,0x065,0x0bd,0x115,0x16d,0x1c5,0x21d,0x275,0x2cd,0x325,0x37d,0x3d5,0x42d,0x485,0x4dd,0x535,0x58d,0x5e5,0x63d,0x695,0x6ed,0x745,0x79d,0x7f5,0x84d,0x8a5,0x041,0x099,0x0f1,0x149,0x1a1,0x1f9,0x251,0x2a9,0x301,0x359,0x3b1 },
-       { 0x70e,0x766,0x7be,0x816,0x86e,0x00a,0x062,0x0ba,0x112,0x16a,0x1c2,0x21a,0x272,0x2ca,0x322,0x37a,0x3d2,0x42a,0x482,0x4da,0x532,0x58a,0x5e2,0x63a,0x692,0x6ea,0x742,0x79a,0x7f2,0x84a,0x8a2,0x03e,0x096,0x0ee,0x146,0x19e,0x1f6,0x24e,0x2a6,0x2fe,0x356,0x3ae,0x406 },
-       { 0x70f,0x767,0x7bf,0x817,0x86f,0x00b,0x063,0x0bb,0x113,0x16b,0x1c3,0x21b,0x273,0x2cb,0x323,0x37b,0x3d3,0x42b,0x483,0x4db,0x533,0x58b,0x5e3,0x63b,0x693,0x6eb,0x743,0x79b,0x7f3,0x84b,0x8a3,0x03f,0x097,0x0ef,0x147,0x19f,0x1f7,0x24f,0x2a7,0x2ff,0x357,0x3af,0x407 },
-       { 0x764,0x7bc,0x814,0x86c,0x008,0x060,0x0b8,0x110,0x168,0x1c0,0x218,0x270,0x2c8,0x320,0x378,0x3d0,0x428,0x480,0x4d8,0x530,0x588,0x5e0,0x638,0x690,0x6e8,0x740,0x798,0x7f0,0x848,0x8a0,0x03c,0x094,0x0ec,0x144,0x19c,0x1f4,0x24c,0x2a4,0x2fc,0x354,0x3ac,0x404,0x45c },
-       { 0x765,0x7bd,0x815,0x86d,0x009,0x061,0x0b9,0x111,0x169,0x1c1,0x219,0x271,0x2c9,0x321,0x379,0x3d1,0x429,0x481,0x4d9,0x531,0x589,0x5e1,0x639,0x691,0x6e9,0x741,0x799,0x7f1,0x849,0x8a1,0x03d,0x095,0x0ed,0x145,0x19d,0x1f5,0x24d,0x2a5,0x2fd,0x355,0x3ad,0x405,0x45d },
-       { 0x7ba,0x812,0x86a,0x006,0x05e,0x0b6,0x10e,0x166,0x1be,0x216,0x26e,0x2c6,0x31e,0x376,0x3ce,0x426,0x47e,0x4d6,0x52e,0x586,0x5de,0x636,0x68e,0x6e6,0x73e,0x796,0x7ee,0x846,0x89e,0x03a,0x092,0x0ea,0x142,0x19a,0x1f2,0x24a,0x2a2,0x2fa,0x352,0x3aa,0x402,0x45a,0x4b2 },
-       { 0x7bb,0x813,0x86b,0x007,0x05f,0x0b7,0x10f,0x167,0x1bf,0x217,0x26f,0x2c7,0x31f,0x377,0x3cf,0x427,0x47f,0x4d7,0x52f,0x587,0x5df,0x637,0x68f,0x6e7,0x73f,0x797,0x7ef,0x847,0x89f,0x03b,0x093,0x0eb,0x143,0x19b,0x1f3,0x24b,0x2a3,0x2fb,0x353,0x3ab,0x403,0x45b,0x4b3 },
-       { 0x810,0x868,0x004,0x05c,0x0b4,0x10c,0x164,0x1bc,0x214,0x26c,0x2c4,0x31c,0x374,0x3cc,0x424,0x47c,0x4d4,0x52c,0x584,0x5dc,0x634,0x68c,0x6e4,0x73c,0x794,0x7ec,0x844,0x89c,0x038,0x090,0x0e8,0x140,0x198,0x1f0,0x248,0x2a0,0x2f8,0x350,0x3a8,0x400,0x458,0x4b0,0x508 },
-       { 0x811,0x869,0x005,0x05d,0x0b5,0x10d,0x165,0x1bd,0x215,0x26d,0x2c5,0x31d,0x375,0x3cd,0x425,0x47d,0x4d5,0x52d,0x585,0x5dd,0x635,0x68d,0x6e5,0x73d,0x795,0x7ed,0x845,0x89d,0x039,0x091,0x0e9,0x141,0x199,0x1f1,0x249,0x2a1,0x2f9,0x351,0x3a9,0x401,0x459,0x4b1,0x509 },
-       { 0x866,0x002,0x05a,0x0b2,0x10a,0x162,0x1ba,0x212,0x26a,0x2c2,0x31a,0x372,0x3ca,0x422,0x47a,0x4d2,0x52a,0x582,0x5da,0x632,0x68a,0x6e2,0x73a,0x792,0x7ea,0x842,0x89a,0x036,0x08e,0x0e6,0x13e,0x196,0x1ee,0x246,0x29e,0x2f6,0x34e,0x3a6,0x3fe,0x456,0x4ae,0x506,0x55e },
-       { 0x867,0x003,0x05b,0x0b3,0x10b,0x163,0x1bb,0x213,0x26b,0x2c3,0x31b,0x373,0x3cb,0x423,0x47b,0x4d3,0x52b,0x583,0x5db,0x633,0x68b,0x6e3,0x73b,0x793,0x7eb,0x843,0x89b,0x037,0x08f,0x0e7,0x13f,0x197,0x1ef,0x247,0x29f,0x2f7,0x34f,0x3a7,0x3ff,0x457,0x4af,0x507,0x55f }
-};
-
-/*-------------------------------------------------
- *  ecc_source_byte - return data from the sector
- *  at the given offset, masking anything
- *  particular to a mode
- *-------------------------------------------------
- */
-
-static inline uint8_t ecc_source_byte(const uint8_t *sector, uint32_t offset)
-{
-       /* in mode 2 always treat these as 0 bytes */
-       return (sector[MODE_OFFSET] == 2 && offset < 4) ? 0x00 : sector[SYNC_OFFSET + SYNC_NUM_BYTES + offset];
-}
-
-/**
- * @fn  void ecc_compute_bytes(const uint8_t *sector, const uint16_t *row, int rowlen, uint8_t &val1, uint8_t &val2)
- *
- * @brief   -------------------------------------------------
- *            ecc_compute_bytes - calculate an ECC value (P or Q)
- *          -------------------------------------------------.
- *
- * @param   sector          The sector.
- * @param   row             The row.
- * @param   rowlen          The rowlen.
- * @param [in,out]  val1    The first value.
- * @param [in,out]  val2    The second value.
- */
-
-void ecc_compute_bytes(const uint8_t *sector, const uint16_t *row, int rowlen, uint8_t *val1, uint8_t *val2)
-{
-       int component;
-       *val1 = *val2 = 0;
-       for (component = 0; component < rowlen; component++)
-       {
-               *val1 ^= ecc_source_byte(sector, row[component]);
-               *val2 ^= ecc_source_byte(sector, row[component]);
-               *val1 = ecclow[*val1];
-       }
-       *val1 = ecchigh[ecclow[*val1] ^ *val2];
-       *val2 ^= *val1;
-}
-
-/**
- * @fn  int ecc_verify(const uint8_t *sector)
- *
- * @brief   -------------------------------------------------
- *            ecc_verify - verify the P and Q ECC codes in a sector
- *          -------------------------------------------------.
- *
- * @param   sector  The sector.
- *
- * @return  true if it succeeds, false if it fails.
- */
-
-int ecc_verify(const uint8_t *sector)
-{
-       int byte;
-       /* first verify P bytes */
-       for (byte = 0; byte < ECC_P_NUM_BYTES; byte++)
-       {
-               uint8_t val1, val2;
-               ecc_compute_bytes(sector, poffsets[byte], ECC_P_COMP, &val1, &val2);
-               if (sector[ECC_P_OFFSET + byte] != val1 || sector[ECC_P_OFFSET + ECC_P_NUM_BYTES + byte] != val2)
-                       return 0;
-       }
-
-       /* then verify Q bytes */
-       for (byte = 0; byte < ECC_Q_NUM_BYTES; byte++)
-       {
-               uint8_t val1, val2;
-               ecc_compute_bytes(sector, qoffsets[byte], ECC_Q_COMP, &val1, &val2);
-               if (sector[ECC_Q_OFFSET + byte] != val1 || sector[ECC_Q_OFFSET + ECC_Q_NUM_BYTES + byte] != val2)
-                       return 0;
-       }
-       return 1;
-}
-
-/**
- * @fn  void ecc_generate(uint8_t *sector)
- *
- * @brief   -------------------------------------------------
- *            ecc_generate - generate the P and Q ECC codes for a sector, overwriting any
- *            existing codes
- *          -------------------------------------------------.
- *
- * @param [in,out]  sector  If non-null, the sector.
- */
-
-void ecc_generate(uint8_t *sector)
-{
-       int byte;
-       /* first verify P bytes */
-       for (byte = 0; byte < ECC_P_NUM_BYTES; byte++)
-               ecc_compute_bytes(sector, poffsets[byte], ECC_P_COMP, &sector[ECC_P_OFFSET + byte], &sector[ECC_P_OFFSET + ECC_P_NUM_BYTES + byte]);
-
-       /* then verify Q bytes */
-       for (byte = 0; byte < ECC_Q_NUM_BYTES; byte++)
-               ecc_compute_bytes(sector, qoffsets[byte], ECC_Q_COMP, &sector[ECC_Q_OFFSET + byte], &sector[ECC_Q_OFFSET + ECC_Q_NUM_BYTES + byte]);
-}
-
-/**
- * @fn  void ecc_clear(uint8_t *sector)
- *
- * @brief   -------------------------------------------------
- *            ecc_clear - erase the ECC P and Q cods to 0 within a sector
- *          -------------------------------------------------.
- *
- * @param [in,out]  sector  If non-null, the sector.
- */
-
-void ecc_clear(uint8_t *sector)
-{
-       memset(&sector[ECC_P_OFFSET], 0, 2 * ECC_P_NUM_BYTES);
-       memset(&sector[ECC_Q_OFFSET], 0, 2 * ECC_Q_NUM_BYTES);
-}
-
-#endif /* WANT_RAW_DATA_SECTOR */
diff --git a/deps/libchdr/src/libchdr_chd.c b/deps/libchdr/src/libchdr_chd.c
deleted file mode 100644 (file)
index 913abaa..0000000
+++ /dev/null
@@ -1,2672 +0,0 @@
-/***************************************************************************
-
-    chd.c
-
-    MAME Compressed Hunks of Data file format
-
-****************************************************************************
-
-    Copyright Aaron Giles
-    All rights reserved.
-
-    Redistribution and use in source and binary forms, with or without
-    modification, are permitted provided that the following conditions are
-    met:
-
-        * Redistributions of source code must retain the above copyright
-          notice, this list of conditions and the following disclaimer.
-        * Redistributions in binary form must reproduce the above copyright
-          notice, this list of conditions and the following disclaimer in
-          the documentation and/or other materials provided with the
-          distribution.
-        * Neither the name 'MAME' nor the names of its contributors may be
-          used to endorse or promote products derived from this software
-          without specific prior written permission.
-
-    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
-    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
-    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
-    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-    POSSIBILITY OF SUCH DAMAGE.
-
-***************************************************************************/
-
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-
-#include <libchdr/chd.h>
-#include <libchdr/cdrom.h>
-#include <libchdr/flac.h>
-#include <libchdr/huffman.h>
-
-#include "LzmaEnc.h"
-#include "LzmaDec.h"
-#include "zlib.h"
-
-#undef TRUE
-#undef FALSE
-#define TRUE 1
-#define FALSE 0
-
-#undef MAX
-#undef MIN
-#define MAX(x, y) (((x) > (y)) ? (x) : (y))
-#define MIN(x, y) (((x) < (y)) ? (x) : (y))
-
-#define SHA1_DIGEST_SIZE 20
-
-/***************************************************************************
-    DEBUGGING
-***************************************************************************/
-
-#define PRINTF_MAX_HUNK                                (0)
-
-/***************************************************************************
-    CONSTANTS
-***************************************************************************/
-
-#define MAP_STACK_ENTRIES                      512                     /* max number of entries to use on the stack */
-#define MAP_ENTRY_SIZE                         16                      /* V3 and later */
-#define OLD_MAP_ENTRY_SIZE                     8                       /* V1-V2 */
-#define METADATA_HEADER_SIZE           16                      /* metadata header size */
-
-#define MAP_ENTRY_FLAG_TYPE_MASK       0x0f            /* what type of hunk */
-#define MAP_ENTRY_FLAG_NO_CRC          0x10            /* no CRC is present */
-
-#define CHD_V1_SECTOR_SIZE                     512                     /* size of a "sector" in the V1 header */
-
-#define COOKIE_VALUE                           0xbaadf00d
-#define MAX_ZLIB_ALLOCS                                64
-
-#define END_OF_LIST_COOKIE                     "EndOfListCookie"
-
-#define NO_MATCH                                       (~0)
-
-#ifdef WANT_RAW_DATA_SECTOR
-static const uint8_t s_cd_sync_header[12] = { 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00 };
-#endif
-
-/* V3-V4 entry types */
-enum
-{
-       V34_MAP_ENTRY_TYPE_INVALID = 0,             /* invalid type */
-       V34_MAP_ENTRY_TYPE_COMPRESSED = 1,          /* standard compression */
-       V34_MAP_ENTRY_TYPE_UNCOMPRESSED = 2,        /* uncompressed data */
-       V34_MAP_ENTRY_TYPE_MINI = 3,                /* mini: use offset as raw data */
-       V34_MAP_ENTRY_TYPE_SELF_HUNK = 4,           /* same as another hunk in this file */
-       V34_MAP_ENTRY_TYPE_PARENT_HUNK = 5,         /* same as a hunk in the parent file */
-       V34_MAP_ENTRY_TYPE_2ND_COMPRESSED = 6       /* compressed with secondary algorithm (usually FLAC CDDA) */
-};
-
-/* V5 compression types */
-enum
-{
-       /* codec #0
-        * these types are live when running */
-       COMPRESSION_TYPE_0 = 0,
-       /* codec #1 */
-       COMPRESSION_TYPE_1 = 1,
-       /* codec #2 */
-       COMPRESSION_TYPE_2 = 2,
-       /* codec #3 */
-       COMPRESSION_TYPE_3 = 3,
-       /* no compression; implicit length = hunkbytes */
-       COMPRESSION_NONE = 4,
-       /* same as another block in this chd */
-       COMPRESSION_SELF = 5,
-       /* same as a hunk's worth of units in the parent chd */
-       COMPRESSION_PARENT = 6,
-
-       /* start of small RLE run (4-bit length)
-        * these additional pseudo-types are used for compressed encodings: */
-       COMPRESSION_RLE_SMALL,
-       /* start of large RLE run (8-bit length) */
-       COMPRESSION_RLE_LARGE,
-       /* same as the last COMPRESSION_SELF block */
-       COMPRESSION_SELF_0,
-       /* same as the last COMPRESSION_SELF block + 1 */
-       COMPRESSION_SELF_1,
-       /* same block in the parent */
-       COMPRESSION_PARENT_SELF,
-       /* same as the last COMPRESSION_PARENT block */
-       COMPRESSION_PARENT_0,
-       /* same as the last COMPRESSION_PARENT block + 1 */
-       COMPRESSION_PARENT_1
-};
-
-/***************************************************************************
-    MACROS
-***************************************************************************/
-
-#define EARLY_EXIT(x)                          do { (void)(x); goto cleanup; } while (0)
-
-/***************************************************************************
-    TYPE DEFINITIONS
-***************************************************************************/
-
-/* interface to a codec */
-typedef struct _codec_interface codec_interface;
-struct _codec_interface
-{
-       UINT32          compression;                                                            /* type of compression */
-       const char *compname;                                                                   /* name of the algorithm */
-       UINT8           lossy;                                                                          /* is this a lossy algorithm? */
-       chd_error       (*init)(void *codec, UINT32 hunkbytes);         /* codec initialize */
-       void            (*free)(void *codec);                                           /* codec free */
-       chd_error       (*decompress)(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen); /* decompress data */
-       chd_error       (*config)(void *codec, int param, void *config); /* configure */
-};
-
-/* a single map entry */
-typedef struct _map_entry map_entry;
-struct _map_entry
-{
-       UINT64                                  offset;                 /* offset within the file of the data */
-       UINT32                                  crc;                    /* 32-bit CRC of the data */
-       UINT32                                  length;                 /* length of the data */
-       UINT8                                   flags;                  /* misc flags */
-};
-
-/* a single metadata entry */
-typedef struct _metadata_entry metadata_entry;
-struct _metadata_entry
-{
-       UINT64                                  offset;                 /* offset within the file of the header */
-       UINT64                                  next;                   /* offset within the file of the next header */
-       UINT64                                  prev;                   /* offset within the file of the previous header */
-       UINT32                                  length;                 /* length of the metadata */
-       UINT32                                  metatag;                /* metadata tag */
-       UINT8                                   flags;                  /* flag bits */
-};
-
-/* codec-private data for the ZLIB codec */
-
-typedef struct _zlib_allocator zlib_allocator;
-struct _zlib_allocator
-{
-       UINT32 *                                allocptr[MAX_ZLIB_ALLOCS];
-       UINT32 *                                allocptr2[MAX_ZLIB_ALLOCS];
-};
-
-typedef struct _zlib_codec_data zlib_codec_data;
-struct _zlib_codec_data
-{
-       z_stream                                inflater;
-       zlib_allocator                  allocator;
-};
-
-/* codec-private data for the LZMA codec */
-#define MAX_LZMA_ALLOCS 64
-
-typedef struct _lzma_allocator lzma_allocator;
-struct _lzma_allocator
-{
-       void *(*Alloc)(void *p, size_t size);
-       void (*Free)(void *p, void *address); /* address can be 0 */
-       void (*FreeSz)(void *p, void *address, size_t size); /* address can be 0 */
-       uint32_t*       allocptr[MAX_LZMA_ALLOCS];
-       uint32_t*       allocptr2[MAX_LZMA_ALLOCS];
-};
-
-typedef struct _lzma_codec_data lzma_codec_data;
-struct _lzma_codec_data
-{
-       CLzmaDec                decoder;
-       lzma_allocator  allocator;
-};
-
-/* codec-private data for the CDZL codec */
-typedef struct _cdzl_codec_data cdzl_codec_data;
-struct _cdzl_codec_data {
-       /* internal state */
-       zlib_codec_data         base_decompressor;
-#ifdef WANT_SUBCODE
-       zlib_codec_data         subcode_decompressor;
-#endif
-       uint8_t*                        buffer;
-};
-
-/* codec-private data for the CDLZ codec */
-typedef struct _cdlz_codec_data cdlz_codec_data;
-struct _cdlz_codec_data {
-       /* internal state */
-       lzma_codec_data         base_decompressor;
-#ifdef WANT_SUBCODE
-       zlib_codec_data         subcode_decompressor;
-#endif
-       uint8_t*                        buffer;
-};
-
-/* codec-private data for the CDFL codec */
-typedef struct _cdfl_codec_data cdfl_codec_data;
-struct _cdfl_codec_data {
-       /* internal state */
-       int             swap_endian;
-       flac_decoder    decoder;
-#ifdef WANT_SUBCODE
-       zlib_codec_data         subcode_decompressor;
-#endif
-       uint8_t*        buffer;
-};
-
-/* internal representation of an open CHD file */
-struct _chd_file
-{
-       UINT32                                  cookie;                 /* cookie, should equal COOKIE_VALUE */
-
-       core_file *                             file;                   /* handle to the open core file */
-       UINT8                                   owns_file;              /* flag indicating if this file should be closed on chd_close() */
-       chd_header                              header;                 /* header, extracted from file */
-
-       chd_file *                              parent;                 /* pointer to parent file, or NULL */
-
-       map_entry *                             map;                    /* array of map entries */
-
-#ifdef NEED_CACHE_HUNK
-       UINT8 *                                 cache;                  /* hunk cache pointer */
-       UINT32                                  cachehunk;              /* index of currently cached hunk */
-
-       UINT8 *                                 compare;                /* hunk compare pointer */
-       UINT32                                  comparehunk;    /* index of current compare data */
-#endif
-
-       UINT8 *                                 compressed;             /* pointer to buffer for compressed data */
-       const codec_interface * codecintf[4];   /* interface to the codec */
-
-       zlib_codec_data                 zlib_codec_data;                /* zlib codec data */
-       cdzl_codec_data                 cdzl_codec_data;                /* cdzl codec data */
-       cdlz_codec_data                 cdlz_codec_data;                /* cdlz codec data */
-       cdfl_codec_data                 cdfl_codec_data;                /* cdfl codec data */
-
-#ifdef NEED_CACHE_HUNK
-       UINT32                                  maxhunk;                /* maximum hunk accessed */
-#endif
-
-       UINT8 *                                 file_cache;             /* cache of underlying file */
-};
-
-
-/***************************************************************************
-    GLOBAL VARIABLES
-***************************************************************************/
-
-static const UINT8 nullmd5[CHD_MD5_BYTES] = { 0 };
-static const UINT8 nullsha1[CHD_SHA1_BYTES] = { 0 };
-
-/***************************************************************************
-    PROTOTYPES
-***************************************************************************/
-
-/* internal header operations */
-static chd_error header_validate(const chd_header *header);
-static chd_error header_read(chd_file *chd, chd_header *header);
-
-/* internal hunk read/write */
-#ifdef NEED_CACHE_HUNK
-static chd_error hunk_read_into_cache(chd_file *chd, UINT32 hunknum);
-#endif
-static chd_error hunk_read_into_memory(chd_file *chd, UINT32 hunknum, UINT8 *dest);
-
-/* internal map access */
-static chd_error map_read(chd_file *chd);
-
-/* metadata management */
-static chd_error metadata_find_entry(chd_file *chd, UINT32 metatag, UINT32 metaindex, metadata_entry *metaentry);
-
-/* zlib compression codec */
-static chd_error zlib_codec_init(void *codec, uint32_t hunkbytes);
-static void zlib_codec_free(void *codec);
-static chd_error zlib_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen);
-static voidpf zlib_fast_alloc(voidpf opaque, uInt items, uInt size);
-static void zlib_fast_free(voidpf opaque, voidpf address);
-static void zlib_allocator_free(voidpf opaque);
-
-/* lzma compression codec */
-static chd_error lzma_codec_init(void *codec, uint32_t hunkbytes);
-static void lzma_codec_free(void *codec);
-static chd_error lzma_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen);
-
-/* cdzl compression codec */
-static chd_error cdzl_codec_init(void* codec, uint32_t hunkbytes);
-static void cdzl_codec_free(void* codec);
-static chd_error cdzl_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen);
-
-/* cdlz compression codec */
-static chd_error cdlz_codec_init(void* codec, uint32_t hunkbytes);
-static void cdlz_codec_free(void* codec);
-static chd_error cdlz_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen);
-
-/* cdfl compression codec */
-static chd_error cdfl_codec_init(void* codec, uint32_t hunkbytes);
-static void cdfl_codec_free(void* codec);
-static chd_error cdfl_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen);
-
-/***************************************************************************
- *  LZMA ALLOCATOR HELPER
- ***************************************************************************
- */
-
-static void *lzma_fast_alloc(void *p, size_t size);
-static void lzma_fast_free(void *p, void *address);
-
-/*-------------------------------------------------
- *  lzma_allocator_init
- *-------------------------------------------------
- */
-
-static void lzma_allocator_init(void* p)
-{
-       lzma_allocator *codec = (lzma_allocator *)(p);
-
-       /* reset pointer list */
-       memset(codec->allocptr, 0, sizeof(codec->allocptr));
-       memset(codec->allocptr2, 0, sizeof(codec->allocptr2));
-       codec->Alloc = lzma_fast_alloc;
-       codec->Free = lzma_fast_free;
-}
-
-/*-------------------------------------------------
- *  lzma_allocator_free
- *-------------------------------------------------
- */
-
-static void lzma_allocator_free(void* p )
-{
-       int i;
-       lzma_allocator *codec = (lzma_allocator *)(p);
-
-       /* free our memory */
-       for (i = 0 ; i < MAX_LZMA_ALLOCS ; i++)
-       {
-               if (codec->allocptr[i] != NULL)
-                       free(codec->allocptr[i]);
-       }
-}
-
-/*-------------------------------------------------
- *  lzma_fast_alloc - fast malloc for lzma, which
- *  allocates and frees memory frequently
- *-------------------------------------------------
- */
-
-/* Huge alignment values for possible SIMD optimization by compiler (NEON, SSE, AVX) */
-#define LZMA_MIN_ALIGNMENT_BITS 512
-#define LZMA_MIN_ALIGNMENT_BYTES (LZMA_MIN_ALIGNMENT_BITS / 8)
-
-static void *lzma_fast_alloc(void *p, size_t size)
-{
-       int scan;
-       uint32_t *addr        = NULL;
-       lzma_allocator *codec = (lzma_allocator *)(p);
-       uintptr_t vaddr = 0;
-
-       /* compute the size, rounding to the nearest 1k */
-       size = (size + 0x3ff) & ~0x3ff;
-
-       /* reuse a hunk if we can */
-       for (scan = 0; scan < MAX_LZMA_ALLOCS; scan++)
-       {
-               uint32_t *ptr = codec->allocptr[scan];
-               if (ptr != NULL && size == *ptr)
-               {
-                       /* set the low bit of the size so we don't match next time */
-                       *ptr |= 1;
-
-                       /* return aligned address of the block */
-                       return codec->allocptr2[scan];
-               }
-       }
-
-       /* alloc a new one and put it into the list */
-       addr = (uint32_t *)malloc(size + sizeof(uint32_t) + LZMA_MIN_ALIGNMENT_BYTES);
-       if (addr==NULL)
-               return NULL;
-       for (scan = 0; scan < MAX_LZMA_ALLOCS; scan++)
-       {
-               if (codec->allocptr[scan] == NULL)
-               {
-                       /* store block address */
-                       codec->allocptr[scan] = addr;
-
-                       /* compute aligned address, store it */
-                       vaddr = (uintptr_t)addr;
-                       vaddr = (vaddr + sizeof(uint32_t) + (LZMA_MIN_ALIGNMENT_BYTES-1)) & (~(LZMA_MIN_ALIGNMENT_BYTES-1));
-                       codec->allocptr2[scan] = (uint32_t*)vaddr;
-                       break;
-               }
-       }
-
-       /* set the low bit of the size so we don't match next time */
-       *addr = size | 1;
-
-       /* return aligned address */
-       return (void*)vaddr;
-}
-
-/*-------------------------------------------------
- *  lzma_fast_free - fast free for lzma, which
- *  allocates and frees memory frequently
- *-------------------------------------------------
- */
-
-static void lzma_fast_free(void *p, void *address)
-{
-       int scan;
-       uint32_t *ptr = NULL;
-       lzma_allocator *codec = NULL;
-
-       if (address == NULL)
-               return;
-
-       codec = (lzma_allocator *)(p);
-
-       /* find the hunk */
-       ptr = (uint32_t *)address;
-       for (scan = 0; scan < MAX_LZMA_ALLOCS; scan++)
-       {
-               if (ptr == codec->allocptr2[scan])
-               {
-                       /* clear the low bit of the size to allow matches */
-                       *codec->allocptr[scan] &= ~1;
-                       return;
-               }
-       }
-}
-
-/***************************************************************************
- *  LZMA DECOMPRESSOR
- ***************************************************************************
- */
-
-/*-------------------------------------------------
- *  lzma_codec_init - constructor
- *-------------------------------------------------
- */
-
-static chd_error lzma_codec_init(void* codec, uint32_t hunkbytes)
-{
-       CLzmaEncHandle enc;
-       CLzmaEncProps encoder_props;
-       Byte decoder_props[LZMA_PROPS_SIZE];
-       SizeT props_size;
-       lzma_allocator* alloc;
-       lzma_codec_data* lzma_codec = (lzma_codec_data*) codec;
-
-       /* construct the decoder */
-       LzmaDec_Construct(&lzma_codec->decoder);
-
-       /* FIXME: this code is written in a way that makes it impossible to safely upgrade the LZMA SDK
-        * This code assumes that the current version of the encoder imposes the same requirements on the
-        * decoder as the encoder used to produce the file.  This is not necessarily true.  The format
-        * needs to be changed so the encoder properties are written to the file.
-
-        * configure the properties like the compressor did */
-       LzmaEncProps_Init(&encoder_props);
-       encoder_props.level = 9;
-       encoder_props.reduceSize = hunkbytes;
-       LzmaEncProps_Normalize(&encoder_props);
-
-       /* convert to decoder properties */
-       alloc = &lzma_codec->allocator;
-       lzma_allocator_init(alloc);
-       enc = LzmaEnc_Create((ISzAlloc*)alloc);
-       if (!enc)
-               return CHDERR_DECOMPRESSION_ERROR;
-       if (LzmaEnc_SetProps(enc, &encoder_props) != SZ_OK)
-       {
-               LzmaEnc_Destroy(enc, (ISzAlloc*)&alloc, (ISzAlloc*)&alloc);
-               return CHDERR_DECOMPRESSION_ERROR;
-       }
-       props_size = sizeof(decoder_props);
-       if (LzmaEnc_WriteProperties(enc, decoder_props, &props_size) != SZ_OK)
-       {
-               LzmaEnc_Destroy(enc, (ISzAlloc*)alloc, (ISzAlloc*)alloc);
-               return CHDERR_DECOMPRESSION_ERROR;
-       }
-       LzmaEnc_Destroy(enc, (ISzAlloc*)alloc, (ISzAlloc*)alloc);
-
-       /* do memory allocations */
-       if (LzmaDec_Allocate(&lzma_codec->decoder, decoder_props, LZMA_PROPS_SIZE, (ISzAlloc*)alloc) != SZ_OK)
-               return CHDERR_DECOMPRESSION_ERROR;
-
-       /* Okay */
-       return CHDERR_NONE;
-}
-
-/*-------------------------------------------------
- *  lzma_codec_free
- *-------------------------------------------------
- */
-
-static void lzma_codec_free(void* codec)
-{
-       lzma_codec_data* lzma_codec = (lzma_codec_data*) codec;
-
-       /* free memory */
-       LzmaDec_Free(&lzma_codec->decoder, (ISzAlloc*)&lzma_codec->allocator);
-       lzma_allocator_free(&lzma_codec->allocator);
-}
-
-/*-------------------------------------------------
- *  decompress - decompress data using the LZMA
- *  codec
- *-------------------------------------------------
- */
-
-static chd_error lzma_codec_decompress(void* codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
-{
-       ELzmaStatus status;
-       SRes res;
-       SizeT consumedlen, decodedlen;
-       /* initialize */
-       lzma_codec_data* lzma_codec = (lzma_codec_data*) codec;
-       LzmaDec_Init(&lzma_codec->decoder);
-
-       /* decode */
-       consumedlen = complen;
-       decodedlen = destlen;
-       res = LzmaDec_DecodeToBuf(&lzma_codec->decoder, dest, &decodedlen, src, &consumedlen, LZMA_FINISH_END, &status);
-       if ((res != SZ_OK && res != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK) || consumedlen != complen || decodedlen != destlen)
-               return CHDERR_DECOMPRESSION_ERROR;
-       return CHDERR_NONE;
-}
-
-/* cdlz */
-static chd_error cdlz_codec_init(void* codec, uint32_t hunkbytes)
-{
-       chd_error ret;
-       cdlz_codec_data* cdlz = (cdlz_codec_data*) codec;
-
-       /* allocate buffer */
-       cdlz->buffer = (uint8_t*)malloc(sizeof(uint8_t) * hunkbytes);
-       if (cdlz->buffer == NULL)
-               return CHDERR_OUT_OF_MEMORY;
-
-       /* make sure the CHD's hunk size is an even multiple of the frame size */
-       ret = lzma_codec_init(&cdlz->base_decompressor, (hunkbytes / CD_FRAME_SIZE) * CD_MAX_SECTOR_DATA);
-       if (ret != CHDERR_NONE)
-               return ret;
-
-#ifdef WANT_SUBCODE
-       ret = zlib_codec_init(&cdlz->subcode_decompressor, (hunkbytes / CD_FRAME_SIZE) * CD_MAX_SUBCODE_DATA);
-       if (ret != CHDERR_NONE)
-               return ret;
-#endif
-
-       if (hunkbytes % CD_FRAME_SIZE != 0)
-               return CHDERR_CODEC_ERROR;
-
-       return CHDERR_NONE;
-}
-
-static void cdlz_codec_free(void* codec)
-{
-       cdlz_codec_data* cdlz = (cdlz_codec_data*) codec;
-       free(cdlz->buffer);
-       lzma_codec_free(&cdlz->base_decompressor);
-#ifdef WANT_SUBCODE
-       zlib_codec_free(&cdlz->subcode_decompressor);
-#endif
-}
-
-static chd_error cdlz_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
-{
-       uint32_t framenum;
-       cdlz_codec_data* cdlz = (cdlz_codec_data*)codec;
-
-       /* determine header bytes */
-       uint32_t frames = destlen / CD_FRAME_SIZE;
-       uint32_t complen_bytes = (destlen < 65536) ? 2 : 3;
-       uint32_t ecc_bytes = (frames + 7) / 8;
-       uint32_t header_bytes = ecc_bytes + complen_bytes;
-
-       /* extract compressed length of base */
-       uint32_t complen_base = (src[ecc_bytes + 0] << 8) | src[ecc_bytes + 1];
-       if (complen_bytes > 2)
-               complen_base = (complen_base << 8) | src[ecc_bytes + 2];
-
-       /* reset and decode */
-       lzma_codec_decompress(&cdlz->base_decompressor, &src[header_bytes], complen_base, &cdlz->buffer[0], frames * CD_MAX_SECTOR_DATA);
-#ifdef WANT_SUBCODE
-       zlib_codec_decompress(&cdlz->subcode_decompressor, &src[header_bytes + complen_base], complen - complen_base - header_bytes, &cdlz->buffer[frames * CD_MAX_SECTOR_DATA], frames * CD_MAX_SUBCODE_DATA);
-#endif
-
-       /* reassemble the data */
-       for (framenum = 0; framenum < frames; framenum++)
-       {
-               uint8_t *sector;
-
-               memcpy(&dest[framenum * CD_FRAME_SIZE], &cdlz->buffer[framenum * CD_MAX_SECTOR_DATA], CD_MAX_SECTOR_DATA);
-#ifdef WANT_SUBCODE
-               memcpy(&dest[framenum * CD_FRAME_SIZE + CD_MAX_SECTOR_DATA], &cdlz->buffer[frames * CD_MAX_SECTOR_DATA + framenum * CD_MAX_SUBCODE_DATA], CD_MAX_SUBCODE_DATA);
-#endif
-
-#ifdef WANT_RAW_DATA_SECTOR
-               /* reconstitute the ECC data and sync header */
-               sector = (uint8_t *)&dest[framenum * CD_FRAME_SIZE];
-               if ((src[framenum / 8] & (1 << (framenum % 8))) != 0)
-               {
-                       memcpy(sector, s_cd_sync_header, sizeof(s_cd_sync_header));
-                       ecc_generate(sector);
-               }
-#endif
-       }
-       return CHDERR_NONE;
-}
-
-/* cdzl */
-
-static chd_error cdzl_codec_init(void *codec, uint32_t hunkbytes)
-{
-       chd_error ret;
-       cdzl_codec_data* cdzl = (cdzl_codec_data*)codec;
-
-       /* make sure the CHD's hunk size is an even multiple of the frame size */
-       if (hunkbytes % CD_FRAME_SIZE != 0)
-               return CHDERR_CODEC_ERROR;
-
-       cdzl->buffer = (uint8_t*)malloc(sizeof(uint8_t) * hunkbytes);
-       if (cdzl->buffer == NULL)
-               return CHDERR_OUT_OF_MEMORY;
-
-       ret = zlib_codec_init(&cdzl->base_decompressor, (hunkbytes / CD_FRAME_SIZE) * CD_MAX_SECTOR_DATA);
-       if (ret != CHDERR_NONE)
-               return ret;
-
-#ifdef WANT_SUBCODE
-       ret = zlib_codec_init(&cdzl->subcode_decompressor, (hunkbytes / CD_FRAME_SIZE) * CD_MAX_SUBCODE_DATA);
-       if (ret != CHDERR_NONE)
-               return ret;
-#endif
-
-       return CHDERR_NONE;
-}
-
-static void cdzl_codec_free(void *codec)
-{
-       cdzl_codec_data* cdzl = (cdzl_codec_data*)codec;
-       zlib_codec_free(&cdzl->base_decompressor);
-#ifdef WANT_SUBCODE
-       zlib_codec_free(&cdzl->subcode_decompressor);
-#endif
-       free(cdzl->buffer);
-}
-
-static chd_error cdzl_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
-{
-       uint32_t framenum;
-       cdzl_codec_data* cdzl = (cdzl_codec_data*)codec;
-
-       /* determine header bytes */
-       uint32_t frames = destlen / CD_FRAME_SIZE;
-       uint32_t complen_bytes = (destlen < 65536) ? 2 : 3;
-       uint32_t ecc_bytes = (frames + 7) / 8;
-       uint32_t header_bytes = ecc_bytes + complen_bytes;
-
-       /* extract compressed length of base */
-       uint32_t complen_base = (src[ecc_bytes + 0] << 8) | src[ecc_bytes + 1];
-       if (complen_bytes > 2)
-               complen_base = (complen_base << 8) | src[ecc_bytes + 2];
-
-       /* reset and decode */
-       zlib_codec_decompress(&cdzl->base_decompressor, &src[header_bytes], complen_base, &cdzl->buffer[0], frames * CD_MAX_SECTOR_DATA);
-#ifdef WANT_SUBCODE
-       zlib_codec_decompress(&cdzl->subcode_decompressor, &src[header_bytes + complen_base], complen - complen_base - header_bytes, &cdzl->buffer[frames * CD_MAX_SECTOR_DATA], frames * CD_MAX_SUBCODE_DATA);
-#endif
-
-       /* reassemble the data */
-       for (framenum = 0; framenum < frames; framenum++)
-       {
-               uint8_t *sector;
-
-               memcpy(&dest[framenum * CD_FRAME_SIZE], &cdzl->buffer[framenum * CD_MAX_SECTOR_DATA], CD_MAX_SECTOR_DATA);
-#ifdef WANT_SUBCODE
-               memcpy(&dest[framenum * CD_FRAME_SIZE + CD_MAX_SECTOR_DATA], &cdzl->buffer[frames * CD_MAX_SECTOR_DATA + framenum * CD_MAX_SUBCODE_DATA], CD_MAX_SUBCODE_DATA);
-#endif
-
-#ifdef WANT_RAW_DATA_SECTOR
-               /* reconstitute the ECC data and sync header */
-               sector = (uint8_t *)&dest[framenum * CD_FRAME_SIZE];
-               if ((src[framenum / 8] & (1 << (framenum % 8))) != 0)
-               {
-                       memcpy(sector, s_cd_sync_header, sizeof(s_cd_sync_header));
-                       ecc_generate(sector);
-               }
-#endif
-       }
-       return CHDERR_NONE;
-}
-
-/***************************************************************************
- *  CD FLAC DECOMPRESSOR
- ***************************************************************************
- */
-
-/*------------------------------------------------------
- *  cdfl_codec_blocksize - return the optimal block size
- *------------------------------------------------------
- */
-
-static uint32_t cdfl_codec_blocksize(uint32_t bytes)
-{
-       /* determine FLAC block size, which must be 16-65535
-        * clamp to 2k since that's supposed to be the sweet spot */
-       uint32_t hunkbytes = bytes / 4;
-       while (hunkbytes > 2048)
-               hunkbytes /= 2;
-       return hunkbytes;
-}
-
-static chd_error cdfl_codec_init(void *codec, uint32_t hunkbytes)
-{
-#ifdef WANT_SUBCODE
-       chd_error ret;
-#endif
-       uint16_t native_endian = 0;
-       cdfl_codec_data *cdfl = (cdfl_codec_data*)codec;
-
-       /* make sure the CHD's hunk size is an even multiple of the frame size */
-       if (hunkbytes % CD_FRAME_SIZE != 0)
-               return CHDERR_CODEC_ERROR;
-
-       cdfl->buffer = (uint8_t*)malloc(sizeof(uint8_t) * hunkbytes);
-       if (cdfl->buffer == NULL)
-               return CHDERR_OUT_OF_MEMORY;
-
-       /* determine whether we want native or swapped samples */
-       *(uint8_t *)(&native_endian) = 1;
-       cdfl->swap_endian = (native_endian & 1);
-
-#ifdef WANT_SUBCODE
-       /* init zlib inflater */
-       ret = zlib_codec_init(&cdfl->subcode_decompressor, (hunkbytes / CD_FRAME_SIZE) * CD_MAX_SECTOR_DATA);
-       if (ret != CHDERR_NONE)
-               return ret;
-#endif
-
-       /* flac decoder init */
-       if (flac_decoder_init(&cdfl->decoder))
-               return CHDERR_OUT_OF_MEMORY;
-
-       return CHDERR_NONE;
-}
-
-static void cdfl_codec_free(void *codec)
-{
-       cdfl_codec_data *cdfl = (cdfl_codec_data*)codec;
-       flac_decoder_free(&cdfl->decoder);
-#ifdef WANT_SUBCODE
-       zlib_codec_free(&cdfl->subcode_decompressor);
-#endif
-       if (cdfl->buffer)
-               free(cdfl->buffer);
-}
-
-static chd_error cdfl_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
-{
-       uint32_t framenum;
-       uint8_t *buffer;
-#ifdef WANT_SUBCODE
-       uint32_t offset;
-       chd_error ret;
-#endif
-       cdfl_codec_data *cdfl = (cdfl_codec_data*)codec;
-
-       /* reset and decode */
-       uint32_t frames = destlen / CD_FRAME_SIZE;
-
-       if (!flac_decoder_reset(&cdfl->decoder, 44100, 2, cdfl_codec_blocksize(frames * CD_MAX_SECTOR_DATA), src, complen))
-               return CHDERR_DECOMPRESSION_ERROR;
-       buffer = &cdfl->buffer[0];
-       if (!flac_decoder_decode_interleaved(&cdfl->decoder, (int16_t *)(buffer), frames * CD_MAX_SECTOR_DATA/4, cdfl->swap_endian))
-               return CHDERR_DECOMPRESSION_ERROR;
-
-#ifdef WANT_SUBCODE
-       /* inflate the subcode data */
-       offset = flac_decoder_finish(&cdfl->decoder);
-       ret = zlib_codec_decompress(&cdfl->subcode_decompressor, src + offset, complen - offset, &cdfl->buffer[frames * CD_MAX_SECTOR_DATA], frames * CD_MAX_SUBCODE_DATA);
-       if (ret != CHDERR_NONE)
-               return ret;
-#else
-       flac_decoder_finish(&cdfl->decoder);
-#endif
-
-       /* reassemble the data */
-       for (framenum = 0; framenum < frames; framenum++)
-       {
-               memcpy(&dest[framenum * CD_FRAME_SIZE], &cdfl->buffer[framenum * CD_MAX_SECTOR_DATA], CD_MAX_SECTOR_DATA);
-#ifdef WANT_SUBCODE
-               memcpy(&dest[framenum * CD_FRAME_SIZE + CD_MAX_SECTOR_DATA], &cdfl->buffer[frames * CD_MAX_SECTOR_DATA + framenum * CD_MAX_SUBCODE_DATA], CD_MAX_SUBCODE_DATA);
-#endif
-       }
-
-       return CHDERR_NONE;
-}
-/***************************************************************************
-    CODEC INTERFACES
-***************************************************************************/
-
-static const codec_interface codec_interfaces[] =
-{
-       /* "none" or no compression */
-       {
-               CHDCOMPRESSION_NONE,
-               "none",
-               FALSE,
-               NULL,
-               NULL,
-               NULL,
-               NULL
-       },
-
-       /* standard zlib compression */
-       {
-               CHDCOMPRESSION_ZLIB,
-               "zlib",
-               FALSE,
-               zlib_codec_init,
-               zlib_codec_free,
-               zlib_codec_decompress,
-               NULL
-       },
-
-       /* zlib+ compression */
-       {
-               CHDCOMPRESSION_ZLIB_PLUS,
-               "zlib+",
-               FALSE,
-               zlib_codec_init,
-               zlib_codec_free,
-               zlib_codec_decompress,
-               NULL
-       },
-
-       /* V5 zlib compression */
-       {
-               CHD_CODEC_ZLIB,
-               "zlib (Deflate)",
-               FALSE,
-               zlib_codec_init,
-               zlib_codec_free,
-               zlib_codec_decompress,
-               NULL
-       },
-
-       /* V5 CD zlib compression */
-       {
-               CHD_CODEC_CD_ZLIB,
-               "cdzl (CD Deflate)",
-               FALSE,
-               cdzl_codec_init,
-               cdzl_codec_free,
-               cdzl_codec_decompress,
-               NULL
-       },
-
-       /* V5 CD lzma compression */
-       {
-               CHD_CODEC_CD_LZMA,
-               "cdlz (CD LZMA)",
-               FALSE,
-               cdlz_codec_init,
-               cdlz_codec_free,
-               cdlz_codec_decompress,
-               NULL
-       },
-
-       /* V5 CD flac compression */
-       {
-               CHD_CODEC_CD_FLAC,
-               "cdfl (CD FLAC)",
-               FALSE,
-               cdfl_codec_init,
-               cdfl_codec_free,
-               cdfl_codec_decompress,
-               NULL
-       },
-};
-
-/***************************************************************************
-    INLINE FUNCTIONS
-***************************************************************************/
-
-/*-------------------------------------------------
-    get_bigendian_uint64 - fetch a UINT64 from
-    the data stream in bigendian order
--------------------------------------------------*/
-
-static inline UINT64 get_bigendian_uint64(const UINT8 *base)
-{
-       return ((UINT64)base[0] << 56) | ((UINT64)base[1] << 48) | ((UINT64)base[2] << 40) | ((UINT64)base[3] << 32) |
-                       ((UINT64)base[4] << 24) | ((UINT64)base[5] << 16) | ((UINT64)base[6] << 8) | (UINT64)base[7];
-}
-
-/*-------------------------------------------------
-    put_bigendian_uint64 - write a UINT64 to
-    the data stream in bigendian order
--------------------------------------------------*/
-
-static inline void put_bigendian_uint64(UINT8 *base, UINT64 value)
-{
-       base[0] = value >> 56;
-       base[1] = value >> 48;
-       base[2] = value >> 40;
-       base[3] = value >> 32;
-       base[4] = value >> 24;
-       base[5] = value >> 16;
-       base[6] = value >> 8;
-       base[7] = value;
-}
-
-/*-------------------------------------------------
-    get_bigendian_uint48 - fetch a UINT48 from
-    the data stream in bigendian order
--------------------------------------------------*/
-
-static inline UINT64 get_bigendian_uint48(const UINT8 *base)
-{
-       return  ((UINT64)base[0] << 40) | ((UINT64)base[1] << 32) |
-                       ((UINT64)base[2] << 24) | ((UINT64)base[3] << 16) | ((UINT64)base[4] << 8) | (UINT64)base[5];
-}
-
-/*-------------------------------------------------
-    put_bigendian_uint48 - write a UINT48 to
-    the data stream in bigendian order
--------------------------------------------------*/
-
-static inline void put_bigendian_uint48(UINT8 *base, UINT64 value)
-{
-       value &= 0xffffffffffff;
-       base[0] = value >> 40;
-       base[1] = value >> 32;
-       base[2] = value >> 24;
-       base[3] = value >> 16;
-       base[4] = value >> 8;
-       base[5] = value;
-}
-/*-------------------------------------------------
-    get_bigendian_uint32 - fetch a UINT32 from
-    the data stream in bigendian order
--------------------------------------------------*/
-
-static inline UINT32 get_bigendian_uint32(const UINT8 *base)
-{
-       return (base[0] << 24) | (base[1] << 16) | (base[2] << 8) | base[3];
-}
-
-/*-------------------------------------------------
-    put_bigendian_uint32 - write a UINT32 to
-    the data stream in bigendian order
--------------------------------------------------*/
-
-static inline void put_bigendian_uint32(UINT8 *base, UINT32 value)
-{
-       base[0] = value >> 24;
-       base[1] = value >> 16;
-       base[2] = value >> 8;
-       base[3] = value;
-}
-
-/*-------------------------------------------------
-    put_bigendian_uint24 - write a UINT24 to
-    the data stream in bigendian order
--------------------------------------------------*/
-
-static inline void put_bigendian_uint24(UINT8 *base, UINT32 value)
-{
-       value &= 0xffffff;
-       base[0] = value >> 16;
-       base[1] = value >> 8;
-       base[2] = value;
-}
-
-/*-------------------------------------------------
-    get_bigendian_uint24 - fetch a UINT24 from
-    the data stream in bigendian order
--------------------------------------------------*/
-
-static inline UINT32 get_bigendian_uint24(const UINT8 *base)
-{
-       return (base[0] << 16) | (base[1] << 8) | base[2];
-}
-
-/*-------------------------------------------------
-    get_bigendian_uint16 - fetch a UINT16 from
-    the data stream in bigendian order
--------------------------------------------------*/
-
-static inline UINT16 get_bigendian_uint16(const UINT8 *base)
-{
-       return (base[0] << 8) | base[1];
-}
-
-/*-------------------------------------------------
-    put_bigendian_uint16 - write a UINT16 to
-    the data stream in bigendian order
--------------------------------------------------*/
-
-static inline void put_bigendian_uint16(UINT8 *base, UINT16 value)
-{
-       base[0] = value >> 8;
-       base[1] = value;
-}
-
-/*-------------------------------------------------
-    map_extract - extract a single map
-    entry from the datastream
--------------------------------------------------*/
-
-static inline void map_extract(const UINT8 *base, map_entry *entry)
-{
-       entry->offset = get_bigendian_uint64(&base[0]);
-       entry->crc = get_bigendian_uint32(&base[8]);
-       entry->length = get_bigendian_uint16(&base[12]) | (base[14] << 16);
-       entry->flags = base[15];
-}
-
-/*-------------------------------------------------
-    map_assemble - write a single map
-    entry to the datastream
--------------------------------------------------*/
-
-static inline void map_assemble(UINT8 *base, map_entry *entry)
-{
-       put_bigendian_uint64(&base[0], entry->offset);
-       put_bigendian_uint32(&base[8], entry->crc);
-       put_bigendian_uint16(&base[12], entry->length);
-       base[14] = entry->length >> 16;
-       base[15] = entry->flags;
-}
-
-/*-------------------------------------------------
-    map_size_v5 - calculate CHDv5 map size
--------------------------------------------------*/
-static inline int map_size_v5(chd_header* header)
-{
-       return header->hunkcount * header->mapentrybytes;
-}
-
-/*-------------------------------------------------
-    crc16 - calculate CRC16 (from hashing.cpp)
--------------------------------------------------*/
-uint16_t crc16(const void *data, uint32_t length)
-{
-       uint16_t crc = 0xffff;
-
-       static const uint16_t s_table[256] =
-       {
-               0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
-               0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
-               0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
-               0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
-               0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
-               0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
-               0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
-               0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
-               0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
-               0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
-               0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
-               0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
-               0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
-               0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
-               0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
-               0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
-               0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
-               0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
-               0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
-               0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
-               0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
-               0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
-               0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
-               0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
-               0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
-               0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
-               0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
-               0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
-               0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
-               0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
-               0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
-               0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
-       };
-
-       const uint8_t *src = (uint8_t*)data;
-
-       /* fetch the current value into a local and rip through the source data */
-       while (length-- != 0)
-               crc = (crc << 8) ^ s_table[(crc >> 8) ^ *src++];
-       return crc;
-}
-
-/*-------------------------------------------------
-       compressed - test if CHD file is compressed
-+-------------------------------------------------*/
-static inline int chd_compressed(chd_header* header) {
-       return header->compression[0] != CHD_CODEC_NONE;
-}
-
-/*-------------------------------------------------
-       decompress_v5_map - decompress the v5 map
--------------------------------------------------*/
-
-static chd_error decompress_v5_map(chd_file* chd, chd_header* header)
-{
-       int result = 0;
-       int hunknum;
-       int repcount = 0;
-       uint8_t lastcomp = 0;
-       uint32_t last_self = 0;
-       uint64_t last_parent = 0;
-       struct bitstream* bitbuf;
-       uint32_t mapbytes;
-       uint64_t firstoffs;
-       uint16_t mapcrc;
-       uint8_t lengthbits;
-       uint8_t selfbits;
-       uint8_t parentbits;
-       uint8_t *compressed_ptr;
-       uint8_t rawbuf[16];
-       struct huffman_decoder* decoder;
-       enum huffman_error err;
-       uint64_t curoffset;     
-       int rawmapsize = map_size_v5(header);
-
-       if (!chd_compressed(header))
-       {
-               header->rawmap = (uint8_t*)malloc(rawmapsize);
-               core_fseek(chd->file, header->mapoffset, SEEK_SET);
-               result = core_fread(chd->file, header->rawmap, rawmapsize);
-               return CHDERR_NONE;
-       }
-
-       /* read the reader */
-       core_fseek(chd->file, header->mapoffset, SEEK_SET);
-       result = core_fread(chd->file, rawbuf, sizeof(rawbuf));
-       mapbytes = get_bigendian_uint32(&rawbuf[0]);
-       firstoffs = get_bigendian_uint48(&rawbuf[4]);
-       mapcrc = get_bigendian_uint16(&rawbuf[10]);
-       lengthbits = rawbuf[12];
-       selfbits = rawbuf[13];
-       parentbits = rawbuf[14];
-
-       /* now read the map */
-       compressed_ptr = (uint8_t*)malloc(sizeof(uint8_t) * mapbytes);
-       core_fseek(chd->file, header->mapoffset + 16, SEEK_SET);
-       result = core_fread(chd->file, compressed_ptr, mapbytes);
-       bitbuf = create_bitstream(compressed_ptr, sizeof(uint8_t) * mapbytes);
-       header->rawmap = (uint8_t*)malloc(rawmapsize);
-
-       /* first decode the compression types */
-       decoder = create_huffman_decoder(16, 8);
-       if (decoder == NULL)
-       {
-               free(compressed_ptr);
-               free(bitbuf);
-               return CHDERR_OUT_OF_MEMORY;
-       }
-
-       err = huffman_import_tree_rle(decoder, bitbuf);
-       if (err != HUFFERR_NONE)
-       {
-               free(compressed_ptr);
-               free(bitbuf);
-               delete_huffman_decoder(decoder);
-               return CHDERR_DECOMPRESSION_ERROR;
-       }
-
-       for (hunknum = 0; hunknum < header->hunkcount; hunknum++)
-       {
-               uint8_t *rawmap = header->rawmap + (hunknum * 12);
-               if (repcount > 0)
-                       rawmap[0] = lastcomp, repcount--;
-               else
-               {
-                       uint8_t val = huffman_decode_one(decoder, bitbuf);
-                       if (val == COMPRESSION_RLE_SMALL)
-                               rawmap[0] = lastcomp, repcount = 2 + huffman_decode_one(decoder, bitbuf);
-                       else if (val == COMPRESSION_RLE_LARGE)
-                               rawmap[0] = lastcomp, repcount = 2 + 16 + (huffman_decode_one(decoder, bitbuf) << 4), repcount += huffman_decode_one(decoder, bitbuf);
-                       else
-                               rawmap[0] = lastcomp = val;
-               }
-       }
-
-       /* then iterate through the hunks and extract the needed data */
-       curoffset = firstoffs;
-       for (hunknum = 0; hunknum < header->hunkcount; hunknum++)
-       {
-               uint8_t *rawmap = header->rawmap + (hunknum * 12);
-               uint64_t offset = curoffset;
-               uint32_t length = 0;
-               uint16_t crc = 0;
-               switch (rawmap[0])
-               {
-                       /* base types */
-                       case COMPRESSION_TYPE_0:
-                       case COMPRESSION_TYPE_1:
-                       case COMPRESSION_TYPE_2:
-                       case COMPRESSION_TYPE_3:
-                               curoffset += length = bitstream_read(bitbuf, lengthbits);
-                               crc = bitstream_read(bitbuf, 16);
-                               break;
-
-                       case COMPRESSION_NONE:
-                               curoffset += length = header->hunkbytes;
-                               crc = bitstream_read(bitbuf, 16);
-                               break;
-
-                       case COMPRESSION_SELF:
-                               last_self = offset = bitstream_read(bitbuf, selfbits);
-                               break;
-
-                       case COMPRESSION_PARENT:
-                               offset = bitstream_read(bitbuf, parentbits);
-                               last_parent = offset;
-                               break;
-
-                       /* pseudo-types; convert into base types */
-                       case COMPRESSION_SELF_1:
-                               last_self++;
-                       case COMPRESSION_SELF_0:
-                               rawmap[0] = COMPRESSION_SELF;
-                               offset = last_self;
-                               break;
-
-                       case COMPRESSION_PARENT_SELF:
-                               rawmap[0] = COMPRESSION_PARENT;
-                               last_parent = offset = ( ((uint64_t)hunknum) * ((uint64_t)header->hunkbytes) ) / header->unitbytes;
-                               break;
-
-                       case COMPRESSION_PARENT_1:
-                               last_parent += header->hunkbytes / header->unitbytes;
-                       case COMPRESSION_PARENT_0:
-                               rawmap[0] = COMPRESSION_PARENT;
-                               offset = last_parent;
-                               break;
-               }
-               /* UINT24 length */
-               put_bigendian_uint24(&rawmap[1], length);
-
-               /* UINT48 offset */
-               put_bigendian_uint48(&rawmap[4], offset);
-
-               /* crc16 */
-               put_bigendian_uint16(&rawmap[10], crc);
-       }
-
-       /* free memory */
-       free(compressed_ptr);
-       free(bitbuf);
-       delete_huffman_decoder(decoder);
-
-       /* verify the final CRC */
-       if (crc16(&header->rawmap[0], header->hunkcount * 12) != mapcrc)
-               return CHDERR_DECOMPRESSION_ERROR;
-
-       return CHDERR_NONE;
-}
-
-/*-------------------------------------------------
-    map_extract_old - extract a single map
-    entry in old format from the datastream
--------------------------------------------------*/
-
-static inline void map_extract_old(const UINT8 *base, map_entry *entry, UINT32 hunkbytes)
-{
-       entry->offset = get_bigendian_uint64(&base[0]);
-       entry->crc = 0;
-       entry->length = entry->offset >> 44;
-       entry->flags = MAP_ENTRY_FLAG_NO_CRC | ((entry->length == hunkbytes) ? V34_MAP_ENTRY_TYPE_UNCOMPRESSED : V34_MAP_ENTRY_TYPE_COMPRESSED);
-#ifdef __MWERKS__
-       entry->offset = entry->offset & 0x00000FFFFFFFFFFFLL;
-#else
-       entry->offset = (entry->offset << 20) >> 20;
-#endif
-}
-
-/***************************************************************************
-    CHD FILE MANAGEMENT
-***************************************************************************/
-
-/*-------------------------------------------------
-    chd_open_file - open a CHD file for access
--------------------------------------------------*/
-
-CHD_EXPORT chd_error chd_open_file(core_file *file, int mode, chd_file *parent, chd_file **chd)
-{
-       chd_file *newchd = NULL;
-       chd_error err;
-       int intfnum;
-
-       /* verify parameters */
-       if (file == NULL)
-               EARLY_EXIT(err = CHDERR_INVALID_PARAMETER);
-
-       /* punt if invalid parent */
-       if (parent != NULL && parent->cookie != COOKIE_VALUE)
-               EARLY_EXIT(err = CHDERR_INVALID_PARAMETER);
-
-       /* allocate memory for the final result */
-       newchd = (chd_file *)malloc(sizeof(**chd));
-       if (newchd == NULL)
-               EARLY_EXIT(err = CHDERR_OUT_OF_MEMORY);
-       memset(newchd, 0, sizeof(*newchd));
-       newchd->cookie = COOKIE_VALUE;
-       newchd->parent = parent;
-       newchd->file = file;
-
-       /* now attempt to read the header */
-       err = header_read(newchd, &newchd->header);
-       if (err != CHDERR_NONE)
-               EARLY_EXIT(err);
-
-       /* validate the header */
-       err = header_validate(&newchd->header);
-       if (err != CHDERR_NONE)
-               EARLY_EXIT(err);
-
-       /* make sure we don't open a read-only file writeable */
-       if (mode == CHD_OPEN_READWRITE && !(newchd->header.flags & CHDFLAGS_IS_WRITEABLE))
-               EARLY_EXIT(err = CHDERR_FILE_NOT_WRITEABLE);
-
-       /* also, never open an older version writeable */
-       if (mode == CHD_OPEN_READWRITE && newchd->header.version < CHD_HEADER_VERSION)
-               EARLY_EXIT(err = CHDERR_UNSUPPORTED_VERSION);
-
-       /* if we need a parent, make sure we have one */
-       if (parent == NULL && (newchd->header.flags & CHDFLAGS_HAS_PARENT))
-               EARLY_EXIT(err = CHDERR_REQUIRES_PARENT);
-
-       /* make sure we have a valid parent */
-       if (parent != NULL)
-       {
-               /* check MD5 if it isn't empty */
-               if (memcmp(nullmd5, newchd->header.parentmd5, sizeof(newchd->header.parentmd5)) != 0 &&
-                       memcmp(nullmd5, newchd->parent->header.md5, sizeof(newchd->parent->header.md5)) != 0 &&
-                       memcmp(newchd->parent->header.md5, newchd->header.parentmd5, sizeof(newchd->header.parentmd5)) != 0)
-                       EARLY_EXIT(err = CHDERR_INVALID_PARENT);
-
-               /* check SHA1 if it isn't empty */
-               if (memcmp(nullsha1, newchd->header.parentsha1, sizeof(newchd->header.parentsha1)) != 0 &&
-                       memcmp(nullsha1, newchd->parent->header.sha1, sizeof(newchd->parent->header.sha1)) != 0 &&
-                       memcmp(newchd->parent->header.sha1, newchd->header.parentsha1, sizeof(newchd->header.parentsha1)) != 0)
-                       EARLY_EXIT(err = CHDERR_INVALID_PARENT);
-       }
-
-       /* now read the hunk map */
-       if (newchd->header.version < 5)
-       {
-               err = map_read(newchd);
-               if (err != CHDERR_NONE)
-                       EARLY_EXIT(err);
-       }
-       else
-       {
-               err = decompress_v5_map(newchd, &(newchd->header));
-       }
-       if (err != CHDERR_NONE)
-               EARLY_EXIT(err);
-
-#ifdef NEED_CACHE_HUNK
-       /* allocate and init the hunk cache */
-       newchd->cache = (UINT8 *)malloc(newchd->header.hunkbytes);
-       newchd->compare = (UINT8 *)malloc(newchd->header.hunkbytes);
-       if (newchd->cache == NULL || newchd->compare == NULL)
-               EARLY_EXIT(err = CHDERR_OUT_OF_MEMORY);
-       newchd->cachehunk = ~0;
-       newchd->comparehunk = ~0;
-#endif
-
-       /* allocate the temporary compressed buffer */
-       newchd->compressed = (UINT8 *)malloc(newchd->header.hunkbytes);
-       if (newchd->compressed == NULL)
-               EARLY_EXIT(err = CHDERR_OUT_OF_MEMORY);
-
-       /* find the codec interface */
-       if (newchd->header.version < 5)
-       {
-               for (intfnum = 0; intfnum < ARRAY_LENGTH(codec_interfaces); intfnum++)
-               {
-                       if (codec_interfaces[intfnum].compression == newchd->header.compression[0])
-                       {
-                               newchd->codecintf[0] = &codec_interfaces[intfnum];
-                               break;
-                       }
-               }
-
-               if (intfnum == ARRAY_LENGTH(codec_interfaces))
-                       EARLY_EXIT(err = CHDERR_UNSUPPORTED_FORMAT);
-
-               /* initialize the codec */
-               if (newchd->codecintf[0]->init != NULL)
-               {
-                       err = (*newchd->codecintf[0]->init)(&newchd->zlib_codec_data, newchd->header.hunkbytes);
-                       if (err != CHDERR_NONE)
-                               EARLY_EXIT(err);
-               }
-       }
-       else
-       {
-               int decompnum;
-               /* verify the compression types and initialize the codecs */
-               for (decompnum = 0; decompnum < ARRAY_LENGTH(newchd->header.compression); decompnum++)
-               {
-                       int i;
-                       for (i = 0 ; i < ARRAY_LENGTH(codec_interfaces) ; i++)
-                       {
-                               if (codec_interfaces[i].compression == newchd->header.compression[decompnum])
-                               {
-                                       newchd->codecintf[decompnum] = &codec_interfaces[i];
-                                       break;
-                               }
-                       }
-
-                       if (newchd->codecintf[decompnum] == NULL && newchd->header.compression[decompnum] != 0)
-                               EARLY_EXIT(err = CHDERR_UNSUPPORTED_FORMAT);
-
-                       /* initialize the codec */
-                       if (newchd->codecintf[decompnum]->init != NULL)
-                       {
-                               void* codec = NULL;
-                               switch (newchd->header.compression[decompnum])
-                               {
-                                       case CHD_CODEC_ZLIB:
-                                               codec = &newchd->zlib_codec_data;
-                                               break;
-
-                                       case CHD_CODEC_CD_ZLIB:
-                                               codec = &newchd->cdzl_codec_data;
-                                               break;
-
-                                       case CHD_CODEC_CD_LZMA:
-                                               codec = &newchd->cdlz_codec_data;
-                                               break;
-
-                                       case CHD_CODEC_CD_FLAC:
-                                               codec = &newchd->cdfl_codec_data;
-                                               break;
-                               }
-
-                               if (codec == NULL)
-                                       EARLY_EXIT(err = CHDERR_UNSUPPORTED_FORMAT);
-
-                               err = (*newchd->codecintf[decompnum]->init)(codec, newchd->header.hunkbytes);
-                               if (err != CHDERR_NONE)
-                                       EARLY_EXIT(err);
-                       }
-               }
-       }
-
-       /* all done */
-       *chd = newchd;
-       return CHDERR_NONE;
-
-cleanup:
-       if (newchd != NULL)
-               chd_close(newchd);
-       return err;
-}
-
-/*-------------------------------------------------
-    chd_precache - precache underlying file in
-    memory
--------------------------------------------------*/
-
-CHD_EXPORT chd_error chd_precache(chd_file *chd)
-{
-#ifdef _MSC_VER
-       size_t size, count;
-#else
-       ssize_t size, count;
-#endif
-
-       if (chd->file_cache == NULL)
-       {
-               core_fseek(chd->file, 0, SEEK_END);
-               size = core_ftell(chd->file);
-               if (size <= 0)
-                       return CHDERR_INVALID_DATA;
-               chd->file_cache = malloc(size);
-               if (chd->file_cache == NULL)
-                       return CHDERR_OUT_OF_MEMORY;
-               core_fseek(chd->file, 0, SEEK_SET);
-               count = core_fread(chd->file, chd->file_cache, size);
-               if (count != size)
-               {
-                       free(chd->file_cache);
-                       chd->file_cache = NULL;
-                       return CHDERR_READ_ERROR;
-               }
-       }
-
-       return CHDERR_NONE;
-}
-
-/*-------------------------------------------------
-    chd_open - open a CHD file by
-    filename
--------------------------------------------------*/
-
-CHD_EXPORT chd_error chd_open(const char *filename, int mode, chd_file *parent, chd_file **chd)
-{
-       chd_error err;
-       core_file *file = NULL;
-
-       /* choose the proper mode */
-       switch(mode)
-       {
-               case CHD_OPEN_READ:
-                       break;
-
-               default:
-                       err = CHDERR_INVALID_PARAMETER;
-                       goto cleanup;
-       }
-
-       /* open the file */
-       file = core_fopen(filename);
-       if (file == 0)
-       {
-               err = CHDERR_FILE_NOT_FOUND;
-               goto cleanup;
-       }
-
-       /* now open the CHD */
-       err = chd_open_file(file, mode, parent, chd);
-       if (err != CHDERR_NONE)
-               goto cleanup;
-
-       /* we now own this file */
-       (*chd)->owns_file = TRUE;
-
-cleanup:
-       if ((err != CHDERR_NONE) && (file != NULL))
-               core_fclose(file);
-       return err;
-}
-
-/*-------------------------------------------------
-    chd_close - close a CHD file for access
--------------------------------------------------*/
-
-CHD_EXPORT void chd_close(chd_file *chd)
-{
-       /* punt if NULL or invalid */
-       if (chd == NULL || chd->cookie != COOKIE_VALUE)
-               return;
-
-       /* deinit the codec */
-       if (chd->header.version < 5)
-       {
-               if (chd->codecintf[0] != NULL && chd->codecintf[0]->free != NULL)
-                       (*chd->codecintf[0]->free)(&chd->zlib_codec_data);
-       }
-       else
-       {
-               int i;
-               /* Free the codecs */
-               for (i = 0 ; i < ARRAY_LENGTH(chd->codecintf); i++)
-               {
-                       void* codec = NULL;
-
-                       if (chd->codecintf[i] == NULL)
-                               continue;
-
-                       switch (chd->codecintf[i]->compression)
-                       {
-                               case CHD_CODEC_CD_LZMA:
-                                       codec = &chd->cdlz_codec_data;
-                                       break;
-
-                               case CHD_CODEC_ZLIB:
-                                       codec = &chd->zlib_codec_data;
-                                       break;
-
-                               case CHD_CODEC_CD_ZLIB:
-                                       codec = &chd->cdzl_codec_data;
-                                       break;
-
-                               case CHD_CODEC_CD_FLAC:
-                                       codec = &chd->cdfl_codec_data;
-                                       break;
-                       }
-
-                       if (codec)
-                       {
-                               (*chd->codecintf[i]->free)(codec);
-                       }
-               }
-
-               /* Free the raw map */
-               if (chd->header.rawmap != NULL)
-                       free(chd->header.rawmap);
-       }
-
-       /* free the compressed data buffer */
-       if (chd->compressed != NULL)
-               free(chd->compressed);
-
-#ifdef NEED_CACHE_HUNK
-       /* free the hunk cache and compare data */
-       if (chd->compare != NULL)
-               free(chd->compare);
-       if (chd->cache != NULL)
-               free(chd->cache);
-#endif
-
-       /* free the hunk map */
-       if (chd->map != NULL)
-               free(chd->map);
-
-       /* close the file */
-       if (chd->owns_file && chd->file != NULL)
-               core_fclose(chd->file);
-
-#ifdef NEED_CACHE_HUNK
-       if (PRINTF_MAX_HUNK) printf("Max hunk = %d/%d\n", chd->maxhunk, chd->header.totalhunks);
-#endif
-       if (chd->file_cache)
-               free(chd->file_cache);
-
-       /* free our memory */
-       free(chd);
-}
-
-/*-------------------------------------------------
-    chd_core_file - return the associated
-    core_file
--------------------------------------------------*/
-
-CHD_EXPORT core_file *chd_core_file(chd_file *chd)
-{
-       return chd->file;
-}
-
-/*-------------------------------------------------
-    chd_error_string - return an error string for
-    the given CHD error
--------------------------------------------------*/
-
-CHD_EXPORT const char *chd_error_string(chd_error err)
-{
-       switch (err)
-       {
-               case CHDERR_NONE:                                               return "no error";
-               case CHDERR_NO_INTERFACE:                               return "no drive interface";
-               case CHDERR_OUT_OF_MEMORY:                              return "out of memory";
-               case CHDERR_INVALID_FILE:                               return "invalid file";
-               case CHDERR_INVALID_PARAMETER:                  return "invalid parameter";
-               case CHDERR_INVALID_DATA:                               return "invalid data";
-               case CHDERR_FILE_NOT_FOUND:                             return "file not found";
-               case CHDERR_REQUIRES_PARENT:                    return "requires parent";
-               case CHDERR_FILE_NOT_WRITEABLE:                 return "file not writeable";
-               case CHDERR_READ_ERROR:                                 return "read error";
-               case CHDERR_WRITE_ERROR:                                return "write error";
-               case CHDERR_CODEC_ERROR:                                return "codec error";
-               case CHDERR_INVALID_PARENT:                             return "invalid parent";
-               case CHDERR_HUNK_OUT_OF_RANGE:                  return "hunk out of range";
-               case CHDERR_DECOMPRESSION_ERROR:                return "decompression error";
-               case CHDERR_COMPRESSION_ERROR:                  return "compression error";
-               case CHDERR_CANT_CREATE_FILE:                   return "can't create file";
-               case CHDERR_CANT_VERIFY:                                return "can't verify file";
-               case CHDERR_NOT_SUPPORTED:                              return "operation not supported";
-               case CHDERR_METADATA_NOT_FOUND:                 return "can't find metadata";
-               case CHDERR_INVALID_METADATA_SIZE:              return "invalid metadata size";
-               case CHDERR_UNSUPPORTED_VERSION:                return "unsupported CHD version";
-               case CHDERR_VERIFY_INCOMPLETE:                  return "incomplete verify";
-               case CHDERR_INVALID_METADATA:                   return "invalid metadata";
-               case CHDERR_INVALID_STATE:                              return "invalid state";
-               case CHDERR_OPERATION_PENDING:                  return "operation pending";
-               case CHDERR_NO_ASYNC_OPERATION:                 return "no async operation in progress";
-               case CHDERR_UNSUPPORTED_FORMAT:                 return "unsupported format";
-               default:                                                                return "undocumented error";
-       }
-}
-
-/***************************************************************************
-    CHD HEADER MANAGEMENT
-***************************************************************************/
-
-/*-------------------------------------------------
-    chd_get_header - return a pointer to the
-    extracted header data
--------------------------------------------------*/
-
-CHD_EXPORT const chd_header *chd_get_header(chd_file *chd)
-{
-       /* punt if NULL or invalid */
-       if (chd == NULL || chd->cookie != COOKIE_VALUE)
-               return NULL;
-
-       return &chd->header;
-}
-
-/***************************************************************************
-    CORE DATA READ/WRITE
-***************************************************************************/
-
-/*-------------------------------------------------
-    chd_read - read a single hunk from the CHD
-    file
--------------------------------------------------*/
-
-CHD_EXPORT chd_error chd_read(chd_file *chd, UINT32 hunknum, void *buffer)
-{
-       /* punt if NULL or invalid */
-       if (chd == NULL || chd->cookie != COOKIE_VALUE)
-               return CHDERR_INVALID_PARAMETER;
-
-       /* if we're past the end, fail */
-       if (hunknum >= chd->header.totalhunks)
-               return CHDERR_HUNK_OUT_OF_RANGE;
-
-       /* perform the read */
-       return hunk_read_into_memory(chd, hunknum, (UINT8 *)buffer);
-}
-
-/***************************************************************************
-    METADATA MANAGEMENT
-***************************************************************************/
-
-/*-------------------------------------------------
-    chd_get_metadata - get the indexed metadata
-    of the given type
--------------------------------------------------*/
-
-CHD_EXPORT chd_error chd_get_metadata(chd_file *chd, UINT32 searchtag, UINT32 searchindex, void *output, UINT32 outputlen, UINT32 *resultlen, UINT32 *resulttag, UINT8 *resultflags)
-{
-       metadata_entry metaentry;
-       chd_error err;
-       UINT32 count;
-
-       /* if we didn't find it, just return */
-       err = metadata_find_entry(chd, searchtag, searchindex, &metaentry);
-       if (err != CHDERR_NONE)
-       {
-               /* unless we're an old version and they are requesting hard disk metadata */
-               if (chd->header.version < 3 && (searchtag == HARD_DISK_METADATA_TAG || searchtag == CHDMETATAG_WILDCARD) && searchindex == 0)
-               {
-                       char faux_metadata[256];
-                       UINT32 faux_length;
-
-                       /* fill in the faux metadata */
-                       sprintf(faux_metadata, HARD_DISK_METADATA_FORMAT, chd->header.obsolete_cylinders, chd->header.obsolete_heads, chd->header.obsolete_sectors, chd->header.hunkbytes / chd->header.obsolete_hunksize);
-                       faux_length = (UINT32)strlen(faux_metadata) + 1;
-
-                       /* copy the metadata itself */
-                       memcpy(output, faux_metadata, MIN(outputlen, faux_length));
-
-                       /* return the length of the data and the tag */
-                       if (resultlen != NULL)
-                               *resultlen = faux_length;
-                       if (resulttag != NULL)
-                               *resulttag = HARD_DISK_METADATA_TAG;
-                       return CHDERR_NONE;
-               }
-               return err;
-       }
-
-       /* read the metadata */
-       outputlen = MIN(outputlen, metaentry.length);
-       core_fseek(chd->file, metaentry.offset + METADATA_HEADER_SIZE, SEEK_SET);
-       count = core_fread(chd->file, output, outputlen);
-       if (count != outputlen)
-               return CHDERR_READ_ERROR;
-
-       /* return the length of the data and the tag */
-       if (resultlen != NULL)
-               *resultlen = metaentry.length;
-       if (resulttag != NULL)
-               *resulttag = metaentry.metatag;
-       if (resultflags != NULL)
-               *resultflags = metaentry.flags;
-       return CHDERR_NONE;
-}
-
-/***************************************************************************
-    CODEC INTERFACES
-***************************************************************************/
-
-/*-------------------------------------------------
-    chd_codec_config - set internal codec
-    parameters
--------------------------------------------------*/
-
-CHD_EXPORT chd_error chd_codec_config(chd_file *chd, int param, void *config)
-{
-       return CHDERR_INVALID_PARAMETER;
-}
-
-/*-------------------------------------------------
-    chd_get_codec_name - get the name of a
-    particular codec
--------------------------------------------------*/
-
-CHD_EXPORT const char *chd_get_codec_name(UINT32 codec)
-{
-       return "Unknown";
-}
-
-/***************************************************************************
-    INTERNAL HEADER OPERATIONS
-***************************************************************************/
-
-/*-------------------------------------------------
-    header_validate - check the validity of a
-    CHD header
--------------------------------------------------*/
-
-static chd_error header_validate(const chd_header *header)
-{
-       int intfnum;
-
-       /* require a valid version */
-       if (header->version == 0 || header->version > CHD_HEADER_VERSION)
-               return CHDERR_UNSUPPORTED_VERSION;
-
-       /* require a valid length */
-       if ((header->version == 1 && header->length != CHD_V1_HEADER_SIZE) ||
-               (header->version == 2 && header->length != CHD_V2_HEADER_SIZE) ||
-               (header->version == 3 && header->length != CHD_V3_HEADER_SIZE) ||
-               (header->version == 4 && header->length != CHD_V4_HEADER_SIZE) ||
-               (header->version == 5 && header->length != CHD_V5_HEADER_SIZE))
-               return CHDERR_INVALID_PARAMETER;
-
-       /* Do not validate v5 header */
-       if (header->version <= 4)
-       {
-               /* require valid flags */
-               if (header->flags & CHDFLAGS_UNDEFINED)
-                       return CHDERR_INVALID_PARAMETER;
-
-               /* require a supported compression mechanism */
-               for (intfnum = 0; intfnum < ARRAY_LENGTH(codec_interfaces); intfnum++)
-                       if (codec_interfaces[intfnum].compression == header->compression[0])
-                               break;
-
-               if (intfnum == ARRAY_LENGTH(codec_interfaces))
-                       return CHDERR_INVALID_PARAMETER;
-
-               /* require a valid hunksize */
-               if (header->hunkbytes == 0 || header->hunkbytes >= 65536 * 256)
-                       return CHDERR_INVALID_PARAMETER;
-
-               /* require a valid hunk count */
-               if (header->totalhunks == 0)
-                       return CHDERR_INVALID_PARAMETER;
-
-               /* require a valid MD5 and/or SHA1 if we're using a parent */
-               if ((header->flags & CHDFLAGS_HAS_PARENT) && memcmp(header->parentmd5, nullmd5, sizeof(nullmd5)) == 0 && memcmp(header->parentsha1, nullsha1, sizeof(nullsha1)) == 0)
-                       return CHDERR_INVALID_PARAMETER;
-
-               /* if we're V3 or later, the obsolete fields must be 0 */
-               if (header->version >= 3 &&
-                       (header->obsolete_cylinders != 0 || header->obsolete_sectors != 0 ||
-                        header->obsolete_heads != 0 || header->obsolete_hunksize != 0))
-                       return CHDERR_INVALID_PARAMETER;
-
-               /* if we're pre-V3, the obsolete fields must NOT be 0 */
-               if (header->version < 3 &&
-                       (header->obsolete_cylinders == 0 || header->obsolete_sectors == 0 ||
-                        header->obsolete_heads == 0 || header->obsolete_hunksize == 0))
-                       return CHDERR_INVALID_PARAMETER;
-       }
-
-       return CHDERR_NONE;
-}
-
-/*-------------------------------------------------
-    header_guess_unitbytes - for older CHD formats,
-    guess at the bytes/unit based on metadata
--------------------------------------------------*/
-
-static UINT32 header_guess_unitbytes(chd_file *chd)
-{
-       /* look for hard disk metadata; if found, then the unit size == sector size */
-       char metadata[512];
-       int i0, i1, i2, i3;
-       if (chd_get_metadata(chd, HARD_DISK_METADATA_TAG, 0, metadata, sizeof(metadata), NULL, NULL, NULL) == CHDERR_NONE &&
-               sscanf(metadata, HARD_DISK_METADATA_FORMAT, &i0, &i1, &i2, &i3) == 4)
-               return i3;
-
-       /* look for CD-ROM metadata; if found, then the unit size == CD frame size */
-       if (chd_get_metadata(chd, CDROM_OLD_METADATA_TAG, 0, metadata, sizeof(metadata), NULL, NULL, NULL) == CHDERR_NONE ||
-               chd_get_metadata(chd, CDROM_TRACK_METADATA_TAG, 0, metadata, sizeof(metadata), NULL, NULL, NULL) == CHDERR_NONE ||
-               chd_get_metadata(chd, CDROM_TRACK_METADATA2_TAG, 0, metadata, sizeof(metadata), NULL, NULL, NULL) == CHDERR_NONE ||
-               chd_get_metadata(chd, GDROM_OLD_METADATA_TAG, 0, metadata, sizeof(metadata), NULL, NULL, NULL) == CHDERR_NONE ||
-               chd_get_metadata(chd, GDROM_TRACK_METADATA_TAG, 0, metadata, sizeof(metadata), NULL, NULL, NULL) == CHDERR_NONE)
-               return CD_FRAME_SIZE;
-
-       /* otherwise, just map 1:1 with the hunk size */
-       return chd->header.hunkbytes;
-}
-
-/*-------------------------------------------------
-    header_read - read a CHD header into the
-    internal data structure
--------------------------------------------------*/
-
-static chd_error header_read(chd_file *chd, chd_header *header)
-{
-       UINT8 rawheader[CHD_MAX_HEADER_SIZE];
-       UINT32 count;
-
-       /* punt if NULL */
-       if (header == NULL)
-               return CHDERR_INVALID_PARAMETER;
-
-       /* punt if invalid file */
-       if (chd->file == NULL)
-               return CHDERR_INVALID_FILE;
-
-       /* seek and read */
-       core_fseek(chd->file, 0, SEEK_SET);
-       count = core_fread(chd->file, rawheader, sizeof(rawheader));
-       if (count != sizeof(rawheader))
-               return CHDERR_READ_ERROR;
-
-       /* verify the tag */
-       if (strncmp((char *)rawheader, "MComprHD", 8) != 0)
-               return CHDERR_INVALID_DATA;
-
-       /* extract the direct data */
-       memset(header, 0, sizeof(*header));
-       header->length        = get_bigendian_uint32(&rawheader[8]);
-       header->version       = get_bigendian_uint32(&rawheader[12]);
-
-       /* make sure it's a version we understand */
-       if (header->version == 0 || header->version > CHD_HEADER_VERSION)
-               return CHDERR_UNSUPPORTED_VERSION;
-
-       /* make sure the length is expected */
-       if ((header->version == 1 && header->length != CHD_V1_HEADER_SIZE) ||
-               (header->version == 2 && header->length != CHD_V2_HEADER_SIZE) ||
-               (header->version == 3 && header->length != CHD_V3_HEADER_SIZE) ||
-               (header->version == 4 && header->length != CHD_V4_HEADER_SIZE) ||
-               (header->version == 5 && header->length != CHD_V5_HEADER_SIZE))
-
-               return CHDERR_INVALID_DATA;
-
-       /* extract the common data */
-       header->flags           = get_bigendian_uint32(&rawheader[16]);
-       header->compression[0]  = get_bigendian_uint32(&rawheader[20]);
-       header->compression[1]  = CHD_CODEC_NONE;
-       header->compression[2]  = CHD_CODEC_NONE;
-       header->compression[3]  = CHD_CODEC_NONE;
-
-       /* extract the V1/V2-specific data */
-       if (header->version < 3)
-       {
-               int seclen = (header->version == 1) ? CHD_V1_SECTOR_SIZE : get_bigendian_uint32(&rawheader[76]);
-               header->obsolete_hunksize  = get_bigendian_uint32(&rawheader[24]);
-               header->totalhunks         = get_bigendian_uint32(&rawheader[28]);
-               header->obsolete_cylinders = get_bigendian_uint32(&rawheader[32]);
-               header->obsolete_heads     = get_bigendian_uint32(&rawheader[36]);
-               header->obsolete_sectors   = get_bigendian_uint32(&rawheader[40]);
-               memcpy(header->md5, &rawheader[44], CHD_MD5_BYTES);
-               memcpy(header->parentmd5, &rawheader[60], CHD_MD5_BYTES);
-               header->logicalbytes = (UINT64)header->obsolete_cylinders * (UINT64)header->obsolete_heads * (UINT64)header->obsolete_sectors * (UINT64)seclen;
-               header->hunkbytes = seclen * header->obsolete_hunksize;
-               header->unitbytes          = header_guess_unitbytes(chd);
-               header->unitcount          = (header->logicalbytes + header->unitbytes - 1) / header->unitbytes;
-               header->metaoffset = 0;
-       }
-
-       /* extract the V3-specific data */
-       else if (header->version == 3)
-       {
-               header->totalhunks   = get_bigendian_uint32(&rawheader[24]);
-               header->logicalbytes = get_bigendian_uint64(&rawheader[28]);
-               header->metaoffset   = get_bigendian_uint64(&rawheader[36]);
-               memcpy(header->md5, &rawheader[44], CHD_MD5_BYTES);
-               memcpy(header->parentmd5, &rawheader[60], CHD_MD5_BYTES);
-               header->hunkbytes    = get_bigendian_uint32(&rawheader[76]);
-               header->unitbytes    = header_guess_unitbytes(chd);
-               header->unitcount    = (header->logicalbytes + header->unitbytes - 1) / header->unitbytes;
-               memcpy(header->sha1, &rawheader[80], CHD_SHA1_BYTES);
-               memcpy(header->parentsha1, &rawheader[100], CHD_SHA1_BYTES);
-       }
-
-       /* extract the V4-specific data */
-       else if (header->version == 4)
-       {
-               header->totalhunks   = get_bigendian_uint32(&rawheader[24]);
-               header->logicalbytes = get_bigendian_uint64(&rawheader[28]);
-               header->metaoffset   = get_bigendian_uint64(&rawheader[36]);
-               header->hunkbytes    = get_bigendian_uint32(&rawheader[44]);
-               header->unitbytes    = header_guess_unitbytes(chd);
-               header->unitcount    = (header->logicalbytes + header->unitbytes - 1) / header->unitbytes;
-               memcpy(header->sha1, &rawheader[48], CHD_SHA1_BYTES);
-               memcpy(header->parentsha1, &rawheader[68], CHD_SHA1_BYTES);
-               memcpy(header->rawsha1, &rawheader[88], CHD_SHA1_BYTES);
-       }
-
-       /* extract the V5-specific data */
-       else if (header->version == 5)
-       {
-               /* TODO */
-               header->compression[0]  = get_bigendian_uint32(&rawheader[16]);
-               header->compression[1]  = get_bigendian_uint32(&rawheader[20]);
-               header->compression[2]  = get_bigendian_uint32(&rawheader[24]);
-               header->compression[3]  = get_bigendian_uint32(&rawheader[28]);
-               header->logicalbytes    = get_bigendian_uint64(&rawheader[32]);
-               header->mapoffset       = get_bigendian_uint64(&rawheader[40]);
-               header->metaoffset      = get_bigendian_uint64(&rawheader[48]);
-               header->hunkbytes       = get_bigendian_uint32(&rawheader[56]);
-               header->hunkcount       = (header->logicalbytes + header->hunkbytes - 1) / header->hunkbytes;
-               header->unitbytes       = get_bigendian_uint32(&rawheader[60]);
-               header->unitcount       = (header->logicalbytes + header->unitbytes - 1) / header->unitbytes;
-               memcpy(header->sha1, &rawheader[84], CHD_SHA1_BYTES);
-               memcpy(header->parentsha1, &rawheader[104], CHD_SHA1_BYTES);
-               memcpy(header->rawsha1, &rawheader[64], CHD_SHA1_BYTES);
-
-               /* determine properties of map entries */
-               header->mapentrybytes = chd_compressed(header) ? 12 : 4;
-
-               /* hack */
-               header->totalhunks              = header->hunkcount;
-       }
-
-       /* Unknown version */
-       else
-       {
-               /* TODO */
-       }
-
-       /* guess it worked */
-       return CHDERR_NONE;
-}
-
-/***************************************************************************
-    INTERNAL HUNK READ/WRITE
-***************************************************************************/
-
-/*-------------------------------------------------
-    hunk_read_compressed - read a compressed
-    hunk
--------------------------------------------------*/
-
-static UINT8* hunk_read_compressed(chd_file *chd, UINT64 offset, size_t size)
-{
-#ifdef _MSC_VER
-       size_t bytes;
-#else
-       ssize_t bytes;
-#endif
-       if (chd->file_cache != NULL)
-       {
-               return chd->file_cache + offset;
-       }
-       else
-       {
-               core_fseek(chd->file, offset, SEEK_SET);
-               bytes = core_fread(chd->file, chd->compressed, size);
-               if (bytes != size)
-                       return NULL;
-               return chd->compressed;
-       }
-}
-
-/*-------------------------------------------------
-    hunk_read_uncompressed - read an uncompressed
-    hunk
--------------------------------------------------*/
-
-static chd_error hunk_read_uncompressed(chd_file *chd, UINT64 offset, size_t size, UINT8 *dest)
-{
-#ifdef _MSC_VER
-       size_t bytes;
-#else
-       ssize_t bytes;
-#endif
-       if (chd->file_cache != NULL)
-       {
-               memcpy(dest, chd->file_cache + offset, size);
-       }
-       else
-       {
-               core_fseek(chd->file, offset, SEEK_SET);
-               bytes = core_fread(chd->file, dest, size);
-               if (bytes != size)
-                       return CHDERR_READ_ERROR;
-       }
-       return CHDERR_NONE;
-}
-
-#ifdef NEED_CACHE_HUNK
-/*-------------------------------------------------
-    hunk_read_into_cache - read a hunk into
-    the CHD's hunk cache
--------------------------------------------------*/
-
-static chd_error hunk_read_into_cache(chd_file *chd, UINT32 hunknum)
-{
-       chd_error err;
-
-       /* track the max */
-       if (hunknum > chd->maxhunk)
-               chd->maxhunk = hunknum;
-
-       /* if we're already in the cache, we're done */
-       if (chd->cachehunk == hunknum)
-               return CHDERR_NONE;
-       chd->cachehunk = ~0;
-
-       /* otherwise, read the data */
-       err = hunk_read_into_memory(chd, hunknum, chd->cache);
-       if (err != CHDERR_NONE)
-               return err;
-
-       /* mark the hunk successfully cached in */
-       chd->cachehunk = hunknum;
-       return CHDERR_NONE;
-}
-#endif
-
-/*-------------------------------------------------
-    hunk_read_into_memory - read a hunk into
-    memory at the given location
--------------------------------------------------*/
-
-static chd_error hunk_read_into_memory(chd_file *chd, UINT32 hunknum, UINT8 *dest)
-{
-       chd_error err;
-
-       /* punt if no file */
-       if (chd->file == NULL)
-               return CHDERR_INVALID_FILE;
-
-       /* return an error if out of range */
-       if (hunknum >= chd->header.totalhunks)
-               return CHDERR_HUNK_OUT_OF_RANGE;
-
-       if (dest == NULL)
-               return CHDERR_INVALID_PARAMETER;
-
-       if (chd->header.version < 5)
-       {
-               map_entry *entry = &chd->map[hunknum];
-               UINT32 bytes;
-               UINT8* compressed_bytes;
-
-               /* switch off the entry type */
-               switch (entry->flags & MAP_ENTRY_FLAG_TYPE_MASK)
-               {
-                       /* compressed data */
-                       case V34_MAP_ENTRY_TYPE_COMPRESSED:
-            {
-               void *codec = NULL;
-
-                               /* read it into the decompression buffer */
-                               compressed_bytes = hunk_read_compressed(chd, entry->offset, entry->length);
-                               if (compressed_bytes == NULL)
-                                       return CHDERR_READ_ERROR;
-
-                               /* now decompress using the codec */
-                               err = CHDERR_NONE;
-                               codec = &chd->zlib_codec_data;
-                               if (chd->codecintf[0]->decompress != NULL)
-                                       err = (*chd->codecintf[0]->decompress)(codec, compressed_bytes, entry->length, dest, chd->header.hunkbytes);
-                               if (err != CHDERR_NONE)
-                                       return err;
-                               break;
-                       }
-
-                       /* uncompressed data */
-                       case V34_MAP_ENTRY_TYPE_UNCOMPRESSED:
-                               err = hunk_read_uncompressed(chd, entry->offset, chd->header.hunkbytes, dest);
-                               if (err != CHDERR_NONE)
-                                       return err;
-                               break;
-
-                       /* mini-compressed data */
-                       case V34_MAP_ENTRY_TYPE_MINI:
-                               put_bigendian_uint64(&dest[0], entry->offset);
-                               for (bytes = 8; bytes < chd->header.hunkbytes; bytes++)
-                                       dest[bytes] = dest[bytes - 8];
-                               break;
-
-                       /* self-referenced data */
-                       case V34_MAP_ENTRY_TYPE_SELF_HUNK:
-#ifdef NEED_CACHE_HUNK
-                               if (chd->cachehunk == entry->offset && dest == chd->cache)
-                                       break;
-#endif
-                               return hunk_read_into_memory(chd, entry->offset, dest);
-
-                       /* parent-referenced data */
-                       case V34_MAP_ENTRY_TYPE_PARENT_HUNK:
-                               err = hunk_read_into_memory(chd->parent, entry->offset, dest);
-                               if (err != CHDERR_NONE)
-                                       return err;
-                               break;
-               }
-               return CHDERR_NONE;
-       }
-       else
-       {
-               void* codec = NULL;
-               /* get a pointer to the map entry */
-               uint64_t blockoffs;
-               uint32_t blocklen;
-#ifdef VERIFY_BLOCK_CRC
-               uint16_t blockcrc;
-#endif
-               uint8_t *rawmap = &chd->header.rawmap[chd->header.mapentrybytes * hunknum];
-               UINT8* compressed_bytes;
-
-               /* uncompressed case */
-               if (!chd_compressed(&chd->header))
-               {
-                       blockoffs = (uint64_t)get_bigendian_uint32(rawmap) * (uint64_t)chd->header.hunkbytes;
-                       if (blockoffs != 0) {
-                               core_fseek(chd->file, blockoffs, SEEK_SET);
-                               int result = core_fread(chd->file, dest, chd->header.hunkbytes);
-                       /* TODO
-                       else if (m_parent_missing)
-                               throw CHDERR_REQUIRES_PARENT; */
-                       } else if (chd->parent) {
-                               err = hunk_read_into_memory(chd->parent, hunknum, dest);
-                               if (err != CHDERR_NONE)
-                                       return err;
-                       } else {
-                               memset(dest, 0, chd->header.hunkbytes);
-                       }
-
-                       return CHDERR_NONE;
-               }
-
-               /* compressed case */
-               blocklen = get_bigendian_uint24(&rawmap[1]);
-               blockoffs = get_bigendian_uint48(&rawmap[4]);
-#ifdef VERIFY_BLOCK_CRC
-               blockcrc = get_bigendian_uint16(&rawmap[10]);
-#endif
-               codec = NULL;
-               switch (rawmap[0])
-               {
-                       case COMPRESSION_TYPE_0:
-                       case COMPRESSION_TYPE_1:
-                       case COMPRESSION_TYPE_2:
-                       case COMPRESSION_TYPE_3:
-                               compressed_bytes = hunk_read_compressed(chd, blockoffs, blocklen);
-                               if (compressed_bytes == NULL)
-                                       return CHDERR_READ_ERROR;
-                               switch (chd->codecintf[rawmap[0]]->compression)
-                               {
-                                       case CHD_CODEC_CD_LZMA:
-                                               codec = &chd->cdlz_codec_data;
-                                               break;
-
-                                       case CHD_CODEC_ZLIB:
-                                               codec = &chd->zlib_codec_data;
-                                               break;
-
-                                       case CHD_CODEC_CD_ZLIB:
-                                               codec = &chd->cdzl_codec_data;
-                                               break;
-
-                                       case CHD_CODEC_CD_FLAC:
-                                               codec = &chd->cdfl_codec_data;
-                                               break;
-                               }
-                               if (codec==NULL)
-                                       return CHDERR_CODEC_ERROR;
-                               err = chd->codecintf[rawmap[0]]->decompress(codec, compressed_bytes, blocklen, dest, chd->header.hunkbytes);
-                               if (err != CHDERR_NONE)
-                                       return err;
-#ifdef VERIFY_BLOCK_CRC
-                               if (crc16(dest, chd->header.hunkbytes) != blockcrc)
-                                       return CHDERR_DECOMPRESSION_ERROR;
-#endif
-                               return CHDERR_NONE;
-
-                       case COMPRESSION_NONE:
-                               err = hunk_read_uncompressed(chd, blockoffs, blocklen, dest);
-                               if (err != CHDERR_NONE)
-                                       return err;
-#ifdef VERIFY_BLOCK_CRC
-                               if (crc16(dest, chd->header.hunkbytes) != blockcrc)
-                                       return CHDERR_DECOMPRESSION_ERROR;
-#endif
-                               return CHDERR_NONE;
-
-                       case COMPRESSION_SELF:
-                               return hunk_read_into_memory(chd, blockoffs, dest);
-
-                       case COMPRESSION_PARENT:
-#if 0
-                               /* TODO */
-                               if (m_parent_missing)
-                                       return CHDERR_REQUIRES_PARENT;
-                               return m_parent->read_bytes(uint64_t(blockoffs) * uint64_t(m_parent->unit_bytes()), dest, m_hunkbytes);
-#endif
-                               return CHDERR_DECOMPRESSION_ERROR;
-               }
-               return CHDERR_NONE;
-       }
-
-       /* We should not reach this code */
-       return CHDERR_DECOMPRESSION_ERROR;
-}
-
-/***************************************************************************
-    INTERNAL MAP ACCESS
-***************************************************************************/
-
-/*-------------------------------------------------
-    map_read - read the initial sector map
--------------------------------------------------*/
-
-static chd_error map_read(chd_file *chd)
-{
-       UINT32 entrysize = (chd->header.version < 3) ? OLD_MAP_ENTRY_SIZE : MAP_ENTRY_SIZE;
-       UINT8 raw_map_entries[MAP_STACK_ENTRIES * MAP_ENTRY_SIZE];
-       UINT64 fileoffset, maxoffset = 0;
-       UINT8 cookie[MAP_ENTRY_SIZE];
-       UINT32 count;
-       chd_error err;
-       int i;
-
-       /* first allocate memory */
-       chd->map = (map_entry *)malloc(sizeof(chd->map[0]) * chd->header.totalhunks);
-       if (!chd->map)
-               return CHDERR_OUT_OF_MEMORY;
-
-       /* read the map entries in in chunks and extract to the map list */
-       fileoffset = chd->header.length;
-       for (i = 0; i < chd->header.totalhunks; i += MAP_STACK_ENTRIES)
-       {
-               /* compute how many entries this time */
-               int entries = chd->header.totalhunks - i, j;
-               if (entries > MAP_STACK_ENTRIES)
-                       entries = MAP_STACK_ENTRIES;
-
-               /* read that many */
-               core_fseek(chd->file, fileoffset, SEEK_SET);
-               count = core_fread(chd->file, raw_map_entries, entries * entrysize);
-               if (count != entries * entrysize)
-               {
-                       err = CHDERR_READ_ERROR;
-                       goto cleanup;
-               }
-               fileoffset += entries * entrysize;
-
-               /* process that many */
-               if (entrysize == MAP_ENTRY_SIZE)
-               {
-                       for (j = 0; j < entries; j++)
-                               map_extract(&raw_map_entries[j * MAP_ENTRY_SIZE], &chd->map[i + j]);
-               }
-               else
-               {
-                       for (j = 0; j < entries; j++)
-                               map_extract_old(&raw_map_entries[j * OLD_MAP_ENTRY_SIZE], &chd->map[i + j], chd->header.hunkbytes);
-               }
-
-               /* track the maximum offset */
-               for (j = 0; j < entries; j++)
-                       if ((chd->map[i + j].flags & MAP_ENTRY_FLAG_TYPE_MASK) == V34_MAP_ENTRY_TYPE_COMPRESSED ||
-                               (chd->map[i + j].flags & MAP_ENTRY_FLAG_TYPE_MASK) == V34_MAP_ENTRY_TYPE_UNCOMPRESSED)
-                               maxoffset = MAX(maxoffset, chd->map[i + j].offset + chd->map[i + j].length);
-       }
-
-       /* verify the cookie */
-       core_fseek(chd->file, fileoffset, SEEK_SET);
-       count = core_fread(chd->file, &cookie, entrysize);
-       if (count != entrysize || memcmp(&cookie, END_OF_LIST_COOKIE, entrysize))
-       {
-               err = CHDERR_INVALID_FILE;
-               goto cleanup;
-       }
-
-       /* verify the length */
-       if (maxoffset > core_fsize(chd->file))
-       {
-               err = CHDERR_INVALID_FILE;
-               goto cleanup;
-       }
-       return CHDERR_NONE;
-
-cleanup:
-       if (chd->map)
-               free(chd->map);
-       chd->map = NULL;
-       return err;
-}
-
-/***************************************************************************
-    INTERNAL METADATA ACCESS
-***************************************************************************/
-
-/*-------------------------------------------------
-    metadata_find_entry - find a metadata entry
--------------------------------------------------*/
-
-static chd_error metadata_find_entry(chd_file *chd, UINT32 metatag, UINT32 metaindex, metadata_entry *metaentry)
-{
-       /* start at the beginning */
-       metaentry->offset = chd->header.metaoffset;
-       metaentry->prev = 0;
-
-       /* loop until we run out of options */
-       while (metaentry->offset != 0)
-       {
-               UINT8   raw_meta_header[METADATA_HEADER_SIZE];
-               UINT32  count;
-
-               /* read the raw header */
-               core_fseek(chd->file, metaentry->offset, SEEK_SET);
-               count = core_fread(chd->file, raw_meta_header, sizeof(raw_meta_header));
-               if (count != sizeof(raw_meta_header))
-                       break;
-
-               /* extract the data */
-               metaentry->metatag = get_bigendian_uint32(&raw_meta_header[0]);
-               metaentry->length = get_bigendian_uint32(&raw_meta_header[4]);
-               metaentry->next = get_bigendian_uint64(&raw_meta_header[8]);
-
-               /* flags are encoded in the high byte of length */
-               metaentry->flags = metaentry->length >> 24;
-               metaentry->length &= 0x00ffffff;
-
-               /* if we got a match, proceed */
-               if (metatag == CHDMETATAG_WILDCARD || metaentry->metatag == metatag)
-                       if (metaindex-- == 0)
-                               return CHDERR_NONE;
-
-               /* no match, fetch the next link */
-               metaentry->prev = metaentry->offset;
-               metaentry->offset = metaentry->next;
-       }
-
-       /* if we get here, we didn't find it */
-       return CHDERR_METADATA_NOT_FOUND;
-}
-
-/***************************************************************************
-    ZLIB COMPRESSION CODEC
-***************************************************************************/
-
-/*-------------------------------------------------
-    zlib_codec_init - initialize the ZLIB codec
--------------------------------------------------*/
-
-static chd_error zlib_codec_init(void *codec, uint32_t hunkbytes)
-{
-       int zerr;
-       chd_error err;
-       zlib_codec_data *data = (zlib_codec_data*)codec;
-
-       /* clear the buffers */
-       memset(data, 0, sizeof(zlib_codec_data));
-
-       /* init the inflater first */
-       data->inflater.next_in = (Bytef *)data; /* bogus, but that's ok */
-       data->inflater.avail_in = 0;
-       data->inflater.zalloc = zlib_fast_alloc;
-       data->inflater.zfree = zlib_fast_free;
-       data->inflater.opaque = &data->allocator;
-       zerr = inflateInit2(&data->inflater, -MAX_WBITS);
-
-       /* convert errors */
-       if (zerr == Z_MEM_ERROR)
-               err = CHDERR_OUT_OF_MEMORY;
-       else if (zerr != Z_OK)
-               err = CHDERR_CODEC_ERROR;
-       else
-               err = CHDERR_NONE;
-
-       /* handle an error */
-       if (err != CHDERR_NONE)
-               free(data);
-
-       return err;
-}
-
-/*-------------------------------------------------
-    zlib_codec_free - free data for the ZLIB
-    codec
--------------------------------------------------*/
-
-static void zlib_codec_free(void *codec)
-{
-       zlib_codec_data *data = (zlib_codec_data *)codec;
-
-       /* deinit the streams */
-       if (data != NULL)
-       {
-               int i;
-
-               inflateEnd(&data->inflater);
-
-               /* free our fast memory */
-               zlib_allocator_free(&data->allocator);
-       }
-}
-
-/*-------------------------------------------------
-    zlib_codec_decompress - decompress data using
-    the ZLIB codec
--------------------------------------------------*/
-
-static chd_error zlib_codec_decompress(void *codec, const uint8_t *src, uint32_t complen, uint8_t *dest, uint32_t destlen)
-{
-       zlib_codec_data *data = (zlib_codec_data *)codec;
-       int zerr;
-
-       /* reset the decompressor */
-       data->inflater.next_in = (Bytef *)src;
-       data->inflater.avail_in = complen;
-       data->inflater.total_in = 0;
-       data->inflater.next_out = (Bytef *)dest;
-       data->inflater.avail_out = destlen;
-       data->inflater.total_out = 0;
-       zerr = inflateReset(&data->inflater);
-       if (zerr != Z_OK)
-               return CHDERR_DECOMPRESSION_ERROR;
-
-       /* do it */
-       zerr = inflate(&data->inflater, Z_FINISH);
-       if (data->inflater.total_out != destlen)
-               return CHDERR_DECOMPRESSION_ERROR;
-
-       return CHDERR_NONE;
-}
-
-/*-------------------------------------------------
-    zlib_fast_alloc - fast malloc for ZLIB, which
-    allocates and frees memory frequently
--------------------------------------------------*/
-
-/* Huge alignment values for possible SIMD optimization by compiler (NEON, SSE, AVX) */
-#define ZLIB_MIN_ALIGNMENT_BITS 512
-#define ZLIB_MIN_ALIGNMENT_BYTES (ZLIB_MIN_ALIGNMENT_BITS / 8)
-
-static voidpf zlib_fast_alloc(voidpf opaque, uInt items, uInt size)
-{
-       zlib_allocator *alloc = (zlib_allocator *)opaque;
-       uintptr_t paddr = 0;
-       UINT32 *ptr;
-       int i;
-
-       /* compute the size, rounding to the nearest 1k */
-       size = (size * items + 0x3ff) & ~0x3ff;
-
-       /* reuse a hunk if we can */
-       for (i = 0; i < MAX_ZLIB_ALLOCS; i++)
-       {
-               ptr = alloc->allocptr[i];
-               if (ptr && size == *ptr)
-               {
-                       /* set the low bit of the size so we don't match next time */
-                       *ptr |= 1;
-
-                       /* return aligned block address */
-                       return (voidpf)(alloc->allocptr2[i]);
-               }
-       }
-
-       /* alloc a new one */
-    ptr = (UINT32 *)malloc(size + sizeof(UINT32) + ZLIB_MIN_ALIGNMENT_BYTES);
-       if (!ptr)
-               return NULL;
-
-       /* put it into the list */
-       for (i = 0; i < MAX_ZLIB_ALLOCS; i++)
-               if (!alloc->allocptr[i])
-               {
-                       alloc->allocptr[i] = ptr;
-                       paddr = (((uintptr_t)ptr) + sizeof(UINT32) + (ZLIB_MIN_ALIGNMENT_BYTES-1)) & (~(ZLIB_MIN_ALIGNMENT_BYTES-1));
-                       alloc->allocptr2[i] = (uint32_t*)paddr;
-                       break;
-               }
-
-       /* set the low bit of the size so we don't match next time */
-       *ptr = size | 1;
-
-       /* return aligned block address */
-       return (voidpf)paddr;
-}
-
-/*-------------------------------------------------
-    zlib_fast_free - fast free for ZLIB, which
-    allocates and frees memory frequently
--------------------------------------------------*/
-
-static void zlib_fast_free(voidpf opaque, voidpf address)
-{
-       zlib_allocator *alloc = (zlib_allocator *)opaque;
-       UINT32 *ptr = (UINT32 *)address;
-       int i;
-
-       /* find the hunk */
-       for (i = 0; i < MAX_ZLIB_ALLOCS; i++)
-               if (ptr == alloc->allocptr2[i])
-               {
-                       /* clear the low bit of the size to allow matches */
-                       *(alloc->allocptr[i]) &= ~1;
-                       return;
-               }
-}
-
-/*-------------------------------------------------
-    zlib_allocator_free
--------------------------------------------------*/
-static void zlib_allocator_free(voidpf opaque)
-{
-       zlib_allocator *alloc = (zlib_allocator *)opaque;
-       int i;
-
-       for (i = 0; i < MAX_ZLIB_ALLOCS; i++)
-               if (alloc->allocptr[i])
-                       free(alloc->allocptr[i]);
-}
diff --git a/deps/libchdr/src/libchdr_flac.c b/deps/libchdr/src/libchdr_flac.c
deleted file mode 100644 (file)
index 54d374f..0000000
+++ /dev/null
@@ -1,302 +0,0 @@
-/* license:BSD-3-Clause
- * copyright-holders:Aaron Giles
-***************************************************************************
-
-    flac.c
-
-    FLAC compression wrappers
-
-***************************************************************************/
-
-#include <assert.h>
-#include <string.h>
-
-#include <libchdr/flac.h>
-#define DR_FLAC_IMPLEMENTATION
-#include <dr_libs/dr_flac.h>
-
-/***************************************************************************
- *  FLAC DECODER
- ***************************************************************************
- */
-
-static size_t flac_decoder_read_callback(void *userdata, void *buffer, size_t bytes);
-static drflac_bool32 flac_decoder_seek_callback(void *userdata, int offset, drflac_seek_origin origin);
-static void flac_decoder_metadata_callback(void *userdata, drflac_metadata *metadata);
-static void flac_decoder_write_callback(void *userdata, void *buffer, size_t len);
-
-
-/* getters (valid after reset) */
-static uint32_t sample_rate(flac_decoder *decoder)  { return decoder->sample_rate; }
-static uint8_t channels(flac_decoder *decoder)  { return decoder->channels; }
-static uint8_t bits_per_sample(flac_decoder *decoder) { return decoder->bits_per_sample; }
-
-/*-------------------------------------------------
- *  flac_decoder - constructor
- *-------------------------------------------------
- */
-
-int flac_decoder_init(flac_decoder *decoder)
-{
-       decoder->decoder = NULL;
-       decoder->sample_rate = 0;
-       decoder->channels = 0;
-       decoder->bits_per_sample = 0;
-       decoder->compressed_offset = 0;
-       decoder->compressed_start = NULL;
-       decoder->compressed_length = 0;
-       decoder->compressed2_start = NULL;
-       decoder->compressed2_length = 0;
-       decoder->uncompressed_offset = 0;
-       decoder->uncompressed_length = 0;
-       decoder->uncompressed_swap = 0;
-       return 0;
-}
-
-/*-------------------------------------------------
- *  flac_decoder - destructor
- *-------------------------------------------------
- */
-
-void flac_decoder_free(flac_decoder* decoder)
-{
-       if ((decoder != NULL) && (decoder->decoder != NULL))
-               drflac_close(decoder->decoder);
-       decoder->decoder = NULL;
-}
-
-/*-------------------------------------------------
- *  reset - reset state with the original
- *  parameters
- *-------------------------------------------------
- */
-
-static int flac_decoder_internal_reset(flac_decoder* decoder)
-{
-       decoder->compressed_offset = 0;
-       flac_decoder_free(decoder);
-       decoder->decoder = drflac_open_with_metadata(
-               flac_decoder_read_callback, flac_decoder_seek_callback,
-               flac_decoder_metadata_callback, decoder, NULL);
-       return (decoder->decoder != NULL);
-}
-
-/*-------------------------------------------------
- *  reset - reset state with new memory parameters
- *  and a custom-generated header
- *-------------------------------------------------
- */
-
-int flac_decoder_reset(flac_decoder* decoder, uint32_t sample_rate, uint8_t num_channels, uint32_t block_size, const void *buffer, uint32_t length)
-{
-       /* modify the template header with our parameters */
-       static const uint8_t s_header_template[0x2a] =
-       {
-               0x66, 0x4C, 0x61, 0x43,                         /* +00: 'fLaC' stream header */
-               0x80,                                           /* +04: metadata block type 0 (STREAMINFO), */
-                                                               /*      flagged as last block */
-               0x00, 0x00, 0x22,                               /* +05: metadata block length = 0x22 */
-               0x00, 0x00,                                     /* +08: minimum block size */
-               0x00, 0x00,                                     /* +0A: maximum block size */
-               0x00, 0x00, 0x00,                               /* +0C: minimum frame size (0 == unknown) */
-               0x00, 0x00, 0x00,                               /* +0F: maximum frame size (0 == unknown) */
-               0x0A, 0xC4, 0x42, 0xF0, 0x00, 0x00, 0x00, 0x00, /* +12: sample rate (0x0ac44 == 44100), */
-                                                               /*      numchannels (2), sample bits (16), */
-                                                               /*      samples in stream (0 == unknown) */
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* +1A: MD5 signature (0 == none) */
-               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00  /* +2A: start of stream data */
-       };
-       memcpy(decoder->custom_header, s_header_template, sizeof(s_header_template));
-       decoder->custom_header[0x08] = decoder->custom_header[0x0a] = (block_size*num_channels) >> 8;
-       decoder->custom_header[0x09] = decoder->custom_header[0x0b] = (block_size*num_channels) & 0xff;
-       decoder->custom_header[0x12] = sample_rate >> 12;
-       decoder->custom_header[0x13] = sample_rate >> 4;
-       decoder->custom_header[0x14] = (sample_rate << 4) | ((num_channels - 1) << 1);
-
-       /* configure the header ahead of the provided buffer */
-       decoder->compressed_start = (const uint8_t *)(decoder->custom_header);
-       decoder->compressed_length = sizeof(decoder->custom_header);
-       decoder->compressed2_start = (const uint8_t *)(buffer);
-       decoder->compressed2_length = length;
-       return flac_decoder_internal_reset(decoder);
-}
-
-/*-------------------------------------------------
- *  decode_interleaved - decode to an interleaved
- *  sound stream
- *-------------------------------------------------
- */
-
-int flac_decoder_decode_interleaved(flac_decoder* decoder, int16_t *samples, uint32_t num_samples, int swap_endian)
-{
-       /* configure the uncompressed buffer */
-       memset(decoder->uncompressed_start, 0, sizeof(decoder->uncompressed_start));
-       decoder->uncompressed_start[0] = samples;
-       decoder->uncompressed_offset = 0;
-       decoder->uncompressed_length = num_samples;
-       decoder->uncompressed_swap = swap_endian;
-
-#define        BUFFER  2352    /* bytes per CD audio sector */
-       int16_t buffer[BUFFER];
-       uint32_t buf_samples = BUFFER / channels(decoder);
-       /* loop until we get everything we want */
-       while (decoder->uncompressed_offset < decoder->uncompressed_length) {
-               uint32_t frames = (num_samples < buf_samples ? num_samples : buf_samples);
-               if (!drflac_read_pcm_frames_s16(decoder->decoder, frames, buffer))
-                       return 0;
-               flac_decoder_write_callback(decoder, buffer, frames*sizeof(*buffer)*channels(decoder));
-               num_samples -= frames;
-       }
-       return 1;
-}
-
-/*-------------------------------------------------
- *  finish - finish up the decode
- *-------------------------------------------------
- */
-
-uint32_t flac_decoder_finish(flac_decoder* decoder)
-{
-       /* get the final decoding position and move forward */
-       drflac *flac = decoder->decoder;
-       uint64_t position = decoder->compressed_offset;
-
-       /* ugh... there's no function to obtain bytes used in drflac :-/ */
-       position -= DRFLAC_CACHE_L2_LINES_REMAINING(&flac->bs) * sizeof(drflac_cache_t);
-       position -= DRFLAC_CACHE_L1_BITS_REMAINING(&flac->bs) / 8;
-       position -= flac->bs.unalignedByteCount;
-
-       /* adjust position if we provided the header */
-       if (position == 0)
-               return 0;
-       if (decoder->compressed_start == (const uint8_t *)(decoder->custom_header))
-               position -= decoder->compressed_length;
-
-       flac_decoder_free(decoder);
-       return position;
-}
-
-/*-------------------------------------------------
- *  read_callback - handle reads from the input
- *  stream
- *-------------------------------------------------
- */
-
-#define MIN(x, y) ((x) < (y) ? (x) : (y))
-
-static size_t flac_decoder_read_callback(void *userdata, void *buffer, size_t bytes)
-{
-       flac_decoder* decoder = (flac_decoder*)userdata;
-       uint8_t *dst = buffer;
-
-       /* copy from primary buffer first */
-       uint32_t outputpos = 0;
-       if (outputpos < bytes && decoder->compressed_offset < decoder->compressed_length)
-       {
-               uint32_t bytes_to_copy = MIN(bytes - outputpos, decoder->compressed_length - decoder->compressed_offset);
-               memcpy(&dst[outputpos], decoder->compressed_start + decoder->compressed_offset, bytes_to_copy);
-               outputpos += bytes_to_copy;
-               decoder->compressed_offset += bytes_to_copy;
-       }
-
-       /* once we're out of that, copy from the secondary buffer */
-       if (outputpos < bytes && decoder->compressed_offset < decoder->compressed_length + decoder->compressed2_length)
-       {
-               uint32_t bytes_to_copy = MIN(bytes - outputpos, decoder->compressed2_length - (decoder->compressed_offset - decoder->compressed_length));
-               memcpy(&dst[outputpos], decoder->compressed2_start + decoder->compressed_offset - decoder->compressed_length, bytes_to_copy);
-               outputpos += bytes_to_copy;
-               decoder->compressed_offset += bytes_to_copy;
-       }
-
-       return outputpos;
-}
-
-/*-------------------------------------------------
- *  metadata_callback - handle STREAMINFO metadata
- *-------------------------------------------------
- */
-
-static void flac_decoder_metadata_callback(void *userdata, drflac_metadata *metadata)
-{
-       flac_decoder *decoder = userdata;
-
-       /* ignore all but STREAMINFO metadata */
-       if (metadata->type != DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO)
-               return;
-
-       /* parse out the data we care about */
-       decoder->sample_rate = metadata->data.streaminfo.sampleRate;
-       decoder->bits_per_sample = metadata->data.streaminfo.bitsPerSample;
-       decoder->channels = metadata->data.streaminfo.channels;
-}
-
-/*-------------------------------------------------
- *  write_callback - handle writes to the output
- *  stream
- *-------------------------------------------------
- */
-
-static void flac_decoder_write_callback(void *userdata, void *buffer, size_t bytes)
-{
-       int sampnum, chan;
-       int shift, blocksize;
-       flac_decoder * decoder = (flac_decoder *)userdata;
-       int16_t *sampbuf = (int16_t *)buffer;
-       int sampch = channels(decoder);
-       uint32_t offset = decoder->uncompressed_offset;
-       uint16_t usample;
-
-       /* interleaved case */
-       shift = decoder->uncompressed_swap ? 8 : 0;
-       blocksize = bytes / (sampch * sizeof(sampbuf[0]));
-       if (decoder->uncompressed_start[1] == NULL)
-       {
-               int16_t *dest = decoder->uncompressed_start[0] + offset * sampch;
-               for (sampnum = 0; sampnum < blocksize && offset < decoder->uncompressed_length; sampnum++, offset++)
-                       for (chan = 0; chan < sampch; chan++) {
-                               usample = (uint16_t)*sampbuf++;
-                               *dest++ = (int16_t)((usample << shift) | (usample >> shift));
-                       }
-       }
-
-       /* non-interleaved case */
-       else
-       {
-               for (sampnum = 0; sampnum < blocksize && offset < decoder->uncompressed_length; sampnum++, offset++)
-                       for (chan = 0; chan < sampch; chan++) {
-                               usample = (uint16_t)*sampbuf++;
-                               if (decoder->uncompressed_start[chan] != NULL)
-                                       decoder->uncompressed_start[chan][offset] = (int16_t) ((usample << shift) | (usample >> shift));
-                       }
-       }
-       decoder->uncompressed_offset = offset;
-}
-
-
-/*-------------------------------------------------
- *  seek_callback - handle seeks on the output
- *  stream
- *-------------------------------------------------
- */
-
-static drflac_bool32 flac_decoder_seek_callback(void *userdata, int offset, drflac_seek_origin origin)
-{
-       flac_decoder * decoder = (flac_decoder *)userdata;
-       uint32_t length = decoder->compressed_length + decoder->compressed2_length;
-
-       if (origin == drflac_seek_origin_start) {
-               uint32_t pos = offset;
-               if (pos <= length) {
-                       decoder->compressed_offset = pos;
-                       return 1;
-               }
-       } else if (origin == drflac_seek_origin_current) {
-               uint32_t pos = decoder->compressed_offset + offset;
-               if (pos <= length) {
-                       decoder->compressed_offset = pos;
-                       return 1;
-               }
-       }
-       return 0;
-}
-
diff --git a/deps/libchdr/src/libchdr_huffman.c b/deps/libchdr/src/libchdr_huffman.c
deleted file mode 100644 (file)
index 6a50f13..0000000
+++ /dev/null
@@ -1,544 +0,0 @@
-/* license:BSD-3-Clause
- * copyright-holders:Aaron Giles
-****************************************************************************
-
-    huffman.c
-
-    Static Huffman compression and decompression helpers.
-
-****************************************************************************
-
-    Maximum codelength is officially (alphabetsize - 1). This would be 255 bits
-    (since we use 1 byte values). However, it is also dependent upon the number
-    of samples used, as follows:
-
-         2 bits -> 3..4 samples
-         3 bits -> 5..7 samples
-         4 bits -> 8..12 samples
-         5 bits -> 13..20 samples
-         6 bits -> 21..33 samples
-         7 bits -> 34..54 samples
-         8 bits -> 55..88 samples
-         9 bits -> 89..143 samples
-        10 bits -> 144..232 samples
-        11 bits -> 233..376 samples
-        12 bits -> 377..609 samples
-        13 bits -> 610..986 samples
-        14 bits -> 987..1596 samples
-        15 bits -> 1597..2583 samples
-        16 bits -> 2584..4180 samples   -> note that a 4k data size guarantees codelength <= 16 bits
-        17 bits -> 4181..6764 samples
-        18 bits -> 6765..10945 samples
-        19 bits -> 10946..17710 samples
-        20 bits -> 17711..28656 samples
-        21 bits -> 28657..46367 samples
-        22 bits -> 46368..75024 samples
-        23 bits -> 75025..121392 samples
-        24 bits -> 121393..196417 samples
-        25 bits -> 196418..317810 samples
-        26 bits -> 317811..514228 samples
-        27 bits -> 514229..832039 samples
-        28 bits -> 832040..1346268 samples
-        29 bits -> 1346269..2178308 samples
-        30 bits -> 2178309..3524577 samples
-        31 bits -> 3524578..5702886 samples
-        32 bits -> 5702887..9227464 samples
-
-    Looking at it differently, here is where powers of 2 fall into these buckets:
-
-          256 samples -> 11 bits max
-          512 samples -> 12 bits max
-           1k samples -> 14 bits max
-           2k samples -> 15 bits max
-           4k samples -> 16 bits max
-           8k samples -> 18 bits max
-          16k samples -> 19 bits max
-          32k samples -> 21 bits max
-          64k samples -> 22 bits max
-         128k samples -> 24 bits max
-         256k samples -> 25 bits max
-         512k samples -> 27 bits max
-           1M samples -> 28 bits max
-           2M samples -> 29 bits max
-           4M samples -> 31 bits max
-           8M samples -> 32 bits max
-
-****************************************************************************
-
-    Delta-RLE encoding works as follows:
-
-    Starting value is assumed to be 0. All data is encoded as a delta
-    from the previous value, such that final[i] = final[i - 1] + delta.
-    Long runs of 0s are RLE-encoded as follows:
-
-        0x100 = repeat count of 8
-        0x101 = repeat count of 9
-        0x102 = repeat count of 10
-        0x103 = repeat count of 11
-        0x104 = repeat count of 12
-        0x105 = repeat count of 13
-        0x106 = repeat count of 14
-        0x107 = repeat count of 15
-        0x108 = repeat count of 16
-        0x109 = repeat count of 32
-        0x10a = repeat count of 64
-        0x10b = repeat count of 128
-        0x10c = repeat count of 256
-        0x10d = repeat count of 512
-        0x10e = repeat count of 1024
-        0x10f = repeat count of 2048
-
-    Note that repeat counts are reset at the end of a row, so if a 0 run
-    extends to the end of a row, a large repeat count may be used.
-
-    The reason for starting the run counts at 8 is that 0 is expected to
-    be the most common symbol, and is typically encoded in 1 or 2 bits.
-
-***************************************************************************/
-
-#include <stdlib.h>
-#include <assert.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <libchdr/huffman.h>
-
-#define MAX(x,y) ((x) > (y) ? (x) : (y))
-
-/***************************************************************************
- *  MACROS
- ***************************************************************************
- */
-
-#define MAKE_LOOKUP(code,bits)  (((code) << 5) | ((bits) & 0x1f))
-
-/***************************************************************************
- *  IMPLEMENTATION
- ***************************************************************************
- */
-
-/*-------------------------------------------------
- *  huffman_context_base - create an encoding/
- *  decoding context
- *-------------------------------------------------
- */
-
-struct huffman_decoder* create_huffman_decoder(int numcodes, int maxbits)
-{
-       struct huffman_decoder* decoder = NULL;
-
-       /* limit to 24 bits */
-       if (maxbits > 24)
-               return NULL;
-
-       decoder = (struct huffman_decoder*)malloc(sizeof(struct huffman_decoder));
-       decoder->numcodes = numcodes;
-       decoder->maxbits = maxbits;
-       decoder->lookup = (lookup_value*)malloc(sizeof(lookup_value) * (1 << maxbits));
-       decoder->huffnode = (struct node_t*)malloc(sizeof(struct node_t) * numcodes);
-       decoder->datahisto = NULL;
-       decoder->prevdata = 0;
-       decoder->rleremaining = 0;
-       return decoder;
-}
-
-void delete_huffman_decoder(struct huffman_decoder* decoder)
-{
-       if (decoder != NULL)
-       {
-               if (decoder->lookup != NULL)
-                       free(decoder->lookup);
-               if (decoder->huffnode != NULL)
-                       free(decoder->huffnode);
-               free(decoder);
-       }
-}
-
-/*-------------------------------------------------
- *  decode_one - decode a single code from the
- *  huffman stream
- *-------------------------------------------------
- */
-
-uint32_t huffman_decode_one(struct huffman_decoder* decoder, struct bitstream* bitbuf)
-{
-       /* peek ahead to get maxbits worth of data */
-       uint32_t bits = bitstream_peek(bitbuf, decoder->maxbits);
-
-       /* look it up, then remove the actual number of bits for this code */
-       lookup_value lookup = decoder->lookup[bits];
-       bitstream_remove(bitbuf, lookup & 0x1f);
-
-       /* return the value */
-       return lookup >> 5;
-}
-
-/*-------------------------------------------------
- *  import_tree_rle - import an RLE-encoded
- *  huffman tree from a source data stream
- *-------------------------------------------------
- */
-
-enum huffman_error huffman_import_tree_rle(struct huffman_decoder* decoder, struct bitstream* bitbuf)
-{
-       int numbits, curnode;
-       enum huffman_error error;
-
-       /* bits per entry depends on the maxbits */
-       if (decoder->maxbits >= 16)
-               numbits = 5;
-       else if (decoder->maxbits >= 8)
-               numbits = 4;
-       else
-               numbits = 3;
-
-       /* loop until we read all the nodes */
-       for (curnode = 0; curnode < decoder->numcodes; )
-       {
-               /* a non-one value is just raw */
-               int nodebits = bitstream_read(bitbuf, numbits);
-               if (nodebits != 1)
-                       decoder->huffnode[curnode++].numbits = nodebits;
-
-               /* a one value is an escape code */
-               else
-               {
-                       /* a double 1 is just a single 1 */
-                       nodebits = bitstream_read(bitbuf, numbits);
-                       if (nodebits == 1)
-                               decoder->huffnode[curnode++].numbits = nodebits;
-
-                       /* otherwise, we need one for value for the repeat count */
-                       else
-                       {
-                               int repcount = bitstream_read(bitbuf, numbits) + 3;
-                               while (repcount--)
-                                       decoder->huffnode[curnode++].numbits = nodebits;
-                       }
-               }
-       }
-
-       /* make sure we ended up with the right number */
-       if (curnode != decoder->numcodes)
-               return HUFFERR_INVALID_DATA;
-
-       /* assign canonical codes for all nodes based on their code lengths */
-       error = huffman_assign_canonical_codes(decoder);
-       if (error != HUFFERR_NONE)
-               return error;
-
-       /* build the lookup table */
-       huffman_build_lookup_table(decoder);
-
-       /* determine final input length and report errors */
-       return bitstream_overflow(bitbuf) ? HUFFERR_INPUT_BUFFER_TOO_SMALL : HUFFERR_NONE;
-}
-
-
-/*-------------------------------------------------
- *  import_tree_huffman - import a huffman-encoded
- *  huffman tree from a source data stream
- *-------------------------------------------------
- */
-
-enum huffman_error huffman_import_tree_huffman(struct huffman_decoder* decoder, struct bitstream* bitbuf)
-{
-       int start;
-       int last = 0;
-       int count = 0;
-       int index;
-       int curcode;
-       uint8_t rlefullbits = 0;
-       uint32_t temp;
-       enum huffman_error error;
-       /* start by parsing the lengths for the small tree */
-       struct huffman_decoder* smallhuff = create_huffman_decoder(24, 6);
-       smallhuff->huffnode[0].numbits = bitstream_read(bitbuf, 3);
-       start = bitstream_read(bitbuf, 3) + 1;
-       for (index = 1; index < 24; index++)
-       {
-               if (index < start || count == 7)
-                       smallhuff->huffnode[index].numbits = 0;
-               else
-               {
-                       count = bitstream_read(bitbuf, 3);
-                       smallhuff->huffnode[index].numbits = (count == 7) ? 0 : count;
-               }
-       }
-
-       /* then regenerate the tree */
-       error = huffman_assign_canonical_codes(smallhuff);
-       if (error != HUFFERR_NONE)
-               return error;
-       huffman_build_lookup_table(smallhuff);
-
-       /* determine the maximum length of an RLE count */
-       temp = decoder->numcodes - 9;
-       while (temp != 0)
-               temp >>= 1, rlefullbits++;
-
-       /* now process the rest of the data */
-       for (curcode = 0; curcode < decoder->numcodes; )
-       {
-               int value = huffman_decode_one(smallhuff, bitbuf);
-               if (value != 0)
-                       decoder->huffnode[curcode++].numbits = last = value - 1;
-               else
-               {
-                       int count = bitstream_read(bitbuf, 3) + 2;
-                       if (count == 7+2)
-                               count += bitstream_read(bitbuf, rlefullbits);
-                       for ( ; count != 0 && curcode < decoder->numcodes; count--)
-                               decoder->huffnode[curcode++].numbits = last;
-               }
-       }
-
-       /* make sure we ended up with the right number */
-       if (curcode != decoder->numcodes)
-               return HUFFERR_INVALID_DATA;
-
-       /* assign canonical codes for all nodes based on their code lengths */
-       error = huffman_assign_canonical_codes(decoder);
-       if (error != HUFFERR_NONE)
-               return error;
-
-       /* build the lookup table */
-       huffman_build_lookup_table(decoder);
-
-       /* determine final input length and report errors */
-       return bitstream_overflow(bitbuf) ? HUFFERR_INPUT_BUFFER_TOO_SMALL : HUFFERR_NONE;
-}
-
-/*-------------------------------------------------
- *  compute_tree_from_histo - common backend for
- *  computing a tree based on the data histogram
- *-------------------------------------------------
- */
-
-enum huffman_error huffman_compute_tree_from_histo(struct huffman_decoder* decoder)
-{
-       int i;
-       uint32_t lowerweight;
-       uint32_t upperweight;
-       /* compute the number of data items in the histogram */
-       uint32_t sdatacount = 0;
-       for (i = 0; i < decoder->numcodes; i++)
-               sdatacount += decoder->datahisto[i];
-
-       /* binary search to achieve the optimum encoding */
-       lowerweight = 0;
-       upperweight = sdatacount * 2;
-       while (1)
-       {
-               /* build a tree using the current weight */
-               uint32_t curweight = (upperweight + lowerweight) / 2;
-               int curmaxbits = huffman_build_tree(decoder, sdatacount, curweight);
-
-               /* apply binary search here */
-               if (curmaxbits <= decoder->maxbits)
-               {
-                       lowerweight = curweight;
-
-                       /* early out if it worked with the raw weights, or if we're done searching */
-                       if (curweight == sdatacount || (upperweight - lowerweight) <= 1)
-                               break;
-               }
-               else
-                       upperweight = curweight;
-       }
-
-       /* assign canonical codes for all nodes based on their code lengths */
-       return huffman_assign_canonical_codes(decoder);
-}
-
-/***************************************************************************
- *  INTERNAL FUNCTIONS
- ***************************************************************************
- */
-
-/*-------------------------------------------------
- *  tree_node_compare - compare two tree nodes
- *  by weight
- *-------------------------------------------------
- */
-
-static int huffman_tree_node_compare(const void *item1, const void *item2)
-{
-       const struct node_t *node1 = *(const struct node_t **)item1;
-       const struct node_t *node2 = *(const struct node_t **)item2;
-       if (node2->weight != node1->weight)
-               return node2->weight - node1->weight;
-       if (node2->bits - node1->bits == 0)
-               fprintf(stderr, "identical node sort keys, should not happen!\n");
-       return (int)node1->bits - (int)node2->bits;
-}
-
-/*-------------------------------------------------
- *  build_tree - build a huffman tree based on the
- *  data distribution
- *-------------------------------------------------
- */
-
-int huffman_build_tree(struct huffman_decoder* decoder, uint32_t totaldata, uint32_t totalweight)
-{
-       int curcode;
-       int nextalloc;
-       int listitems = 0;
-       int maxbits = 0;
-       /* make a list of all non-zero nodes */
-       struct node_t** list = (struct node_t**)malloc(sizeof(struct node_t*) * decoder->numcodes * 2);
-       memset(decoder->huffnode, 0, decoder->numcodes * sizeof(decoder->huffnode[0]));
-       for (curcode = 0; curcode < decoder->numcodes; curcode++)
-               if (decoder->datahisto[curcode] != 0)
-               {
-                       list[listitems++] = &decoder->huffnode[curcode];
-                       decoder->huffnode[curcode].count = decoder->datahisto[curcode];
-                       decoder->huffnode[curcode].bits = curcode;
-
-                       /* scale the weight by the current effective length, ensuring we don't go to 0 */
-                       decoder->huffnode[curcode].weight = ((uint64_t)decoder->datahisto[curcode]) * ((uint64_t)totalweight) / ((uint64_t)totaldata);
-                       if (decoder->huffnode[curcode].weight == 0)
-                               decoder->huffnode[curcode].weight = 1;
-               }
-
-#if 0
-        fprintf(stderr, "Pre-sort:\n");
-        for (int i = 0; i < listitems; i++) {
-            fprintf(stderr, "weight: %d code: %d\n", list[i]->m_weight, list[i]->m_bits);
-        }
-#endif
-
-       /* sort the list by weight, largest weight first */
-       qsort(&list[0], listitems, sizeof(list[0]), huffman_tree_node_compare);
-
-#if 0
-        fprintf(stderr, "Post-sort:\n");
-        for (int i = 0; i < listitems; i++) {
-            fprintf(stderr, "weight: %d code: %d\n", list[i]->m_weight, list[i]->m_bits);
-        }
-        fprintf(stderr, "===================\n");
-#endif
-
-       /* now build the tree */
-       nextalloc = decoder->numcodes;
-       while (listitems > 1)
-       {
-               int curitem;
-               /* remove lowest two items */
-               struct node_t* node1 = &(*list[--listitems]);
-               struct node_t* node0 = &(*list[--listitems]);
-
-               /* create new node */
-               struct node_t* newnode = &decoder->huffnode[nextalloc++];
-               newnode->parent = NULL;
-               node0->parent = node1->parent = newnode;
-               newnode->weight = node0->weight + node1->weight;
-
-               /* insert into list at appropriate location */
-               for (curitem = 0; curitem < listitems; curitem++)
-                       if (newnode->weight > list[curitem]->weight)
-                       {
-                               memmove(&list[curitem+1], &list[curitem], (listitems - curitem) * sizeof(list[0]));
-                               break;
-                       }
-               list[curitem] = newnode;
-               listitems++;
-       }
-
-       /* compute the number of bits in each code, and fill in another histogram */
-       for (curcode = 0; curcode < decoder->numcodes; curcode++)
-       {
-               struct node_t *curnode;
-               struct node_t* node = &decoder->huffnode[curcode];
-               node->numbits = 0;
-               node->bits = 0;
-
-               /* if we have a non-zero weight, compute the number of bits */
-               if (node->weight > 0)
-               {
-                       /* determine the number of bits for this node */
-                       for (curnode = node; curnode->parent != NULL; curnode = curnode->parent)
-                               node->numbits++;
-                       if (node->numbits == 0)
-                               node->numbits = 1;
-
-                       /* keep track of the max */
-                       maxbits = MAX(maxbits, ((int)node->numbits));
-               }
-       }
-       return maxbits;
-}
-
-/*-------------------------------------------------
- *  assign_canonical_codes - assign canonical codes
- *  to all the nodes based on the number of bits
- *  in each
- *-------------------------------------------------
- */
-
-enum huffman_error huffman_assign_canonical_codes(struct huffman_decoder* decoder)
-{
-       int curcode, codelen;
-       uint32_t curstart = 0;
-       /* build up a histogram of bit lengths */
-       uint32_t bithisto[33] = { 0 };
-       for (curcode = 0; curcode < decoder->numcodes; curcode++)
-       {
-               struct node_t* node = &decoder->huffnode[curcode];
-               if (node->numbits > decoder->maxbits)
-                       return HUFFERR_INTERNAL_INCONSISTENCY;
-               if (node->numbits <= 32)
-                       bithisto[node->numbits]++;
-       }
-
-       /* for each code length, determine the starting code number */
-       for (codelen = 32; codelen > 0; codelen--)
-       {
-               uint32_t nextstart = (curstart + bithisto[codelen]) >> 1;
-               if (codelen != 1 && nextstart * 2 != (curstart + bithisto[codelen]))
-                       return HUFFERR_INTERNAL_INCONSISTENCY;
-               bithisto[codelen] = curstart;
-               curstart = nextstart;
-       }
-
-       /* now assign canonical codes */
-       for (curcode = 0; curcode < decoder->numcodes; curcode++)
-       {
-               struct node_t* node = &decoder->huffnode[curcode];
-               if (node->numbits > 0)
-                       node->bits = bithisto[node->numbits]++;
-       }
-       return HUFFERR_NONE;
-}
-
-/*-------------------------------------------------
- *  build_lookup_table - build a lookup table for
- *  fast decoding
- *-------------------------------------------------
- */
-
-void huffman_build_lookup_table(struct huffman_decoder* decoder)
-{
-       int curcode;
-       /* iterate over all codes */
-       for (curcode = 0; curcode < decoder->numcodes; curcode++)
-       {
-               /* process all nodes which have non-zero bits */
-               struct node_t* node = &decoder->huffnode[curcode];
-               if (node->numbits > 0)
-               {
-         int shift;
-         lookup_value *dest;
-         lookup_value *destend;
-                       /* set up the entry */
-                       lookup_value value = MAKE_LOOKUP(curcode, node->numbits);
-
-                       /* fill all matching entries */
-                       shift = decoder->maxbits - node->numbits;
-                       dest = &decoder->lookup[node->bits << shift];
-                       destend = &decoder->lookup[((node->bits + 1) << shift) - 1];
-                       while (dest <= destend)
-                               *dest++ = value;
-               }
-       }
-}
diff --git a/deps/lzma-16.04/C/7z.h b/deps/lzma-16.04/C/7z.h
deleted file mode 100644 (file)
index 216f381..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-/* 7z.h -- 7z interface\r
-2015-11-18 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __7Z_H\r
-#define __7Z_H\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-#define k7zStartHeaderSize 0x20\r
-#define k7zSignatureSize 6\r
-\r
-extern const Byte k7zSignature[k7zSignatureSize];\r
-\r
-typedef struct\r
-{\r
-  const Byte *Data;\r
-  size_t Size;\r
-} CSzData;\r
-\r
-/* CSzCoderInfo & CSzFolder support only default methods */\r
-\r
-typedef struct\r
-{\r
-  size_t PropsOffset;\r
-  UInt32 MethodID;\r
-  Byte NumStreams;\r
-  Byte PropsSize;\r
-} CSzCoderInfo;\r
-\r
-typedef struct\r
-{\r
-  UInt32 InIndex;\r
-  UInt32 OutIndex;\r
-} CSzBond;\r
-\r
-#define SZ_NUM_CODERS_IN_FOLDER_MAX 4\r
-#define SZ_NUM_BONDS_IN_FOLDER_MAX 3\r
-#define SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX 4\r
-\r
-typedef struct\r
-{\r
-  UInt32 NumCoders;\r
-  UInt32 NumBonds;\r
-  UInt32 NumPackStreams;\r
-  UInt32 UnpackStream;\r
-  UInt32 PackStreams[SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX];\r
-  CSzBond Bonds[SZ_NUM_BONDS_IN_FOLDER_MAX];\r
-  CSzCoderInfo Coders[SZ_NUM_CODERS_IN_FOLDER_MAX];\r
-} CSzFolder;\r
-\r
-\r
-SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd);\r
-\r
-typedef struct\r
-{\r
-  UInt32 Low;\r
-  UInt32 High;\r
-} CNtfsFileTime;\r
-\r
-typedef struct\r
-{\r
-  Byte *Defs; /* MSB 0 bit numbering */\r
-  UInt32 *Vals;\r
-} CSzBitUi32s;\r
-\r
-typedef struct\r
-{\r
-  Byte *Defs; /* MSB 0 bit numbering */\r
-  // UInt64 *Vals;\r
-  CNtfsFileTime *Vals;\r
-} CSzBitUi64s;\r
-\r
-#define SzBitArray_Check(p, i) (((p)[(i) >> 3] & (0x80 >> ((i) & 7))) != 0)\r
-\r
-#define SzBitWithVals_Check(p, i) ((p)->Defs && ((p)->Defs[(i) >> 3] & (0x80 >> ((i) & 7))) != 0)\r
-\r
-typedef struct\r
-{\r
-  UInt32 NumPackStreams;\r
-  UInt32 NumFolders;\r
-\r
-  UInt64 *PackPositions;          // NumPackStreams + 1\r
-  CSzBitUi32s FolderCRCs;         // NumFolders\r
-\r
-  size_t *FoCodersOffsets;        // NumFolders + 1\r
-  UInt32 *FoStartPackStreamIndex; // NumFolders + 1\r
-  UInt32 *FoToCoderUnpackSizes;   // NumFolders + 1\r
-  Byte *FoToMainUnpackSizeIndex;  // NumFolders\r
-  UInt64 *CoderUnpackSizes;       // for all coders in all folders\r
-\r
-  Byte *CodersData;\r
-} CSzAr;\r
-\r
-UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex);\r
-\r
-SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex,\r
-    ILookInStream *stream, UInt64 startPos,\r
-    Byte *outBuffer, size_t outSize,\r
-    ISzAlloc *allocMain);\r
-\r
-typedef struct\r
-{\r
-  CSzAr db;\r
-\r
-  UInt64 startPosAfterHeader;\r
-  UInt64 dataPos;\r
-  \r
-  UInt32 NumFiles;\r
-\r
-  UInt64 *UnpackPositions;  // NumFiles + 1\r
-  // Byte *IsEmptyFiles;\r
-  Byte *IsDirs;\r
-  CSzBitUi32s CRCs;\r
-\r
-  CSzBitUi32s Attribs;\r
-  // CSzBitUi32s Parents;\r
-  CSzBitUi64s MTime;\r
-  CSzBitUi64s CTime;\r
-\r
-  UInt32 *FolderToFile;   // NumFolders + 1\r
-  UInt32 *FileToFolder;   // NumFiles\r
-\r
-  size_t *FileNameOffsets; /* in 2-byte steps */\r
-  Byte *FileNames;  /* UTF-16-LE */\r
-} CSzArEx;\r
-\r
-#define SzArEx_IsDir(p, i) (SzBitArray_Check((p)->IsDirs, i))\r
-\r
-#define SzArEx_GetFileSize(p, i) ((p)->UnpackPositions[(i) + 1] - (p)->UnpackPositions[i])\r
-\r
-void SzArEx_Init(CSzArEx *p);\r
-void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc);\r
-UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder);\r
-int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *resSize);\r
-\r
-/*\r
-if dest == NULL, the return value specifies the required size of the buffer,\r
-  in 16-bit characters, including the null-terminating character.\r
-if dest != NULL, the return value specifies the number of 16-bit characters that\r
-  are written to the dest, including the null-terminating character. */\r
-\r
-size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest);\r
-\r
-/*\r
-size_t SzArEx_GetFullNameLen(const CSzArEx *p, size_t fileIndex);\r
-UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest);\r
-*/\r
-\r
-\r
-\r
-/*\r
-  SzArEx_Extract extracts file from archive\r
-\r
-  *outBuffer must be 0 before first call for each new archive.\r
-\r
-  Extracting cache:\r
-    If you need to decompress more than one file, you can send\r
-    these values from previous call:\r
-      *blockIndex,\r
-      *outBuffer,\r
-      *outBufferSize\r
-    You can consider "*outBuffer" as cache of solid block. If your archive is solid,\r
-    it will increase decompression speed.\r
-  \r
-    If you use external function, you can declare these 3 cache variables\r
-    (blockIndex, outBuffer, outBufferSize) as static in that external function.\r
-    \r
-    Free *outBuffer and set *outBuffer to 0, if you want to flush cache.\r
-*/\r
-\r
-SRes SzArEx_Extract(\r
-    const CSzArEx *db,\r
-    ILookInStream *inStream,\r
-    UInt32 fileIndex,         /* index of file */\r
-    UInt32 *blockIndex,       /* index of solid block */\r
-    Byte **outBuffer,         /* pointer to pointer to output buffer (allocated with allocMain) */\r
-    size_t *outBufferSize,    /* buffer size for output buffer */\r
-    size_t *offset,           /* offset of stream for required file in *outBuffer */\r
-    size_t *outSizeProcessed, /* size of file in *outBuffer */\r
-    ISzAlloc *allocMain,\r
-    ISzAlloc *allocTemp);\r
-\r
-\r
-/*\r
-SzArEx_Open Errors:\r
-SZ_ERROR_NO_ARCHIVE\r
-SZ_ERROR_ARCHIVE\r
-SZ_ERROR_UNSUPPORTED\r
-SZ_ERROR_MEM\r
-SZ_ERROR_CRC\r
-SZ_ERROR_INPUT_EOF\r
-SZ_ERROR_FAIL\r
-*/\r
-\r
-SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream,\r
-    ISzAlloc *allocMain, ISzAlloc *allocTemp);\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/7zAlloc.c b/deps/lzma-16.04/C/7zAlloc.c
deleted file mode 100644 (file)
index 360da05..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/* 7zAlloc.c -- Allocation functions\r
-2015-11-09 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "7zAlloc.h"\r
-\r
-/* #define _SZ_ALLOC_DEBUG */\r
-/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */\r
-\r
-#ifdef _SZ_ALLOC_DEBUG\r
-\r
-#ifdef _WIN32\r
-#include <windows.h>\r
-#endif\r
-\r
-#include <stdio.h>\r
-int g_allocCount = 0;\r
-int g_allocCountTemp = 0;\r
-\r
-#endif\r
-\r
-void *SzAlloc(void *p, size_t size)\r
-{\r
-  UNUSED_VAR(p);\r
-  if (size == 0)\r
-    return 0;\r
-  #ifdef _SZ_ALLOC_DEBUG\r
-  fprintf(stderr, "\nAlloc %10u bytes; count = %10d", (unsigned)size, g_allocCount);\r
-  g_allocCount++;\r
-  #endif\r
-  return malloc(size);\r
-}\r
-\r
-void SzFree(void *p, void *address)\r
-{\r
-  UNUSED_VAR(p);\r
-  #ifdef _SZ_ALLOC_DEBUG\r
-  if (address != 0)\r
-  {\r
-    g_allocCount--;\r
-    fprintf(stderr, "\nFree; count = %10d", g_allocCount);\r
-  }\r
-  #endif\r
-  free(address);\r
-}\r
-\r
-void *SzAllocTemp(void *p, size_t size)\r
-{\r
-  UNUSED_VAR(p);\r
-  if (size == 0)\r
-    return 0;\r
-  #ifdef _SZ_ALLOC_DEBUG\r
-  fprintf(stderr, "\nAlloc_temp %10u bytes;  count = %10d", (unsigned)size, g_allocCountTemp);\r
-  g_allocCountTemp++;\r
-  #ifdef _WIN32\r
-  return HeapAlloc(GetProcessHeap(), 0, size);\r
-  #endif\r
-  #endif\r
-  return malloc(size);\r
-}\r
-\r
-void SzFreeTemp(void *p, void *address)\r
-{\r
-  UNUSED_VAR(p);\r
-  #ifdef _SZ_ALLOC_DEBUG\r
-  if (address != 0)\r
-  {\r
-    g_allocCountTemp--;\r
-    fprintf(stderr, "\nFree_temp; count = %10d", g_allocCountTemp);\r
-  }\r
-  #ifdef _WIN32\r
-  HeapFree(GetProcessHeap(), 0, address);\r
-  return;\r
-  #endif\r
-  #endif\r
-  free(address);\r
-}\r
diff --git a/deps/lzma-16.04/C/7zAlloc.h b/deps/lzma-16.04/C/7zAlloc.h
deleted file mode 100644 (file)
index 4d7502f..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/* 7zAlloc.h -- Allocation functions\r
-2013-03-25 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __7Z_ALLOC_H\r
-#define __7Z_ALLOC_H\r
-\r
-#include <stdlib.h>\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-void *SzAlloc(void *p, size_t size);\r
-void SzFree(void *p, void *address);\r
-\r
-void *SzAllocTemp(void *p, size_t size);\r
-void SzFreeTemp(void *p, void *address);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/7zArcIn.c b/deps/lzma-16.04/C/7zArcIn.c
deleted file mode 100644 (file)
index c324c37..0000000
+++ /dev/null
@@ -1,1771 +0,0 @@
-/* 7zArcIn.c -- 7z Input functions\r
-2016-05-16 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include <string.h>\r
-\r
-#include "7z.h"\r
-#include "7zBuf.h"\r
-#include "7zCrc.h"\r
-#include "CpuArch.h"\r
-\r
-#define MY_ALLOC(T, p, size, alloc) { \\r
-  if ((p = (T *)IAlloc_Alloc(alloc, (size) * sizeof(T))) == NULL) return SZ_ERROR_MEM; }\r
-\r
-#define MY_ALLOC_ZE(T, p, size, alloc) { if ((size) == 0) p = NULL; else MY_ALLOC(T, p, size, alloc) }\r
-\r
-#define MY_ALLOC_AND_CPY(to, size, from, alloc) \\r
-  { MY_ALLOC(Byte, to, size, alloc); memcpy(to, from, size); }\r
-\r
-#define MY_ALLOC_ZE_AND_CPY(to, size, from, alloc) \\r
-  { if ((size) == 0) p = NULL; else { MY_ALLOC_AND_CPY(to, size, from, alloc) } }\r
-\r
-#define k7zMajorVersion 0\r
-\r
-enum EIdEnum\r
-{\r
-  k7zIdEnd,\r
-  k7zIdHeader,\r
-  k7zIdArchiveProperties,\r
-  k7zIdAdditionalStreamsInfo,\r
-  k7zIdMainStreamsInfo,\r
-  k7zIdFilesInfo,\r
-  k7zIdPackInfo,\r
-  k7zIdUnpackInfo,\r
-  k7zIdSubStreamsInfo,\r
-  k7zIdSize,\r
-  k7zIdCRC,\r
-  k7zIdFolder,\r
-  k7zIdCodersUnpackSize,\r
-  k7zIdNumUnpackStream,\r
-  k7zIdEmptyStream,\r
-  k7zIdEmptyFile,\r
-  k7zIdAnti,\r
-  k7zIdName,\r
-  k7zIdCTime,\r
-  k7zIdATime,\r
-  k7zIdMTime,\r
-  k7zIdWinAttrib,\r
-  k7zIdComment,\r
-  k7zIdEncodedHeader,\r
-  k7zIdStartPos,\r
-  k7zIdDummy\r
-  // k7zNtSecure,\r
-  // k7zParent,\r
-  // k7zIsReal\r
-};\r
-\r
-const Byte k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C};\r
-\r
-#define SzBitUi32s_Init(p) { (p)->Defs = NULL; (p)->Vals = NULL; }\r
-\r
-static SRes SzBitUi32s_Alloc(CSzBitUi32s *p, size_t num, ISzAlloc *alloc)\r
-{\r
-  if (num == 0)\r
-  {\r
-    p->Defs = NULL;\r
-    p->Vals = NULL;\r
-  }\r
-  else\r
-  {\r
-    MY_ALLOC(Byte, p->Defs, (num + 7) >> 3, alloc);\r
-    MY_ALLOC(UInt32, p->Vals, num, alloc);\r
-  }\r
-  return SZ_OK;\r
-}\r
-\r
-void SzBitUi32s_Free(CSzBitUi32s *p, ISzAlloc *alloc)\r
-{\r
-  IAlloc_Free(alloc, p->Defs); p->Defs = NULL;\r
-  IAlloc_Free(alloc, p->Vals); p->Vals = NULL;\r
-}\r
-\r
-#define SzBitUi64s_Init(p) { (p)->Defs = NULL; (p)->Vals = NULL; }\r
-\r
-void SzBitUi64s_Free(CSzBitUi64s *p, ISzAlloc *alloc)\r
-{\r
-  IAlloc_Free(alloc, p->Defs); p->Defs = NULL;\r
-  IAlloc_Free(alloc, p->Vals); p->Vals = NULL;\r
-}\r
-\r
-\r
-static void SzAr_Init(CSzAr *p)\r
-{\r
-  p->NumPackStreams = 0;\r
-  p->NumFolders = 0;\r
-  \r
-  p->PackPositions = NULL;\r
-  SzBitUi32s_Init(&p->FolderCRCs);\r
-\r
-  p->FoCodersOffsets = NULL;\r
-  p->FoStartPackStreamIndex = NULL;\r
-  p->FoToCoderUnpackSizes = NULL;\r
-  p->FoToMainUnpackSizeIndex = NULL;\r
-  p->CoderUnpackSizes = NULL;\r
-\r
-  p->CodersData = NULL;\r
-}\r
-\r
-static void SzAr_Free(CSzAr *p, ISzAlloc *alloc)\r
-{\r
-  IAlloc_Free(alloc, p->PackPositions);\r
-  SzBitUi32s_Free(&p->FolderCRCs, alloc);\r
\r
-  IAlloc_Free(alloc, p->FoCodersOffsets);\r
-  IAlloc_Free(alloc, p->FoStartPackStreamIndex);\r
-  IAlloc_Free(alloc, p->FoToCoderUnpackSizes);\r
-  IAlloc_Free(alloc, p->FoToMainUnpackSizeIndex);\r
-  IAlloc_Free(alloc, p->CoderUnpackSizes);\r
-  \r
-  IAlloc_Free(alloc, p->CodersData);\r
-\r
-  SzAr_Init(p);\r
-}\r
-\r
-\r
-void SzArEx_Init(CSzArEx *p)\r
-{\r
-  SzAr_Init(&p->db);\r
-  \r
-  p->NumFiles = 0;\r
-  p->dataPos = 0;\r
-  \r
-  p->UnpackPositions = NULL;\r
-  p->IsDirs = NULL;\r
-  \r
-  p->FolderToFile = NULL;\r
-  p->FileToFolder = NULL;\r
-  \r
-  p->FileNameOffsets = NULL;\r
-  p->FileNames = NULL;\r
-  \r
-  SzBitUi32s_Init(&p->CRCs);\r
-  SzBitUi32s_Init(&p->Attribs);\r
-  // SzBitUi32s_Init(&p->Parents);\r
-  SzBitUi64s_Init(&p->MTime);\r
-  SzBitUi64s_Init(&p->CTime);\r
-}\r
-\r
-void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc)\r
-{\r
-  IAlloc_Free(alloc, p->UnpackPositions);\r
-  IAlloc_Free(alloc, p->IsDirs);\r
-\r
-  IAlloc_Free(alloc, p->FolderToFile);\r
-  IAlloc_Free(alloc, p->FileToFolder);\r
-\r
-  IAlloc_Free(alloc, p->FileNameOffsets);\r
-  IAlloc_Free(alloc, p->FileNames);\r
-\r
-  SzBitUi32s_Free(&p->CRCs, alloc);\r
-  SzBitUi32s_Free(&p->Attribs, alloc);\r
-  // SzBitUi32s_Free(&p->Parents, alloc);\r
-  SzBitUi64s_Free(&p->MTime, alloc);\r
-  SzBitUi64s_Free(&p->CTime, alloc);\r
-  \r
-  SzAr_Free(&p->db, alloc);\r
-  SzArEx_Init(p);\r
-}\r
-\r
-\r
-static int TestSignatureCandidate(const Byte *testBytes)\r
-{\r
-  unsigned i;\r
-  for (i = 0; i < k7zSignatureSize; i++)\r
-    if (testBytes[i] != k7zSignature[i])\r
-      return 0;\r
-  return 1;\r
-}\r
-\r
-#define SzData_Clear(p) { (p)->Data = NULL; (p)->Size = 0; }\r
-\r
-#define SZ_READ_BYTE_SD(_sd_, dest) if ((_sd_)->Size == 0) return SZ_ERROR_ARCHIVE; (_sd_)->Size--; dest = *(_sd_)->Data++;\r
-#define SZ_READ_BYTE(dest) SZ_READ_BYTE_SD(sd, dest)\r
-#define SZ_READ_BYTE_2(dest) if (sd.Size == 0) return SZ_ERROR_ARCHIVE; sd.Size--; dest = *sd.Data++;\r
-\r
-#define SKIP_DATA(sd, size) { sd->Size -= (size_t)(size); sd->Data += (size_t)(size); }\r
-#define SKIP_DATA2(sd, size) { sd.Size -= (size_t)(size); sd.Data += (size_t)(size); }\r
-\r
-#define SZ_READ_32(dest) if (sd.Size < 4) return SZ_ERROR_ARCHIVE; \\r
-   dest = GetUi32(sd.Data); SKIP_DATA2(sd, 4);\r
-\r
-static MY_NO_INLINE SRes ReadNumber(CSzData *sd, UInt64 *value)\r
-{\r
-  Byte firstByte, mask;\r
-  unsigned i;\r
-  UInt32 v;\r
-\r
-  SZ_READ_BYTE(firstByte);\r
-  if ((firstByte & 0x80) == 0)\r
-  {\r
-    *value = firstByte;\r
-    return SZ_OK;\r
-  }\r
-  SZ_READ_BYTE(v);\r
-  if ((firstByte & 0x40) == 0)\r
-  {\r
-    *value = (((UInt32)firstByte & 0x3F) << 8) | v;\r
-    return SZ_OK;\r
-  }\r
-  SZ_READ_BYTE(mask);\r
-  *value = v | ((UInt32)mask << 8);\r
-  mask = 0x20;\r
-  for (i = 2; i < 8; i++)\r
-  {\r
-    Byte b;\r
-    if ((firstByte & mask) == 0)\r
-    {\r
-      UInt64 highPart = (unsigned)firstByte & (unsigned)(mask - 1);\r
-      *value |= (highPart << (8 * i));\r
-      return SZ_OK;\r
-    }\r
-    SZ_READ_BYTE(b);\r
-    *value |= ((UInt64)b << (8 * i));\r
-    mask >>= 1;\r
-  }\r
-  return SZ_OK;\r
-}\r
-\r
-\r
-static MY_NO_INLINE SRes SzReadNumber32(CSzData *sd, UInt32 *value)\r
-{\r
-  Byte firstByte;\r
-  UInt64 value64;\r
-  if (sd->Size == 0)\r
-    return SZ_ERROR_ARCHIVE;\r
-  firstByte = *sd->Data;\r
-  if ((firstByte & 0x80) == 0)\r
-  {\r
-    *value = firstByte;\r
-    sd->Data++;\r
-    sd->Size--;\r
-    return SZ_OK;\r
-  }\r
-  RINOK(ReadNumber(sd, &value64));\r
-  if (value64 >= (UInt32)0x80000000 - 1)\r
-    return SZ_ERROR_UNSUPPORTED;\r
-  if (value64 >= ((UInt64)(1) << ((sizeof(size_t) - 1) * 8 + 4)))\r
-    return SZ_ERROR_UNSUPPORTED;\r
-  *value = (UInt32)value64;\r
-  return SZ_OK;\r
-}\r
-\r
-#define ReadID(sd, value) ReadNumber(sd, value)\r
-\r
-static SRes SkipData(CSzData *sd)\r
-{\r
-  UInt64 size;\r
-  RINOK(ReadNumber(sd, &size));\r
-  if (size > sd->Size)\r
-    return SZ_ERROR_ARCHIVE;\r
-  SKIP_DATA(sd, size);\r
-  return SZ_OK;\r
-}\r
-\r
-static SRes WaitId(CSzData *sd, UInt32 id)\r
-{\r
-  for (;;)\r
-  {\r
-    UInt64 type;\r
-    RINOK(ReadID(sd, &type));\r
-    if (type == id)\r
-      return SZ_OK;\r
-    if (type == k7zIdEnd)\r
-      return SZ_ERROR_ARCHIVE;\r
-    RINOK(SkipData(sd));\r
-  }\r
-}\r
-\r
-static SRes RememberBitVector(CSzData *sd, UInt32 numItems, const Byte **v)\r
-{\r
-  UInt32 numBytes = (numItems + 7) >> 3;\r
-  if (numBytes > sd->Size)\r
-    return SZ_ERROR_ARCHIVE;\r
-  *v = sd->Data;\r
-  SKIP_DATA(sd, numBytes);\r
-  return SZ_OK;\r
-}\r
-\r
-static UInt32 CountDefinedBits(const Byte *bits, UInt32 numItems)\r
-{\r
-  Byte b = 0;\r
-  unsigned m = 0;\r
-  UInt32 sum = 0;\r
-  for (; numItems != 0; numItems--)\r
-  {\r
-    if (m == 0)\r
-    {\r
-      b = *bits++;\r
-      m = 8;\r
-    }\r
-    m--;\r
-    sum += ((b >> m) & 1);\r
-  }\r
-  return sum;\r
-}\r
-\r
-static MY_NO_INLINE SRes ReadBitVector(CSzData *sd, UInt32 numItems, Byte **v, ISzAlloc *alloc)\r
-{\r
-  Byte allAreDefined;\r
-  Byte *v2;\r
-  UInt32 numBytes = (numItems + 7) >> 3;\r
-  *v = NULL;\r
-  SZ_READ_BYTE(allAreDefined);\r
-  if (numBytes == 0)\r
-    return SZ_OK;\r
-  if (allAreDefined == 0)\r
-  {\r
-    if (numBytes > sd->Size)\r
-      return SZ_ERROR_ARCHIVE;\r
-    MY_ALLOC_AND_CPY(*v, numBytes, sd->Data, alloc);\r
-    SKIP_DATA(sd, numBytes);\r
-    return SZ_OK;\r
-  }\r
-  MY_ALLOC(Byte, *v, numBytes, alloc);\r
-  v2 = *v;\r
-  memset(v2, 0xFF, (size_t)numBytes);\r
-  {\r
-    unsigned numBits = (unsigned)numItems & 7;\r
-    if (numBits != 0)\r
-      v2[numBytes - 1] = (Byte)((((UInt32)1 << numBits) - 1) << (8 - numBits));\r
-  }\r
-  return SZ_OK;\r
-}\r
-\r
-static MY_NO_INLINE SRes ReadUi32s(CSzData *sd2, UInt32 numItems, CSzBitUi32s *crcs, ISzAlloc *alloc)\r
-{\r
-  UInt32 i;\r
-  CSzData sd;\r
-  UInt32 *vals;\r
-  const Byte *defs;\r
-  MY_ALLOC_ZE(UInt32, crcs->Vals, numItems, alloc);\r
-  sd = *sd2;\r
-  defs = crcs->Defs;\r
-  vals = crcs->Vals;\r
-  for (i = 0; i < numItems; i++)\r
-    if (SzBitArray_Check(defs, i))\r
-    {\r
-      SZ_READ_32(vals[i]);\r
-    }\r
-    else\r
-      vals[i] = 0;\r
-  *sd2 = sd;\r
-  return SZ_OK;\r
-}\r
-\r
-static SRes ReadBitUi32s(CSzData *sd, UInt32 numItems, CSzBitUi32s *crcs, ISzAlloc *alloc)\r
-{\r
-  SzBitUi32s_Free(crcs, alloc);\r
-  RINOK(ReadBitVector(sd, numItems, &crcs->Defs, alloc));\r
-  return ReadUi32s(sd, numItems, crcs, alloc);\r
-}\r
-\r
-static SRes SkipBitUi32s(CSzData *sd, UInt32 numItems)\r
-{\r
-  Byte allAreDefined;\r
-  UInt32 numDefined = numItems;\r
-  SZ_READ_BYTE(allAreDefined);\r
-  if (!allAreDefined)\r
-  {\r
-    size_t numBytes = (numItems + 7) >> 3;\r
-    if (numBytes > sd->Size)\r
-      return SZ_ERROR_ARCHIVE;\r
-    numDefined = CountDefinedBits(sd->Data, numItems);\r
-    SKIP_DATA(sd, numBytes);\r
-  }\r
-  if (numDefined > (sd->Size >> 2))\r
-    return SZ_ERROR_ARCHIVE;\r
-  SKIP_DATA(sd, (size_t)numDefined * 4);\r
-  return SZ_OK;\r
-}\r
-\r
-static SRes ReadPackInfo(CSzAr *p, CSzData *sd, ISzAlloc *alloc)\r
-{\r
-  RINOK(SzReadNumber32(sd, &p->NumPackStreams));\r
-\r
-  RINOK(WaitId(sd, k7zIdSize));\r
-  MY_ALLOC(UInt64, p->PackPositions, (size_t)p->NumPackStreams + 1, alloc);\r
-  {\r
-    UInt64 sum = 0;\r
-    UInt32 i;\r
-    UInt32 numPackStreams = p->NumPackStreams;\r
-    for (i = 0; i < numPackStreams; i++)\r
-    {\r
-      UInt64 packSize;\r
-      p->PackPositions[i] = sum;\r
-      RINOK(ReadNumber(sd, &packSize));\r
-      sum += packSize;\r
-      if (sum < packSize)\r
-        return SZ_ERROR_ARCHIVE;\r
-    }\r
-    p->PackPositions[i] = sum;\r
-  }\r
-\r
-  for (;;)\r
-  {\r
-    UInt64 type;\r
-    RINOK(ReadID(sd, &type));\r
-    if (type == k7zIdEnd)\r
-      return SZ_OK;\r
-    if (type == k7zIdCRC)\r
-    {\r
-      /* CRC of packed streams is unused now */\r
-      RINOK(SkipBitUi32s(sd, p->NumPackStreams));\r
-      continue;\r
-    }\r
-    RINOK(SkipData(sd));\r
-  }\r
-}\r
-\r
-/*\r
-static SRes SzReadSwitch(CSzData *sd)\r
-{\r
-  Byte external;\r
-  RINOK(SzReadByte(sd, &external));\r
-  return (external == 0) ? SZ_OK: SZ_ERROR_UNSUPPORTED;\r
-}\r
-*/\r
-\r
-#define k_NumCodersStreams_in_Folder_MAX (SZ_NUM_BONDS_IN_FOLDER_MAX + SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX)\r
-\r
-SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd)\r
-{\r
-  UInt32 numCoders, i;\r
-  UInt32 numInStreams = 0;\r
-  const Byte *dataStart = sd->Data;\r
-\r
-  f->NumCoders = 0;\r
-  f->NumBonds = 0;\r
-  f->NumPackStreams = 0;\r
-  f->UnpackStream = 0;\r
-  \r
-  RINOK(SzReadNumber32(sd, &numCoders));\r
-  if (numCoders == 0 || numCoders > SZ_NUM_CODERS_IN_FOLDER_MAX)\r
-    return SZ_ERROR_UNSUPPORTED;\r
-  \r
-  for (i = 0; i < numCoders; i++)\r
-  {\r
-    Byte mainByte;\r
-    CSzCoderInfo *coder = f->Coders + i;\r
-    unsigned idSize, j;\r
-    UInt64 id;\r
-    \r
-    SZ_READ_BYTE(mainByte);\r
-    if ((mainByte & 0xC0) != 0)\r
-      return SZ_ERROR_UNSUPPORTED;\r
-    \r
-    idSize = (unsigned)(mainByte & 0xF);\r
-    if (idSize > sizeof(id))\r
-      return SZ_ERROR_UNSUPPORTED;\r
-    if (idSize > sd->Size)\r
-      return SZ_ERROR_ARCHIVE;\r
-    id = 0;\r
-    for (j = 0; j < idSize; j++)\r
-    {\r
-      id = ((id << 8) | *sd->Data);\r
-      sd->Data++;\r
-      sd->Size--;\r
-    }\r
-    if (id > (UInt32)0xFFFFFFFF)\r
-      return SZ_ERROR_UNSUPPORTED;\r
-    coder->MethodID = (UInt32)id;\r
-    \r
-    coder->NumStreams = 1;\r
-    coder->PropsOffset = 0;\r
-    coder->PropsSize = 0;\r
-    \r
-    if ((mainByte & 0x10) != 0)\r
-    {\r
-      UInt32 numStreams;\r
-      \r
-      RINOK(SzReadNumber32(sd, &numStreams));\r
-      if (numStreams > k_NumCodersStreams_in_Folder_MAX)\r
-        return SZ_ERROR_UNSUPPORTED;\r
-      coder->NumStreams = (Byte)numStreams;\r
-\r
-      RINOK(SzReadNumber32(sd, &numStreams));\r
-      if (numStreams != 1)\r
-        return SZ_ERROR_UNSUPPORTED;\r
-    }\r
-\r
-    numInStreams += coder->NumStreams;\r
-\r
-    if (numInStreams > k_NumCodersStreams_in_Folder_MAX)\r
-      return SZ_ERROR_UNSUPPORTED;\r
-\r
-    if ((mainByte & 0x20) != 0)\r
-    {\r
-      UInt32 propsSize = 0;\r
-      RINOK(SzReadNumber32(sd, &propsSize));\r
-      if (propsSize > sd->Size)\r
-        return SZ_ERROR_ARCHIVE;\r
-      if (propsSize >= 0x80)\r
-        return SZ_ERROR_UNSUPPORTED;\r
-      coder->PropsOffset = sd->Data - dataStart;\r
-      coder->PropsSize = (Byte)propsSize;\r
-      sd->Data += (size_t)propsSize;\r
-      sd->Size -= (size_t)propsSize;\r
-    }\r
-  }\r
-\r
-  /*\r
-  if (numInStreams == 1 && numCoders == 1)\r
-  {\r
-    f->NumPackStreams = 1;\r
-    f->PackStreams[0] = 0;\r
-  }\r
-  else\r
-  */\r
-  {\r
-    Byte streamUsed[k_NumCodersStreams_in_Folder_MAX];\r
-    UInt32 numBonds, numPackStreams;\r
-    \r
-    numBonds = numCoders - 1;\r
-    if (numInStreams < numBonds)\r
-      return SZ_ERROR_ARCHIVE;\r
-    if (numBonds > SZ_NUM_BONDS_IN_FOLDER_MAX)\r
-      return SZ_ERROR_UNSUPPORTED;\r
-    f->NumBonds = numBonds;\r
-    \r
-    numPackStreams = numInStreams - numBonds;\r
-    if (numPackStreams > SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX)\r
-      return SZ_ERROR_UNSUPPORTED;\r
-    f->NumPackStreams = numPackStreams;\r
-  \r
-    for (i = 0; i < numInStreams; i++)\r
-      streamUsed[i] = False;\r
-    \r
-    if (numBonds != 0)\r
-    {\r
-      Byte coderUsed[SZ_NUM_CODERS_IN_FOLDER_MAX];\r
-\r
-      for (i = 0; i < numCoders; i++)\r
-        coderUsed[i] = False;\r
-      \r
-      for (i = 0; i < numBonds; i++)\r
-      {\r
-        CSzBond *bp = f->Bonds + i;\r
-        \r
-        RINOK(SzReadNumber32(sd, &bp->InIndex));\r
-        if (bp->InIndex >= numInStreams || streamUsed[bp->InIndex])\r
-          return SZ_ERROR_ARCHIVE;\r
-        streamUsed[bp->InIndex] = True;\r
-        \r
-        RINOK(SzReadNumber32(sd, &bp->OutIndex));\r
-        if (bp->OutIndex >= numCoders || coderUsed[bp->OutIndex])\r
-          return SZ_ERROR_ARCHIVE;\r
-        coderUsed[bp->OutIndex] = True;\r
-      }\r
-      \r
-      for (i = 0; i < numCoders; i++)\r
-        if (!coderUsed[i])\r
-        {\r
-          f->UnpackStream = i;\r
-          break;\r
-        }\r
-      \r
-      if (i == numCoders)\r
-        return SZ_ERROR_ARCHIVE;\r
-    }\r
-    \r
-    if (numPackStreams == 1)\r
-    {\r
-      for (i = 0; i < numInStreams; i++)\r
-        if (!streamUsed[i])\r
-          break;\r
-      if (i == numInStreams)\r
-        return SZ_ERROR_ARCHIVE;\r
-      f->PackStreams[0] = i;\r
-    }\r
-    else\r
-      for (i = 0; i < numPackStreams; i++)\r
-      {\r
-        UInt32 index;\r
-        RINOK(SzReadNumber32(sd, &index));\r
-        if (index >= numInStreams || streamUsed[index])\r
-          return SZ_ERROR_ARCHIVE;\r
-        streamUsed[index] = True;\r
-        f->PackStreams[i] = index;\r
-      }\r
-  }\r
-\r
-  f->NumCoders = numCoders;\r
-\r
-  return SZ_OK;\r
-}\r
-\r
-\r
-static MY_NO_INLINE SRes SkipNumbers(CSzData *sd2, UInt32 num)\r
-{\r
-  CSzData sd;\r
-  sd = *sd2;\r
-  for (; num != 0; num--)\r
-  {\r
-    Byte firstByte, mask;\r
-    unsigned i;\r
-    SZ_READ_BYTE_2(firstByte);\r
-    if ((firstByte & 0x80) == 0)\r
-      continue;\r
-    if ((firstByte & 0x40) == 0)\r
-    {\r
-      if (sd.Size == 0)\r
-        return SZ_ERROR_ARCHIVE;\r
-      sd.Size--;\r
-      sd.Data++;\r
-      continue;\r
-    }\r
-    mask = 0x20;\r
-    for (i = 2; i < 8 && (firstByte & mask) != 0; i++)\r
-      mask >>= 1;\r
-    if (i > sd.Size)\r
-      return SZ_ERROR_ARCHIVE;\r
-    SKIP_DATA2(sd, i);\r
-  }\r
-  *sd2 = sd;\r
-  return SZ_OK;\r
-}\r
-\r
-\r
-#define k_Scan_NumCoders_MAX 64\r
-#define k_Scan_NumCodersStreams_in_Folder_MAX 64\r
-\r
-\r
-static SRes ReadUnpackInfo(CSzAr *p,\r
-    CSzData *sd2,\r
-    UInt32 numFoldersMax,\r
-    const CBuf *tempBufs, UInt32 numTempBufs,\r
-    ISzAlloc *alloc)\r
-{\r
-  CSzData sd;\r
-  \r
-  UInt32 fo, numFolders, numCodersOutStreams, packStreamIndex;\r
-  const Byte *startBufPtr;\r
-  Byte external;\r
-  \r
-  RINOK(WaitId(sd2, k7zIdFolder));\r
-  \r
-  RINOK(SzReadNumber32(sd2, &numFolders));\r
-  if (numFolders > numFoldersMax)\r
-    return SZ_ERROR_UNSUPPORTED;\r
-  p->NumFolders = numFolders;\r
-\r
-  SZ_READ_BYTE_SD(sd2, external);\r
-  if (external == 0)\r
-    sd = *sd2;\r
-  else\r
-  {\r
-    UInt32 index;\r
-    RINOK(SzReadNumber32(sd2, &index));\r
-    if (index >= numTempBufs)\r
-      return SZ_ERROR_ARCHIVE;\r
-    sd.Data = tempBufs[index].data;\r
-    sd.Size = tempBufs[index].size;\r
-  }\r
-  \r
-  MY_ALLOC(size_t, p->FoCodersOffsets, (size_t)numFolders + 1, alloc);\r
-  MY_ALLOC(UInt32, p->FoStartPackStreamIndex, (size_t)numFolders + 1, alloc);\r
-  MY_ALLOC(UInt32, p->FoToCoderUnpackSizes, (size_t)numFolders + 1, alloc);\r
-  MY_ALLOC(Byte, p->FoToMainUnpackSizeIndex, (size_t)numFolders, alloc);\r
-  \r
-  startBufPtr = sd.Data;\r
-  \r
-  packStreamIndex = 0;\r
-  numCodersOutStreams = 0;\r
-\r
-  for (fo = 0; fo < numFolders; fo++)\r
-  {\r
-    UInt32 numCoders, ci, numInStreams = 0;\r
-    \r
-    p->FoCodersOffsets[fo] = sd.Data - startBufPtr;\r
-    \r
-    RINOK(SzReadNumber32(&sd, &numCoders));\r
-    if (numCoders == 0 || numCoders > k_Scan_NumCoders_MAX)\r
-      return SZ_ERROR_UNSUPPORTED;\r
-    \r
-    for (ci = 0; ci < numCoders; ci++)\r
-    {\r
-      Byte mainByte;\r
-      unsigned idSize;\r
-      UInt32 coderInStreams;\r
-      \r
-      SZ_READ_BYTE_2(mainByte);\r
-      if ((mainByte & 0xC0) != 0)\r
-        return SZ_ERROR_UNSUPPORTED;\r
-      idSize = (mainByte & 0xF);\r
-      if (idSize > 8)\r
-        return SZ_ERROR_UNSUPPORTED;\r
-      if (idSize > sd.Size)\r
-        return SZ_ERROR_ARCHIVE;\r
-      SKIP_DATA2(sd, idSize);\r
-      \r
-      coderInStreams = 1;\r
-      \r
-      if ((mainByte & 0x10) != 0)\r
-      {\r
-        UInt32 coderOutStreams;\r
-        RINOK(SzReadNumber32(&sd, &coderInStreams));\r
-        RINOK(SzReadNumber32(&sd, &coderOutStreams));\r
-        if (coderInStreams > k_Scan_NumCodersStreams_in_Folder_MAX || coderOutStreams != 1)\r
-          return SZ_ERROR_UNSUPPORTED;\r
-      }\r
-      \r
-      numInStreams += coderInStreams;\r
-\r
-      if ((mainByte & 0x20) != 0)\r
-      {\r
-        UInt32 propsSize;\r
-        RINOK(SzReadNumber32(&sd, &propsSize));\r
-        if (propsSize > sd.Size)\r
-          return SZ_ERROR_ARCHIVE;\r
-        SKIP_DATA2(sd, propsSize);\r
-      }\r
-    }\r
-    \r
-    {\r
-      UInt32 indexOfMainStream = 0;\r
-      UInt32 numPackStreams = 1;\r
-      \r
-      if (numCoders != 1 || numInStreams != 1)\r
-      {\r
-        Byte streamUsed[k_Scan_NumCodersStreams_in_Folder_MAX];\r
-        Byte coderUsed[k_Scan_NumCoders_MAX];\r
-    \r
-        UInt32 i;\r
-        UInt32 numBonds = numCoders - 1;\r
-        if (numInStreams < numBonds)\r
-          return SZ_ERROR_ARCHIVE;\r
-        \r
-        if (numInStreams > k_Scan_NumCodersStreams_in_Folder_MAX)\r
-          return SZ_ERROR_UNSUPPORTED;\r
-        \r
-        for (i = 0; i < numInStreams; i++)\r
-          streamUsed[i] = False;\r
-        for (i = 0; i < numCoders; i++)\r
-          coderUsed[i] = False;\r
-        \r
-        for (i = 0; i < numBonds; i++)\r
-        {\r
-          UInt32 index;\r
-          \r
-          RINOK(SzReadNumber32(&sd, &index));\r
-          if (index >= numInStreams || streamUsed[index])\r
-            return SZ_ERROR_ARCHIVE;\r
-          streamUsed[index] = True;\r
-          \r
-          RINOK(SzReadNumber32(&sd, &index));\r
-          if (index >= numCoders || coderUsed[index])\r
-            return SZ_ERROR_ARCHIVE;\r
-          coderUsed[index] = True;\r
-        }\r
-        \r
-        numPackStreams = numInStreams - numBonds;\r
-        \r
-        if (numPackStreams != 1)\r
-          for (i = 0; i < numPackStreams; i++)\r
-          {\r
-            UInt32 index;\r
-            RINOK(SzReadNumber32(&sd, &index));\r
-            if (index >= numInStreams || streamUsed[index])\r
-              return SZ_ERROR_ARCHIVE;\r
-            streamUsed[index] = True;\r
-          }\r
-          \r
-        for (i = 0; i < numCoders; i++)\r
-          if (!coderUsed[i])\r
-          {\r
-            indexOfMainStream = i;\r
-            break;\r
-          }\r
\r
-        if (i == numCoders)\r
-          return SZ_ERROR_ARCHIVE;\r
-      }\r
-      \r
-      p->FoStartPackStreamIndex[fo] = packStreamIndex;\r
-      p->FoToCoderUnpackSizes[fo] = numCodersOutStreams;\r
-      p->FoToMainUnpackSizeIndex[fo] = (Byte)indexOfMainStream;\r
-      numCodersOutStreams += numCoders;\r
-      if (numCodersOutStreams < numCoders)\r
-        return SZ_ERROR_UNSUPPORTED;\r
-      if (numPackStreams > p->NumPackStreams - packStreamIndex)\r
-        return SZ_ERROR_ARCHIVE;\r
-      packStreamIndex += numPackStreams;\r
-    }\r
-  }\r
-\r
-  p->FoToCoderUnpackSizes[fo] = numCodersOutStreams;\r
-  \r
-  {\r
-    size_t dataSize = sd.Data - startBufPtr;\r
-    p->FoStartPackStreamIndex[fo] = packStreamIndex;\r
-    p->FoCodersOffsets[fo] = dataSize;\r
-    MY_ALLOC_ZE_AND_CPY(p->CodersData, dataSize, startBufPtr, alloc);\r
-  }\r
-  \r
-  if (external != 0)\r
-  {\r
-    if (sd.Size != 0)\r
-      return SZ_ERROR_ARCHIVE;\r
-    sd = *sd2;\r
-  }\r
-  \r
-  RINOK(WaitId(&sd, k7zIdCodersUnpackSize));\r
-  \r
-  MY_ALLOC_ZE(UInt64, p->CoderUnpackSizes, (size_t)numCodersOutStreams, alloc);\r
-  {\r
-    UInt32 i;\r
-    for (i = 0; i < numCodersOutStreams; i++)\r
-    {\r
-      RINOK(ReadNumber(&sd, p->CoderUnpackSizes + i));\r
-    }\r
-  }\r
-\r
-  for (;;)\r
-  {\r
-    UInt64 type;\r
-    RINOK(ReadID(&sd, &type));\r
-    if (type == k7zIdEnd)\r
-    {\r
-      *sd2 = sd;\r
-      return SZ_OK;\r
-    }\r
-    if (type == k7zIdCRC)\r
-    {\r
-      RINOK(ReadBitUi32s(&sd, numFolders, &p->FolderCRCs, alloc));\r
-      continue;\r
-    }\r
-    RINOK(SkipData(&sd));\r
-  }\r
-}\r
-\r
-\r
-UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex)\r
-{\r
-  return p->CoderUnpackSizes[p->FoToCoderUnpackSizes[folderIndex] + p->FoToMainUnpackSizeIndex[folderIndex]];\r
-}\r
-\r
-\r
-typedef struct\r
-{\r
-  UInt32 NumTotalSubStreams;\r
-  UInt32 NumSubDigests;\r
-  CSzData sdNumSubStreams;\r
-  CSzData sdSizes;\r
-  CSzData sdCRCs;\r
-} CSubStreamInfo;\r
-\r
-\r
-static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi)\r
-{\r
-  UInt64 type = 0;\r
-  UInt32 numSubDigests = 0;\r
-  UInt32 numFolders = p->NumFolders;\r
-  UInt32 numUnpackStreams = numFolders;\r
-  UInt32 numUnpackSizesInData = 0;\r
-\r
-  for (;;)\r
-  {\r
-    RINOK(ReadID(sd, &type));\r
-    if (type == k7zIdNumUnpackStream)\r
-    {\r
-      UInt32 i;\r
-      ssi->sdNumSubStreams.Data = sd->Data;\r
-      numUnpackStreams = 0;\r
-      numSubDigests = 0;\r
-      for (i = 0; i < numFolders; i++)\r
-      {\r
-        UInt32 numStreams;\r
-        RINOK(SzReadNumber32(sd, &numStreams));\r
-        if (numUnpackStreams > numUnpackStreams + numStreams)\r
-          return SZ_ERROR_UNSUPPORTED;\r
-        numUnpackStreams += numStreams;\r
-        if (numStreams != 0)\r
-          numUnpackSizesInData += (numStreams - 1);\r
-        if (numStreams != 1 || !SzBitWithVals_Check(&p->FolderCRCs, i))\r
-          numSubDigests += numStreams;\r
-      }\r
-      ssi->sdNumSubStreams.Size = sd->Data - ssi->sdNumSubStreams.Data;\r
-      continue;\r
-    }\r
-    if (type == k7zIdCRC || type == k7zIdSize || type == k7zIdEnd)\r
-      break;\r
-    RINOK(SkipData(sd));\r
-  }\r
-\r
-  if (!ssi->sdNumSubStreams.Data)\r
-  {\r
-    numSubDigests = numFolders;\r
-    if (p->FolderCRCs.Defs)\r
-      numSubDigests = numFolders - CountDefinedBits(p->FolderCRCs.Defs, numFolders);\r
-  }\r
-  \r
-  ssi->NumTotalSubStreams = numUnpackStreams;\r
-  ssi->NumSubDigests = numSubDigests;\r
-\r
-  if (type == k7zIdSize)\r
-  {\r
-    ssi->sdSizes.Data = sd->Data;\r
-    RINOK(SkipNumbers(sd, numUnpackSizesInData));\r
-    ssi->sdSizes.Size = sd->Data - ssi->sdSizes.Data;\r
-    RINOK(ReadID(sd, &type));\r
-  }\r
-\r
-  for (;;)\r
-  {\r
-    if (type == k7zIdEnd)\r
-      return SZ_OK;\r
-    if (type == k7zIdCRC)\r
-    {\r
-      ssi->sdCRCs.Data = sd->Data;\r
-      RINOK(SkipBitUi32s(sd, numSubDigests));\r
-      ssi->sdCRCs.Size = sd->Data - ssi->sdCRCs.Data;\r
-    }\r
-    else\r
-    {\r
-      RINOK(SkipData(sd));\r
-    }\r
-    RINOK(ReadID(sd, &type));\r
-  }\r
-}\r
-\r
-static SRes SzReadStreamsInfo(CSzAr *p,\r
-    CSzData *sd,\r
-    UInt32 numFoldersMax, const CBuf *tempBufs, UInt32 numTempBufs,\r
-    UInt64 *dataOffset,\r
-    CSubStreamInfo *ssi,\r
-    ISzAlloc *alloc)\r
-{\r
-  UInt64 type;\r
-\r
-  SzData_Clear(&ssi->sdSizes);\r
-  SzData_Clear(&ssi->sdCRCs);\r
-  SzData_Clear(&ssi->sdNumSubStreams);\r
-\r
-  *dataOffset = 0;\r
-  RINOK(ReadID(sd, &type));\r
-  if (type == k7zIdPackInfo)\r
-  {\r
-    RINOK(ReadNumber(sd, dataOffset));\r
-    RINOK(ReadPackInfo(p, sd, alloc));\r
-    RINOK(ReadID(sd, &type));\r
-  }\r
-  if (type == k7zIdUnpackInfo)\r
-  {\r
-    RINOK(ReadUnpackInfo(p, sd, numFoldersMax, tempBufs, numTempBufs, alloc));\r
-    RINOK(ReadID(sd, &type));\r
-  }\r
-  if (type == k7zIdSubStreamsInfo)\r
-  {\r
-    RINOK(ReadSubStreamsInfo(p, sd, ssi));\r
-    RINOK(ReadID(sd, &type));\r
-  }\r
-  else\r
-  {\r
-    ssi->NumTotalSubStreams = p->NumFolders;\r
-    // ssi->NumSubDigests = 0;\r
-  }\r
-\r
-  return (type == k7zIdEnd ? SZ_OK : SZ_ERROR_UNSUPPORTED);\r
-}\r
-\r
-static SRes SzReadAndDecodePackedStreams(\r
-    ILookInStream *inStream,\r
-    CSzData *sd,\r
-    CBuf *tempBufs,\r
-    UInt32 numFoldersMax,\r
-    UInt64 baseOffset,\r
-    CSzAr *p,\r
-    ISzAlloc *allocTemp)\r
-{\r
-  UInt64 dataStartPos;\r
-  UInt32 fo;\r
-  CSubStreamInfo ssi;\r
-\r
-  RINOK(SzReadStreamsInfo(p, sd, numFoldersMax, NULL, 0, &dataStartPos, &ssi, allocTemp));\r
-  \r
-  dataStartPos += baseOffset;\r
-  if (p->NumFolders == 0)\r
-    return SZ_ERROR_ARCHIVE;\r
\r
-  for (fo = 0; fo < p->NumFolders; fo++)\r
-    Buf_Init(tempBufs + fo);\r
-  \r
-  for (fo = 0; fo < p->NumFolders; fo++)\r
-  {\r
-    CBuf *tempBuf = tempBufs + fo;\r
-    UInt64 unpackSize = SzAr_GetFolderUnpackSize(p, fo);\r
-    if ((size_t)unpackSize != unpackSize)\r
-      return SZ_ERROR_MEM;\r
-    if (!Buf_Create(tempBuf, (size_t)unpackSize, allocTemp))\r
-      return SZ_ERROR_MEM;\r
-  }\r
-  \r
-  for (fo = 0; fo < p->NumFolders; fo++)\r
-  {\r
-    const CBuf *tempBuf = tempBufs + fo;\r
-    RINOK(LookInStream_SeekTo(inStream, dataStartPos));\r
-    RINOK(SzAr_DecodeFolder(p, fo, inStream, dataStartPos, tempBuf->data, tempBuf->size, allocTemp));\r
-  }\r
-  \r
-  return SZ_OK;\r
-}\r
-\r
-static SRes SzReadFileNames(const Byte *data, size_t size, UInt32 numFiles, size_t *offsets)\r
-{\r
-  size_t pos = 0;\r
-  *offsets++ = 0;\r
-  if (numFiles == 0)\r
-    return (size == 0) ? SZ_OK : SZ_ERROR_ARCHIVE;\r
-  if (size < 2)\r
-    return SZ_ERROR_ARCHIVE;\r
-  if (data[size - 2] != 0 || data[size - 1] != 0)\r
-    return SZ_ERROR_ARCHIVE;\r
-  do\r
-  {\r
-    const Byte *p;\r
-    if (pos == size)\r
-      return SZ_ERROR_ARCHIVE;\r
-    for (p = data + pos;\r
-      #ifdef _WIN32\r
-      *(const UInt16 *)p != 0\r
-      #else\r
-      p[0] != 0 || p[1] != 0\r
-      #endif\r
-      ; p += 2);\r
-    pos = p - data + 2;\r
-    *offsets++ = (pos >> 1);\r
-  }\r
-  while (--numFiles);\r
-  return (pos == size) ? SZ_OK : SZ_ERROR_ARCHIVE;\r
-}\r
-\r
-static MY_NO_INLINE SRes ReadTime(CSzBitUi64s *p, UInt32 num,\r
-    CSzData *sd2,\r
-    const CBuf *tempBufs, UInt32 numTempBufs,\r
-    ISzAlloc *alloc)\r
-{\r
-  CSzData sd;\r
-  UInt32 i;\r
-  CNtfsFileTime *vals;\r
-  Byte *defs;\r
-  Byte external;\r
-  \r
-  RINOK(ReadBitVector(sd2, num, &p->Defs, alloc));\r
-  \r
-  SZ_READ_BYTE_SD(sd2, external);\r
-  if (external == 0)\r
-    sd = *sd2;\r
-  else\r
-  {\r
-    UInt32 index;\r
-    RINOK(SzReadNumber32(sd2, &index));\r
-    if (index >= numTempBufs)\r
-      return SZ_ERROR_ARCHIVE;\r
-    sd.Data = tempBufs[index].data;\r
-    sd.Size = tempBufs[index].size;\r
-  }\r
-  \r
-  MY_ALLOC_ZE(CNtfsFileTime, p->Vals, num, alloc);\r
-  vals = p->Vals;\r
-  defs = p->Defs;\r
-  for (i = 0; i < num; i++)\r
-    if (SzBitArray_Check(defs, i))\r
-    {\r
-      if (sd.Size < 8)\r
-        return SZ_ERROR_ARCHIVE;\r
-      vals[i].Low = GetUi32(sd.Data);\r
-      vals[i].High = GetUi32(sd.Data + 4);\r
-      SKIP_DATA2(sd, 8);\r
-    }\r
-    else\r
-      vals[i].High = vals[i].Low = 0;\r
-  \r
-  if (external == 0)\r
-    *sd2 = sd;\r
-  \r
-  return SZ_OK;\r
-}\r
-\r
-\r
-#define NUM_ADDITIONAL_STREAMS_MAX 8\r
-\r
-\r
-static SRes SzReadHeader2(\r
-    CSzArEx *p,   /* allocMain */\r
-    CSzData *sd,\r
-    ILookInStream *inStream,\r
-    CBuf *tempBufs, UInt32 *numTempBufs,\r
-    ISzAlloc *allocMain,\r
-    ISzAlloc *allocTemp\r
-    )\r
-{\r
-  CSubStreamInfo ssi;\r
-\r
-{\r
-  UInt64 type;\r
-  \r
-  SzData_Clear(&ssi.sdSizes);\r
-  SzData_Clear(&ssi.sdCRCs);\r
-  SzData_Clear(&ssi.sdNumSubStreams);\r
-\r
-  ssi.NumSubDigests = 0;\r
-  ssi.NumTotalSubStreams = 0;\r
-\r
-  RINOK(ReadID(sd, &type));\r
-\r
-  if (type == k7zIdArchiveProperties)\r
-  {\r
-    for (;;)\r
-    {\r
-      UInt64 type2;\r
-      RINOK(ReadID(sd, &type2));\r
-      if (type2 == k7zIdEnd)\r
-        break;\r
-      RINOK(SkipData(sd));\r
-    }\r
-    RINOK(ReadID(sd, &type));\r
-  }\r
-\r
-  if (type == k7zIdAdditionalStreamsInfo)\r
-  {\r
-    CSzAr tempAr;\r
-    SRes res;\r
-    \r
-    SzAr_Init(&tempAr);\r
-    res = SzReadAndDecodePackedStreams(inStream, sd, tempBufs, NUM_ADDITIONAL_STREAMS_MAX,\r
-        p->startPosAfterHeader, &tempAr, allocTemp);\r
-    *numTempBufs = tempAr.NumFolders;\r
-    SzAr_Free(&tempAr, allocTemp);\r
-    \r
-    if (res != SZ_OK)\r
-      return res;\r
-    RINOK(ReadID(sd, &type));\r
-  }\r
-\r
-  if (type == k7zIdMainStreamsInfo)\r
-  {\r
-    RINOK(SzReadStreamsInfo(&p->db, sd, (UInt32)1 << 30, tempBufs, *numTempBufs,\r
-        &p->dataPos, &ssi, allocMain));\r
-    p->dataPos += p->startPosAfterHeader;\r
-    RINOK(ReadID(sd, &type));\r
-  }\r
-\r
-  if (type == k7zIdEnd)\r
-  {\r
-    return SZ_OK;\r
-  }\r
-\r
-  if (type != k7zIdFilesInfo)\r
-    return SZ_ERROR_ARCHIVE;\r
-}\r
-\r
-{\r
-  UInt32 numFiles = 0;\r
-  UInt32 numEmptyStreams = 0;\r
-  const Byte *emptyStreams = NULL;\r
-  const Byte *emptyFiles = NULL;\r
-  \r
-  RINOK(SzReadNumber32(sd, &numFiles));\r
-  p->NumFiles = numFiles;\r
-\r
-  for (;;)\r
-  {\r
-    UInt64 type;\r
-    UInt64 size;\r
-    RINOK(ReadID(sd, &type));\r
-    if (type == k7zIdEnd)\r
-      break;\r
-    RINOK(ReadNumber(sd, &size));\r
-    if (size > sd->Size)\r
-      return SZ_ERROR_ARCHIVE;\r
-    \r
-    if (type >= ((UInt32)1 << 8))\r
-    {\r
-      SKIP_DATA(sd, size);\r
-    }\r
-    else switch ((unsigned)type)\r
-    {\r
-      case k7zIdName:\r
-      {\r
-        size_t namesSize;\r
-        const Byte *namesData;\r
-        Byte external;\r
-\r
-        SZ_READ_BYTE(external);\r
-        if (external == 0)\r
-        {\r
-          namesSize = (size_t)size - 1;\r
-          namesData = sd->Data;\r
-        }\r
-        else\r
-        {\r
-          UInt32 index;\r
-          RINOK(SzReadNumber32(sd, &index));\r
-          if (index >= *numTempBufs)\r
-            return SZ_ERROR_ARCHIVE;\r
-          namesData = (tempBufs)[index].data;\r
-          namesSize = (tempBufs)[index].size;\r
-        }\r
-\r
-        if ((namesSize & 1) != 0)\r
-          return SZ_ERROR_ARCHIVE;\r
-        MY_ALLOC(size_t, p->FileNameOffsets, numFiles + 1, allocMain);\r
-        MY_ALLOC_ZE_AND_CPY(p->FileNames, namesSize, namesData, allocMain);\r
-        RINOK(SzReadFileNames(p->FileNames, namesSize, numFiles, p->FileNameOffsets))\r
-        if (external == 0)\r
-        {\r
-          SKIP_DATA(sd, namesSize);\r
-        }\r
-        break;\r
-      }\r
-      case k7zIdEmptyStream:\r
-      {\r
-        RINOK(RememberBitVector(sd, numFiles, &emptyStreams));\r
-        numEmptyStreams = CountDefinedBits(emptyStreams, numFiles);\r
-        emptyFiles = NULL;\r
-        break;\r
-      }\r
-      case k7zIdEmptyFile:\r
-      {\r
-        RINOK(RememberBitVector(sd, numEmptyStreams, &emptyFiles));\r
-        break;\r
-      }\r
-      case k7zIdWinAttrib:\r
-      {\r
-        Byte external;\r
-        CSzData sdSwitch;\r
-        CSzData *sdPtr;\r
-        SzBitUi32s_Free(&p->Attribs, allocMain);\r
-        RINOK(ReadBitVector(sd, numFiles, &p->Attribs.Defs, allocMain));\r
-\r
-        SZ_READ_BYTE(external);\r
-        if (external == 0)\r
-          sdPtr = sd;\r
-        else\r
-        {\r
-          UInt32 index;\r
-          RINOK(SzReadNumber32(sd, &index));\r
-          if (index >= *numTempBufs)\r
-            return SZ_ERROR_ARCHIVE;\r
-          sdSwitch.Data = (tempBufs)[index].data;\r
-          sdSwitch.Size = (tempBufs)[index].size;\r
-          sdPtr = &sdSwitch;\r
-        }\r
-        RINOK(ReadUi32s(sdPtr, numFiles, &p->Attribs, allocMain));\r
-        break;\r
-      }\r
-      /*\r
-      case k7zParent:\r
-      {\r
-        SzBitUi32s_Free(&p->Parents, allocMain);\r
-        RINOK(ReadBitVector(sd, numFiles, &p->Parents.Defs, allocMain));\r
-        RINOK(SzReadSwitch(sd));\r
-        RINOK(ReadUi32s(sd, numFiles, &p->Parents, allocMain));\r
-        break;\r
-      }\r
-      */\r
-      case k7zIdMTime: RINOK(ReadTime(&p->MTime, numFiles, sd, tempBufs, *numTempBufs, allocMain)); break;\r
-      case k7zIdCTime: RINOK(ReadTime(&p->CTime, numFiles, sd, tempBufs, *numTempBufs, allocMain)); break;\r
-      default:\r
-      {\r
-        SKIP_DATA(sd, size);\r
-      }\r
-    }\r
-  }\r
-\r
-  if (numFiles - numEmptyStreams != ssi.NumTotalSubStreams)\r
-    return SZ_ERROR_ARCHIVE;\r
-\r
-  for (;;)\r
-  {\r
-    UInt64 type;\r
-    RINOK(ReadID(sd, &type));\r
-    if (type == k7zIdEnd)\r
-      break;\r
-    RINOK(SkipData(sd));\r
-  }\r
-\r
-  {\r
-    UInt32 i;\r
-    UInt32 emptyFileIndex = 0;\r
-    UInt32 folderIndex = 0;\r
-    UInt32 remSubStreams = 0;\r
-    UInt32 numSubStreams = 0;\r
-    UInt64 unpackPos = 0;\r
-    const Byte *digestsDefs = NULL;\r
-    const Byte *digestsVals = NULL;\r
-    UInt32 digestsValsIndex = 0;\r
-    UInt32 digestIndex;\r
-    Byte allDigestsDefined = 0;\r
-    Byte isDirMask = 0;\r
-    Byte crcMask = 0;\r
-    Byte mask = 0x80;\r
-    \r
-    MY_ALLOC(UInt32, p->FolderToFile, p->db.NumFolders + 1, allocMain);\r
-    MY_ALLOC_ZE(UInt32, p->FileToFolder, p->NumFiles, allocMain);\r
-    MY_ALLOC(UInt64, p->UnpackPositions, p->NumFiles + 1, allocMain);\r
-    MY_ALLOC_ZE(Byte, p->IsDirs, (p->NumFiles + 7) >> 3, allocMain);\r
-\r
-    RINOK(SzBitUi32s_Alloc(&p->CRCs, p->NumFiles, allocMain));\r
-\r
-    if (ssi.sdCRCs.Size != 0)\r
-    {\r
-      SZ_READ_BYTE_SD(&ssi.sdCRCs, allDigestsDefined);\r
-      if (allDigestsDefined)\r
-        digestsVals = ssi.sdCRCs.Data;\r
-      else\r
-      {\r
-        size_t numBytes = (ssi.NumSubDigests + 7) >> 3;\r
-        digestsDefs = ssi.sdCRCs.Data;\r
-        digestsVals = digestsDefs + numBytes;\r
-      }\r
-    }\r
-\r
-    digestIndex = 0;\r
-    \r
-    for (i = 0; i < numFiles; i++, mask >>= 1)\r
-    {\r
-      if (mask == 0)\r
-      {\r
-        UInt32 byteIndex = (i - 1) >> 3;\r
-        p->IsDirs[byteIndex] = isDirMask;\r
-        p->CRCs.Defs[byteIndex] = crcMask;\r
-        isDirMask = 0;\r
-        crcMask = 0;\r
-        mask = 0x80;\r
-      }\r
-\r
-      p->UnpackPositions[i] = unpackPos;\r
-      p->CRCs.Vals[i] = 0;\r
-      \r
-      if (emptyStreams && SzBitArray_Check(emptyStreams, i))\r
-      {\r
-        if (emptyFiles)\r
-        {\r
-          if (!SzBitArray_Check(emptyFiles, emptyFileIndex))\r
-            isDirMask |= mask;\r
-          emptyFileIndex++;\r
-        }\r
-        else\r
-          isDirMask |= mask;\r
-        if (remSubStreams == 0)\r
-        {\r
-          p->FileToFolder[i] = (UInt32)-1;\r
-          continue;\r
-        }\r
-      }\r
-      \r
-      if (remSubStreams == 0)\r
-      {\r
-        for (;;)\r
-        {\r
-          if (folderIndex >= p->db.NumFolders)\r
-            return SZ_ERROR_ARCHIVE;\r
-          p->FolderToFile[folderIndex] = i;\r
-          numSubStreams = 1;\r
-          if (ssi.sdNumSubStreams.Data)\r
-          {\r
-            RINOK(SzReadNumber32(&ssi.sdNumSubStreams, &numSubStreams));\r
-          }\r
-          remSubStreams = numSubStreams;\r
-          if (numSubStreams != 0)\r
-            break;\r
-          {\r
-            UInt64 folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex);\r
-            unpackPos += folderUnpackSize;\r
-            if (unpackPos < folderUnpackSize)\r
-              return SZ_ERROR_ARCHIVE;\r
-          }\r
-\r
-          folderIndex++;\r
-        }\r
-      }\r
-      \r
-      p->FileToFolder[i] = folderIndex;\r
-      \r
-      if (emptyStreams && SzBitArray_Check(emptyStreams, i))\r
-        continue;\r
-      \r
-      if (--remSubStreams == 0)\r
-      {\r
-        UInt64 folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex);\r
-        UInt64 startFolderUnpackPos = p->UnpackPositions[p->FolderToFile[folderIndex]];\r
-        if (folderUnpackSize < unpackPos - startFolderUnpackPos)\r
-          return SZ_ERROR_ARCHIVE;\r
-        unpackPos = startFolderUnpackPos + folderUnpackSize;\r
-        if (unpackPos < folderUnpackSize)\r
-          return SZ_ERROR_ARCHIVE;\r
-\r
-        if (numSubStreams == 1 && SzBitWithVals_Check(&p->db.FolderCRCs, i))\r
-        {\r
-          p->CRCs.Vals[i] = p->db.FolderCRCs.Vals[folderIndex];\r
-          crcMask |= mask;\r
-        }\r
-        else if (allDigestsDefined || (digestsDefs && SzBitArray_Check(digestsDefs, digestIndex)))\r
-        {\r
-          p->CRCs.Vals[i] = GetUi32(digestsVals + (size_t)digestsValsIndex * 4);\r
-          digestsValsIndex++;\r
-          crcMask |= mask;\r
-        }\r
-        \r
-        folderIndex++;\r
-      }\r
-      else\r
-      {\r
-        UInt64 v;\r
-        RINOK(ReadNumber(&ssi.sdSizes, &v));\r
-        unpackPos += v;\r
-        if (unpackPos < v)\r
-          return SZ_ERROR_ARCHIVE;\r
-        if (allDigestsDefined || (digestsDefs && SzBitArray_Check(digestsDefs, digestIndex)))\r
-        {\r
-          p->CRCs.Vals[i] = GetUi32(digestsVals + (size_t)digestsValsIndex * 4);\r
-          digestsValsIndex++;\r
-          crcMask |= mask;\r
-        }\r
-      }\r
-    }\r
-\r
-    if (mask != 0x80)\r
-    {\r
-      UInt32 byteIndex = (i - 1) >> 3;\r
-      p->IsDirs[byteIndex] = isDirMask;\r
-      p->CRCs.Defs[byteIndex] = crcMask;\r
-    }\r
-    \r
-    p->UnpackPositions[i] = unpackPos;\r
-\r
-    if (remSubStreams != 0)\r
-      return SZ_ERROR_ARCHIVE;\r
-\r
-    for (;;)\r
-    {\r
-      p->FolderToFile[folderIndex] = i;\r
-      if (folderIndex >= p->db.NumFolders)\r
-        break;\r
-      if (!ssi.sdNumSubStreams.Data)\r
-        return SZ_ERROR_ARCHIVE;\r
-      RINOK(SzReadNumber32(&ssi.sdNumSubStreams, &numSubStreams));\r
-      if (numSubStreams != 0)\r
-        return SZ_ERROR_ARCHIVE;\r
-      /*\r
-      {\r
-        UInt64 folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex);\r
-        unpackPos += folderUnpackSize;\r
-        if (unpackPos < folderUnpackSize)\r
-          return SZ_ERROR_ARCHIVE;\r
-      }\r
-      */\r
-      folderIndex++;\r
-    }\r
-\r
-    if (ssi.sdNumSubStreams.Data && ssi.sdNumSubStreams.Size != 0)\r
-      return SZ_ERROR_ARCHIVE;\r
-  }\r
-}\r
-  return SZ_OK;\r
-}\r
-\r
-\r
-static SRes SzReadHeader(\r
-    CSzArEx *p,\r
-    CSzData *sd,\r
-    ILookInStream *inStream,\r
-    ISzAlloc *allocMain,\r
-    ISzAlloc *allocTemp)\r
-{\r
-  UInt32 i;\r
-  UInt32 numTempBufs = 0;\r
-  SRes res;\r
-  CBuf tempBufs[NUM_ADDITIONAL_STREAMS_MAX];\r
-\r
-  for (i = 0; i < NUM_ADDITIONAL_STREAMS_MAX; i++)\r
-    Buf_Init(tempBufs + i);\r
-  \r
-  res = SzReadHeader2(p, sd, inStream,\r
-      tempBufs, &numTempBufs,\r
-      allocMain, allocTemp);\r
-  \r
-  for (i = 0; i < NUM_ADDITIONAL_STREAMS_MAX; i++)\r
-    Buf_Free(tempBufs + i, allocTemp);\r
-\r
-  RINOK(res);\r
-\r
-  if (sd->Size != 0)\r
-    return SZ_ERROR_FAIL;\r
-\r
-  return res;\r
-}\r
-\r
-static SRes SzArEx_Open2(\r
-    CSzArEx *p,\r
-    ILookInStream *inStream,\r
-    ISzAlloc *allocMain,\r
-    ISzAlloc *allocTemp)\r
-{\r
-  Byte header[k7zStartHeaderSize];\r
-  Int64 startArcPos;\r
-  UInt64 nextHeaderOffset, nextHeaderSize;\r
-  size_t nextHeaderSizeT;\r
-  UInt32 nextHeaderCRC;\r
-  CBuf buf;\r
-  SRes res;\r
-\r
-  startArcPos = 0;\r
-  RINOK(inStream->Seek(inStream, &startArcPos, SZ_SEEK_CUR));\r
-\r
-  RINOK(LookInStream_Read2(inStream, header, k7zStartHeaderSize, SZ_ERROR_NO_ARCHIVE));\r
-\r
-  if (!TestSignatureCandidate(header))\r
-    return SZ_ERROR_NO_ARCHIVE;\r
-  if (header[6] != k7zMajorVersion)\r
-    return SZ_ERROR_UNSUPPORTED;\r
-\r
-  nextHeaderOffset = GetUi64(header + 12);\r
-  nextHeaderSize = GetUi64(header + 20);\r
-  nextHeaderCRC = GetUi32(header + 28);\r
-\r
-  p->startPosAfterHeader = startArcPos + k7zStartHeaderSize;\r
-  \r
-  if (CrcCalc(header + 12, 20) != GetUi32(header + 8))\r
-    return SZ_ERROR_CRC;\r
-\r
-  nextHeaderSizeT = (size_t)nextHeaderSize;\r
-  if (nextHeaderSizeT != nextHeaderSize)\r
-    return SZ_ERROR_MEM;\r
-  if (nextHeaderSizeT == 0)\r
-    return SZ_OK;\r
-  if (nextHeaderOffset > nextHeaderOffset + nextHeaderSize ||\r
-      nextHeaderOffset > nextHeaderOffset + nextHeaderSize + k7zStartHeaderSize)\r
-    return SZ_ERROR_NO_ARCHIVE;\r
-\r
-  {\r
-    Int64 pos = 0;\r
-    RINOK(inStream->Seek(inStream, &pos, SZ_SEEK_END));\r
-    if ((UInt64)pos < startArcPos + nextHeaderOffset ||\r
-        (UInt64)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset ||\r
-        (UInt64)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset + nextHeaderSize)\r
-      return SZ_ERROR_INPUT_EOF;\r
-  }\r
-\r
-  RINOK(LookInStream_SeekTo(inStream, startArcPos + k7zStartHeaderSize + nextHeaderOffset));\r
-\r
-  if (!Buf_Create(&buf, nextHeaderSizeT, allocTemp))\r
-    return SZ_ERROR_MEM;\r
-\r
-  res = LookInStream_Read(inStream, buf.data, nextHeaderSizeT);\r
-  \r
-  if (res == SZ_OK)\r
-  {\r
-    res = SZ_ERROR_ARCHIVE;\r
-    if (CrcCalc(buf.data, nextHeaderSizeT) == nextHeaderCRC)\r
-    {\r
-      CSzData sd;\r
-      UInt64 type;\r
-      sd.Data = buf.data;\r
-      sd.Size = buf.size;\r
-      \r
-      res = ReadID(&sd, &type);\r
-      \r
-      if (res == SZ_OK && type == k7zIdEncodedHeader)\r
-      {\r
-        CSzAr tempAr;\r
-        CBuf tempBuf;\r
-        Buf_Init(&tempBuf);\r
-        \r
-        SzAr_Init(&tempAr);\r
-        res = SzReadAndDecodePackedStreams(inStream, &sd, &tempBuf, 1, p->startPosAfterHeader, &tempAr, allocTemp);\r
-        SzAr_Free(&tempAr, allocTemp);\r
-       \r
-        if (res != SZ_OK)\r
-        {\r
-          Buf_Free(&tempBuf, allocTemp);\r
-        }\r
-        else\r
-        {\r
-          Buf_Free(&buf, allocTemp);\r
-          buf.data = tempBuf.data;\r
-          buf.size = tempBuf.size;\r
-          sd.Data = buf.data;\r
-          sd.Size = buf.size;\r
-          res = ReadID(&sd, &type);\r
-        }\r
-      }\r
-  \r
-      if (res == SZ_OK)\r
-      {\r
-        if (type == k7zIdHeader)\r
-        {\r
-          /*\r
-          CSzData sd2;\r
-          unsigned ttt;\r
-          for (ttt = 0; ttt < 40000; ttt++)\r
-          {\r
-            SzArEx_Free(p, allocMain);\r
-            sd2 = sd;\r
-            res = SzReadHeader(p, &sd2, inStream, allocMain, allocTemp);\r
-            if (res != SZ_OK)\r
-              break;\r
-          }\r
-          */\r
-          res = SzReadHeader(p, &sd, inStream, allocMain, allocTemp);\r
-        }\r
-        else\r
-          res = SZ_ERROR_UNSUPPORTED;\r
-      }\r
-    }\r
-  }\r
\r
-  Buf_Free(&buf, allocTemp);\r
-  return res;\r
-}\r
-\r
-\r
-SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream,\r
-    ISzAlloc *allocMain, ISzAlloc *allocTemp)\r
-{\r
-  SRes res = SzArEx_Open2(p, inStream, allocMain, allocTemp);\r
-  if (res != SZ_OK)\r
-    SzArEx_Free(p, allocMain);\r
-  return res;\r
-}\r
-\r
-\r
-SRes SzArEx_Extract(\r
-    const CSzArEx *p,\r
-    ILookInStream *inStream,\r
-    UInt32 fileIndex,\r
-    UInt32 *blockIndex,\r
-    Byte **tempBuf,\r
-    size_t *outBufferSize,\r
-    size_t *offset,\r
-    size_t *outSizeProcessed,\r
-    ISzAlloc *allocMain,\r
-    ISzAlloc *allocTemp)\r
-{\r
-  UInt32 folderIndex = p->FileToFolder[fileIndex];\r
-  SRes res = SZ_OK;\r
-  \r
-  *offset = 0;\r
-  *outSizeProcessed = 0;\r
-  \r
-  if (folderIndex == (UInt32)-1)\r
-  {\r
-    IAlloc_Free(allocMain, *tempBuf);\r
-    *blockIndex = folderIndex;\r
-    *tempBuf = NULL;\r
-    *outBufferSize = 0;\r
-    return SZ_OK;\r
-  }\r
-\r
-  if (*tempBuf == NULL || *blockIndex != folderIndex)\r
-  {\r
-    UInt64 unpackSizeSpec = SzAr_GetFolderUnpackSize(&p->db, folderIndex);\r
-    /*\r
-    UInt64 unpackSizeSpec =\r
-        p->UnpackPositions[p->FolderToFile[folderIndex + 1]] -\r
-        p->UnpackPositions[p->FolderToFile[folderIndex]];\r
-    */\r
-    size_t unpackSize = (size_t)unpackSizeSpec;\r
-\r
-    if (unpackSize != unpackSizeSpec)\r
-      return SZ_ERROR_MEM;\r
-    *blockIndex = folderIndex;\r
-    IAlloc_Free(allocMain, *tempBuf);\r
-    *tempBuf = NULL;\r
-    \r
-    if (res == SZ_OK)\r
-    {\r
-      *outBufferSize = unpackSize;\r
-      if (unpackSize != 0)\r
-      {\r
-        *tempBuf = (Byte *)IAlloc_Alloc(allocMain, unpackSize);\r
-        if (*tempBuf == NULL)\r
-          res = SZ_ERROR_MEM;\r
-      }\r
-  \r
-      if (res == SZ_OK)\r
-      {\r
-        res = SzAr_DecodeFolder(&p->db, folderIndex,\r
-            inStream, p->dataPos, *tempBuf, unpackSize, allocTemp);\r
-      }\r
-    }\r
-  }\r
-\r
-  if (res == SZ_OK)\r
-  {\r
-    UInt64 unpackPos = p->UnpackPositions[fileIndex];\r
-    *offset = (size_t)(unpackPos - p->UnpackPositions[p->FolderToFile[folderIndex]]);\r
-    *outSizeProcessed = (size_t)(p->UnpackPositions[fileIndex + 1] - unpackPos);\r
-    if (*offset + *outSizeProcessed > *outBufferSize)\r
-      return SZ_ERROR_FAIL;\r
-    if (SzBitWithVals_Check(&p->CRCs, fileIndex))\r
-      if (CrcCalc(*tempBuf + *offset, *outSizeProcessed) != p->CRCs.Vals[fileIndex])\r
-        res = SZ_ERROR_CRC;\r
-  }\r
-\r
-  return res;\r
-}\r
-\r
-\r
-size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest)\r
-{\r
-  size_t offs = p->FileNameOffsets[fileIndex];\r
-  size_t len = p->FileNameOffsets[fileIndex + 1] - offs;\r
-  if (dest != 0)\r
-  {\r
-    size_t i;\r
-    const Byte *src = p->FileNames + offs * 2;\r
-    for (i = 0; i < len; i++)\r
-      dest[i] = GetUi16(src + i * 2);\r
-  }\r
-  return len;\r
-}\r
-\r
-/*\r
-size_t SzArEx_GetFullNameLen(const CSzArEx *p, size_t fileIndex)\r
-{\r
-  size_t len;\r
-  if (!p->FileNameOffsets)\r
-    return 1;\r
-  len = 0;\r
-  for (;;)\r
-  {\r
-    UInt32 parent = (UInt32)(Int32)-1;\r
-    len += p->FileNameOffsets[fileIndex + 1] - p->FileNameOffsets[fileIndex];\r
-    if SzBitWithVals_Check(&p->Parents, fileIndex)\r
-      parent = p->Parents.Vals[fileIndex];\r
-    if (parent == (UInt32)(Int32)-1)\r
-      return len;\r
-    fileIndex = parent;\r
-  }\r
-}\r
-\r
-UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest)\r
-{\r
-  Bool needSlash;\r
-  if (!p->FileNameOffsets)\r
-  {\r
-    *(--dest) = 0;\r
-    return dest;\r
-  }\r
-  needSlash = False;\r
-  for (;;)\r
-  {\r
-    UInt32 parent = (UInt32)(Int32)-1;\r
-    size_t curLen = p->FileNameOffsets[fileIndex + 1] - p->FileNameOffsets[fileIndex];\r
-    SzArEx_GetFileNameUtf16(p, fileIndex, dest - curLen);\r
-    if (needSlash)\r
-      *(dest - 1) = '/';\r
-    needSlash = True;\r
-    dest -= curLen;\r
-\r
-    if SzBitWithVals_Check(&p->Parents, fileIndex)\r
-      parent = p->Parents.Vals[fileIndex];\r
-    if (parent == (UInt32)(Int32)-1)\r
-      return dest;\r
-    fileIndex = parent;\r
-  }\r
-}\r
-*/\r
diff --git a/deps/lzma-16.04/C/7zBuf.c b/deps/lzma-16.04/C/7zBuf.c
deleted file mode 100644 (file)
index b0ac110..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/* 7zBuf.c -- Byte Buffer\r
-2013-01-21 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "7zBuf.h"\r
-\r
-void Buf_Init(CBuf *p)\r
-{\r
-  p->data = 0;\r
-  p->size = 0;\r
-}\r
-\r
-int Buf_Create(CBuf *p, size_t size, ISzAlloc *alloc)\r
-{\r
-  p->size = 0;\r
-  if (size == 0)\r
-  {\r
-    p->data = 0;\r
-    return 1;\r
-  }\r
-  p->data = (Byte *)alloc->Alloc(alloc, size);\r
-  if (p->data != 0)\r
-  {\r
-    p->size = size;\r
-    return 1;\r
-  }\r
-  return 0;\r
-}\r
-\r
-void Buf_Free(CBuf *p, ISzAlloc *alloc)\r
-{\r
-  alloc->Free(alloc, p->data);\r
-  p->data = 0;\r
-  p->size = 0;\r
-}\r
diff --git a/deps/lzma-16.04/C/7zBuf.h b/deps/lzma-16.04/C/7zBuf.h
deleted file mode 100644 (file)
index e5f9218..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/* 7zBuf.h -- Byte Buffer\r
-2013-01-18 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __7Z_BUF_H\r
-#define __7Z_BUF_H\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-typedef struct\r
-{\r
-  Byte *data;\r
-  size_t size;\r
-} CBuf;\r
-\r
-void Buf_Init(CBuf *p);\r
-int Buf_Create(CBuf *p, size_t size, ISzAlloc *alloc);\r
-void Buf_Free(CBuf *p, ISzAlloc *alloc);\r
-\r
-typedef struct\r
-{\r
-  Byte *data;\r
-  size_t size;\r
-  size_t pos;\r
-} CDynBuf;\r
-\r
-void DynBuf_Construct(CDynBuf *p);\r
-void DynBuf_SeekToBeg(CDynBuf *p);\r
-int DynBuf_Write(CDynBuf *p, const Byte *buf, size_t size, ISzAlloc *alloc);\r
-void DynBuf_Free(CDynBuf *p, ISzAlloc *alloc);\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/7zBuf2.c b/deps/lzma-16.04/C/7zBuf2.c
deleted file mode 100644 (file)
index 8e3fe92..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/* 7zBuf2.c -- Byte Buffer\r
-2014-08-22 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include <string.h>\r
-\r
-#include "7zBuf.h"\r
-\r
-void DynBuf_Construct(CDynBuf *p)\r
-{\r
-  p->data = 0;\r
-  p->size = 0;\r
-  p->pos = 0;\r
-}\r
-\r
-void DynBuf_SeekToBeg(CDynBuf *p)\r
-{\r
-  p->pos = 0;\r
-}\r
-\r
-int DynBuf_Write(CDynBuf *p, const Byte *buf, size_t size, ISzAlloc *alloc)\r
-{\r
-  if (size > p->size - p->pos)\r
-  {\r
-    size_t newSize = p->pos + size;\r
-    Byte *data;\r
-    newSize += newSize / 4;\r
-    data = (Byte *)alloc->Alloc(alloc, newSize);\r
-    if (data == 0)\r
-      return 0;\r
-    p->size = newSize;\r
-    memcpy(data, p->data, p->pos);\r
-    alloc->Free(alloc, p->data);\r
-    p->data = data;\r
-  }\r
-  if (size != 0)\r
-  {\r
-    memcpy(p->data + p->pos, buf, size);\r
-    p->pos += size;\r
-  }\r
-  return 1;\r
-}\r
-\r
-void DynBuf_Free(CDynBuf *p, ISzAlloc *alloc)\r
-{\r
-  alloc->Free(alloc, p->data);\r
-  p->data = 0;\r
-  p->size = 0;\r
-  p->pos = 0;\r
-}\r
diff --git a/deps/lzma-16.04/C/7zCrc.c b/deps/lzma-16.04/C/7zCrc.c
deleted file mode 100644 (file)
index 607db34..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/* 7zCrc.c -- CRC32 init\r
-2015-03-10 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "7zCrc.h"\r
-#include "CpuArch.h"\r
-\r
-#define kCrcPoly 0xEDB88320\r
-\r
-#ifdef MY_CPU_LE\r
-  #define CRC_NUM_TABLES 8\r
-#else\r
-  #define CRC_NUM_TABLES 9\r
-\r
-  #define CRC_UINT32_SWAP(v) ((v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | (v << 24))\r
-\r
-  UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void *data, size_t size, const UInt32 *table);\r
-  UInt32 MY_FAST_CALL CrcUpdateT1_BeT8(UInt32 v, const void *data, size_t size, const UInt32 *table);\r
-#endif\r
-\r
-#ifndef MY_CPU_BE\r
-  UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table);\r
-  UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table);\r
-#endif\r
-\r
-typedef UInt32 (MY_FAST_CALL *CRC_FUNC)(UInt32 v, const void *data, size_t size, const UInt32 *table);\r
-\r
-CRC_FUNC g_CrcUpdateT4;\r
-CRC_FUNC g_CrcUpdateT8;\r
-CRC_FUNC g_CrcUpdate;\r
-\r
-UInt32 g_CrcTable[256 * CRC_NUM_TABLES];\r
-\r
-UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size)\r
-{\r
-  return g_CrcUpdate(v, data, size, g_CrcTable);\r
-}\r
-\r
-UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size)\r
-{\r
-  return g_CrcUpdate(CRC_INIT_VAL, data, size, g_CrcTable) ^ CRC_INIT_VAL;\r
-}\r
-\r
-#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))\r
-\r
-UInt32 MY_FAST_CALL CrcUpdateT1(UInt32 v, const void *data, size_t size, const UInt32 *table)\r
-{\r
-  const Byte *p = (const Byte *)data;\r
-  const Byte *pEnd = p + size;\r
-  for (; p != pEnd; p++)\r
-    v = CRC_UPDATE_BYTE_2(v, *p);\r
-  return v;\r
-}\r
-\r
-void MY_FAST_CALL CrcGenerateTable()\r
-{\r
-  UInt32 i;\r
-  for (i = 0; i < 256; i++)\r
-  {\r
-    UInt32 r = i;\r
-    unsigned j;\r
-    for (j = 0; j < 8; j++)\r
-      r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));\r
-    g_CrcTable[i] = r;\r
-  }\r
-  for (; i < 256 * CRC_NUM_TABLES; i++)\r
-  {\r
-    UInt32 r = g_CrcTable[i - 256];\r
-    g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8);\r
-  }\r
-\r
-  #if CRC_NUM_TABLES < 4\r
-  \r
-  g_CrcUpdate = CrcUpdateT1;\r
-  \r
-  #else\r
\r
-  #ifdef MY_CPU_LE\r
-\r
-    g_CrcUpdateT4 = CrcUpdateT4;\r
-    g_CrcUpdate = CrcUpdateT4;\r
-\r
-    #if CRC_NUM_TABLES >= 8\r
-      g_CrcUpdateT8 = CrcUpdateT8;\r
-  \r
-      #ifdef MY_CPU_X86_OR_AMD64\r
-      if (!CPU_Is_InOrder())\r
-        g_CrcUpdate = CrcUpdateT8;\r
-      #endif\r
-    #endif\r
-\r
-  #else\r
-  {\r
-    #ifndef MY_CPU_BE\r
-    UInt32 k = 0x01020304;\r
-    const Byte *p = (const Byte *)&k;\r
-    if (p[0] == 4 && p[1] == 3)\r
-    {\r
-      g_CrcUpdateT4 = CrcUpdateT4;\r
-      g_CrcUpdate = CrcUpdateT4;\r
-      #if CRC_NUM_TABLES >= 8\r
-      g_CrcUpdateT8 = CrcUpdateT8;\r
-      // g_CrcUpdate = CrcUpdateT8;\r
-      #endif\r
-    }\r
-    else if (p[0] != 1 || p[1] != 2)\r
-      g_CrcUpdate = CrcUpdateT1;\r
-    else\r
-    #endif\r
-    {\r
-      for (i = 256 * CRC_NUM_TABLES - 1; i >= 256; i--)\r
-      {\r
-        UInt32 x = g_CrcTable[i - 256];\r
-        g_CrcTable[i] = CRC_UINT32_SWAP(x);\r
-      }\r
-      g_CrcUpdateT4 = CrcUpdateT1_BeT4;\r
-      g_CrcUpdate = CrcUpdateT1_BeT4;\r
-      #if CRC_NUM_TABLES >= 8\r
-      g_CrcUpdateT8 = CrcUpdateT1_BeT8;\r
-      // g_CrcUpdate = CrcUpdateT1_BeT8;\r
-      #endif\r
-    }\r
-  }\r
-  #endif\r
-\r
-  #endif\r
-}\r
diff --git a/deps/lzma-16.04/C/7zCrc.h b/deps/lzma-16.04/C/7zCrc.h
deleted file mode 100644 (file)
index 3b04594..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/* 7zCrc.h -- CRC32 calculation\r
-2013-01-18 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __7Z_CRC_H\r
-#define __7Z_CRC_H\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-extern UInt32 g_CrcTable[];\r
-\r
-/* Call CrcGenerateTable one time before other CRC functions */\r
-void MY_FAST_CALL CrcGenerateTable(void);\r
-\r
-#define CRC_INIT_VAL 0xFFFFFFFF\r
-#define CRC_GET_DIGEST(crc) ((crc) ^ CRC_INIT_VAL)\r
-#define CRC_UPDATE_BYTE(crc, b) (g_CrcTable[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))\r
-\r
-UInt32 MY_FAST_CALL CrcUpdate(UInt32 crc, const void *data, size_t size);\r
-UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size);\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/7zCrcOpt.c b/deps/lzma-16.04/C/7zCrcOpt.c
deleted file mode 100644 (file)
index 58628ef..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/* 7zCrcOpt.c -- CRC32 calculation\r
-2015-03-01 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "CpuArch.h"\r
-\r
-#ifndef MY_CPU_BE\r
-\r
-#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))\r
-\r
-UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table)\r
-{\r
-  const Byte *p = (const Byte *)data;\r
-  for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++)\r
-    v = CRC_UPDATE_BYTE_2(v, *p);\r
-  for (; size >= 4; size -= 4, p += 4)\r
-  {\r
-    v ^= *(const UInt32 *)p;\r
-    v =\r
-          table[0x300 + ((v      ) & 0xFF)]\r
-        ^ table[0x200 + ((v >>  8) & 0xFF)]\r
-        ^ table[0x100 + ((v >> 16) & 0xFF)]\r
-        ^ table[0x000 + ((v >> 24))];\r
-  }\r
-  for (; size > 0; size--, p++)\r
-    v = CRC_UPDATE_BYTE_2(v, *p);\r
-  return v;\r
-}\r
-\r
-UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table)\r
-{\r
-  const Byte *p = (const Byte *)data;\r
-  for (; size > 0 && ((unsigned)(ptrdiff_t)p & 7) != 0; size--, p++)\r
-    v = CRC_UPDATE_BYTE_2(v, *p);\r
-  for (; size >= 8; size -= 8, p += 8)\r
-  {\r
-    UInt32 d;\r
-    v ^= *(const UInt32 *)p;\r
-    v =\r
-          table[0x700 + ((v      ) & 0xFF)]\r
-        ^ table[0x600 + ((v >>  8) & 0xFF)]\r
-        ^ table[0x500 + ((v >> 16) & 0xFF)]\r
-        ^ table[0x400 + ((v >> 24))];\r
-    d = *((const UInt32 *)p + 1);\r
-    v ^=\r
-          table[0x300 + ((d      ) & 0xFF)]\r
-        ^ table[0x200 + ((d >>  8) & 0xFF)]\r
-        ^ table[0x100 + ((d >> 16) & 0xFF)]\r
-        ^ table[0x000 + ((d >> 24))];\r
-  }\r
-  for (; size > 0; size--, p++)\r
-    v = CRC_UPDATE_BYTE_2(v, *p);\r
-  return v;\r
-}\r
-\r
-#endif\r
-\r
-\r
-#ifndef MY_CPU_LE\r
-\r
-#define CRC_UINT32_SWAP(v) ((v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | (v << 24))\r
-\r
-#define CRC_UPDATE_BYTE_2_BE(crc, b) (table[(((crc) >> 24) ^ (b))] ^ ((crc) << 8))\r
-\r
-UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void *data, size_t size, const UInt32 *table)\r
-{\r
-  const Byte *p = (const Byte *)data;\r
-  table += 0x100;\r
-  v = CRC_UINT32_SWAP(v);\r
-  for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++)\r
-    v = CRC_UPDATE_BYTE_2_BE(v, *p);\r
-  for (; size >= 4; size -= 4, p += 4)\r
-  {\r
-    v ^= *(const UInt32 *)p;\r
-    v =\r
-          table[0x000 + ((v      ) & 0xFF)]\r
-        ^ table[0x100 + ((v >>  8) & 0xFF)]\r
-        ^ table[0x200 + ((v >> 16) & 0xFF)]\r
-        ^ table[0x300 + ((v >> 24))];\r
-  }\r
-  for (; size > 0; size--, p++)\r
-    v = CRC_UPDATE_BYTE_2_BE(v, *p);\r
-  return CRC_UINT32_SWAP(v);\r
-}\r
-\r
-UInt32 MY_FAST_CALL CrcUpdateT1_BeT8(UInt32 v, const void *data, size_t size, const UInt32 *table)\r
-{\r
-  const Byte *p = (const Byte *)data;\r
-  table += 0x100;\r
-  v = CRC_UINT32_SWAP(v);\r
-  for (; size > 0 && ((unsigned)(ptrdiff_t)p & 7) != 0; size--, p++)\r
-    v = CRC_UPDATE_BYTE_2_BE(v, *p);\r
-  for (; size >= 8; size -= 8, p += 8)\r
-  {\r
-    UInt32 d;\r
-    v ^= *(const UInt32 *)p;\r
-    v =\r
-          table[0x400 + ((v      ) & 0xFF)]\r
-        ^ table[0x500 + ((v >>  8) & 0xFF)]\r
-        ^ table[0x600 + ((v >> 16) & 0xFF)]\r
-        ^ table[0x700 + ((v >> 24))];\r
-    d = *((const UInt32 *)p + 1);\r
-    v ^=\r
-          table[0x000 + ((d      ) & 0xFF)]\r
-        ^ table[0x100 + ((d >>  8) & 0xFF)]\r
-        ^ table[0x200 + ((d >> 16) & 0xFF)]\r
-        ^ table[0x300 + ((d >> 24))];\r
-  }\r
-  for (; size > 0; size--, p++)\r
-    v = CRC_UPDATE_BYTE_2_BE(v, *p);\r
-  return CRC_UINT32_SWAP(v);\r
-}\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/7zDec.c b/deps/lzma-16.04/C/7zDec.c
deleted file mode 100644 (file)
index e39b4ff..0000000
+++ /dev/null
@@ -1,591 +0,0 @@
-/* 7zDec.c -- Decoding from 7z folder\r
-2015-11-18 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include <string.h>\r
-\r
-/* #define _7ZIP_PPMD_SUPPPORT */\r
-\r
-#include "7z.h"\r
-#include "7zCrc.h"\r
-\r
-#include "Bcj2.h"\r
-#include "Bra.h"\r
-#include "CpuArch.h"\r
-#include "Delta.h"\r
-#include "LzmaDec.h"\r
-#include "Lzma2Dec.h"\r
-#ifdef _7ZIP_PPMD_SUPPPORT\r
-#include "Ppmd7.h"\r
-#endif\r
-\r
-#define k_Copy 0\r
-#define k_Delta 3\r
-#define k_LZMA2 0x21\r
-#define k_LZMA  0x30101\r
-#define k_BCJ   0x3030103\r
-#define k_BCJ2  0x303011B\r
-#define k_PPC   0x3030205\r
-#define k_IA64  0x3030401\r
-#define k_ARM   0x3030501\r
-#define k_ARMT  0x3030701\r
-#define k_SPARC 0x3030805\r
-\r
-\r
-#ifdef _7ZIP_PPMD_SUPPPORT\r
-\r
-#define k_PPMD 0x30401\r
-\r
-typedef struct\r
-{\r
-  IByteIn p;\r
-  const Byte *cur;\r
-  const Byte *end;\r
-  const Byte *begin;\r
-  UInt64 processed;\r
-  Bool extra;\r
-  SRes res;\r
-  ILookInStream *inStream;\r
-} CByteInToLook;\r
-\r
-static Byte ReadByte(void *pp)\r
-{\r
-  CByteInToLook *p = (CByteInToLook *)pp;\r
-  if (p->cur != p->end)\r
-    return *p->cur++;\r
-  if (p->res == SZ_OK)\r
-  {\r
-    size_t size = p->cur - p->begin;\r
-    p->processed += size;\r
-    p->res = p->inStream->Skip(p->inStream, size);\r
-    size = (1 << 25);\r
-    p->res = p->inStream->Look(p->inStream, (const void **)&p->begin, &size);\r
-    p->cur = p->begin;\r
-    p->end = p->begin + size;\r
-    if (size != 0)\r
-      return *p->cur++;;\r
-  }\r
-  p->extra = True;\r
-  return 0;\r
-}\r
-\r
-static SRes SzDecodePpmd(const Byte *props, unsigned propsSize, UInt64 inSize, ILookInStream *inStream,\r
-    Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain)\r
-{\r
-  CPpmd7 ppmd;\r
-  CByteInToLook s;\r
-  SRes res = SZ_OK;\r
-\r
-  s.p.Read = ReadByte;\r
-  s.inStream = inStream;\r
-  s.begin = s.end = s.cur = NULL;\r
-  s.extra = False;\r
-  s.res = SZ_OK;\r
-  s.processed = 0;\r
-\r
-  if (propsSize != 5)\r
-    return SZ_ERROR_UNSUPPORTED;\r
-\r
-  {\r
-    unsigned order = props[0];\r
-    UInt32 memSize = GetUi32(props + 1);\r
-    if (order < PPMD7_MIN_ORDER ||\r
-        order > PPMD7_MAX_ORDER ||\r
-        memSize < PPMD7_MIN_MEM_SIZE ||\r
-        memSize > PPMD7_MAX_MEM_SIZE)\r
-      return SZ_ERROR_UNSUPPORTED;\r
-    Ppmd7_Construct(&ppmd);\r
-    if (!Ppmd7_Alloc(&ppmd, memSize, allocMain))\r
-      return SZ_ERROR_MEM;\r
-    Ppmd7_Init(&ppmd, order);\r
-  }\r
-  {\r
-    CPpmd7z_RangeDec rc;\r
-    Ppmd7z_RangeDec_CreateVTable(&rc);\r
-    rc.Stream = &s.p;\r
-    if (!Ppmd7z_RangeDec_Init(&rc))\r
-      res = SZ_ERROR_DATA;\r
-    else if (s.extra)\r
-      res = (s.res != SZ_OK ? s.res : SZ_ERROR_DATA);\r
-    else\r
-    {\r
-      SizeT i;\r
-      for (i = 0; i < outSize; i++)\r
-      {\r
-        int sym = Ppmd7_DecodeSymbol(&ppmd, &rc.p);\r
-        if (s.extra || sym < 0)\r
-          break;\r
-        outBuffer[i] = (Byte)sym;\r
-      }\r
-      if (i != outSize)\r
-        res = (s.res != SZ_OK ? s.res : SZ_ERROR_DATA);\r
-      else if (s.processed + (s.cur - s.begin) != inSize || !Ppmd7z_RangeDec_IsFinishedOK(&rc))\r
-        res = SZ_ERROR_DATA;\r
-    }\r
-  }\r
-  Ppmd7_Free(&ppmd, allocMain);\r
-  return res;\r
-}\r
-\r
-#endif\r
-\r
-\r
-static SRes SzDecodeLzma(const Byte *props, unsigned propsSize, UInt64 inSize, ILookInStream *inStream,\r
-    Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain)\r
-{\r
-  CLzmaDec state;\r
-  SRes res = SZ_OK;\r
-\r
-  LzmaDec_Construct(&state);\r
-  RINOK(LzmaDec_AllocateProbs(&state, props, propsSize, allocMain));\r
-  state.dic = outBuffer;\r
-  state.dicBufSize = outSize;\r
-  LzmaDec_Init(&state);\r
-\r
-  for (;;)\r
-  {\r
-    const void *inBuf = NULL;\r
-    size_t lookahead = (1 << 18);\r
-    if (lookahead > inSize)\r
-      lookahead = (size_t)inSize;\r
-    res = inStream->Look(inStream, &inBuf, &lookahead);\r
-    if (res != SZ_OK)\r
-      break;\r
-\r
-    {\r
-      SizeT inProcessed = (SizeT)lookahead, dicPos = state.dicPos;\r
-      ELzmaStatus status;\r
-      res = LzmaDec_DecodeToDic(&state, outSize, inBuf, &inProcessed, LZMA_FINISH_END, &status);\r
-      lookahead -= inProcessed;\r
-      inSize -= inProcessed;\r
-      if (res != SZ_OK)\r
-        break;\r
-\r
-      if (status == LZMA_STATUS_FINISHED_WITH_MARK)\r
-      {\r
-        if (outSize != state.dicPos || inSize != 0)\r
-          res = SZ_ERROR_DATA;\r
-        break;\r
-      }\r
-\r
-      if (outSize == state.dicPos && inSize == 0 && status == LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK)\r
-        break;\r
-\r
-      if (inProcessed == 0 && dicPos == state.dicPos)\r
-      {\r
-        res = SZ_ERROR_DATA;\r
-        break;\r
-      }\r
-\r
-      res = inStream->Skip((void *)inStream, inProcessed);\r
-      if (res != SZ_OK)\r
-        break;\r
-    }\r
-  }\r
-\r
-  LzmaDec_FreeProbs(&state, allocMain);\r
-  return res;\r
-}\r
-\r
-\r
-#ifndef _7Z_NO_METHOD_LZMA2\r
-\r
-static SRes SzDecodeLzma2(const Byte *props, unsigned propsSize, UInt64 inSize, ILookInStream *inStream,\r
-    Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain)\r
-{\r
-  CLzma2Dec state;\r
-  SRes res = SZ_OK;\r
-\r
-  Lzma2Dec_Construct(&state);\r
-  if (propsSize != 1)\r
-    return SZ_ERROR_DATA;\r
-  RINOK(Lzma2Dec_AllocateProbs(&state, props[0], allocMain));\r
-  state.decoder.dic = outBuffer;\r
-  state.decoder.dicBufSize = outSize;\r
-  Lzma2Dec_Init(&state);\r
-\r
-  for (;;)\r
-  {\r
-    const void *inBuf = NULL;\r
-    size_t lookahead = (1 << 18);\r
-    if (lookahead > inSize)\r
-      lookahead = (size_t)inSize;\r
-    res = inStream->Look(inStream, &inBuf, &lookahead);\r
-    if (res != SZ_OK)\r
-      break;\r
-\r
-    {\r
-      SizeT inProcessed = (SizeT)lookahead, dicPos = state.decoder.dicPos;\r
-      ELzmaStatus status;\r
-      res = Lzma2Dec_DecodeToDic(&state, outSize, inBuf, &inProcessed, LZMA_FINISH_END, &status);\r
-      lookahead -= inProcessed;\r
-      inSize -= inProcessed;\r
-      if (res != SZ_OK)\r
-        break;\r
-\r
-      if (status == LZMA_STATUS_FINISHED_WITH_MARK)\r
-      {\r
-        if (outSize != state.decoder.dicPos || inSize != 0)\r
-          res = SZ_ERROR_DATA;\r
-        break;\r
-      }\r
-\r
-      if (inProcessed == 0 && dicPos == state.decoder.dicPos)\r
-      {\r
-        res = SZ_ERROR_DATA;\r
-        break;\r
-      }\r
-\r
-      res = inStream->Skip((void *)inStream, inProcessed);\r
-      if (res != SZ_OK)\r
-        break;\r
-    }\r
-  }\r
-\r
-  Lzma2Dec_FreeProbs(&state, allocMain);\r
-  return res;\r
-}\r
-\r
-#endif\r
-\r
-\r
-static SRes SzDecodeCopy(UInt64 inSize, ILookInStream *inStream, Byte *outBuffer)\r
-{\r
-  while (inSize > 0)\r
-  {\r
-    const void *inBuf;\r
-    size_t curSize = (1 << 18);\r
-    if (curSize > inSize)\r
-      curSize = (size_t)inSize;\r
-    RINOK(inStream->Look(inStream, &inBuf, &curSize));\r
-    if (curSize == 0)\r
-      return SZ_ERROR_INPUT_EOF;\r
-    memcpy(outBuffer, inBuf, curSize);\r
-    outBuffer += curSize;\r
-    inSize -= curSize;\r
-    RINOK(inStream->Skip((void *)inStream, curSize));\r
-  }\r
-  return SZ_OK;\r
-}\r
-\r
-static Bool IS_MAIN_METHOD(UInt32 m)\r
-{\r
-  switch (m)\r
-  {\r
-    case k_Copy:\r
-    case k_LZMA:\r
-    #ifndef _7Z_NO_METHOD_LZMA2\r
-    case k_LZMA2:\r
-    #endif\r
-    #ifdef _7ZIP_PPMD_SUPPPORT\r
-    case k_PPMD:\r
-    #endif\r
-      return True;\r
-  }\r
-  return False;\r
-}\r
-\r
-static Bool IS_SUPPORTED_CODER(const CSzCoderInfo *c)\r
-{\r
-  return\r
-      c->NumStreams == 1\r
-      /* && c->MethodID <= (UInt32)0xFFFFFFFF */\r
-      && IS_MAIN_METHOD((UInt32)c->MethodID);\r
-}\r
-\r
-#define IS_BCJ2(c) ((c)->MethodID == k_BCJ2 && (c)->NumStreams == 4)\r
-\r
-static SRes CheckSupportedFolder(const CSzFolder *f)\r
-{\r
-  if (f->NumCoders < 1 || f->NumCoders > 4)\r
-    return SZ_ERROR_UNSUPPORTED;\r
-  if (!IS_SUPPORTED_CODER(&f->Coders[0]))\r
-    return SZ_ERROR_UNSUPPORTED;\r
-  if (f->NumCoders == 1)\r
-  {\r
-    if (f->NumPackStreams != 1 || f->PackStreams[0] != 0 || f->NumBonds != 0)\r
-      return SZ_ERROR_UNSUPPORTED;\r
-    return SZ_OK;\r
-  }\r
-  \r
-  \r
-  #ifndef _7Z_NO_METHODS_FILTERS\r
-\r
-  if (f->NumCoders == 2)\r
-  {\r
-    const CSzCoderInfo *c = &f->Coders[1];\r
-    if (\r
-        /* c->MethodID > (UInt32)0xFFFFFFFF || */\r
-        c->NumStreams != 1\r
-        || f->NumPackStreams != 1\r
-        || f->PackStreams[0] != 0\r
-        || f->NumBonds != 1\r
-        || f->Bonds[0].InIndex != 1\r
-        || f->Bonds[0].OutIndex != 0)\r
-      return SZ_ERROR_UNSUPPORTED;\r
-    switch ((UInt32)c->MethodID)\r
-    {\r
-      case k_Delta:\r
-      case k_BCJ:\r
-      case k_PPC:\r
-      case k_IA64:\r
-      case k_SPARC:\r
-      case k_ARM:\r
-      case k_ARMT:\r
-        break;\r
-      default:\r
-        return SZ_ERROR_UNSUPPORTED;\r
-    }\r
-    return SZ_OK;\r
-  }\r
-\r
-  #endif\r
-\r
-  \r
-  if (f->NumCoders == 4)\r
-  {\r
-    if (!IS_SUPPORTED_CODER(&f->Coders[1])\r
-        || !IS_SUPPORTED_CODER(&f->Coders[2])\r
-        || !IS_BCJ2(&f->Coders[3]))\r
-      return SZ_ERROR_UNSUPPORTED;\r
-    if (f->NumPackStreams != 4\r
-        || f->PackStreams[0] != 2\r
-        || f->PackStreams[1] != 6\r
-        || f->PackStreams[2] != 1\r
-        || f->PackStreams[3] != 0\r
-        || f->NumBonds != 3\r
-        || f->Bonds[0].InIndex != 5 || f->Bonds[0].OutIndex != 0\r
-        || f->Bonds[1].InIndex != 4 || f->Bonds[1].OutIndex != 1\r
-        || f->Bonds[2].InIndex != 3 || f->Bonds[2].OutIndex != 2)\r
-      return SZ_ERROR_UNSUPPORTED;\r
-    return SZ_OK;\r
-  }\r
-  \r
-  return SZ_ERROR_UNSUPPORTED;\r
-}\r
-\r
-#define CASE_BRA_CONV(isa) case k_ ## isa: isa ## _Convert(outBuffer, outSize, 0, 0); break;\r
-\r
-static SRes SzFolder_Decode2(const CSzFolder *folder,\r
-    const Byte *propsData,\r
-    const UInt64 *unpackSizes,\r
-    const UInt64 *packPositions,\r
-    ILookInStream *inStream, UInt64 startPos,\r
-    Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain,\r
-    Byte *tempBuf[])\r
-{\r
-  UInt32 ci;\r
-  SizeT tempSizes[3] = { 0, 0, 0};\r
-  SizeT tempSize3 = 0;\r
-  Byte *tempBuf3 = 0;\r
-\r
-  RINOK(CheckSupportedFolder(folder));\r
-\r
-  for (ci = 0; ci < folder->NumCoders; ci++)\r
-  {\r
-    const CSzCoderInfo *coder = &folder->Coders[ci];\r
-\r
-    if (IS_MAIN_METHOD((UInt32)coder->MethodID))\r
-    {\r
-      UInt32 si = 0;\r
-      UInt64 offset;\r
-      UInt64 inSize;\r
-      Byte *outBufCur = outBuffer;\r
-      SizeT outSizeCur = outSize;\r
-      if (folder->NumCoders == 4)\r
-      {\r
-        UInt32 indices[] = { 3, 2, 0 };\r
-        UInt64 unpackSize = unpackSizes[ci];\r
-        si = indices[ci];\r
-        if (ci < 2)\r
-        {\r
-          Byte *temp;\r
-          outSizeCur = (SizeT)unpackSize;\r
-          if (outSizeCur != unpackSize)\r
-            return SZ_ERROR_MEM;\r
-          temp = (Byte *)IAlloc_Alloc(allocMain, outSizeCur);\r
-          if (!temp && outSizeCur != 0)\r
-            return SZ_ERROR_MEM;\r
-          outBufCur = tempBuf[1 - ci] = temp;\r
-          tempSizes[1 - ci] = outSizeCur;\r
-        }\r
-        else if (ci == 2)\r
-        {\r
-          if (unpackSize > outSize) /* check it */\r
-            return SZ_ERROR_PARAM;\r
-          tempBuf3 = outBufCur = outBuffer + (outSize - (size_t)unpackSize);\r
-          tempSize3 = outSizeCur = (SizeT)unpackSize;\r
-        }\r
-        else\r
-          return SZ_ERROR_UNSUPPORTED;\r
-      }\r
-      offset = packPositions[si];\r
-      inSize = packPositions[si + 1] - offset;\r
-      RINOK(LookInStream_SeekTo(inStream, startPos + offset));\r
-\r
-      if (coder->MethodID == k_Copy)\r
-      {\r
-        if (inSize != outSizeCur) /* check it */\r
-          return SZ_ERROR_DATA;\r
-        RINOK(SzDecodeCopy(inSize, inStream, outBufCur));\r
-      }\r
-      else if (coder->MethodID == k_LZMA)\r
-      {\r
-        RINOK(SzDecodeLzma(propsData + coder->PropsOffset, coder->PropsSize, inSize, inStream, outBufCur, outSizeCur, allocMain));\r
-      }\r
-      #ifndef _7Z_NO_METHOD_LZMA2\r
-      else if (coder->MethodID == k_LZMA2)\r
-      {\r
-        RINOK(SzDecodeLzma2(propsData + coder->PropsOffset, coder->PropsSize, inSize, inStream, outBufCur, outSizeCur, allocMain));\r
-      }\r
-      #endif\r
-      #ifdef _7ZIP_PPMD_SUPPPORT\r
-      else if (coder->MethodID == k_PPMD)\r
-      {\r
-        RINOK(SzDecodePpmd(propsData + coder->PropsOffset, coder->PropsSize, inSize, inStream, outBufCur, outSizeCur, allocMain));\r
-      }\r
-      #endif\r
-      else\r
-        return SZ_ERROR_UNSUPPORTED;\r
-    }\r
-    else if (coder->MethodID == k_BCJ2)\r
-    {\r
-      UInt64 offset = packPositions[1];\r
-      UInt64 s3Size = packPositions[2] - offset;\r
-      \r
-      if (ci != 3)\r
-        return SZ_ERROR_UNSUPPORTED;\r
-      \r
-      tempSizes[2] = (SizeT)s3Size;\r
-      if (tempSizes[2] != s3Size)\r
-        return SZ_ERROR_MEM;\r
-      tempBuf[2] = (Byte *)IAlloc_Alloc(allocMain, tempSizes[2]);\r
-      if (!tempBuf[2] && tempSizes[2] != 0)\r
-        return SZ_ERROR_MEM;\r
-      \r
-      RINOK(LookInStream_SeekTo(inStream, startPos + offset));\r
-      RINOK(SzDecodeCopy(s3Size, inStream, tempBuf[2]));\r
-\r
-      if ((tempSizes[0] & 3) != 0 ||\r
-          (tempSizes[1] & 3) != 0 ||\r
-          tempSize3 + tempSizes[0] + tempSizes[1] != outSize)\r
-        return SZ_ERROR_DATA;\r
-\r
-      {\r
-        CBcj2Dec p;\r
-        \r
-        p.bufs[0] = tempBuf3;   p.lims[0] = tempBuf3 + tempSize3;\r
-        p.bufs[1] = tempBuf[0]; p.lims[1] = tempBuf[0] + tempSizes[0];\r
-        p.bufs[2] = tempBuf[1]; p.lims[2] = tempBuf[1] + tempSizes[1];\r
-        p.bufs[3] = tempBuf[2]; p.lims[3] = tempBuf[2] + tempSizes[2];\r
-        \r
-        p.dest = outBuffer;\r
-        p.destLim = outBuffer + outSize;\r
-        \r
-        Bcj2Dec_Init(&p);\r
-        RINOK(Bcj2Dec_Decode(&p));\r
-\r
-        {\r
-          unsigned i;\r
-          for (i = 0; i < 4; i++)\r
-            if (p.bufs[i] != p.lims[i])\r
-              return SZ_ERROR_DATA;\r
-          \r
-          if (!Bcj2Dec_IsFinished(&p))\r
-            return SZ_ERROR_DATA;\r
-\r
-          if (p.dest != p.destLim\r
-             || p.state != BCJ2_STREAM_MAIN)\r
-            return SZ_ERROR_DATA;\r
-        }\r
-      }\r
-    }\r
-    #ifndef _7Z_NO_METHODS_FILTERS\r
-    else if (ci == 1)\r
-    {\r
-      if (coder->MethodID == k_Delta)\r
-      {\r
-        if (coder->PropsSize != 1)\r
-          return SZ_ERROR_UNSUPPORTED;\r
-        {\r
-          Byte state[DELTA_STATE_SIZE];\r
-          Delta_Init(state);\r
-          Delta_Decode(state, (unsigned)(propsData[coder->PropsOffset]) + 1, outBuffer, outSize);\r
-        }\r
-      }\r
-      else\r
-      {\r
-        if (coder->PropsSize != 0)\r
-          return SZ_ERROR_UNSUPPORTED;\r
-        switch (coder->MethodID)\r
-        {\r
-          case k_BCJ:\r
-          {\r
-            UInt32 state;\r
-            x86_Convert_Init(state);\r
-            x86_Convert(outBuffer, outSize, 0, &state, 0);\r
-            break;\r
-          }\r
-          CASE_BRA_CONV(PPC)\r
-          CASE_BRA_CONV(IA64)\r
-          CASE_BRA_CONV(SPARC)\r
-          CASE_BRA_CONV(ARM)\r
-          CASE_BRA_CONV(ARMT)\r
-          default:\r
-            return SZ_ERROR_UNSUPPORTED;\r
-        }\r
-      }\r
-    }\r
-    #endif\r
-    else\r
-      return SZ_ERROR_UNSUPPORTED;\r
-  }\r
-\r
-  return SZ_OK;\r
-}\r
-\r
-\r
-SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex,\r
-    ILookInStream *inStream, UInt64 startPos,\r
-    Byte *outBuffer, size_t outSize,\r
-    ISzAlloc *allocMain)\r
-{\r
-  SRes res;\r
-  CSzFolder folder;\r
-  CSzData sd;\r
-  \r
-  const Byte *data = p->CodersData + p->FoCodersOffsets[folderIndex];\r
-  sd.Data = data;\r
-  sd.Size = p->FoCodersOffsets[folderIndex + 1] - p->FoCodersOffsets[folderIndex];\r
-  \r
-  res = SzGetNextFolderItem(&folder, &sd);\r
-  \r
-  if (res != SZ_OK)\r
-    return res;\r
-\r
-  if (sd.Size != 0\r
-      || folder.UnpackStream != p->FoToMainUnpackSizeIndex[folderIndex]\r
-      || outSize != SzAr_GetFolderUnpackSize(p, folderIndex))\r
-    return SZ_ERROR_FAIL;\r
-  {\r
-    unsigned i;\r
-    Byte *tempBuf[3] = { 0, 0, 0};\r
-\r
-    res = SzFolder_Decode2(&folder, data,\r
-        &p->CoderUnpackSizes[p->FoToCoderUnpackSizes[folderIndex]],\r
-        p->PackPositions + p->FoStartPackStreamIndex[folderIndex],\r
-        inStream, startPos,\r
-        outBuffer, (SizeT)outSize, allocMain, tempBuf);\r
-    \r
-    for (i = 0; i < 3; i++)\r
-      IAlloc_Free(allocMain, tempBuf[i]);\r
-\r
-    if (res == SZ_OK)\r
-      if (SzBitWithVals_Check(&p->FolderCRCs, folderIndex))\r
-        if (CrcCalc(outBuffer, outSize) != p->FolderCRCs.Vals[folderIndex])\r
-          res = SZ_ERROR_CRC;\r
-\r
-    return res;\r
-  }\r
-}\r
diff --git a/deps/lzma-16.04/C/7zFile.c b/deps/lzma-16.04/C/7zFile.c
deleted file mode 100644 (file)
index 98fe716..0000000
+++ /dev/null
@@ -1,286 +0,0 @@
-/* 7zFile.c -- File IO\r
-2009-11-24 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "7zFile.h"\r
-\r
-#ifndef USE_WINDOWS_FILE\r
-\r
-#ifndef UNDER_CE\r
-#include <errno.h>\r
-#endif\r
-\r
-#else\r
-\r
-/*\r
-   ReadFile and WriteFile functions in Windows have BUG:\r
-   If you Read or Write 64MB or more (probably min_failure_size = 64MB - 32KB + 1)\r
-   from/to Network file, it returns ERROR_NO_SYSTEM_RESOURCES\r
-   (Insufficient system resources exist to complete the requested service).\r
-   Probably in some version of Windows there are problems with other sizes:\r
-   for 32 MB (maybe also for 16 MB).\r
-   And message can be "Network connection was lost"\r
-*/\r
-\r
-#define kChunkSizeMax (1 << 22)\r
-\r
-#endif\r
-\r
-void File_Construct(CSzFile *p)\r
-{\r
-  #ifdef USE_WINDOWS_FILE\r
-  p->handle = INVALID_HANDLE_VALUE;\r
-  #else\r
-  p->file = NULL;\r
-  #endif\r
-}\r
-\r
-#if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE)\r
-static WRes File_Open(CSzFile *p, const char *name, int writeMode)\r
-{\r
-  #ifdef USE_WINDOWS_FILE\r
-  p->handle = CreateFileA(name,\r
-      writeMode ? GENERIC_WRITE : GENERIC_READ,\r
-      FILE_SHARE_READ, NULL,\r
-      writeMode ? CREATE_ALWAYS : OPEN_EXISTING,\r
-      FILE_ATTRIBUTE_NORMAL, NULL);\r
-  return (p->handle != INVALID_HANDLE_VALUE) ? 0 : GetLastError();\r
-  #else\r
-  p->file = fopen(name, writeMode ? "wb+" : "rb");\r
-  return (p->file != 0) ? 0 :\r
-    #ifdef UNDER_CE\r
-    2; /* ENOENT */\r
-    #else\r
-    errno;\r
-    #endif\r
-  #endif\r
-}\r
-\r
-WRes InFile_Open(CSzFile *p, const char *name) { return File_Open(p, name, 0); }\r
-WRes OutFile_Open(CSzFile *p, const char *name) { return File_Open(p, name, 1); }\r
-#endif\r
-\r
-#ifdef USE_WINDOWS_FILE\r
-static WRes File_OpenW(CSzFile *p, const WCHAR *name, int writeMode)\r
-{\r
-  p->handle = CreateFileW(name,\r
-      writeMode ? GENERIC_WRITE : GENERIC_READ,\r
-      FILE_SHARE_READ, NULL,\r
-      writeMode ? CREATE_ALWAYS : OPEN_EXISTING,\r
-      FILE_ATTRIBUTE_NORMAL, NULL);\r
-  return (p->handle != INVALID_HANDLE_VALUE) ? 0 : GetLastError();\r
-}\r
-WRes InFile_OpenW(CSzFile *p, const WCHAR *name) { return File_OpenW(p, name, 0); }\r
-WRes OutFile_OpenW(CSzFile *p, const WCHAR *name) { return File_OpenW(p, name, 1); }\r
-#endif\r
-\r
-WRes File_Close(CSzFile *p)\r
-{\r
-  #ifdef USE_WINDOWS_FILE\r
-  if (p->handle != INVALID_HANDLE_VALUE)\r
-  {\r
-    if (!CloseHandle(p->handle))\r
-      return GetLastError();\r
-    p->handle = INVALID_HANDLE_VALUE;\r
-  }\r
-  #else\r
-  if (p->file != NULL)\r
-  {\r
-    int res = fclose(p->file);\r
-    if (res != 0)\r
-      return res;\r
-    p->file = NULL;\r
-  }\r
-  #endif\r
-  return 0;\r
-}\r
-\r
-WRes File_Read(CSzFile *p, void *data, size_t *size)\r
-{\r
-  size_t originalSize = *size;\r
-  if (originalSize == 0)\r
-    return 0;\r
-\r
-  #ifdef USE_WINDOWS_FILE\r
-\r
-  *size = 0;\r
-  do\r
-  {\r
-    DWORD curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : (DWORD)originalSize;\r
-    DWORD processed = 0;\r
-    BOOL res = ReadFile(p->handle, data, curSize, &processed, NULL);\r
-    data = (void *)((Byte *)data + processed);\r
-    originalSize -= processed;\r
-    *size += processed;\r
-    if (!res)\r
-      return GetLastError();\r
-    if (processed == 0)\r
-      break;\r
-  }\r
-  while (originalSize > 0);\r
-  return 0;\r
-\r
-  #else\r
-  \r
-  *size = fread(data, 1, originalSize, p->file);\r
-  if (*size == originalSize)\r
-    return 0;\r
-  return ferror(p->file);\r
-  \r
-  #endif\r
-}\r
-\r
-WRes File_Write(CSzFile *p, const void *data, size_t *size)\r
-{\r
-  size_t originalSize = *size;\r
-  if (originalSize == 0)\r
-    return 0;\r
-  \r
-  #ifdef USE_WINDOWS_FILE\r
-\r
-  *size = 0;\r
-  do\r
-  {\r
-    DWORD curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : (DWORD)originalSize;\r
-    DWORD processed = 0;\r
-    BOOL res = WriteFile(p->handle, data, curSize, &processed, NULL);\r
-    data = (void *)((Byte *)data + processed);\r
-    originalSize -= processed;\r
-    *size += processed;\r
-    if (!res)\r
-      return GetLastError();\r
-    if (processed == 0)\r
-      break;\r
-  }\r
-  while (originalSize > 0);\r
-  return 0;\r
-\r
-  #else\r
-\r
-  *size = fwrite(data, 1, originalSize, p->file);\r
-  if (*size == originalSize)\r
-    return 0;\r
-  return ferror(p->file);\r
-  \r
-  #endif\r
-}\r
-\r
-WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin)\r
-{\r
-  #ifdef USE_WINDOWS_FILE\r
-\r
-  LARGE_INTEGER value;\r
-  DWORD moveMethod;\r
-  value.LowPart = (DWORD)*pos;\r
-  value.HighPart = (LONG)((UInt64)*pos >> 16 >> 16); /* for case when UInt64 is 32-bit only */\r
-  switch (origin)\r
-  {\r
-    case SZ_SEEK_SET: moveMethod = FILE_BEGIN; break;\r
-    case SZ_SEEK_CUR: moveMethod = FILE_CURRENT; break;\r
-    case SZ_SEEK_END: moveMethod = FILE_END; break;\r
-    default: return ERROR_INVALID_PARAMETER;\r
-  }\r
-  value.LowPart = SetFilePointer(p->handle, value.LowPart, &value.HighPart, moveMethod);\r
-  if (value.LowPart == 0xFFFFFFFF)\r
-  {\r
-    WRes res = GetLastError();\r
-    if (res != NO_ERROR)\r
-      return res;\r
-  }\r
-  *pos = ((Int64)value.HighPart << 32) | value.LowPart;\r
-  return 0;\r
-\r
-  #else\r
-  \r
-  int moveMethod;\r
-  int res;\r
-  switch (origin)\r
-  {\r
-    case SZ_SEEK_SET: moveMethod = SEEK_SET; break;\r
-    case SZ_SEEK_CUR: moveMethod = SEEK_CUR; break;\r
-    case SZ_SEEK_END: moveMethod = SEEK_END; break;\r
-    default: return 1;\r
-  }\r
-  res = fseek(p->file, (long)*pos, moveMethod);\r
-  *pos = ftell(p->file);\r
-  return res;\r
-  \r
-  #endif\r
-}\r
-\r
-WRes File_GetLength(CSzFile *p, UInt64 *length)\r
-{\r
-  #ifdef USE_WINDOWS_FILE\r
-  \r
-  DWORD sizeHigh;\r
-  DWORD sizeLow = GetFileSize(p->handle, &sizeHigh);\r
-  if (sizeLow == 0xFFFFFFFF)\r
-  {\r
-    DWORD res = GetLastError();\r
-    if (res != NO_ERROR)\r
-      return res;\r
-  }\r
-  *length = (((UInt64)sizeHigh) << 32) + sizeLow;\r
-  return 0;\r
-  \r
-  #else\r
-  \r
-  long pos = ftell(p->file);\r
-  int res = fseek(p->file, 0, SEEK_END);\r
-  *length = ftell(p->file);\r
-  fseek(p->file, pos, SEEK_SET);\r
-  return res;\r
-  \r
-  #endif\r
-}\r
-\r
-\r
-/* ---------- FileSeqInStream ---------- */\r
-\r
-static SRes FileSeqInStream_Read(void *pp, void *buf, size_t *size)\r
-{\r
-  CFileSeqInStream *p = (CFileSeqInStream *)pp;\r
-  return File_Read(&p->file, buf, size) == 0 ? SZ_OK : SZ_ERROR_READ;\r
-}\r
-\r
-void FileSeqInStream_CreateVTable(CFileSeqInStream *p)\r
-{\r
-  p->s.Read = FileSeqInStream_Read;\r
-}\r
-\r
-\r
-/* ---------- FileInStream ---------- */\r
-\r
-static SRes FileInStream_Read(void *pp, void *buf, size_t *size)\r
-{\r
-  CFileInStream *p = (CFileInStream *)pp;\r
-  return (File_Read(&p->file, buf, size) == 0) ? SZ_OK : SZ_ERROR_READ;\r
-}\r
-\r
-static SRes FileInStream_Seek(void *pp, Int64 *pos, ESzSeek origin)\r
-{\r
-  CFileInStream *p = (CFileInStream *)pp;\r
-  return File_Seek(&p->file, pos, origin);\r
-}\r
-\r
-void FileInStream_CreateVTable(CFileInStream *p)\r
-{\r
-  p->s.Read = FileInStream_Read;\r
-  p->s.Seek = FileInStream_Seek;\r
-}\r
-\r
-\r
-/* ---------- FileOutStream ---------- */\r
-\r
-static size_t FileOutStream_Write(void *pp, const void *data, size_t size)\r
-{\r
-  CFileOutStream *p = (CFileOutStream *)pp;\r
-  File_Write(&p->file, data, &size);\r
-  return size;\r
-}\r
-\r
-void FileOutStream_CreateVTable(CFileOutStream *p)\r
-{\r
-  p->s.Write = FileOutStream_Write;\r
-}\r
diff --git a/deps/lzma-16.04/C/7zFile.h b/deps/lzma-16.04/C/7zFile.h
deleted file mode 100644 (file)
index d62a192..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/* 7zFile.h -- File IO\r
-2013-01-18 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __7Z_FILE_H\r
-#define __7Z_FILE_H\r
-\r
-#ifdef _WIN32\r
-#define USE_WINDOWS_FILE\r
-#endif\r
-\r
-#ifdef USE_WINDOWS_FILE\r
-#include <windows.h>\r
-#else\r
-#include <stdio.h>\r
-#endif\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-/* ---------- File ---------- */\r
-\r
-typedef struct\r
-{\r
-  #ifdef USE_WINDOWS_FILE\r
-  HANDLE handle;\r
-  #else\r
-  FILE *file;\r
-  #endif\r
-} CSzFile;\r
-\r
-void File_Construct(CSzFile *p);\r
-#if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE)\r
-WRes InFile_Open(CSzFile *p, const char *name);\r
-WRes OutFile_Open(CSzFile *p, const char *name);\r
-#endif\r
-#ifdef USE_WINDOWS_FILE\r
-WRes InFile_OpenW(CSzFile *p, const WCHAR *name);\r
-WRes OutFile_OpenW(CSzFile *p, const WCHAR *name);\r
-#endif\r
-WRes File_Close(CSzFile *p);\r
-\r
-/* reads max(*size, remain file's size) bytes */\r
-WRes File_Read(CSzFile *p, void *data, size_t *size);\r
-\r
-/* writes *size bytes */\r
-WRes File_Write(CSzFile *p, const void *data, size_t *size);\r
-\r
-WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin);\r
-WRes File_GetLength(CSzFile *p, UInt64 *length);\r
-\r
-\r
-/* ---------- FileInStream ---------- */\r
-\r
-typedef struct\r
-{\r
-  ISeqInStream s;\r
-  CSzFile file;\r
-} CFileSeqInStream;\r
-\r
-void FileSeqInStream_CreateVTable(CFileSeqInStream *p);\r
-\r
-\r
-typedef struct\r
-{\r
-  ISeekInStream s;\r
-  CSzFile file;\r
-} CFileInStream;\r
-\r
-void FileInStream_CreateVTable(CFileInStream *p);\r
-\r
-\r
-typedef struct\r
-{\r
-  ISeqOutStream s;\r
-  CSzFile file;\r
-} CFileOutStream;\r
-\r
-void FileOutStream_CreateVTable(CFileOutStream *p);\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/7zStream.c b/deps/lzma-16.04/C/7zStream.c
deleted file mode 100644 (file)
index 5a92d53..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-/* 7zStream.c -- 7z Stream functions\r
-2013-11-12 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include <string.h>\r
-\r
-#include "7zTypes.h"\r
-\r
-SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType)\r
-{\r
-  while (size != 0)\r
-  {\r
-    size_t processed = size;\r
-    RINOK(stream->Read(stream, buf, &processed));\r
-    if (processed == 0)\r
-      return errorType;\r
-    buf = (void *)((Byte *)buf + processed);\r
-    size -= processed;\r
-  }\r
-  return SZ_OK;\r
-}\r
-\r
-SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size)\r
-{\r
-  return SeqInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF);\r
-}\r
-\r
-SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf)\r
-{\r
-  size_t processed = 1;\r
-  RINOK(stream->Read(stream, buf, &processed));\r
-  return (processed == 1) ? SZ_OK : SZ_ERROR_INPUT_EOF;\r
-}\r
-\r
-SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset)\r
-{\r
-  Int64 t = offset;\r
-  return stream->Seek(stream, &t, SZ_SEEK_SET);\r
-}\r
-\r
-SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size)\r
-{\r
-  const void *lookBuf;\r
-  if (*size == 0)\r
-    return SZ_OK;\r
-  RINOK(stream->Look(stream, &lookBuf, size));\r
-  memcpy(buf, lookBuf, *size);\r
-  return stream->Skip(stream, *size);\r
-}\r
-\r
-SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType)\r
-{\r
-  while (size != 0)\r
-  {\r
-    size_t processed = size;\r
-    RINOK(stream->Read(stream, buf, &processed));\r
-    if (processed == 0)\r
-      return errorType;\r
-    buf = (void *)((Byte *)buf + processed);\r
-    size -= processed;\r
-  }\r
-  return SZ_OK;\r
-}\r
-\r
-SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size)\r
-{\r
-  return LookInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF);\r
-}\r
-\r
-static SRes LookToRead_Look_Lookahead(void *pp, const void **buf, size_t *size)\r
-{\r
-  SRes res = SZ_OK;\r
-  CLookToRead *p = (CLookToRead *)pp;\r
-  size_t size2 = p->size - p->pos;\r
-  if (size2 == 0 && *size > 0)\r
-  {\r
-    p->pos = 0;\r
-    size2 = LookToRead_BUF_SIZE;\r
-    res = p->realStream->Read(p->realStream, p->buf, &size2);\r
-    p->size = size2;\r
-  }\r
-  if (size2 < *size)\r
-    *size = size2;\r
-  *buf = p->buf + p->pos;\r
-  return res;\r
-}\r
-\r
-static SRes LookToRead_Look_Exact(void *pp, const void **buf, size_t *size)\r
-{\r
-  SRes res = SZ_OK;\r
-  CLookToRead *p = (CLookToRead *)pp;\r
-  size_t size2 = p->size - p->pos;\r
-  if (size2 == 0 && *size > 0)\r
-  {\r
-    p->pos = 0;\r
-    if (*size > LookToRead_BUF_SIZE)\r
-      *size = LookToRead_BUF_SIZE;\r
-    res = p->realStream->Read(p->realStream, p->buf, size);\r
-    size2 = p->size = *size;\r
-  }\r
-  if (size2 < *size)\r
-    *size = size2;\r
-  *buf = p->buf + p->pos;\r
-  return res;\r
-}\r
-\r
-static SRes LookToRead_Skip(void *pp, size_t offset)\r
-{\r
-  CLookToRead *p = (CLookToRead *)pp;\r
-  p->pos += offset;\r
-  return SZ_OK;\r
-}\r
-\r
-static SRes LookToRead_Read(void *pp, void *buf, size_t *size)\r
-{\r
-  CLookToRead *p = (CLookToRead *)pp;\r
-  size_t rem = p->size - p->pos;\r
-  if (rem == 0)\r
-    return p->realStream->Read(p->realStream, buf, size);\r
-  if (rem > *size)\r
-    rem = *size;\r
-  memcpy(buf, p->buf + p->pos, rem);\r
-  p->pos += rem;\r
-  *size = rem;\r
-  return SZ_OK;\r
-}\r
-\r
-static SRes LookToRead_Seek(void *pp, Int64 *pos, ESzSeek origin)\r
-{\r
-  CLookToRead *p = (CLookToRead *)pp;\r
-  p->pos = p->size = 0;\r
-  return p->realStream->Seek(p->realStream, pos, origin);\r
-}\r
-\r
-void LookToRead_CreateVTable(CLookToRead *p, int lookahead)\r
-{\r
-  p->s.Look = lookahead ?\r
-      LookToRead_Look_Lookahead :\r
-      LookToRead_Look_Exact;\r
-  p->s.Skip = LookToRead_Skip;\r
-  p->s.Read = LookToRead_Read;\r
-  p->s.Seek = LookToRead_Seek;\r
-}\r
-\r
-void LookToRead_Init(CLookToRead *p)\r
-{\r
-  p->pos = p->size = 0;\r
-}\r
-\r
-static SRes SecToLook_Read(void *pp, void *buf, size_t *size)\r
-{\r
-  CSecToLook *p = (CSecToLook *)pp;\r
-  return LookInStream_LookRead(p->realStream, buf, size);\r
-}\r
-\r
-void SecToLook_CreateVTable(CSecToLook *p)\r
-{\r
-  p->s.Read = SecToLook_Read;\r
-}\r
-\r
-static SRes SecToRead_Read(void *pp, void *buf, size_t *size)\r
-{\r
-  CSecToRead *p = (CSecToRead *)pp;\r
-  return p->realStream->Read(p->realStream, buf, size);\r
-}\r
-\r
-void SecToRead_CreateVTable(CSecToRead *p)\r
-{\r
-  p->s.Read = SecToRead_Read;\r
-}\r
diff --git a/deps/lzma-16.04/C/7zTypes.h b/deps/lzma-16.04/C/7zTypes.h
deleted file mode 100644 (file)
index 894212a..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-/* 7zTypes.h -- Basic types\r
-2013-11-12 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __7Z_TYPES_H\r
-#define __7Z_TYPES_H\r
-\r
-#ifdef _WIN32\r
-/* #include <windows.h> */\r
-#endif\r
-\r
-#include <stddef.h>\r
-\r
-#ifndef EXTERN_C_BEGIN\r
-#ifdef __cplusplus\r
-#define EXTERN_C_BEGIN extern "C" {\r
-#define EXTERN_C_END }\r
-#else\r
-#define EXTERN_C_BEGIN\r
-#define EXTERN_C_END\r
-#endif\r
-#endif\r
-\r
-EXTERN_C_BEGIN\r
-\r
-#define SZ_OK 0\r
-\r
-#define SZ_ERROR_DATA 1\r
-#define SZ_ERROR_MEM 2\r
-#define SZ_ERROR_CRC 3\r
-#define SZ_ERROR_UNSUPPORTED 4\r
-#define SZ_ERROR_PARAM 5\r
-#define SZ_ERROR_INPUT_EOF 6\r
-#define SZ_ERROR_OUTPUT_EOF 7\r
-#define SZ_ERROR_READ 8\r
-#define SZ_ERROR_WRITE 9\r
-#define SZ_ERROR_PROGRESS 10\r
-#define SZ_ERROR_FAIL 11\r
-#define SZ_ERROR_THREAD 12\r
-\r
-#define SZ_ERROR_ARCHIVE 16\r
-#define SZ_ERROR_NO_ARCHIVE 17\r
-\r
-typedef int SRes;\r
-\r
-#ifdef _WIN32\r
-/* typedef DWORD WRes; */\r
-typedef unsigned WRes;\r
-#else\r
-typedef int WRes;\r
-#endif\r
-\r
-#ifndef RINOK\r
-#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }\r
-#endif\r
-\r
-#ifndef DONT_SET_BYTE\r
-typedef unsigned char Byte;\r
-#endif\r
-typedef short Int16;\r
-typedef unsigned short UInt16;\r
-\r
-#ifdef _LZMA_UINT32_IS_ULONG\r
-typedef long Int32;\r
-typedef unsigned long UInt32;\r
-#else\r
-typedef int Int32;\r
-typedef unsigned int UInt32;\r
-#endif\r
-\r
-#ifdef _SZ_NO_INT_64\r
-\r
-/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.\r
-   NOTES: Some code will work incorrectly in that case! */\r
-\r
-typedef long Int64;\r
-typedef unsigned long UInt64;\r
-\r
-#else\r
-\r
-#if defined(_MSC_VER) || defined(__BORLANDC__)\r
-typedef __int64 Int64;\r
-typedef unsigned __int64 UInt64;\r
-#define UINT64_CONST(n) n\r
-#else\r
-typedef long long int Int64;\r
-typedef unsigned long long int UInt64;\r
-#define UINT64_CONST(n) n ## ULL\r
-#endif\r
-\r
-#endif\r
-\r
-#ifdef _LZMA_NO_SYSTEM_SIZE_T\r
-typedef UInt32 SizeT;\r
-#else\r
-typedef size_t SizeT;\r
-#endif\r
-\r
-typedef int Bool;\r
-#define True 1\r
-#define False 0\r
-\r
-\r
-#ifdef _WIN32\r
-#define MY_STD_CALL __stdcall\r
-#else\r
-#define MY_STD_CALL\r
-#endif\r
-\r
-#ifdef _MSC_VER\r
-\r
-#if _MSC_VER >= 1300\r
-#define MY_NO_INLINE __declspec(noinline)\r
-#else\r
-#define MY_NO_INLINE\r
-#endif\r
-\r
-#define MY_CDECL __cdecl\r
-#define MY_FAST_CALL __fastcall\r
-\r
-#else\r
-\r
-#define MY_NO_INLINE\r
-#define MY_CDECL\r
-#define MY_FAST_CALL\r
-\r
-#endif\r
-\r
-\r
-/* The following interfaces use first parameter as pointer to structure */\r
-\r
-typedef struct\r
-{\r
-  Byte (*Read)(void *p); /* reads one byte, returns 0 in case of EOF or error */\r
-} IByteIn;\r
-\r
-typedef struct\r
-{\r
-  void (*Write)(void *p, Byte b);\r
-} IByteOut;\r
-\r
-typedef struct\r
-{\r
-  SRes (*Read)(void *p, void *buf, size_t *size);\r
-    /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.\r
-       (output(*size) < input(*size)) is allowed */\r
-} ISeqInStream;\r
-\r
-/* it can return SZ_ERROR_INPUT_EOF */\r
-SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size);\r
-SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType);\r
-SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf);\r
-\r
-typedef struct\r
-{\r
-  size_t (*Write)(void *p, const void *buf, size_t size);\r
-    /* Returns: result - the number of actually written bytes.\r
-       (result < size) means error */\r
-} ISeqOutStream;\r
-\r
-typedef enum\r
-{\r
-  SZ_SEEK_SET = 0,\r
-  SZ_SEEK_CUR = 1,\r
-  SZ_SEEK_END = 2\r
-} ESzSeek;\r
-\r
-typedef struct\r
-{\r
-  SRes (*Read)(void *p, void *buf, size_t *size);  /* same as ISeqInStream::Read */\r
-  SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);\r
-} ISeekInStream;\r
-\r
-typedef struct\r
-{\r
-  SRes (*Look)(void *p, const void **buf, size_t *size);\r
-    /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.\r
-       (output(*size) > input(*size)) is not allowed\r
-       (output(*size) < input(*size)) is allowed */\r
-  SRes (*Skip)(void *p, size_t offset);\r
-    /* offset must be <= output(*size) of Look */\r
-\r
-  SRes (*Read)(void *p, void *buf, size_t *size);\r
-    /* reads directly (without buffer). It's same as ISeqInStream::Read */\r
-  SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);\r
-} ILookInStream;\r
-\r
-SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size);\r
-SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset);\r
-\r
-/* reads via ILookInStream::Read */\r
-SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType);\r
-SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size);\r
-\r
-#define LookToRead_BUF_SIZE (1 << 14)\r
-\r
-typedef struct\r
-{\r
-  ILookInStream s;\r
-  ISeekInStream *realStream;\r
-  size_t pos;\r
-  size_t size;\r
-  Byte buf[LookToRead_BUF_SIZE];\r
-} CLookToRead;\r
-\r
-void LookToRead_CreateVTable(CLookToRead *p, int lookahead);\r
-void LookToRead_Init(CLookToRead *p);\r
-\r
-typedef struct\r
-{\r
-  ISeqInStream s;\r
-  ILookInStream *realStream;\r
-} CSecToLook;\r
-\r
-void SecToLook_CreateVTable(CSecToLook *p);\r
-\r
-typedef struct\r
-{\r
-  ISeqInStream s;\r
-  ILookInStream *realStream;\r
-} CSecToRead;\r
-\r
-void SecToRead_CreateVTable(CSecToRead *p);\r
-\r
-typedef struct\r
-{\r
-  SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize);\r
-    /* Returns: result. (result != SZ_OK) means break.\r
-       Value (UInt64)(Int64)-1 for size means unknown value. */\r
-} ICompressProgress;\r
-\r
-typedef struct\r
-{\r
-  void *(*Alloc)(void *p, size_t size);\r
-  void (*Free)(void *p, void *address); /* address can be 0 */\r
-} ISzAlloc;\r
-\r
-#define IAlloc_Alloc(p, size) (p)->Alloc((p), size)\r
-#define IAlloc_Free(p, a) (p)->Free((p), a)\r
-\r
-#ifdef _WIN32\r
-\r
-#define CHAR_PATH_SEPARATOR '\\'\r
-#define WCHAR_PATH_SEPARATOR L'\\'\r
-#define STRING_PATH_SEPARATOR "\\"\r
-#define WSTRING_PATH_SEPARATOR L"\\"\r
-\r
-#else\r
-\r
-#define CHAR_PATH_SEPARATOR '/'\r
-#define WCHAR_PATH_SEPARATOR L'/'\r
-#define STRING_PATH_SEPARATOR "/"\r
-#define WSTRING_PATH_SEPARATOR L"/"\r
-\r
-#endif\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/7zVersion.h b/deps/lzma-16.04/C/7zVersion.h
deleted file mode 100644 (file)
index acb67a9..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#define MY_VER_MAJOR 16\r
-#define MY_VER_MINOR 04\r
-#define MY_VER_BUILD 0\r
-#define MY_VERSION_NUMBERS "16.04"\r
-#define MY_VERSION "16.04"\r
-#define MY_DATE "2016-10-04"\r
-#undef MY_COPYRIGHT\r
-#undef MY_VERSION_COPYRIGHT_DATE\r
-#define MY_AUTHOR_NAME "Igor Pavlov"\r
-#define MY_COPYRIGHT_PD "Igor Pavlov : Public domain"\r
-#define MY_COPYRIGHT_CR "Copyright (c) 1999-2016 Igor Pavlov"\r
-\r
-#ifdef USE_COPYRIGHT_CR\r
-  #define MY_COPYRIGHT MY_COPYRIGHT_CR\r
-#else\r
-  #define MY_COPYRIGHT MY_COPYRIGHT_PD\r
-#endif\r
-\r
-#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " : " MY_COPYRIGHT " : " MY_DATE\r
diff --git a/deps/lzma-16.04/C/7zVersion.rc b/deps/lzma-16.04/C/7zVersion.rc
deleted file mode 100644 (file)
index 6ed26de..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#define MY_VS_FFI_FILEFLAGSMASK  0x0000003FL\r
-#define MY_VOS_NT_WINDOWS32  0x00040004L\r
-#define MY_VOS_CE_WINDOWS32  0x00050004L\r
-\r
-#define MY_VFT_APP  0x00000001L\r
-#define MY_VFT_DLL  0x00000002L\r
-\r
-// #include <WinVer.h>\r
-\r
-#ifndef MY_VERSION\r
-#include "7zVersion.h"\r
-#endif\r
-\r
-#define MY_VER MY_VER_MAJOR,MY_VER_MINOR,MY_VER_BUILD,0\r
-\r
-#ifdef DEBUG\r
-#define DBG_FL VS_FF_DEBUG\r
-#else\r
-#define DBG_FL 0\r
-#endif\r
-\r
-#define MY_VERSION_INFO(fileType, descr, intName, origName)  \\r
-LANGUAGE 9, 1 \\r
-1 VERSIONINFO \\r
-  FILEVERSION MY_VER \\r
-  PRODUCTVERSION MY_VER \\r
-  FILEFLAGSMASK MY_VS_FFI_FILEFLAGSMASK \\r
-  FILEFLAGS DBG_FL \\r
-  FILEOS MY_VOS_NT_WINDOWS32 \\r
-  FILETYPE fileType \\r
-  FILESUBTYPE 0x0L \\r
-BEGIN \\r
-    BLOCK "StringFileInfo" \\r
-    BEGIN  \\r
-        BLOCK "040904b0" \\r
-        BEGIN \\r
-            VALUE "CompanyName", "Igor Pavlov" \\r
-            VALUE "FileDescription", descr \\r
-            VALUE "FileVersion", MY_VERSION  \\r
-            VALUE "InternalName", intName \\r
-            VALUE "LegalCopyright", MY_COPYRIGHT \\r
-            VALUE "OriginalFilename", origName \\r
-            VALUE "ProductName", "7-Zip" \\r
-            VALUE "ProductVersion", MY_VERSION \\r
-        END \\r
-    END \\r
-    BLOCK "VarFileInfo" \\r
-    BEGIN \\r
-        VALUE "Translation", 0x409, 1200 \\r
-    END \\r
-END\r
-\r
-#define MY_VERSION_INFO_APP(descr, intName) MY_VERSION_INFO(MY_VFT_APP, descr, intName, intName ".exe")\r
-\r
-#define MY_VERSION_INFO_DLL(descr, intName) MY_VERSION_INFO(MY_VFT_DLL, descr, intName, intName ".dll")\r
diff --git a/deps/lzma-16.04/C/Aes.c b/deps/lzma-16.04/C/Aes.c
deleted file mode 100644 (file)
index 8e658e7..0000000
+++ /dev/null
@@ -1,295 +0,0 @@
-/* Aes.c -- AES encryption / decryption\r
-2016-05-21 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "Aes.h"\r
-#include "CpuArch.h"\r
-\r
-static UInt32 T[256 * 4];\r
-static const Byte Sbox[256] = {\r
-  0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,\r
-  0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,\r
-  0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,\r
-  0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,\r
-  0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,\r
-  0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,\r
-  0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,\r
-  0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,\r
-  0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,\r
-  0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,\r
-  0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,\r
-  0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,\r
-  0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,\r
-  0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,\r
-  0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,\r
-  0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16};\r
-\r
-void MY_FAST_CALL AesCbc_Encode(UInt32 *ivAes, Byte *data, size_t numBlocks);\r
-void MY_FAST_CALL AesCbc_Decode(UInt32 *ivAes, Byte *data, size_t numBlocks);\r
-void MY_FAST_CALL AesCtr_Code(UInt32 *ivAes, Byte *data, size_t numBlocks);\r
-\r
-void MY_FAST_CALL AesCbc_Encode_Intel(UInt32 *ivAes, Byte *data, size_t numBlocks);\r
-void MY_FAST_CALL AesCbc_Decode_Intel(UInt32 *ivAes, Byte *data, size_t numBlocks);\r
-void MY_FAST_CALL AesCtr_Code_Intel(UInt32 *ivAes, Byte *data, size_t numBlocks);\r
-\r
-AES_CODE_FUNC g_AesCbc_Encode;\r
-AES_CODE_FUNC g_AesCbc_Decode;\r
-AES_CODE_FUNC g_AesCtr_Code;\r
-\r
-static UInt32 D[256 * 4];\r
-static Byte InvS[256];\r
-\r
-static const Byte Rcon[11] = { 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 };\r
-\r
-#define xtime(x) ((((x) << 1) ^ (((x) & 0x80) != 0 ? 0x1B : 0)) & 0xFF)\r
-\r
-#define Ui32(a0, a1, a2, a3) ((UInt32)(a0) | ((UInt32)(a1) << 8) | ((UInt32)(a2) << 16) | ((UInt32)(a3) << 24))\r
-\r
-#define gb0(x) ( (x)          & 0xFF)\r
-#define gb1(x) (((x) >> ( 8)) & 0xFF)\r
-#define gb2(x) (((x) >> (16)) & 0xFF)\r
-#define gb3(x) (((x) >> (24)) & 0xFF)\r
-\r
-void AesGenTables(void)\r
-{\r
-  unsigned i;\r
-  for (i = 0; i < 256; i++)\r
-    InvS[Sbox[i]] = (Byte)i;\r
-  \r
-  for (i = 0; i < 256; i++)\r
-  {\r
-    {\r
-      UInt32 a1 = Sbox[i];\r
-      UInt32 a2 = xtime(a1);\r
-      UInt32 a3 = a2 ^ a1;\r
-      T[        i] = Ui32(a2, a1, a1, a3);\r
-      T[0x100 + i] = Ui32(a3, a2, a1, a1);\r
-      T[0x200 + i] = Ui32(a1, a3, a2, a1);\r
-      T[0x300 + i] = Ui32(a1, a1, a3, a2);\r
-    }\r
-    {\r
-      UInt32 a1 = InvS[i];\r
-      UInt32 a2 = xtime(a1);\r
-      UInt32 a4 = xtime(a2);\r
-      UInt32 a8 = xtime(a4);\r
-      UInt32 a9 = a8 ^ a1;\r
-      UInt32 aB = a8 ^ a2 ^ a1;\r
-      UInt32 aD = a8 ^ a4 ^ a1;\r
-      UInt32 aE = a8 ^ a4 ^ a2;\r
-      D[        i] = Ui32(aE, a9, aD, aB);\r
-      D[0x100 + i] = Ui32(aB, aE, a9, aD);\r
-      D[0x200 + i] = Ui32(aD, aB, aE, a9);\r
-      D[0x300 + i] = Ui32(a9, aD, aB, aE);\r
-    }\r
-  }\r
-  \r
-  g_AesCbc_Encode = AesCbc_Encode;\r
-  g_AesCbc_Decode = AesCbc_Decode;\r
-  g_AesCtr_Code = AesCtr_Code;\r
-  \r
-  #ifdef MY_CPU_X86_OR_AMD64\r
-  if (CPU_Is_Aes_Supported())\r
-  {\r
-    g_AesCbc_Encode = AesCbc_Encode_Intel;\r
-    g_AesCbc_Decode = AesCbc_Decode_Intel;\r
-    g_AesCtr_Code = AesCtr_Code_Intel;\r
-  }\r
-  #endif\r
-}\r
-\r
-\r
-#define HT(i, x, s) (T + (x << 8))[gb ## x(s[(i + x) & 3])]\r
-\r
-#define HT4(m, i, s, p) m[i] = \\r
-    HT(i, 0, s) ^ \\r
-    HT(i, 1, s) ^ \\r
-    HT(i, 2, s) ^ \\r
-    HT(i, 3, s) ^ w[p + i]\r
-\r
-#define HT16(m, s, p) \\r
-    HT4(m, 0, s, p); \\r
-    HT4(m, 1, s, p); \\r
-    HT4(m, 2, s, p); \\r
-    HT4(m, 3, s, p); \\r
-\r
-#define FT(i, x) Sbox[gb ## x(m[(i + x) & 3])]\r
-#define FT4(i) dest[i] = Ui32(FT(i, 0), FT(i, 1), FT(i, 2), FT(i, 3)) ^ w[i];\r
-\r
-\r
-#define HD(i, x, s) (D + (x << 8))[gb ## x(s[(i - x) & 3])]\r
-\r
-#define HD4(m, i, s, p) m[i] = \\r
-    HD(i, 0, s) ^ \\r
-    HD(i, 1, s) ^ \\r
-    HD(i, 2, s) ^ \\r
-    HD(i, 3, s) ^ w[p + i];\r
-\r
-#define HD16(m, s, p) \\r
-    HD4(m, 0, s, p); \\r
-    HD4(m, 1, s, p); \\r
-    HD4(m, 2, s, p); \\r
-    HD4(m, 3, s, p); \\r
-\r
-#define FD(i, x) InvS[gb ## x(m[(i - x) & 3])]\r
-#define FD4(i) dest[i] = Ui32(FD(i, 0), FD(i, 1), FD(i, 2), FD(i, 3)) ^ w[i];\r
-\r
-void MY_FAST_CALL Aes_SetKey_Enc(UInt32 *w, const Byte *key, unsigned keySize)\r
-{\r
-  unsigned i, wSize;\r
-  wSize = keySize + 28;\r
-  keySize /= 4;\r
-  w[0] = ((UInt32)keySize / 2) + 3;\r
-  w += 4;\r
-\r
-  for (i = 0; i < keySize; i++, key += 4)\r
-    w[i] = GetUi32(key);\r
-\r
-  for (; i < wSize; i++)\r
-  {\r
-    UInt32 t = w[i - 1];\r
-    unsigned rem = i % keySize;\r
-    if (rem == 0)\r
-      t = Ui32(Sbox[gb1(t)] ^ Rcon[i / keySize], Sbox[gb2(t)], Sbox[gb3(t)], Sbox[gb0(t)]);\r
-    else if (keySize > 6 && rem == 4)\r
-      t = Ui32(Sbox[gb0(t)], Sbox[gb1(t)], Sbox[gb2(t)], Sbox[gb3(t)]);\r
-    w[i] = w[i - keySize] ^ t;\r
-  }\r
-}\r
-\r
-void MY_FAST_CALL Aes_SetKey_Dec(UInt32 *w, const Byte *key, unsigned keySize)\r
-{\r
-  unsigned i, num;\r
-  Aes_SetKey_Enc(w, key, keySize);\r
-  num = keySize + 20;\r
-  w += 8;\r
-  for (i = 0; i < num; i++)\r
-  {\r
-    UInt32 r = w[i];\r
-    w[i] =\r
-      D[        (unsigned)Sbox[gb0(r)]] ^\r
-      D[0x100 + (unsigned)Sbox[gb1(r)]] ^\r
-      D[0x200 + (unsigned)Sbox[gb2(r)]] ^\r
-      D[0x300 + (unsigned)Sbox[gb3(r)]];\r
-  }\r
-}\r
-\r
-/* Aes_Encode and Aes_Decode functions work with little-endian words.\r
-  src and dest are pointers to 4 UInt32 words.\r
-  src and dest can point to same block */\r
-\r
-static void Aes_Encode(const UInt32 *w, UInt32 *dest, const UInt32 *src)\r
-{\r
-  UInt32 s[4];\r
-  UInt32 m[4];\r
-  UInt32 numRounds2 = w[0];\r
-  w += 4;\r
-  s[0] = src[0] ^ w[0];\r
-  s[1] = src[1] ^ w[1];\r
-  s[2] = src[2] ^ w[2];\r
-  s[3] = src[3] ^ w[3];\r
-  w += 4;\r
-  for (;;)\r
-  {\r
-    HT16(m, s, 0);\r
-    if (--numRounds2 == 0)\r
-      break;\r
-    HT16(s, m, 4);\r
-    w += 8;\r
-  }\r
-  w += 4;\r
-  FT4(0); FT4(1); FT4(2); FT4(3);\r
-}\r
-\r
-static void Aes_Decode(const UInt32 *w, UInt32 *dest, const UInt32 *src)\r
-{\r
-  UInt32 s[4];\r
-  UInt32 m[4];\r
-  UInt32 numRounds2 = w[0];\r
-  w += 4 + numRounds2 * 8;\r
-  s[0] = src[0] ^ w[0];\r
-  s[1] = src[1] ^ w[1];\r
-  s[2] = src[2] ^ w[2];\r
-  s[3] = src[3] ^ w[3];\r
-  for (;;)\r
-  {\r
-    w -= 8;\r
-    HD16(m, s, 4);\r
-    if (--numRounds2 == 0)\r
-      break;\r
-    HD16(s, m, 0);\r
-  }\r
-  FD4(0); FD4(1); FD4(2); FD4(3);\r
-}\r
-\r
-void AesCbc_Init(UInt32 *p, const Byte *iv)\r
-{\r
-  unsigned i;\r
-  for (i = 0; i < 4; i++)\r
-    p[i] = GetUi32(iv + i * 4);\r
-}\r
-\r
-void MY_FAST_CALL AesCbc_Encode(UInt32 *p, Byte *data, size_t numBlocks)\r
-{\r
-  for (; numBlocks != 0; numBlocks--, data += AES_BLOCK_SIZE)\r
-  {\r
-    p[0] ^= GetUi32(data);\r
-    p[1] ^= GetUi32(data + 4);\r
-    p[2] ^= GetUi32(data + 8);\r
-    p[3] ^= GetUi32(data + 12);\r
-    \r
-    Aes_Encode(p + 4, p, p);\r
-    \r
-    SetUi32(data,      p[0]);\r
-    SetUi32(data + 4,  p[1]);\r
-    SetUi32(data + 8,  p[2]);\r
-    SetUi32(data + 12, p[3]);\r
-  }\r
-}\r
-\r
-void MY_FAST_CALL AesCbc_Decode(UInt32 *p, Byte *data, size_t numBlocks)\r
-{\r
-  UInt32 in[4], out[4];\r
-  for (; numBlocks != 0; numBlocks--, data += AES_BLOCK_SIZE)\r
-  {\r
-    in[0] = GetUi32(data);\r
-    in[1] = GetUi32(data + 4);\r
-    in[2] = GetUi32(data + 8);\r
-    in[3] = GetUi32(data + 12);\r
-\r
-    Aes_Decode(p + 4, out, in);\r
-\r
-    SetUi32(data,      p[0] ^ out[0]);\r
-    SetUi32(data + 4,  p[1] ^ out[1]);\r
-    SetUi32(data + 8,  p[2] ^ out[2]);\r
-    SetUi32(data + 12, p[3] ^ out[3]);\r
-    \r
-    p[0] = in[0];\r
-    p[1] = in[1];\r
-    p[2] = in[2];\r
-    p[3] = in[3];\r
-  }\r
-}\r
-\r
-void MY_FAST_CALL AesCtr_Code(UInt32 *p, Byte *data, size_t numBlocks)\r
-{\r
-  for (; numBlocks != 0; numBlocks--)\r
-  {\r
-    UInt32 temp[4];\r
-    Byte buf[16];\r
-    int i;\r
-\r
-    if (++p[0] == 0)\r
-      p[1]++;\r
-    \r
-    Aes_Encode(p + 4, temp, p);\r
-    \r
-    SetUi32(buf,      temp[0]);\r
-    SetUi32(buf + 4,  temp[1]);\r
-    SetUi32(buf + 8,  temp[2]);\r
-    SetUi32(buf + 12, temp[3]);\r
-    \r
-    for (i = 0; i < 16; i++)\r
-      *data++ ^= buf[i];\r
-  }\r
-}\r
diff --git a/deps/lzma-16.04/C/Aes.h b/deps/lzma-16.04/C/Aes.h
deleted file mode 100644 (file)
index 381e979..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Aes.h -- AES encryption / decryption\r
-2013-01-18 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __AES_H\r
-#define __AES_H\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-#define AES_BLOCK_SIZE 16\r
-\r
-/* Call AesGenTables one time before other AES functions */\r
-void AesGenTables(void);\r
-\r
-/* UInt32 pointers must be 16-byte aligned */\r
-\r
-/* 16-byte (4 * 32-bit words) blocks: 1 (IV) + 1 (keyMode) + 15 (AES-256 roundKeys) */\r
-#define AES_NUM_IVMRK_WORDS ((1 + 1 + 15) * 4)\r
-\r
-/* aes - 16-byte aligned pointer to keyMode+roundKeys sequence */\r
-/* keySize = 16 or 24 or 32 (bytes) */\r
-typedef void (MY_FAST_CALL *AES_SET_KEY_FUNC)(UInt32 *aes, const Byte *key, unsigned keySize);\r
-void MY_FAST_CALL Aes_SetKey_Enc(UInt32 *aes, const Byte *key, unsigned keySize);\r
-void MY_FAST_CALL Aes_SetKey_Dec(UInt32 *aes, const Byte *key, unsigned keySize);\r
-\r
-/* ivAes - 16-byte aligned pointer to iv+keyMode+roundKeys sequence: UInt32[AES_NUM_IVMRK_WORDS] */\r
-void AesCbc_Init(UInt32 *ivAes, const Byte *iv); /* iv size is AES_BLOCK_SIZE */\r
-/* data - 16-byte aligned pointer to data */\r
-/* numBlocks - the number of 16-byte blocks in data array */\r
-typedef void (MY_FAST_CALL *AES_CODE_FUNC)(UInt32 *ivAes, Byte *data, size_t numBlocks);\r
-extern AES_CODE_FUNC g_AesCbc_Encode;\r
-extern AES_CODE_FUNC g_AesCbc_Decode;\r
-extern AES_CODE_FUNC g_AesCtr_Code;\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/AesOpt.c b/deps/lzma-16.04/C/AesOpt.c
deleted file mode 100644 (file)
index e5d4d26..0000000
+++ /dev/null
@@ -1,184 +0,0 @@
-/* AesOpt.c -- Intel's AES\r
-2013-11-12 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "CpuArch.h"\r
-\r
-#ifdef MY_CPU_X86_OR_AMD64\r
-#if _MSC_VER >= 1500\r
-#define USE_INTEL_AES\r
-#endif\r
-#endif\r
-\r
-#ifdef USE_INTEL_AES\r
-\r
-#include <wmmintrin.h>\r
-\r
-void MY_FAST_CALL AesCbc_Encode_Intel(__m128i *p, __m128i *data, size_t numBlocks)\r
-{\r
-  __m128i m = *p;\r
-  for (; numBlocks != 0; numBlocks--, data++)\r
-  {\r
-    UInt32 numRounds2 = *(const UInt32 *)(p + 1) - 1;\r
-    const __m128i *w = p + 3;\r
-    m = _mm_xor_si128(m, *data);\r
-    m = _mm_xor_si128(m, p[2]);\r
-    do\r
-    {\r
-      m = _mm_aesenc_si128(m, w[0]);\r
-      m = _mm_aesenc_si128(m, w[1]);\r
-      w += 2;\r
-    }\r
-    while (--numRounds2 != 0);\r
-    m = _mm_aesenc_si128(m, w[0]);\r
-    m = _mm_aesenclast_si128(m, w[1]);\r
-    *data = m;\r
-  }\r
-  *p = m;\r
-}\r
-\r
-#define NUM_WAYS 3\r
-\r
-#define AES_OP_W(op, n) { \\r
-    const __m128i t = w[n]; \\r
-    m0 = op(m0, t); \\r
-    m1 = op(m1, t); \\r
-    m2 = op(m2, t); \\r
-    }\r
-\r
-#define AES_DEC(n) AES_OP_W(_mm_aesdec_si128, n)\r
-#define AES_DEC_LAST(n) AES_OP_W(_mm_aesdeclast_si128, n)\r
-#define AES_ENC(n) AES_OP_W(_mm_aesenc_si128, n)\r
-#define AES_ENC_LAST(n) AES_OP_W(_mm_aesenclast_si128, n)\r
-\r
-void MY_FAST_CALL AesCbc_Decode_Intel(__m128i *p, __m128i *data, size_t numBlocks)\r
-{\r
-  __m128i iv = *p;\r
-  for (; numBlocks >= NUM_WAYS; numBlocks -= NUM_WAYS, data += NUM_WAYS)\r
-  {\r
-    UInt32 numRounds2 = *(const UInt32 *)(p + 1);\r
-    const __m128i *w = p + numRounds2 * 2;\r
-    __m128i m0, m1, m2;\r
-    {\r
-      const __m128i t = w[2];\r
-      m0 = _mm_xor_si128(t, data[0]);\r
-      m1 = _mm_xor_si128(t, data[1]);\r
-      m2 = _mm_xor_si128(t, data[2]);\r
-    }\r
-    numRounds2--;\r
-    do\r
-    {\r
-      AES_DEC(1)\r
-      AES_DEC(0)\r
-      w -= 2;\r
-    }\r
-    while (--numRounds2 != 0);\r
-    AES_DEC(1)\r
-    AES_DEC_LAST(0)\r
-\r
-    {\r
-      __m128i t;\r
-      t = _mm_xor_si128(m0, iv); iv = data[0]; data[0] = t;\r
-      t = _mm_xor_si128(m1, iv); iv = data[1]; data[1] = t;\r
-      t = _mm_xor_si128(m2, iv); iv = data[2]; data[2] = t;\r
-    }\r
-  }\r
-  for (; numBlocks != 0; numBlocks--, data++)\r
-  {\r
-    UInt32 numRounds2 = *(const UInt32 *)(p + 1);\r
-    const __m128i *w = p + numRounds2 * 2;\r
-    __m128i m = _mm_xor_si128(w[2], *data);\r
-    numRounds2--;\r
-    do\r
-    {\r
-      m = _mm_aesdec_si128(m, w[1]);\r
-      m = _mm_aesdec_si128(m, w[0]);\r
-      w -= 2;\r
-    }\r
-    while (--numRounds2 != 0);\r
-    m = _mm_aesdec_si128(m, w[1]);\r
-    m = _mm_aesdeclast_si128(m, w[0]);\r
-\r
-    m = _mm_xor_si128(m, iv);\r
-    iv = *data;\r
-    *data = m;\r
-  }\r
-  *p = iv;\r
-}\r
-\r
-void MY_FAST_CALL AesCtr_Code_Intel(__m128i *p, __m128i *data, size_t numBlocks)\r
-{\r
-  __m128i ctr = *p;\r
-  __m128i one;\r
-  one.m128i_u64[0] = 1;\r
-  one.m128i_u64[1] = 0;\r
-  for (; numBlocks >= NUM_WAYS; numBlocks -= NUM_WAYS, data += NUM_WAYS)\r
-  {\r
-    UInt32 numRounds2 = *(const UInt32 *)(p + 1) - 1;\r
-    const __m128i *w = p;\r
-    __m128i m0, m1, m2;\r
-    {\r
-      const __m128i t = w[2];\r
-      ctr = _mm_add_epi64(ctr, one); m0 = _mm_xor_si128(ctr, t);\r
-      ctr = _mm_add_epi64(ctr, one); m1 = _mm_xor_si128(ctr, t);\r
-      ctr = _mm_add_epi64(ctr, one); m2 = _mm_xor_si128(ctr, t);\r
-    }\r
-    w += 3;\r
-    do\r
-    {\r
-      AES_ENC(0)\r
-      AES_ENC(1)\r
-      w += 2;\r
-    }\r
-    while (--numRounds2 != 0);\r
-    AES_ENC(0)\r
-    AES_ENC_LAST(1)\r
-    data[0] = _mm_xor_si128(data[0], m0);\r
-    data[1] = _mm_xor_si128(data[1], m1);\r
-    data[2] = _mm_xor_si128(data[2], m2);\r
-  }\r
-  for (; numBlocks != 0; numBlocks--, data++)\r
-  {\r
-    UInt32 numRounds2 = *(const UInt32 *)(p + 1) - 1;\r
-    const __m128i *w = p;\r
-    __m128i m;\r
-    ctr = _mm_add_epi64(ctr, one);\r
-    m = _mm_xor_si128(ctr, p[2]);\r
-    w += 3;\r
-    do\r
-    {\r
-      m = _mm_aesenc_si128(m, w[0]);\r
-      m = _mm_aesenc_si128(m, w[1]);\r
-      w += 2;\r
-    }\r
-    while (--numRounds2 != 0);\r
-    m = _mm_aesenc_si128(m, w[0]);\r
-    m = _mm_aesenclast_si128(m, w[1]);\r
-    *data = _mm_xor_si128(*data, m);\r
-  }\r
-  *p = ctr;\r
-}\r
-\r
-#else\r
-\r
-void MY_FAST_CALL AesCbc_Encode(UInt32 *ivAes, Byte *data, size_t numBlocks);\r
-void MY_FAST_CALL AesCbc_Decode(UInt32 *ivAes, Byte *data, size_t numBlocks);\r
-void MY_FAST_CALL AesCtr_Code(UInt32 *ivAes, Byte *data, size_t numBlocks);\r
-\r
-void MY_FAST_CALL AesCbc_Encode_Intel(UInt32 *p, Byte *data, size_t numBlocks)\r
-{\r
-  AesCbc_Encode(p, data, numBlocks);\r
-}\r
-\r
-void MY_FAST_CALL AesCbc_Decode_Intel(UInt32 *p, Byte *data, size_t numBlocks)\r
-{\r
-  AesCbc_Decode(p, data, numBlocks);\r
-}\r
-\r
-void MY_FAST_CALL AesCtr_Code_Intel(UInt32 *p, Byte *data, size_t numBlocks)\r
-{\r
-  AesCtr_Code(p, data, numBlocks);\r
-}\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/Alloc.c b/deps/lzma-16.04/C/Alloc.c
deleted file mode 100644 (file)
index 9f1d036..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-/* Alloc.c -- Memory allocation functions\r
-2015-02-21 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#ifdef _WIN32\r
-#include <windows.h>\r
-#endif\r
-#include <stdlib.h>\r
-\r
-#include "Alloc.h"\r
-\r
-/* #define _SZ_ALLOC_DEBUG */\r
-\r
-/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */\r
-#ifdef _SZ_ALLOC_DEBUG\r
-#include <stdio.h>\r
-int g_allocCount = 0;\r
-int g_allocCountMid = 0;\r
-int g_allocCountBig = 0;\r
-#endif\r
-\r
-void *MyAlloc(size_t size)\r
-{\r
-  if (size == 0)\r
-    return 0;\r
-  #ifdef _SZ_ALLOC_DEBUG\r
-  {\r
-    void *p = malloc(size);\r
-    fprintf(stderr, "\nAlloc %10d bytes, count = %10d,  addr = %8X", size, g_allocCount++, (unsigned)p);\r
-    return p;\r
-  }\r
-  #else\r
-  return malloc(size);\r
-  #endif\r
-}\r
-\r
-void MyFree(void *address)\r
-{\r
-  #ifdef _SZ_ALLOC_DEBUG\r
-  if (address != 0)\r
-    fprintf(stderr, "\nFree; count = %10d,  addr = %8X", --g_allocCount, (unsigned)address);\r
-  #endif\r
-  free(address);\r
-}\r
-\r
-#ifdef _WIN32\r
-\r
-void *MidAlloc(size_t size)\r
-{\r
-  if (size == 0)\r
-    return 0;\r
-  #ifdef _SZ_ALLOC_DEBUG\r
-  fprintf(stderr, "\nAlloc_Mid %10d bytes;  count = %10d", size, g_allocCountMid++);\r
-  #endif\r
-  return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);\r
-}\r
-\r
-void MidFree(void *address)\r
-{\r
-  #ifdef _SZ_ALLOC_DEBUG\r
-  if (address != 0)\r
-    fprintf(stderr, "\nFree_Mid; count = %10d", --g_allocCountMid);\r
-  #endif\r
-  if (address == 0)\r
-    return;\r
-  VirtualFree(address, 0, MEM_RELEASE);\r
-}\r
-\r
-#ifndef MEM_LARGE_PAGES\r
-#undef _7ZIP_LARGE_PAGES\r
-#endif\r
-\r
-#ifdef _7ZIP_LARGE_PAGES\r
-SIZE_T g_LargePageSize = 0;\r
-typedef SIZE_T (WINAPI *GetLargePageMinimumP)();\r
-#endif\r
-\r
-void SetLargePageSize()\r
-{\r
-  #ifdef _7ZIP_LARGE_PAGES\r
-  SIZE_T size = 0;\r
-  GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP)\r
-        GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum");\r
-  if (largePageMinimum == 0)\r
-    return;\r
-  size = largePageMinimum();\r
-  if (size == 0 || (size & (size - 1)) != 0)\r
-    return;\r
-  g_LargePageSize = size;\r
-  #endif\r
-}\r
-\r
-\r
-void *BigAlloc(size_t size)\r
-{\r
-  if (size == 0)\r
-    return 0;\r
-  #ifdef _SZ_ALLOC_DEBUG\r
-  fprintf(stderr, "\nAlloc_Big %10d bytes;  count = %10d", size, g_allocCountBig++);\r
-  #endif\r
-  \r
-  #ifdef _7ZIP_LARGE_PAGES\r
-  if (g_LargePageSize != 0 && g_LargePageSize <= (1 << 30) && size >= (1 << 18))\r
-  {\r
-    void *res = VirtualAlloc(0, (size + g_LargePageSize - 1) & (~(g_LargePageSize - 1)),\r
-        MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE);\r
-    if (res != 0)\r
-      return res;\r
-  }\r
-  #endif\r
-  return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);\r
-}\r
-\r
-void BigFree(void *address)\r
-{\r
-  #ifdef _SZ_ALLOC_DEBUG\r
-  if (address != 0)\r
-    fprintf(stderr, "\nFree_Big; count = %10d", --g_allocCountBig);\r
-  #endif\r
-  \r
-  if (address == 0)\r
-    return;\r
-  VirtualFree(address, 0, MEM_RELEASE);\r
-}\r
-\r
-#endif\r
-\r
-\r
-static void *SzAlloc(void *p, size_t size) { UNUSED_VAR(p); return MyAlloc(size); }\r
-static void SzFree(void *p, void *address) { UNUSED_VAR(p); MyFree(address); }\r
-ISzAlloc g_Alloc = { SzAlloc, SzFree };\r
-\r
-static void *SzBigAlloc(void *p, size_t size) { UNUSED_VAR(p); return BigAlloc(size); }\r
-static void SzBigFree(void *p, void *address) { UNUSED_VAR(p); BigFree(address); }\r
-ISzAlloc g_BigAlloc = { SzBigAlloc, SzBigFree };\r
diff --git a/deps/lzma-16.04/C/Alloc.h b/deps/lzma-16.04/C/Alloc.h
deleted file mode 100644 (file)
index 73b282a..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Alloc.h -- Memory allocation functions\r
-2015-02-21 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __COMMON_ALLOC_H\r
-#define __COMMON_ALLOC_H\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-void *MyAlloc(size_t size);\r
-void MyFree(void *address);\r
-\r
-#ifdef _WIN32\r
-\r
-void SetLargePageSize();\r
-\r
-void *MidAlloc(size_t size);\r
-void MidFree(void *address);\r
-void *BigAlloc(size_t size);\r
-void BigFree(void *address);\r
-\r
-#else\r
-\r
-#define MidAlloc(size) MyAlloc(size)\r
-#define MidFree(address) MyFree(address)\r
-#define BigAlloc(size) MyAlloc(size)\r
-#define BigFree(address) MyFree(address)\r
-\r
-#endif\r
-\r
-extern ISzAlloc g_Alloc;\r
-extern ISzAlloc g_BigAlloc;\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/Bcj2.c b/deps/lzma-16.04/C/Bcj2.c
deleted file mode 100644 (file)
index 707362a..0000000
+++ /dev/null
@@ -1,256 +0,0 @@
-/* Bcj2.c -- BCJ2 Decoder (Converter for x86 code)\r
-2015-08-01 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "Bcj2.h"\r
-#include "CpuArch.h"\r
-\r
-#define CProb UInt16\r
-\r
-#define kTopValue ((UInt32)1 << 24)\r
-#define kNumModelBits 11\r
-#define kBitModelTotal (1 << kNumModelBits)\r
-#define kNumMoveBits 5\r
-\r
-#define _IF_BIT_0 ttt = *prob; bound = (p->range >> kNumModelBits) * ttt; if (p->code < bound)\r
-#define _UPDATE_0 p->range = bound; *prob = (CProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits));\r
-#define _UPDATE_1 p->range -= bound; p->code -= bound; *prob = (CProb)(ttt - (ttt >> kNumMoveBits));\r
-\r
-void Bcj2Dec_Init(CBcj2Dec *p)\r
-{\r
-  unsigned i;\r
-\r
-  p->state = BCJ2_DEC_STATE_OK;\r
-  p->ip = 0;\r
-  p->temp[3] = 0;\r
-  p->range = 0;\r
-  p->code = 0;\r
-  for (i = 0; i < sizeof(p->probs) / sizeof(p->probs[0]); i++)\r
-    p->probs[i] = kBitModelTotal >> 1;\r
-}\r
-\r
-SRes Bcj2Dec_Decode(CBcj2Dec *p)\r
-{\r
-  if (p->range <= 5)\r
-  {\r
-    p->state = BCJ2_DEC_STATE_OK;\r
-    for (; p->range != 5; p->range++)\r
-    {\r
-      if (p->range == 1 && p->code != 0)\r
-        return SZ_ERROR_DATA;\r
-      \r
-      if (p->bufs[BCJ2_STREAM_RC] == p->lims[BCJ2_STREAM_RC])\r
-      {\r
-        p->state = BCJ2_STREAM_RC;\r
-        return SZ_OK;\r
-      }\r
-\r
-      p->code = (p->code << 8) | *(p->bufs[BCJ2_STREAM_RC])++;\r
-    }\r
-    \r
-    if (p->code == 0xFFFFFFFF)\r
-      return SZ_ERROR_DATA;\r
-    \r
-    p->range = 0xFFFFFFFF;\r
-  }\r
-  else if (p->state >= BCJ2_DEC_STATE_ORIG_0)\r
-  {\r
-    while (p->state <= BCJ2_DEC_STATE_ORIG_3)\r
-    {\r
-      Byte *dest = p->dest;\r
-      if (dest == p->destLim)\r
-        return SZ_OK;\r
-      *dest = p->temp[p->state++ - BCJ2_DEC_STATE_ORIG_0];\r
-      p->dest = dest + 1;\r
-    }\r
-  }\r
-\r
-  /*\r
-  if (BCJ2_IS_32BIT_STREAM(p->state))\r
-  {\r
-    const Byte *cur = p->bufs[p->state];\r
-    if (cur == p->lims[p->state])\r
-      return SZ_OK;\r
-    p->bufs[p->state] = cur + 4;\r
-    \r
-    {\r
-      UInt32 val;\r
-      Byte *dest;\r
-      SizeT rem;\r
-      \r
-      p->ip += 4;\r
-      val = GetBe32(cur) - p->ip;\r
-      dest = p->dest;\r
-      rem = p->destLim - dest;\r
-      if (rem < 4)\r
-      {\r
-        SizeT i;\r
-        SetUi32(p->temp, val);\r
-        for (i = 0; i < rem; i++)\r
-          dest[i] = p->temp[i];\r
-        p->dest = dest + rem;\r
-        p->state = BCJ2_DEC_STATE_ORIG_0 + (unsigned)rem;\r
-        return SZ_OK;\r
-      }\r
-      SetUi32(dest, val);\r
-      p->temp[3] = (Byte)(val >> 24);\r
-      p->dest = dest + 4;\r
-      p->state = BCJ2_DEC_STATE_OK;\r
-    }\r
-  }\r
-  */\r
-\r
-  for (;;)\r
-  {\r
-    if (BCJ2_IS_32BIT_STREAM(p->state))\r
-      p->state = BCJ2_DEC_STATE_OK;\r
-    else\r
-    {\r
-      if (p->range < kTopValue)\r
-      {\r
-        if (p->bufs[BCJ2_STREAM_RC] == p->lims[BCJ2_STREAM_RC])\r
-        {\r
-          p->state = BCJ2_STREAM_RC;\r
-          return SZ_OK;\r
-        }\r
-        p->range <<= 8;\r
-        p->code = (p->code << 8) | *(p->bufs[BCJ2_STREAM_RC])++;\r
-      }\r
-\r
-      {\r
-        const Byte *src = p->bufs[BCJ2_STREAM_MAIN];\r
-        const Byte *srcLim;\r
-        Byte *dest;\r
-        SizeT num = p->lims[BCJ2_STREAM_MAIN] - src;\r
-        \r
-        if (num == 0)\r
-        {\r
-          p->state = BCJ2_STREAM_MAIN;\r
-          return SZ_OK;\r
-        }\r
-        \r
-        dest = p->dest;\r
-        if (num > (SizeT)(p->destLim - dest))\r
-        {\r
-          num = p->destLim - dest;\r
-          if (num == 0)\r
-          {\r
-            p->state = BCJ2_DEC_STATE_ORIG;\r
-            return SZ_OK;\r
-          }\r
-        }\r
-       \r
-        srcLim = src + num;\r
-\r
-        if (p->temp[3] == 0x0F && (src[0] & 0xF0) == 0x80)\r
-          *dest = src[0];\r
-        else for (;;)\r
-        {\r
-          Byte b = *src;\r
-          *dest = b;\r
-          if (b != 0x0F)\r
-          {\r
-            if ((b & 0xFE) == 0xE8)\r
-              break;\r
-            dest++;\r
-            if (++src != srcLim)\r
-              continue;\r
-            break;\r
-          }\r
-          dest++;\r
-          if (++src == srcLim)\r
-            break;\r
-          if ((*src & 0xF0) != 0x80)\r
-            continue;\r
-          *dest = *src;\r
-          break;\r
-        }\r
-        \r
-        num = src - p->bufs[BCJ2_STREAM_MAIN];\r
-        \r
-        if (src == srcLim)\r
-        {\r
-          p->temp[3] = src[-1];\r
-          p->bufs[BCJ2_STREAM_MAIN] = src;\r
-          p->ip += (UInt32)num;\r
-          p->dest += num;\r
-          p->state =\r
-            p->bufs[BCJ2_STREAM_MAIN] ==\r
-            p->lims[BCJ2_STREAM_MAIN] ?\r
-              (unsigned)BCJ2_STREAM_MAIN :\r
-              (unsigned)BCJ2_DEC_STATE_ORIG;\r
-          return SZ_OK;\r
-        }\r
-        \r
-        {\r
-          UInt32 bound, ttt;\r
-          CProb *prob;\r
-          Byte b = src[0];\r
-          Byte prev = (Byte)(num == 0 ? p->temp[3] : src[-1]);\r
-          \r
-          p->temp[3] = b;\r
-          p->bufs[BCJ2_STREAM_MAIN] = src + 1;\r
-          num++;\r
-          p->ip += (UInt32)num;\r
-          p->dest += num;\r
-          \r
-          prob = p->probs + (unsigned)(b == 0xE8 ? 2 + (unsigned)prev : (b == 0xE9 ? 1 : 0));\r
-          \r
-          _IF_BIT_0\r
-          {\r
-            _UPDATE_0\r
-            continue;\r
-          }\r
-          _UPDATE_1\r
-            \r
-        }\r
-      }\r
-    }\r
-\r
-    {\r
-      UInt32 val;\r
-      unsigned cj = (p->temp[3] == 0xE8) ? BCJ2_STREAM_CALL : BCJ2_STREAM_JUMP;\r
-      const Byte *cur = p->bufs[cj];\r
-      Byte *dest;\r
-      SizeT rem;\r
-      \r
-      if (cur == p->lims[cj])\r
-      {\r
-        p->state = cj;\r
-        break;\r
-      }\r
-      \r
-      val = GetBe32(cur);\r
-      p->bufs[cj] = cur + 4;\r
-\r
-      p->ip += 4;\r
-      val -= p->ip;\r
-      dest = p->dest;\r
-      rem = p->destLim - dest;\r
-      \r
-      if (rem < 4)\r
-      {\r
-        SizeT i;\r
-        SetUi32(p->temp, val);\r
-        for (i = 0; i < rem; i++)\r
-          dest[i] = p->temp[i];\r
-        p->dest = dest + rem;\r
-        p->state = BCJ2_DEC_STATE_ORIG_0 + (unsigned)rem;\r
-        break;\r
-      }\r
-      \r
-      SetUi32(dest, val);\r
-      p->temp[3] = (Byte)(val >> 24);\r
-      p->dest = dest + 4;\r
-    }\r
-  }\r
-\r
-  if (p->range < kTopValue && p->bufs[BCJ2_STREAM_RC] != p->lims[BCJ2_STREAM_RC])\r
-  {\r
-    p->range <<= 8;\r
-    p->code = (p->code << 8) | *(p->bufs[BCJ2_STREAM_RC])++;\r
-  }\r
-\r
-  return SZ_OK;\r
-}\r
diff --git a/deps/lzma-16.04/C/Bcj2.h b/deps/lzma-16.04/C/Bcj2.h
deleted file mode 100644 (file)
index 68893d2..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/* Bcj2.h -- BCJ2 Converter for x86 code\r
-2014-11-10 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __BCJ2_H\r
-#define __BCJ2_H\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-#define BCJ2_NUM_STREAMS 4\r
-\r
-enum\r
-{\r
-  BCJ2_STREAM_MAIN,\r
-  BCJ2_STREAM_CALL,\r
-  BCJ2_STREAM_JUMP,\r
-  BCJ2_STREAM_RC\r
-};\r
-\r
-enum\r
-{\r
-  BCJ2_DEC_STATE_ORIG_0 = BCJ2_NUM_STREAMS,\r
-  BCJ2_DEC_STATE_ORIG_1,\r
-  BCJ2_DEC_STATE_ORIG_2,\r
-  BCJ2_DEC_STATE_ORIG_3,\r
-  \r
-  BCJ2_DEC_STATE_ORIG,\r
-  BCJ2_DEC_STATE_OK\r
-};\r
-\r
-enum\r
-{\r
-  BCJ2_ENC_STATE_ORIG = BCJ2_NUM_STREAMS,\r
-  BCJ2_ENC_STATE_OK\r
-};\r
-\r
-\r
-#define BCJ2_IS_32BIT_STREAM(s) ((s) == BCJ2_STREAM_CALL || (s) == BCJ2_STREAM_JUMP)\r
-\r
-/*\r
-CBcj2Dec / CBcj2Enc\r
-bufs sizes:\r
-  BUF_SIZE(n) = lims[n] - bufs[n]\r
-bufs sizes for BCJ2_STREAM_CALL and BCJ2_STREAM_JUMP must be mutliply of 4:\r
-    (BUF_SIZE(BCJ2_STREAM_CALL) & 3) == 0\r
-    (BUF_SIZE(BCJ2_STREAM_JUMP) & 3) == 0\r
-*/\r
-\r
-/*\r
-CBcj2Dec:\r
-dest is allowed to overlap with bufs[BCJ2_STREAM_MAIN], with the following conditions:\r
-  bufs[BCJ2_STREAM_MAIN] >= dest &&\r
-  bufs[BCJ2_STREAM_MAIN] - dest >= tempReserv +\r
-        BUF_SIZE(BCJ2_STREAM_CALL) +\r
-        BUF_SIZE(BCJ2_STREAM_JUMP)\r
-     tempReserv = 0 : for first call of Bcj2Dec_Decode\r
-     tempReserv = 4 : for any other calls of Bcj2Dec_Decode\r
-  overlap with offset = 1 is not allowed\r
-*/\r
-\r
-typedef struct\r
-{\r
-  const Byte *bufs[BCJ2_NUM_STREAMS];\r
-  const Byte *lims[BCJ2_NUM_STREAMS];\r
-  Byte *dest;\r
-  const Byte *destLim;\r
-\r
-  unsigned state; /* BCJ2_STREAM_MAIN has more priority than BCJ2_STATE_ORIG */\r
-\r
-  UInt32 ip;\r
-  Byte temp[4];\r
-  UInt32 range;\r
-  UInt32 code;\r
-  UInt16 probs[2 + 256];\r
-} CBcj2Dec;\r
-\r
-void Bcj2Dec_Init(CBcj2Dec *p);\r
-\r
-/* Returns: SZ_OK or SZ_ERROR_DATA */\r
-SRes Bcj2Dec_Decode(CBcj2Dec *p);\r
-\r
-#define Bcj2Dec_IsFinished(_p_) ((_p_)->code == 0)\r
-\r
-\r
-\r
-typedef enum\r
-{\r
-  BCJ2_ENC_FINISH_MODE_CONTINUE,\r
-  BCJ2_ENC_FINISH_MODE_END_BLOCK,\r
-  BCJ2_ENC_FINISH_MODE_END_STREAM\r
-} EBcj2Enc_FinishMode;\r
-\r
-typedef struct\r
-{\r
-  Byte *bufs[BCJ2_NUM_STREAMS];\r
-  const Byte *lims[BCJ2_NUM_STREAMS];\r
-  const Byte *src;\r
-  const Byte *srcLim;\r
-\r
-  unsigned state;\r
-  EBcj2Enc_FinishMode finishMode;\r
-\r
-  Byte prevByte;\r
-\r
-  Byte cache;\r
-  UInt32 range;\r
-  UInt64 low;\r
-  UInt64 cacheSize;\r
-\r
-  UInt32 ip;\r
-\r
-  /* 32-bit ralative offset in JUMP/CALL commands is\r
-       - (mod 4 GB)   in 32-bit mode\r
-       - signed Int32 in 64-bit mode\r
-     We use (mod 4 GB) check for fileSize.\r
-     Use fileSize up to 2 GB, if you want to support 32-bit and 64-bit code conversion. */\r
-  UInt32 fileIp;\r
-  UInt32 fileSize;    /* (fileSize <= ((UInt32)1 << 31)), 0 means no_limit */\r
-  UInt32 relatLimit;  /* (relatLimit <= ((UInt32)1 << 31)), 0 means desable_conversion */\r
-\r
-  UInt32 tempTarget;\r
-  unsigned tempPos;\r
-  Byte temp[4 * 2];\r
-\r
-  unsigned flushPos;\r
-  \r
-  UInt16 probs[2 + 256];\r
-} CBcj2Enc;\r
-\r
-void Bcj2Enc_Init(CBcj2Enc *p);\r
-void Bcj2Enc_Encode(CBcj2Enc *p);\r
-\r
-#define Bcj2Enc_Get_InputData_Size(p) ((SizeT)((p)->srcLim - (p)->src) + (p)->tempPos)\r
-#define Bcj2Enc_IsFinished(p) ((p)->flushPos == 5)\r
-\r
-\r
-#define BCJ2_RELAT_LIMIT_NUM_BITS 26\r
-#define BCJ2_RELAT_LIMIT ((UInt32)1 << BCJ2_RELAT_LIMIT_NUM_BITS)\r
-\r
-/* limit for CBcj2Enc::fileSize variable */\r
-#define BCJ2_FileSize_MAX ((UInt32)1 << 31)\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/Bcj2Enc.c b/deps/lzma-16.04/C/Bcj2Enc.c
deleted file mode 100644 (file)
index 6a21015..0000000
+++ /dev/null
@@ -1,312 +0,0 @@
-/* Bcj2Enc.c -- BCJ2 Encoder (Converter for x86 code)\r
-2014-11-10 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-/* #define SHOW_STAT */\r
-\r
-#ifdef SHOW_STAT\r
-#include <stdio.h>\r
-#define PRF(x) x\r
-#else\r
-#define PRF(x)\r
-#endif\r
-\r
-#include <windows.h>\r
-#include <string.h>\r
-\r
-#include "Bcj2.h"\r
-#include "CpuArch.h"\r
-\r
-#define CProb UInt16\r
-\r
-#define kTopValue ((UInt32)1 << 24)\r
-#define kNumModelBits 11\r
-#define kBitModelTotal (1 << kNumModelBits)\r
-#define kNumMoveBits 5\r
-\r
-void Bcj2Enc_Init(CBcj2Enc *p)\r
-{\r
-  unsigned i;\r
-\r
-  p->state = BCJ2_ENC_STATE_OK;\r
-  p->finishMode = BCJ2_ENC_FINISH_MODE_CONTINUE;\r
-\r
-  p->prevByte = 0;\r
-\r
-  p->cache = 0;\r
-  p->range = 0xFFFFFFFF;\r
-  p->low = 0;\r
-  p->cacheSize = 1;\r
-\r
-  p->ip = 0;\r
-\r
-  p->fileIp = 0;\r
-  p->fileSize = 0;\r
-  p->relatLimit = BCJ2_RELAT_LIMIT;\r
-\r
-  p->tempPos = 0;\r
-\r
-  p->flushPos = 0;\r
-\r
-  for (i = 0; i < sizeof(p->probs) / sizeof(p->probs[0]); i++)\r
-    p->probs[i] = kBitModelTotal >> 1;\r
-}\r
-\r
-static Bool MY_FAST_CALL RangeEnc_ShiftLow(CBcj2Enc *p)\r
-{\r
-  if ((UInt32)p->low < (UInt32)0xFF000000 || (UInt32)(p->low >> 32) != 0)\r
-  {\r
-    Byte *buf = p->bufs[BCJ2_STREAM_RC];\r
-    do\r
-    {\r
-      if (buf == p->lims[BCJ2_STREAM_RC])\r
-      {\r
-        p->state = BCJ2_STREAM_RC;\r
-        p->bufs[BCJ2_STREAM_RC] = buf;\r
-        return True;\r
-      }\r
-      *buf++ = (Byte)(p->cache + (Byte)(p->low >> 32));\r
-      p->cache = 0xFF;\r
-    }\r
-    while (--p->cacheSize);\r
-    p->bufs[BCJ2_STREAM_RC] = buf;\r
-    p->cache = (Byte)((UInt32)p->low >> 24);\r
-  }\r
-  p->cacheSize++;\r
-  p->low = (UInt32)p->low << 8;\r
-  return False;\r
-}\r
-\r
-static void Bcj2Enc_Encode_2(CBcj2Enc *p)\r
-{\r
-  if (BCJ2_IS_32BIT_STREAM(p->state))\r
-  {\r
-    Byte *cur = p->bufs[p->state];\r
-    if (cur == p->lims[p->state])\r
-      return;\r
-    SetBe32(cur, p->tempTarget);\r
-    p->bufs[p->state] = cur + 4;\r
-  }\r
-\r
-  p->state = BCJ2_ENC_STATE_ORIG;\r
-\r
-  for (;;)\r
-  {\r
-    if (p->range < kTopValue)\r
-    {\r
-      if (RangeEnc_ShiftLow(p))\r
-        return;\r
-      p->range <<= 8;\r
-    }\r
-\r
-    {\r
-      {\r
-        const Byte *src = p->src;\r
-        const Byte *srcLim;\r
-        Byte *dest;\r
-        SizeT num = p->srcLim - src;\r
-\r
-        if (p->finishMode == BCJ2_ENC_FINISH_MODE_CONTINUE)\r
-        {\r
-          if (num <= 4)\r
-            return;\r
-          num -= 4;\r
-        }\r
-        else if (num == 0)\r
-          break;\r
-\r
-        dest = p->bufs[BCJ2_STREAM_MAIN];\r
-        if (num > (SizeT)(p->lims[BCJ2_STREAM_MAIN] - dest))\r
-        {\r
-          num = p->lims[BCJ2_STREAM_MAIN] - dest;\r
-          if (num == 0)\r
-          {\r
-            p->state = BCJ2_STREAM_MAIN;\r
-            return;\r
-          }\r
-        }\r
-       \r
-        srcLim = src + num;\r
-\r
-        if (p->prevByte == 0x0F && (src[0] & 0xF0) == 0x80)\r
-          *dest = src[0];\r
-        else for (;;)\r
-        {\r
-          Byte b = *src;\r
-          *dest = b;\r
-          if (b != 0x0F)\r
-          {\r
-            if ((b & 0xFE) == 0xE8)\r
-              break;\r
-            dest++;\r
-            if (++src != srcLim)\r
-              continue;\r
-            break;\r
-          }\r
-          dest++;\r
-          if (++src == srcLim)\r
-            break;\r
-          if ((*src & 0xF0) != 0x80)\r
-            continue;\r
-          *dest = *src;\r
-          break;\r
-        }\r
-        \r
-        num = src - p->src;\r
-        \r
-        if (src == srcLim)\r
-        {\r
-          p->prevByte = src[-1];\r
-          p->bufs[BCJ2_STREAM_MAIN] = dest;\r
-          p->src = src;\r
-          p->ip += (UInt32)num;\r
-          continue;\r
-        }\r
\r
-        {\r
-          Byte context = (Byte)(num == 0 ? p->prevByte : src[-1]);\r
-          Bool needConvert;\r
-\r
-          p->bufs[BCJ2_STREAM_MAIN] = dest + 1;\r
-          p->ip += (UInt32)num + 1;\r
-          src++;\r
-          \r
-          needConvert = False;\r
-\r
-          if ((SizeT)(p->srcLim - src) >= 4)\r
-          {\r
-            UInt32 relatVal = GetUi32(src);\r
-            if ((p->fileSize == 0 || (UInt32)(p->ip + 4 + relatVal - p->fileIp) < p->fileSize)\r
-                && ((relatVal + p->relatLimit) >> 1) < p->relatLimit)\r
-              needConvert = True;\r
-          }\r
-\r
-          {\r
-            UInt32 bound;\r
-            unsigned ttt;\r
-            Byte b = src[-1];\r
-            CProb *prob = p->probs + (unsigned)(b == 0xE8 ? 2 + (unsigned)context : (b == 0xE9 ? 1 : 0));\r
-\r
-            ttt = *prob;\r
-            bound = (p->range >> kNumModelBits) * ttt;\r
-            \r
-            if (!needConvert)\r
-            {\r
-              p->range = bound;\r
-              *prob = (CProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits));\r
-              p->src = src;\r
-              p->prevByte = b;\r
-              continue;\r
-            }\r
-            \r
-            p->low += bound;\r
-            p->range -= bound;\r
-            *prob = (CProb)(ttt - (ttt >> kNumMoveBits));\r
-\r
-            {\r
-              UInt32 relatVal = GetUi32(src);\r
-              UInt32 absVal;\r
-              p->ip += 4;\r
-              absVal = p->ip + relatVal;\r
-              p->prevByte = src[3];\r
-              src += 4;\r
-              p->src = src;\r
-              {\r
-                unsigned cj = (b == 0xE8) ? BCJ2_STREAM_CALL : BCJ2_STREAM_JUMP;\r
-                Byte *cur = p->bufs[cj];\r
-                if (cur == p->lims[cj])\r
-                {\r
-                  p->state = cj;\r
-                  p->tempTarget = absVal;\r
-                  return;\r
-                }\r
-                SetBe32(cur, absVal);\r
-                p->bufs[cj] = cur + 4;\r
-              }\r
-            }\r
-          }\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  if (p->finishMode != BCJ2_ENC_FINISH_MODE_END_STREAM)\r
-    return;\r
-\r
-  for (; p->flushPos < 5; p->flushPos++)\r
-    if (RangeEnc_ShiftLow(p))\r
-      return;\r
-  p->state = BCJ2_ENC_STATE_OK;\r
-}\r
-\r
-\r
-void Bcj2Enc_Encode(CBcj2Enc *p)\r
-{\r
-  PRF(printf("\n"));\r
-  PRF(printf("---- ip = %8d   tempPos = %8d   src = %8d\n", p->ip, p->tempPos, p->srcLim - p->src));\r
-\r
-  if (p->tempPos != 0)\r
-  {\r
-    unsigned extra = 0;\r
-   \r
-    for (;;)\r
-    {\r
-      const Byte *src = p->src;\r
-      const Byte *srcLim = p->srcLim;\r
-      unsigned finishMode = p->finishMode;\r
-      \r
-      p->src = p->temp;\r
-      p->srcLim = p->temp + p->tempPos;\r
-      if (src != srcLim)\r
-        p->finishMode = BCJ2_ENC_FINISH_MODE_CONTINUE;\r
-      \r
-      PRF(printf("     ip = %8d   tempPos = %8d   src = %8d\n", p->ip, p->tempPos, p->srcLim - p->src));\r
-\r
-      Bcj2Enc_Encode_2(p);\r
-      \r
-      {\r
-        unsigned num = (unsigned)(p->src - p->temp);\r
-        unsigned tempPos = p->tempPos - num;\r
-        unsigned i;\r
-        p->tempPos = tempPos;\r
-        for (i = 0; i < tempPos; i++)\r
-          p->temp[i] = p->temp[i + num];\r
-      \r
-        p->src = src;\r
-        p->srcLim = srcLim;\r
-        p->finishMode = finishMode;\r
-        \r
-        if (p->state != BCJ2_ENC_STATE_ORIG || src == srcLim)\r
-          return;\r
-        \r
-        if (extra >= tempPos)\r
-        {\r
-          p->src = src - tempPos;\r
-          p->tempPos = 0;\r
-          break;\r
-        }\r
-        \r
-        p->temp[tempPos] = src[0];\r
-        p->tempPos = tempPos + 1;\r
-        p->src = src + 1;\r
-        extra++;\r
-      }\r
-    }\r
-  }\r
-\r
-  PRF(printf("++++ ip = %8d   tempPos = %8d   src = %8d\n", p->ip, p->tempPos, p->srcLim - p->src));\r
-\r
-  Bcj2Enc_Encode_2(p);\r
-  \r
-  if (p->state == BCJ2_ENC_STATE_ORIG)\r
-  {\r
-    const Byte *src = p->src;\r
-    unsigned rem = (unsigned)(p->srcLim - src);\r
-    unsigned i;\r
-    for (i = 0; i < rem; i++)\r
-      p->temp[i] = src[i];\r
-    p->tempPos = rem;\r
-    p->src = src + rem;\r
-  }\r
-}\r
diff --git a/deps/lzma-16.04/C/Bra.c b/deps/lzma-16.04/C/Bra.c
deleted file mode 100644 (file)
index 976810c..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/* Bra.c -- Converters for RISC code\r
-2010-04-16 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "Bra.h"\r
-\r
-SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)\r
-{\r
-  SizeT i;\r
-  if (size < 4)\r
-    return 0;\r
-  size -= 4;\r
-  ip += 8;\r
-  for (i = 0; i <= size; i += 4)\r
-  {\r
-    if (data[i + 3] == 0xEB)\r
-    {\r
-      UInt32 dest;\r
-      UInt32 src = ((UInt32)data[i + 2] << 16) | ((UInt32)data[i + 1] << 8) | (data[i + 0]);\r
-      src <<= 2;\r
-      if (encoding)\r
-        dest = ip + (UInt32)i + src;\r
-      else\r
-        dest = src - (ip + (UInt32)i);\r
-      dest >>= 2;\r
-      data[i + 2] = (Byte)(dest >> 16);\r
-      data[i + 1] = (Byte)(dest >> 8);\r
-      data[i + 0] = (Byte)dest;\r
-    }\r
-  }\r
-  return i;\r
-}\r
-\r
-SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)\r
-{\r
-  SizeT i;\r
-  if (size < 4)\r
-    return 0;\r
-  size -= 4;\r
-  ip += 4;\r
-  for (i = 0; i <= size; i += 2)\r
-  {\r
-    if ((data[i + 1] & 0xF8) == 0xF0 &&\r
-        (data[i + 3] & 0xF8) == 0xF8)\r
-    {\r
-      UInt32 dest;\r
-      UInt32 src =\r
-        (((UInt32)data[i + 1] & 0x7) << 19) |\r
-        ((UInt32)data[i + 0] << 11) |\r
-        (((UInt32)data[i + 3] & 0x7) << 8) |\r
-        (data[i + 2]);\r
-      \r
-      src <<= 1;\r
-      if (encoding)\r
-        dest = ip + (UInt32)i + src;\r
-      else\r
-        dest = src - (ip + (UInt32)i);\r
-      dest >>= 1;\r
-      \r
-      data[i + 1] = (Byte)(0xF0 | ((dest >> 19) & 0x7));\r
-      data[i + 0] = (Byte)(dest >> 11);\r
-      data[i + 3] = (Byte)(0xF8 | ((dest >> 8) & 0x7));\r
-      data[i + 2] = (Byte)dest;\r
-      i += 2;\r
-    }\r
-  }\r
-  return i;\r
-}\r
-\r
-SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)\r
-{\r
-  SizeT i;\r
-  if (size < 4)\r
-    return 0;\r
-  size -= 4;\r
-  for (i = 0; i <= size; i += 4)\r
-  {\r
-    if ((data[i] >> 2) == 0x12 && (data[i + 3] & 3) == 1)\r
-    {\r
-      UInt32 src = ((UInt32)(data[i + 0] & 3) << 24) |\r
-        ((UInt32)data[i + 1] << 16) |\r
-        ((UInt32)data[i + 2] << 8) |\r
-        ((UInt32)data[i + 3] & (~3));\r
-      \r
-      UInt32 dest;\r
-      if (encoding)\r
-        dest = ip + (UInt32)i + src;\r
-      else\r
-        dest = src - (ip + (UInt32)i);\r
-      data[i + 0] = (Byte)(0x48 | ((dest >> 24) &  0x3));\r
-      data[i + 1] = (Byte)(dest >> 16);\r
-      data[i + 2] = (Byte)(dest >> 8);\r
-      data[i + 3] &= 0x3;\r
-      data[i + 3] |= dest;\r
-    }\r
-  }\r
-  return i;\r
-}\r
-\r
-SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)\r
-{\r
-  UInt32 i;\r
-  if (size < 4)\r
-    return 0;\r
-  size -= 4;\r
-  for (i = 0; i <= size; i += 4)\r
-  {\r
-    if ((data[i] == 0x40 && (data[i + 1] & 0xC0) == 0x00) ||\r
-        (data[i] == 0x7F && (data[i + 1] & 0xC0) == 0xC0))\r
-    {\r
-      UInt32 src =\r
-        ((UInt32)data[i + 0] << 24) |\r
-        ((UInt32)data[i + 1] << 16) |\r
-        ((UInt32)data[i + 2] << 8) |\r
-        ((UInt32)data[i + 3]);\r
-      UInt32 dest;\r
-      \r
-      src <<= 2;\r
-      if (encoding)\r
-        dest = ip + i + src;\r
-      else\r
-        dest = src - (ip + i);\r
-      dest >>= 2;\r
-      \r
-      dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | 0x40000000;\r
-\r
-      data[i + 0] = (Byte)(dest >> 24);\r
-      data[i + 1] = (Byte)(dest >> 16);\r
-      data[i + 2] = (Byte)(dest >> 8);\r
-      data[i + 3] = (Byte)dest;\r
-    }\r
-  }\r
-  return i;\r
-}\r
diff --git a/deps/lzma-16.04/C/Bra.h b/deps/lzma-16.04/C/Bra.h
deleted file mode 100644 (file)
index aba8dce..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/* Bra.h -- Branch converters for executables\r
-2013-01-18 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __BRA_H\r
-#define __BRA_H\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-/*\r
-These functions convert relative addresses to absolute addresses\r
-in CALL instructions to increase the compression ratio.\r
-  \r
-  In:\r
-    data     - data buffer\r
-    size     - size of data\r
-    ip       - current virtual Instruction Pinter (IP) value\r
-    state    - state variable for x86 converter\r
-    encoding - 0 (for decoding), 1 (for encoding)\r
-  \r
-  Out:\r
-    state    - state variable for x86 converter\r
-\r
-  Returns:\r
-    The number of processed bytes. If you call these functions with multiple calls,\r
-    you must start next call with first byte after block of processed bytes.\r
-  \r
-  Type   Endian  Alignment  LookAhead\r
-  \r
-  x86    little      1          4\r
-  ARMT   little      2          2\r
-  ARM    little      4          0\r
-  PPC     big        4          0\r
-  SPARC   big        4          0\r
-  IA64   little     16          0\r
-\r
-  size must be >= Alignment + LookAhead, if it's not last block.\r
-  If (size < Alignment + LookAhead), converter returns 0.\r
-\r
-  Example:\r
-\r
-    UInt32 ip = 0;\r
-    for ()\r
-    {\r
-      ; size must be >= Alignment + LookAhead, if it's not last block\r
-      SizeT processed = Convert(data, size, ip, 1);\r
-      data += processed;\r
-      size -= processed;\r
-      ip += processed;\r
-    }\r
-*/\r
-\r
-#define x86_Convert_Init(state) { state = 0; }\r
-SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding);\r
-SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);\r
-SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);\r
-SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);\r
-SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);\r
-SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/Bra86.c b/deps/lzma-16.04/C/Bra86.c
deleted file mode 100644 (file)
index 8dd3ed4..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/* Bra86.c -- Converter for x86 code (BCJ)\r
-2013-11-12 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "Bra.h"\r
-\r
-#define Test86MSByte(b) ((((b) + 1) & 0xFE) == 0)\r
-\r
-SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding)\r
-{\r
-  SizeT pos = 0;\r
-  UInt32 mask = *state & 7;\r
-  if (size < 5)\r
-    return 0;\r
-  size -= 4;\r
-  ip += 5;\r
-\r
-  for (;;)\r
-  {\r
-    Byte *p = data + pos;\r
-    const Byte *limit = data + size;\r
-    for (; p < limit; p++)\r
-      if ((*p & 0xFE) == 0xE8)\r
-        break;\r
-\r
-    {\r
-      SizeT d = (SizeT)(p - data - pos);\r
-      pos = (SizeT)(p - data);\r
-      if (p >= limit)\r
-      {\r
-        *state = (d > 2 ? 0 : mask >> (unsigned)d);\r
-        return pos;\r
-      }\r
-      if (d > 2)\r
-        mask = 0;\r
-      else\r
-      {\r
-        mask >>= (unsigned)d;\r
-        if (mask != 0 && (mask > 4 || mask == 3 || Test86MSByte(p[(mask >> 1) + 1])))\r
-        {\r
-          mask = (mask >> 1) | 4;\r
-          pos++;\r
-          continue;\r
-        }\r
-      }\r
-    }\r
-\r
-    if (Test86MSByte(p[4]))\r
-    {\r
-      UInt32 v = ((UInt32)p[4] << 24) | ((UInt32)p[3] << 16) | ((UInt32)p[2] << 8) | ((UInt32)p[1]);\r
-      UInt32 cur = ip + (UInt32)pos;\r
-      pos += 5;\r
-      if (encoding)\r
-        v += cur;\r
-      else\r
-        v -= cur;\r
-      if (mask != 0)\r
-      {\r
-        unsigned sh = (mask & 6) << 2;\r
-        if (Test86MSByte((Byte)(v >> sh)))\r
-        {\r
-          v ^= (((UInt32)0x100 << sh) - 1);\r
-          if (encoding)\r
-            v += cur;\r
-          else\r
-            v -= cur;\r
-        }\r
-        mask = 0;\r
-      }\r
-      p[1] = (Byte)v;\r
-      p[2] = (Byte)(v >> 8);\r
-      p[3] = (Byte)(v >> 16);\r
-      p[4] = (Byte)(0 - ((v >> 24) & 1));\r
-    }\r
-    else\r
-    {\r
-      mask = (mask >> 1) | 4;\r
-      pos++;\r
-    }\r
-  }\r
-}\r
diff --git a/deps/lzma-16.04/C/BraIA64.c b/deps/lzma-16.04/C/BraIA64.c
deleted file mode 100644 (file)
index 813830c..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/* BraIA64.c -- Converter for IA-64 code\r
-2013-11-12 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "Bra.h"\r
-\r
-static const Byte kBranchTable[32] =\r
-{\r
-  0, 0, 0, 0, 0, 0, 0, 0,\r
-  0, 0, 0, 0, 0, 0, 0, 0,\r
-  4, 4, 6, 6, 0, 0, 7, 7,\r
-  4, 4, 0, 0, 4, 4, 0, 0\r
-};\r
-\r
-SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)\r
-{\r
-  SizeT i;\r
-  if (size < 16)\r
-    return 0;\r
-  size -= 16;\r
-  for (i = 0; i <= size; i += 16)\r
-  {\r
-    UInt32 instrTemplate = data[i] & 0x1F;\r
-    UInt32 mask = kBranchTable[instrTemplate];\r
-    UInt32 bitPos = 5;\r
-    int slot;\r
-    for (slot = 0; slot < 3; slot++, bitPos += 41)\r
-    {\r
-      UInt32 bytePos, bitRes;\r
-      UInt64 instruction, instNorm;\r
-      int j;\r
-      if (((mask >> slot) & 1) == 0)\r
-        continue;\r
-      bytePos = (bitPos >> 3);\r
-      bitRes = bitPos & 0x7;\r
-      instruction = 0;\r
-      for (j = 0; j < 6; j++)\r
-        instruction += (UInt64)data[i + j + bytePos] << (8 * j);\r
-\r
-      instNorm = instruction >> bitRes;\r
-      if (((instNorm >> 37) & 0xF) == 0x5 && ((instNorm >> 9) & 0x7) == 0)\r
-      {\r
-        UInt32 src = (UInt32)((instNorm >> 13) & 0xFFFFF);\r
-        UInt32 dest;\r
-        src |= ((UInt32)(instNorm >> 36) & 1) << 20;\r
-        \r
-        src <<= 4;\r
-        \r
-        if (encoding)\r
-          dest = ip + (UInt32)i + src;\r
-        else\r
-          dest = src - (ip + (UInt32)i);\r
-        \r
-        dest >>= 4;\r
-        \r
-        instNorm &= ~((UInt64)(0x8FFFFF) << 13);\r
-        instNorm |= ((UInt64)(dest & 0xFFFFF) << 13);\r
-        instNorm |= ((UInt64)(dest & 0x100000) << (36 - 20));\r
-        \r
-        instruction &= (1 << bitRes) - 1;\r
-        instruction |= (instNorm << bitRes);\r
-        for (j = 0; j < 6; j++)\r
-          data[i + j + bytePos] = (Byte)(instruction >> (8 * j));\r
-      }\r
-    }\r
-  }\r
-  return i;\r
-}\r
diff --git a/deps/lzma-16.04/C/Compiler.h b/deps/lzma-16.04/C/Compiler.h
deleted file mode 100644 (file)
index de8fab3..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Compiler.h\r
-2015-08-02 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __7Z_COMPILER_H\r
-#define __7Z_COMPILER_H\r
-\r
-#ifdef _MSC_VER\r
-\r
-  #ifdef UNDER_CE\r
-    #define RPC_NO_WINDOWS_H\r
-    /* #pragma warning(disable : 4115) // '_RPC_ASYNC_STATE' : named type definition in parentheses */\r
-    #pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union\r
-    #pragma warning(disable : 4214) // nonstandard extension used : bit field types other than int\r
-  #endif\r
-\r
-  #if _MSC_VER >= 1300\r
-    #pragma warning(disable : 4996) // This function or variable may be unsafe\r
-  #else\r
-    #pragma warning(disable : 4511) // copy constructor could not be generated\r
-    #pragma warning(disable : 4512) // assignment operator could not be generated\r
-    #pragma warning(disable : 4514) // unreferenced inline function has been removed\r
-    #pragma warning(disable : 4702) // unreachable code\r
-    #pragma warning(disable : 4710) // not inlined\r
-    #pragma warning(disable : 4786) // identifier was truncated to '255' characters in the debug information\r
-  #endif\r
-\r
-#endif\r
-\r
-#define UNUSED_VAR(x) (void)x;\r
-/* #define UNUSED_VAR(x) x=x; */\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/CpuArch.c b/deps/lzma-16.04/C/CpuArch.c
deleted file mode 100644 (file)
index 098e301..0000000
+++ /dev/null
@@ -1,204 +0,0 @@
-/* CpuArch.c -- CPU specific code\r
-2016-02-25: Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "CpuArch.h"\r
-\r
-#ifdef MY_CPU_X86_OR_AMD64\r
-\r
-#if (defined(_MSC_VER) && !defined(MY_CPU_AMD64)) || defined(__GNUC__)\r
-#define USE_ASM\r
-#endif\r
-\r
-#if !defined(USE_ASM) && _MSC_VER >= 1500\r
-#include <intrin.h>\r
-#endif\r
-\r
-#if defined(USE_ASM) && !defined(MY_CPU_AMD64)\r
-static UInt32 CheckFlag(UInt32 flag)\r
-{\r
-  #ifdef _MSC_VER\r
-  __asm pushfd;\r
-  __asm pop EAX;\r
-  __asm mov EDX, EAX;\r
-  __asm xor EAX, flag;\r
-  __asm push EAX;\r
-  __asm popfd;\r
-  __asm pushfd;\r
-  __asm pop EAX;\r
-  __asm xor EAX, EDX;\r
-  __asm push EDX;\r
-  __asm popfd;\r
-  __asm and flag, EAX;\r
-  #else\r
-  __asm__ __volatile__ (\r
-    "pushf\n\t"\r
-    "pop  %%EAX\n\t"\r
-    "movl %%EAX,%%EDX\n\t"\r
-    "xorl %0,%%EAX\n\t"\r
-    "push %%EAX\n\t"\r
-    "popf\n\t"\r
-    "pushf\n\t"\r
-    "pop  %%EAX\n\t"\r
-    "xorl %%EDX,%%EAX\n\t"\r
-    "push %%EDX\n\t"\r
-    "popf\n\t"\r
-    "andl %%EAX, %0\n\t":\r
-    "=c" (flag) : "c" (flag) :\r
-    "%eax", "%edx");\r
-  #endif\r
-  return flag;\r
-}\r
-#define CHECK_CPUID_IS_SUPPORTED if (CheckFlag(1 << 18) == 0 || CheckFlag(1 << 21) == 0) return False;\r
-#else\r
-#define CHECK_CPUID_IS_SUPPORTED\r
-#endif\r
-\r
-void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d)\r
-{\r
-  #ifdef USE_ASM\r
-\r
-  #ifdef _MSC_VER\r
-\r
-  UInt32 a2, b2, c2, d2;\r
-  __asm xor EBX, EBX;\r
-  __asm xor ECX, ECX;\r
-  __asm xor EDX, EDX;\r
-  __asm mov EAX, function;\r
-  __asm cpuid;\r
-  __asm mov a2, EAX;\r
-  __asm mov b2, EBX;\r
-  __asm mov c2, ECX;\r
-  __asm mov d2, EDX;\r
-\r
-  *a = a2;\r
-  *b = b2;\r
-  *c = c2;\r
-  *d = d2;\r
-\r
-  #else\r
-\r
-  __asm__ __volatile__ (\r
-  #if defined(MY_CPU_AMD64) && defined(__PIC__)\r
-    "mov %%rbx, %%rdi;"\r
-    "cpuid;"\r
-    "xchg %%rbx, %%rdi;"\r
-    : "=a" (*a) ,\r
-      "=D" (*b) ,\r
-  #elif defined(MY_CPU_X86) && defined(__PIC__)\r
-    "mov %%ebx, %%edi;"\r
-    "cpuid;"\r
-    "xchgl %%ebx, %%edi;"\r
-    : "=a" (*a) ,\r
-      "=D" (*b) ,\r
-  #else\r
-    "cpuid"\r
-    : "=a" (*a) ,\r
-      "=b" (*b) ,\r
-  #endif\r
-      "=c" (*c) ,\r
-      "=d" (*d)\r
-    : "0" (function)) ;\r
-\r
-  #endif\r
-  \r
-  #else\r
-\r
-  int CPUInfo[4];\r
-  __cpuid(CPUInfo, function);\r
-  *a = CPUInfo[0];\r
-  *b = CPUInfo[1];\r
-  *c = CPUInfo[2];\r
-  *d = CPUInfo[3];\r
-\r
-  #endif\r
-}\r
-\r
-Bool x86cpuid_CheckAndRead(Cx86cpuid *p)\r
-{\r
-  CHECK_CPUID_IS_SUPPORTED\r
-  MyCPUID(0, &p->maxFunc, &p->vendor[0], &p->vendor[2], &p->vendor[1]);\r
-  MyCPUID(1, &p->ver, &p->b, &p->c, &p->d);\r
-  return True;\r
-}\r
-\r
-static const UInt32 kVendors[][3] =\r
-{\r
-  { 0x756E6547, 0x49656E69, 0x6C65746E},\r
-  { 0x68747541, 0x69746E65, 0x444D4163},\r
-  { 0x746E6543, 0x48727561, 0x736C7561}\r
-};\r
-\r
-int x86cpuid_GetFirm(const Cx86cpuid *p)\r
-{\r
-  unsigned i;\r
-  for (i = 0; i < sizeof(kVendors) / sizeof(kVendors[i]); i++)\r
-  {\r
-    const UInt32 *v = kVendors[i];\r
-    if (v[0] == p->vendor[0] &&\r
-        v[1] == p->vendor[1] &&\r
-        v[2] == p->vendor[2])\r
-      return (int)i;\r
-  }\r
-  return -1;\r
-}\r
-\r
-Bool CPU_Is_InOrder()\r
-{\r
-  Cx86cpuid p;\r
-  int firm;\r
-  UInt32 family, model;\r
-  if (!x86cpuid_CheckAndRead(&p))\r
-    return True;\r
-\r
-  family = x86cpuid_GetFamily(p.ver);\r
-  model = x86cpuid_GetModel(p.ver);\r
-  \r
-  firm = x86cpuid_GetFirm(&p);\r
-\r
-  switch (firm)\r
-  {\r
-    case CPU_FIRM_INTEL: return (family < 6 || (family == 6 && (\r
-        /* In-Order Atom CPU */\r
-           model == 0x1C  /* 45 nm, N4xx, D4xx, N5xx, D5xx, 230, 330 */\r
-        || model == 0x26  /* 45 nm, Z6xx */\r
-        || model == 0x27  /* 32 nm, Z2460 */\r
-        || model == 0x35  /* 32 nm, Z2760 */\r
-        || model == 0x36  /* 32 nm, N2xxx, D2xxx */\r
-        )));\r
-    case CPU_FIRM_AMD: return (family < 5 || (family == 5 && (model < 6 || model == 0xA)));\r
-    case CPU_FIRM_VIA: return (family < 6 || (family == 6 && model < 0xF));\r
-  }\r
-  return True;\r
-}\r
-\r
-#if !defined(MY_CPU_AMD64) && defined(_WIN32)\r
-#include <windows.h>\r
-static Bool CPU_Sys_Is_SSE_Supported()\r
-{\r
-#if _MSC_VER >= 1900 && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)\r
-  return True;\r
-#else\r
-  OSVERSIONINFO vi;\r
-  vi.dwOSVersionInfoSize = sizeof(vi);\r
-  if (!GetVersionEx(&vi))\r
-    return False;\r
-  return (vi.dwMajorVersion >= 5);\r
-#endif\r
-}\r
-#define CHECK_SYS_SSE_SUPPORT if (!CPU_Sys_Is_SSE_Supported()) return False;\r
-#else\r
-#define CHECK_SYS_SSE_SUPPORT\r
-#endif\r
-\r
-Bool CPU_Is_Aes_Supported()\r
-{\r
-  Cx86cpuid p;\r
-  CHECK_SYS_SSE_SUPPORT\r
-  if (!x86cpuid_CheckAndRead(&p))\r
-    return False;\r
-  return (p.c >> 25) & 1;\r
-}\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/CpuArch.h b/deps/lzma-16.04/C/CpuArch.h
deleted file mode 100644 (file)
index ef6083c..0000000
+++ /dev/null
@@ -1,223 +0,0 @@
-/* CpuArch.h -- CPU specific code\r
-2016-06-09: Igor Pavlov : Public domain */\r
-\r
-#ifndef __CPU_ARCH_H\r
-#define __CPU_ARCH_H\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-/*\r
-MY_CPU_LE means that CPU is LITTLE ENDIAN.\r
-MY_CPU_BE means that CPU is BIG ENDIAN.\r
-If MY_CPU_LE and MY_CPU_BE are not defined, we don't know about ENDIANNESS of platform.\r
-\r
-MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned memory accesses.\r
-*/\r
-\r
-#if defined(_M_X64) \\r
-   || defined(_M_AMD64) \\r
-   || defined(__x86_64__) \\r
-   || defined(__AMD64__) \\r
-   || defined(__amd64__)\r
-  #define MY_CPU_AMD64\r
-#endif\r
-\r
-#if defined(MY_CPU_AMD64) \\r
-    || defined(_M_IA64) \\r
-    || defined(__AARCH64EL__) \\r
-    || defined(__AARCH64EB__)\r
-  #define MY_CPU_64BIT\r
-#endif\r
-\r
-#if defined(_M_IX86) || defined(__i386__)\r
-#define MY_CPU_X86\r
-#endif\r
-\r
-#if defined(MY_CPU_X86) || defined(MY_CPU_AMD64)\r
-#define MY_CPU_X86_OR_AMD64\r
-#endif\r
-\r
-#if defined(MY_CPU_X86) \\r
-    || defined(_M_ARM) \\r
-    || defined(__ARMEL__) \\r
-    || defined(__THUMBEL__) \\r
-    || defined(__ARMEB__) \\r
-    || defined(__THUMBEB__)\r
-  #define MY_CPU_32BIT\r
-#endif\r
-\r
-#if defined(_WIN32) && defined(_M_ARM)\r
-#define MY_CPU_ARM_LE\r
-#endif\r
-\r
-#if defined(_WIN32) && defined(_M_IA64)\r
-#define MY_CPU_IA64_LE\r
-#endif\r
-\r
-#if defined(MY_CPU_X86_OR_AMD64) \\r
-    || defined(MY_CPU_ARM_LE) \\r
-    || defined(MY_CPU_IA64_LE) \\r
-    || defined(__LITTLE_ENDIAN__) \\r
-    || defined(__ARMEL__) \\r
-    || defined(__THUMBEL__) \\r
-    || defined(__AARCH64EL__) \\r
-    || defined(__MIPSEL__) \\r
-    || defined(__MIPSEL) \\r
-    || defined(_MIPSEL) \\r
-    || defined(__BFIN__) \\r
-    || (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))\r
-  #define MY_CPU_LE\r
-#endif\r
-\r
-#if defined(__BIG_ENDIAN__) \\r
-    || defined(__ARMEB__) \\r
-    || defined(__THUMBEB__) \\r
-    || defined(__AARCH64EB__) \\r
-    || defined(__MIPSEB__) \\r
-    || defined(__MIPSEB) \\r
-    || defined(_MIPSEB) \\r
-    || defined(__m68k__) \\r
-    || defined(__s390__) \\r
-    || defined(__s390x__) \\r
-    || defined(__zarch__) \\r
-    || (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))\r
-  #define MY_CPU_BE\r
-#endif\r
-\r
-#if defined(MY_CPU_LE) && defined(MY_CPU_BE)\r
-Stop_Compiling_Bad_Endian\r
-#endif\r
-\r
-\r
-#ifdef MY_CPU_LE\r
-  #if defined(MY_CPU_X86_OR_AMD64) \\r
-      /* || defined(__AARCH64EL__) */\r
-    #define MY_CPU_LE_UNALIGN\r
-  #endif\r
-#endif\r
-\r
-\r
-#ifdef MY_CPU_LE_UNALIGN\r
-\r
-#define GetUi16(p) (*(const UInt16 *)(const void *)(p))\r
-#define GetUi32(p) (*(const UInt32 *)(const void *)(p))\r
-#define GetUi64(p) (*(const UInt64 *)(const void *)(p))\r
-\r
-#define SetUi16(p, v) { *(UInt16 *)(p) = (v); }\r
-#define SetUi32(p, v) { *(UInt32 *)(p) = (v); }\r
-#define SetUi64(p, v) { *(UInt64 *)(p) = (v); }\r
-\r
-#else\r
-\r
-#define GetUi16(p) ( (UInt16) ( \\r
-             ((const Byte *)(p))[0] | \\r
-    ((UInt16)((const Byte *)(p))[1] << 8) ))\r
-\r
-#define GetUi32(p) ( \\r
-             ((const Byte *)(p))[0]        | \\r
-    ((UInt32)((const Byte *)(p))[1] <<  8) | \\r
-    ((UInt32)((const Byte *)(p))[2] << 16) | \\r
-    ((UInt32)((const Byte *)(p))[3] << 24))\r
-\r
-#define GetUi64(p) (GetUi32(p) | ((UInt64)GetUi32(((const Byte *)(p)) + 4) << 32))\r
-\r
-#define SetUi16(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \\r
-    _ppp_[0] = (Byte)_vvv_; \\r
-    _ppp_[1] = (Byte)(_vvv_ >> 8); }\r
-\r
-#define SetUi32(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \\r
-    _ppp_[0] = (Byte)_vvv_; \\r
-    _ppp_[1] = (Byte)(_vvv_ >> 8); \\r
-    _ppp_[2] = (Byte)(_vvv_ >> 16); \\r
-    _ppp_[3] = (Byte)(_vvv_ >> 24); }\r
-\r
-#define SetUi64(p, v) { Byte *_ppp2_ = (Byte *)(p); UInt64 _vvv2_ = (v); \\r
-    SetUi32(_ppp2_    , (UInt32)_vvv2_); \\r
-    SetUi32(_ppp2_ + 4, (UInt32)(_vvv2_ >> 32)); }\r
-\r
-#endif\r
-\r
-\r
-#if defined(MY_CPU_LE_UNALIGN) && /* defined(_WIN64) && */ (_MSC_VER >= 1300)\r
-\r
-/* Note: we use bswap instruction, that is unsupported in 386 cpu */\r
-\r
-#include <stdlib.h>\r
-\r
-#pragma intrinsic(_byteswap_ulong)\r
-#pragma intrinsic(_byteswap_uint64)\r
-#define GetBe32(p) _byteswap_ulong(*(const UInt32 *)(const Byte *)(p))\r
-#define GetBe64(p) _byteswap_uint64(*(const UInt64 *)(const Byte *)(p))\r
-\r
-#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = _byteswap_ulong(v)\r
-\r
-#elif defined(MY_CPU_LE_UNALIGN) && defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))\r
-\r
-#define GetBe32(p) __builtin_bswap32(*(const UInt32 *)(const Byte *)(p))\r
-#define GetBe64(p) __builtin_bswap64(*(const UInt64 *)(const Byte *)(p))\r
-\r
-#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = __builtin_bswap32(v)\r
-\r
-#else\r
-\r
-#define GetBe32(p) ( \\r
-    ((UInt32)((const Byte *)(p))[0] << 24) | \\r
-    ((UInt32)((const Byte *)(p))[1] << 16) | \\r
-    ((UInt32)((const Byte *)(p))[2] <<  8) | \\r
-             ((const Byte *)(p))[3] )\r
-\r
-#define GetBe64(p) (((UInt64)GetBe32(p) << 32) | GetBe32(((const Byte *)(p)) + 4))\r
-\r
-#define SetBe32(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \\r
-    _ppp_[0] = (Byte)(_vvv_ >> 24); \\r
-    _ppp_[1] = (Byte)(_vvv_ >> 16); \\r
-    _ppp_[2] = (Byte)(_vvv_ >> 8); \\r
-    _ppp_[3] = (Byte)_vvv_; }\r
-\r
-#endif\r
-\r
-\r
-#define GetBe16(p) ( (UInt16) ( \\r
-    ((UInt16)((const Byte *)(p))[0] << 8) | \\r
-             ((const Byte *)(p))[1] ))\r
-\r
-\r
-\r
-#ifdef MY_CPU_X86_OR_AMD64\r
-\r
-typedef struct\r
-{\r
-  UInt32 maxFunc;\r
-  UInt32 vendor[3];\r
-  UInt32 ver;\r
-  UInt32 b;\r
-  UInt32 c;\r
-  UInt32 d;\r
-} Cx86cpuid;\r
-\r
-enum\r
-{\r
-  CPU_FIRM_INTEL,\r
-  CPU_FIRM_AMD,\r
-  CPU_FIRM_VIA\r
-};\r
-\r
-void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d);\r
-\r
-Bool x86cpuid_CheckAndRead(Cx86cpuid *p);\r
-int x86cpuid_GetFirm(const Cx86cpuid *p);\r
-\r
-#define x86cpuid_GetFamily(ver) (((ver >> 16) & 0xFF0) | ((ver >> 8) & 0xF))\r
-#define x86cpuid_GetModel(ver)  (((ver >> 12) &  0xF0) | ((ver >> 4) & 0xF))\r
-#define x86cpuid_GetStepping(ver) (ver & 0xF)\r
-\r
-Bool CPU_Is_InOrder();\r
-Bool CPU_Is_Aes_Supported();\r
-\r
-#endif\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/Delta.c b/deps/lzma-16.04/C/Delta.c
deleted file mode 100644 (file)
index 6cbbe46..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/* Delta.c -- Delta converter\r
-2009-05-26 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "Delta.h"\r
-\r
-void Delta_Init(Byte *state)\r
-{\r
-  unsigned i;\r
-  for (i = 0; i < DELTA_STATE_SIZE; i++)\r
-    state[i] = 0;\r
-}\r
-\r
-static void MyMemCpy(Byte *dest, const Byte *src, unsigned size)\r
-{\r
-  unsigned i;\r
-  for (i = 0; i < size; i++)\r
-    dest[i] = src[i];\r
-}\r
-\r
-void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size)\r
-{\r
-  Byte buf[DELTA_STATE_SIZE];\r
-  unsigned j = 0;\r
-  MyMemCpy(buf, state, delta);\r
-  {\r
-    SizeT i;\r
-    for (i = 0; i < size;)\r
-    {\r
-      for (j = 0; j < delta && i < size; i++, j++)\r
-      {\r
-        Byte b = data[i];\r
-        data[i] = (Byte)(b - buf[j]);\r
-        buf[j] = b;\r
-      }\r
-    }\r
-  }\r
-  if (j == delta)\r
-    j = 0;\r
-  MyMemCpy(state, buf + j, delta - j);\r
-  MyMemCpy(state + delta - j, buf, j);\r
-}\r
-\r
-void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size)\r
-{\r
-  Byte buf[DELTA_STATE_SIZE];\r
-  unsigned j = 0;\r
-  MyMemCpy(buf, state, delta);\r
-  {\r
-    SizeT i;\r
-    for (i = 0; i < size;)\r
-    {\r
-      for (j = 0; j < delta && i < size; i++, j++)\r
-      {\r
-        buf[j] = data[i] = (Byte)(buf[j] + data[i]);\r
-      }\r
-    }\r
-  }\r
-  if (j == delta)\r
-    j = 0;\r
-  MyMemCpy(state, buf + j, delta - j);\r
-  MyMemCpy(state + delta - j, buf, j);\r
-}\r
diff --git a/deps/lzma-16.04/C/Delta.h b/deps/lzma-16.04/C/Delta.h
deleted file mode 100644 (file)
index e59d5a2..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Delta.h -- Delta converter\r
-2013-01-18 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __DELTA_H\r
-#define __DELTA_H\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-#define DELTA_STATE_SIZE 256\r
-\r
-void Delta_Init(Byte *state);\r
-void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size);\r
-void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size);\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/DllSecur.c b/deps/lzma-16.04/C/DllSecur.c
deleted file mode 100644 (file)
index 8745421..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/* DllSecur.c -- DLL loading security\r
-2016-10-04 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#ifdef _WIN32\r
-\r
-#include <windows.h>\r
-\r
-#include "DllSecur.h"\r
-\r
-#ifndef UNDER_CE\r
-\r
-typedef BOOL (WINAPI *Func_SetDefaultDllDirectories)(DWORD DirectoryFlags);\r
-\r
-#define MY_LOAD_LIBRARY_SEARCH_USER_DIRS 0x400\r
-#define MY_LOAD_LIBRARY_SEARCH_SYSTEM32  0x800\r
-\r
-static const char * const g_Dlls =\r
-  #ifndef _CONSOLE\r
-  "UXTHEME\0"\r
-  #endif\r
-  "USERENV\0"\r
-  "SETUPAPI\0"\r
-  "APPHELP\0"\r
-  "PROPSYS\0"\r
-  "DWMAPI\0"\r
-  "CRYPTBASE\0"\r
-  "OLEACC\0"\r
-  "CLBCATQ\0"\r
-  ;\r
-\r
-#endif\r
-\r
-void LoadSecurityDlls()\r
-{\r
-  #ifndef UNDER_CE\r
-  \r
-  wchar_t buf[MAX_PATH + 100];\r
-\r
-  {\r
-    // at Vista (ver 6.0) : CoCreateInstance(CLSID_ShellLink, ...) doesn't work after SetDefaultDllDirectories() : Check it ???\r
-    OSVERSIONINFO vi;\r
-    vi.dwOSVersionInfoSize = sizeof(vi);\r
-    if (!GetVersionEx(&vi) || vi.dwMajorVersion != 6 || vi.dwMinorVersion != 0)\r
-    {\r
-      Func_SetDefaultDllDirectories setDllDirs = (Func_SetDefaultDllDirectories)\r
-          GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories");\r
-      if (setDllDirs)\r
-        if (setDllDirs(MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS))\r
-          return;\r
-    }\r
-  }\r
-\r
-  {\r
-    unsigned len = GetSystemDirectoryW(buf, MAX_PATH + 2);\r
-    if (len == 0 || len > MAX_PATH)\r
-      return;\r
-  }\r
-  {\r
-    const char *dll;\r
-    unsigned pos = (unsigned)lstrlenW(buf);\r
-\r
-    if (buf[pos - 1] != '\\')\r
-      buf[pos++] = '\\';\r
-    \r
-    for (dll = g_Dlls; dll[0] != 0;)\r
-    {\r
-      unsigned k = 0;\r
-      for (;;)\r
-      {\r
-        char c = *dll++;\r
-        buf[pos + k] = c;\r
-        k++;\r
-        if (c == 0)\r
-          break;\r
-      }\r
-\r
-      lstrcatW(buf, L".dll");\r
-      LoadLibraryExW(buf, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);\r
-    }\r
-  }\r
-  \r
-  #endif\r
-}\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/DllSecur.h b/deps/lzma-16.04/C/DllSecur.h
deleted file mode 100644 (file)
index 023c509..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/* DllSecur.h -- DLL loading for security\r
-2016-06-08 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __DLL_SECUR_H\r
-#define __DLL_SECUR_H\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-#ifdef _WIN32\r
-\r
-void LoadSecurityDlls();\r
-\r
-#endif\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/LzFind.c b/deps/lzma-16.04/C/LzFind.c
deleted file mode 100644 (file)
index c335d36..0000000
+++ /dev/null
@@ -1,1044 +0,0 @@
-/* LzFind.c -- Match finder for LZ algorithms\r
-2015-10-15 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include <string.h>\r
-\r
-#include "LzFind.h"\r
-#include "LzHash.h"\r
-\r
-#define kEmptyHashValue 0\r
-#define kMaxValForNormalize ((UInt32)0xFFFFFFFF)\r
-#define kNormalizeStepMin (1 << 10) /* it must be power of 2 */\r
-#define kNormalizeMask (~(UInt32)(kNormalizeStepMin - 1))\r
-#define kMaxHistorySize ((UInt32)7 << 29)\r
-\r
-#define kStartMaxLen 3\r
-\r
-static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc)\r
-{\r
-  if (!p->directInput)\r
-  {\r
-    alloc->Free(alloc, p->bufferBase);\r
-    p->bufferBase = NULL;\r
-  }\r
-}\r
-\r
-/* keepSizeBefore + keepSizeAfter + keepSizeReserv must be < 4G) */\r
-\r
-static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *alloc)\r
-{\r
-  UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv;\r
-  if (p->directInput)\r
-  {\r
-    p->blockSize = blockSize;\r
-    return 1;\r
-  }\r
-  if (!p->bufferBase || p->blockSize != blockSize)\r
-  {\r
-    LzInWindow_Free(p, alloc);\r
-    p->blockSize = blockSize;\r
-    p->bufferBase = (Byte *)alloc->Alloc(alloc, (size_t)blockSize);\r
-  }\r
-  return (p->bufferBase != NULL);\r
-}\r
-\r
-Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }\r
-\r
-UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }\r
-\r
-void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)\r
-{\r
-  p->posLimit -= subValue;\r
-  p->pos -= subValue;\r
-  p->streamPos -= subValue;\r
-}\r
-\r
-static void MatchFinder_ReadBlock(CMatchFinder *p)\r
-{\r
-  if (p->streamEndWasReached || p->result != SZ_OK)\r
-    return;\r
-\r
-  /* We use (p->streamPos - p->pos) value. (p->streamPos < p->pos) is allowed. */\r
-\r
-  if (p->directInput)\r
-  {\r
-    UInt32 curSize = 0xFFFFFFFF - (p->streamPos - p->pos);\r
-    if (curSize > p->directInputRem)\r
-      curSize = (UInt32)p->directInputRem;\r
-    p->directInputRem -= curSize;\r
-    p->streamPos += curSize;\r
-    if (p->directInputRem == 0)\r
-      p->streamEndWasReached = 1;\r
-    return;\r
-  }\r
-  \r
-  for (;;)\r
-  {\r
-    Byte *dest = p->buffer + (p->streamPos - p->pos);\r
-    size_t size = (p->bufferBase + p->blockSize - dest);\r
-    if (size == 0)\r
-      return;\r
-\r
-    p->result = p->stream->Read(p->stream, dest, &size);\r
-    if (p->result != SZ_OK)\r
-      return;\r
-    if (size == 0)\r
-    {\r
-      p->streamEndWasReached = 1;\r
-      return;\r
-    }\r
-    p->streamPos += (UInt32)size;\r
-    if (p->streamPos - p->pos > p->keepSizeAfter)\r
-      return;\r
-  }\r
-}\r
-\r
-void MatchFinder_MoveBlock(CMatchFinder *p)\r
-{\r
-  memmove(p->bufferBase,\r
-      p->buffer - p->keepSizeBefore,\r
-      (size_t)(p->streamPos - p->pos) + p->keepSizeBefore);\r
-  p->buffer = p->bufferBase + p->keepSizeBefore;\r
-}\r
-\r
-int MatchFinder_NeedMove(CMatchFinder *p)\r
-{\r
-  if (p->directInput)\r
-    return 0;\r
-  /* if (p->streamEndWasReached) return 0; */\r
-  return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter);\r
-}\r
-\r
-void MatchFinder_ReadIfRequired(CMatchFinder *p)\r
-{\r
-  if (p->streamEndWasReached)\r
-    return;\r
-  if (p->keepSizeAfter >= p->streamPos - p->pos)\r
-    MatchFinder_ReadBlock(p);\r
-}\r
-\r
-static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p)\r
-{\r
-  if (MatchFinder_NeedMove(p))\r
-    MatchFinder_MoveBlock(p);\r
-  MatchFinder_ReadBlock(p);\r
-}\r
-\r
-static void MatchFinder_SetDefaultSettings(CMatchFinder *p)\r
-{\r
-  p->cutValue = 32;\r
-  p->btMode = 1;\r
-  p->numHashBytes = 4;\r
-  p->bigHash = 0;\r
-}\r
-\r
-#define kCrcPoly 0xEDB88320\r
-\r
-void MatchFinder_Construct(CMatchFinder *p)\r
-{\r
-  UInt32 i;\r
-  p->bufferBase = NULL;\r
-  p->directInput = 0;\r
-  p->hash = NULL;\r
-  MatchFinder_SetDefaultSettings(p);\r
-\r
-  for (i = 0; i < 256; i++)\r
-  {\r
-    UInt32 r = i;\r
-    unsigned j;\r
-    for (j = 0; j < 8; j++)\r
-      r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));\r
-    p->crc[i] = r;\r
-  }\r
-}\r
-\r
-static void MatchFinder_FreeThisClassMemory(CMatchFinder *p, ISzAlloc *alloc)\r
-{\r
-  alloc->Free(alloc, p->hash);\r
-  p->hash = NULL;\r
-}\r
-\r
-void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc)\r
-{\r
-  MatchFinder_FreeThisClassMemory(p, alloc);\r
-  LzInWindow_Free(p, alloc);\r
-}\r
-\r
-static CLzRef* AllocRefs(size_t num, ISzAlloc *alloc)\r
-{\r
-  size_t sizeInBytes = (size_t)num * sizeof(CLzRef);\r
-  if (sizeInBytes / sizeof(CLzRef) != num)\r
-    return NULL;\r
-  return (CLzRef *)alloc->Alloc(alloc, sizeInBytes);\r
-}\r
-\r
-int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,\r
-    UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,\r
-    ISzAlloc *alloc)\r
-{\r
-  UInt32 sizeReserv;\r
-  \r
-  if (historySize > kMaxHistorySize)\r
-  {\r
-    MatchFinder_Free(p, alloc);\r
-    return 0;\r
-  }\r
-  \r
-  sizeReserv = historySize >> 1;\r
-       if (historySize >= ((UInt32)3 << 30)) sizeReserv = historySize >> 3;\r
-  else if (historySize >= ((UInt32)2 << 30)) sizeReserv = historySize >> 2;\r
-  \r
-  sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19);\r
-\r
-  p->keepSizeBefore = historySize + keepAddBufferBefore + 1;\r
-  p->keepSizeAfter = matchMaxLen + keepAddBufferAfter;\r
-  \r
-  /* we need one additional byte, since we use MoveBlock after pos++ and before dictionary using */\r
-  \r
-  if (LzInWindow_Create(p, sizeReserv, alloc))\r
-  {\r
-    UInt32 newCyclicBufferSize = historySize + 1;\r
-    UInt32 hs;\r
-    p->matchMaxLen = matchMaxLen;\r
-    {\r
-      p->fixedHashSize = 0;\r
-      if (p->numHashBytes == 2)\r
-        hs = (1 << 16) - 1;\r
-      else\r
-      {\r
-        hs = historySize - 1;\r
-        hs |= (hs >> 1);\r
-        hs |= (hs >> 2);\r
-        hs |= (hs >> 4);\r
-        hs |= (hs >> 8);\r
-        hs >>= 1;\r
-        hs |= 0xFFFF; /* don't change it! It's required for Deflate */\r
-        if (hs > (1 << 24))\r
-        {\r
-          if (p->numHashBytes == 3)\r
-            hs = (1 << 24) - 1;\r
-          else\r
-            hs >>= 1;\r
-          /* if (bigHash) mode, GetHeads4b() in LzFindMt.c needs (hs >= ((1 << 24) - 1))) */\r
-        }\r
-      }\r
-      p->hashMask = hs;\r
-      hs++;\r
-      if (p->numHashBytes > 2) p->fixedHashSize += kHash2Size;\r
-      if (p->numHashBytes > 3) p->fixedHashSize += kHash3Size;\r
-      if (p->numHashBytes > 4) p->fixedHashSize += kHash4Size;\r
-      hs += p->fixedHashSize;\r
-    }\r
-\r
-    {\r
-      size_t newSize;\r
-      size_t numSons;\r
-      p->historySize = historySize;\r
-      p->hashSizeSum = hs;\r
-      p->cyclicBufferSize = newCyclicBufferSize;\r
-      \r
-      numSons = newCyclicBufferSize;\r
-      if (p->btMode)\r
-        numSons <<= 1;\r
-      newSize = hs + numSons;\r
-\r
-      if (p->hash && p->numRefs == newSize)\r
-        return 1;\r
-      \r
-      MatchFinder_FreeThisClassMemory(p, alloc);\r
-      p->numRefs = newSize;\r
-      p->hash = AllocRefs(newSize, alloc);\r
-      \r
-      if (p->hash)\r
-      {\r
-        p->son = p->hash + p->hashSizeSum;\r
-        return 1;\r
-      }\r
-    }\r
-  }\r
-\r
-  MatchFinder_Free(p, alloc);\r
-  return 0;\r
-}\r
-\r
-static void MatchFinder_SetLimits(CMatchFinder *p)\r
-{\r
-  UInt32 limit = kMaxValForNormalize - p->pos;\r
-  UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos;\r
-  \r
-  if (limit2 < limit)\r
-    limit = limit2;\r
-  limit2 = p->streamPos - p->pos;\r
-  \r
-  if (limit2 <= p->keepSizeAfter)\r
-  {\r
-    if (limit2 > 0)\r
-      limit2 = 1;\r
-  }\r
-  else\r
-    limit2 -= p->keepSizeAfter;\r
-  \r
-  if (limit2 < limit)\r
-    limit = limit2;\r
-  \r
-  {\r
-    UInt32 lenLimit = p->streamPos - p->pos;\r
-    if (lenLimit > p->matchMaxLen)\r
-      lenLimit = p->matchMaxLen;\r
-    p->lenLimit = lenLimit;\r
-  }\r
-  p->posLimit = p->pos + limit;\r
-}\r
-\r
-void MatchFinder_Init_2(CMatchFinder *p, int readData)\r
-{\r
-  UInt32 i;\r
-  UInt32 *hash = p->hash;\r
-  UInt32 num = p->hashSizeSum;\r
-  for (i = 0; i < num; i++)\r
-    hash[i] = kEmptyHashValue;\r
-  \r
-  p->cyclicBufferPos = 0;\r
-  p->buffer = p->bufferBase;\r
-  p->pos = p->streamPos = p->cyclicBufferSize;\r
-  p->result = SZ_OK;\r
-  p->streamEndWasReached = 0;\r
-  \r
-  if (readData)\r
-    MatchFinder_ReadBlock(p);\r
-  \r
-  MatchFinder_SetLimits(p);\r
-}\r
-\r
-void MatchFinder_Init(CMatchFinder *p)\r
-{\r
-  MatchFinder_Init_2(p, True);\r
-}\r
-  \r
-static UInt32 MatchFinder_GetSubValue(CMatchFinder *p)\r
-{\r
-  return (p->pos - p->historySize - 1) & kNormalizeMask;\r
-}\r
-\r
-void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems)\r
-{\r
-  size_t i;\r
-  for (i = 0; i < numItems; i++)\r
-  {\r
-    UInt32 value = items[i];\r
-    if (value <= subValue)\r
-      value = kEmptyHashValue;\r
-    else\r
-      value -= subValue;\r
-    items[i] = value;\r
-  }\r
-}\r
-\r
-static void MatchFinder_Normalize(CMatchFinder *p)\r
-{\r
-  UInt32 subValue = MatchFinder_GetSubValue(p);\r
-  MatchFinder_Normalize3(subValue, p->hash, p->numRefs);\r
-  MatchFinder_ReduceOffsets(p, subValue);\r
-}\r
-\r
-static void MatchFinder_CheckLimits(CMatchFinder *p)\r
-{\r
-  if (p->pos == kMaxValForNormalize)\r
-    MatchFinder_Normalize(p);\r
-  if (!p->streamEndWasReached && p->keepSizeAfter == p->streamPos - p->pos)\r
-    MatchFinder_CheckAndMoveAndRead(p);\r
-  if (p->cyclicBufferPos == p->cyclicBufferSize)\r
-    p->cyclicBufferPos = 0;\r
-  MatchFinder_SetLimits(p);\r
-}\r
-\r
-static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,\r
-    UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,\r
-    UInt32 *distances, UInt32 maxLen)\r
-{\r
-  son[_cyclicBufferPos] = curMatch;\r
-  for (;;)\r
-  {\r
-    UInt32 delta = pos - curMatch;\r
-    if (cutValue-- == 0 || delta >= _cyclicBufferSize)\r
-      return distances;\r
-    {\r
-      const Byte *pb = cur - delta;\r
-      curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)];\r
-      if (pb[maxLen] == cur[maxLen] && *pb == *cur)\r
-      {\r
-        UInt32 len = 0;\r
-        while (++len != lenLimit)\r
-          if (pb[len] != cur[len])\r
-            break;\r
-        if (maxLen < len)\r
-        {\r
-          *distances++ = maxLen = len;\r
-          *distances++ = delta - 1;\r
-          if (len == lenLimit)\r
-            return distances;\r
-        }\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,\r
-    UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,\r
-    UInt32 *distances, UInt32 maxLen)\r
-{\r
-  CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;\r
-  CLzRef *ptr1 = son + (_cyclicBufferPos << 1);\r
-  UInt32 len0 = 0, len1 = 0;\r
-  for (;;)\r
-  {\r
-    UInt32 delta = pos - curMatch;\r
-    if (cutValue-- == 0 || delta >= _cyclicBufferSize)\r
-    {\r
-      *ptr0 = *ptr1 = kEmptyHashValue;\r
-      return distances;\r
-    }\r
-    {\r
-      CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);\r
-      const Byte *pb = cur - delta;\r
-      UInt32 len = (len0 < len1 ? len0 : len1);\r
-      if (pb[len] == cur[len])\r
-      {\r
-        if (++len != lenLimit && pb[len] == cur[len])\r
-          while (++len != lenLimit)\r
-            if (pb[len] != cur[len])\r
-              break;\r
-        if (maxLen < len)\r
-        {\r
-          *distances++ = maxLen = len;\r
-          *distances++ = delta - 1;\r
-          if (len == lenLimit)\r
-          {\r
-            *ptr1 = pair[0];\r
-            *ptr0 = pair[1];\r
-            return distances;\r
-          }\r
-        }\r
-      }\r
-      if (pb[len] < cur[len])\r
-      {\r
-        *ptr1 = curMatch;\r
-        ptr1 = pair + 1;\r
-        curMatch = *ptr1;\r
-        len1 = len;\r
-      }\r
-      else\r
-      {\r
-        *ptr0 = curMatch;\r
-        ptr0 = pair;\r
-        curMatch = *ptr0;\r
-        len0 = len;\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,\r
-    UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue)\r
-{\r
-  CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;\r
-  CLzRef *ptr1 = son + (_cyclicBufferPos << 1);\r
-  UInt32 len0 = 0, len1 = 0;\r
-  for (;;)\r
-  {\r
-    UInt32 delta = pos - curMatch;\r
-    if (cutValue-- == 0 || delta >= _cyclicBufferSize)\r
-    {\r
-      *ptr0 = *ptr1 = kEmptyHashValue;\r
-      return;\r
-    }\r
-    {\r
-      CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);\r
-      const Byte *pb = cur - delta;\r
-      UInt32 len = (len0 < len1 ? len0 : len1);\r
-      if (pb[len] == cur[len])\r
-      {\r
-        while (++len != lenLimit)\r
-          if (pb[len] != cur[len])\r
-            break;\r
-        {\r
-          if (len == lenLimit)\r
-          {\r
-            *ptr1 = pair[0];\r
-            *ptr0 = pair[1];\r
-            return;\r
-          }\r
-        }\r
-      }\r
-      if (pb[len] < cur[len])\r
-      {\r
-        *ptr1 = curMatch;\r
-        ptr1 = pair + 1;\r
-        curMatch = *ptr1;\r
-        len1 = len;\r
-      }\r
-      else\r
-      {\r
-        *ptr0 = curMatch;\r
-        ptr0 = pair;\r
-        curMatch = *ptr0;\r
-        len0 = len;\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-#define MOVE_POS \\r
-  ++p->cyclicBufferPos; \\r
-  p->buffer++; \\r
-  if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p);\r
-\r
-#define MOVE_POS_RET MOVE_POS return offset;\r
-\r
-static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }\r
-\r
-#define GET_MATCHES_HEADER2(minLen, ret_op) \\r
-  UInt32 lenLimit; UInt32 hv; const Byte *cur; UInt32 curMatch; \\r
-  lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \\r
-  cur = p->buffer;\r
-\r
-#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return 0)\r
-#define SKIP_HEADER(minLen)        GET_MATCHES_HEADER2(minLen, continue)\r
-\r
-#define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue\r
-\r
-#define GET_MATCHES_FOOTER(offset, maxLen) \\r
-  offset = (UInt32)(GetMatchesSpec1(lenLimit, curMatch, MF_PARAMS(p), \\r
-  distances + offset, maxLen) - distances); MOVE_POS_RET;\r
-\r
-#define SKIP_FOOTER \\r
-  SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;\r
-\r
-#define UPDATE_maxLen { \\r
-    ptrdiff_t diff = (ptrdiff_t)0 - d2; \\r
-    const Byte *c = cur + maxLen; \\r
-    const Byte *lim = cur + lenLimit; \\r
-    for (; c != lim; c++) if (*(c + diff) != *c) break; \\r
-    maxLen = (UInt32)(c - cur); }\r
-\r
-static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)\r
-{\r
-  UInt32 offset;\r
-  GET_MATCHES_HEADER(2)\r
-  HASH2_CALC;\r
-  curMatch = p->hash[hv];\r
-  p->hash[hv] = p->pos;\r
-  offset = 0;\r
-  GET_MATCHES_FOOTER(offset, 1)\r
-}\r
-\r
-UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)\r
-{\r
-  UInt32 offset;\r
-  GET_MATCHES_HEADER(3)\r
-  HASH_ZIP_CALC;\r
-  curMatch = p->hash[hv];\r
-  p->hash[hv] = p->pos;\r
-  offset = 0;\r
-  GET_MATCHES_FOOTER(offset, 2)\r
-}\r
-\r
-static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)\r
-{\r
-  UInt32 h2, d2, maxLen, offset, pos;\r
-  UInt32 *hash;\r
-  GET_MATCHES_HEADER(3)\r
-\r
-  HASH3_CALC;\r
-\r
-  hash = p->hash;\r
-  pos = p->pos;\r
-\r
-  d2 = pos - hash[h2];\r
-\r
-  curMatch = hash[kFix3HashSize + hv];\r
-  \r
-  hash[h2] = pos;\r
-  hash[kFix3HashSize + hv] = pos;\r
-\r
-  maxLen = 2;\r
-  offset = 0;\r
-\r
-  if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)\r
-  {\r
-    UPDATE_maxLen\r
-    distances[0] = maxLen;\r
-    distances[1] = d2 - 1;\r
-    offset = 2;\r
-    if (maxLen == lenLimit)\r
-    {\r
-      SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));\r
-      MOVE_POS_RET;\r
-    }\r
-  }\r
-  \r
-  GET_MATCHES_FOOTER(offset, maxLen)\r
-}\r
-\r
-static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)\r
-{\r
-  UInt32 h2, h3, d2, d3, maxLen, offset, pos;\r
-  UInt32 *hash;\r
-  GET_MATCHES_HEADER(4)\r
-\r
-  HASH4_CALC;\r
-\r
-  hash = p->hash;\r
-  pos = p->pos;\r
-\r
-  d2 = pos - hash[                h2];\r
-  d3 = pos - hash[kFix3HashSize + h3];\r
-\r
-  curMatch = hash[kFix4HashSize + hv];\r
-\r
-  hash[                h2] = pos;\r
-  hash[kFix3HashSize + h3] = pos;\r
-  hash[kFix4HashSize + hv] = pos;\r
-\r
-  maxLen = 0;\r
-  offset = 0;\r
-  \r
-  if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)\r
-  {\r
-    distances[0] = maxLen = 2;\r
-    distances[1] = d2 - 1;\r
-    offset = 2;\r
-  }\r
-  \r
-  if (d2 != d3 && d3 < p->cyclicBufferSize && *(cur - d3) == *cur)\r
-  {\r
-    maxLen = 3;\r
-    distances[offset + 1] = d3 - 1;\r
-    offset += 2;\r
-    d2 = d3;\r
-  }\r
-  \r
-  if (offset != 0)\r
-  {\r
-    UPDATE_maxLen\r
-    distances[offset - 2] = maxLen;\r
-    if (maxLen == lenLimit)\r
-    {\r
-      SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));\r
-      MOVE_POS_RET;\r
-    }\r
-  }\r
-  \r
-  if (maxLen < 3)\r
-    maxLen = 3;\r
-  \r
-  GET_MATCHES_FOOTER(offset, maxLen)\r
-}\r
-\r
-/*\r
-static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)\r
-{\r
-  UInt32 h2, h3, h4, d2, d3, d4, maxLen, offset, pos;\r
-  UInt32 *hash;\r
-  GET_MATCHES_HEADER(5)\r
-\r
-  HASH5_CALC;\r
-\r
-  hash = p->hash;\r
-  pos = p->pos;\r
-\r
-  d2 = pos - hash[                h2];\r
-  d3 = pos - hash[kFix3HashSize + h3];\r
-  d4 = pos - hash[kFix4HashSize + h4];\r
-\r
-  curMatch = hash[kFix5HashSize + hv];\r
-\r
-  hash[                h2] = pos;\r
-  hash[kFix3HashSize + h3] = pos;\r
-  hash[kFix4HashSize + h4] = pos;\r
-  hash[kFix5HashSize + hv] = pos;\r
-\r
-  maxLen = 0;\r
-  offset = 0;\r
-\r
-  if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)\r
-  {\r
-    distances[0] = maxLen = 2;\r
-    distances[1] = d2 - 1;\r
-    offset = 2;\r
-    if (*(cur - d2 + 2) == cur[2])\r
-      distances[0] = maxLen = 3;\r
-    else if (d3 < p->cyclicBufferSize && *(cur - d3) == *cur)\r
-    {\r
-      distances[2] = maxLen = 3;\r
-      distances[3] = d3 - 1;\r
-      offset = 4;\r
-      d2 = d3;\r
-    }\r
-  }\r
-  else if (d3 < p->cyclicBufferSize && *(cur - d3) == *cur)\r
-  {\r
-    distances[0] = maxLen = 3;\r
-    distances[1] = d3 - 1;\r
-    offset = 2;\r
-    d2 = d3;\r
-  }\r
-  \r
-  if (d2 != d4 && d4 < p->cyclicBufferSize\r
-      && *(cur - d4) == *cur\r
-      && *(cur - d4 + 3) == *(cur + 3))\r
-  {\r
-    maxLen = 4;\r
-    distances[offset + 1] = d4 - 1;\r
-    offset += 2;\r
-    d2 = d4;\r
-  }\r
-  \r
-  if (offset != 0)\r
-  {\r
-    UPDATE_maxLen\r
-    distances[offset - 2] = maxLen;\r
-    if (maxLen == lenLimit)\r
-    {\r
-      SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p));\r
-      MOVE_POS_RET;\r
-    }\r
-  }\r
-\r
-  if (maxLen < 4)\r
-    maxLen = 4;\r
-  \r
-  GET_MATCHES_FOOTER(offset, maxLen)\r
-}\r
-*/\r
-\r
-static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)\r
-{\r
-  UInt32 h2, h3, d2, d3, maxLen, offset, pos;\r
-  UInt32 *hash;\r
-  GET_MATCHES_HEADER(4)\r
-\r
-  HASH4_CALC;\r
-\r
-  hash = p->hash;\r
-  pos = p->pos;\r
-  \r
-  d2 = pos - hash[                h2];\r
-  d3 = pos - hash[kFix3HashSize + h3];\r
-  \r
-  curMatch = hash[kFix4HashSize + hv];\r
-\r
-  hash[                h2] = pos;\r
-  hash[kFix3HashSize + h3] = pos;\r
-  hash[kFix4HashSize + hv] = pos;\r
-\r
-  maxLen = 0;\r
-  offset = 0;\r
-\r
-  if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)\r
-  {\r
-    distances[0] = maxLen = 2;\r
-    distances[1] = d2 - 1;\r
-    offset = 2;\r
-  }\r
-  \r
-  if (d2 != d3 && d3 < p->cyclicBufferSize && *(cur - d3) == *cur)\r
-  {\r
-    maxLen = 3;\r
-    distances[offset + 1] = d3 - 1;\r
-    offset += 2;\r
-    d2 = d3;\r
-  }\r
-  \r
-  if (offset != 0)\r
-  {\r
-    UPDATE_maxLen\r
-    distances[offset - 2] = maxLen;\r
-    if (maxLen == lenLimit)\r
-    {\r
-      p->son[p->cyclicBufferPos] = curMatch;\r
-      MOVE_POS_RET;\r
-    }\r
-  }\r
-  \r
-  if (maxLen < 3)\r
-    maxLen = 3;\r
-\r
-  offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),\r
-      distances + offset, maxLen) - (distances));\r
-  MOVE_POS_RET\r
-}\r
-\r
-/*\r
-static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)\r
-{\r
-  UInt32 h2, h3, h4, d2, d3, d4, maxLen, offset, pos\r
-  UInt32 *hash;\r
-  GET_MATCHES_HEADER(5)\r
-\r
-  HASH5_CALC;\r
-\r
-  hash = p->hash;\r
-  pos = p->pos;\r
-  \r
-  d2 = pos - hash[                h2];\r
-  d3 = pos - hash[kFix3HashSize + h3];\r
-  d4 = pos - hash[kFix4HashSize + h4];\r
-\r
-  curMatch = hash[kFix5HashSize + hv];\r
-\r
-  hash[                h2] = pos;\r
-  hash[kFix3HashSize + h3] = pos;\r
-  hash[kFix4HashSize + h4] = pos;\r
-  hash[kFix5HashSize + hv] = pos;\r
-\r
-  maxLen = 0;\r
-  offset = 0;\r
-\r
-  if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)\r
-  {\r
-    distances[0] = maxLen = 2;\r
-    distances[1] = d2 - 1;\r
-    offset = 2;\r
-    if (*(cur - d2 + 2) == cur[2])\r
-      distances[0] = maxLen = 3;\r
-    else if (d3 < p->cyclicBufferSize && *(cur - d3) == *cur)\r
-    {\r
-      distances[2] = maxLen = 3;\r
-      distances[3] = d3 - 1;\r
-      offset = 4;\r
-      d2 = d3;\r
-    }\r
-  }\r
-  else if (d3 < p->cyclicBufferSize && *(cur - d3) == *cur)\r
-  {\r
-    distances[0] = maxLen = 3;\r
-    distances[1] = d3 - 1;\r
-    offset = 2;\r
-    d2 = d3;\r
-  }\r
-  \r
-  if (d2 != d4 && d4 < p->cyclicBufferSize\r
-      && *(cur - d4) == *cur\r
-      && *(cur - d4 + 3) == *(cur + 3))\r
-  {\r
-    maxLen = 4;\r
-    distances[offset + 1] = d4 - 1;\r
-    offset += 2;\r
-    d2 = d4;\r
-  }\r
-  \r
-  if (offset != 0)\r
-  {\r
-    UPDATE_maxLen\r
-    distances[offset - 2] = maxLen;\r
-    if (maxLen == lenLimit)\r
-    {\r
-      p->son[p->cyclicBufferPos] = curMatch;\r
-      MOVE_POS_RET;\r
-    }\r
-  }\r
-  \r
-  if (maxLen < 4)\r
-    maxLen = 4;\r
-\r
-  offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),\r
-      distances + offset, maxLen) - (distances));\r
-  MOVE_POS_RET\r
-}\r
-*/\r
-\r
-UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)\r
-{\r
-  UInt32 offset;\r
-  GET_MATCHES_HEADER(3)\r
-  HASH_ZIP_CALC;\r
-  curMatch = p->hash[hv];\r
-  p->hash[hv] = p->pos;\r
-  offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),\r
-      distances, 2) - (distances));\r
-  MOVE_POS_RET\r
-}\r
-\r
-static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num)\r
-{\r
-  do\r
-  {\r
-    SKIP_HEADER(2)\r
-    HASH2_CALC;\r
-    curMatch = p->hash[hv];\r
-    p->hash[hv] = p->pos;\r
-    SKIP_FOOTER\r
-  }\r
-  while (--num != 0);\r
-}\r
-\r
-void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)\r
-{\r
-  do\r
-  {\r
-    SKIP_HEADER(3)\r
-    HASH_ZIP_CALC;\r
-    curMatch = p->hash[hv];\r
-    p->hash[hv] = p->pos;\r
-    SKIP_FOOTER\r
-  }\r
-  while (--num != 0);\r
-}\r
-\r
-static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num)\r
-{\r
-  do\r
-  {\r
-    UInt32 h2;\r
-    UInt32 *hash;\r
-    SKIP_HEADER(3)\r
-    HASH3_CALC;\r
-    hash = p->hash;\r
-    curMatch = hash[kFix3HashSize + hv];\r
-    hash[h2] =\r
-    hash[kFix3HashSize + hv] = p->pos;\r
-    SKIP_FOOTER\r
-  }\r
-  while (--num != 0);\r
-}\r
-\r
-static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)\r
-{\r
-  do\r
-  {\r
-    UInt32 h2, h3;\r
-    UInt32 *hash;\r
-    SKIP_HEADER(4)\r
-    HASH4_CALC;\r
-    hash = p->hash;\r
-    curMatch = hash[kFix4HashSize + hv];\r
-    hash[                h2] =\r
-    hash[kFix3HashSize + h3] =\r
-    hash[kFix4HashSize + hv] = p->pos;\r
-    SKIP_FOOTER\r
-  }\r
-  while (--num != 0);\r
-}\r
-\r
-/*\r
-static void Bt5_MatchFinder_Skip(CMatchFinder *p, UInt32 num)\r
-{\r
-  do\r
-  {\r
-    UInt32 h2, h3, h4;\r
-    UInt32 *hash;\r
-    SKIP_HEADER(5)\r
-    HASH5_CALC;\r
-    hash = p->hash;\r
-    curMatch = hash[kFix5HashSize + hv];\r
-    hash[                h2] =\r
-    hash[kFix3HashSize + h3] =\r
-    hash[kFix4HashSize + h4] =\r
-    hash[kFix5HashSize + hv] = p->pos;\r
-    SKIP_FOOTER\r
-  }\r
-  while (--num != 0);\r
-}\r
-*/\r
-\r
-static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)\r
-{\r
-  do\r
-  {\r
-    UInt32 h2, h3;\r
-    UInt32 *hash;\r
-    SKIP_HEADER(4)\r
-    HASH4_CALC;\r
-    hash = p->hash;\r
-    curMatch = hash[kFix4HashSize + hv];\r
-    hash[                h2] =\r
-    hash[kFix3HashSize + h3] =\r
-    hash[kFix4HashSize + hv] = p->pos;\r
-    p->son[p->cyclicBufferPos] = curMatch;\r
-    MOVE_POS\r
-  }\r
-  while (--num != 0);\r
-}\r
-\r
-/*\r
-static void Hc5_MatchFinder_Skip(CMatchFinder *p, UInt32 num)\r
-{\r
-  do\r
-  {\r
-    UInt32 h2, h3, h4;\r
-    UInt32 *hash;\r
-    SKIP_HEADER(5)\r
-    HASH5_CALC;\r
-    hash = p->hash;\r
-    curMatch = p->hash[kFix5HashSize + hv];\r
-    hash[                h2] =\r
-    hash[kFix3HashSize + h3] =\r
-    hash[kFix4HashSize + h4] =\r
-    hash[kFix5HashSize + hv] = p->pos;\r
-    p->son[p->cyclicBufferPos] = curMatch;\r
-    MOVE_POS\r
-  }\r
-  while (--num != 0);\r
-}\r
-*/\r
-\r
-void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)\r
-{\r
-  do\r
-  {\r
-    SKIP_HEADER(3)\r
-    HASH_ZIP_CALC;\r
-    curMatch = p->hash[hv];\r
-    p->hash[hv] = p->pos;\r
-    p->son[p->cyclicBufferPos] = curMatch;\r
-    MOVE_POS\r
-  }\r
-  while (--num != 0);\r
-}\r
-\r
-void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable)\r
-{\r
-  vTable->Init = (Mf_Init_Func)MatchFinder_Init;\r
-  vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes;\r
-  vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos;\r
-  if (!p->btMode)\r
-  {\r
-    /* if (p->numHashBytes <= 4) */\r
-    {\r
-      vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches;\r
-      vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip;\r
-    }\r
-    /*\r
-    else\r
-    {\r
-      vTable->GetMatches = (Mf_GetMatches_Func)Hc5_MatchFinder_GetMatches;\r
-      vTable->Skip = (Mf_Skip_Func)Hc5_MatchFinder_Skip;\r
-    }\r
-    */\r
-  }\r
-  else if (p->numHashBytes == 2)\r
-  {\r
-    vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches;\r
-    vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip;\r
-  }\r
-  else if (p->numHashBytes == 3)\r
-  {\r
-    vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches;\r
-    vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip;\r
-  }\r
-  else /* if (p->numHashBytes == 4) */\r
-  {\r
-    vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches;\r
-    vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip;\r
-  }\r
-  /*\r
-  else\r
-  {\r
-    vTable->GetMatches = (Mf_GetMatches_Func)Bt5_MatchFinder_GetMatches;\r
-    vTable->Skip = (Mf_Skip_Func)Bt5_MatchFinder_Skip;\r
-  }\r
-  */\r
-}\r
diff --git a/deps/lzma-16.04/C/LzFind.h b/deps/lzma-16.04/C/LzFind.h
deleted file mode 100644 (file)
index 2ff6673..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/* LzFind.h -- Match finder for LZ algorithms\r
-2015-10-15 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __LZ_FIND_H\r
-#define __LZ_FIND_H\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-typedef UInt32 CLzRef;\r
-\r
-typedef struct _CMatchFinder\r
-{\r
-  Byte *buffer;\r
-  UInt32 pos;\r
-  UInt32 posLimit;\r
-  UInt32 streamPos;\r
-  UInt32 lenLimit;\r
-\r
-  UInt32 cyclicBufferPos;\r
-  UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */\r
-\r
-  Byte streamEndWasReached;\r
-  Byte btMode;\r
-  Byte bigHash;\r
-  Byte directInput;\r
-\r
-  UInt32 matchMaxLen;\r
-  CLzRef *hash;\r
-  CLzRef *son;\r
-  UInt32 hashMask;\r
-  UInt32 cutValue;\r
-\r
-  Byte *bufferBase;\r
-  ISeqInStream *stream;\r
-  \r
-  UInt32 blockSize;\r
-  UInt32 keepSizeBefore;\r
-  UInt32 keepSizeAfter;\r
-\r
-  UInt32 numHashBytes;\r
-  size_t directInputRem;\r
-  UInt32 historySize;\r
-  UInt32 fixedHashSize;\r
-  UInt32 hashSizeSum;\r
-  SRes result;\r
-  UInt32 crc[256];\r
-  size_t numRefs;\r
-} CMatchFinder;\r
-\r
-#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)\r
-\r
-#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)\r
-\r
-#define Inline_MatchFinder_IsFinishedOK(p) \\r
-    ((p)->streamEndWasReached \\r
-        && (p)->streamPos == (p)->pos \\r
-        && (!(p)->directInput || (p)->directInputRem == 0))\r
-      \r
-int MatchFinder_NeedMove(CMatchFinder *p);\r
-Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);\r
-void MatchFinder_MoveBlock(CMatchFinder *p);\r
-void MatchFinder_ReadIfRequired(CMatchFinder *p);\r
-\r
-void MatchFinder_Construct(CMatchFinder *p);\r
-\r
-/* Conditions:\r
-     historySize <= 3 GB\r
-     keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB\r
-*/\r
-int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,\r
-    UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,\r
-    ISzAlloc *alloc);\r
-void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc);\r
-void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems);\r
-void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);\r
-\r
-UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,\r
-    UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,\r
-    UInt32 *distances, UInt32 maxLen);\r
-\r
-/*\r
-Conditions:\r
-  Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.\r
-  Mf_GetPointerToCurrentPos_Func's result must be used only before any other function\r
-*/\r
-\r
-typedef void (*Mf_Init_Func)(void *object);\r
-typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object);\r
-typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object);\r
-typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances);\r
-typedef void (*Mf_Skip_Func)(void *object, UInt32);\r
-\r
-typedef struct _IMatchFinder\r
-{\r
-  Mf_Init_Func Init;\r
-  Mf_GetNumAvailableBytes_Func GetNumAvailableBytes;\r
-  Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos;\r
-  Mf_GetMatches_Func GetMatches;\r
-  Mf_Skip_Func Skip;\r
-} IMatchFinder;\r
-\r
-void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);\r
-\r
-void MatchFinder_Init_2(CMatchFinder *p, int readData);\r
-void MatchFinder_Init(CMatchFinder *p);\r
-\r
-UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);\r
-UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);\r
-\r
-void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);\r
-void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/LzFindMt.c b/deps/lzma-16.04/C/LzFindMt.c
deleted file mode 100644 (file)
index cb61e09..0000000
+++ /dev/null
@@ -1,803 +0,0 @@
-/* LzFindMt.c -- multithreaded Match finder for LZ algorithms\r
-2015-10-15 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "LzHash.h"\r
-\r
-#include "LzFindMt.h"\r
-\r
-static void MtSync_Construct(CMtSync *p)\r
-{\r
-  p->wasCreated = False;\r
-  p->csWasInitialized = False;\r
-  p->csWasEntered = False;\r
-  Thread_Construct(&p->thread);\r
-  Event_Construct(&p->canStart);\r
-  Event_Construct(&p->wasStarted);\r
-  Event_Construct(&p->wasStopped);\r
-  Semaphore_Construct(&p->freeSemaphore);\r
-  Semaphore_Construct(&p->filledSemaphore);\r
-}\r
-\r
-static void MtSync_GetNextBlock(CMtSync *p)\r
-{\r
-  if (p->needStart)\r
-  {\r
-    p->numProcessedBlocks = 1;\r
-    p->needStart = False;\r
-    p->stopWriting = False;\r
-    p->exit = False;\r
-    Event_Reset(&p->wasStarted);\r
-    Event_Reset(&p->wasStopped);\r
-\r
-    Event_Set(&p->canStart);\r
-    Event_Wait(&p->wasStarted);\r
-  }\r
-  else\r
-  {\r
-    CriticalSection_Leave(&p->cs);\r
-    p->csWasEntered = False;\r
-    p->numProcessedBlocks++;\r
-    Semaphore_Release1(&p->freeSemaphore);\r
-  }\r
-  Semaphore_Wait(&p->filledSemaphore);\r
-  CriticalSection_Enter(&p->cs);\r
-  p->csWasEntered = True;\r
-}\r
-\r
-/* MtSync_StopWriting must be called if Writing was started */\r
-\r
-static void MtSync_StopWriting(CMtSync *p)\r
-{\r
-  UInt32 myNumBlocks = p->numProcessedBlocks;\r
-  if (!Thread_WasCreated(&p->thread) || p->needStart)\r
-    return;\r
-  p->stopWriting = True;\r
-  if (p->csWasEntered)\r
-  {\r
-    CriticalSection_Leave(&p->cs);\r
-    p->csWasEntered = False;\r
-  }\r
-  Semaphore_Release1(&p->freeSemaphore);\r
\r
-  Event_Wait(&p->wasStopped);\r
-\r
-  while (myNumBlocks++ != p->numProcessedBlocks)\r
-  {\r
-    Semaphore_Wait(&p->filledSemaphore);\r
-    Semaphore_Release1(&p->freeSemaphore);\r
-  }\r
-  p->needStart = True;\r
-}\r
-\r
-static void MtSync_Destruct(CMtSync *p)\r
-{\r
-  if (Thread_WasCreated(&p->thread))\r
-  {\r
-    MtSync_StopWriting(p);\r
-    p->exit = True;\r
-    if (p->needStart)\r
-      Event_Set(&p->canStart);\r
-    Thread_Wait(&p->thread);\r
-    Thread_Close(&p->thread);\r
-  }\r
-  if (p->csWasInitialized)\r
-  {\r
-    CriticalSection_Delete(&p->cs);\r
-    p->csWasInitialized = False;\r
-  }\r
-\r
-  Event_Close(&p->canStart);\r
-  Event_Close(&p->wasStarted);\r
-  Event_Close(&p->wasStopped);\r
-  Semaphore_Close(&p->freeSemaphore);\r
-  Semaphore_Close(&p->filledSemaphore);\r
-\r
-  p->wasCreated = False;\r
-}\r
-\r
-#define RINOK_THREAD(x) { if ((x) != 0) return SZ_ERROR_THREAD; }\r
-\r
-static SRes MtSync_Create2(CMtSync *p, THREAD_FUNC_TYPE startAddress, void *obj, UInt32 numBlocks)\r
-{\r
-  if (p->wasCreated)\r
-    return SZ_OK;\r
-\r
-  RINOK_THREAD(CriticalSection_Init(&p->cs));\r
-  p->csWasInitialized = True;\r
-\r
-  RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->canStart));\r
-  RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->wasStarted));\r
-  RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->wasStopped));\r
-  \r
-  RINOK_THREAD(Semaphore_Create(&p->freeSemaphore, numBlocks, numBlocks));\r
-  RINOK_THREAD(Semaphore_Create(&p->filledSemaphore, 0, numBlocks));\r
-\r
-  p->needStart = True;\r
-  \r
-  RINOK_THREAD(Thread_Create(&p->thread, startAddress, obj));\r
-  p->wasCreated = True;\r
-  return SZ_OK;\r
-}\r
-\r
-static SRes MtSync_Create(CMtSync *p, THREAD_FUNC_TYPE startAddress, void *obj, UInt32 numBlocks)\r
-{\r
-  SRes res = MtSync_Create2(p, startAddress, obj, numBlocks);\r
-  if (res != SZ_OK)\r
-    MtSync_Destruct(p);\r
-  return res;\r
-}\r
-\r
-void MtSync_Init(CMtSync *p) { p->needStart = True; }\r
-\r
-#define kMtMaxValForNormalize 0xFFFFFFFF\r
-\r
-#define DEF_GetHeads2(name, v, action) \\r
-  static void GetHeads ## name(const Byte *p, UInt32 pos, \\r
-      UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc) \\r
-    { action; for (; numHeads != 0; numHeads--) { \\r
-      const UInt32 value = (v); p++; *heads++ = pos - hash[value]; hash[value] = pos++;  } }\r
-\r
-#define DEF_GetHeads(name, v) DEF_GetHeads2(name, v, ;)\r
-\r
-DEF_GetHeads2(2,  (p[0] | ((UInt32)p[1] << 8)), UNUSED_VAR(hashMask); UNUSED_VAR(crc); )\r
-DEF_GetHeads(3,  (crc[p[0]] ^ p[1] ^ ((UInt32)p[2] << 8)) & hashMask)\r
-DEF_GetHeads(4,  (crc[p[0]] ^ p[1] ^ ((UInt32)p[2] << 8) ^ (crc[p[3]] << 5)) & hashMask)\r
-DEF_GetHeads(4b, (crc[p[0]] ^ p[1] ^ ((UInt32)p[2] << 8) ^ ((UInt32)p[3] << 16)) & hashMask)\r
-/* DEF_GetHeads(5,  (crc[p[0]] ^ p[1] ^ ((UInt32)p[2] << 8) ^ (crc[p[3]] << 5) ^ (crc[p[4]] << 3)) & hashMask) */\r
-\r
-static void HashThreadFunc(CMatchFinderMt *mt)\r
-{\r
-  CMtSync *p = &mt->hashSync;\r
-  for (;;)\r
-  {\r
-    UInt32 numProcessedBlocks = 0;\r
-    Event_Wait(&p->canStart);\r
-    Event_Set(&p->wasStarted);\r
-    for (;;)\r
-    {\r
-      if (p->exit)\r
-        return;\r
-      if (p->stopWriting)\r
-      {\r
-        p->numProcessedBlocks = numProcessedBlocks;\r
-        Event_Set(&p->wasStopped);\r
-        break;\r
-      }\r
-\r
-      {\r
-        CMatchFinder *mf = mt->MatchFinder;\r
-        if (MatchFinder_NeedMove(mf))\r
-        {\r
-          CriticalSection_Enter(&mt->btSync.cs);\r
-          CriticalSection_Enter(&mt->hashSync.cs);\r
-          {\r
-            const Byte *beforePtr = Inline_MatchFinder_GetPointerToCurrentPos(mf);\r
-            ptrdiff_t offset;\r
-            MatchFinder_MoveBlock(mf);\r
-            offset = beforePtr - Inline_MatchFinder_GetPointerToCurrentPos(mf);\r
-            mt->pointerToCurPos -= offset;\r
-            mt->buffer -= offset;\r
-          }\r
-          CriticalSection_Leave(&mt->btSync.cs);\r
-          CriticalSection_Leave(&mt->hashSync.cs);\r
-          continue;\r
-        }\r
-\r
-        Semaphore_Wait(&p->freeSemaphore);\r
-\r
-        MatchFinder_ReadIfRequired(mf);\r
-        if (mf->pos > (kMtMaxValForNormalize - kMtHashBlockSize))\r
-        {\r
-          UInt32 subValue = (mf->pos - mf->historySize - 1);\r
-          MatchFinder_ReduceOffsets(mf, subValue);\r
-          MatchFinder_Normalize3(subValue, mf->hash + mf->fixedHashSize, (size_t)mf->hashMask + 1);\r
-        }\r
-        {\r
-          UInt32 *heads = mt->hashBuf + ((numProcessedBlocks++) & kMtHashNumBlocksMask) * kMtHashBlockSize;\r
-          UInt32 num = mf->streamPos - mf->pos;\r
-          heads[0] = 2;\r
-          heads[1] = num;\r
-          if (num >= mf->numHashBytes)\r
-          {\r
-            num = num - mf->numHashBytes + 1;\r
-            if (num > kMtHashBlockSize - 2)\r
-              num = kMtHashBlockSize - 2;\r
-            mt->GetHeadsFunc(mf->buffer, mf->pos, mf->hash + mf->fixedHashSize, mf->hashMask, heads + 2, num, mf->crc);\r
-            heads[0] += num;\r
-          }\r
-          mf->pos += num;\r
-          mf->buffer += num;\r
-        }\r
-      }\r
-\r
-      Semaphore_Release1(&p->filledSemaphore);\r
-    }\r
-  }\r
-}\r
-\r
-static void MatchFinderMt_GetNextBlock_Hash(CMatchFinderMt *p)\r
-{\r
-  MtSync_GetNextBlock(&p->hashSync);\r
-  p->hashBufPosLimit = p->hashBufPos = ((p->hashSync.numProcessedBlocks - 1) & kMtHashNumBlocksMask) * kMtHashBlockSize;\r
-  p->hashBufPosLimit += p->hashBuf[p->hashBufPos++];\r
-  p->hashNumAvail = p->hashBuf[p->hashBufPos++];\r
-}\r
-\r
-#define kEmptyHashValue 0\r
-\r
-/* #define MFMT_GM_INLINE */\r
-\r
-#ifdef MFMT_GM_INLINE\r
-\r
-#define NO_INLINE MY_FAST_CALL\r
-\r
-static Int32 NO_INLINE GetMatchesSpecN(UInt32 lenLimit, UInt32 pos, const Byte *cur, CLzRef *son,\r
-    UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,\r
-    UInt32 *_distances, UInt32 _maxLen, const UInt32 *hash, Int32 limit, UInt32 size, UInt32 *posRes)\r
-{\r
-  do\r
-  {\r
-  UInt32 *distances = _distances + 1;\r
-  UInt32 curMatch = pos - *hash++;\r
-\r
-  CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1;\r
-  CLzRef *ptr1 = son + (_cyclicBufferPos << 1);\r
-  UInt32 len0 = 0, len1 = 0;\r
-  UInt32 cutValue = _cutValue;\r
-  UInt32 maxLen = _maxLen;\r
-  for (;;)\r
-  {\r
-    UInt32 delta = pos - curMatch;\r
-    if (cutValue-- == 0 || delta >= _cyclicBufferSize)\r
-    {\r
-      *ptr0 = *ptr1 = kEmptyHashValue;\r
-      break;\r
-    }\r
-    {\r
-      CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);\r
-      const Byte *pb = cur - delta;\r
-      UInt32 len = (len0 < len1 ? len0 : len1);\r
-      if (pb[len] == cur[len])\r
-      {\r
-        if (++len != lenLimit && pb[len] == cur[len])\r
-          while (++len != lenLimit)\r
-            if (pb[len] != cur[len])\r
-              break;\r
-        if (maxLen < len)\r
-        {\r
-          *distances++ = maxLen = len;\r
-          *distances++ = delta - 1;\r
-          if (len == lenLimit)\r
-          {\r
-            *ptr1 = pair[0];\r
-            *ptr0 = pair[1];\r
-            break;\r
-          }\r
-        }\r
-      }\r
-      if (pb[len] < cur[len])\r
-      {\r
-        *ptr1 = curMatch;\r
-        ptr1 = pair + 1;\r
-        curMatch = *ptr1;\r
-        len1 = len;\r
-      }\r
-      else\r
-      {\r
-        *ptr0 = curMatch;\r
-        ptr0 = pair;\r
-        curMatch = *ptr0;\r
-        len0 = len;\r
-      }\r
-    }\r
-  }\r
-  pos++;\r
-  _cyclicBufferPos++;\r
-  cur++;\r
-  {\r
-    UInt32 num = (UInt32)(distances - _distances);\r
-    *_distances = num - 1;\r
-    _distances += num;\r
-    limit -= num;\r
-  }\r
-  }\r
-  while (limit > 0 && --size != 0);\r
-  *posRes = pos;\r
-  return limit;\r
-}\r
-\r
-#endif\r
-\r
-static void BtGetMatches(CMatchFinderMt *p, UInt32 *distances)\r
-{\r
-  UInt32 numProcessed = 0;\r
-  UInt32 curPos = 2;\r
-  UInt32 limit = kMtBtBlockSize - (p->matchMaxLen * 2);\r
-  \r
-  distances[1] = p->hashNumAvail;\r
-  \r
-  while (curPos < limit)\r
-  {\r
-    if (p->hashBufPos == p->hashBufPosLimit)\r
-    {\r
-      MatchFinderMt_GetNextBlock_Hash(p);\r
-      distances[1] = numProcessed + p->hashNumAvail;\r
-      if (p->hashNumAvail >= p->numHashBytes)\r
-        continue;\r
-      distances[0] = curPos + p->hashNumAvail;\r
-      distances += curPos;\r
-      for (; p->hashNumAvail != 0; p->hashNumAvail--)\r
-        *distances++ = 0;\r
-      return;\r
-    }\r
-    {\r
-      UInt32 size = p->hashBufPosLimit - p->hashBufPos;\r
-      UInt32 lenLimit = p->matchMaxLen;\r
-      UInt32 pos = p->pos;\r
-      UInt32 cyclicBufferPos = p->cyclicBufferPos;\r
-      if (lenLimit >= p->hashNumAvail)\r
-        lenLimit = p->hashNumAvail;\r
-      {\r
-        UInt32 size2 = p->hashNumAvail - lenLimit + 1;\r
-        if (size2 < size)\r
-          size = size2;\r
-        size2 = p->cyclicBufferSize - cyclicBufferPos;\r
-        if (size2 < size)\r
-          size = size2;\r
-      }\r
-      \r
-      #ifndef MFMT_GM_INLINE\r
-      while (curPos < limit && size-- != 0)\r
-      {\r
-        UInt32 *startDistances = distances + curPos;\r
-        UInt32 num = (UInt32)(GetMatchesSpec1(lenLimit, pos - p->hashBuf[p->hashBufPos++],\r
-            pos, p->buffer, p->son, cyclicBufferPos, p->cyclicBufferSize, p->cutValue,\r
-            startDistances + 1, p->numHashBytes - 1) - startDistances);\r
-        *startDistances = num - 1;\r
-        curPos += num;\r
-        cyclicBufferPos++;\r
-        pos++;\r
-        p->buffer++;\r
-      }\r
-      #else\r
-      {\r
-        UInt32 posRes;\r
-        curPos = limit - GetMatchesSpecN(lenLimit, pos, p->buffer, p->son, cyclicBufferPos, p->cyclicBufferSize, p->cutValue,\r
-            distances + curPos, p->numHashBytes - 1, p->hashBuf + p->hashBufPos, (Int32)(limit - curPos), size, &posRes);\r
-        p->hashBufPos += posRes - pos;\r
-        cyclicBufferPos += posRes - pos;\r
-        p->buffer += posRes - pos;\r
-        pos = posRes;\r
-      }\r
-      #endif\r
-\r
-      numProcessed += pos - p->pos;\r
-      p->hashNumAvail -= pos - p->pos;\r
-      p->pos = pos;\r
-      if (cyclicBufferPos == p->cyclicBufferSize)\r
-        cyclicBufferPos = 0;\r
-      p->cyclicBufferPos = cyclicBufferPos;\r
-    }\r
-  }\r
-  \r
-  distances[0] = curPos;\r
-}\r
-\r
-static void BtFillBlock(CMatchFinderMt *p, UInt32 globalBlockIndex)\r
-{\r
-  CMtSync *sync = &p->hashSync;\r
-  if (!sync->needStart)\r
-  {\r
-    CriticalSection_Enter(&sync->cs);\r
-    sync->csWasEntered = True;\r
-  }\r
-  \r
-  BtGetMatches(p, p->btBuf + (globalBlockIndex & kMtBtNumBlocksMask) * kMtBtBlockSize);\r
-\r
-  if (p->pos > kMtMaxValForNormalize - kMtBtBlockSize)\r
-  {\r
-    UInt32 subValue = p->pos - p->cyclicBufferSize;\r
-    MatchFinder_Normalize3(subValue, p->son, (size_t)p->cyclicBufferSize * 2);\r
-    p->pos -= subValue;\r
-  }\r
-\r
-  if (!sync->needStart)\r
-  {\r
-    CriticalSection_Leave(&sync->cs);\r
-    sync->csWasEntered = False;\r
-  }\r
-}\r
-\r
-void BtThreadFunc(CMatchFinderMt *mt)\r
-{\r
-  CMtSync *p = &mt->btSync;\r
-  for (;;)\r
-  {\r
-    UInt32 blockIndex = 0;\r
-    Event_Wait(&p->canStart);\r
-    Event_Set(&p->wasStarted);\r
-    for (;;)\r
-    {\r
-      if (p->exit)\r
-        return;\r
-      if (p->stopWriting)\r
-      {\r
-        p->numProcessedBlocks = blockIndex;\r
-        MtSync_StopWriting(&mt->hashSync);\r
-        Event_Set(&p->wasStopped);\r
-        break;\r
-      }\r
-      Semaphore_Wait(&p->freeSemaphore);\r
-      BtFillBlock(mt, blockIndex++);\r
-      Semaphore_Release1(&p->filledSemaphore);\r
-    }\r
-  }\r
-}\r
-\r
-void MatchFinderMt_Construct(CMatchFinderMt *p)\r
-{\r
-  p->hashBuf = NULL;\r
-  MtSync_Construct(&p->hashSync);\r
-  MtSync_Construct(&p->btSync);\r
-}\r
-\r
-static void MatchFinderMt_FreeMem(CMatchFinderMt *p, ISzAlloc *alloc)\r
-{\r
-  alloc->Free(alloc, p->hashBuf);\r
-  p->hashBuf = NULL;\r
-}\r
-\r
-void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAlloc *alloc)\r
-{\r
-  MtSync_Destruct(&p->hashSync);\r
-  MtSync_Destruct(&p->btSync);\r
-  MatchFinderMt_FreeMem(p, alloc);\r
-}\r
-\r
-#define kHashBufferSize (kMtHashBlockSize * kMtHashNumBlocks)\r
-#define kBtBufferSize (kMtBtBlockSize * kMtBtNumBlocks)\r
-\r
-static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE HashThreadFunc2(void *p) { HashThreadFunc((CMatchFinderMt *)p);  return 0; }\r
-static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE BtThreadFunc2(void *p)\r
-{\r
-  Byte allocaDummy[0x180];\r
-  unsigned i = 0;\r
-  for (i = 0; i < 16; i++)\r
-    allocaDummy[i] = (Byte)0;\r
-  if (allocaDummy[0] == 0)\r
-    BtThreadFunc((CMatchFinderMt *)p);\r
-  return 0;\r
-}\r
-\r
-SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore,\r
-    UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAlloc *alloc)\r
-{\r
-  CMatchFinder *mf = p->MatchFinder;\r
-  p->historySize = historySize;\r
-  if (kMtBtBlockSize <= matchMaxLen * 4)\r
-    return SZ_ERROR_PARAM;\r
-  if (!p->hashBuf)\r
-  {\r
-    p->hashBuf = (UInt32 *)alloc->Alloc(alloc, (kHashBufferSize + kBtBufferSize) * sizeof(UInt32));\r
-    if (!p->hashBuf)\r
-      return SZ_ERROR_MEM;\r
-    p->btBuf = p->hashBuf + kHashBufferSize;\r
-  }\r
-  keepAddBufferBefore += (kHashBufferSize + kBtBufferSize);\r
-  keepAddBufferAfter += kMtHashBlockSize;\r
-  if (!MatchFinder_Create(mf, historySize, keepAddBufferBefore, matchMaxLen, keepAddBufferAfter, alloc))\r
-    return SZ_ERROR_MEM;\r
-\r
-  RINOK(MtSync_Create(&p->hashSync, HashThreadFunc2, p, kMtHashNumBlocks));\r
-  RINOK(MtSync_Create(&p->btSync, BtThreadFunc2, p, kMtBtNumBlocks));\r
-  return SZ_OK;\r
-}\r
-\r
-/* Call it after ReleaseStream / SetStream */\r
-void MatchFinderMt_Init(CMatchFinderMt *p)\r
-{\r
-  CMatchFinder *mf = p->MatchFinder;\r
-  p->btBufPos = p->btBufPosLimit = 0;\r
-  p->hashBufPos = p->hashBufPosLimit = 0;\r
-\r
-  /* Init without data reading. We don't want to read data in this thread */\r
-  MatchFinder_Init_2(mf, False);\r
-  \r
-  p->pointerToCurPos = Inline_MatchFinder_GetPointerToCurrentPos(mf);\r
-  p->btNumAvailBytes = 0;\r
-  p->lzPos = p->historySize + 1;\r
-\r
-  p->hash = mf->hash;\r
-  p->fixedHashSize = mf->fixedHashSize;\r
-  p->crc = mf->crc;\r
-\r
-  p->son = mf->son;\r
-  p->matchMaxLen = mf->matchMaxLen;\r
-  p->numHashBytes = mf->numHashBytes;\r
-  p->pos = mf->pos;\r
-  p->buffer = mf->buffer;\r
-  p->cyclicBufferPos = mf->cyclicBufferPos;\r
-  p->cyclicBufferSize = mf->cyclicBufferSize;\r
-  p->cutValue = mf->cutValue;\r
-}\r
-\r
-/* ReleaseStream is required to finish multithreading */\r
-void MatchFinderMt_ReleaseStream(CMatchFinderMt *p)\r
-{\r
-  MtSync_StopWriting(&p->btSync);\r
-  /* p->MatchFinder->ReleaseStream(); */\r
-}\r
-\r
-static void MatchFinderMt_Normalize(CMatchFinderMt *p)\r
-{\r
-  MatchFinder_Normalize3(p->lzPos - p->historySize - 1, p->hash, p->fixedHashSize);\r
-  p->lzPos = p->historySize + 1;\r
-}\r
-\r
-static void MatchFinderMt_GetNextBlock_Bt(CMatchFinderMt *p)\r
-{\r
-  UInt32 blockIndex;\r
-  MtSync_GetNextBlock(&p->btSync);\r
-  blockIndex = ((p->btSync.numProcessedBlocks - 1) & kMtBtNumBlocksMask);\r
-  p->btBufPosLimit = p->btBufPos = blockIndex * kMtBtBlockSize;\r
-  p->btBufPosLimit += p->btBuf[p->btBufPos++];\r
-  p->btNumAvailBytes = p->btBuf[p->btBufPos++];\r
-  if (p->lzPos >= kMtMaxValForNormalize - kMtBtBlockSize)\r
-    MatchFinderMt_Normalize(p);\r
-}\r
-\r
-static const Byte * MatchFinderMt_GetPointerToCurrentPos(CMatchFinderMt *p)\r
-{\r
-  return p->pointerToCurPos;\r
-}\r
-\r
-#define GET_NEXT_BLOCK_IF_REQUIRED if (p->btBufPos == p->btBufPosLimit) MatchFinderMt_GetNextBlock_Bt(p);\r
-\r
-static UInt32 MatchFinderMt_GetNumAvailableBytes(CMatchFinderMt *p)\r
-{\r
-  GET_NEXT_BLOCK_IF_REQUIRED;\r
-  return p->btNumAvailBytes;\r
-}\r
-\r
-static UInt32 * MixMatches2(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)\r
-{\r
-  UInt32 h2, curMatch2;\r
-  UInt32 *hash = p->hash;\r
-  const Byte *cur = p->pointerToCurPos;\r
-  UInt32 lzPos = p->lzPos;\r
-  MT_HASH2_CALC\r
-      \r
-  curMatch2 = hash[h2];\r
-  hash[h2] = lzPos;\r
-\r
-  if (curMatch2 >= matchMinPos)\r
-    if (cur[(ptrdiff_t)curMatch2 - lzPos] == cur[0])\r
-    {\r
-      *distances++ = 2;\r
-      *distances++ = lzPos - curMatch2 - 1;\r
-    }\r
-  \r
-  return distances;\r
-}\r
-\r
-static UInt32 * MixMatches3(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)\r
-{\r
-  UInt32 h2, h3, curMatch2, curMatch3;\r
-  UInt32 *hash = p->hash;\r
-  const Byte *cur = p->pointerToCurPos;\r
-  UInt32 lzPos = p->lzPos;\r
-  MT_HASH3_CALC\r
-\r
-  curMatch2 = hash[                h2];\r
-  curMatch3 = hash[kFix3HashSize + h3];\r
-  \r
-  hash[                h2] = lzPos;\r
-  hash[kFix3HashSize + h3] = lzPos;\r
-\r
-  if (curMatch2 >= matchMinPos && cur[(ptrdiff_t)curMatch2 - lzPos] == cur[0])\r
-  {\r
-    distances[1] = lzPos - curMatch2 - 1;\r
-    if (cur[(ptrdiff_t)curMatch2 - lzPos + 2] == cur[2])\r
-    {\r
-      distances[0] = 3;\r
-      return distances + 2;\r
-    }\r
-    distances[0] = 2;\r
-    distances += 2;\r
-  }\r
-  \r
-  if (curMatch3 >= matchMinPos && cur[(ptrdiff_t)curMatch3 - lzPos] == cur[0])\r
-  {\r
-    *distances++ = 3;\r
-    *distances++ = lzPos - curMatch3 - 1;\r
-  }\r
-  \r
-  return distances;\r
-}\r
-\r
-/*\r
-static UInt32 *MixMatches4(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)\r
-{\r
-  UInt32 h2, h3, h4, curMatch2, curMatch3, curMatch4;\r
-  UInt32 *hash = p->hash;\r
-  const Byte *cur = p->pointerToCurPos;\r
-  UInt32 lzPos = p->lzPos;\r
-  MT_HASH4_CALC\r
-      \r
-  curMatch2 = hash[                h2];\r
-  curMatch3 = hash[kFix3HashSize + h3];\r
-  curMatch4 = hash[kFix4HashSize + h4];\r
-  \r
-  hash[                h2] = lzPos;\r
-  hash[kFix3HashSize + h3] = lzPos;\r
-  hash[kFix4HashSize + h4] = lzPos;\r
-\r
-  if (curMatch2 >= matchMinPos && cur[(ptrdiff_t)curMatch2 - lzPos] == cur[0])\r
-  {\r
-    distances[1] = lzPos - curMatch2 - 1;\r
-    if (cur[(ptrdiff_t)curMatch2 - lzPos + 2] == cur[2])\r
-    {\r
-      distances[0] = (cur[(ptrdiff_t)curMatch2 - lzPos + 3] == cur[3]) ? 4 : 3;\r
-      return distances + 2;\r
-    }\r
-    distances[0] = 2;\r
-    distances += 2;\r
-  }\r
-  \r
-  if (curMatch3 >= matchMinPos && cur[(ptrdiff_t)curMatch3 - lzPos] == cur[0])\r
-  {\r
-    distances[1] = lzPos - curMatch3 - 1;\r
-    if (cur[(ptrdiff_t)curMatch3 - lzPos + 3] == cur[3])\r
-    {\r
-      distances[0] = 4;\r
-      return distances + 2;\r
-    }\r
-    distances[0] = 3;\r
-    distances += 2;\r
-  }\r
-\r
-  if (curMatch4 >= matchMinPos)\r
-    if (\r
-      cur[(ptrdiff_t)curMatch4 - lzPos] == cur[0] &&\r
-      cur[(ptrdiff_t)curMatch4 - lzPos + 3] == cur[3]\r
-      )\r
-    {\r
-      *distances++ = 4;\r
-      *distances++ = lzPos - curMatch4 - 1;\r
-    }\r
-  \r
-  return distances;\r
-}\r
-*/\r
-\r
-#define INCREASE_LZ_POS p->lzPos++; p->pointerToCurPos++;\r
-\r
-static UInt32 MatchFinderMt2_GetMatches(CMatchFinderMt *p, UInt32 *distances)\r
-{\r
-  const UInt32 *btBuf = p->btBuf + p->btBufPos;\r
-  UInt32 len = *btBuf++;\r
-  p->btBufPos += 1 + len;\r
-  p->btNumAvailBytes--;\r
-  {\r
-    UInt32 i;\r
-    for (i = 0; i < len; i += 2)\r
-    {\r
-      *distances++ = *btBuf++;\r
-      *distances++ = *btBuf++;\r
-    }\r
-  }\r
-  INCREASE_LZ_POS\r
-  return len;\r
-}\r
-\r
-static UInt32 MatchFinderMt_GetMatches(CMatchFinderMt *p, UInt32 *distances)\r
-{\r
-  const UInt32 *btBuf = p->btBuf + p->btBufPos;\r
-  UInt32 len = *btBuf++;\r
-  p->btBufPos += 1 + len;\r
-\r
-  if (len == 0)\r
-  {\r
-    /* change for bt5 ! */\r
-    if (p->btNumAvailBytes-- >= 4)\r
-      len = (UInt32)(p->MixMatchesFunc(p, p->lzPos - p->historySize, distances) - (distances));\r
-  }\r
-  else\r
-  {\r
-    /* Condition: there are matches in btBuf with length < p->numHashBytes */\r
-    UInt32 *distances2;\r
-    p->btNumAvailBytes--;\r
-    distances2 = p->MixMatchesFunc(p, p->lzPos - btBuf[1], distances);\r
-    do\r
-    {\r
-      *distances2++ = *btBuf++;\r
-      *distances2++ = *btBuf++;\r
-    }\r
-    while ((len -= 2) != 0);\r
-    len = (UInt32)(distances2 - (distances));\r
-  }\r
-  INCREASE_LZ_POS\r
-  return len;\r
-}\r
-\r
-#define SKIP_HEADER2_MT  do { GET_NEXT_BLOCK_IF_REQUIRED\r
-#define SKIP_HEADER_MT(n) SKIP_HEADER2_MT if (p->btNumAvailBytes-- >= (n)) { const Byte *cur = p->pointerToCurPos; UInt32 *hash = p->hash;\r
-#define SKIP_FOOTER_MT } INCREASE_LZ_POS p->btBufPos += p->btBuf[p->btBufPos] + 1; } while (--num != 0);\r
-\r
-static void MatchFinderMt0_Skip(CMatchFinderMt *p, UInt32 num)\r
-{\r
-  SKIP_HEADER2_MT { p->btNumAvailBytes--;\r
-  SKIP_FOOTER_MT\r
-}\r
-\r
-static void MatchFinderMt2_Skip(CMatchFinderMt *p, UInt32 num)\r
-{\r
-  SKIP_HEADER_MT(2)\r
-      UInt32 h2;\r
-      MT_HASH2_CALC\r
-      hash[h2] = p->lzPos;\r
-  SKIP_FOOTER_MT\r
-}\r
-\r
-static void MatchFinderMt3_Skip(CMatchFinderMt *p, UInt32 num)\r
-{\r
-  SKIP_HEADER_MT(3)\r
-      UInt32 h2, h3;\r
-      MT_HASH3_CALC\r
-      hash[kFix3HashSize + h3] =\r
-      hash[                h2] =\r
-        p->lzPos;\r
-  SKIP_FOOTER_MT\r
-}\r
-\r
-/*\r
-static void MatchFinderMt4_Skip(CMatchFinderMt *p, UInt32 num)\r
-{\r
-  SKIP_HEADER_MT(4)\r
-      UInt32 h2, h3, h4;\r
-      MT_HASH4_CALC\r
-      hash[kFix4HashSize + h4] =\r
-      hash[kFix3HashSize + h3] =\r
-      hash[                h2] =\r
-        p->lzPos;\r
-  SKIP_FOOTER_MT\r
-}\r
-*/\r
-\r
-void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder *vTable)\r
-{\r
-  vTable->Init = (Mf_Init_Func)MatchFinderMt_Init;\r
-  vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinderMt_GetNumAvailableBytes;\r
-  vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinderMt_GetPointerToCurrentPos;\r
-  vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt_GetMatches;\r
-  \r
-  switch (p->MatchFinder->numHashBytes)\r
-  {\r
-    case 2:\r
-      p->GetHeadsFunc = GetHeads2;\r
-      p->MixMatchesFunc = (Mf_Mix_Matches)0;\r
-      vTable->Skip = (Mf_Skip_Func)MatchFinderMt0_Skip;\r
-      vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt2_GetMatches;\r
-      break;\r
-    case 3:\r
-      p->GetHeadsFunc = GetHeads3;\r
-      p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches2;\r
-      vTable->Skip = (Mf_Skip_Func)MatchFinderMt2_Skip;\r
-      break;\r
-    default:\r
-    /* case 4: */\r
-      p->GetHeadsFunc = p->MatchFinder->bigHash ? GetHeads4b : GetHeads4;\r
-      p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches3;\r
-      vTable->Skip = (Mf_Skip_Func)MatchFinderMt3_Skip;\r
-      break;\r
-    /*\r
-    default:\r
-      p->GetHeadsFunc = GetHeads5;\r
-      p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches4;\r
-      vTable->Skip = (Mf_Skip_Func)MatchFinderMt4_Skip;\r
-      break;\r
-    */\r
-  }\r
-}\r
diff --git a/deps/lzma-16.04/C/LzFindMt.h b/deps/lzma-16.04/C/LzFindMt.h
deleted file mode 100644 (file)
index 46b6924..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/* LzFindMt.h -- multithreaded Match finder for LZ algorithms\r
-2015-05-03 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __LZ_FIND_MT_H\r
-#define __LZ_FIND_MT_H\r
-\r
-#include "LzFind.h"\r
-#include "Threads.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-#define kMtHashBlockSize (1 << 13)\r
-#define kMtHashNumBlocks (1 << 3)\r
-#define kMtHashNumBlocksMask (kMtHashNumBlocks - 1)\r
-\r
-#define kMtBtBlockSize (1 << 14)\r
-#define kMtBtNumBlocks (1 << 6)\r
-#define kMtBtNumBlocksMask (kMtBtNumBlocks - 1)\r
-\r
-typedef struct _CMtSync\r
-{\r
-  Bool wasCreated;\r
-  Bool needStart;\r
-  Bool exit;\r
-  Bool stopWriting;\r
-\r
-  CThread thread;\r
-  CAutoResetEvent canStart;\r
-  CAutoResetEvent wasStarted;\r
-  CAutoResetEvent wasStopped;\r
-  CSemaphore freeSemaphore;\r
-  CSemaphore filledSemaphore;\r
-  Bool csWasInitialized;\r
-  Bool csWasEntered;\r
-  CCriticalSection cs;\r
-  UInt32 numProcessedBlocks;\r
-} CMtSync;\r
-\r
-typedef UInt32 * (*Mf_Mix_Matches)(void *p, UInt32 matchMinPos, UInt32 *distances);\r
-\r
-/* kMtCacheLineDummy must be >= size_of_CPU_cache_line */\r
-#define kMtCacheLineDummy 128\r
-\r
-typedef void (*Mf_GetHeads)(const Byte *buffer, UInt32 pos,\r
-  UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc);\r
-\r
-typedef struct _CMatchFinderMt\r
-{\r
-  /* LZ */\r
-  const Byte *pointerToCurPos;\r
-  UInt32 *btBuf;\r
-  UInt32 btBufPos;\r
-  UInt32 btBufPosLimit;\r
-  UInt32 lzPos;\r
-  UInt32 btNumAvailBytes;\r
-\r
-  UInt32 *hash;\r
-  UInt32 fixedHashSize;\r
-  UInt32 historySize;\r
-  const UInt32 *crc;\r
-\r
-  Mf_Mix_Matches MixMatchesFunc;\r
-  \r
-  /* LZ + BT */\r
-  CMtSync btSync;\r
-  Byte btDummy[kMtCacheLineDummy];\r
-\r
-  /* BT */\r
-  UInt32 *hashBuf;\r
-  UInt32 hashBufPos;\r
-  UInt32 hashBufPosLimit;\r
-  UInt32 hashNumAvail;\r
-\r
-  CLzRef *son;\r
-  UInt32 matchMaxLen;\r
-  UInt32 numHashBytes;\r
-  UInt32 pos;\r
-  const Byte *buffer;\r
-  UInt32 cyclicBufferPos;\r
-  UInt32 cyclicBufferSize; /* it must be historySize + 1 */\r
-  UInt32 cutValue;\r
-\r
-  /* BT + Hash */\r
-  CMtSync hashSync;\r
-  /* Byte hashDummy[kMtCacheLineDummy]; */\r
-  \r
-  /* Hash */\r
-  Mf_GetHeads GetHeadsFunc;\r
-  CMatchFinder *MatchFinder;\r
-} CMatchFinderMt;\r
-\r
-void MatchFinderMt_Construct(CMatchFinderMt *p);\r
-void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAlloc *alloc);\r
-SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore,\r
-    UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAlloc *alloc);\r
-void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder *vTable);\r
-void MatchFinderMt_ReleaseStream(CMatchFinderMt *p);\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/LzHash.h b/deps/lzma-16.04/C/LzHash.h
deleted file mode 100644 (file)
index 2191444..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/* LzHash.h -- HASH functions for LZ algorithms\r
-2015-04-12 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __LZ_HASH_H\r
-#define __LZ_HASH_H\r
-\r
-#define kHash2Size (1 << 10)\r
-#define kHash3Size (1 << 16)\r
-#define kHash4Size (1 << 20)\r
-\r
-#define kFix3HashSize (kHash2Size)\r
-#define kFix4HashSize (kHash2Size + kHash3Size)\r
-#define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size)\r
-\r
-#define HASH2_CALC hv = cur[0] | ((UInt32)cur[1] << 8);\r
-\r
-#define HASH3_CALC { \\r
-  UInt32 temp = p->crc[cur[0]] ^ cur[1]; \\r
-  h2 = temp & (kHash2Size - 1); \\r
-  hv = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; }\r
-\r
-#define HASH4_CALC { \\r
-  UInt32 temp = p->crc[cur[0]] ^ cur[1]; \\r
-  h2 = temp & (kHash2Size - 1); \\r
-  temp ^= ((UInt32)cur[2] << 8); \\r
-  h3 = temp & (kHash3Size - 1); \\r
-  hv = (temp ^ (p->crc[cur[3]] << 5)) & p->hashMask; }\r
-\r
-#define HASH5_CALC { \\r
-  UInt32 temp = p->crc[cur[0]] ^ cur[1]; \\r
-  h2 = temp & (kHash2Size - 1); \\r
-  temp ^= ((UInt32)cur[2] << 8); \\r
-  h3 = temp & (kHash3Size - 1); \\r
-  temp ^= (p->crc[cur[3]] << 5); \\r
-  h4 = temp & (kHash4Size - 1); \\r
-  hv = (temp ^ (p->crc[cur[4]] << 3)) & p->hashMask; }\r
-\r
-/* #define HASH_ZIP_CALC hv = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */\r
-#define HASH_ZIP_CALC hv = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF;\r
-\r
-\r
-#define MT_HASH2_CALC \\r
-  h2 = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1);\r
-\r
-#define MT_HASH3_CALC { \\r
-  UInt32 temp = p->crc[cur[0]] ^ cur[1]; \\r
-  h2 = temp & (kHash2Size - 1); \\r
-  h3 = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); }\r
-\r
-#define MT_HASH4_CALC { \\r
-  UInt32 temp = p->crc[cur[0]] ^ cur[1]; \\r
-  h2 = temp & (kHash2Size - 1); \\r
-  temp ^= ((UInt32)cur[2] << 8); \\r
-  h3 = temp & (kHash3Size - 1); \\r
-  h4 = (temp ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); }\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/Lzma2Dec.c b/deps/lzma-16.04/C/Lzma2Dec.c
deleted file mode 100644 (file)
index b688457..0000000
+++ /dev/null
@@ -1,378 +0,0 @@
-/* Lzma2Dec.c -- LZMA2 Decoder\r
-2015-11-09 : Igor Pavlov : Public domain */\r
-\r
-/* #define SHOW_DEBUG_INFO */\r
-\r
-#include "Precomp.h"\r
-\r
-#ifdef SHOW_DEBUG_INFO\r
-#include <stdio.h>\r
-#endif\r
-\r
-#include <string.h>\r
-\r
-#include "Lzma2Dec.h"\r
-\r
-/*\r
-00000000  -  EOS\r
-00000001 U U  -  Uncompressed Reset Dic\r
-00000010 U U  -  Uncompressed No Reset\r
-100uuuuu U U P P  -  LZMA no reset\r
-101uuuuu U U P P  -  LZMA reset state\r
-110uuuuu U U P P S  -  LZMA reset state + new prop\r
-111uuuuu U U P P S  -  LZMA reset state + new prop + reset dic\r
-\r
-  u, U - Unpack Size\r
-  P - Pack Size\r
-  S - Props\r
-*/\r
-\r
-#define LZMA2_CONTROL_LZMA (1 << 7)\r
-#define LZMA2_CONTROL_COPY_NO_RESET 2\r
-#define LZMA2_CONTROL_COPY_RESET_DIC 1\r
-#define LZMA2_CONTROL_EOF 0\r
-\r
-#define LZMA2_IS_UNCOMPRESSED_STATE(p) (((p)->control & LZMA2_CONTROL_LZMA) == 0)\r
-\r
-#define LZMA2_GET_LZMA_MODE(p) (((p)->control >> 5) & 3)\r
-#define LZMA2_IS_THERE_PROP(mode) ((mode) >= 2)\r
-\r
-#define LZMA2_LCLP_MAX 4\r
-#define LZMA2_DIC_SIZE_FROM_PROP(p) (((UInt32)2 | ((p) & 1)) << ((p) / 2 + 11))\r
-\r
-#ifdef SHOW_DEBUG_INFO\r
-#define PRF(x) x\r
-#else\r
-#define PRF(x)\r
-#endif\r
-\r
-typedef enum\r
-{\r
-  LZMA2_STATE_CONTROL,\r
-  LZMA2_STATE_UNPACK0,\r
-  LZMA2_STATE_UNPACK1,\r
-  LZMA2_STATE_PACK0,\r
-  LZMA2_STATE_PACK1,\r
-  LZMA2_STATE_PROP,\r
-  LZMA2_STATE_DATA,\r
-  LZMA2_STATE_DATA_CONT,\r
-  LZMA2_STATE_FINISHED,\r
-  LZMA2_STATE_ERROR\r
-} ELzma2State;\r
-\r
-static SRes Lzma2Dec_GetOldProps(Byte prop, Byte *props)\r
-{\r
-  UInt32 dicSize;\r
-  if (prop > 40)\r
-    return SZ_ERROR_UNSUPPORTED;\r
-  dicSize = (prop == 40) ? 0xFFFFFFFF : LZMA2_DIC_SIZE_FROM_PROP(prop);\r
-  props[0] = (Byte)LZMA2_LCLP_MAX;\r
-  props[1] = (Byte)(dicSize);\r
-  props[2] = (Byte)(dicSize >> 8);\r
-  props[3] = (Byte)(dicSize >> 16);\r
-  props[4] = (Byte)(dicSize >> 24);\r
-  return SZ_OK;\r
-}\r
-\r
-SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, Byte prop, ISzAlloc *alloc)\r
-{\r
-  Byte props[LZMA_PROPS_SIZE];\r
-  RINOK(Lzma2Dec_GetOldProps(prop, props));\r
-  return LzmaDec_AllocateProbs(&p->decoder, props, LZMA_PROPS_SIZE, alloc);\r
-}\r
-\r
-SRes Lzma2Dec_Allocate(CLzma2Dec *p, Byte prop, ISzAlloc *alloc)\r
-{\r
-  Byte props[LZMA_PROPS_SIZE];\r
-  RINOK(Lzma2Dec_GetOldProps(prop, props));\r
-  return LzmaDec_Allocate(&p->decoder, props, LZMA_PROPS_SIZE, alloc);\r
-}\r
-\r
-void Lzma2Dec_Init(CLzma2Dec *p)\r
-{\r
-  p->state = LZMA2_STATE_CONTROL;\r
-  p->needInitDic = True;\r
-  p->needInitState = True;\r
-  p->needInitProp = True;\r
-  LzmaDec_Init(&p->decoder);\r
-}\r
-\r
-static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)\r
-{\r
-  switch (p->state)\r
-  {\r
-    case LZMA2_STATE_CONTROL:\r
-      p->control = b;\r
-      PRF(printf("\n %4X ", (unsigned)p->decoder.dicPos));\r
-      PRF(printf(" %2X", (unsigned)b));\r
-      if (p->control == 0)\r
-        return LZMA2_STATE_FINISHED;\r
-      if (LZMA2_IS_UNCOMPRESSED_STATE(p))\r
-      {\r
-        if ((p->control & 0x7F) > 2)\r
-          return LZMA2_STATE_ERROR;\r
-        p->unpackSize = 0;\r
-      }\r
-      else\r
-        p->unpackSize = (UInt32)(p->control & 0x1F) << 16;\r
-      return LZMA2_STATE_UNPACK0;\r
-    \r
-    case LZMA2_STATE_UNPACK0:\r
-      p->unpackSize |= (UInt32)b << 8;\r
-      return LZMA2_STATE_UNPACK1;\r
-    \r
-    case LZMA2_STATE_UNPACK1:\r
-      p->unpackSize |= (UInt32)b;\r
-      p->unpackSize++;\r
-      PRF(printf(" %8u", (unsigned)p->unpackSize));\r
-      return (LZMA2_IS_UNCOMPRESSED_STATE(p)) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0;\r
-    \r
-    case LZMA2_STATE_PACK0:\r
-      p->packSize = (UInt32)b << 8;\r
-      return LZMA2_STATE_PACK1;\r
-\r
-    case LZMA2_STATE_PACK1:\r
-      p->packSize |= (UInt32)b;\r
-      p->packSize++;\r
-      PRF(printf(" %8u", (unsigned)p->packSize));\r
-      return LZMA2_IS_THERE_PROP(LZMA2_GET_LZMA_MODE(p)) ? LZMA2_STATE_PROP:\r
-        (p->needInitProp ? LZMA2_STATE_ERROR : LZMA2_STATE_DATA);\r
-\r
-    case LZMA2_STATE_PROP:\r
-    {\r
-      unsigned lc, lp;\r
-      if (b >= (9 * 5 * 5))\r
-        return LZMA2_STATE_ERROR;\r
-      lc = b % 9;\r
-      b /= 9;\r
-      p->decoder.prop.pb = b / 5;\r
-      lp = b % 5;\r
-      if (lc + lp > LZMA2_LCLP_MAX)\r
-        return LZMA2_STATE_ERROR;\r
-      p->decoder.prop.lc = lc;\r
-      p->decoder.prop.lp = lp;\r
-      p->needInitProp = False;\r
-      return LZMA2_STATE_DATA;\r
-    }\r
-  }\r
-  return LZMA2_STATE_ERROR;\r
-}\r
-\r
-static void LzmaDec_UpdateWithUncompressed(CLzmaDec *p, const Byte *src, SizeT size)\r
-{\r
-  memcpy(p->dic + p->dicPos, src, size);\r
-  p->dicPos += size;\r
-  if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= size)\r
-    p->checkDicSize = p->prop.dicSize;\r
-  p->processedPos += (UInt32)size;\r
-}\r
-\r
-void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState);\r
-\r
-SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit,\r
-    const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)\r
-{\r
-  SizeT inSize = *srcLen;\r
-  *srcLen = 0;\r
-  *status = LZMA_STATUS_NOT_SPECIFIED;\r
-\r
-  while (p->state != LZMA2_STATE_FINISHED)\r
-  {\r
-    SizeT dicPos = p->decoder.dicPos;\r
-    \r
-    if (p->state == LZMA2_STATE_ERROR)\r
-      return SZ_ERROR_DATA;\r
-    \r
-    if (dicPos == dicLimit && finishMode == LZMA_FINISH_ANY)\r
-    {\r
-      *status = LZMA_STATUS_NOT_FINISHED;\r
-      return SZ_OK;\r
-    }\r
-\r
-    if (p->state != LZMA2_STATE_DATA && p->state != LZMA2_STATE_DATA_CONT)\r
-    {\r
-      if (*srcLen == inSize)\r
-      {\r
-        *status = LZMA_STATUS_NEEDS_MORE_INPUT;\r
-        return SZ_OK;\r
-      }\r
-      (*srcLen)++;\r
-      p->state = Lzma2Dec_UpdateState(p, *src++);\r
-\r
-      if (dicPos == dicLimit && p->state != LZMA2_STATE_FINISHED)\r
-      {\r
-        p->state = LZMA2_STATE_ERROR;\r
-        return SZ_ERROR_DATA;\r
-      }\r
-      continue;\r
-    }\r
-    \r
-    {\r
-      SizeT destSizeCur = dicLimit - dicPos;\r
-      SizeT srcSizeCur = inSize - *srcLen;\r
-      ELzmaFinishMode curFinishMode = LZMA_FINISH_ANY;\r
-      \r
-      if (p->unpackSize <= destSizeCur)\r
-      {\r
-        destSizeCur = (SizeT)p->unpackSize;\r
-        curFinishMode = LZMA_FINISH_END;\r
-      }\r
-\r
-      if (LZMA2_IS_UNCOMPRESSED_STATE(p))\r
-      {\r
-        if (*srcLen == inSize)\r
-        {\r
-          *status = LZMA_STATUS_NEEDS_MORE_INPUT;\r
-          return SZ_OK;\r
-        }\r
-\r
-        if (p->state == LZMA2_STATE_DATA)\r
-        {\r
-          Bool initDic = (p->control == LZMA2_CONTROL_COPY_RESET_DIC);\r
-          if (initDic)\r
-            p->needInitProp = p->needInitState = True;\r
-          else if (p->needInitDic)\r
-          {\r
-            p->state = LZMA2_STATE_ERROR;\r
-            return SZ_ERROR_DATA;\r
-          }\r
-          p->needInitDic = False;\r
-          LzmaDec_InitDicAndState(&p->decoder, initDic, False);\r
-        }\r
-\r
-        if (srcSizeCur > destSizeCur)\r
-          srcSizeCur = destSizeCur;\r
-\r
-        if (srcSizeCur == 0)\r
-        {\r
-          p->state = LZMA2_STATE_ERROR;\r
-          return SZ_ERROR_DATA;\r
-        }\r
-\r
-        LzmaDec_UpdateWithUncompressed(&p->decoder, src, srcSizeCur);\r
-\r
-        src += srcSizeCur;\r
-        *srcLen += srcSizeCur;\r
-        p->unpackSize -= (UInt32)srcSizeCur;\r
-        p->state = (p->unpackSize == 0) ? LZMA2_STATE_CONTROL : LZMA2_STATE_DATA_CONT;\r
-      }\r
-      else\r
-      {\r
-        SizeT outSizeProcessed;\r
-        SRes res;\r
-\r
-        if (p->state == LZMA2_STATE_DATA)\r
-        {\r
-          unsigned mode = LZMA2_GET_LZMA_MODE(p);\r
-          Bool initDic = (mode == 3);\r
-          Bool initState = (mode != 0);\r
-          if ((!initDic && p->needInitDic) || (!initState && p->needInitState))\r
-          {\r
-            p->state = LZMA2_STATE_ERROR;\r
-            return SZ_ERROR_DATA;\r
-          }\r
-          \r
-          LzmaDec_InitDicAndState(&p->decoder, initDic, initState);\r
-          p->needInitDic = False;\r
-          p->needInitState = False;\r
-          p->state = LZMA2_STATE_DATA_CONT;\r
-        }\r
-  \r
-        if (srcSizeCur > p->packSize)\r
-          srcSizeCur = (SizeT)p->packSize;\r
-          \r
-        res = LzmaDec_DecodeToDic(&p->decoder, dicPos + destSizeCur, src, &srcSizeCur, curFinishMode, status);\r
-        \r
-        src += srcSizeCur;\r
-        *srcLen += srcSizeCur;\r
-        p->packSize -= (UInt32)srcSizeCur;\r
-\r
-        outSizeProcessed = p->decoder.dicPos - dicPos;\r
-        p->unpackSize -= (UInt32)outSizeProcessed;\r
-\r
-        RINOK(res);\r
-        if (*status == LZMA_STATUS_NEEDS_MORE_INPUT)\r
-          return res;\r
-\r
-        if (srcSizeCur == 0 && outSizeProcessed == 0)\r
-        {\r
-          if (*status != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK\r
-              || p->unpackSize != 0\r
-              || p->packSize != 0)\r
-          {\r
-            p->state = LZMA2_STATE_ERROR;\r
-            return SZ_ERROR_DATA;\r
-          }\r
-          p->state = LZMA2_STATE_CONTROL;\r
-        }\r
-        \r
-        if (*status == LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK)\r
-          *status = LZMA_STATUS_NOT_FINISHED;\r
-      }\r
-    }\r
-  }\r
-  \r
-  *status = LZMA_STATUS_FINISHED_WITH_MARK;\r
-  return SZ_OK;\r
-}\r
-\r
-SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)\r
-{\r
-  SizeT outSize = *destLen, inSize = *srcLen;\r
-  *srcLen = *destLen = 0;\r
-  for (;;)\r
-  {\r
-    SizeT srcSizeCur = inSize, outSizeCur, dicPos;\r
-    ELzmaFinishMode curFinishMode;\r
-    SRes res;\r
-    if (p->decoder.dicPos == p->decoder.dicBufSize)\r
-      p->decoder.dicPos = 0;\r
-    dicPos = p->decoder.dicPos;\r
-    if (outSize > p->decoder.dicBufSize - dicPos)\r
-    {\r
-      outSizeCur = p->decoder.dicBufSize;\r
-      curFinishMode = LZMA_FINISH_ANY;\r
-    }\r
-    else\r
-    {\r
-      outSizeCur = dicPos + outSize;\r
-      curFinishMode = finishMode;\r
-    }\r
-\r
-    res = Lzma2Dec_DecodeToDic(p, outSizeCur, src, &srcSizeCur, curFinishMode, status);\r
-    src += srcSizeCur;\r
-    inSize -= srcSizeCur;\r
-    *srcLen += srcSizeCur;\r
-    outSizeCur = p->decoder.dicPos - dicPos;\r
-    memcpy(dest, p->decoder.dic + dicPos, outSizeCur);\r
-    dest += outSizeCur;\r
-    outSize -= outSizeCur;\r
-    *destLen += outSizeCur;\r
-    if (res != 0)\r
-      return res;\r
-    if (outSizeCur == 0 || outSize == 0)\r
-      return SZ_OK;\r
-  }\r
-}\r
-\r
-SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,\r
-    Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc)\r
-{\r
-  CLzma2Dec p;\r
-  SRes res;\r
-  SizeT outSize = *destLen, inSize = *srcLen;\r
-  *destLen = *srcLen = 0;\r
-  *status = LZMA_STATUS_NOT_SPECIFIED;\r
-  Lzma2Dec_Construct(&p);\r
-  RINOK(Lzma2Dec_AllocateProbs(&p, prop, alloc));\r
-  p.decoder.dic = dest;\r
-  p.decoder.dicBufSize = outSize;\r
-  Lzma2Dec_Init(&p);\r
-  *srcLen = inSize;\r
-  res = Lzma2Dec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status);\r
-  *destLen = p.decoder.dicPos;\r
-  if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT)\r
-    res = SZ_ERROR_INPUT_EOF;\r
-  Lzma2Dec_FreeProbs(&p, alloc);\r
-  return res;\r
-}\r
diff --git a/deps/lzma-16.04/C/Lzma2Dec.h b/deps/lzma-16.04/C/Lzma2Dec.h
deleted file mode 100644 (file)
index 026cdef..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/* Lzma2Dec.h -- LZMA2 Decoder\r
-2015-05-13 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __LZMA2_DEC_H\r
-#define __LZMA2_DEC_H\r
-\r
-#include "LzmaDec.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-/* ---------- State Interface ---------- */\r
-\r
-typedef struct\r
-{\r
-  CLzmaDec decoder;\r
-  UInt32 packSize;\r
-  UInt32 unpackSize;\r
-  unsigned state;\r
-  Byte control;\r
-  Bool needInitDic;\r
-  Bool needInitState;\r
-  Bool needInitProp;\r
-} CLzma2Dec;\r
-\r
-#define Lzma2Dec_Construct(p) LzmaDec_Construct(&(p)->decoder)\r
-#define Lzma2Dec_FreeProbs(p, alloc) LzmaDec_FreeProbs(&(p)->decoder, alloc);\r
-#define Lzma2Dec_Free(p, alloc) LzmaDec_Free(&(p)->decoder, alloc);\r
-\r
-SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, Byte prop, ISzAlloc *alloc);\r
-SRes Lzma2Dec_Allocate(CLzma2Dec *p, Byte prop, ISzAlloc *alloc);\r
-void Lzma2Dec_Init(CLzma2Dec *p);\r
-\r
-\r
-/*\r
-finishMode:\r
-  It has meaning only if the decoding reaches output limit (*destLen or dicLimit).\r
-  LZMA_FINISH_ANY - use smallest number of input bytes\r
-  LZMA_FINISH_END - read EndOfStream marker after decoding\r
-\r
-Returns:\r
-  SZ_OK\r
-    status:\r
-      LZMA_STATUS_FINISHED_WITH_MARK\r
-      LZMA_STATUS_NOT_FINISHED\r
-      LZMA_STATUS_NEEDS_MORE_INPUT\r
-  SZ_ERROR_DATA - Data error\r
-*/\r
-\r
-SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit,\r
-    const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);\r
-\r
-SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen,\r
-    const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);\r
-\r
-\r
-/* ---------- One Call Interface ---------- */\r
-\r
-/*\r
-finishMode:\r
-  It has meaning only if the decoding reaches output limit (*destLen).\r
-  LZMA_FINISH_ANY - use smallest number of input bytes\r
-  LZMA_FINISH_END - read EndOfStream marker after decoding\r
-\r
-Returns:\r
-  SZ_OK\r
-    status:\r
-      LZMA_STATUS_FINISHED_WITH_MARK\r
-      LZMA_STATUS_NOT_FINISHED\r
-  SZ_ERROR_DATA - Data error\r
-  SZ_ERROR_MEM  - Memory allocation error\r
-  SZ_ERROR_UNSUPPORTED - Unsupported properties\r
-  SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).\r
-*/\r
-\r
-SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,\r
-    Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc);\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/Lzma2Enc.c b/deps/lzma-16.04/C/Lzma2Enc.c
deleted file mode 100644 (file)
index cba0134..0000000
+++ /dev/null
@@ -1,520 +0,0 @@
-/* Lzma2Enc.c -- LZMA2 Encoder\r
-2015-10-04 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-/* #include <stdio.h> */\r
-#include <string.h>\r
-\r
-/* #define _7ZIP_ST */\r
-\r
-#include "Lzma2Enc.h"\r
-\r
-#ifndef _7ZIP_ST\r
-#include "MtCoder.h"\r
-#else\r
-#define NUM_MT_CODER_THREADS_MAX 1\r
-#endif\r
-\r
-#define LZMA2_CONTROL_LZMA (1 << 7)\r
-#define LZMA2_CONTROL_COPY_NO_RESET 2\r
-#define LZMA2_CONTROL_COPY_RESET_DIC 1\r
-#define LZMA2_CONTROL_EOF 0\r
-\r
-#define LZMA2_LCLP_MAX 4\r
-\r
-#define LZMA2_DIC_SIZE_FROM_PROP(p) (((UInt32)2 | ((p) & 1)) << ((p) / 2 + 11))\r
-\r
-#define LZMA2_PACK_SIZE_MAX (1 << 16)\r
-#define LZMA2_COPY_CHUNK_SIZE LZMA2_PACK_SIZE_MAX\r
-#define LZMA2_UNPACK_SIZE_MAX (1 << 21)\r
-#define LZMA2_KEEP_WINDOW_SIZE LZMA2_UNPACK_SIZE_MAX\r
-\r
-#define LZMA2_CHUNK_SIZE_COMPRESSED_MAX ((1 << 16) + 16)\r
-\r
-\r
-#define PRF(x) /* x */\r
-\r
-/* ---------- CLzma2EncInt ---------- */\r
-\r
-typedef struct\r
-{\r
-  CLzmaEncHandle enc;\r
-  UInt64 srcPos;\r
-  Byte props;\r
-  Bool needInitState;\r
-  Bool needInitProp;\r
-} CLzma2EncInt;\r
-\r
-static SRes Lzma2EncInt_Init(CLzma2EncInt *p, const CLzma2EncProps *props)\r
-{\r
-  Byte propsEncoded[LZMA_PROPS_SIZE];\r
-  SizeT propsSize = LZMA_PROPS_SIZE;\r
-  RINOK(LzmaEnc_SetProps(p->enc, &props->lzmaProps));\r
-  RINOK(LzmaEnc_WriteProperties(p->enc, propsEncoded, &propsSize));\r
-  p->srcPos = 0;\r
-  p->props = propsEncoded[0];\r
-  p->needInitState = True;\r
-  p->needInitProp = True;\r
-  return SZ_OK;\r
-}\r
-\r
-SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, ISeqInStream *inStream, UInt32 keepWindowSize,\r
-    ISzAlloc *alloc, ISzAlloc *allocBig);\r
-SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,\r
-    UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig);\r
-SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,\r
-    Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize);\r
-const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp);\r
-void LzmaEnc_Finish(CLzmaEncHandle pp);\r
-void LzmaEnc_SaveState(CLzmaEncHandle pp);\r
-void LzmaEnc_RestoreState(CLzmaEncHandle pp);\r
-\r
-\r
-static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf,\r
-    size_t *packSizeRes, ISeqOutStream *outStream)\r
-{\r
-  size_t packSizeLimit = *packSizeRes;\r
-  size_t packSize = packSizeLimit;\r
-  UInt32 unpackSize = LZMA2_UNPACK_SIZE_MAX;\r
-  unsigned lzHeaderSize = 5 + (p->needInitProp ? 1 : 0);\r
-  Bool useCopyBlock;\r
-  SRes res;\r
-\r
-  *packSizeRes = 0;\r
-  if (packSize < lzHeaderSize)\r
-    return SZ_ERROR_OUTPUT_EOF;\r
-  packSize -= lzHeaderSize;\r
-  \r
-  LzmaEnc_SaveState(p->enc);\r
-  res = LzmaEnc_CodeOneMemBlock(p->enc, p->needInitState,\r
-      outBuf + lzHeaderSize, &packSize, LZMA2_PACK_SIZE_MAX, &unpackSize);\r
-  \r
-  PRF(printf("\npackSize = %7d unpackSize = %7d  ", packSize, unpackSize));\r
-\r
-  if (unpackSize == 0)\r
-    return res;\r
-\r
-  if (res == SZ_OK)\r
-    useCopyBlock = (packSize + 2 >= unpackSize || packSize > (1 << 16));\r
-  else\r
-  {\r
-    if (res != SZ_ERROR_OUTPUT_EOF)\r
-      return res;\r
-    res = SZ_OK;\r
-    useCopyBlock = True;\r
-  }\r
-\r
-  if (useCopyBlock)\r
-  {\r
-    size_t destPos = 0;\r
-    PRF(printf("################# COPY           "));\r
-\r
-    while (unpackSize > 0)\r
-    {\r
-      UInt32 u = (unpackSize < LZMA2_COPY_CHUNK_SIZE) ? unpackSize : LZMA2_COPY_CHUNK_SIZE;\r
-      if (packSizeLimit - destPos < u + 3)\r
-        return SZ_ERROR_OUTPUT_EOF;\r
-      outBuf[destPos++] = (Byte)(p->srcPos == 0 ? LZMA2_CONTROL_COPY_RESET_DIC : LZMA2_CONTROL_COPY_NO_RESET);\r
-      outBuf[destPos++] = (Byte)((u - 1) >> 8);\r
-      outBuf[destPos++] = (Byte)(u - 1);\r
-      memcpy(outBuf + destPos, LzmaEnc_GetCurBuf(p->enc) - unpackSize, u);\r
-      unpackSize -= u;\r
-      destPos += u;\r
-      p->srcPos += u;\r
-      \r
-      if (outStream)\r
-      {\r
-        *packSizeRes += destPos;\r
-        if (outStream->Write(outStream, outBuf, destPos) != destPos)\r
-          return SZ_ERROR_WRITE;\r
-        destPos = 0;\r
-      }\r
-      else\r
-        *packSizeRes = destPos;\r
-      /* needInitState = True; */\r
-    }\r
-    \r
-    LzmaEnc_RestoreState(p->enc);\r
-    return SZ_OK;\r
-  }\r
-\r
-  {\r
-    size_t destPos = 0;\r
-    UInt32 u = unpackSize - 1;\r
-    UInt32 pm = (UInt32)(packSize - 1);\r
-    unsigned mode = (p->srcPos == 0) ? 3 : (p->needInitState ? (p->needInitProp ? 2 : 1) : 0);\r
-\r
-    PRF(printf("               "));\r
-\r
-    outBuf[destPos++] = (Byte)(LZMA2_CONTROL_LZMA | (mode << 5) | ((u >> 16) & 0x1F));\r
-    outBuf[destPos++] = (Byte)(u >> 8);\r
-    outBuf[destPos++] = (Byte)u;\r
-    outBuf[destPos++] = (Byte)(pm >> 8);\r
-    outBuf[destPos++] = (Byte)pm;\r
-    \r
-    if (p->needInitProp)\r
-      outBuf[destPos++] = p->props;\r
-    \r
-    p->needInitProp = False;\r
-    p->needInitState = False;\r
-    destPos += packSize;\r
-    p->srcPos += unpackSize;\r
-\r
-    if (outStream)\r
-      if (outStream->Write(outStream, outBuf, destPos) != destPos)\r
-        return SZ_ERROR_WRITE;\r
-    \r
-    *packSizeRes = destPos;\r
-    return SZ_OK;\r
-  }\r
-}\r
-\r
-\r
-/* ---------- Lzma2 Props ---------- */\r
-\r
-void Lzma2EncProps_Init(CLzma2EncProps *p)\r
-{\r
-  LzmaEncProps_Init(&p->lzmaProps);\r
-  p->numTotalThreads = -1;\r
-  p->numBlockThreads = -1;\r
-  p->blockSize = 0;\r
-}\r
-\r
-void Lzma2EncProps_Normalize(CLzma2EncProps *p)\r
-{\r
-  int t1, t1n, t2, t3;\r
-  {\r
-    CLzmaEncProps lzmaProps = p->lzmaProps;\r
-    LzmaEncProps_Normalize(&lzmaProps);\r
-    t1n = lzmaProps.numThreads;\r
-  }\r
-\r
-  t1 = p->lzmaProps.numThreads;\r
-  t2 = p->numBlockThreads;\r
-  t3 = p->numTotalThreads;\r
-\r
-  if (t2 > NUM_MT_CODER_THREADS_MAX)\r
-    t2 = NUM_MT_CODER_THREADS_MAX;\r
-\r
-  if (t3 <= 0)\r
-  {\r
-    if (t2 <= 0)\r
-      t2 = 1;\r
-    t3 = t1n * t2;\r
-  }\r
-  else if (t2 <= 0)\r
-  {\r
-    t2 = t3 / t1n;\r
-    if (t2 == 0)\r
-    {\r
-      t1 = 1;\r
-      t2 = t3;\r
-    }\r
-    if (t2 > NUM_MT_CODER_THREADS_MAX)\r
-      t2 = NUM_MT_CODER_THREADS_MAX;\r
-  }\r
-  else if (t1 <= 0)\r
-  {\r
-    t1 = t3 / t2;\r
-    if (t1 == 0)\r
-      t1 = 1;\r
-  }\r
-  else\r
-    t3 = t1n * t2;\r
-\r
-  p->lzmaProps.numThreads = t1;\r
-\r
-  LzmaEncProps_Normalize(&p->lzmaProps);\r
-\r
-  t1 = p->lzmaProps.numThreads;\r
-\r
-  if (p->blockSize == 0)\r
-  {\r
-    UInt32 dictSize = p->lzmaProps.dictSize;\r
-    UInt64 blockSize = (UInt64)dictSize << 2;\r
-    const UInt32 kMinSize = (UInt32)1 << 20;\r
-    const UInt32 kMaxSize = (UInt32)1 << 28;\r
-    if (blockSize < kMinSize) blockSize = kMinSize;\r
-    if (blockSize > kMaxSize) blockSize = kMaxSize;\r
-    if (blockSize < dictSize) blockSize = dictSize;\r
-    p->blockSize = (size_t)blockSize;\r
-  }\r
-  \r
-  if (t2 > 1 && p->lzmaProps.reduceSize != (UInt64)(Int64)-1)\r
-  {\r
-    UInt64 temp = p->lzmaProps.reduceSize + p->blockSize - 1;\r
-    if (temp > p->lzmaProps.reduceSize)\r
-    {\r
-      UInt64 numBlocks = temp / p->blockSize;\r
-      if (numBlocks < (unsigned)t2)\r
-      {\r
-        t2 = (unsigned)numBlocks;\r
-        if (t2 == 0)\r
-          t2 = 1;\r
-        t3 = t1 * t2;\r
-      }\r
-    }\r
-  }\r
-  \r
-  p->numBlockThreads = t2;\r
-  p->numTotalThreads = t3;\r
-}\r
-\r
-\r
-static SRes Progress(ICompressProgress *p, UInt64 inSize, UInt64 outSize)\r
-{\r
-  return (p && p->Progress(p, inSize, outSize) != SZ_OK) ? SZ_ERROR_PROGRESS : SZ_OK;\r
-}\r
-\r
-\r
-/* ---------- Lzma2 ---------- */\r
-\r
-typedef struct\r
-{\r
-  Byte propEncoded;\r
-  CLzma2EncProps props;\r
-  \r
-  Byte *outBuf;\r
-\r
-  ISzAlloc *alloc;\r
-  ISzAlloc *allocBig;\r
-\r
-  CLzma2EncInt coders[NUM_MT_CODER_THREADS_MAX];\r
-\r
-  #ifndef _7ZIP_ST\r
-  CMtCoder mtCoder;\r
-  #endif\r
-\r
-} CLzma2Enc;\r
-\r
-\r
-/* ---------- Lzma2EncThread ---------- */\r
-\r
-static SRes Lzma2Enc_EncodeMt1(CLzma2EncInt *p, CLzma2Enc *mainEncoder,\r
-  ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress)\r
-{\r
-  UInt64 packTotal = 0;\r
-  SRes res = SZ_OK;\r
-\r
-  if (!mainEncoder->outBuf)\r
-  {\r
-    mainEncoder->outBuf = (Byte *)IAlloc_Alloc(mainEncoder->alloc, LZMA2_CHUNK_SIZE_COMPRESSED_MAX);\r
-    if (!mainEncoder->outBuf)\r
-      return SZ_ERROR_MEM;\r
-  }\r
-  \r
-  RINOK(Lzma2EncInt_Init(p, &mainEncoder->props));\r
-  RINOK(LzmaEnc_PrepareForLzma2(p->enc, inStream, LZMA2_KEEP_WINDOW_SIZE,\r
-      mainEncoder->alloc, mainEncoder->allocBig));\r
-  \r
-  for (;;)\r
-  {\r
-    size_t packSize = LZMA2_CHUNK_SIZE_COMPRESSED_MAX;\r
-    res = Lzma2EncInt_EncodeSubblock(p, mainEncoder->outBuf, &packSize, outStream);\r
-    if (res != SZ_OK)\r
-      break;\r
-    packTotal += packSize;\r
-    res = Progress(progress, p->srcPos, packTotal);\r
-    if (res != SZ_OK)\r
-      break;\r
-    if (packSize == 0)\r
-      break;\r
-  }\r
-  \r
-  LzmaEnc_Finish(p->enc);\r
-\r
-  if (res == SZ_OK)\r
-  {\r
-    Byte b = 0;\r
-    if (outStream->Write(outStream, &b, 1) != 1)\r
-      return SZ_ERROR_WRITE;\r
-  }\r
-  \r
-  return res;\r
-}\r
-\r
-\r
-#ifndef _7ZIP_ST\r
-\r
-typedef struct\r
-{\r
-  IMtCoderCallback funcTable;\r
-  CLzma2Enc *lzma2Enc;\r
-} CMtCallbackImp;\r
-\r
-static SRes MtCallbackImp_Code(void *pp, unsigned index, Byte *dest, size_t *destSize,\r
-      const Byte *src, size_t srcSize, int finished)\r
-{\r
-  CMtCallbackImp *imp = (CMtCallbackImp *)pp;\r
-  CLzma2Enc *mainEncoder = imp->lzma2Enc;\r
-  CLzma2EncInt *p = &mainEncoder->coders[index];\r
-\r
-  SRes res = SZ_OK;\r
-  {\r
-    size_t destLim = *destSize;\r
-    *destSize = 0;\r
-\r
-    if (srcSize != 0)\r
-    {\r
-      RINOK(Lzma2EncInt_Init(p, &mainEncoder->props));\r
-     \r
-      RINOK(LzmaEnc_MemPrepare(p->enc, src, srcSize, LZMA2_KEEP_WINDOW_SIZE,\r
-          mainEncoder->alloc, mainEncoder->allocBig));\r
-     \r
-      while (p->srcPos < srcSize)\r
-      {\r
-        size_t packSize = destLim - *destSize;\r
-        res = Lzma2EncInt_EncodeSubblock(p, dest + *destSize, &packSize, NULL);\r
-        if (res != SZ_OK)\r
-          break;\r
-        *destSize += packSize;\r
-\r
-        if (packSize == 0)\r
-        {\r
-          res = SZ_ERROR_FAIL;\r
-          break;\r
-        }\r
-\r
-        if (MtProgress_Set(&mainEncoder->mtCoder.mtProgress, index, p->srcPos, *destSize) != SZ_OK)\r
-        {\r
-          res = SZ_ERROR_PROGRESS;\r
-          break;\r
-        }\r
-      }\r
-      \r
-      LzmaEnc_Finish(p->enc);\r
-      if (res != SZ_OK)\r
-        return res;\r
-    }\r
-    \r
-    if (finished)\r
-    {\r
-      if (*destSize == destLim)\r
-        return SZ_ERROR_OUTPUT_EOF;\r
-      dest[(*destSize)++] = 0;\r
-    }\r
-  }\r
-  return res;\r
-}\r
-\r
-#endif\r
-\r
-\r
-/* ---------- Lzma2Enc ---------- */\r
-\r
-CLzma2EncHandle Lzma2Enc_Create(ISzAlloc *alloc, ISzAlloc *allocBig)\r
-{\r
-  CLzma2Enc *p = (CLzma2Enc *)alloc->Alloc(alloc, sizeof(CLzma2Enc));\r
-  if (!p)\r
-    return NULL;\r
-  Lzma2EncProps_Init(&p->props);\r
-  Lzma2EncProps_Normalize(&p->props);\r
-  p->outBuf = 0;\r
-  p->alloc = alloc;\r
-  p->allocBig = allocBig;\r
-  {\r
-    unsigned i;\r
-    for (i = 0; i < NUM_MT_CODER_THREADS_MAX; i++)\r
-      p->coders[i].enc = 0;\r
-  }\r
-  \r
-  #ifndef _7ZIP_ST\r
-  MtCoder_Construct(&p->mtCoder);\r
-  #endif\r
-\r
-  return p;\r
-}\r
-\r
-void Lzma2Enc_Destroy(CLzma2EncHandle pp)\r
-{\r
-  CLzma2Enc *p = (CLzma2Enc *)pp;\r
-  unsigned i;\r
-  for (i = 0; i < NUM_MT_CODER_THREADS_MAX; i++)\r
-  {\r
-    CLzma2EncInt *t = &p->coders[i];\r
-    if (t->enc)\r
-    {\r
-      LzmaEnc_Destroy(t->enc, p->alloc, p->allocBig);\r
-      t->enc = 0;\r
-    }\r
-  }\r
-\r
-  #ifndef _7ZIP_ST\r
-  MtCoder_Destruct(&p->mtCoder);\r
-  #endif\r
-\r
-  IAlloc_Free(p->alloc, p->outBuf);\r
-  IAlloc_Free(p->alloc, pp);\r
-}\r
-\r
-SRes Lzma2Enc_SetProps(CLzma2EncHandle pp, const CLzma2EncProps *props)\r
-{\r
-  CLzma2Enc *p = (CLzma2Enc *)pp;\r
-  CLzmaEncProps lzmaProps = props->lzmaProps;\r
-  LzmaEncProps_Normalize(&lzmaProps);\r
-  if (lzmaProps.lc + lzmaProps.lp > LZMA2_LCLP_MAX)\r
-    return SZ_ERROR_PARAM;\r
-  p->props = *props;\r
-  Lzma2EncProps_Normalize(&p->props);\r
-  return SZ_OK;\r
-}\r
-\r
-Byte Lzma2Enc_WriteProperties(CLzma2EncHandle pp)\r
-{\r
-  CLzma2Enc *p = (CLzma2Enc *)pp;\r
-  unsigned i;\r
-  UInt32 dicSize = LzmaEncProps_GetDictSize(&p->props.lzmaProps);\r
-  for (i = 0; i < 40; i++)\r
-    if (dicSize <= LZMA2_DIC_SIZE_FROM_PROP(i))\r
-      break;\r
-  return (Byte)i;\r
-}\r
-\r
-SRes Lzma2Enc_Encode(CLzma2EncHandle pp,\r
-    ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress)\r
-{\r
-  CLzma2Enc *p = (CLzma2Enc *)pp;\r
-  int i;\r
-\r
-  for (i = 0; i < p->props.numBlockThreads; i++)\r
-  {\r
-    CLzma2EncInt *t = &p->coders[(unsigned)i];\r
-    if (!t->enc)\r
-    {\r
-      t->enc = LzmaEnc_Create(p->alloc);\r
-      if (!t->enc)\r
-        return SZ_ERROR_MEM;\r
-    }\r
-  }\r
-\r
-  #ifndef _7ZIP_ST\r
-  if (p->props.numBlockThreads > 1)\r
-  {\r
-    CMtCallbackImp mtCallback;\r
-\r
-    mtCallback.funcTable.Code = MtCallbackImp_Code;\r
-    mtCallback.lzma2Enc = p;\r
-    \r
-    p->mtCoder.progress = progress;\r
-    p->mtCoder.inStream = inStream;\r
-    p->mtCoder.outStream = outStream;\r
-    p->mtCoder.alloc = p->alloc;\r
-    p->mtCoder.mtCallback = &mtCallback.funcTable;\r
-\r
-    p->mtCoder.blockSize = p->props.blockSize;\r
-    p->mtCoder.destBlockSize = p->props.blockSize + (p->props.blockSize >> 10) + 16;\r
-    if (p->mtCoder.destBlockSize < p->props.blockSize)\r
-    {\r
-      p->mtCoder.destBlockSize = (size_t)0 - 1;\r
-      if (p->mtCoder.destBlockSize < p->props.blockSize)\r
-        return SZ_ERROR_FAIL;\r
-    }\r
-    p->mtCoder.numThreads = p->props.numBlockThreads;\r
-    \r
-    return MtCoder_Code(&p->mtCoder);\r
-  }\r
-  #endif\r
-\r
-  return Lzma2Enc_EncodeMt1(&p->coders[0], p, outStream, inStream, progress);\r
-}\r
diff --git a/deps/lzma-16.04/C/Lzma2Enc.h b/deps/lzma-16.04/C/Lzma2Enc.h
deleted file mode 100644 (file)
index 061178a..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Lzma2Enc.h -- LZMA2 Encoder\r
-2013-01-18 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __LZMA2_ENC_H\r
-#define __LZMA2_ENC_H\r
-\r
-#include "LzmaEnc.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-typedef struct\r
-{\r
-  CLzmaEncProps lzmaProps;\r
-  size_t blockSize;\r
-  int numBlockThreads;\r
-  int numTotalThreads;\r
-} CLzma2EncProps;\r
-\r
-void Lzma2EncProps_Init(CLzma2EncProps *p);\r
-void Lzma2EncProps_Normalize(CLzma2EncProps *p);\r
-\r
-/* ---------- CLzmaEnc2Handle Interface ---------- */\r
-\r
-/* Lzma2Enc_* functions can return the following exit codes:\r
-Returns:\r
-  SZ_OK           - OK\r
-  SZ_ERROR_MEM    - Memory allocation error\r
-  SZ_ERROR_PARAM  - Incorrect paramater in props\r
-  SZ_ERROR_WRITE  - Write callback error\r
-  SZ_ERROR_PROGRESS - some break from progress callback\r
-  SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)\r
-*/\r
-\r
-typedef void * CLzma2EncHandle;\r
-\r
-CLzma2EncHandle Lzma2Enc_Create(ISzAlloc *alloc, ISzAlloc *allocBig);\r
-void Lzma2Enc_Destroy(CLzma2EncHandle p);\r
-SRes Lzma2Enc_SetProps(CLzma2EncHandle p, const CLzma2EncProps *props);\r
-Byte Lzma2Enc_WriteProperties(CLzma2EncHandle p);\r
-SRes Lzma2Enc_Encode(CLzma2EncHandle p,\r
-    ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress);\r
-\r
-/* ---------- One Call Interface ---------- */\r
-\r
-/* Lzma2Encode\r
-Return code:\r
-  SZ_OK               - OK\r
-  SZ_ERROR_MEM        - Memory allocation error\r
-  SZ_ERROR_PARAM      - Incorrect paramater\r
-  SZ_ERROR_OUTPUT_EOF - output buffer overflow\r
-  SZ_ERROR_THREAD     - errors in multithreading functions (only for Mt version)\r
-*/\r
-\r
-/*\r
-SRes Lzma2Encode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,\r
-    const CLzmaEncProps *props, Byte *propsEncoded, int writeEndMark,\r
-    ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);\r
-*/\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/Lzma86.h b/deps/lzma-16.04/C/Lzma86.h
deleted file mode 100644 (file)
index 83057e5..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/* Lzma86.h -- LZMA + x86 (BCJ) Filter\r
-2013-01-18 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __LZMA86_H\r
-#define __LZMA86_H\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-#define LZMA86_SIZE_OFFSET (1 + 5)\r
-#define LZMA86_HEADER_SIZE (LZMA86_SIZE_OFFSET + 8)\r
-\r
-/*\r
-It's an example for LZMA + x86 Filter use.\r
-You can use .lzma86 extension, if you write that stream to file.\r
-.lzma86 header adds one additional byte to standard .lzma header.\r
-.lzma86 header (14 bytes):\r
-  Offset Size  Description\r
-    0     1    = 0 - no filter, pure LZMA\r
-               = 1 - x86 filter + LZMA\r
-    1     1    lc, lp and pb in encoded form\r
-    2     4    dictSize (little endian)\r
-    6     8    uncompressed size (little endian)\r
-\r
-\r
-Lzma86_Encode\r
--------------\r
-level - compression level: 0 <= level <= 9, the default value for "level" is 5.\r
-\r
-dictSize - The dictionary size in bytes. The maximum value is\r
-        128 MB = (1 << 27) bytes for 32-bit version\r
-          1 GB = (1 << 30) bytes for 64-bit version\r
-     The default value is 16 MB = (1 << 24) bytes, for level = 5.\r
-     It's recommended to use the dictionary that is larger than 4 KB and\r
-     that can be calculated as (1 << N) or (3 << N) sizes.\r
-     For better compression ratio dictSize must be >= inSize.\r
-\r
-filterMode:\r
-    SZ_FILTER_NO   - no Filter\r
-    SZ_FILTER_YES  - x86 Filter\r
-    SZ_FILTER_AUTO - it tries both alternatives to select best.\r
-              Encoder will use 2 or 3 passes:\r
-              2 passes when FILTER_NO provides better compression.\r
-              3 passes when FILTER_YES provides better compression.\r
-\r
-Lzma86Encode allocates Data with MyAlloc functions.\r
-RAM Requirements for compressing:\r
-  RamSize = dictionarySize * 11.5 + 6MB + FilterBlockSize\r
-      filterMode     FilterBlockSize\r
-     SZ_FILTER_NO         0\r
-     SZ_FILTER_YES      inSize\r
-     SZ_FILTER_AUTO     inSize\r
-\r
-\r
-Return code:\r
-  SZ_OK               - OK\r
-  SZ_ERROR_MEM        - Memory allocation error\r
-  SZ_ERROR_PARAM      - Incorrect paramater\r
-  SZ_ERROR_OUTPUT_EOF - output buffer overflow\r
-  SZ_ERROR_THREAD     - errors in multithreading functions (only for Mt version)\r
-*/\r
-\r
-enum ESzFilterMode\r
-{\r
-  SZ_FILTER_NO,\r
-  SZ_FILTER_YES,\r
-  SZ_FILTER_AUTO\r
-};\r
-\r
-SRes Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,\r
-    int level, UInt32 dictSize, int filterMode);\r
-\r
-\r
-/*\r
-Lzma86_GetUnpackSize:\r
-  In:\r
-    src      - input data\r
-    srcLen   - input data size\r
-  Out:\r
-    unpackSize - size of uncompressed stream\r
-  Return code:\r
-    SZ_OK               - OK\r
-    SZ_ERROR_INPUT_EOF  - Error in headers\r
-*/\r
-\r
-SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize);\r
-\r
-/*\r
-Lzma86_Decode:\r
-  In:\r
-    dest     - output data\r
-    destLen  - output data size\r
-    src      - input data\r
-    srcLen   - input data size\r
-  Out:\r
-    destLen  - processed output size\r
-    srcLen   - processed input size\r
-  Return code:\r
-    SZ_OK           - OK\r
-    SZ_ERROR_DATA  - Data error\r
-    SZ_ERROR_MEM   - Memory allocation error\r
-    SZ_ERROR_UNSUPPORTED - unsupported file\r
-    SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer\r
-*/\r
-\r
-SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen);\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/Lzma86Dec.c b/deps/lzma-16.04/C/Lzma86Dec.c
deleted file mode 100644 (file)
index 20ac5e7..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Lzma86Dec.c -- LZMA + x86 (BCJ) Filter Decoder\r
-2016-05-16 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "Lzma86.h"\r
-\r
-#include "Alloc.h"\r
-#include "Bra.h"\r
-#include "LzmaDec.h"\r
-\r
-SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize)\r
-{\r
-  unsigned i;\r
-  if (srcLen < LZMA86_HEADER_SIZE)\r
-    return SZ_ERROR_INPUT_EOF;\r
-  *unpackSize = 0;\r
-  for (i = 0; i < sizeof(UInt64); i++)\r
-    *unpackSize += ((UInt64)src[LZMA86_SIZE_OFFSET + i]) << (8 * i);\r
-  return SZ_OK;\r
-}\r
-\r
-SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen)\r
-{\r
-  SRes res;\r
-  int useFilter;\r
-  SizeT inSizePure;\r
-  ELzmaStatus status;\r
-\r
-  if (*srcLen < LZMA86_HEADER_SIZE)\r
-    return SZ_ERROR_INPUT_EOF;\r
-\r
-  useFilter = src[0];\r
-\r
-  if (useFilter > 1)\r
-  {\r
-    *destLen = 0;\r
-    return SZ_ERROR_UNSUPPORTED;\r
-  }\r
-\r
-  inSizePure = *srcLen - LZMA86_HEADER_SIZE;\r
-  res = LzmaDecode(dest, destLen, src + LZMA86_HEADER_SIZE, &inSizePure,\r
-      src + 1, LZMA_PROPS_SIZE, LZMA_FINISH_ANY, &status, &g_Alloc);\r
-  *srcLen = inSizePure + LZMA86_HEADER_SIZE;\r
-  if (res != SZ_OK)\r
-    return res;\r
-  if (useFilter == 1)\r
-  {\r
-    UInt32 x86State;\r
-    x86_Convert_Init(x86State);\r
-    x86_Convert(dest, *destLen, 0, &x86State, 0);\r
-  }\r
-  return SZ_OK;\r
-}\r
diff --git a/deps/lzma-16.04/C/Lzma86Enc.c b/deps/lzma-16.04/C/Lzma86Enc.c
deleted file mode 100644 (file)
index ee59fb7..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/* Lzma86Enc.c -- LZMA + x86 (BCJ) Filter Encoder\r
-2016-05-16 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include <string.h>\r
-\r
-#include "Lzma86.h"\r
-\r
-#include "Alloc.h"\r
-#include "Bra.h"\r
-#include "LzmaEnc.h"\r
-\r
-#define SZE_OUT_OVERFLOW SZE_DATA_ERROR\r
-\r
-int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,\r
-    int level, UInt32 dictSize, int filterMode)\r
-{\r
-  size_t outSize2 = *destLen;\r
-  Byte *filteredStream;\r
-  Bool useFilter;\r
-  int mainResult = SZ_ERROR_OUTPUT_EOF;\r
-  CLzmaEncProps props;\r
-  LzmaEncProps_Init(&props);\r
-  props.level = level;\r
-  props.dictSize = dictSize;\r
-  \r
-  *destLen = 0;\r
-  if (outSize2 < LZMA86_HEADER_SIZE)\r
-    return SZ_ERROR_OUTPUT_EOF;\r
-\r
-  {\r
-    int i;\r
-    UInt64 t = srcLen;\r
-    for (i = 0; i < 8; i++, t >>= 8)\r
-      dest[LZMA86_SIZE_OFFSET + i] = (Byte)t;\r
-  }\r
-\r
-  filteredStream = 0;\r
-  useFilter = (filterMode != SZ_FILTER_NO);\r
-  if (useFilter)\r
-  {\r
-    if (srcLen != 0)\r
-    {\r
-      filteredStream = (Byte *)MyAlloc(srcLen);\r
-      if (filteredStream == 0)\r
-        return SZ_ERROR_MEM;\r
-      memcpy(filteredStream, src, srcLen);\r
-    }\r
-    {\r
-      UInt32 x86State;\r
-      x86_Convert_Init(x86State);\r
-      x86_Convert(filteredStream, srcLen, 0, &x86State, 1);\r
-    }\r
-  }\r
-\r
-  {\r
-    size_t minSize = 0;\r
-    Bool bestIsFiltered = False;\r
-\r
-    /* passes for SZ_FILTER_AUTO:\r
-        0 - BCJ + LZMA\r
-        1 - LZMA\r
-        2 - BCJ + LZMA agaian, if pass 0 (BCJ + LZMA) is better.\r
-    */\r
-    int numPasses = (filterMode == SZ_FILTER_AUTO) ? 3 : 1;\r
-\r
-    int i;\r
-    for (i = 0; i < numPasses; i++)\r
-    {\r
-      size_t outSizeProcessed = outSize2 - LZMA86_HEADER_SIZE;\r
-      size_t outPropsSize = 5;\r
-      SRes curRes;\r
-      Bool curModeIsFiltered = (numPasses > 1 && i == numPasses - 1);\r
-      if (curModeIsFiltered && !bestIsFiltered)\r
-        break;\r
-      if (useFilter && i == 0)\r
-        curModeIsFiltered = True;\r
-      \r
-      curRes = LzmaEncode(dest + LZMA86_HEADER_SIZE, &outSizeProcessed,\r
-          curModeIsFiltered ? filteredStream : src, srcLen,\r
-          &props, dest + 1, &outPropsSize, 0,\r
-          NULL, &g_Alloc, &g_Alloc);\r
-      \r
-      if (curRes != SZ_ERROR_OUTPUT_EOF)\r
-      {\r
-        if (curRes != SZ_OK)\r
-        {\r
-          mainResult = curRes;\r
-          break;\r
-        }\r
-        if (outSizeProcessed <= minSize || mainResult != SZ_OK)\r
-        {\r
-          minSize = outSizeProcessed;\r
-          bestIsFiltered = curModeIsFiltered;\r
-          mainResult = SZ_OK;\r
-        }\r
-      }\r
-    }\r
-    dest[0] = (Byte)(bestIsFiltered ? 1 : 0);\r
-    *destLen = LZMA86_HEADER_SIZE + minSize;\r
-  }\r
-  if (useFilter)\r
-    MyFree(filteredStream);\r
-  return mainResult;\r
-}\r
diff --git a/deps/lzma-16.04/C/LzmaDec.c b/deps/lzma-16.04/C/LzmaDec.c
deleted file mode 100644 (file)
index 64f1164..0000000
+++ /dev/null
@@ -1,1100 +0,0 @@
-/* LzmaDec.c -- LZMA Decoder\r
-2016-05-16 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "LzmaDec.h"\r
-\r
-#include <string.h>\r
-\r
-#define kNumTopBits 24\r
-#define kTopValue ((UInt32)1 << kNumTopBits)\r
-\r
-#define kNumBitModelTotalBits 11\r
-#define kBitModelTotal (1 << kNumBitModelTotalBits)\r
-#define kNumMoveBits 5\r
-\r
-#define RC_INIT_SIZE 5\r
-\r
-#define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); }\r
-\r
-#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)\r
-#define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits));\r
-#define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits));\r
-#define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \\r
-  { UPDATE_0(p); i = (i + i); A0; } else \\r
-  { UPDATE_1(p); i = (i + i) + 1; A1; }\r
-#define GET_BIT(p, i) GET_BIT2(p, i, ; , ;)\r
-\r
-#define TREE_GET_BIT(probs, i) { GET_BIT((probs + i), i); }\r
-#define TREE_DECODE(probs, limit, i) \\r
-  { i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; }\r
-\r
-/* #define _LZMA_SIZE_OPT */\r
-\r
-#ifdef _LZMA_SIZE_OPT\r
-#define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i)\r
-#else\r
-#define TREE_6_DECODE(probs, i) \\r
-  { i = 1; \\r
-  TREE_GET_BIT(probs, i); \\r
-  TREE_GET_BIT(probs, i); \\r
-  TREE_GET_BIT(probs, i); \\r
-  TREE_GET_BIT(probs, i); \\r
-  TREE_GET_BIT(probs, i); \\r
-  TREE_GET_BIT(probs, i); \\r
-  i -= 0x40; }\r
-#endif\r
-\r
-#define NORMAL_LITER_DEC GET_BIT(prob + symbol, symbol)\r
-#define MATCHED_LITER_DEC \\r
-  matchByte <<= 1; \\r
-  bit = (matchByte & offs); \\r
-  probLit = prob + offs + bit + symbol; \\r
-  GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit)\r
-\r
-#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); }\r
-\r
-#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)\r
-#define UPDATE_0_CHECK range = bound;\r
-#define UPDATE_1_CHECK range -= bound; code -= bound;\r
-#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \\r
-  { UPDATE_0_CHECK; i = (i + i); A0; } else \\r
-  { UPDATE_1_CHECK; i = (i + i) + 1; A1; }\r
-#define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;)\r
-#define TREE_DECODE_CHECK(probs, limit, i) \\r
-  { i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; }\r
-\r
-\r
-#define kNumPosBitsMax 4\r
-#define kNumPosStatesMax (1 << kNumPosBitsMax)\r
-\r
-#define kLenNumLowBits 3\r
-#define kLenNumLowSymbols (1 << kLenNumLowBits)\r
-#define kLenNumMidBits 3\r
-#define kLenNumMidSymbols (1 << kLenNumMidBits)\r
-#define kLenNumHighBits 8\r
-#define kLenNumHighSymbols (1 << kLenNumHighBits)\r
-\r
-#define LenChoice 0\r
-#define LenChoice2 (LenChoice + 1)\r
-#define LenLow (LenChoice2 + 1)\r
-#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))\r
-#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))\r
-#define kNumLenProbs (LenHigh + kLenNumHighSymbols)\r
-\r
-\r
-#define kNumStates 12\r
-#define kNumLitStates 7\r
-\r
-#define kStartPosModelIndex 4\r
-#define kEndPosModelIndex 14\r
-#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))\r
-\r
-#define kNumPosSlotBits 6\r
-#define kNumLenToPosStates 4\r
-\r
-#define kNumAlignBits 4\r
-#define kAlignTableSize (1 << kNumAlignBits)\r
-\r
-#define kMatchMinLen 2\r
-#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols)\r
-\r
-#define IsMatch 0\r
-#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))\r
-#define IsRepG0 (IsRep + kNumStates)\r
-#define IsRepG1 (IsRepG0 + kNumStates)\r
-#define IsRepG2 (IsRepG1 + kNumStates)\r
-#define IsRep0Long (IsRepG2 + kNumStates)\r
-#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))\r
-#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))\r
-#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)\r
-#define LenCoder (Align + kAlignTableSize)\r
-#define RepLenCoder (LenCoder + kNumLenProbs)\r
-#define Literal (RepLenCoder + kNumLenProbs)\r
-\r
-#define LZMA_BASE_SIZE 1846\r
-#define LZMA_LIT_SIZE 0x300\r
-\r
-#if Literal != LZMA_BASE_SIZE\r
-StopCompilingDueBUG\r
-#endif\r
-\r
-#define LzmaProps_GetNumProbs(p) (Literal + ((UInt32)LZMA_LIT_SIZE << ((p)->lc + (p)->lp)))\r
-\r
-#define LZMA_DIC_MIN (1 << 12)\r
-\r
-/* First LZMA-symbol is always decoded.\r
-And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization\r
-Out:\r
-  Result:\r
-    SZ_OK - OK\r
-    SZ_ERROR_DATA - Error\r
-  p->remainLen:\r
-    < kMatchSpecLenStart : normal remain\r
-    = kMatchSpecLenStart : finished\r
-    = kMatchSpecLenStart + 1 : Flush marker (unused now)\r
-    = kMatchSpecLenStart + 2 : State Init Marker (unused now)\r
-*/\r
-\r
-static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte *bufLimit)\r
-{\r
-  CLzmaProb *probs = p->probs;\r
-\r
-  unsigned state = p->state;\r
-  UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3];\r
-  unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1;\r
-  unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1;\r
-  unsigned lc = p->prop.lc;\r
-\r
-  Byte *dic = p->dic;\r
-  SizeT dicBufSize = p->dicBufSize;\r
-  SizeT dicPos = p->dicPos;\r
-  \r
-  UInt32 processedPos = p->processedPos;\r
-  UInt32 checkDicSize = p->checkDicSize;\r
-  unsigned len = 0;\r
-\r
-  const Byte *buf = p->buf;\r
-  UInt32 range = p->range;\r
-  UInt32 code = p->code;\r
-\r
-  do\r
-  {\r
-    CLzmaProb *prob;\r
-    UInt32 bound;\r
-    unsigned ttt;\r
-    unsigned posState = processedPos & pbMask;\r
-\r
-    prob = probs + IsMatch + (state << kNumPosBitsMax) + posState;\r
-    IF_BIT_0(prob)\r
-    {\r
-      unsigned symbol;\r
-      UPDATE_0(prob);\r
-      prob = probs + Literal;\r
-      if (processedPos != 0 || checkDicSize != 0)\r
-        prob += ((UInt32)LZMA_LIT_SIZE * (((processedPos & lpMask) << lc) +\r
-            (dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc))));\r
-      processedPos++;\r
-\r
-      if (state < kNumLitStates)\r
-      {\r
-        state -= (state < 4) ? state : 3;\r
-        symbol = 1;\r
-        #ifdef _LZMA_SIZE_OPT\r
-        do { NORMAL_LITER_DEC } while (symbol < 0x100);\r
-        #else\r
-        NORMAL_LITER_DEC\r
-        NORMAL_LITER_DEC\r
-        NORMAL_LITER_DEC\r
-        NORMAL_LITER_DEC\r
-        NORMAL_LITER_DEC\r
-        NORMAL_LITER_DEC\r
-        NORMAL_LITER_DEC\r
-        NORMAL_LITER_DEC\r
-        #endif\r
-      }\r
-      else\r
-      {\r
-        unsigned matchByte = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)];\r
-        unsigned offs = 0x100;\r
-        state -= (state < 10) ? 3 : 6;\r
-        symbol = 1;\r
-        #ifdef _LZMA_SIZE_OPT\r
-        do\r
-        {\r
-          unsigned bit;\r
-          CLzmaProb *probLit;\r
-          MATCHED_LITER_DEC\r
-        }\r
-        while (symbol < 0x100);\r
-        #else\r
-        {\r
-          unsigned bit;\r
-          CLzmaProb *probLit;\r
-          MATCHED_LITER_DEC\r
-          MATCHED_LITER_DEC\r
-          MATCHED_LITER_DEC\r
-          MATCHED_LITER_DEC\r
-          MATCHED_LITER_DEC\r
-          MATCHED_LITER_DEC\r
-          MATCHED_LITER_DEC\r
-          MATCHED_LITER_DEC\r
-        }\r
-        #endif\r
-      }\r
-\r
-      dic[dicPos++] = (Byte)symbol;\r
-      continue;\r
-    }\r
-    \r
-    {\r
-      UPDATE_1(prob);\r
-      prob = probs + IsRep + state;\r
-      IF_BIT_0(prob)\r
-      {\r
-        UPDATE_0(prob);\r
-        state += kNumStates;\r
-        prob = probs + LenCoder;\r
-      }\r
-      else\r
-      {\r
-        UPDATE_1(prob);\r
-        if (checkDicSize == 0 && processedPos == 0)\r
-          return SZ_ERROR_DATA;\r
-        prob = probs + IsRepG0 + state;\r
-        IF_BIT_0(prob)\r
-        {\r
-          UPDATE_0(prob);\r
-          prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState;\r
-          IF_BIT_0(prob)\r
-          {\r
-            UPDATE_0(prob);\r
-            dic[dicPos] = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)];\r
-            dicPos++;\r
-            processedPos++;\r
-            state = state < kNumLitStates ? 9 : 11;\r
-            continue;\r
-          }\r
-          UPDATE_1(prob);\r
-        }\r
-        else\r
-        {\r
-          UInt32 distance;\r
-          UPDATE_1(prob);\r
-          prob = probs + IsRepG1 + state;\r
-          IF_BIT_0(prob)\r
-          {\r
-            UPDATE_0(prob);\r
-            distance = rep1;\r
-          }\r
-          else\r
-          {\r
-            UPDATE_1(prob);\r
-            prob = probs + IsRepG2 + state;\r
-            IF_BIT_0(prob)\r
-            {\r
-              UPDATE_0(prob);\r
-              distance = rep2;\r
-            }\r
-            else\r
-            {\r
-              UPDATE_1(prob);\r
-              distance = rep3;\r
-              rep3 = rep2;\r
-            }\r
-            rep2 = rep1;\r
-          }\r
-          rep1 = rep0;\r
-          rep0 = distance;\r
-        }\r
-        state = state < kNumLitStates ? 8 : 11;\r
-        prob = probs + RepLenCoder;\r
-      }\r
-      \r
-      #ifdef _LZMA_SIZE_OPT\r
-      {\r
-        unsigned lim, offset;\r
-        CLzmaProb *probLen = prob + LenChoice;\r
-        IF_BIT_0(probLen)\r
-        {\r
-          UPDATE_0(probLen);\r
-          probLen = prob + LenLow + (posState << kLenNumLowBits);\r
-          offset = 0;\r
-          lim = (1 << kLenNumLowBits);\r
-        }\r
-        else\r
-        {\r
-          UPDATE_1(probLen);\r
-          probLen = prob + LenChoice2;\r
-          IF_BIT_0(probLen)\r
-          {\r
-            UPDATE_0(probLen);\r
-            probLen = prob + LenMid + (posState << kLenNumMidBits);\r
-            offset = kLenNumLowSymbols;\r
-            lim = (1 << kLenNumMidBits);\r
-          }\r
-          else\r
-          {\r
-            UPDATE_1(probLen);\r
-            probLen = prob + LenHigh;\r
-            offset = kLenNumLowSymbols + kLenNumMidSymbols;\r
-            lim = (1 << kLenNumHighBits);\r
-          }\r
-        }\r
-        TREE_DECODE(probLen, lim, len);\r
-        len += offset;\r
-      }\r
-      #else\r
-      {\r
-        CLzmaProb *probLen = prob + LenChoice;\r
-        IF_BIT_0(probLen)\r
-        {\r
-          UPDATE_0(probLen);\r
-          probLen = prob + LenLow + (posState << kLenNumLowBits);\r
-          len = 1;\r
-          TREE_GET_BIT(probLen, len);\r
-          TREE_GET_BIT(probLen, len);\r
-          TREE_GET_BIT(probLen, len);\r
-          len -= 8;\r
-        }\r
-        else\r
-        {\r
-          UPDATE_1(probLen);\r
-          probLen = prob + LenChoice2;\r
-          IF_BIT_0(probLen)\r
-          {\r
-            UPDATE_0(probLen);\r
-            probLen = prob + LenMid + (posState << kLenNumMidBits);\r
-            len = 1;\r
-            TREE_GET_BIT(probLen, len);\r
-            TREE_GET_BIT(probLen, len);\r
-            TREE_GET_BIT(probLen, len);\r
-          }\r
-          else\r
-          {\r
-            UPDATE_1(probLen);\r
-            probLen = prob + LenHigh;\r
-            TREE_DECODE(probLen, (1 << kLenNumHighBits), len);\r
-            len += kLenNumLowSymbols + kLenNumMidSymbols;\r
-          }\r
-        }\r
-      }\r
-      #endif\r
-\r
-      if (state >= kNumStates)\r
-      {\r
-        UInt32 distance;\r
-        prob = probs + PosSlot +\r
-            ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits);\r
-        TREE_6_DECODE(prob, distance);\r
-        if (distance >= kStartPosModelIndex)\r
-        {\r
-          unsigned posSlot = (unsigned)distance;\r
-          unsigned numDirectBits = (unsigned)(((distance >> 1) - 1));\r
-          distance = (2 | (distance & 1));\r
-          if (posSlot < kEndPosModelIndex)\r
-          {\r
-            distance <<= numDirectBits;\r
-            prob = probs + SpecPos + distance - posSlot - 1;\r
-            {\r
-              UInt32 mask = 1;\r
-              unsigned i = 1;\r
-              do\r
-              {\r
-                GET_BIT2(prob + i, i, ; , distance |= mask);\r
-                mask <<= 1;\r
-              }\r
-              while (--numDirectBits != 0);\r
-            }\r
-          }\r
-          else\r
-          {\r
-            numDirectBits -= kNumAlignBits;\r
-            do\r
-            {\r
-              NORMALIZE\r
-              range >>= 1;\r
-              \r
-              {\r
-                UInt32 t;\r
-                code -= range;\r
-                t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */\r
-                distance = (distance << 1) + (t + 1);\r
-                code += range & t;\r
-              }\r
-              /*\r
-              distance <<= 1;\r
-              if (code >= range)\r
-              {\r
-                code -= range;\r
-                distance |= 1;\r
-              }\r
-              */\r
-            }\r
-            while (--numDirectBits != 0);\r
-            prob = probs + Align;\r
-            distance <<= kNumAlignBits;\r
-            {\r
-              unsigned i = 1;\r
-              GET_BIT2(prob + i, i, ; , distance |= 1);\r
-              GET_BIT2(prob + i, i, ; , distance |= 2);\r
-              GET_BIT2(prob + i, i, ; , distance |= 4);\r
-              GET_BIT2(prob + i, i, ; , distance |= 8);\r
-            }\r
-            if (distance == (UInt32)0xFFFFFFFF)\r
-            {\r
-              len += kMatchSpecLenStart;\r
-              state -= kNumStates;\r
-              break;\r
-            }\r
-          }\r
-        }\r
-        \r
-        rep3 = rep2;\r
-        rep2 = rep1;\r
-        rep1 = rep0;\r
-        rep0 = distance + 1;\r
-        if (checkDicSize == 0)\r
-        {\r
-          if (distance >= processedPos)\r
-          {\r
-            p->dicPos = dicPos;\r
-            return SZ_ERROR_DATA;\r
-          }\r
-        }\r
-        else if (distance >= checkDicSize)\r
-        {\r
-          p->dicPos = dicPos;\r
-          return SZ_ERROR_DATA;\r
-        }\r
-        state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3;\r
-      }\r
-\r
-      len += kMatchMinLen;\r
-\r
-      {\r
-        SizeT rem;\r
-        unsigned curLen;\r
-        SizeT pos;\r
-        \r
-        if ((rem = limit - dicPos) == 0)\r
-        {\r
-          p->dicPos = dicPos;\r
-          return SZ_ERROR_DATA;\r
-        }\r
-        \r
-        curLen = ((rem < len) ? (unsigned)rem : len);\r
-        pos = dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0);\r
-\r
-        processedPos += curLen;\r
-\r
-        len -= curLen;\r
-        if (curLen <= dicBufSize - pos)\r
-        {\r
-          Byte *dest = dic + dicPos;\r
-          ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos;\r
-          const Byte *lim = dest + curLen;\r
-          dicPos += curLen;\r
-          do\r
-            *(dest) = (Byte)*(dest + src);\r
-          while (++dest != lim);\r
-        }\r
-        else\r
-        {\r
-          do\r
-          {\r
-            dic[dicPos++] = dic[pos];\r
-            if (++pos == dicBufSize)\r
-              pos = 0;\r
-          }\r
-          while (--curLen != 0);\r
-        }\r
-      }\r
-    }\r
-  }\r
-  while (dicPos < limit && buf < bufLimit);\r
-\r
-  NORMALIZE;\r
-  \r
-  p->buf = buf;\r
-  p->range = range;\r
-  p->code = code;\r
-  p->remainLen = len;\r
-  p->dicPos = dicPos;\r
-  p->processedPos = processedPos;\r
-  p->reps[0] = rep0;\r
-  p->reps[1] = rep1;\r
-  p->reps[2] = rep2;\r
-  p->reps[3] = rep3;\r
-  p->state = state;\r
-\r
-  return SZ_OK;\r
-}\r
-\r
-static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)\r
-{\r
-  if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart)\r
-  {\r
-    Byte *dic = p->dic;\r
-    SizeT dicPos = p->dicPos;\r
-    SizeT dicBufSize = p->dicBufSize;\r
-    unsigned len = p->remainLen;\r
-    SizeT rep0 = p->reps[0]; /* we use SizeT to avoid the BUG of VC14 for AMD64 */\r
-    SizeT rem = limit - dicPos;\r
-    if (rem < len)\r
-      len = (unsigned)(rem);\r
-\r
-    if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len)\r
-      p->checkDicSize = p->prop.dicSize;\r
-\r
-    p->processedPos += len;\r
-    p->remainLen -= len;\r
-    while (len != 0)\r
-    {\r
-      len--;\r
-      dic[dicPos] = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)];\r
-      dicPos++;\r
-    }\r
-    p->dicPos = dicPos;\r
-  }\r
-}\r
-\r
-static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit)\r
-{\r
-  do\r
-  {\r
-    SizeT limit2 = limit;\r
-    if (p->checkDicSize == 0)\r
-    {\r
-      UInt32 rem = p->prop.dicSize - p->processedPos;\r
-      if (limit - p->dicPos > rem)\r
-        limit2 = p->dicPos + rem;\r
-    }\r
-    \r
-    RINOK(LzmaDec_DecodeReal(p, limit2, bufLimit));\r
-    \r
-    if (p->checkDicSize == 0 && p->processedPos >= p->prop.dicSize)\r
-      p->checkDicSize = p->prop.dicSize;\r
-    \r
-    LzmaDec_WriteRem(p, limit);\r
-  }\r
-  while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart);\r
-\r
-  if (p->remainLen > kMatchSpecLenStart)\r
-    p->remainLen = kMatchSpecLenStart;\r
-\r
-  return 0;\r
-}\r
-\r
-typedef enum\r
-{\r
-  DUMMY_ERROR, /* unexpected end of input stream */\r
-  DUMMY_LIT,\r
-  DUMMY_MATCH,\r
-  DUMMY_REP\r
-} ELzmaDummy;\r
-\r
-static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inSize)\r
-{\r
-  UInt32 range = p->range;\r
-  UInt32 code = p->code;\r
-  const Byte *bufLimit = buf + inSize;\r
-  const CLzmaProb *probs = p->probs;\r
-  unsigned state = p->state;\r
-  ELzmaDummy res;\r
-\r
-  {\r
-    const CLzmaProb *prob;\r
-    UInt32 bound;\r
-    unsigned ttt;\r
-    unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1);\r
-\r
-    prob = probs + IsMatch + (state << kNumPosBitsMax) + posState;\r
-    IF_BIT_0_CHECK(prob)\r
-    {\r
-      UPDATE_0_CHECK\r
-\r
-      /* if (bufLimit - buf >= 7) return DUMMY_LIT; */\r
-\r
-      prob = probs + Literal;\r
-      if (p->checkDicSize != 0 || p->processedPos != 0)\r
-        prob += ((UInt32)LZMA_LIT_SIZE *\r
-            ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) +\r
-            (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc))));\r
-\r
-      if (state < kNumLitStates)\r
-      {\r
-        unsigned symbol = 1;\r
-        do { GET_BIT_CHECK(prob + symbol, symbol) } while (symbol < 0x100);\r
-      }\r
-      else\r
-      {\r
-        unsigned matchByte = p->dic[p->dicPos - p->reps[0] +\r
-            (p->dicPos < p->reps[0] ? p->dicBufSize : 0)];\r
-        unsigned offs = 0x100;\r
-        unsigned symbol = 1;\r
-        do\r
-        {\r
-          unsigned bit;\r
-          const CLzmaProb *probLit;\r
-          matchByte <<= 1;\r
-          bit = (matchByte & offs);\r
-          probLit = prob + offs + bit + symbol;\r
-          GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit)\r
-        }\r
-        while (symbol < 0x100);\r
-      }\r
-      res = DUMMY_LIT;\r
-    }\r
-    else\r
-    {\r
-      unsigned len;\r
-      UPDATE_1_CHECK;\r
-\r
-      prob = probs + IsRep + state;\r
-      IF_BIT_0_CHECK(prob)\r
-      {\r
-        UPDATE_0_CHECK;\r
-        state = 0;\r
-        prob = probs + LenCoder;\r
-        res = DUMMY_MATCH;\r
-      }\r
-      else\r
-      {\r
-        UPDATE_1_CHECK;\r
-        res = DUMMY_REP;\r
-        prob = probs + IsRepG0 + state;\r
-        IF_BIT_0_CHECK(prob)\r
-        {\r
-          UPDATE_0_CHECK;\r
-          prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState;\r
-          IF_BIT_0_CHECK(prob)\r
-          {\r
-            UPDATE_0_CHECK;\r
-            NORMALIZE_CHECK;\r
-            return DUMMY_REP;\r
-          }\r
-          else\r
-          {\r
-            UPDATE_1_CHECK;\r
-          }\r
-        }\r
-        else\r
-        {\r
-          UPDATE_1_CHECK;\r
-          prob = probs + IsRepG1 + state;\r
-          IF_BIT_0_CHECK(prob)\r
-          {\r
-            UPDATE_0_CHECK;\r
-          }\r
-          else\r
-          {\r
-            UPDATE_1_CHECK;\r
-            prob = probs + IsRepG2 + state;\r
-            IF_BIT_0_CHECK(prob)\r
-            {\r
-              UPDATE_0_CHECK;\r
-            }\r
-            else\r
-            {\r
-              UPDATE_1_CHECK;\r
-            }\r
-          }\r
-        }\r
-        state = kNumStates;\r
-        prob = probs + RepLenCoder;\r
-      }\r
-      {\r
-        unsigned limit, offset;\r
-        const CLzmaProb *probLen = prob + LenChoice;\r
-        IF_BIT_0_CHECK(probLen)\r
-        {\r
-          UPDATE_0_CHECK;\r
-          probLen = prob + LenLow + (posState << kLenNumLowBits);\r
-          offset = 0;\r
-          limit = 1 << kLenNumLowBits;\r
-        }\r
-        else\r
-        {\r
-          UPDATE_1_CHECK;\r
-          probLen = prob + LenChoice2;\r
-          IF_BIT_0_CHECK(probLen)\r
-          {\r
-            UPDATE_0_CHECK;\r
-            probLen = prob + LenMid + (posState << kLenNumMidBits);\r
-            offset = kLenNumLowSymbols;\r
-            limit = 1 << kLenNumMidBits;\r
-          }\r
-          else\r
-          {\r
-            UPDATE_1_CHECK;\r
-            probLen = prob + LenHigh;\r
-            offset = kLenNumLowSymbols + kLenNumMidSymbols;\r
-            limit = 1 << kLenNumHighBits;\r
-          }\r
-        }\r
-        TREE_DECODE_CHECK(probLen, limit, len);\r
-        len += offset;\r
-      }\r
-\r
-      if (state < 4)\r
-      {\r
-        unsigned posSlot;\r
-        prob = probs + PosSlot +\r
-            ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<\r
-            kNumPosSlotBits);\r
-        TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot);\r
-        if (posSlot >= kStartPosModelIndex)\r
-        {\r
-          unsigned numDirectBits = ((posSlot >> 1) - 1);\r
-\r
-          /* if (bufLimit - buf >= 8) return DUMMY_MATCH; */\r
-\r
-          if (posSlot < kEndPosModelIndex)\r
-          {\r
-            prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits) - posSlot - 1;\r
-          }\r
-          else\r
-          {\r
-            numDirectBits -= kNumAlignBits;\r
-            do\r
-            {\r
-              NORMALIZE_CHECK\r
-              range >>= 1;\r
-              code -= range & (((code - range) >> 31) - 1);\r
-              /* if (code >= range) code -= range; */\r
-            }\r
-            while (--numDirectBits != 0);\r
-            prob = probs + Align;\r
-            numDirectBits = kNumAlignBits;\r
-          }\r
-          {\r
-            unsigned i = 1;\r
-            do\r
-            {\r
-              GET_BIT_CHECK(prob + i, i);\r
-            }\r
-            while (--numDirectBits != 0);\r
-          }\r
-        }\r
-      }\r
-    }\r
-  }\r
-  NORMALIZE_CHECK;\r
-  return res;\r
-}\r
-\r
-\r
-void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)\r
-{\r
-  p->needFlush = 1;\r
-  p->remainLen = 0;\r
-  p->tempBufSize = 0;\r
-\r
-  if (initDic)\r
-  {\r
-    p->processedPos = 0;\r
-    p->checkDicSize = 0;\r
-    p->needInitState = 1;\r
-  }\r
-  if (initState)\r
-    p->needInitState = 1;\r
-}\r
-\r
-void LzmaDec_Init(CLzmaDec *p)\r
-{\r
-  p->dicPos = 0;\r
-  LzmaDec_InitDicAndState(p, True, True);\r
-}\r
-\r
-static void LzmaDec_InitStateReal(CLzmaDec *p)\r
-{\r
-  SizeT numProbs = LzmaProps_GetNumProbs(&p->prop);\r
-  SizeT i;\r
-  CLzmaProb *probs = p->probs;\r
-  for (i = 0; i < numProbs; i++)\r
-    probs[i] = kBitModelTotal >> 1;\r
-  p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1;\r
-  p->state = 0;\r
-  p->needInitState = 0;\r
-}\r
-\r
-SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen,\r
-    ELzmaFinishMode finishMode, ELzmaStatus *status)\r
-{\r
-  SizeT inSize = *srcLen;\r
-  (*srcLen) = 0;\r
-  LzmaDec_WriteRem(p, dicLimit);\r
-  \r
-  *status = LZMA_STATUS_NOT_SPECIFIED;\r
-\r
-  while (p->remainLen != kMatchSpecLenStart)\r
-  {\r
-      int checkEndMarkNow;\r
-\r
-      if (p->needFlush)\r
-      {\r
-        for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--)\r
-          p->tempBuf[p->tempBufSize++] = *src++;\r
-        if (p->tempBufSize < RC_INIT_SIZE)\r
-        {\r
-          *status = LZMA_STATUS_NEEDS_MORE_INPUT;\r
-          return SZ_OK;\r
-        }\r
-        if (p->tempBuf[0] != 0)\r
-          return SZ_ERROR_DATA;\r
-        p->code =\r
-              ((UInt32)p->tempBuf[1] << 24)\r
-            | ((UInt32)p->tempBuf[2] << 16)\r
-            | ((UInt32)p->tempBuf[3] << 8)\r
-            | ((UInt32)p->tempBuf[4]);\r
-        p->range = 0xFFFFFFFF;\r
-        p->needFlush = 0;\r
-        p->tempBufSize = 0;\r
-      }\r
-\r
-      checkEndMarkNow = 0;\r
-      if (p->dicPos >= dicLimit)\r
-      {\r
-        if (p->remainLen == 0 && p->code == 0)\r
-        {\r
-          *status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK;\r
-          return SZ_OK;\r
-        }\r
-        if (finishMode == LZMA_FINISH_ANY)\r
-        {\r
-          *status = LZMA_STATUS_NOT_FINISHED;\r
-          return SZ_OK;\r
-        }\r
-        if (p->remainLen != 0)\r
-        {\r
-          *status = LZMA_STATUS_NOT_FINISHED;\r
-          return SZ_ERROR_DATA;\r
-        }\r
-        checkEndMarkNow = 1;\r
-      }\r
-\r
-      if (p->needInitState)\r
-        LzmaDec_InitStateReal(p);\r
-  \r
-      if (p->tempBufSize == 0)\r
-      {\r
-        SizeT processed;\r
-        const Byte *bufLimit;\r
-        if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)\r
-        {\r
-          int dummyRes = LzmaDec_TryDummy(p, src, inSize);\r
-          if (dummyRes == DUMMY_ERROR)\r
-          {\r
-            memcpy(p->tempBuf, src, inSize);\r
-            p->tempBufSize = (unsigned)inSize;\r
-            (*srcLen) += inSize;\r
-            *status = LZMA_STATUS_NEEDS_MORE_INPUT;\r
-            return SZ_OK;\r
-          }\r
-          if (checkEndMarkNow && dummyRes != DUMMY_MATCH)\r
-          {\r
-            *status = LZMA_STATUS_NOT_FINISHED;\r
-            return SZ_ERROR_DATA;\r
-          }\r
-          bufLimit = src;\r
-        }\r
-        else\r
-          bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX;\r
-        p->buf = src;\r
-        if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0)\r
-          return SZ_ERROR_DATA;\r
-        processed = (SizeT)(p->buf - src);\r
-        (*srcLen) += processed;\r
-        src += processed;\r
-        inSize -= processed;\r
-      }\r
-      else\r
-      {\r
-        unsigned rem = p->tempBufSize, lookAhead = 0;\r
-        while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize)\r
-          p->tempBuf[rem++] = src[lookAhead++];\r
-        p->tempBufSize = rem;\r
-        if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)\r
-        {\r
-          int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem);\r
-          if (dummyRes == DUMMY_ERROR)\r
-          {\r
-            (*srcLen) += lookAhead;\r
-            *status = LZMA_STATUS_NEEDS_MORE_INPUT;\r
-            return SZ_OK;\r
-          }\r
-          if (checkEndMarkNow && dummyRes != DUMMY_MATCH)\r
-          {\r
-            *status = LZMA_STATUS_NOT_FINISHED;\r
-            return SZ_ERROR_DATA;\r
-          }\r
-        }\r
-        p->buf = p->tempBuf;\r
-        if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0)\r
-          return SZ_ERROR_DATA;\r
-        \r
-        {\r
-          unsigned kkk = (unsigned)(p->buf - p->tempBuf);\r
-          if (rem < kkk)\r
-            return SZ_ERROR_FAIL; /* some internal error */\r
-          rem -= kkk;\r
-          if (lookAhead < rem)\r
-            return SZ_ERROR_FAIL; /* some internal error */\r
-          lookAhead -= rem;\r
-        }\r
-        (*srcLen) += lookAhead;\r
-        src += lookAhead;\r
-        inSize -= lookAhead;\r
-        p->tempBufSize = 0;\r
-      }\r
-  }\r
-  if (p->code == 0)\r
-    *status = LZMA_STATUS_FINISHED_WITH_MARK;\r
-  return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA;\r
-}\r
-\r
-SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)\r
-{\r
-  SizeT outSize = *destLen;\r
-  SizeT inSize = *srcLen;\r
-  *srcLen = *destLen = 0;\r
-  for (;;)\r
-  {\r
-    SizeT inSizeCur = inSize, outSizeCur, dicPos;\r
-    ELzmaFinishMode curFinishMode;\r
-    SRes res;\r
-    if (p->dicPos == p->dicBufSize)\r
-      p->dicPos = 0;\r
-    dicPos = p->dicPos;\r
-    if (outSize > p->dicBufSize - dicPos)\r
-    {\r
-      outSizeCur = p->dicBufSize;\r
-      curFinishMode = LZMA_FINISH_ANY;\r
-    }\r
-    else\r
-    {\r
-      outSizeCur = dicPos + outSize;\r
-      curFinishMode = finishMode;\r
-    }\r
-\r
-    res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status);\r
-    src += inSizeCur;\r
-    inSize -= inSizeCur;\r
-    *srcLen += inSizeCur;\r
-    outSizeCur = p->dicPos - dicPos;\r
-    memcpy(dest, p->dic + dicPos, outSizeCur);\r
-    dest += outSizeCur;\r
-    outSize -= outSizeCur;\r
-    *destLen += outSizeCur;\r
-    if (res != 0)\r
-      return res;\r
-    if (outSizeCur == 0 || outSize == 0)\r
-      return SZ_OK;\r
-  }\r
-}\r
-\r
-void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc)\r
-{\r
-  alloc->Free(alloc, p->probs);\r
-  p->probs = NULL;\r
-}\r
-\r
-static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc)\r
-{\r
-  alloc->Free(alloc, p->dic);\r
-  p->dic = NULL;\r
-}\r
-\r
-void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc)\r
-{\r
-  LzmaDec_FreeProbs(p, alloc);\r
-  LzmaDec_FreeDict(p, alloc);\r
-}\r
-\r
-SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)\r
-{\r
-  UInt32 dicSize;\r
-  Byte d;\r
-  \r
-  if (size < LZMA_PROPS_SIZE)\r
-    return SZ_ERROR_UNSUPPORTED;\r
-  else\r
-    dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24);\r
\r
-  if (dicSize < LZMA_DIC_MIN)\r
-    dicSize = LZMA_DIC_MIN;\r
-  p->dicSize = dicSize;\r
-\r
-  d = data[0];\r
-  if (d >= (9 * 5 * 5))\r
-    return SZ_ERROR_UNSUPPORTED;\r
-\r
-  p->lc = d % 9;\r
-  d /= 9;\r
-  p->pb = d / 5;\r
-  p->lp = d % 5;\r
-\r
-  return SZ_OK;\r
-}\r
-\r
-static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc)\r
-{\r
-  UInt32 numProbs = LzmaProps_GetNumProbs(propNew);\r
-  if (!p->probs || numProbs != p->numProbs)\r
-  {\r
-    LzmaDec_FreeProbs(p, alloc);\r
-    p->probs = (CLzmaProb *)alloc->Alloc(alloc, numProbs * sizeof(CLzmaProb));\r
-    p->numProbs = numProbs;\r
-    if (!p->probs)\r
-      return SZ_ERROR_MEM;\r
-  }\r
-  return SZ_OK;\r
-}\r
-\r
-SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)\r
-{\r
-  CLzmaProps propNew;\r
-  RINOK(LzmaProps_Decode(&propNew, props, propsSize));\r
-  RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));\r
-  p->prop = propNew;\r
-  return SZ_OK;\r
-}\r
-\r
-SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)\r
-{\r
-  CLzmaProps propNew;\r
-  SizeT dicBufSize;\r
-  RINOK(LzmaProps_Decode(&propNew, props, propsSize));\r
-  RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));\r
-\r
-  {\r
-    UInt32 dictSize = propNew.dicSize;\r
-    SizeT mask = ((UInt32)1 << 12) - 1;\r
-         if (dictSize >= ((UInt32)1 << 30)) mask = ((UInt32)1 << 22) - 1;\r
-    else if (dictSize >= ((UInt32)1 << 22)) mask = ((UInt32)1 << 20) - 1;;\r
-    dicBufSize = ((SizeT)dictSize + mask) & ~mask;\r
-    if (dicBufSize < dictSize)\r
-      dicBufSize = dictSize;\r
-  }\r
-\r
-  if (!p->dic || dicBufSize != p->dicBufSize)\r
-  {\r
-    LzmaDec_FreeDict(p, alloc);\r
-    p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize);\r
-    if (!p->dic)\r
-    {\r
-      LzmaDec_FreeProbs(p, alloc);\r
-      return SZ_ERROR_MEM;\r
-    }\r
-  }\r
-  p->dicBufSize = dicBufSize;\r
-  p->prop = propNew;\r
-  return SZ_OK;\r
-}\r
-\r
-SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,\r
-    const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,\r
-    ELzmaStatus *status, ISzAlloc *alloc)\r
-{\r
-  CLzmaDec p;\r
-  SRes res;\r
-  SizeT outSize = *destLen, inSize = *srcLen;\r
-  *destLen = *srcLen = 0;\r
-  *status = LZMA_STATUS_NOT_SPECIFIED;\r
-  if (inSize < RC_INIT_SIZE)\r
-    return SZ_ERROR_INPUT_EOF;\r
-  LzmaDec_Construct(&p);\r
-  RINOK(LzmaDec_AllocateProbs(&p, propData, propSize, alloc));\r
-  p.dic = dest;\r
-  p.dicBufSize = outSize;\r
-  LzmaDec_Init(&p);\r
-  *srcLen = inSize;\r
-  res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status);\r
-  *destLen = p.dicPos;\r
-  if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT)\r
-    res = SZ_ERROR_INPUT_EOF;\r
-  LzmaDec_FreeProbs(&p, alloc);\r
-  return res;\r
-}\r
diff --git a/deps/lzma-16.04/C/LzmaDec.h b/deps/lzma-16.04/C/LzmaDec.h
deleted file mode 100644 (file)
index 2633abe..0000000
+++ /dev/null
@@ -1,227 +0,0 @@
-/* LzmaDec.h -- LZMA Decoder\r
-2013-01-18 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __LZMA_DEC_H\r
-#define __LZMA_DEC_H\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-/* #define _LZMA_PROB32 */\r
-/* _LZMA_PROB32 can increase the speed on some CPUs,\r
-   but memory usage for CLzmaDec::probs will be doubled in that case */\r
-\r
-#ifdef _LZMA_PROB32\r
-#define CLzmaProb UInt32\r
-#else\r
-#define CLzmaProb UInt16\r
-#endif\r
-\r
-\r
-/* ---------- LZMA Properties ---------- */\r
-\r
-#define LZMA_PROPS_SIZE 5\r
-\r
-typedef struct _CLzmaProps\r
-{\r
-  unsigned lc, lp, pb;\r
-  UInt32 dicSize;\r
-} CLzmaProps;\r
-\r
-/* LzmaProps_Decode - decodes properties\r
-Returns:\r
-  SZ_OK\r
-  SZ_ERROR_UNSUPPORTED - Unsupported properties\r
-*/\r
-\r
-SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size);\r
-\r
-\r
-/* ---------- LZMA Decoder state ---------- */\r
-\r
-/* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case.\r
-   Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */\r
-\r
-#define LZMA_REQUIRED_INPUT_MAX 20\r
-\r
-typedef struct\r
-{\r
-  CLzmaProps prop;\r
-  CLzmaProb *probs;\r
-  Byte *dic;\r
-  const Byte *buf;\r
-  UInt32 range, code;\r
-  SizeT dicPos;\r
-  SizeT dicBufSize;\r
-  UInt32 processedPos;\r
-  UInt32 checkDicSize;\r
-  unsigned state;\r
-  UInt32 reps[4];\r
-  unsigned remainLen;\r
-  int needFlush;\r
-  int needInitState;\r
-  UInt32 numProbs;\r
-  unsigned tempBufSize;\r
-  Byte tempBuf[LZMA_REQUIRED_INPUT_MAX];\r
-} CLzmaDec;\r
-\r
-#define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; }\r
-\r
-void LzmaDec_Init(CLzmaDec *p);\r
-\r
-/* There are two types of LZMA streams:\r
-     0) Stream with end mark. That end mark adds about 6 bytes to compressed size.\r
-     1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */\r
-\r
-typedef enum\r
-{\r
-  LZMA_FINISH_ANY,   /* finish at any point */\r
-  LZMA_FINISH_END    /* block must be finished at the end */\r
-} ELzmaFinishMode;\r
-\r
-/* ELzmaFinishMode has meaning only if the decoding reaches output limit !!!\r
-\r
-   You must use LZMA_FINISH_END, when you know that current output buffer\r
-   covers last bytes of block. In other cases you must use LZMA_FINISH_ANY.\r
-\r
-   If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK,\r
-   and output value of destLen will be less than output buffer size limit.\r
-   You can check status result also.\r
-\r
-   You can use multiple checks to test data integrity after full decompression:\r
-     1) Check Result and "status" variable.\r
-     2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize.\r
-     3) Check that output(srcLen) = compressedSize, if you know real compressedSize.\r
-        You must use correct finish mode in that case. */\r
-\r
-typedef enum\r
-{\r
-  LZMA_STATUS_NOT_SPECIFIED,               /* use main error code instead */\r
-  LZMA_STATUS_FINISHED_WITH_MARK,          /* stream was finished with end mark. */\r
-  LZMA_STATUS_NOT_FINISHED,                /* stream was not finished */\r
-  LZMA_STATUS_NEEDS_MORE_INPUT,            /* you must provide more input bytes */\r
-  LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK  /* there is probability that stream was finished without end mark */\r
-} ELzmaStatus;\r
-\r
-/* ELzmaStatus is used only as output value for function call */\r
-\r
-\r
-/* ---------- Interfaces ---------- */\r
-\r
-/* There are 3 levels of interfaces:\r
-     1) Dictionary Interface\r
-     2) Buffer Interface\r
-     3) One Call Interface\r
-   You can select any of these interfaces, but don't mix functions from different\r
-   groups for same object. */\r
-\r
-\r
-/* There are two variants to allocate state for Dictionary Interface:\r
-     1) LzmaDec_Allocate / LzmaDec_Free\r
-     2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs\r
-   You can use variant 2, if you set dictionary buffer manually.\r
-   For Buffer Interface you must always use variant 1.\r
-\r
-LzmaDec_Allocate* can return:\r
-  SZ_OK\r
-  SZ_ERROR_MEM         - Memory allocation error\r
-  SZ_ERROR_UNSUPPORTED - Unsupported properties\r
-*/\r
-   \r
-SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc);\r
-void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc);\r
-\r
-SRes LzmaDec_Allocate(CLzmaDec *state, const Byte *prop, unsigned propsSize, ISzAlloc *alloc);\r
-void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc);\r
-\r
-/* ---------- Dictionary Interface ---------- */\r
-\r
-/* You can use it, if you want to eliminate the overhead for data copying from\r
-   dictionary to some other external buffer.\r
-   You must work with CLzmaDec variables directly in this interface.\r
-\r
-   STEPS:\r
-     LzmaDec_Constr()\r
-     LzmaDec_Allocate()\r
-     for (each new stream)\r
-     {\r
-       LzmaDec_Init()\r
-       while (it needs more decompression)\r
-       {\r
-         LzmaDec_DecodeToDic()\r
-         use data from CLzmaDec::dic and update CLzmaDec::dicPos\r
-       }\r
-     }\r
-     LzmaDec_Free()\r
-*/\r
-\r
-/* LzmaDec_DecodeToDic\r
-   \r
-   The decoding to internal dictionary buffer (CLzmaDec::dic).\r
-   You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!!\r
-\r
-finishMode:\r
-  It has meaning only if the decoding reaches output limit (dicLimit).\r
-  LZMA_FINISH_ANY - Decode just dicLimit bytes.\r
-  LZMA_FINISH_END - Stream must be finished after dicLimit.\r
-\r
-Returns:\r
-  SZ_OK\r
-    status:\r
-      LZMA_STATUS_FINISHED_WITH_MARK\r
-      LZMA_STATUS_NOT_FINISHED\r
-      LZMA_STATUS_NEEDS_MORE_INPUT\r
-      LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK\r
-  SZ_ERROR_DATA - Data error\r
-*/\r
-\r
-SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit,\r
-    const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);\r
-\r
-\r
-/* ---------- Buffer Interface ---------- */\r
-\r
-/* It's zlib-like interface.\r
-   See LzmaDec_DecodeToDic description for information about STEPS and return results,\r
-   but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need\r
-   to work with CLzmaDec variables manually.\r
-\r
-finishMode:\r
-  It has meaning only if the decoding reaches output limit (*destLen).\r
-  LZMA_FINISH_ANY - Decode just destLen bytes.\r
-  LZMA_FINISH_END - Stream must be finished after (*destLen).\r
-*/\r
-\r
-SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen,\r
-    const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);\r
-\r
-\r
-/* ---------- One Call Interface ---------- */\r
-\r
-/* LzmaDecode\r
-\r
-finishMode:\r
-  It has meaning only if the decoding reaches output limit (*destLen).\r
-  LZMA_FINISH_ANY - Decode just destLen bytes.\r
-  LZMA_FINISH_END - Stream must be finished after (*destLen).\r
-\r
-Returns:\r
-  SZ_OK\r
-    status:\r
-      LZMA_STATUS_FINISHED_WITH_MARK\r
-      LZMA_STATUS_NOT_FINISHED\r
-      LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK\r
-  SZ_ERROR_DATA - Data error\r
-  SZ_ERROR_MEM  - Memory allocation error\r
-  SZ_ERROR_UNSUPPORTED - Unsupported properties\r
-  SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).\r
-*/\r
-\r
-SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,\r
-    const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,\r
-    ELzmaStatus *status, ISzAlloc *alloc);\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/LzmaEnc.c b/deps/lzma-16.04/C/LzmaEnc.c
deleted file mode 100644 (file)
index 462ca67..0000000
+++ /dev/null
@@ -1,2351 +0,0 @@
-/* LzmaEnc.c -- LZMA Encoder\r
-2016-05-16 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include <string.h>\r
-\r
-/* #define SHOW_STAT */\r
-/* #define SHOW_STAT2 */\r
-\r
-#if defined(SHOW_STAT) || defined(SHOW_STAT2)\r
-#include <stdio.h>\r
-#endif\r
-\r
-#include "LzmaEnc.h"\r
-\r
-#include "LzFind.h"\r
-#ifndef _7ZIP_ST\r
-#include "LzFindMt.h"\r
-#endif\r
-\r
-#ifdef SHOW_STAT\r
-static unsigned g_STAT_OFFSET = 0;\r
-#endif\r
-\r
-#define kMaxHistorySize ((UInt32)3 << 29)\r
-/* #define kMaxHistorySize ((UInt32)7 << 29) */\r
-\r
-#define kBlockSizeMax ((1 << LZMA_NUM_BLOCK_SIZE_BITS) - 1)\r
-\r
-#define kBlockSize (9 << 10)\r
-#define kUnpackBlockSize (1 << 18)\r
-#define kMatchArraySize (1 << 21)\r
-#define kMatchRecordMaxSize ((LZMA_MATCH_LEN_MAX * 2 + 3) * LZMA_MATCH_LEN_MAX)\r
-\r
-#define kNumMaxDirectBits (31)\r
-\r
-#define kNumTopBits 24\r
-#define kTopValue ((UInt32)1 << kNumTopBits)\r
-\r
-#define kNumBitModelTotalBits 11\r
-#define kBitModelTotal (1 << kNumBitModelTotalBits)\r
-#define kNumMoveBits 5\r
-#define kProbInitValue (kBitModelTotal >> 1)\r
-\r
-#define kNumMoveReducingBits 4\r
-#define kNumBitPriceShiftBits 4\r
-#define kBitPrice (1 << kNumBitPriceShiftBits)\r
-\r
-void LzmaEncProps_Init(CLzmaEncProps *p)\r
-{\r
-  p->level = 5;\r
-  p->dictSize = p->mc = 0;\r
-  p->reduceSize = (UInt64)(Int64)-1;\r
-  p->lc = p->lp = p->pb = p->algo = p->fb = p->btMode = p->numHashBytes = p->numThreads = -1;\r
-  p->writeEndMark = 0;\r
-}\r
-\r
-void LzmaEncProps_Normalize(CLzmaEncProps *p)\r
-{\r
-  int level = p->level;\r
-  if (level < 0) level = 5;\r
-  p->level = level;\r
-  \r
-  if (p->dictSize == 0) p->dictSize = (level <= 5 ? (1 << (level * 2 + 14)) : (level == 6 ? (1 << 25) : (1 << 26)));\r
-  if (p->dictSize > p->reduceSize)\r
-  {\r
-    unsigned i;\r
-    for (i = 11; i <= 30; i++)\r
-    {\r
-      if ((UInt32)p->reduceSize <= ((UInt32)2 << i)) { p->dictSize = ((UInt32)2 << i); break; }\r
-      if ((UInt32)p->reduceSize <= ((UInt32)3 << i)) { p->dictSize = ((UInt32)3 << i); break; }\r
-    }\r
-  }\r
-\r
-  if (p->lc < 0) p->lc = 3;\r
-  if (p->lp < 0) p->lp = 0;\r
-  if (p->pb < 0) p->pb = 2;\r
-\r
-  if (p->algo < 0) p->algo = (level < 5 ? 0 : 1);\r
-  if (p->fb < 0) p->fb = (level < 7 ? 32 : 64);\r
-  if (p->btMode < 0) p->btMode = (p->algo == 0 ? 0 : 1);\r
-  if (p->numHashBytes < 0) p->numHashBytes = 4;\r
-  if (p->mc == 0) p->mc = (16 + (p->fb >> 1)) >> (p->btMode ? 0 : 1);\r
-  \r
-  if (p->numThreads < 0)\r
-    p->numThreads =\r
-      #ifndef _7ZIP_ST\r
-      ((p->btMode && p->algo) ? 2 : 1);\r
-      #else\r
-      1;\r
-      #endif\r
-}\r
-\r
-UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)\r
-{\r
-  CLzmaEncProps props = *props2;\r
-  LzmaEncProps_Normalize(&props);\r
-  return props.dictSize;\r
-}\r
-\r
-#if (_MSC_VER >= 1400)\r
-/* BSR code is fast for some new CPUs */\r
-/* #define LZMA_LOG_BSR */\r
-#endif\r
-\r
-#ifdef LZMA_LOG_BSR\r
-\r
-#define kDicLogSizeMaxCompress 32\r
-\r
-#define BSR2_RET(pos, res) { unsigned long zz; _BitScanReverse(&zz, (pos)); res = (zz + zz) + ((pos >> (zz - 1)) & 1); }\r
-\r
-static UInt32 GetPosSlot1(UInt32 pos)\r
-{\r
-  UInt32 res;\r
-  BSR2_RET(pos, res);\r
-  return res;\r
-}\r
-#define GetPosSlot2(pos, res) { BSR2_RET(pos, res); }\r
-#define GetPosSlot(pos, res) { if (pos < 2) res = pos; else BSR2_RET(pos, res); }\r
-\r
-#else\r
-\r
-#define kNumLogBits (9 + sizeof(size_t) / 2)\r
-/* #define kNumLogBits (11 + sizeof(size_t) / 8 * 3) */\r
-\r
-#define kDicLogSizeMaxCompress ((kNumLogBits - 1) * 2 + 7)\r
-\r
-static void LzmaEnc_FastPosInit(Byte *g_FastPos)\r
-{\r
-  unsigned slot;\r
-  g_FastPos[0] = 0;\r
-  g_FastPos[1] = 1;\r
-  g_FastPos += 2;\r
-  \r
-  for (slot = 2; slot < kNumLogBits * 2; slot++)\r
-  {\r
-    size_t k = ((size_t)1 << ((slot >> 1) - 1));\r
-    size_t j;\r
-    for (j = 0; j < k; j++)\r
-      g_FastPos[j] = (Byte)slot;\r
-    g_FastPos += k;\r
-  }\r
-}\r
-\r
-/* we can use ((limit - pos) >> 31) only if (pos < ((UInt32)1 << 31)) */\r
-/*\r
-#define BSR2_RET(pos, res) { UInt32 zz = 6 + ((kNumLogBits - 1) & \\r
-  (0 - (((((UInt32)1 << (kNumLogBits + 6)) - 1) - pos) >> 31))); \\r
-  res = p->g_FastPos[pos >> zz] + (zz * 2); }\r
-*/\r
-\r
-/*\r
-#define BSR2_RET(pos, res) { UInt32 zz = 6 + ((kNumLogBits - 1) & \\r
-  (0 - (((((UInt32)1 << (kNumLogBits)) - 1) - (pos >> 6)) >> 31))); \\r
-  res = p->g_FastPos[pos >> zz] + (zz * 2); }\r
-*/\r
-\r
-#define BSR2_RET(pos, res) { UInt32 zz = (pos < (1 << (kNumLogBits + 6))) ? 6 : 6 + kNumLogBits - 1; \\r
-  res = p->g_FastPos[pos >> zz] + (zz * 2); }\r
-\r
-/*\r
-#define BSR2_RET(pos, res) { res = (pos < (1 << (kNumLogBits + 6))) ? \\r
-  p->g_FastPos[pos >> 6] + 12 : \\r
-  p->g_FastPos[pos >> (6 + kNumLogBits - 1)] + (6 + (kNumLogBits - 1)) * 2; }\r
-*/\r
-\r
-#define GetPosSlot1(pos) p->g_FastPos[pos]\r
-#define GetPosSlot2(pos, res) { BSR2_RET(pos, res); }\r
-#define GetPosSlot(pos, res) { if (pos < kNumFullDistances) res = p->g_FastPos[pos]; else BSR2_RET(pos, res); }\r
-\r
-#endif\r
-\r
-\r
-#define LZMA_NUM_REPS 4\r
-\r
-typedef unsigned CState;\r
-\r
-typedef struct\r
-{\r
-  UInt32 price;\r
-\r
-  CState state;\r
-  int prev1IsChar;\r
-  int prev2;\r
-\r
-  UInt32 posPrev2;\r
-  UInt32 backPrev2;\r
-\r
-  UInt32 posPrev;\r
-  UInt32 backPrev;\r
-  UInt32 backs[LZMA_NUM_REPS];\r
-} COptimal;\r
-\r
-#define kNumOpts (1 << 12)\r
-\r
-#define kNumLenToPosStates 4\r
-#define kNumPosSlotBits 6\r
-#define kDicLogSizeMin 0\r
-#define kDicLogSizeMax 32\r
-#define kDistTableSizeMax (kDicLogSizeMax * 2)\r
-\r
-\r
-#define kNumAlignBits 4\r
-#define kAlignTableSize (1 << kNumAlignBits)\r
-#define kAlignMask (kAlignTableSize - 1)\r
-\r
-#define kStartPosModelIndex 4\r
-#define kEndPosModelIndex 14\r
-#define kNumPosModels (kEndPosModelIndex - kStartPosModelIndex)\r
-\r
-#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))\r
-\r
-#ifdef _LZMA_PROB32\r
-#define CLzmaProb UInt32\r
-#else\r
-#define CLzmaProb UInt16\r
-#endif\r
-\r
-#define LZMA_PB_MAX 4\r
-#define LZMA_LC_MAX 8\r
-#define LZMA_LP_MAX 4\r
-\r
-#define LZMA_NUM_PB_STATES_MAX (1 << LZMA_PB_MAX)\r
-\r
-\r
-#define kLenNumLowBits 3\r
-#define kLenNumLowSymbols (1 << kLenNumLowBits)\r
-#define kLenNumMidBits 3\r
-#define kLenNumMidSymbols (1 << kLenNumMidBits)\r
-#define kLenNumHighBits 8\r
-#define kLenNumHighSymbols (1 << kLenNumHighBits)\r
-\r
-#define kLenNumSymbolsTotal (kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols)\r
-\r
-#define LZMA_MATCH_LEN_MIN 2\r
-#define LZMA_MATCH_LEN_MAX (LZMA_MATCH_LEN_MIN + kLenNumSymbolsTotal - 1)\r
-\r
-#define kNumStates 12\r
-\r
-\r
-typedef struct\r
-{\r
-  CLzmaProb choice;\r
-  CLzmaProb choice2;\r
-  CLzmaProb low[LZMA_NUM_PB_STATES_MAX << kLenNumLowBits];\r
-  CLzmaProb mid[LZMA_NUM_PB_STATES_MAX << kLenNumMidBits];\r
-  CLzmaProb high[kLenNumHighSymbols];\r
-} CLenEnc;\r
-\r
-\r
-typedef struct\r
-{\r
-  CLenEnc p;\r
-  UInt32 tableSize;\r
-  UInt32 prices[LZMA_NUM_PB_STATES_MAX][kLenNumSymbolsTotal];\r
-  UInt32 counters[LZMA_NUM_PB_STATES_MAX];\r
-} CLenPriceEnc;\r
-\r
-\r
-typedef struct\r
-{\r
-  UInt32 range;\r
-  Byte cache;\r
-  UInt64 low;\r
-  UInt64 cacheSize;\r
-  Byte *buf;\r
-  Byte *bufLim;\r
-  Byte *bufBase;\r
-  ISeqOutStream *outStream;\r
-  UInt64 processed;\r
-  SRes res;\r
-} CRangeEnc;\r
-\r
-\r
-typedef struct\r
-{\r
-  CLzmaProb *litProbs;\r
-\r
-  UInt32 state;\r
-  UInt32 reps[LZMA_NUM_REPS];\r
-\r
-  CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX];\r
-  CLzmaProb isRep[kNumStates];\r
-  CLzmaProb isRepG0[kNumStates];\r
-  CLzmaProb isRepG1[kNumStates];\r
-  CLzmaProb isRepG2[kNumStates];\r
-  CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX];\r
-\r
-  CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits];\r
-  CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex];\r
-  CLzmaProb posAlignEncoder[1 << kNumAlignBits];\r
-  \r
-  CLenPriceEnc lenEnc;\r
-  CLenPriceEnc repLenEnc;\r
-} CSaveState;\r
-\r
-\r
-typedef struct\r
-{\r
-  void *matchFinderObj;\r
-  IMatchFinder matchFinder;\r
-\r
-  UInt32 optimumEndIndex;\r
-  UInt32 optimumCurrentIndex;\r
-\r
-  UInt32 longestMatchLength;\r
-  UInt32 numPairs;\r
-  UInt32 numAvail;\r
-\r
-  UInt32 numFastBytes;\r
-  UInt32 additionalOffset;\r
-  UInt32 reps[LZMA_NUM_REPS];\r
-  UInt32 state;\r
-\r
-  unsigned lc, lp, pb;\r
-  unsigned lpMask, pbMask;\r
-  unsigned lclp;\r
-\r
-  CLzmaProb *litProbs;\r
-\r
-  Bool fastMode;\r
-  Bool writeEndMark;\r
-  Bool finished;\r
-  Bool multiThread;\r
-  Bool needInit;\r
-\r
-  UInt64 nowPos64;\r
-  \r
-  UInt32 matchPriceCount;\r
-  UInt32 alignPriceCount;\r
-\r
-  UInt32 distTableSize;\r
-\r
-  UInt32 dictSize;\r
-  SRes result;\r
-\r
-  CRangeEnc rc;\r
-\r
-  #ifndef _7ZIP_ST\r
-  Bool mtMode;\r
-  CMatchFinderMt matchFinderMt;\r
-  #endif\r
-\r
-  CMatchFinder matchFinderBase;\r
-\r
-  #ifndef _7ZIP_ST\r
-  Byte pad[128];\r
-  #endif\r
-  \r
-  COptimal opt[kNumOpts];\r
-  \r
-  #ifndef LZMA_LOG_BSR\r
-  Byte g_FastPos[1 << kNumLogBits];\r
-  #endif\r
-\r
-  UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits];\r
-  UInt32 matches[LZMA_MATCH_LEN_MAX * 2 + 2 + 1];\r
-\r
-  UInt32 posSlotPrices[kNumLenToPosStates][kDistTableSizeMax];\r
-  UInt32 distancesPrices[kNumLenToPosStates][kNumFullDistances];\r
-  UInt32 alignPrices[kAlignTableSize];\r
-\r
-  CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX];\r
-  CLzmaProb isRep[kNumStates];\r
-  CLzmaProb isRepG0[kNumStates];\r
-  CLzmaProb isRepG1[kNumStates];\r
-  CLzmaProb isRepG2[kNumStates];\r
-  CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX];\r
-\r
-  CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits];\r
-  CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex];\r
-  CLzmaProb posAlignEncoder[1 << kNumAlignBits];\r
-  \r
-  CLenPriceEnc lenEnc;\r
-  CLenPriceEnc repLenEnc;\r
-\r
-  CSaveState saveState;\r
-\r
-  #ifndef _7ZIP_ST\r
-  Byte pad2[128];\r
-  #endif\r
-} CLzmaEnc;\r
-\r
-\r
-void LzmaEnc_SaveState(CLzmaEncHandle pp)\r
-{\r
-  CLzmaEnc *p = (CLzmaEnc *)pp;\r
-  CSaveState *dest = &p->saveState;\r
-  int i;\r
-  dest->lenEnc = p->lenEnc;\r
-  dest->repLenEnc = p->repLenEnc;\r
-  dest->state = p->state;\r
-\r
-  for (i = 0; i < kNumStates; i++)\r
-  {\r
-    memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i]));\r
-    memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i]));\r
-  }\r
-  for (i = 0; i < kNumLenToPosStates; i++)\r
-    memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i]));\r
-  memcpy(dest->isRep, p->isRep, sizeof(p->isRep));\r
-  memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0));\r
-  memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1));\r
-  memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2));\r
-  memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders));\r
-  memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder));\r
-  memcpy(dest->reps, p->reps, sizeof(p->reps));\r
-  memcpy(dest->litProbs, p->litProbs, ((UInt32)0x300 << p->lclp) * sizeof(CLzmaProb));\r
-}\r
-\r
-void LzmaEnc_RestoreState(CLzmaEncHandle pp)\r
-{\r
-  CLzmaEnc *dest = (CLzmaEnc *)pp;\r
-  const CSaveState *p = &dest->saveState;\r
-  int i;\r
-  dest->lenEnc = p->lenEnc;\r
-  dest->repLenEnc = p->repLenEnc;\r
-  dest->state = p->state;\r
-\r
-  for (i = 0; i < kNumStates; i++)\r
-  {\r
-    memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i]));\r
-    memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i]));\r
-  }\r
-  for (i = 0; i < kNumLenToPosStates; i++)\r
-    memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i]));\r
-  memcpy(dest->isRep, p->isRep, sizeof(p->isRep));\r
-  memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0));\r
-  memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1));\r
-  memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2));\r
-  memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders));\r
-  memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder));\r
-  memcpy(dest->reps, p->reps, sizeof(p->reps));\r
-  memcpy(dest->litProbs, p->litProbs, ((UInt32)0x300 << dest->lclp) * sizeof(CLzmaProb));\r
-}\r
-\r
-SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2)\r
-{\r
-  CLzmaEnc *p = (CLzmaEnc *)pp;\r
-  CLzmaEncProps props = *props2;\r
-  LzmaEncProps_Normalize(&props);\r
-\r
-  if (props.lc > LZMA_LC_MAX\r
-      || props.lp > LZMA_LP_MAX\r
-      || props.pb > LZMA_PB_MAX\r
-      || props.dictSize > ((UInt64)1 << kDicLogSizeMaxCompress)\r
-      || props.dictSize > kMaxHistorySize)\r
-    return SZ_ERROR_PARAM;\r
-\r
-  p->dictSize = props.dictSize;\r
-  {\r
-    unsigned fb = props.fb;\r
-    if (fb < 5)\r
-      fb = 5;\r
-    if (fb > LZMA_MATCH_LEN_MAX)\r
-      fb = LZMA_MATCH_LEN_MAX;\r
-    p->numFastBytes = fb;\r
-  }\r
-  p->lc = props.lc;\r
-  p->lp = props.lp;\r
-  p->pb = props.pb;\r
-  p->fastMode = (props.algo == 0);\r
-  p->matchFinderBase.btMode = (Byte)(props.btMode ? 1 : 0);\r
-  {\r
-    UInt32 numHashBytes = 4;\r
-    if (props.btMode)\r
-    {\r
-      if (props.numHashBytes < 2)\r
-        numHashBytes = 2;\r
-      else if (props.numHashBytes < 4)\r
-        numHashBytes = props.numHashBytes;\r
-    }\r
-    p->matchFinderBase.numHashBytes = numHashBytes;\r
-  }\r
-\r
-  p->matchFinderBase.cutValue = props.mc;\r
-\r
-  p->writeEndMark = props.writeEndMark;\r
-\r
-  #ifndef _7ZIP_ST\r
-  /*\r
-  if (newMultiThread != _multiThread)\r
-  {\r
-    ReleaseMatchFinder();\r
-    _multiThread = newMultiThread;\r
-  }\r
-  */\r
-  p->multiThread = (props.numThreads > 1);\r
-  #endif\r
-\r
-  return SZ_OK;\r
-}\r
-\r
-static const int kLiteralNextStates[kNumStates] = {0, 0, 0, 0, 1, 2, 3, 4,  5,  6,   4, 5};\r
-static const int kMatchNextStates[kNumStates]   = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10};\r
-static const int kRepNextStates[kNumStates]     = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11};\r
-static const int kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11};\r
-\r
-#define IsCharState(s) ((s) < 7)\r
-\r
-#define GetLenToPosState(len) (((len) < kNumLenToPosStates + 1) ? (len) - 2 : kNumLenToPosStates - 1)\r
-\r
-#define kInfinityPrice (1 << 30)\r
-\r
-static void RangeEnc_Construct(CRangeEnc *p)\r
-{\r
-  p->outStream = NULL;\r
-  p->bufBase = NULL;\r
-}\r
-\r
-#define RangeEnc_GetProcessed(p) ((p)->processed + ((p)->buf - (p)->bufBase) + (p)->cacheSize)\r
-\r
-#define RC_BUF_SIZE (1 << 16)\r
-static int RangeEnc_Alloc(CRangeEnc *p, ISzAlloc *alloc)\r
-{\r
-  if (!p->bufBase)\r
-  {\r
-    p->bufBase = (Byte *)alloc->Alloc(alloc, RC_BUF_SIZE);\r
-    if (!p->bufBase)\r
-      return 0;\r
-    p->bufLim = p->bufBase + RC_BUF_SIZE;\r
-  }\r
-  return 1;\r
-}\r
-\r
-static void RangeEnc_Free(CRangeEnc *p, ISzAlloc *alloc)\r
-{\r
-  alloc->Free(alloc, p->bufBase);\r
-  p->bufBase = 0;\r
-}\r
-\r
-static void RangeEnc_Init(CRangeEnc *p)\r
-{\r
-  /* Stream.Init(); */\r
-  p->low = 0;\r
-  p->range = 0xFFFFFFFF;\r
-  p->cacheSize = 1;\r
-  p->cache = 0;\r
-\r
-  p->buf = p->bufBase;\r
-\r
-  p->processed = 0;\r
-  p->res = SZ_OK;\r
-}\r
-\r
-static void RangeEnc_FlushStream(CRangeEnc *p)\r
-{\r
-  size_t num;\r
-  if (p->res != SZ_OK)\r
-    return;\r
-  num = p->buf - p->bufBase;\r
-  if (num != p->outStream->Write(p->outStream, p->bufBase, num))\r
-    p->res = SZ_ERROR_WRITE;\r
-  p->processed += num;\r
-  p->buf = p->bufBase;\r
-}\r
-\r
-static void MY_FAST_CALL RangeEnc_ShiftLow(CRangeEnc *p)\r
-{\r
-  if ((UInt32)p->low < (UInt32)0xFF000000 || (unsigned)(p->low >> 32) != 0)\r
-  {\r
-    Byte temp = p->cache;\r
-    do\r
-    {\r
-      Byte *buf = p->buf;\r
-      *buf++ = (Byte)(temp + (Byte)(p->low >> 32));\r
-      p->buf = buf;\r
-      if (buf == p->bufLim)\r
-        RangeEnc_FlushStream(p);\r
-      temp = 0xFF;\r
-    }\r
-    while (--p->cacheSize != 0);\r
-    p->cache = (Byte)((UInt32)p->low >> 24);\r
-  }\r
-  p->cacheSize++;\r
-  p->low = (UInt32)p->low << 8;\r
-}\r
-\r
-static void RangeEnc_FlushData(CRangeEnc *p)\r
-{\r
-  int i;\r
-  for (i = 0; i < 5; i++)\r
-    RangeEnc_ShiftLow(p);\r
-}\r
-\r
-static void RangeEnc_EncodeDirectBits(CRangeEnc *p, UInt32 value, unsigned numBits)\r
-{\r
-  do\r
-  {\r
-    p->range >>= 1;\r
-    p->low += p->range & (0 - ((value >> --numBits) & 1));\r
-    if (p->range < kTopValue)\r
-    {\r
-      p->range <<= 8;\r
-      RangeEnc_ShiftLow(p);\r
-    }\r
-  }\r
-  while (numBits != 0);\r
-}\r
-\r
-static void RangeEnc_EncodeBit(CRangeEnc *p, CLzmaProb *prob, UInt32 symbol)\r
-{\r
-  UInt32 ttt = *prob;\r
-  UInt32 newBound = (p->range >> kNumBitModelTotalBits) * ttt;\r
-  if (symbol == 0)\r
-  {\r
-    p->range = newBound;\r
-    ttt += (kBitModelTotal - ttt) >> kNumMoveBits;\r
-  }\r
-  else\r
-  {\r
-    p->low += newBound;\r
-    p->range -= newBound;\r
-    ttt -= ttt >> kNumMoveBits;\r
-  }\r
-  *prob = (CLzmaProb)ttt;\r
-  if (p->range < kTopValue)\r
-  {\r
-    p->range <<= 8;\r
-    RangeEnc_ShiftLow(p);\r
-  }\r
-}\r
-\r
-static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol)\r
-{\r
-  symbol |= 0x100;\r
-  do\r
-  {\r
-    RangeEnc_EncodeBit(p, probs + (symbol >> 8), (symbol >> 7) & 1);\r
-    symbol <<= 1;\r
-  }\r
-  while (symbol < 0x10000);\r
-}\r
-\r
-static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol, UInt32 matchByte)\r
-{\r
-  UInt32 offs = 0x100;\r
-  symbol |= 0x100;\r
-  do\r
-  {\r
-    matchByte <<= 1;\r
-    RangeEnc_EncodeBit(p, probs + (offs + (matchByte & offs) + (symbol >> 8)), (symbol >> 7) & 1);\r
-    symbol <<= 1;\r
-    offs &= ~(matchByte ^ symbol);\r
-  }\r
-  while (symbol < 0x10000);\r
-}\r
-\r
-static void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)\r
-{\r
-  UInt32 i;\r
-  for (i = (1 << kNumMoveReducingBits) / 2; i < kBitModelTotal; i += (1 << kNumMoveReducingBits))\r
-  {\r
-    const int kCyclesBits = kNumBitPriceShiftBits;\r
-    UInt32 w = i;\r
-    UInt32 bitCount = 0;\r
-    int j;\r
-    for (j = 0; j < kCyclesBits; j++)\r
-    {\r
-      w = w * w;\r
-      bitCount <<= 1;\r
-      while (w >= ((UInt32)1 << 16))\r
-      {\r
-        w >>= 1;\r
-        bitCount++;\r
-      }\r
-    }\r
-    ProbPrices[i >> kNumMoveReducingBits] = ((kNumBitModelTotalBits << kCyclesBits) - 15 - bitCount);\r
-  }\r
-}\r
-\r
-\r
-#define GET_PRICE(prob, symbol) \\r
-  p->ProbPrices[((prob) ^ (((-(int)(symbol))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits];\r
-\r
-#define GET_PRICEa(prob, symbol) \\r
-  ProbPrices[((prob) ^ ((-((int)(symbol))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits];\r
-\r
-#define GET_PRICE_0(prob) p->ProbPrices[(prob) >> kNumMoveReducingBits]\r
-#define GET_PRICE_1(prob) p->ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits]\r
-\r
-#define GET_PRICE_0a(prob) ProbPrices[(prob) >> kNumMoveReducingBits]\r
-#define GET_PRICE_1a(prob) ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits]\r
-\r
-static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 symbol, const UInt32 *ProbPrices)\r
-{\r
-  UInt32 price = 0;\r
-  symbol |= 0x100;\r
-  do\r
-  {\r
-    price += GET_PRICEa(probs[symbol >> 8], (symbol >> 7) & 1);\r
-    symbol <<= 1;\r
-  }\r
-  while (symbol < 0x10000);\r
-  return price;\r
-}\r
-\r
-static UInt32 LitEnc_GetPriceMatched(const CLzmaProb *probs, UInt32 symbol, UInt32 matchByte, const UInt32 *ProbPrices)\r
-{\r
-  UInt32 price = 0;\r
-  UInt32 offs = 0x100;\r
-  symbol |= 0x100;\r
-  do\r
-  {\r
-    matchByte <<= 1;\r
-    price += GET_PRICEa(probs[offs + (matchByte & offs) + (symbol >> 8)], (symbol >> 7) & 1);\r
-    symbol <<= 1;\r
-    offs &= ~(matchByte ^ symbol);\r
-  }\r
-  while (symbol < 0x10000);\r
-  return price;\r
-}\r
-\r
-\r
-static void RcTree_Encode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UInt32 symbol)\r
-{\r
-  UInt32 m = 1;\r
-  int i;\r
-  for (i = numBitLevels; i != 0;)\r
-  {\r
-    UInt32 bit;\r
-    i--;\r
-    bit = (symbol >> i) & 1;\r
-    RangeEnc_EncodeBit(rc, probs + m, bit);\r
-    m = (m << 1) | bit;\r
-  }\r
-}\r
-\r
-static void RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UInt32 symbol)\r
-{\r
-  UInt32 m = 1;\r
-  int i;\r
-  for (i = 0; i < numBitLevels; i++)\r
-  {\r
-    UInt32 bit = symbol & 1;\r
-    RangeEnc_EncodeBit(rc, probs + m, bit);\r
-    m = (m << 1) | bit;\r
-    symbol >>= 1;\r
-  }\r
-}\r
-\r
-static UInt32 RcTree_GetPrice(const CLzmaProb *probs, int numBitLevels, UInt32 symbol, const UInt32 *ProbPrices)\r
-{\r
-  UInt32 price = 0;\r
-  symbol |= (1 << numBitLevels);\r
-  while (symbol != 1)\r
-  {\r
-    price += GET_PRICEa(probs[symbol >> 1], symbol & 1);\r
-    symbol >>= 1;\r
-  }\r
-  return price;\r
-}\r
-\r
-static UInt32 RcTree_ReverseGetPrice(const CLzmaProb *probs, int numBitLevels, UInt32 symbol, const UInt32 *ProbPrices)\r
-{\r
-  UInt32 price = 0;\r
-  UInt32 m = 1;\r
-  int i;\r
-  for (i = numBitLevels; i != 0; i--)\r
-  {\r
-    UInt32 bit = symbol & 1;\r
-    symbol >>= 1;\r
-    price += GET_PRICEa(probs[m], bit);\r
-    m = (m << 1) | bit;\r
-  }\r
-  return price;\r
-}\r
-\r
-\r
-static void LenEnc_Init(CLenEnc *p)\r
-{\r
-  unsigned i;\r
-  p->choice = p->choice2 = kProbInitValue;\r
-  for (i = 0; i < (LZMA_NUM_PB_STATES_MAX << kLenNumLowBits); i++)\r
-    p->low[i] = kProbInitValue;\r
-  for (i = 0; i < (LZMA_NUM_PB_STATES_MAX << kLenNumMidBits); i++)\r
-    p->mid[i] = kProbInitValue;\r
-  for (i = 0; i < kLenNumHighSymbols; i++)\r
-    p->high[i] = kProbInitValue;\r
-}\r
-\r
-static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posState)\r
-{\r
-  if (symbol < kLenNumLowSymbols)\r
-  {\r
-    RangeEnc_EncodeBit(rc, &p->choice, 0);\r
-    RcTree_Encode(rc, p->low + (posState << kLenNumLowBits), kLenNumLowBits, symbol);\r
-  }\r
-  else\r
-  {\r
-    RangeEnc_EncodeBit(rc, &p->choice, 1);\r
-    if (symbol < kLenNumLowSymbols + kLenNumMidSymbols)\r
-    {\r
-      RangeEnc_EncodeBit(rc, &p->choice2, 0);\r
-      RcTree_Encode(rc, p->mid + (posState << kLenNumMidBits), kLenNumMidBits, symbol - kLenNumLowSymbols);\r
-    }\r
-    else\r
-    {\r
-      RangeEnc_EncodeBit(rc, &p->choice2, 1);\r
-      RcTree_Encode(rc, p->high, kLenNumHighBits, symbol - kLenNumLowSymbols - kLenNumMidSymbols);\r
-    }\r
-  }\r
-}\r
-\r
-static void LenEnc_SetPrices(CLenEnc *p, UInt32 posState, UInt32 numSymbols, UInt32 *prices, const UInt32 *ProbPrices)\r
-{\r
-  UInt32 a0 = GET_PRICE_0a(p->choice);\r
-  UInt32 a1 = GET_PRICE_1a(p->choice);\r
-  UInt32 b0 = a1 + GET_PRICE_0a(p->choice2);\r
-  UInt32 b1 = a1 + GET_PRICE_1a(p->choice2);\r
-  UInt32 i = 0;\r
-  for (i = 0; i < kLenNumLowSymbols; i++)\r
-  {\r
-    if (i >= numSymbols)\r
-      return;\r
-    prices[i] = a0 + RcTree_GetPrice(p->low + (posState << kLenNumLowBits), kLenNumLowBits, i, ProbPrices);\r
-  }\r
-  for (; i < kLenNumLowSymbols + kLenNumMidSymbols; i++)\r
-  {\r
-    if (i >= numSymbols)\r
-      return;\r
-    prices[i] = b0 + RcTree_GetPrice(p->mid + (posState << kLenNumMidBits), kLenNumMidBits, i - kLenNumLowSymbols, ProbPrices);\r
-  }\r
-  for (; i < numSymbols; i++)\r
-    prices[i] = b1 + RcTree_GetPrice(p->high, kLenNumHighBits, i - kLenNumLowSymbols - kLenNumMidSymbols, ProbPrices);\r
-}\r
-\r
-static void MY_FAST_CALL LenPriceEnc_UpdateTable(CLenPriceEnc *p, UInt32 posState, const UInt32 *ProbPrices)\r
-{\r
-  LenEnc_SetPrices(&p->p, posState, p->tableSize, p->prices[posState], ProbPrices);\r
-  p->counters[posState] = p->tableSize;\r
-}\r
-\r
-static void LenPriceEnc_UpdateTables(CLenPriceEnc *p, UInt32 numPosStates, const UInt32 *ProbPrices)\r
-{\r
-  UInt32 posState;\r
-  for (posState = 0; posState < numPosStates; posState++)\r
-    LenPriceEnc_UpdateTable(p, posState, ProbPrices);\r
-}\r
-\r
-static void LenEnc_Encode2(CLenPriceEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posState, Bool updatePrice, const UInt32 *ProbPrices)\r
-{\r
-  LenEnc_Encode(&p->p, rc, symbol, posState);\r
-  if (updatePrice)\r
-    if (--p->counters[posState] == 0)\r
-      LenPriceEnc_UpdateTable(p, posState, ProbPrices);\r
-}\r
-\r
-\r
-\r
-\r
-static void MovePos(CLzmaEnc *p, UInt32 num)\r
-{\r
-  #ifdef SHOW_STAT\r
-  g_STAT_OFFSET += num;\r
-  printf("\n MovePos %u", num);\r
-  #endif\r
-  \r
-  if (num != 0)\r
-  {\r
-    p->additionalOffset += num;\r
-    p->matchFinder.Skip(p->matchFinderObj, num);\r
-  }\r
-}\r
-\r
-static UInt32 ReadMatchDistances(CLzmaEnc *p, UInt32 *numDistancePairsRes)\r
-{\r
-  UInt32 lenRes = 0, numPairs;\r
-  p->numAvail = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);\r
-  numPairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matches);\r
-  \r
-  #ifdef SHOW_STAT\r
-  printf("\n i = %u numPairs = %u    ", g_STAT_OFFSET, numPairs / 2);\r
-  g_STAT_OFFSET++;\r
-  {\r
-    UInt32 i;\r
-    for (i = 0; i < numPairs; i += 2)\r
-      printf("%2u %6u   | ", p->matches[i], p->matches[i + 1]);\r
-  }\r
-  #endif\r
-  \r
-  if (numPairs > 0)\r
-  {\r
-    lenRes = p->matches[numPairs - 2];\r
-    if (lenRes == p->numFastBytes)\r
-    {\r
-      UInt32 numAvail = p->numAvail;\r
-      if (numAvail > LZMA_MATCH_LEN_MAX)\r
-        numAvail = LZMA_MATCH_LEN_MAX;\r
-      {\r
-        const Byte *pbyCur = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;\r
-        const Byte *pby = pbyCur + lenRes;\r
-        ptrdiff_t dif = (ptrdiff_t)-1 - p->matches[numPairs - 1];\r
-        const Byte *pbyLim = pbyCur + numAvail;\r
-        for (; pby != pbyLim && *pby == pby[dif]; pby++);\r
-        lenRes = (UInt32)(pby - pbyCur);\r
-      }\r
-    }\r
-  }\r
-  p->additionalOffset++;\r
-  *numDistancePairsRes = numPairs;\r
-  return lenRes;\r
-}\r
-\r
-\r
-#define MakeAsChar(p) (p)->backPrev = (UInt32)(-1); (p)->prev1IsChar = False;\r
-#define MakeAsShortRep(p) (p)->backPrev = 0; (p)->prev1IsChar = False;\r
-#define IsShortRep(p) ((p)->backPrev == 0)\r
-\r
-static UInt32 GetRepLen1Price(CLzmaEnc *p, UInt32 state, UInt32 posState)\r
-{\r
-  return\r
-    GET_PRICE_0(p->isRepG0[state]) +\r
-    GET_PRICE_0(p->isRep0Long[state][posState]);\r
-}\r
-\r
-static UInt32 GetPureRepPrice(CLzmaEnc *p, UInt32 repIndex, UInt32 state, UInt32 posState)\r
-{\r
-  UInt32 price;\r
-  if (repIndex == 0)\r
-  {\r
-    price = GET_PRICE_0(p->isRepG0[state]);\r
-    price += GET_PRICE_1(p->isRep0Long[state][posState]);\r
-  }\r
-  else\r
-  {\r
-    price = GET_PRICE_1(p->isRepG0[state]);\r
-    if (repIndex == 1)\r
-      price += GET_PRICE_0(p->isRepG1[state]);\r
-    else\r
-    {\r
-      price += GET_PRICE_1(p->isRepG1[state]);\r
-      price += GET_PRICE(p->isRepG2[state], repIndex - 2);\r
-    }\r
-  }\r
-  return price;\r
-}\r
-\r
-static UInt32 GetRepPrice(CLzmaEnc *p, UInt32 repIndex, UInt32 len, UInt32 state, UInt32 posState)\r
-{\r
-  return p->repLenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN] +\r
-    GetPureRepPrice(p, repIndex, state, posState);\r
-}\r
-\r
-static UInt32 Backward(CLzmaEnc *p, UInt32 *backRes, UInt32 cur)\r
-{\r
-  UInt32 posMem = p->opt[cur].posPrev;\r
-  UInt32 backMem = p->opt[cur].backPrev;\r
-  p->optimumEndIndex = cur;\r
-  do\r
-  {\r
-    if (p->opt[cur].prev1IsChar)\r
-    {\r
-      MakeAsChar(&p->opt[posMem])\r
-      p->opt[posMem].posPrev = posMem - 1;\r
-      if (p->opt[cur].prev2)\r
-      {\r
-        p->opt[posMem - 1].prev1IsChar = False;\r
-        p->opt[posMem - 1].posPrev = p->opt[cur].posPrev2;\r
-        p->opt[posMem - 1].backPrev = p->opt[cur].backPrev2;\r
-      }\r
-    }\r
-    {\r
-      UInt32 posPrev = posMem;\r
-      UInt32 backCur = backMem;\r
-      \r
-      backMem = p->opt[posPrev].backPrev;\r
-      posMem = p->opt[posPrev].posPrev;\r
-      \r
-      p->opt[posPrev].backPrev = backCur;\r
-      p->opt[posPrev].posPrev = cur;\r
-      cur = posPrev;\r
-    }\r
-  }\r
-  while (cur != 0);\r
-  *backRes = p->opt[0].backPrev;\r
-  p->optimumCurrentIndex  = p->opt[0].posPrev;\r
-  return p->optimumCurrentIndex;\r
-}\r
-\r
-#define LIT_PROBS(pos, prevByte) (p->litProbs + ((((pos) & p->lpMask) << p->lc) + ((prevByte) >> (8 - p->lc))) * (UInt32)0x300)\r
-\r
-static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes)\r
-{\r
-  UInt32 lenEnd, cur;\r
-  UInt32 reps[LZMA_NUM_REPS], repLens[LZMA_NUM_REPS];\r
-  UInt32 *matches;\r
-\r
-  {\r
-\r
-  UInt32 numAvail, mainLen, numPairs, repMaxIndex, i, posState, len;\r
-  UInt32 matchPrice, repMatchPrice, normalMatchPrice;\r
-  const Byte *data;\r
-  Byte curByte, matchByte;\r
-\r
-  if (p->optimumEndIndex != p->optimumCurrentIndex)\r
-  {\r
-    const COptimal *opt = &p->opt[p->optimumCurrentIndex];\r
-    UInt32 lenRes = opt->posPrev - p->optimumCurrentIndex;\r
-    *backRes = opt->backPrev;\r
-    p->optimumCurrentIndex = opt->posPrev;\r
-    return lenRes;\r
-  }\r
-  p->optimumCurrentIndex = p->optimumEndIndex = 0;\r
-  \r
-  if (p->additionalOffset == 0)\r
-    mainLen = ReadMatchDistances(p, &numPairs);\r
-  else\r
-  {\r
-    mainLen = p->longestMatchLength;\r
-    numPairs = p->numPairs;\r
-  }\r
-\r
-  numAvail = p->numAvail;\r
-  if (numAvail < 2)\r
-  {\r
-    *backRes = (UInt32)(-1);\r
-    return 1;\r
-  }\r
-  if (numAvail > LZMA_MATCH_LEN_MAX)\r
-    numAvail = LZMA_MATCH_LEN_MAX;\r
-\r
-  data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;\r
-  repMaxIndex = 0;\r
-  for (i = 0; i < LZMA_NUM_REPS; i++)\r
-  {\r
-    UInt32 lenTest;\r
-    const Byte *data2;\r
-    reps[i] = p->reps[i];\r
-    data2 = data - reps[i] - 1;\r
-    if (data[0] != data2[0] || data[1] != data2[1])\r
-    {\r
-      repLens[i] = 0;\r
-      continue;\r
-    }\r
-    for (lenTest = 2; lenTest < numAvail && data[lenTest] == data2[lenTest]; lenTest++);\r
-    repLens[i] = lenTest;\r
-    if (lenTest > repLens[repMaxIndex])\r
-      repMaxIndex = i;\r
-  }\r
-  if (repLens[repMaxIndex] >= p->numFastBytes)\r
-  {\r
-    UInt32 lenRes;\r
-    *backRes = repMaxIndex;\r
-    lenRes = repLens[repMaxIndex];\r
-    MovePos(p, lenRes - 1);\r
-    return lenRes;\r
-  }\r
-\r
-  matches = p->matches;\r
-  if (mainLen >= p->numFastBytes)\r
-  {\r
-    *backRes = matches[numPairs - 1] + LZMA_NUM_REPS;\r
-    MovePos(p, mainLen - 1);\r
-    return mainLen;\r
-  }\r
-  curByte = *data;\r
-  matchByte = *(data - (reps[0] + 1));\r
-\r
-  if (mainLen < 2 && curByte != matchByte && repLens[repMaxIndex] < 2)\r
-  {\r
-    *backRes = (UInt32)-1;\r
-    return 1;\r
-  }\r
-\r
-  p->opt[0].state = (CState)p->state;\r
-\r
-  posState = (position & p->pbMask);\r
-\r
-  {\r
-    const CLzmaProb *probs = LIT_PROBS(position, *(data - 1));\r
-    p->opt[1].price = GET_PRICE_0(p->isMatch[p->state][posState]) +\r
-        (!IsCharState(p->state) ?\r
-          LitEnc_GetPriceMatched(probs, curByte, matchByte, p->ProbPrices) :\r
-          LitEnc_GetPrice(probs, curByte, p->ProbPrices));\r
-  }\r
-\r
-  MakeAsChar(&p->opt[1]);\r
-\r
-  matchPrice = GET_PRICE_1(p->isMatch[p->state][posState]);\r
-  repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[p->state]);\r
-\r
-  if (matchByte == curByte)\r
-  {\r
-    UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, p->state, posState);\r
-    if (shortRepPrice < p->opt[1].price)\r
-    {\r
-      p->opt[1].price = shortRepPrice;\r
-      MakeAsShortRep(&p->opt[1]);\r
-    }\r
-  }\r
-  lenEnd = ((mainLen >= repLens[repMaxIndex]) ? mainLen : repLens[repMaxIndex]);\r
-\r
-  if (lenEnd < 2)\r
-  {\r
-    *backRes = p->opt[1].backPrev;\r
-    return 1;\r
-  }\r
-\r
-  p->opt[1].posPrev = 0;\r
-  for (i = 0; i < LZMA_NUM_REPS; i++)\r
-    p->opt[0].backs[i] = reps[i];\r
-\r
-  len = lenEnd;\r
-  do\r
-    p->opt[len--].price = kInfinityPrice;\r
-  while (len >= 2);\r
-\r
-  for (i = 0; i < LZMA_NUM_REPS; i++)\r
-  {\r
-    UInt32 repLen = repLens[i];\r
-    UInt32 price;\r
-    if (repLen < 2)\r
-      continue;\r
-    price = repMatchPrice + GetPureRepPrice(p, i, p->state, posState);\r
-    do\r
-    {\r
-      UInt32 curAndLenPrice = price + p->repLenEnc.prices[posState][repLen - 2];\r
-      COptimal *opt = &p->opt[repLen];\r
-      if (curAndLenPrice < opt->price)\r
-      {\r
-        opt->price = curAndLenPrice;\r
-        opt->posPrev = 0;\r
-        opt->backPrev = i;\r
-        opt->prev1IsChar = False;\r
-      }\r
-    }\r
-    while (--repLen >= 2);\r
-  }\r
-\r
-  normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[p->state]);\r
-\r
-  len = ((repLens[0] >= 2) ? repLens[0] + 1 : 2);\r
-  if (len <= mainLen)\r
-  {\r
-    UInt32 offs = 0;\r
-    while (len > matches[offs])\r
-      offs += 2;\r
-    for (; ; len++)\r
-    {\r
-      COptimal *opt;\r
-      UInt32 distance = matches[offs + 1];\r
-\r
-      UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN];\r
-      UInt32 lenToPosState = GetLenToPosState(len);\r
-      if (distance < kNumFullDistances)\r
-        curAndLenPrice += p->distancesPrices[lenToPosState][distance];\r
-      else\r
-      {\r
-        UInt32 slot;\r
-        GetPosSlot2(distance, slot);\r
-        curAndLenPrice += p->alignPrices[distance & kAlignMask] + p->posSlotPrices[lenToPosState][slot];\r
-      }\r
-      opt = &p->opt[len];\r
-      if (curAndLenPrice < opt->price)\r
-      {\r
-        opt->price = curAndLenPrice;\r
-        opt->posPrev = 0;\r
-        opt->backPrev = distance + LZMA_NUM_REPS;\r
-        opt->prev1IsChar = False;\r
-      }\r
-      if (len == matches[offs])\r
-      {\r
-        offs += 2;\r
-        if (offs == numPairs)\r
-          break;\r
-      }\r
-    }\r
-  }\r
-\r
-  cur = 0;\r
-\r
-    #ifdef SHOW_STAT2\r
-    /* if (position >= 0) */\r
-    {\r
-      unsigned i;\r
-      printf("\n pos = %4X", position);\r
-      for (i = cur; i <= lenEnd; i++)\r
-      printf("\nprice[%4X] = %u", position - cur + i, p->opt[i].price);\r
-    }\r
-    #endif\r
-\r
-  }\r
-\r
-  for (;;)\r
-  {\r
-    UInt32 numAvail;\r
-    UInt32 numAvailFull, newLen, numPairs, posPrev, state, posState, startLen;\r
-    UInt32 curPrice, curAnd1Price, matchPrice, repMatchPrice;\r
-    Bool nextIsChar;\r
-    Byte curByte, matchByte;\r
-    const Byte *data;\r
-    COptimal *curOpt;\r
-    COptimal *nextOpt;\r
-\r
-    cur++;\r
-    if (cur == lenEnd)\r
-      return Backward(p, backRes, cur);\r
-\r
-    newLen = ReadMatchDistances(p, &numPairs);\r
-    if (newLen >= p->numFastBytes)\r
-    {\r
-      p->numPairs = numPairs;\r
-      p->longestMatchLength = newLen;\r
-      return Backward(p, backRes, cur);\r
-    }\r
-    position++;\r
-    curOpt = &p->opt[cur];\r
-    posPrev = curOpt->posPrev;\r
-    if (curOpt->prev1IsChar)\r
-    {\r
-      posPrev--;\r
-      if (curOpt->prev2)\r
-      {\r
-        state = p->opt[curOpt->posPrev2].state;\r
-        if (curOpt->backPrev2 < LZMA_NUM_REPS)\r
-          state = kRepNextStates[state];\r
-        else\r
-          state = kMatchNextStates[state];\r
-      }\r
-      else\r
-        state = p->opt[posPrev].state;\r
-      state = kLiteralNextStates[state];\r
-    }\r
-    else\r
-      state = p->opt[posPrev].state;\r
-    if (posPrev == cur - 1)\r
-    {\r
-      if (IsShortRep(curOpt))\r
-        state = kShortRepNextStates[state];\r
-      else\r
-        state = kLiteralNextStates[state];\r
-    }\r
-    else\r
-    {\r
-      UInt32 pos;\r
-      const COptimal *prevOpt;\r
-      if (curOpt->prev1IsChar && curOpt->prev2)\r
-      {\r
-        posPrev = curOpt->posPrev2;\r
-        pos = curOpt->backPrev2;\r
-        state = kRepNextStates[state];\r
-      }\r
-      else\r
-      {\r
-        pos = curOpt->backPrev;\r
-        if (pos < LZMA_NUM_REPS)\r
-          state = kRepNextStates[state];\r
-        else\r
-          state = kMatchNextStates[state];\r
-      }\r
-      prevOpt = &p->opt[posPrev];\r
-      if (pos < LZMA_NUM_REPS)\r
-      {\r
-        UInt32 i;\r
-        reps[0] = prevOpt->backs[pos];\r
-        for (i = 1; i <= pos; i++)\r
-          reps[i] = prevOpt->backs[i - 1];\r
-        for (; i < LZMA_NUM_REPS; i++)\r
-          reps[i] = prevOpt->backs[i];\r
-      }\r
-      else\r
-      {\r
-        UInt32 i;\r
-        reps[0] = (pos - LZMA_NUM_REPS);\r
-        for (i = 1; i < LZMA_NUM_REPS; i++)\r
-          reps[i] = prevOpt->backs[i - 1];\r
-      }\r
-    }\r
-    curOpt->state = (CState)state;\r
-\r
-    curOpt->backs[0] = reps[0];\r
-    curOpt->backs[1] = reps[1];\r
-    curOpt->backs[2] = reps[2];\r
-    curOpt->backs[3] = reps[3];\r
-\r
-    curPrice = curOpt->price;\r
-    nextIsChar = False;\r
-    data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;\r
-    curByte = *data;\r
-    matchByte = *(data - (reps[0] + 1));\r
-\r
-    posState = (position & p->pbMask);\r
-\r
-    curAnd1Price = curPrice + GET_PRICE_0(p->isMatch[state][posState]);\r
-    {\r
-      const CLzmaProb *probs = LIT_PROBS(position, *(data - 1));\r
-      curAnd1Price +=\r
-        (!IsCharState(state) ?\r
-          LitEnc_GetPriceMatched(probs, curByte, matchByte, p->ProbPrices) :\r
-          LitEnc_GetPrice(probs, curByte, p->ProbPrices));\r
-    }\r
-\r
-    nextOpt = &p->opt[cur + 1];\r
-\r
-    if (curAnd1Price < nextOpt->price)\r
-    {\r
-      nextOpt->price = curAnd1Price;\r
-      nextOpt->posPrev = cur;\r
-      MakeAsChar(nextOpt);\r
-      nextIsChar = True;\r
-    }\r
-\r
-    matchPrice = curPrice + GET_PRICE_1(p->isMatch[state][posState]);\r
-    repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[state]);\r
-    \r
-    if (matchByte == curByte && !(nextOpt->posPrev < cur && nextOpt->backPrev == 0))\r
-    {\r
-      UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, state, posState);\r
-      if (shortRepPrice <= nextOpt->price)\r
-      {\r
-        nextOpt->price = shortRepPrice;\r
-        nextOpt->posPrev = cur;\r
-        MakeAsShortRep(nextOpt);\r
-        nextIsChar = True;\r
-      }\r
-    }\r
-    numAvailFull = p->numAvail;\r
-    {\r
-      UInt32 temp = kNumOpts - 1 - cur;\r
-      if (temp < numAvailFull)\r
-        numAvailFull = temp;\r
-    }\r
-\r
-    if (numAvailFull < 2)\r
-      continue;\r
-    numAvail = (numAvailFull <= p->numFastBytes ? numAvailFull : p->numFastBytes);\r
-\r
-    if (!nextIsChar && matchByte != curByte) /* speed optimization */\r
-    {\r
-      /* try Literal + rep0 */\r
-      UInt32 temp;\r
-      UInt32 lenTest2;\r
-      const Byte *data2 = data - reps[0] - 1;\r
-      UInt32 limit = p->numFastBytes + 1;\r
-      if (limit > numAvailFull)\r
-        limit = numAvailFull;\r
-\r
-      for (temp = 1; temp < limit && data[temp] == data2[temp]; temp++);\r
-      lenTest2 = temp - 1;\r
-      if (lenTest2 >= 2)\r
-      {\r
-        UInt32 state2 = kLiteralNextStates[state];\r
-        UInt32 posStateNext = (position + 1) & p->pbMask;\r
-        UInt32 nextRepMatchPrice = curAnd1Price +\r
-            GET_PRICE_1(p->isMatch[state2][posStateNext]) +\r
-            GET_PRICE_1(p->isRep[state2]);\r
-        /* for (; lenTest2 >= 2; lenTest2--) */\r
-        {\r
-          UInt32 curAndLenPrice;\r
-          COptimal *opt;\r
-          UInt32 offset = cur + 1 + lenTest2;\r
-          while (lenEnd < offset)\r
-            p->opt[++lenEnd].price = kInfinityPrice;\r
-          curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);\r
-          opt = &p->opt[offset];\r
-          if (curAndLenPrice < opt->price)\r
-          {\r
-            opt->price = curAndLenPrice;\r
-            opt->posPrev = cur + 1;\r
-            opt->backPrev = 0;\r
-            opt->prev1IsChar = True;\r
-            opt->prev2 = False;\r
-          }\r
-        }\r
-      }\r
-    }\r
-    \r
-    startLen = 2; /* speed optimization */\r
-    {\r
-    UInt32 repIndex;\r
-    for (repIndex = 0; repIndex < LZMA_NUM_REPS; repIndex++)\r
-    {\r
-      UInt32 lenTest;\r
-      UInt32 lenTestTemp;\r
-      UInt32 price;\r
-      const Byte *data2 = data - reps[repIndex] - 1;\r
-      if (data[0] != data2[0] || data[1] != data2[1])\r
-        continue;\r
-      for (lenTest = 2; lenTest < numAvail && data[lenTest] == data2[lenTest]; lenTest++);\r
-      while (lenEnd < cur + lenTest)\r
-        p->opt[++lenEnd].price = kInfinityPrice;\r
-      lenTestTemp = lenTest;\r
-      price = repMatchPrice + GetPureRepPrice(p, repIndex, state, posState);\r
-      do\r
-      {\r
-        UInt32 curAndLenPrice = price + p->repLenEnc.prices[posState][lenTest - 2];\r
-        COptimal *opt = &p->opt[cur + lenTest];\r
-        if (curAndLenPrice < opt->price)\r
-        {\r
-          opt->price = curAndLenPrice;\r
-          opt->posPrev = cur;\r
-          opt->backPrev = repIndex;\r
-          opt->prev1IsChar = False;\r
-        }\r
-      }\r
-      while (--lenTest >= 2);\r
-      lenTest = lenTestTemp;\r
-      \r
-      if (repIndex == 0)\r
-        startLen = lenTest + 1;\r
-        \r
-      /* if (_maxMode) */\r
-        {\r
-          UInt32 lenTest2 = lenTest + 1;\r
-          UInt32 limit = lenTest2 + p->numFastBytes;\r
-          if (limit > numAvailFull)\r
-            limit = numAvailFull;\r
-          for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);\r
-          lenTest2 -= lenTest + 1;\r
-          if (lenTest2 >= 2)\r
-          {\r
-            UInt32 nextRepMatchPrice;\r
-            UInt32 state2 = kRepNextStates[state];\r
-            UInt32 posStateNext = (position + lenTest) & p->pbMask;\r
-            UInt32 curAndLenCharPrice =\r
-                price + p->repLenEnc.prices[posState][lenTest - 2] +\r
-                GET_PRICE_0(p->isMatch[state2][posStateNext]) +\r
-                LitEnc_GetPriceMatched(LIT_PROBS(position + lenTest, data[lenTest - 1]),\r
-                    data[lenTest], data2[lenTest], p->ProbPrices);\r
-            state2 = kLiteralNextStates[state2];\r
-            posStateNext = (position + lenTest + 1) & p->pbMask;\r
-            nextRepMatchPrice = curAndLenCharPrice +\r
-                GET_PRICE_1(p->isMatch[state2][posStateNext]) +\r
-                GET_PRICE_1(p->isRep[state2]);\r
-            \r
-            /* for (; lenTest2 >= 2; lenTest2--) */\r
-            {\r
-              UInt32 curAndLenPrice;\r
-              COptimal *opt;\r
-              UInt32 offset = cur + lenTest + 1 + lenTest2;\r
-              while (lenEnd < offset)\r
-                p->opt[++lenEnd].price = kInfinityPrice;\r
-              curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);\r
-              opt = &p->opt[offset];\r
-              if (curAndLenPrice < opt->price)\r
-              {\r
-                opt->price = curAndLenPrice;\r
-                opt->posPrev = cur + lenTest + 1;\r
-                opt->backPrev = 0;\r
-                opt->prev1IsChar = True;\r
-                opt->prev2 = True;\r
-                opt->posPrev2 = cur;\r
-                opt->backPrev2 = repIndex;\r
-              }\r
-            }\r
-          }\r
-        }\r
-    }\r
-    }\r
-    /* for (UInt32 lenTest = 2; lenTest <= newLen; lenTest++) */\r
-    if (newLen > numAvail)\r
-    {\r
-      newLen = numAvail;\r
-      for (numPairs = 0; newLen > matches[numPairs]; numPairs += 2);\r
-      matches[numPairs] = newLen;\r
-      numPairs += 2;\r
-    }\r
-    if (newLen >= startLen)\r
-    {\r
-      UInt32 normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[state]);\r
-      UInt32 offs, curBack, posSlot;\r
-      UInt32 lenTest;\r
-      while (lenEnd < cur + newLen)\r
-        p->opt[++lenEnd].price = kInfinityPrice;\r
-\r
-      offs = 0;\r
-      while (startLen > matches[offs])\r
-        offs += 2;\r
-      curBack = matches[offs + 1];\r
-      GetPosSlot2(curBack, posSlot);\r
-      for (lenTest = /*2*/ startLen; ; lenTest++)\r
-      {\r
-        UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][lenTest - LZMA_MATCH_LEN_MIN];\r
-        {\r
-        UInt32 lenToPosState = GetLenToPosState(lenTest);\r
-        COptimal *opt;\r
-        if (curBack < kNumFullDistances)\r
-          curAndLenPrice += p->distancesPrices[lenToPosState][curBack];\r
-        else\r
-          curAndLenPrice += p->posSlotPrices[lenToPosState][posSlot] + p->alignPrices[curBack & kAlignMask];\r
-        \r
-        opt = &p->opt[cur + lenTest];\r
-        if (curAndLenPrice < opt->price)\r
-        {\r
-          opt->price = curAndLenPrice;\r
-          opt->posPrev = cur;\r
-          opt->backPrev = curBack + LZMA_NUM_REPS;\r
-          opt->prev1IsChar = False;\r
-        }\r
-        }\r
-\r
-        if (/*_maxMode && */lenTest == matches[offs])\r
-        {\r
-          /* Try Match + Literal + Rep0 */\r
-          const Byte *data2 = data - curBack - 1;\r
-          UInt32 lenTest2 = lenTest + 1;\r
-          UInt32 limit = lenTest2 + p->numFastBytes;\r
-          if (limit > numAvailFull)\r
-            limit = numAvailFull;\r
-          for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);\r
-          lenTest2 -= lenTest + 1;\r
-          if (lenTest2 >= 2)\r
-          {\r
-            UInt32 nextRepMatchPrice;\r
-            UInt32 state2 = kMatchNextStates[state];\r
-            UInt32 posStateNext = (position + lenTest) & p->pbMask;\r
-            UInt32 curAndLenCharPrice = curAndLenPrice +\r
-                GET_PRICE_0(p->isMatch[state2][posStateNext]) +\r
-                LitEnc_GetPriceMatched(LIT_PROBS(position + lenTest, data[lenTest - 1]),\r
-                    data[lenTest], data2[lenTest], p->ProbPrices);\r
-            state2 = kLiteralNextStates[state2];\r
-            posStateNext = (posStateNext + 1) & p->pbMask;\r
-            nextRepMatchPrice = curAndLenCharPrice +\r
-                GET_PRICE_1(p->isMatch[state2][posStateNext]) +\r
-                GET_PRICE_1(p->isRep[state2]);\r
-            \r
-            /* for (; lenTest2 >= 2; lenTest2--) */\r
-            {\r
-              UInt32 offset = cur + lenTest + 1 + lenTest2;\r
-              UInt32 curAndLenPrice2;\r
-              COptimal *opt;\r
-              while (lenEnd < offset)\r
-                p->opt[++lenEnd].price = kInfinityPrice;\r
-              curAndLenPrice2 = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);\r
-              opt = &p->opt[offset];\r
-              if (curAndLenPrice2 < opt->price)\r
-              {\r
-                opt->price = curAndLenPrice2;\r
-                opt->posPrev = cur + lenTest + 1;\r
-                opt->backPrev = 0;\r
-                opt->prev1IsChar = True;\r
-                opt->prev2 = True;\r
-                opt->posPrev2 = cur;\r
-                opt->backPrev2 = curBack + LZMA_NUM_REPS;\r
-              }\r
-            }\r
-          }\r
-          offs += 2;\r
-          if (offs == numPairs)\r
-            break;\r
-          curBack = matches[offs + 1];\r
-          if (curBack >= kNumFullDistances)\r
-            GetPosSlot2(curBack, posSlot);\r
-        }\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-#define ChangePair(smallDist, bigDist) (((bigDist) >> 7) > (smallDist))\r
-\r
-static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes)\r
-{\r
-  UInt32 numAvail, mainLen, mainDist, numPairs, repIndex, repLen, i;\r
-  const Byte *data;\r
-  const UInt32 *matches;\r
-\r
-  if (p->additionalOffset == 0)\r
-    mainLen = ReadMatchDistances(p, &numPairs);\r
-  else\r
-  {\r
-    mainLen = p->longestMatchLength;\r
-    numPairs = p->numPairs;\r
-  }\r
-\r
-  numAvail = p->numAvail;\r
-  *backRes = (UInt32)-1;\r
-  if (numAvail < 2)\r
-    return 1;\r
-  if (numAvail > LZMA_MATCH_LEN_MAX)\r
-    numAvail = LZMA_MATCH_LEN_MAX;\r
-  data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;\r
-\r
-  repLen = repIndex = 0;\r
-  for (i = 0; i < LZMA_NUM_REPS; i++)\r
-  {\r
-    UInt32 len;\r
-    const Byte *data2 = data - p->reps[i] - 1;\r
-    if (data[0] != data2[0] || data[1] != data2[1])\r
-      continue;\r
-    for (len = 2; len < numAvail && data[len] == data2[len]; len++);\r
-    if (len >= p->numFastBytes)\r
-    {\r
-      *backRes = i;\r
-      MovePos(p, len - 1);\r
-      return len;\r
-    }\r
-    if (len > repLen)\r
-    {\r
-      repIndex = i;\r
-      repLen = len;\r
-    }\r
-  }\r
-\r
-  matches = p->matches;\r
-  if (mainLen >= p->numFastBytes)\r
-  {\r
-    *backRes = matches[numPairs - 1] + LZMA_NUM_REPS;\r
-    MovePos(p, mainLen - 1);\r
-    return mainLen;\r
-  }\r
-\r
-  mainDist = 0; /* for GCC */\r
-  if (mainLen >= 2)\r
-  {\r
-    mainDist = matches[numPairs - 1];\r
-    while (numPairs > 2 && mainLen == matches[numPairs - 4] + 1)\r
-    {\r
-      if (!ChangePair(matches[numPairs - 3], mainDist))\r
-        break;\r
-      numPairs -= 2;\r
-      mainLen = matches[numPairs - 2];\r
-      mainDist = matches[numPairs - 1];\r
-    }\r
-    if (mainLen == 2 && mainDist >= 0x80)\r
-      mainLen = 1;\r
-  }\r
-\r
-  if (repLen >= 2 && (\r
-        (repLen + 1 >= mainLen) ||\r
-        (repLen + 2 >= mainLen && mainDist >= (1 << 9)) ||\r
-        (repLen + 3 >= mainLen && mainDist >= (1 << 15))))\r
-  {\r
-    *backRes = repIndex;\r
-    MovePos(p, repLen - 1);\r
-    return repLen;\r
-  }\r
-  \r
-  if (mainLen < 2 || numAvail <= 2)\r
-    return 1;\r
-\r
-  p->longestMatchLength = ReadMatchDistances(p, &p->numPairs);\r
-  if (p->longestMatchLength >= 2)\r
-  {\r
-    UInt32 newDistance = matches[p->numPairs - 1];\r
-    if ((p->longestMatchLength >= mainLen && newDistance < mainDist) ||\r
-        (p->longestMatchLength == mainLen + 1 && !ChangePair(mainDist, newDistance)) ||\r
-        (p->longestMatchLength > mainLen + 1) ||\r
-        (p->longestMatchLength + 1 >= mainLen && mainLen >= 3 && ChangePair(newDistance, mainDist)))\r
-      return 1;\r
-  }\r
-  \r
-  data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1;\r
-  for (i = 0; i < LZMA_NUM_REPS; i++)\r
-  {\r
-    UInt32 len, limit;\r
-    const Byte *data2 = data - p->reps[i] - 1;\r
-    if (data[0] != data2[0] || data[1] != data2[1])\r
-      continue;\r
-    limit = mainLen - 1;\r
-    for (len = 2; len < limit && data[len] == data2[len]; len++);\r
-    if (len >= limit)\r
-      return 1;\r
-  }\r
-  *backRes = mainDist + LZMA_NUM_REPS;\r
-  MovePos(p, mainLen - 2);\r
-  return mainLen;\r
-}\r
-\r
-static void WriteEndMarker(CLzmaEnc *p, UInt32 posState)\r
-{\r
-  UInt32 len;\r
-  RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 1);\r
-  RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0);\r
-  p->state = kMatchNextStates[p->state];\r
-  len = LZMA_MATCH_LEN_MIN;\r
-  LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices);\r
-  RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, (1 << kNumPosSlotBits) - 1);\r
-  RangeEnc_EncodeDirectBits(&p->rc, (((UInt32)1 << 30) - 1) >> kNumAlignBits, 30 - kNumAlignBits);\r
-  RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, kAlignMask);\r
-}\r
-\r
-static SRes CheckErrors(CLzmaEnc *p)\r
-{\r
-  if (p->result != SZ_OK)\r
-    return p->result;\r
-  if (p->rc.res != SZ_OK)\r
-    p->result = SZ_ERROR_WRITE;\r
-  if (p->matchFinderBase.result != SZ_OK)\r
-    p->result = SZ_ERROR_READ;\r
-  if (p->result != SZ_OK)\r
-    p->finished = True;\r
-  return p->result;\r
-}\r
-\r
-static SRes Flush(CLzmaEnc *p, UInt32 nowPos)\r
-{\r
-  /* ReleaseMFStream(); */\r
-  p->finished = True;\r
-  if (p->writeEndMark)\r
-    WriteEndMarker(p, nowPos & p->pbMask);\r
-  RangeEnc_FlushData(&p->rc);\r
-  RangeEnc_FlushStream(&p->rc);\r
-  return CheckErrors(p);\r
-}\r
-\r
-static void FillAlignPrices(CLzmaEnc *p)\r
-{\r
-  UInt32 i;\r
-  for (i = 0; i < kAlignTableSize; i++)\r
-    p->alignPrices[i] = RcTree_ReverseGetPrice(p->posAlignEncoder, kNumAlignBits, i, p->ProbPrices);\r
-  p->alignPriceCount = 0;\r
-}\r
-\r
-static void FillDistancesPrices(CLzmaEnc *p)\r
-{\r
-  UInt32 tempPrices[kNumFullDistances];\r
-  UInt32 i, lenToPosState;\r
-  for (i = kStartPosModelIndex; i < kNumFullDistances; i++)\r
-  {\r
-    UInt32 posSlot = GetPosSlot1(i);\r
-    UInt32 footerBits = ((posSlot >> 1) - 1);\r
-    UInt32 base = ((2 | (posSlot & 1)) << footerBits);\r
-    tempPrices[i] = RcTree_ReverseGetPrice(p->posEncoders + base - posSlot - 1, footerBits, i - base, p->ProbPrices);\r
-  }\r
-\r
-  for (lenToPosState = 0; lenToPosState < kNumLenToPosStates; lenToPosState++)\r
-  {\r
-    UInt32 posSlot;\r
-    const CLzmaProb *encoder = p->posSlotEncoder[lenToPosState];\r
-    UInt32 *posSlotPrices = p->posSlotPrices[lenToPosState];\r
-    for (posSlot = 0; posSlot < p->distTableSize; posSlot++)\r
-      posSlotPrices[posSlot] = RcTree_GetPrice(encoder, kNumPosSlotBits, posSlot, p->ProbPrices);\r
-    for (posSlot = kEndPosModelIndex; posSlot < p->distTableSize; posSlot++)\r
-      posSlotPrices[posSlot] += ((((posSlot >> 1) - 1) - kNumAlignBits) << kNumBitPriceShiftBits);\r
-\r
-    {\r
-      UInt32 *distancesPrices = p->distancesPrices[lenToPosState];\r
-      for (i = 0; i < kStartPosModelIndex; i++)\r
-        distancesPrices[i] = posSlotPrices[i];\r
-      for (; i < kNumFullDistances; i++)\r
-        distancesPrices[i] = posSlotPrices[GetPosSlot1(i)] + tempPrices[i];\r
-    }\r
-  }\r
-  p->matchPriceCount = 0;\r
-}\r
-\r
-void LzmaEnc_Construct(CLzmaEnc *p)\r
-{\r
-  RangeEnc_Construct(&p->rc);\r
-  MatchFinder_Construct(&p->matchFinderBase);\r
-  \r
-  #ifndef _7ZIP_ST\r
-  MatchFinderMt_Construct(&p->matchFinderMt);\r
-  p->matchFinderMt.MatchFinder = &p->matchFinderBase;\r
-  #endif\r
-\r
-  {\r
-    CLzmaEncProps props;\r
-    LzmaEncProps_Init(&props);\r
-    LzmaEnc_SetProps(p, &props);\r
-  }\r
-\r
-  #ifndef LZMA_LOG_BSR\r
-  LzmaEnc_FastPosInit(p->g_FastPos);\r
-  #endif\r
-\r
-  LzmaEnc_InitPriceTables(p->ProbPrices);\r
-  p->litProbs = NULL;\r
-  p->saveState.litProbs = NULL;\r
-}\r
-\r
-CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc)\r
-{\r
-  void *p;\r
-  p = alloc->Alloc(alloc, sizeof(CLzmaEnc));\r
-  if (p)\r
-    LzmaEnc_Construct((CLzmaEnc *)p);\r
-  return p;\r
-}\r
-\r
-void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)\r
-{\r
-  alloc->Free(alloc, p->litProbs);\r
-  alloc->Free(alloc, p->saveState.litProbs);\r
-  p->litProbs = NULL;\r
-  p->saveState.litProbs = NULL;\r
-}\r
-\r
-void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)\r
-{\r
-  #ifndef _7ZIP_ST\r
-  MatchFinderMt_Destruct(&p->matchFinderMt, allocBig);\r
-  #endif\r
-  \r
-  MatchFinder_Free(&p->matchFinderBase, allocBig);\r
-  LzmaEnc_FreeLits(p, alloc);\r
-  RangeEnc_Free(&p->rc, alloc);\r
-}\r
-\r
-void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig)\r
-{\r
-  LzmaEnc_Destruct((CLzmaEnc *)p, alloc, allocBig);\r
-  alloc->Free(alloc, p);\r
-}\r
-\r
-static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize, UInt32 maxUnpackSize)\r
-{\r
-  UInt32 nowPos32, startPos32;\r
-  if (p->needInit)\r
-  {\r
-    p->matchFinder.Init(p->matchFinderObj);\r
-    p->needInit = 0;\r
-  }\r
-\r
-  if (p->finished)\r
-    return p->result;\r
-  RINOK(CheckErrors(p));\r
-\r
-  nowPos32 = (UInt32)p->nowPos64;\r
-  startPos32 = nowPos32;\r
-\r
-  if (p->nowPos64 == 0)\r
-  {\r
-    UInt32 numPairs;\r
-    Byte curByte;\r
-    if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0)\r
-      return Flush(p, nowPos32);\r
-    ReadMatchDistances(p, &numPairs);\r
-    RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][0], 0);\r
-    p->state = kLiteralNextStates[p->state];\r
-    curByte = *(p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset);\r
-    LitEnc_Encode(&p->rc, p->litProbs, curByte);\r
-    p->additionalOffset--;\r
-    nowPos32++;\r
-  }\r
-\r
-  if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) != 0)\r
-  for (;;)\r
-  {\r
-    UInt32 pos, len, posState;\r
-\r
-    if (p->fastMode)\r
-      len = GetOptimumFast(p, &pos);\r
-    else\r
-      len = GetOptimum(p, nowPos32, &pos);\r
-\r
-    #ifdef SHOW_STAT2\r
-    printf("\n pos = %4X,   len = %u   pos = %u", nowPos32, len, pos);\r
-    #endif\r
-\r
-    posState = nowPos32 & p->pbMask;\r
-    if (len == 1 && pos == (UInt32)-1)\r
-    {\r
-      Byte curByte;\r
-      CLzmaProb *probs;\r
-      const Byte *data;\r
-\r
-      RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 0);\r
-      data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset;\r
-      curByte = *data;\r
-      probs = LIT_PROBS(nowPos32, *(data - 1));\r
-      if (IsCharState(p->state))\r
-        LitEnc_Encode(&p->rc, probs, curByte);\r
-      else\r
-        LitEnc_EncodeMatched(&p->rc, probs, curByte, *(data - p->reps[0] - 1));\r
-      p->state = kLiteralNextStates[p->state];\r
-    }\r
-    else\r
-    {\r
-      RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 1);\r
-      if (pos < LZMA_NUM_REPS)\r
-      {\r
-        RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 1);\r
-        if (pos == 0)\r
-        {\r
-          RangeEnc_EncodeBit(&p->rc, &p->isRepG0[p->state], 0);\r
-          RangeEnc_EncodeBit(&p->rc, &p->isRep0Long[p->state][posState], ((len == 1) ? 0 : 1));\r
-        }\r
-        else\r
-        {\r
-          UInt32 distance = p->reps[pos];\r
-          RangeEnc_EncodeBit(&p->rc, &p->isRepG0[p->state], 1);\r
-          if (pos == 1)\r
-            RangeEnc_EncodeBit(&p->rc, &p->isRepG1[p->state], 0);\r
-          else\r
-          {\r
-            RangeEnc_EncodeBit(&p->rc, &p->isRepG1[p->state], 1);\r
-            RangeEnc_EncodeBit(&p->rc, &p->isRepG2[p->state], pos - 2);\r
-            if (pos == 3)\r
-              p->reps[3] = p->reps[2];\r
-            p->reps[2] = p->reps[1];\r
-          }\r
-          p->reps[1] = p->reps[0];\r
-          p->reps[0] = distance;\r
-        }\r
-        if (len == 1)\r
-          p->state = kShortRepNextStates[p->state];\r
-        else\r
-        {\r
-          LenEnc_Encode2(&p->repLenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices);\r
-          p->state = kRepNextStates[p->state];\r
-        }\r
-      }\r
-      else\r
-      {\r
-        UInt32 posSlot;\r
-        RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0);\r
-        p->state = kMatchNextStates[p->state];\r
-        LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices);\r
-        pos -= LZMA_NUM_REPS;\r
-        GetPosSlot(pos, posSlot);\r
-        RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, posSlot);\r
-        \r
-        if (posSlot >= kStartPosModelIndex)\r
-        {\r
-          UInt32 footerBits = ((posSlot >> 1) - 1);\r
-          UInt32 base = ((2 | (posSlot & 1)) << footerBits);\r
-          UInt32 posReduced = pos - base;\r
-\r
-          if (posSlot < kEndPosModelIndex)\r
-            RcTree_ReverseEncode(&p->rc, p->posEncoders + base - posSlot - 1, footerBits, posReduced);\r
-          else\r
-          {\r
-            RangeEnc_EncodeDirectBits(&p->rc, posReduced >> kNumAlignBits, footerBits - kNumAlignBits);\r
-            RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, posReduced & kAlignMask);\r
-            p->alignPriceCount++;\r
-          }\r
-        }\r
-        p->reps[3] = p->reps[2];\r
-        p->reps[2] = p->reps[1];\r
-        p->reps[1] = p->reps[0];\r
-        p->reps[0] = pos;\r
-        p->matchPriceCount++;\r
-      }\r
-    }\r
-    p->additionalOffset -= len;\r
-    nowPos32 += len;\r
-    if (p->additionalOffset == 0)\r
-    {\r
-      UInt32 processed;\r
-      if (!p->fastMode)\r
-      {\r
-        if (p->matchPriceCount >= (1 << 7))\r
-          FillDistancesPrices(p);\r
-        if (p->alignPriceCount >= kAlignTableSize)\r
-          FillAlignPrices(p);\r
-      }\r
-      if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0)\r
-        break;\r
-      processed = nowPos32 - startPos32;\r
-      if (useLimits)\r
-      {\r
-        if (processed + kNumOpts + 300 >= maxUnpackSize ||\r
-            RangeEnc_GetProcessed(&p->rc) + kNumOpts * 2 >= maxPackSize)\r
-          break;\r
-      }\r
-      else if (processed >= (1 << 17))\r
-      {\r
-        p->nowPos64 += nowPos32 - startPos32;\r
-        return CheckErrors(p);\r
-      }\r
-    }\r
-  }\r
-  p->nowPos64 += nowPos32 - startPos32;\r
-  return Flush(p, nowPos32);\r
-}\r
-\r
-#define kBigHashDicLimit ((UInt32)1 << 24)\r
-\r
-static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)\r
-{\r
-  UInt32 beforeSize = kNumOpts;\r
-  if (!RangeEnc_Alloc(&p->rc, alloc))\r
-    return SZ_ERROR_MEM;\r
-\r
-  #ifndef _7ZIP_ST\r
-  p->mtMode = (p->multiThread && !p->fastMode && (p->matchFinderBase.btMode != 0));\r
-  #endif\r
-\r
-  {\r
-    unsigned lclp = p->lc + p->lp;\r
-    if (!p->litProbs || !p->saveState.litProbs || p->lclp != lclp)\r
-    {\r
-      LzmaEnc_FreeLits(p, alloc);\r
-      p->litProbs = (CLzmaProb *)alloc->Alloc(alloc, ((UInt32)0x300 << lclp) * sizeof(CLzmaProb));\r
-      p->saveState.litProbs = (CLzmaProb *)alloc->Alloc(alloc, ((UInt32)0x300 << lclp) * sizeof(CLzmaProb));\r
-      if (!p->litProbs || !p->saveState.litProbs)\r
-      {\r
-        LzmaEnc_FreeLits(p, alloc);\r
-        return SZ_ERROR_MEM;\r
-      }\r
-      p->lclp = lclp;\r
-    }\r
-  }\r
-\r
-  p->matchFinderBase.bigHash = (Byte)(p->dictSize > kBigHashDicLimit ? 1 : 0);\r
-\r
-  if (beforeSize + p->dictSize < keepWindowSize)\r
-    beforeSize = keepWindowSize - p->dictSize;\r
-\r
-  #ifndef _7ZIP_ST\r
-  if (p->mtMode)\r
-  {\r
-    RINOK(MatchFinderMt_Create(&p->matchFinderMt, p->dictSize, beforeSize, p->numFastBytes, LZMA_MATCH_LEN_MAX, allocBig));\r
-    p->matchFinderObj = &p->matchFinderMt;\r
-    MatchFinderMt_CreateVTable(&p->matchFinderMt, &p->matchFinder);\r
-  }\r
-  else\r
-  #endif\r
-  {\r
-    if (!MatchFinder_Create(&p->matchFinderBase, p->dictSize, beforeSize, p->numFastBytes, LZMA_MATCH_LEN_MAX, allocBig))\r
-      return SZ_ERROR_MEM;\r
-    p->matchFinderObj = &p->matchFinderBase;\r
-    MatchFinder_CreateVTable(&p->matchFinderBase, &p->matchFinder);\r
-  }\r
-  \r
-  return SZ_OK;\r
-}\r
-\r
-void LzmaEnc_Init(CLzmaEnc *p)\r
-{\r
-  UInt32 i;\r
-  p->state = 0;\r
-  for (i = 0 ; i < LZMA_NUM_REPS; i++)\r
-    p->reps[i] = 0;\r
-\r
-  RangeEnc_Init(&p->rc);\r
-\r
-\r
-  for (i = 0; i < kNumStates; i++)\r
-  {\r
-    UInt32 j;\r
-    for (j = 0; j < LZMA_NUM_PB_STATES_MAX; j++)\r
-    {\r
-      p->isMatch[i][j] = kProbInitValue;\r
-      p->isRep0Long[i][j] = kProbInitValue;\r
-    }\r
-    p->isRep[i] = kProbInitValue;\r
-    p->isRepG0[i] = kProbInitValue;\r
-    p->isRepG1[i] = kProbInitValue;\r
-    p->isRepG2[i] = kProbInitValue;\r
-  }\r
-\r
-  {\r
-    UInt32 num = (UInt32)0x300 << (p->lp + p->lc);\r
-    CLzmaProb *probs = p->litProbs;\r
-    for (i = 0; i < num; i++)\r
-      probs[i] = kProbInitValue;\r
-  }\r
-\r
-  {\r
-    for (i = 0; i < kNumLenToPosStates; i++)\r
-    {\r
-      CLzmaProb *probs = p->posSlotEncoder[i];\r
-      UInt32 j;\r
-      for (j = 0; j < (1 << kNumPosSlotBits); j++)\r
-        probs[j] = kProbInitValue;\r
-    }\r
-  }\r
-  {\r
-    for (i = 0; i < kNumFullDistances - kEndPosModelIndex; i++)\r
-      p->posEncoders[i] = kProbInitValue;\r
-  }\r
-\r
-  LenEnc_Init(&p->lenEnc.p);\r
-  LenEnc_Init(&p->repLenEnc.p);\r
-\r
-  for (i = 0; i < (1 << kNumAlignBits); i++)\r
-    p->posAlignEncoder[i] = kProbInitValue;\r
-\r
-  p->optimumEndIndex = 0;\r
-  p->optimumCurrentIndex = 0;\r
-  p->additionalOffset = 0;\r
-\r
-  p->pbMask = (1 << p->pb) - 1;\r
-  p->lpMask = (1 << p->lp) - 1;\r
-}\r
-\r
-void LzmaEnc_InitPrices(CLzmaEnc *p)\r
-{\r
-  if (!p->fastMode)\r
-  {\r
-    FillDistancesPrices(p);\r
-    FillAlignPrices(p);\r
-  }\r
-\r
-  p->lenEnc.tableSize =\r
-  p->repLenEnc.tableSize =\r
-      p->numFastBytes + 1 - LZMA_MATCH_LEN_MIN;\r
-  LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, p->ProbPrices);\r
-  LenPriceEnc_UpdateTables(&p->repLenEnc, 1 << p->pb, p->ProbPrices);\r
-}\r
-\r
-static SRes LzmaEnc_AllocAndInit(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)\r
-{\r
-  UInt32 i;\r
-  for (i = 0; i < (UInt32)kDicLogSizeMaxCompress; i++)\r
-    if (p->dictSize <= ((UInt32)1 << i))\r
-      break;\r
-  p->distTableSize = i * 2;\r
-\r
-  p->finished = False;\r
-  p->result = SZ_OK;\r
-  RINOK(LzmaEnc_Alloc(p, keepWindowSize, alloc, allocBig));\r
-  LzmaEnc_Init(p);\r
-  LzmaEnc_InitPrices(p);\r
-  p->nowPos64 = 0;\r
-  return SZ_OK;\r
-}\r
-\r
-static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream,\r
-    ISzAlloc *alloc, ISzAlloc *allocBig)\r
-{\r
-  CLzmaEnc *p = (CLzmaEnc *)pp;\r
-  p->matchFinderBase.stream = inStream;\r
-  p->needInit = 1;\r
-  p->rc.outStream = outStream;\r
-  return LzmaEnc_AllocAndInit(p, 0, alloc, allocBig);\r
-}\r
-\r
-SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp,\r
-    ISeqInStream *inStream, UInt32 keepWindowSize,\r
-    ISzAlloc *alloc, ISzAlloc *allocBig)\r
-{\r
-  CLzmaEnc *p = (CLzmaEnc *)pp;\r
-  p->matchFinderBase.stream = inStream;\r
-  p->needInit = 1;\r
-  return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig);\r
-}\r
-\r
-static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const Byte *src, SizeT srcLen)\r
-{\r
-  p->matchFinderBase.directInput = 1;\r
-  p->matchFinderBase.bufferBase = (Byte *)src;\r
-  p->matchFinderBase.directInputRem = srcLen;\r
-}\r
-\r
-SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,\r
-    UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)\r
-{\r
-  CLzmaEnc *p = (CLzmaEnc *)pp;\r
-  LzmaEnc_SetInputBuf(p, src, srcLen);\r
-  p->needInit = 1;\r
-\r
-  return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig);\r
-}\r
-\r
-void LzmaEnc_Finish(CLzmaEncHandle pp)\r
-{\r
-  #ifndef _7ZIP_ST\r
-  CLzmaEnc *p = (CLzmaEnc *)pp;\r
-  if (p->mtMode)\r
-    MatchFinderMt_ReleaseStream(&p->matchFinderMt);\r
-  #else\r
-  UNUSED_VAR(pp);\r
-  #endif\r
-}\r
-\r
-\r
-typedef struct\r
-{\r
-  ISeqOutStream funcTable;\r
-  Byte *data;\r
-  SizeT rem;\r
-  Bool overflow;\r
-} CSeqOutStreamBuf;\r
-\r
-static size_t MyWrite(void *pp, const void *data, size_t size)\r
-{\r
-  CSeqOutStreamBuf *p = (CSeqOutStreamBuf *)pp;\r
-  if (p->rem < size)\r
-  {\r
-    size = p->rem;\r
-    p->overflow = True;\r
-  }\r
-  memcpy(p->data, data, size);\r
-  p->rem -= size;\r
-  p->data += size;\r
-  return size;\r
-}\r
-\r
-\r
-UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp)\r
-{\r
-  const CLzmaEnc *p = (CLzmaEnc *)pp;\r
-  return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);\r
-}\r
-\r
-\r
-const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp)\r
-{\r
-  const CLzmaEnc *p = (CLzmaEnc *)pp;\r
-  return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset;\r
-}\r
-\r
-\r
-SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit,\r
-    Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize)\r
-{\r
-  CLzmaEnc *p = (CLzmaEnc *)pp;\r
-  UInt64 nowPos64;\r
-  SRes res;\r
-  CSeqOutStreamBuf outStream;\r
-\r
-  outStream.funcTable.Write = MyWrite;\r
-  outStream.data = dest;\r
-  outStream.rem = *destLen;\r
-  outStream.overflow = False;\r
-\r
-  p->writeEndMark = False;\r
-  p->finished = False;\r
-  p->result = SZ_OK;\r
-\r
-  if (reInit)\r
-    LzmaEnc_Init(p);\r
-  LzmaEnc_InitPrices(p);\r
-  nowPos64 = p->nowPos64;\r
-  RangeEnc_Init(&p->rc);\r
-  p->rc.outStream = &outStream.funcTable;\r
-\r
-  res = LzmaEnc_CodeOneBlock(p, True, desiredPackSize, *unpackSize);\r
-  \r
-  *unpackSize = (UInt32)(p->nowPos64 - nowPos64);\r
-  *destLen -= outStream.rem;\r
-  if (outStream.overflow)\r
-    return SZ_ERROR_OUTPUT_EOF;\r
-\r
-  return res;\r
-}\r
-\r
-\r
-static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress)\r
-{\r
-  SRes res = SZ_OK;\r
-\r
-  #ifndef _7ZIP_ST\r
-  Byte allocaDummy[0x300];\r
-  allocaDummy[0] = 0;\r
-  allocaDummy[1] = allocaDummy[0];\r
-  #endif\r
-\r
-  for (;;)\r
-  {\r
-    res = LzmaEnc_CodeOneBlock(p, False, 0, 0);\r
-    if (res != SZ_OK || p->finished)\r
-      break;\r
-    if (progress)\r
-    {\r
-      res = progress->Progress(progress, p->nowPos64, RangeEnc_GetProcessed(&p->rc));\r
-      if (res != SZ_OK)\r
-      {\r
-        res = SZ_ERROR_PROGRESS;\r
-        break;\r
-      }\r
-    }\r
-  }\r
-  \r
-  LzmaEnc_Finish(p);\r
-\r
-  /*\r
-  if (res == S_OK && !Inline_MatchFinder_IsFinishedOK(&p->matchFinderBase))\r
-    res = SZ_ERROR_FAIL;\r
-  }\r
-  */\r
-\r
-  return res;\r
-}\r
-\r
-\r
-SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress,\r
-    ISzAlloc *alloc, ISzAlloc *allocBig)\r
-{\r
-  RINOK(LzmaEnc_Prepare(pp, outStream, inStream, alloc, allocBig));\r
-  return LzmaEnc_Encode2((CLzmaEnc *)pp, progress);\r
-}\r
-\r
-\r
-SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size)\r
-{\r
-  CLzmaEnc *p = (CLzmaEnc *)pp;\r
-  unsigned i;\r
-  UInt32 dictSize = p->dictSize;\r
-  if (*size < LZMA_PROPS_SIZE)\r
-    return SZ_ERROR_PARAM;\r
-  *size = LZMA_PROPS_SIZE;\r
-  props[0] = (Byte)((p->pb * 5 + p->lp) * 9 + p->lc);\r
-\r
-  if (dictSize >= ((UInt32)1 << 22))\r
-  {\r
-    UInt32 kDictMask = ((UInt32)1 << 20) - 1;\r
-    if (dictSize < (UInt32)0xFFFFFFFF - kDictMask)\r
-      dictSize = (dictSize + kDictMask) & ~kDictMask;\r
-  }\r
-  else for (i = 11; i <= 30; i++)\r
-  {\r
-    if (dictSize <= ((UInt32)2 << i)) { dictSize = (2 << i); break; }\r
-    if (dictSize <= ((UInt32)3 << i)) { dictSize = (3 << i); break; }\r
-  }\r
-\r
-  for (i = 0; i < 4; i++)\r
-    props[1 + i] = (Byte)(dictSize >> (8 * i));\r
-  return SZ_OK;\r
-}\r
-\r
-\r
-SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,\r
-    int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)\r
-{\r
-  SRes res;\r
-  CLzmaEnc *p = (CLzmaEnc *)pp;\r
-\r
-  CSeqOutStreamBuf outStream;\r
-\r
-  outStream.funcTable.Write = MyWrite;\r
-  outStream.data = dest;\r
-  outStream.rem = *destLen;\r
-  outStream.overflow = False;\r
-\r
-  p->writeEndMark = writeEndMark;\r
-  p->rc.outStream = &outStream.funcTable;\r
-\r
-  res = LzmaEnc_MemPrepare(pp, src, srcLen, 0, alloc, allocBig);\r
-  \r
-  if (res == SZ_OK)\r
-  {\r
-    res = LzmaEnc_Encode2(p, progress);\r
-    if (res == SZ_OK && p->nowPos64 != srcLen)\r
-      res = SZ_ERROR_FAIL;\r
-  }\r
-\r
-  *destLen -= outStream.rem;\r
-  if (outStream.overflow)\r
-    return SZ_ERROR_OUTPUT_EOF;\r
-  return res;\r
-}\r
-\r
-\r
-SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,\r
-    const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,\r
-    ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)\r
-{\r
-  CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc);\r
-  SRes res;\r
-  if (!p)\r
-    return SZ_ERROR_MEM;\r
-\r
-  res = LzmaEnc_SetProps(p, props);\r
-  if (res == SZ_OK)\r
-  {\r
-    res = LzmaEnc_WriteProperties(p, propsEncoded, propsSize);\r
-    if (res == SZ_OK)\r
-      res = LzmaEnc_MemEncode(p, dest, destLen, src, srcLen,\r
-          writeEndMark, progress, alloc, allocBig);\r
-  }\r
-\r
-  LzmaEnc_Destroy(p, alloc, allocBig);\r
-  return res;\r
-}\r
diff --git a/deps/lzma-16.04/C/LzmaEnc.h b/deps/lzma-16.04/C/LzmaEnc.h
deleted file mode 100644 (file)
index c2806b4..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*  LzmaEnc.h -- LZMA Encoder\r
-2013-01-18 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __LZMA_ENC_H\r
-#define __LZMA_ENC_H\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-#define LZMA_PROPS_SIZE 5\r
-\r
-typedef struct _CLzmaEncProps\r
-{\r
-  int level;       /*  0 <= level <= 9 */\r
-  UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version\r
-                      (1 << 12) <= dictSize <= (1 << 30) for 64-bit version\r
-                       default = (1 << 24) */\r
-  UInt64 reduceSize; /* estimated size of data that will be compressed. default = 0xFFFFFFFF.\r
-                        Encoder uses this value to reduce dictionary size */\r
-  int lc;          /* 0 <= lc <= 8, default = 3 */\r
-  int lp;          /* 0 <= lp <= 4, default = 0 */\r
-  int pb;          /* 0 <= pb <= 4, default = 2 */\r
-  int algo;        /* 0 - fast, 1 - normal, default = 1 */\r
-  int fb;          /* 5 <= fb <= 273, default = 32 */\r
-  int btMode;      /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */\r
-  int numHashBytes; /* 2, 3 or 4, default = 4 */\r
-  UInt32 mc;        /* 1 <= mc <= (1 << 30), default = 32 */\r
-  unsigned writeEndMark;  /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */\r
-  int numThreads;  /* 1 or 2, default = 2 */\r
-} CLzmaEncProps;\r
-\r
-void LzmaEncProps_Init(CLzmaEncProps *p);\r
-void LzmaEncProps_Normalize(CLzmaEncProps *p);\r
-UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);\r
-\r
-\r
-/* ---------- CLzmaEncHandle Interface ---------- */\r
-\r
-/* LzmaEnc_* functions can return the following exit codes:\r
-Returns:\r
-  SZ_OK           - OK\r
-  SZ_ERROR_MEM    - Memory allocation error\r
-  SZ_ERROR_PARAM  - Incorrect paramater in props\r
-  SZ_ERROR_WRITE  - Write callback error.\r
-  SZ_ERROR_PROGRESS - some break from progress callback\r
-  SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)\r
-*/\r
-\r
-typedef void * CLzmaEncHandle;\r
-\r
-CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc);\r
-void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig);\r
-SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);\r
-SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);\r
-SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,\r
-    ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);\r
-SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,\r
-    int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);\r
-\r
-/* ---------- One Call Interface ---------- */\r
-\r
-/* LzmaEncode\r
-Return code:\r
-  SZ_OK               - OK\r
-  SZ_ERROR_MEM        - Memory allocation error\r
-  SZ_ERROR_PARAM      - Incorrect paramater\r
-  SZ_ERROR_OUTPUT_EOF - output buffer overflow\r
-  SZ_ERROR_THREAD     - errors in multithreading functions (only for Mt version)\r
-*/\r
-\r
-SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,\r
-    const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,\r
-    ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/LzmaLib.c b/deps/lzma-16.04/C/LzmaLib.c
deleted file mode 100644 (file)
index c10cf1a..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/* LzmaLib.c -- LZMA library wrapper\r
-2015-06-13 : Igor Pavlov : Public domain */\r
-\r
-#include "Alloc.h"\r
-#include "LzmaDec.h"\r
-#include "LzmaEnc.h"\r
-#include "LzmaLib.h"\r
-\r
-MY_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t srcLen,\r
-  unsigned char *outProps, size_t *outPropsSize,\r
-  int level, /* 0 <= level <= 9, default = 5 */\r
-  unsigned dictSize, /* use (1 << N) or (3 << N). 4 KB < dictSize <= 128 MB */\r
-  int lc, /* 0 <= lc <= 8, default = 3  */\r
-  int lp, /* 0 <= lp <= 4, default = 0  */\r
-  int pb, /* 0 <= pb <= 4, default = 2  */\r
-  int fb,  /* 5 <= fb <= 273, default = 32 */\r
-  int numThreads /* 1 or 2, default = 2 */\r
-)\r
-{\r
-  CLzmaEncProps props;\r
-  LzmaEncProps_Init(&props);\r
-  props.level = level;\r
-  props.dictSize = dictSize;\r
-  props.lc = lc;\r
-  props.lp = lp;\r
-  props.pb = pb;\r
-  props.fb = fb;\r
-  props.numThreads = numThreads;\r
-\r
-  return LzmaEncode(dest, destLen, src, srcLen, &props, outProps, outPropsSize, 0,\r
-      NULL, &g_Alloc, &g_Alloc);\r
-}\r
-\r
-\r
-MY_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t *srcLen,\r
-  const unsigned char *props, size_t propsSize)\r
-{\r
-  ELzmaStatus status;\r
-  return LzmaDecode(dest, destLen, src, srcLen, props, (unsigned)propsSize, LZMA_FINISH_ANY, &status, &g_Alloc);\r
-}\r
diff --git a/deps/lzma-16.04/C/LzmaLib.h b/deps/lzma-16.04/C/LzmaLib.h
deleted file mode 100644 (file)
index 5c35e53..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/* LzmaLib.h -- LZMA library interface\r
-2013-01-18 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __LZMA_LIB_H\r
-#define __LZMA_LIB_H\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-#define MY_STDAPI int MY_STD_CALL\r
-\r
-#define LZMA_PROPS_SIZE 5\r
-\r
-/*\r
-RAM requirements for LZMA:\r
-  for compression:   (dictSize * 11.5 + 6 MB) + state_size\r
-  for decompression: dictSize + state_size\r
-    state_size = (4 + (1.5 << (lc + lp))) KB\r
-    by default (lc=3, lp=0), state_size = 16 KB.\r
-\r
-LZMA properties (5 bytes) format\r
-    Offset Size  Description\r
-      0     1    lc, lp and pb in encoded form.\r
-      1     4    dictSize (little endian).\r
-*/\r
-\r
-/*\r
-LzmaCompress\r
-------------\r
-\r
-outPropsSize -\r
-     In:  the pointer to the size of outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5.\r
-     Out: the pointer to the size of written properties in outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5.\r
-\r
-  LZMA Encoder will use defult values for any parameter, if it is\r
-  -1  for any from: level, loc, lp, pb, fb, numThreads\r
-   0  for dictSize\r
-  \r
-level - compression level: 0 <= level <= 9;\r
-\r
-  level dictSize algo  fb\r
-    0:    16 KB   0    32\r
-    1:    64 KB   0    32\r
-    2:   256 KB   0    32\r
-    3:     1 MB   0    32\r
-    4:     4 MB   0    32\r
-    5:    16 MB   1    32\r
-    6:    32 MB   1    32\r
-    7+:   64 MB   1    64\r
\r
-  The default value for "level" is 5.\r
-\r
-  algo = 0 means fast method\r
-  algo = 1 means normal method\r
-\r
-dictSize - The dictionary size in bytes. The maximum value is\r
-        128 MB = (1 << 27) bytes for 32-bit version\r
-          1 GB = (1 << 30) bytes for 64-bit version\r
-     The default value is 16 MB = (1 << 24) bytes.\r
-     It's recommended to use the dictionary that is larger than 4 KB and\r
-     that can be calculated as (1 << N) or (3 << N) sizes.\r
-\r
-lc - The number of literal context bits (high bits of previous literal).\r
-     It can be in the range from 0 to 8. The default value is 3.\r
-     Sometimes lc=4 gives the gain for big files.\r
-\r
-lp - The number of literal pos bits (low bits of current position for literals).\r
-     It can be in the range from 0 to 4. The default value is 0.\r
-     The lp switch is intended for periodical data when the period is equal to 2^lp.\r
-     For example, for 32-bit (4 bytes) periodical data you can use lp=2. Often it's\r
-     better to set lc=0, if you change lp switch.\r
-\r
-pb - The number of pos bits (low bits of current position).\r
-     It can be in the range from 0 to 4. The default value is 2.\r
-     The pb switch is intended for periodical data when the period is equal 2^pb.\r
-\r
-fb - Word size (the number of fast bytes).\r
-     It can be in the range from 5 to 273. The default value is 32.\r
-     Usually, a big number gives a little bit better compression ratio and\r
-     slower compression process.\r
-\r
-numThreads - The number of thereads. 1 or 2. The default value is 2.\r
-     Fast mode (algo = 0) can use only 1 thread.\r
-\r
-Out:\r
-  destLen  - processed output size\r
-Returns:\r
-  SZ_OK               - OK\r
-  SZ_ERROR_MEM        - Memory allocation error\r
-  SZ_ERROR_PARAM      - Incorrect paramater\r
-  SZ_ERROR_OUTPUT_EOF - output buffer overflow\r
-  SZ_ERROR_THREAD     - errors in multithreading functions (only for Mt version)\r
-*/\r
-\r
-MY_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t srcLen,\r
-  unsigned char *outProps, size_t *outPropsSize, /* *outPropsSize must be = 5 */\r
-  int level,      /* 0 <= level <= 9, default = 5 */\r
-  unsigned dictSize,  /* default = (1 << 24) */\r
-  int lc,        /* 0 <= lc <= 8, default = 3  */\r
-  int lp,        /* 0 <= lp <= 4, default = 0  */\r
-  int pb,        /* 0 <= pb <= 4, default = 2  */\r
-  int fb,        /* 5 <= fb <= 273, default = 32 */\r
-  int numThreads /* 1 or 2, default = 2 */\r
-  );\r
-\r
-/*\r
-LzmaUncompress\r
---------------\r
-In:\r
-  dest     - output data\r
-  destLen  - output data size\r
-  src      - input data\r
-  srcLen   - input data size\r
-Out:\r
-  destLen  - processed output size\r
-  srcLen   - processed input size\r
-Returns:\r
-  SZ_OK                - OK\r
-  SZ_ERROR_DATA        - Data error\r
-  SZ_ERROR_MEM         - Memory allocation arror\r
-  SZ_ERROR_UNSUPPORTED - Unsupported properties\r
-  SZ_ERROR_INPUT_EOF   - it needs more bytes in input buffer (src)\r
-*/\r
-\r
-MY_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, SizeT *srcLen,\r
-  const unsigned char *props, size_t propsSize);\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/MtCoder.c b/deps/lzma-16.04/C/MtCoder.c
deleted file mode 100644 (file)
index 8c0d9b3..0000000
+++ /dev/null
@@ -1,327 +0,0 @@
-/* MtCoder.c -- Multi-thread Coder\r
-2015-10-13 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "MtCoder.h"\r
-\r
-void LoopThread_Construct(CLoopThread *p)\r
-{\r
-  Thread_Construct(&p->thread);\r
-  Event_Construct(&p->startEvent);\r
-  Event_Construct(&p->finishedEvent);\r
-}\r
-\r
-void LoopThread_Close(CLoopThread *p)\r
-{\r
-  Thread_Close(&p->thread);\r
-  Event_Close(&p->startEvent);\r
-  Event_Close(&p->finishedEvent);\r
-}\r
-\r
-static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE LoopThreadFunc(void *pp)\r
-{\r
-  CLoopThread *p = (CLoopThread *)pp;\r
-  for (;;)\r
-  {\r
-    if (Event_Wait(&p->startEvent) != 0)\r
-      return SZ_ERROR_THREAD;\r
-    if (p->stop)\r
-      return 0;\r
-    p->res = p->func(p->param);\r
-    if (Event_Set(&p->finishedEvent) != 0)\r
-      return SZ_ERROR_THREAD;\r
-  }\r
-}\r
-\r
-WRes LoopThread_Create(CLoopThread *p)\r
-{\r
-  p->stop = 0;\r
-  RINOK(AutoResetEvent_CreateNotSignaled(&p->startEvent));\r
-  RINOK(AutoResetEvent_CreateNotSignaled(&p->finishedEvent));\r
-  return Thread_Create(&p->thread, LoopThreadFunc, p);\r
-}\r
-\r
-WRes LoopThread_StopAndWait(CLoopThread *p)\r
-{\r
-  p->stop = 1;\r
-  if (Event_Set(&p->startEvent) != 0)\r
-    return SZ_ERROR_THREAD;\r
-  return Thread_Wait(&p->thread);\r
-}\r
-\r
-WRes LoopThread_StartSubThread(CLoopThread *p) { return Event_Set(&p->startEvent); }\r
-WRes LoopThread_WaitSubThread(CLoopThread *p) { return Event_Wait(&p->finishedEvent); }\r
-\r
-static SRes Progress(ICompressProgress *p, UInt64 inSize, UInt64 outSize)\r
-{\r
-  return (p && p->Progress(p, inSize, outSize) != SZ_OK) ? SZ_ERROR_PROGRESS : SZ_OK;\r
-}\r
-\r
-static void MtProgress_Init(CMtProgress *p, ICompressProgress *progress)\r
-{\r
-  unsigned i;\r
-  for (i = 0; i < NUM_MT_CODER_THREADS_MAX; i++)\r
-    p->inSizes[i] = p->outSizes[i] = 0;\r
-  p->totalInSize = p->totalOutSize = 0;\r
-  p->progress = progress;\r
-  p->res = SZ_OK;\r
-}\r
-\r
-static void MtProgress_Reinit(CMtProgress *p, unsigned index)\r
-{\r
-  p->inSizes[index] = 0;\r
-  p->outSizes[index] = 0;\r
-}\r
-\r
-#define UPDATE_PROGRESS(size, prev, total) \\r
-  if (size != (UInt64)(Int64)-1) { total += size - prev; prev = size; }\r
-\r
-SRes MtProgress_Set(CMtProgress *p, unsigned index, UInt64 inSize, UInt64 outSize)\r
-{\r
-  SRes res;\r
-  CriticalSection_Enter(&p->cs);\r
-  UPDATE_PROGRESS(inSize, p->inSizes[index], p->totalInSize)\r
-  UPDATE_PROGRESS(outSize, p->outSizes[index], p->totalOutSize)\r
-  if (p->res == SZ_OK)\r
-    p->res = Progress(p->progress, p->totalInSize, p->totalOutSize);\r
-  res = p->res;\r
-  CriticalSection_Leave(&p->cs);\r
-  return res;\r
-}\r
-\r
-static void MtProgress_SetError(CMtProgress *p, SRes res)\r
-{\r
-  CriticalSection_Enter(&p->cs);\r
-  if (p->res == SZ_OK)\r
-    p->res = res;\r
-  CriticalSection_Leave(&p->cs);\r
-}\r
-\r
-static void MtCoder_SetError(CMtCoder* p, SRes res)\r
-{\r
-  CriticalSection_Enter(&p->cs);\r
-  if (p->res == SZ_OK)\r
-    p->res = res;\r
-  CriticalSection_Leave(&p->cs);\r
-}\r
-\r
-/* ---------- MtThread ---------- */\r
-\r
-void CMtThread_Construct(CMtThread *p, CMtCoder *mtCoder)\r
-{\r
-  p->mtCoder = mtCoder;\r
-  p->outBuf = 0;\r
-  p->inBuf = 0;\r
-  Event_Construct(&p->canRead);\r
-  Event_Construct(&p->canWrite);\r
-  LoopThread_Construct(&p->thread);\r
-}\r
-\r
-#define RINOK_THREAD(x) { if ((x) != 0) return SZ_ERROR_THREAD; }\r
-\r
-static void CMtThread_CloseEvents(CMtThread *p)\r
-{\r
-  Event_Close(&p->canRead);\r
-  Event_Close(&p->canWrite);\r
-}\r
-\r
-static void CMtThread_Destruct(CMtThread *p)\r
-{\r
-  CMtThread_CloseEvents(p);\r
-\r
-  if (Thread_WasCreated(&p->thread.thread))\r
-  {\r
-    LoopThread_StopAndWait(&p->thread);\r
-    LoopThread_Close(&p->thread);\r
-  }\r
-\r
-  if (p->mtCoder->alloc)\r
-    IAlloc_Free(p->mtCoder->alloc, p->outBuf);\r
-  p->outBuf = 0;\r
-\r
-  if (p->mtCoder->alloc)\r
-    IAlloc_Free(p->mtCoder->alloc, p->inBuf);\r
-  p->inBuf = 0;\r
-}\r
-\r
-#define MY_BUF_ALLOC(buf, size, newSize) \\r
-  if (buf == 0 || size != newSize) \\r
-  { IAlloc_Free(p->mtCoder->alloc, buf); \\r
-    size = newSize; buf = (Byte *)IAlloc_Alloc(p->mtCoder->alloc, size); \\r
-    if (buf == 0) return SZ_ERROR_MEM; }\r
-\r
-static SRes CMtThread_Prepare(CMtThread *p)\r
-{\r
-  MY_BUF_ALLOC(p->inBuf, p->inBufSize, p->mtCoder->blockSize)\r
-  MY_BUF_ALLOC(p->outBuf, p->outBufSize, p->mtCoder->destBlockSize)\r
-\r
-  p->stopReading = False;\r
-  p->stopWriting = False;\r
-  RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->canRead));\r
-  RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->canWrite));\r
-\r
-  return SZ_OK;\r
-}\r
-\r
-static SRes FullRead(ISeqInStream *stream, Byte *data, size_t *processedSize)\r
-{\r
-  size_t size = *processedSize;\r
-  *processedSize = 0;\r
-  while (size != 0)\r
-  {\r
-    size_t curSize = size;\r
-    SRes res = stream->Read(stream, data, &curSize);\r
-    *processedSize += curSize;\r
-    data += curSize;\r
-    size -= curSize;\r
-    RINOK(res);\r
-    if (curSize == 0)\r
-      return SZ_OK;\r
-  }\r
-  return SZ_OK;\r
-}\r
-\r
-#define GET_NEXT_THREAD(p) &p->mtCoder->threads[p->index == p->mtCoder->numThreads  - 1 ? 0 : p->index + 1]\r
-\r
-static SRes MtThread_Process(CMtThread *p, Bool *stop)\r
-{\r
-  CMtThread *next;\r
-  *stop = True;\r
-  if (Event_Wait(&p->canRead) != 0)\r
-    return SZ_ERROR_THREAD;\r
-  \r
-  next = GET_NEXT_THREAD(p);\r
-  \r
-  if (p->stopReading)\r
-  {\r
-    next->stopReading = True;\r
-    return Event_Set(&next->canRead) == 0 ? SZ_OK : SZ_ERROR_THREAD;\r
-  }\r
-\r
-  {\r
-    size_t size = p->mtCoder->blockSize;\r
-    size_t destSize = p->outBufSize;\r
-\r
-    RINOK(FullRead(p->mtCoder->inStream, p->inBuf, &size));\r
-    next->stopReading = *stop = (size != p->mtCoder->blockSize);\r
-    if (Event_Set(&next->canRead) != 0)\r
-      return SZ_ERROR_THREAD;\r
-\r
-    RINOK(p->mtCoder->mtCallback->Code(p->mtCoder->mtCallback, p->index,\r
-        p->outBuf, &destSize, p->inBuf, size, *stop));\r
-\r
-    MtProgress_Reinit(&p->mtCoder->mtProgress, p->index);\r
-\r
-    if (Event_Wait(&p->canWrite) != 0)\r
-      return SZ_ERROR_THREAD;\r
-    if (p->stopWriting)\r
-      return SZ_ERROR_FAIL;\r
-    if (p->mtCoder->outStream->Write(p->mtCoder->outStream, p->outBuf, destSize) != destSize)\r
-      return SZ_ERROR_WRITE;\r
-    return Event_Set(&next->canWrite) == 0 ? SZ_OK : SZ_ERROR_THREAD;\r
-  }\r
-}\r
-\r
-static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE ThreadFunc(void *pp)\r
-{\r
-  CMtThread *p = (CMtThread *)pp;\r
-  for (;;)\r
-  {\r
-    Bool stop;\r
-    CMtThread *next = GET_NEXT_THREAD(p);\r
-    SRes res = MtThread_Process(p, &stop);\r
-    if (res != SZ_OK)\r
-    {\r
-      MtCoder_SetError(p->mtCoder, res);\r
-      MtProgress_SetError(&p->mtCoder->mtProgress, res);\r
-      next->stopReading = True;\r
-      next->stopWriting = True;\r
-      Event_Set(&next->canRead);\r
-      Event_Set(&next->canWrite);\r
-      return res;\r
-    }\r
-    if (stop)\r
-      return 0;\r
-  }\r
-}\r
-\r
-void MtCoder_Construct(CMtCoder* p)\r
-{\r
-  unsigned i;\r
-  p->alloc = 0;\r
-  for (i = 0; i < NUM_MT_CODER_THREADS_MAX; i++)\r
-  {\r
-    CMtThread *t = &p->threads[i];\r
-    t->index = i;\r
-    CMtThread_Construct(t, p);\r
-  }\r
-  CriticalSection_Init(&p->cs);\r
-  CriticalSection_Init(&p->mtProgress.cs);\r
-}\r
-\r
-void MtCoder_Destruct(CMtCoder* p)\r
-{\r
-  unsigned i;\r
-  for (i = 0; i < NUM_MT_CODER_THREADS_MAX; i++)\r
-    CMtThread_Destruct(&p->threads[i]);\r
-  CriticalSection_Delete(&p->cs);\r
-  CriticalSection_Delete(&p->mtProgress.cs);\r
-}\r
-\r
-SRes MtCoder_Code(CMtCoder *p)\r
-{\r
-  unsigned i, numThreads = p->numThreads;\r
-  SRes res = SZ_OK;\r
-  p->res = SZ_OK;\r
-\r
-  MtProgress_Init(&p->mtProgress, p->progress);\r
-\r
-  for (i = 0; i < numThreads; i++)\r
-  {\r
-    RINOK(CMtThread_Prepare(&p->threads[i]));\r
-  }\r
-\r
-  for (i = 0; i < numThreads; i++)\r
-  {\r
-    CMtThread *t = &p->threads[i];\r
-    CLoopThread *lt = &t->thread;\r
-\r
-    if (!Thread_WasCreated(&lt->thread))\r
-    {\r
-      lt->func = ThreadFunc;\r
-      lt->param = t;\r
-\r
-      if (LoopThread_Create(lt) != SZ_OK)\r
-      {\r
-        res = SZ_ERROR_THREAD;\r
-        break;\r
-      }\r
-    }\r
-  }\r
-\r
-  if (res == SZ_OK)\r
-  {\r
-    unsigned j;\r
-    for (i = 0; i < numThreads; i++)\r
-    {\r
-      CMtThread *t = &p->threads[i];\r
-      if (LoopThread_StartSubThread(&t->thread) != SZ_OK)\r
-      {\r
-        res = SZ_ERROR_THREAD;\r
-        p->threads[0].stopReading = True;\r
-        break;\r
-      }\r
-    }\r
-\r
-    Event_Set(&p->threads[0].canWrite);\r
-    Event_Set(&p->threads[0].canRead);\r
-\r
-    for (j = 0; j < i; j++)\r
-      LoopThread_WaitSubThread(&p->threads[j].thread);\r
-  }\r
-\r
-  for (i = 0; i < numThreads; i++)\r
-    CMtThread_CloseEvents(&p->threads[i]);\r
-  return (res == SZ_OK) ? p->res : res;\r
-}\r
diff --git a/deps/lzma-16.04/C/MtCoder.h b/deps/lzma-16.04/C/MtCoder.h
deleted file mode 100644 (file)
index 705208e..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/* MtCoder.h -- Multi-thread Coder\r
-2009-11-19 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __MT_CODER_H\r
-#define __MT_CODER_H\r
-\r
-#include "Threads.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-typedef struct\r
-{\r
-  CThread thread;\r
-  CAutoResetEvent startEvent;\r
-  CAutoResetEvent finishedEvent;\r
-  int stop;\r
-  \r
-  THREAD_FUNC_TYPE func;\r
-  LPVOID param;\r
-  THREAD_FUNC_RET_TYPE res;\r
-} CLoopThread;\r
-\r
-void LoopThread_Construct(CLoopThread *p);\r
-void LoopThread_Close(CLoopThread *p);\r
-WRes LoopThread_Create(CLoopThread *p);\r
-WRes LoopThread_StopAndWait(CLoopThread *p);\r
-WRes LoopThread_StartSubThread(CLoopThread *p);\r
-WRes LoopThread_WaitSubThread(CLoopThread *p);\r
-\r
-#ifndef _7ZIP_ST\r
-#define NUM_MT_CODER_THREADS_MAX 32\r
-#else\r
-#define NUM_MT_CODER_THREADS_MAX 1\r
-#endif\r
-\r
-typedef struct\r
-{\r
-  UInt64 totalInSize;\r
-  UInt64 totalOutSize;\r
-  ICompressProgress *progress;\r
-  SRes res;\r
-  CCriticalSection cs;\r
-  UInt64 inSizes[NUM_MT_CODER_THREADS_MAX];\r
-  UInt64 outSizes[NUM_MT_CODER_THREADS_MAX];\r
-} CMtProgress;\r
-\r
-SRes MtProgress_Set(CMtProgress *p, unsigned index, UInt64 inSize, UInt64 outSize);\r
-\r
-struct _CMtCoder;\r
-\r
-typedef struct\r
-{\r
-  struct _CMtCoder *mtCoder;\r
-  Byte *outBuf;\r
-  size_t outBufSize;\r
-  Byte *inBuf;\r
-  size_t inBufSize;\r
-  unsigned index;\r
-  CLoopThread thread;\r
-\r
-  Bool stopReading;\r
-  Bool stopWriting;\r
-  CAutoResetEvent canRead;\r
-  CAutoResetEvent canWrite;\r
-} CMtThread;\r
-\r
-typedef struct\r
-{\r
-  SRes (*Code)(void *p, unsigned index, Byte *dest, size_t *destSize,\r
-      const Byte *src, size_t srcSize, int finished);\r
-} IMtCoderCallback;\r
-\r
-typedef struct _CMtCoder\r
-{\r
-  size_t blockSize;\r
-  size_t destBlockSize;\r
-  unsigned numThreads;\r
-  \r
-  ISeqInStream *inStream;\r
-  ISeqOutStream *outStream;\r
-  ICompressProgress *progress;\r
-  ISzAlloc *alloc;\r
-\r
-  IMtCoderCallback *mtCallback;\r
-  CCriticalSection cs;\r
-  SRes res;\r
-\r
-  CMtProgress mtProgress;\r
-  CMtThread threads[NUM_MT_CODER_THREADS_MAX];\r
-} CMtCoder;\r
-\r
-void MtCoder_Construct(CMtCoder* p);\r
-void MtCoder_Destruct(CMtCoder* p);\r
-SRes MtCoder_Code(CMtCoder *p);\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/Ppmd.h b/deps/lzma-16.04/C/Ppmd.h
deleted file mode 100644 (file)
index e807ca1..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/* Ppmd.h -- PPMD codec common code\r
-2016-05-16 : Igor Pavlov : Public domain\r
-This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */\r
-\r
-#ifndef __PPMD_H\r
-#define __PPMD_H\r
-\r
-#include "CpuArch.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-#ifdef MY_CPU_32BIT\r
-  #define PPMD_32BIT\r
-#endif\r
-\r
-#define PPMD_INT_BITS 7\r
-#define PPMD_PERIOD_BITS 7\r
-#define PPMD_BIN_SCALE (1 << (PPMD_INT_BITS + PPMD_PERIOD_BITS))\r
-\r
-#define PPMD_GET_MEAN_SPEC(summ, shift, round) (((summ) + (1 << ((shift) - (round)))) >> (shift))\r
-#define PPMD_GET_MEAN(summ) PPMD_GET_MEAN_SPEC((summ), PPMD_PERIOD_BITS, 2)\r
-#define PPMD_UPDATE_PROB_0(prob) ((prob) + (1 << PPMD_INT_BITS) - PPMD_GET_MEAN(prob))\r
-#define PPMD_UPDATE_PROB_1(prob) ((prob) - PPMD_GET_MEAN(prob))\r
-\r
-#define PPMD_N1 4\r
-#define PPMD_N2 4\r
-#define PPMD_N3 4\r
-#define PPMD_N4 ((128 + 3 - 1 * PPMD_N1 - 2 * PPMD_N2 - 3 * PPMD_N3) / 4)\r
-#define PPMD_NUM_INDEXES (PPMD_N1 + PPMD_N2 + PPMD_N3 + PPMD_N4)\r
-\r
-#pragma pack(push, 1)\r
-/* Most compilers works OK here even without #pragma pack(push, 1), but some GCC compilers need it. */\r
-\r
-/* SEE-contexts for PPM-contexts with masked symbols */\r
-typedef struct\r
-{\r
-  UInt16 Summ; /* Freq */\r
-  Byte Shift;  /* Speed of Freq change; low Shift is for fast change */\r
-  Byte Count;  /* Count to next change of Shift */\r
-} CPpmd_See;\r
-\r
-#define Ppmd_See_Update(p)  if ((p)->Shift < PPMD_PERIOD_BITS && --(p)->Count == 0) \\r
-    { (p)->Summ <<= 1; (p)->Count = (Byte)(3 << (p)->Shift++); }\r
-\r
-typedef struct\r
-{\r
-  Byte Symbol;\r
-  Byte Freq;\r
-  UInt16 SuccessorLow;\r
-  UInt16 SuccessorHigh;\r
-} CPpmd_State;\r
-\r
-#pragma pack(pop)\r
-\r
-typedef\r
-  #ifdef PPMD_32BIT\r
-    CPpmd_State *\r
-  #else\r
-    UInt32\r
-  #endif\r
-  CPpmd_State_Ref;\r
-\r
-typedef\r
-  #ifdef PPMD_32BIT\r
-    void *\r
-  #else\r
-    UInt32\r
-  #endif\r
-  CPpmd_Void_Ref;\r
-\r
-typedef\r
-  #ifdef PPMD_32BIT\r
-    Byte *\r
-  #else\r
-    UInt32\r
-  #endif\r
-  CPpmd_Byte_Ref;\r
-\r
-#define PPMD_SetAllBitsIn256Bytes(p) \\r
-  { unsigned z; for (z = 0; z < 256 / sizeof(p[0]); z += 8) { \\r
-  p[z+7] = p[z+6] = p[z+5] = p[z+4] = p[z+3] = p[z+2] = p[z+1] = p[z+0] = ~(size_t)0; }}\r
-\r
-EXTERN_C_END\r
\r
-#endif\r
diff --git a/deps/lzma-16.04/C/Ppmd7.c b/deps/lzma-16.04/C/Ppmd7.c
deleted file mode 100644 (file)
index ba5d329..0000000
+++ /dev/null
@@ -1,710 +0,0 @@
-/* Ppmd7.c -- PPMdH codec\r
-2016-05-21 : Igor Pavlov : Public domain\r
-This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include <string.h>\r
-\r
-#include "Ppmd7.h"\r
-\r
-const Byte PPMD7_kExpEscape[16] = { 25, 14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2 };\r
-static const UInt16 kInitBinEsc[] = { 0x3CDD, 0x1F3F, 0x59BF, 0x48F3, 0x64A1, 0x5ABC, 0x6632, 0x6051};\r
-\r
-#define MAX_FREQ 124\r
-#define UNIT_SIZE 12\r
-\r
-#define U2B(nu) ((UInt32)(nu) * UNIT_SIZE)\r
-#define U2I(nu) (p->Units2Indx[(nu) - 1])\r
-#define I2U(indx) (p->Indx2Units[indx])\r
-\r
-#ifdef PPMD_32BIT\r
-  #define REF(ptr) (ptr)\r
-#else\r
-  #define REF(ptr) ((UInt32)((Byte *)(ptr) - (p)->Base))\r
-#endif\r
-\r
-#define STATS_REF(ptr) ((CPpmd_State_Ref)REF(ptr))\r
-\r
-#define CTX(ref) ((CPpmd7_Context *)Ppmd7_GetContext(p, ref))\r
-#define STATS(ctx) Ppmd7_GetStats(p, ctx)\r
-#define ONE_STATE(ctx) Ppmd7Context_OneState(ctx)\r
-#define SUFFIX(ctx) CTX((ctx)->Suffix)\r
-\r
-typedef CPpmd7_Context * CTX_PTR;\r
-\r
-struct CPpmd7_Node_;\r
-\r
-typedef\r
-  #ifdef PPMD_32BIT\r
-    struct CPpmd7_Node_ *\r
-  #else\r
-    UInt32\r
-  #endif\r
-  CPpmd7_Node_Ref;\r
-\r
-typedef struct CPpmd7_Node_\r
-{\r
-  UInt16 Stamp; /* must be at offset 0 as CPpmd7_Context::NumStats. Stamp=0 means free */\r
-  UInt16 NU;\r
-  CPpmd7_Node_Ref Next; /* must be at offset >= 4 */\r
-  CPpmd7_Node_Ref Prev;\r
-} CPpmd7_Node;\r
-\r
-#ifdef PPMD_32BIT\r
-  #define NODE(ptr) (ptr)\r
-#else\r
-  #define NODE(offs) ((CPpmd7_Node *)(p->Base + (offs)))\r
-#endif\r
-\r
-void Ppmd7_Construct(CPpmd7 *p)\r
-{\r
-  unsigned i, k, m;\r
-\r
-  p->Base = 0;\r
-\r
-  for (i = 0, k = 0; i < PPMD_NUM_INDEXES; i++)\r
-  {\r
-    unsigned step = (i >= 12 ? 4 : (i >> 2) + 1);\r
-    do { p->Units2Indx[k++] = (Byte)i; } while (--step);\r
-    p->Indx2Units[i] = (Byte)k;\r
-  }\r
-\r
-  p->NS2BSIndx[0] = (0 << 1);\r
-  p->NS2BSIndx[1] = (1 << 1);\r
-  memset(p->NS2BSIndx + 2, (2 << 1), 9);\r
-  memset(p->NS2BSIndx + 11, (3 << 1), 256 - 11);\r
-\r
-  for (i = 0; i < 3; i++)\r
-    p->NS2Indx[i] = (Byte)i;\r
-  for (m = i, k = 1; i < 256; i++)\r
-  {\r
-    p->NS2Indx[i] = (Byte)m;\r
-    if (--k == 0)\r
-      k = (++m) - 2;\r
-  }\r
-\r
-  memset(p->HB2Flag, 0, 0x40);\r
-  memset(p->HB2Flag + 0x40, 8, 0x100 - 0x40);\r
-}\r
-\r
-void Ppmd7_Free(CPpmd7 *p, ISzAlloc *alloc)\r
-{\r
-  alloc->Free(alloc, p->Base);\r
-  p->Size = 0;\r
-  p->Base = 0;\r
-}\r
-\r
-Bool Ppmd7_Alloc(CPpmd7 *p, UInt32 size, ISzAlloc *alloc)\r
-{\r
-  if (p->Base == 0 || p->Size != size)\r
-  {\r
-    Ppmd7_Free(p, alloc);\r
-    p->AlignOffset =\r
-      #ifdef PPMD_32BIT\r
-        (4 - size) & 3;\r
-      #else\r
-        4 - (size & 3);\r
-      #endif\r
-    if ((p->Base = (Byte *)alloc->Alloc(alloc, p->AlignOffset + size\r
-        #ifndef PPMD_32BIT\r
-        + UNIT_SIZE\r
-        #endif\r
-        )) == 0)\r
-      return False;\r
-    p->Size = size;\r
-  }\r
-  return True;\r
-}\r
-\r
-static void InsertNode(CPpmd7 *p, void *node, unsigned indx)\r
-{\r
-  *((CPpmd_Void_Ref *)node) = p->FreeList[indx];\r
-  p->FreeList[indx] = REF(node);\r
-}\r
-\r
-static void *RemoveNode(CPpmd7 *p, unsigned indx)\r
-{\r
-  CPpmd_Void_Ref *node = (CPpmd_Void_Ref *)Ppmd7_GetPtr(p, p->FreeList[indx]);\r
-  p->FreeList[indx] = *node;\r
-  return node;\r
-}\r
-\r
-static void SplitBlock(CPpmd7 *p, void *ptr, unsigned oldIndx, unsigned newIndx)\r
-{\r
-  unsigned i, nu = I2U(oldIndx) - I2U(newIndx);\r
-  ptr = (Byte *)ptr + U2B(I2U(newIndx));\r
-  if (I2U(i = U2I(nu)) != nu)\r
-  {\r
-    unsigned k = I2U(--i);\r
-    InsertNode(p, ((Byte *)ptr) + U2B(k), nu - k - 1);\r
-  }\r
-  InsertNode(p, ptr, i);\r
-}\r
-\r
-static void GlueFreeBlocks(CPpmd7 *p)\r
-{\r
-  #ifdef PPMD_32BIT\r
-  CPpmd7_Node headItem;\r
-  CPpmd7_Node_Ref head = &headItem;\r
-  #else\r
-  CPpmd7_Node_Ref head = p->AlignOffset + p->Size;\r
-  #endif\r
-  \r
-  CPpmd7_Node_Ref n = head;\r
-  unsigned i;\r
-\r
-  p->GlueCount = 255;\r
-\r
-  /* create doubly-linked list of free blocks */\r
-  for (i = 0; i < PPMD_NUM_INDEXES; i++)\r
-  {\r
-    UInt16 nu = I2U(i);\r
-    CPpmd7_Node_Ref next = (CPpmd7_Node_Ref)p->FreeList[i];\r
-    p->FreeList[i] = 0;\r
-    while (next != 0)\r
-    {\r
-      CPpmd7_Node *node = NODE(next);\r
-      node->Next = n;\r
-      n = NODE(n)->Prev = next;\r
-      next = *(const CPpmd7_Node_Ref *)node;\r
-      node->Stamp = 0;\r
-      node->NU = (UInt16)nu;\r
-    }\r
-  }\r
-  NODE(head)->Stamp = 1;\r
-  NODE(head)->Next = n;\r
-  NODE(n)->Prev = head;\r
-  if (p->LoUnit != p->HiUnit)\r
-    ((CPpmd7_Node *)p->LoUnit)->Stamp = 1;\r
-  \r
-  /* Glue free blocks */\r
-  while (n != head)\r
-  {\r
-    CPpmd7_Node *node = NODE(n);\r
-    UInt32 nu = (UInt32)node->NU;\r
-    for (;;)\r
-    {\r
-      CPpmd7_Node *node2 = NODE(n) + nu;\r
-      nu += node2->NU;\r
-      if (node2->Stamp != 0 || nu >= 0x10000)\r
-        break;\r
-      NODE(node2->Prev)->Next = node2->Next;\r
-      NODE(node2->Next)->Prev = node2->Prev;\r
-      node->NU = (UInt16)nu;\r
-    }\r
-    n = node->Next;\r
-  }\r
-  \r
-  /* Fill lists of free blocks */\r
-  for (n = NODE(head)->Next; n != head;)\r
-  {\r
-    CPpmd7_Node *node = NODE(n);\r
-    unsigned nu;\r
-    CPpmd7_Node_Ref next = node->Next;\r
-    for (nu = node->NU; nu > 128; nu -= 128, node += 128)\r
-      InsertNode(p, node, PPMD_NUM_INDEXES - 1);\r
-    if (I2U(i = U2I(nu)) != nu)\r
-    {\r
-      unsigned k = I2U(--i);\r
-      InsertNode(p, node + k, nu - k - 1);\r
-    }\r
-    InsertNode(p, node, i);\r
-    n = next;\r
-  }\r
-}\r
-\r
-static void *AllocUnitsRare(CPpmd7 *p, unsigned indx)\r
-{\r
-  unsigned i;\r
-  void *retVal;\r
-  if (p->GlueCount == 0)\r
-  {\r
-    GlueFreeBlocks(p);\r
-    if (p->FreeList[indx] != 0)\r
-      return RemoveNode(p, indx);\r
-  }\r
-  i = indx;\r
-  do\r
-  {\r
-    if (++i == PPMD_NUM_INDEXES)\r
-    {\r
-      UInt32 numBytes = U2B(I2U(indx));\r
-      p->GlueCount--;\r
-      return ((UInt32)(p->UnitsStart - p->Text) > numBytes) ? (p->UnitsStart -= numBytes) : (NULL);\r
-    }\r
-  }\r
-  while (p->FreeList[i] == 0);\r
-  retVal = RemoveNode(p, i);\r
-  SplitBlock(p, retVal, i, indx);\r
-  return retVal;\r
-}\r
-\r
-static void *AllocUnits(CPpmd7 *p, unsigned indx)\r
-{\r
-  UInt32 numBytes;\r
-  if (p->FreeList[indx] != 0)\r
-    return RemoveNode(p, indx);\r
-  numBytes = U2B(I2U(indx));\r
-  if (numBytes <= (UInt32)(p->HiUnit - p->LoUnit))\r
-  {\r
-    void *retVal = p->LoUnit;\r
-    p->LoUnit += numBytes;\r
-    return retVal;\r
-  }\r
-  return AllocUnitsRare(p, indx);\r
-}\r
-\r
-#define MyMem12Cpy(dest, src, num) \\r
-  { UInt32 *d = (UInt32 *)dest; const UInt32 *s = (const UInt32 *)src; UInt32 n = num; \\r
-    do { d[0] = s[0]; d[1] = s[1]; d[2] = s[2]; s += 3; d += 3; } while (--n); }\r
-\r
-static void *ShrinkUnits(CPpmd7 *p, void *oldPtr, unsigned oldNU, unsigned newNU)\r
-{\r
-  unsigned i0 = U2I(oldNU);\r
-  unsigned i1 = U2I(newNU);\r
-  if (i0 == i1)\r
-    return oldPtr;\r
-  if (p->FreeList[i1] != 0)\r
-  {\r
-    void *ptr = RemoveNode(p, i1);\r
-    MyMem12Cpy(ptr, oldPtr, newNU);\r
-    InsertNode(p, oldPtr, i0);\r
-    return ptr;\r
-  }\r
-  SplitBlock(p, oldPtr, i0, i1);\r
-  return oldPtr;\r
-}\r
-\r
-#define SUCCESSOR(p) ((CPpmd_Void_Ref)((p)->SuccessorLow | ((UInt32)(p)->SuccessorHigh << 16)))\r
-\r
-static void SetSuccessor(CPpmd_State *p, CPpmd_Void_Ref v)\r
-{\r
-  (p)->SuccessorLow = (UInt16)((UInt32)(v) & 0xFFFF);\r
-  (p)->SuccessorHigh = (UInt16)(((UInt32)(v) >> 16) & 0xFFFF);\r
-}\r
-\r
-static void RestartModel(CPpmd7 *p)\r
-{\r
-  unsigned i, k, m;\r
-\r
-  memset(p->FreeList, 0, sizeof(p->FreeList));\r
-  p->Text = p->Base + p->AlignOffset;\r
-  p->HiUnit = p->Text + p->Size;\r
-  p->LoUnit = p->UnitsStart = p->HiUnit - p->Size / 8 / UNIT_SIZE * 7 * UNIT_SIZE;\r
-  p->GlueCount = 0;\r
-\r
-  p->OrderFall = p->MaxOrder;\r
-  p->RunLength = p->InitRL = -(Int32)((p->MaxOrder < 12) ? p->MaxOrder : 12) - 1;\r
-  p->PrevSuccess = 0;\r
-\r
-  p->MinContext = p->MaxContext = (CTX_PTR)(p->HiUnit -= UNIT_SIZE); /* AllocContext(p); */\r
-  p->MinContext->Suffix = 0;\r
-  p->MinContext->NumStats = 256;\r
-  p->MinContext->SummFreq = 256 + 1;\r
-  p->FoundState = (CPpmd_State *)p->LoUnit; /* AllocUnits(p, PPMD_NUM_INDEXES - 1); */\r
-  p->LoUnit += U2B(256 / 2);\r
-  p->MinContext->Stats = REF(p->FoundState);\r
-  for (i = 0; i < 256; i++)\r
-  {\r
-    CPpmd_State *s = &p->FoundState[i];\r
-    s->Symbol = (Byte)i;\r
-    s->Freq = 1;\r
-    SetSuccessor(s, 0);\r
-  }\r
-\r
-  for (i = 0; i < 128; i++)\r
-    for (k = 0; k < 8; k++)\r
-    {\r
-      UInt16 *dest = p->BinSumm[i] + k;\r
-      UInt16 val = (UInt16)(PPMD_BIN_SCALE - kInitBinEsc[k] / (i + 2));\r
-      for (m = 0; m < 64; m += 8)\r
-        dest[m] = val;\r
-    }\r
-  \r
-  for (i = 0; i < 25; i++)\r
-    for (k = 0; k < 16; k++)\r
-    {\r
-      CPpmd_See *s = &p->See[i][k];\r
-      s->Summ = (UInt16)((5 * i + 10) << (s->Shift = PPMD_PERIOD_BITS - 4));\r
-      s->Count = 4;\r
-    }\r
-}\r
-\r
-void Ppmd7_Init(CPpmd7 *p, unsigned maxOrder)\r
-{\r
-  p->MaxOrder = maxOrder;\r
-  RestartModel(p);\r
-  p->DummySee.Shift = PPMD_PERIOD_BITS;\r
-  p->DummySee.Summ = 0; /* unused */\r
-  p->DummySee.Count = 64; /* unused */\r
-}\r
-\r
-static CTX_PTR CreateSuccessors(CPpmd7 *p, Bool skip)\r
-{\r
-  CPpmd_State upState;\r
-  CTX_PTR c = p->MinContext;\r
-  CPpmd_Byte_Ref upBranch = (CPpmd_Byte_Ref)SUCCESSOR(p->FoundState);\r
-  CPpmd_State *ps[PPMD7_MAX_ORDER];\r
-  unsigned numPs = 0;\r
-  \r
-  if (!skip)\r
-    ps[numPs++] = p->FoundState;\r
-  \r
-  while (c->Suffix)\r
-  {\r
-    CPpmd_Void_Ref successor;\r
-    CPpmd_State *s;\r
-    c = SUFFIX(c);\r
-    if (c->NumStats != 1)\r
-    {\r
-      for (s = STATS(c); s->Symbol != p->FoundState->Symbol; s++);\r
-    }\r
-    else\r
-      s = ONE_STATE(c);\r
-    successor = SUCCESSOR(s);\r
-    if (successor != upBranch)\r
-    {\r
-      c = CTX(successor);\r
-      if (numPs == 0)\r
-        return c;\r
-      break;\r
-    }\r
-    ps[numPs++] = s;\r
-  }\r
-  \r
-  upState.Symbol = *(const Byte *)Ppmd7_GetPtr(p, upBranch);\r
-  SetSuccessor(&upState, upBranch + 1);\r
-  \r
-  if (c->NumStats == 1)\r
-    upState.Freq = ONE_STATE(c)->Freq;\r
-  else\r
-  {\r
-    UInt32 cf, s0;\r
-    CPpmd_State *s;\r
-    for (s = STATS(c); s->Symbol != upState.Symbol; s++);\r
-    cf = s->Freq - 1;\r
-    s0 = c->SummFreq - c->NumStats - cf;\r
-    upState.Freq = (Byte)(1 + ((2 * cf <= s0) ? (5 * cf > s0) : ((2 * cf + 3 * s0 - 1) / (2 * s0))));\r
-  }\r
-\r
-  do\r
-  {\r
-    /* Create Child */\r
-    CTX_PTR c1; /* = AllocContext(p); */\r
-    if (p->HiUnit != p->LoUnit)\r
-      c1 = (CTX_PTR)(p->HiUnit -= UNIT_SIZE);\r
-    else if (p->FreeList[0] != 0)\r
-      c1 = (CTX_PTR)RemoveNode(p, 0);\r
-    else\r
-    {\r
-      c1 = (CTX_PTR)AllocUnitsRare(p, 0);\r
-      if (!c1)\r
-        return NULL;\r
-    }\r
-    c1->NumStats = 1;\r
-    *ONE_STATE(c1) = upState;\r
-    c1->Suffix = REF(c);\r
-    SetSuccessor(ps[--numPs], REF(c1));\r
-    c = c1;\r
-  }\r
-  while (numPs != 0);\r
-  \r
-  return c;\r
-}\r
-\r
-static void SwapStates(CPpmd_State *t1, CPpmd_State *t2)\r
-{\r
-  CPpmd_State tmp = *t1;\r
-  *t1 = *t2;\r
-  *t2 = tmp;\r
-}\r
-\r
-static void UpdateModel(CPpmd7 *p)\r
-{\r
-  CPpmd_Void_Ref successor, fSuccessor = SUCCESSOR(p->FoundState);\r
-  CTX_PTR c;\r
-  unsigned s0, ns;\r
-  \r
-  if (p->FoundState->Freq < MAX_FREQ / 4 && p->MinContext->Suffix != 0)\r
-  {\r
-    c = SUFFIX(p->MinContext);\r
-    \r
-    if (c->NumStats == 1)\r
-    {\r
-      CPpmd_State *s = ONE_STATE(c);\r
-      if (s->Freq < 32)\r
-        s->Freq++;\r
-    }\r
-    else\r
-    {\r
-      CPpmd_State *s = STATS(c);\r
-      if (s->Symbol != p->FoundState->Symbol)\r
-      {\r
-        do { s++; } while (s->Symbol != p->FoundState->Symbol);\r
-        if (s[0].Freq >= s[-1].Freq)\r
-        {\r
-          SwapStates(&s[0], &s[-1]);\r
-          s--;\r
-        }\r
-      }\r
-      if (s->Freq < MAX_FREQ - 9)\r
-      {\r
-        s->Freq += 2;\r
-        c->SummFreq += 2;\r
-      }\r
-    }\r
-  }\r
-\r
-  if (p->OrderFall == 0)\r
-  {\r
-    p->MinContext = p->MaxContext = CreateSuccessors(p, True);\r
-    if (p->MinContext == 0)\r
-    {\r
-      RestartModel(p);\r
-      return;\r
-    }\r
-    SetSuccessor(p->FoundState, REF(p->MinContext));\r
-    return;\r
-  }\r
-  \r
-  *p->Text++ = p->FoundState->Symbol;\r
-  successor = REF(p->Text);\r
-  if (p->Text >= p->UnitsStart)\r
-  {\r
-    RestartModel(p);\r
-    return;\r
-  }\r
-  \r
-  if (fSuccessor)\r
-  {\r
-    if (fSuccessor <= successor)\r
-    {\r
-      CTX_PTR cs = CreateSuccessors(p, False);\r
-      if (cs == NULL)\r
-      {\r
-        RestartModel(p);\r
-        return;\r
-      }\r
-      fSuccessor = REF(cs);\r
-    }\r
-    if (--p->OrderFall == 0)\r
-    {\r
-      successor = fSuccessor;\r
-      p->Text -= (p->MaxContext != p->MinContext);\r
-    }\r
-  }\r
-  else\r
-  {\r
-    SetSuccessor(p->FoundState, successor);\r
-    fSuccessor = REF(p->MinContext);\r
-  }\r
-  \r
-  s0 = p->MinContext->SummFreq - (ns = p->MinContext->NumStats) - (p->FoundState->Freq - 1);\r
-  \r
-  for (c = p->MaxContext; c != p->MinContext; c = SUFFIX(c))\r
-  {\r
-    unsigned ns1;\r
-    UInt32 cf, sf;\r
-    if ((ns1 = c->NumStats) != 1)\r
-    {\r
-      if ((ns1 & 1) == 0)\r
-      {\r
-        /* Expand for one UNIT */\r
-        unsigned oldNU = ns1 >> 1;\r
-        unsigned i = U2I(oldNU);\r
-        if (i != U2I(oldNU + 1))\r
-        {\r
-          void *ptr = AllocUnits(p, i + 1);\r
-          void *oldPtr;\r
-          if (!ptr)\r
-          {\r
-            RestartModel(p);\r
-            return;\r
-          }\r
-          oldPtr = STATS(c);\r
-          MyMem12Cpy(ptr, oldPtr, oldNU);\r
-          InsertNode(p, oldPtr, i);\r
-          c->Stats = STATS_REF(ptr);\r
-        }\r
-      }\r
-      c->SummFreq = (UInt16)(c->SummFreq + (2 * ns1 < ns) + 2 * ((4 * ns1 <= ns) & (c->SummFreq <= 8 * ns1)));\r
-    }\r
-    else\r
-    {\r
-      CPpmd_State *s = (CPpmd_State*)AllocUnits(p, 0);\r
-      if (!s)\r
-      {\r
-        RestartModel(p);\r
-        return;\r
-      }\r
-      *s = *ONE_STATE(c);\r
-      c->Stats = REF(s);\r
-      if (s->Freq < MAX_FREQ / 4 - 1)\r
-        s->Freq <<= 1;\r
-      else\r
-        s->Freq = MAX_FREQ - 4;\r
-      c->SummFreq = (UInt16)(s->Freq + p->InitEsc + (ns > 3));\r
-    }\r
-    cf = 2 * (UInt32)p->FoundState->Freq * (c->SummFreq + 6);\r
-    sf = (UInt32)s0 + c->SummFreq;\r
-    if (cf < 6 * sf)\r
-    {\r
-      cf = 1 + (cf > sf) + (cf >= 4 * sf);\r
-      c->SummFreq += 3;\r
-    }\r
-    else\r
-    {\r
-      cf = 4 + (cf >= 9 * sf) + (cf >= 12 * sf) + (cf >= 15 * sf);\r
-      c->SummFreq = (UInt16)(c->SummFreq + cf);\r
-    }\r
-    {\r
-      CPpmd_State *s = STATS(c) + ns1;\r
-      SetSuccessor(s, successor);\r
-      s->Symbol = p->FoundState->Symbol;\r
-      s->Freq = (Byte)cf;\r
-      c->NumStats = (UInt16)(ns1 + 1);\r
-    }\r
-  }\r
-  p->MaxContext = p->MinContext = CTX(fSuccessor);\r
-}\r
-  \r
-static void Rescale(CPpmd7 *p)\r
-{\r
-  unsigned i, adder, sumFreq, escFreq;\r
-  CPpmd_State *stats = STATS(p->MinContext);\r
-  CPpmd_State *s = p->FoundState;\r
-  {\r
-    CPpmd_State tmp = *s;\r
-    for (; s != stats; s--)\r
-      s[0] = s[-1];\r
-    *s = tmp;\r
-  }\r
-  escFreq = p->MinContext->SummFreq - s->Freq;\r
-  s->Freq += 4;\r
-  adder = (p->OrderFall != 0);\r
-  s->Freq = (Byte)((s->Freq + adder) >> 1);\r
-  sumFreq = s->Freq;\r
-  \r
-  i = p->MinContext->NumStats - 1;\r
-  do\r
-  {\r
-    escFreq -= (++s)->Freq;\r
-    s->Freq = (Byte)((s->Freq + adder) >> 1);\r
-    sumFreq += s->Freq;\r
-    if (s[0].Freq > s[-1].Freq)\r
-    {\r
-      CPpmd_State *s1 = s;\r
-      CPpmd_State tmp = *s1;\r
-      do\r
-        s1[0] = s1[-1];\r
-      while (--s1 != stats && tmp.Freq > s1[-1].Freq);\r
-      *s1 = tmp;\r
-    }\r
-  }\r
-  while (--i);\r
-  \r
-  if (s->Freq == 0)\r
-  {\r
-    unsigned numStats = p->MinContext->NumStats;\r
-    unsigned n0, n1;\r
-    do { i++; } while ((--s)->Freq == 0);\r
-    escFreq += i;\r
-    p->MinContext->NumStats = (UInt16)(p->MinContext->NumStats - i);\r
-    if (p->MinContext->NumStats == 1)\r
-    {\r
-      CPpmd_State tmp = *stats;\r
-      do\r
-      {\r
-        tmp.Freq = (Byte)(tmp.Freq - (tmp.Freq >> 1));\r
-        escFreq >>= 1;\r
-      }\r
-      while (escFreq > 1);\r
-      InsertNode(p, stats, U2I(((numStats + 1) >> 1)));\r
-      *(p->FoundState = ONE_STATE(p->MinContext)) = tmp;\r
-      return;\r
-    }\r
-    n0 = (numStats + 1) >> 1;\r
-    n1 = (p->MinContext->NumStats + 1) >> 1;\r
-    if (n0 != n1)\r
-      p->MinContext->Stats = STATS_REF(ShrinkUnits(p, stats, n0, n1));\r
-  }\r
-  p->MinContext->SummFreq = (UInt16)(sumFreq + escFreq - (escFreq >> 1));\r
-  p->FoundState = STATS(p->MinContext);\r
-}\r
-\r
-CPpmd_See *Ppmd7_MakeEscFreq(CPpmd7 *p, unsigned numMasked, UInt32 *escFreq)\r
-{\r
-  CPpmd_See *see;\r
-  unsigned nonMasked = p->MinContext->NumStats - numMasked;\r
-  if (p->MinContext->NumStats != 256)\r
-  {\r
-    see = p->See[(unsigned)p->NS2Indx[nonMasked - 1]] +\r
-        (nonMasked < (unsigned)SUFFIX(p->MinContext)->NumStats - p->MinContext->NumStats) +\r
-        2 * (unsigned)(p->MinContext->SummFreq < 11 * p->MinContext->NumStats) +\r
-        4 * (unsigned)(numMasked > nonMasked) +\r
-        p->HiBitsFlag;\r
-    {\r
-      unsigned r = (see->Summ >> see->Shift);\r
-      see->Summ = (UInt16)(see->Summ - r);\r
-      *escFreq = r + (r == 0);\r
-    }\r
-  }\r
-  else\r
-  {\r
-    see = &p->DummySee;\r
-    *escFreq = 1;\r
-  }\r
-  return see;\r
-}\r
-\r
-static void NextContext(CPpmd7 *p)\r
-{\r
-  CTX_PTR c = CTX(SUCCESSOR(p->FoundState));\r
-  if (p->OrderFall == 0 && (Byte *)c > p->Text)\r
-    p->MinContext = p->MaxContext = c;\r
-  else\r
-    UpdateModel(p);\r
-}\r
-\r
-void Ppmd7_Update1(CPpmd7 *p)\r
-{\r
-  CPpmd_State *s = p->FoundState;\r
-  s->Freq += 4;\r
-  p->MinContext->SummFreq += 4;\r
-  if (s[0].Freq > s[-1].Freq)\r
-  {\r
-    SwapStates(&s[0], &s[-1]);\r
-    p->FoundState = --s;\r
-    if (s->Freq > MAX_FREQ)\r
-      Rescale(p);\r
-  }\r
-  NextContext(p);\r
-}\r
-\r
-void Ppmd7_Update1_0(CPpmd7 *p)\r
-{\r
-  p->PrevSuccess = (2 * p->FoundState->Freq > p->MinContext->SummFreq);\r
-  p->RunLength += p->PrevSuccess;\r
-  p->MinContext->SummFreq += 4;\r
-  if ((p->FoundState->Freq += 4) > MAX_FREQ)\r
-    Rescale(p);\r
-  NextContext(p);\r
-}\r
-\r
-void Ppmd7_UpdateBin(CPpmd7 *p)\r
-{\r
-  p->FoundState->Freq = (Byte)(p->FoundState->Freq + (p->FoundState->Freq < 128 ? 1: 0));\r
-  p->PrevSuccess = 1;\r
-  p->RunLength++;\r
-  NextContext(p);\r
-}\r
-\r
-void Ppmd7_Update2(CPpmd7 *p)\r
-{\r
-  p->MinContext->SummFreq += 4;\r
-  if ((p->FoundState->Freq += 4) > MAX_FREQ)\r
-    Rescale(p);\r
-  p->RunLength = p->InitRL;\r
-  UpdateModel(p);\r
-}\r
diff --git a/deps/lzma-16.04/C/Ppmd7.h b/deps/lzma-16.04/C/Ppmd7.h
deleted file mode 100644 (file)
index 1c7870c..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/* Ppmd7.h -- PPMdH compression codec\r
-2016-05-21 : Igor Pavlov : Public domain\r
-This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */\r
-\r
-/* This code supports virtual RangeDecoder and includes the implementation\r
-of RangeCoder from 7z, instead of RangeCoder from original PPMd var.H.\r
-If you need the compatibility with original PPMd var.H, you can use external RangeDecoder */\r
-\r
-#ifndef __PPMD7_H\r
-#define __PPMD7_H\r
-\r
-#include "Ppmd.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-#define PPMD7_MIN_ORDER 2\r
-#define PPMD7_MAX_ORDER 64\r
-\r
-#define PPMD7_MIN_MEM_SIZE (1 << 11)\r
-#define PPMD7_MAX_MEM_SIZE (0xFFFFFFFF - 12 * 3)\r
-\r
-struct CPpmd7_Context_;\r
-\r
-typedef\r
-  #ifdef PPMD_32BIT\r
-    struct CPpmd7_Context_ *\r
-  #else\r
-    UInt32\r
-  #endif\r
-  CPpmd7_Context_Ref;\r
-\r
-typedef struct CPpmd7_Context_\r
-{\r
-  UInt16 NumStats;\r
-  UInt16 SummFreq;\r
-  CPpmd_State_Ref Stats;\r
-  CPpmd7_Context_Ref Suffix;\r
-} CPpmd7_Context;\r
-\r
-#define Ppmd7Context_OneState(p) ((CPpmd_State *)&(p)->SummFreq)\r
-\r
-typedef struct\r
-{\r
-  CPpmd7_Context *MinContext, *MaxContext;\r
-  CPpmd_State *FoundState;\r
-  unsigned OrderFall, InitEsc, PrevSuccess, MaxOrder, HiBitsFlag;\r
-  Int32 RunLength, InitRL; /* must be 32-bit at least */\r
-\r
-  UInt32 Size;\r
-  UInt32 GlueCount;\r
-  Byte *Base, *LoUnit, *HiUnit, *Text, *UnitsStart;\r
-  UInt32 AlignOffset;\r
-\r
-  Byte Indx2Units[PPMD_NUM_INDEXES];\r
-  Byte Units2Indx[128];\r
-  CPpmd_Void_Ref FreeList[PPMD_NUM_INDEXES];\r
-  Byte NS2Indx[256], NS2BSIndx[256], HB2Flag[256];\r
-  CPpmd_See DummySee, See[25][16];\r
-  UInt16 BinSumm[128][64];\r
-} CPpmd7;\r
-\r
-void Ppmd7_Construct(CPpmd7 *p);\r
-Bool Ppmd7_Alloc(CPpmd7 *p, UInt32 size, ISzAlloc *alloc);\r
-void Ppmd7_Free(CPpmd7 *p, ISzAlloc *alloc);\r
-void Ppmd7_Init(CPpmd7 *p, unsigned maxOrder);\r
-#define Ppmd7_WasAllocated(p) ((p)->Base != NULL)\r
-\r
-\r
-/* ---------- Internal Functions ---------- */\r
-\r
-extern const Byte PPMD7_kExpEscape[16];\r
-\r
-#ifdef PPMD_32BIT\r
-  #define Ppmd7_GetPtr(p, ptr) (ptr)\r
-  #define Ppmd7_GetContext(p, ptr) (ptr)\r
-  #define Ppmd7_GetStats(p, ctx) ((ctx)->Stats)\r
-#else\r
-  #define Ppmd7_GetPtr(p, offs) ((void *)((p)->Base + (offs)))\r
-  #define Ppmd7_GetContext(p, offs) ((CPpmd7_Context *)Ppmd7_GetPtr((p), (offs)))\r
-  #define Ppmd7_GetStats(p, ctx) ((CPpmd_State *)Ppmd7_GetPtr((p), ((ctx)->Stats)))\r
-#endif\r
-\r
-void Ppmd7_Update1(CPpmd7 *p);\r
-void Ppmd7_Update1_0(CPpmd7 *p);\r
-void Ppmd7_Update2(CPpmd7 *p);\r
-void Ppmd7_UpdateBin(CPpmd7 *p);\r
-\r
-#define Ppmd7_GetBinSumm(p) \\r
-    &p->BinSumm[(unsigned)Ppmd7Context_OneState(p->MinContext)->Freq - 1][p->PrevSuccess + \\r
-    p->NS2BSIndx[Ppmd7_GetContext(p, p->MinContext->Suffix)->NumStats - 1] + \\r
-    (p->HiBitsFlag = p->HB2Flag[p->FoundState->Symbol]) + \\r
-    2 * p->HB2Flag[(unsigned)Ppmd7Context_OneState(p->MinContext)->Symbol] + \\r
-    ((p->RunLength >> 26) & 0x20)]\r
-\r
-CPpmd_See *Ppmd7_MakeEscFreq(CPpmd7 *p, unsigned numMasked, UInt32 *scale);\r
-\r
-\r
-/* ---------- Decode ---------- */\r
-\r
-typedef struct\r
-{\r
-  UInt32 (*GetThreshold)(void *p, UInt32 total);\r
-  void (*Decode)(void *p, UInt32 start, UInt32 size);\r
-  UInt32 (*DecodeBit)(void *p, UInt32 size0);\r
-} IPpmd7_RangeDec;\r
-\r
-typedef struct\r
-{\r
-  IPpmd7_RangeDec p;\r
-  UInt32 Range;\r
-  UInt32 Code;\r
-  IByteIn *Stream;\r
-} CPpmd7z_RangeDec;\r
-\r
-void Ppmd7z_RangeDec_CreateVTable(CPpmd7z_RangeDec *p);\r
-Bool Ppmd7z_RangeDec_Init(CPpmd7z_RangeDec *p);\r
-#define Ppmd7z_RangeDec_IsFinishedOK(p) ((p)->Code == 0)\r
-\r
-int Ppmd7_DecodeSymbol(CPpmd7 *p, IPpmd7_RangeDec *rc);\r
-\r
-\r
-/* ---------- Encode ---------- */\r
-\r
-typedef struct\r
-{\r
-  UInt64 Low;\r
-  UInt32 Range;\r
-  Byte Cache;\r
-  UInt64 CacheSize;\r
-  IByteOut *Stream;\r
-} CPpmd7z_RangeEnc;\r
-\r
-void Ppmd7z_RangeEnc_Init(CPpmd7z_RangeEnc *p);\r
-void Ppmd7z_RangeEnc_FlushData(CPpmd7z_RangeEnc *p);\r
-\r
-void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol);\r
-\r
-EXTERN_C_END\r
\r
-#endif\r
diff --git a/deps/lzma-16.04/C/Ppmd7Dec.c b/deps/lzma-16.04/C/Ppmd7Dec.c
deleted file mode 100644 (file)
index 3d01d76..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-/* Ppmd7Dec.c -- PPMdH Decoder\r
-2010-03-12 : Igor Pavlov : Public domain\r
-This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "Ppmd7.h"\r
-\r
-#define kTopValue (1 << 24)\r
-\r
-Bool Ppmd7z_RangeDec_Init(CPpmd7z_RangeDec *p)\r
-{\r
-  unsigned i;\r
-  p->Code = 0;\r
-  p->Range = 0xFFFFFFFF;\r
-  if (p->Stream->Read((void *)p->Stream) != 0)\r
-    return False;\r
-  for (i = 0; i < 4; i++)\r
-    p->Code = (p->Code << 8) | p->Stream->Read((void *)p->Stream);\r
-  return (p->Code < 0xFFFFFFFF);\r
-}\r
-\r
-static UInt32 Range_GetThreshold(void *pp, UInt32 total)\r
-{\r
-  CPpmd7z_RangeDec *p = (CPpmd7z_RangeDec *)pp;\r
-  return (p->Code) / (p->Range /= total);\r
-}\r
-\r
-static void Range_Normalize(CPpmd7z_RangeDec *p)\r
-{\r
-  if (p->Range < kTopValue)\r
-  {\r
-    p->Code = (p->Code << 8) | p->Stream->Read((void *)p->Stream);\r
-    p->Range <<= 8;\r
-    if (p->Range < kTopValue)\r
-    {\r
-      p->Code = (p->Code << 8) | p->Stream->Read((void *)p->Stream);\r
-      p->Range <<= 8;\r
-    }\r
-  }\r
-}\r
-\r
-static void Range_Decode(void *pp, UInt32 start, UInt32 size)\r
-{\r
-  CPpmd7z_RangeDec *p = (CPpmd7z_RangeDec *)pp;\r
-  p->Code -= start * p->Range;\r
-  p->Range *= size;\r
-  Range_Normalize(p);\r
-}\r
-\r
-static UInt32 Range_DecodeBit(void *pp, UInt32 size0)\r
-{\r
-  CPpmd7z_RangeDec *p = (CPpmd7z_RangeDec *)pp;\r
-  UInt32 newBound = (p->Range >> 14) * size0;\r
-  UInt32 symbol;\r
-  if (p->Code < newBound)\r
-  {\r
-    symbol = 0;\r
-    p->Range = newBound;\r
-  }\r
-  else\r
-  {\r
-    symbol = 1;\r
-    p->Code -= newBound;\r
-    p->Range -= newBound;\r
-  }\r
-  Range_Normalize(p);\r
-  return symbol;\r
-}\r
-\r
-void Ppmd7z_RangeDec_CreateVTable(CPpmd7z_RangeDec *p)\r
-{\r
-  p->p.GetThreshold = Range_GetThreshold;\r
-  p->p.Decode = Range_Decode;\r
-  p->p.DecodeBit = Range_DecodeBit;\r
-}\r
-\r
-\r
-#define MASK(sym) ((signed char *)charMask)[sym]\r
-\r
-int Ppmd7_DecodeSymbol(CPpmd7 *p, IPpmd7_RangeDec *rc)\r
-{\r
-  size_t charMask[256 / sizeof(size_t)];\r
-  if (p->MinContext->NumStats != 1)\r
-  {\r
-    CPpmd_State *s = Ppmd7_GetStats(p, p->MinContext);\r
-    unsigned i;\r
-    UInt32 count, hiCnt;\r
-    if ((count = rc->GetThreshold(rc, p->MinContext->SummFreq)) < (hiCnt = s->Freq))\r
-    {\r
-      Byte symbol;\r
-      rc->Decode(rc, 0, s->Freq);\r
-      p->FoundState = s;\r
-      symbol = s->Symbol;\r
-      Ppmd7_Update1_0(p);\r
-      return symbol;\r
-    }\r
-    p->PrevSuccess = 0;\r
-    i = p->MinContext->NumStats - 1;\r
-    do\r
-    {\r
-      if ((hiCnt += (++s)->Freq) > count)\r
-      {\r
-        Byte symbol;\r
-        rc->Decode(rc, hiCnt - s->Freq, s->Freq);\r
-        p->FoundState = s;\r
-        symbol = s->Symbol;\r
-        Ppmd7_Update1(p);\r
-        return symbol;\r
-      }\r
-    }\r
-    while (--i);\r
-    if (count >= p->MinContext->SummFreq)\r
-      return -2;\r
-    p->HiBitsFlag = p->HB2Flag[p->FoundState->Symbol];\r
-    rc->Decode(rc, hiCnt, p->MinContext->SummFreq - hiCnt);\r
-    PPMD_SetAllBitsIn256Bytes(charMask);\r
-    MASK(s->Symbol) = 0;\r
-    i = p->MinContext->NumStats - 1;\r
-    do { MASK((--s)->Symbol) = 0; } while (--i);\r
-  }\r
-  else\r
-  {\r
-    UInt16 *prob = Ppmd7_GetBinSumm(p);\r
-    if (rc->DecodeBit(rc, *prob) == 0)\r
-    {\r
-      Byte symbol;\r
-      *prob = (UInt16)PPMD_UPDATE_PROB_0(*prob);\r
-      symbol = (p->FoundState = Ppmd7Context_OneState(p->MinContext))->Symbol;\r
-      Ppmd7_UpdateBin(p);\r
-      return symbol;\r
-    }\r
-    *prob = (UInt16)PPMD_UPDATE_PROB_1(*prob);\r
-    p->InitEsc = PPMD7_kExpEscape[*prob >> 10];\r
-    PPMD_SetAllBitsIn256Bytes(charMask);\r
-    MASK(Ppmd7Context_OneState(p->MinContext)->Symbol) = 0;\r
-    p->PrevSuccess = 0;\r
-  }\r
-  for (;;)\r
-  {\r
-    CPpmd_State *ps[256], *s;\r
-    UInt32 freqSum, count, hiCnt;\r
-    CPpmd_See *see;\r
-    unsigned i, num, numMasked = p->MinContext->NumStats;\r
-    do\r
-    {\r
-      p->OrderFall++;\r
-      if (!p->MinContext->Suffix)\r
-        return -1;\r
-      p->MinContext = Ppmd7_GetContext(p, p->MinContext->Suffix);\r
-    }\r
-    while (p->MinContext->NumStats == numMasked);\r
-    hiCnt = 0;\r
-    s = Ppmd7_GetStats(p, p->MinContext);\r
-    i = 0;\r
-    num = p->MinContext->NumStats - numMasked;\r
-    do\r
-    {\r
-      int k = (int)(MASK(s->Symbol));\r
-      hiCnt += (s->Freq & k);\r
-      ps[i] = s++;\r
-      i -= k;\r
-    }\r
-    while (i != num);\r
-    \r
-    see = Ppmd7_MakeEscFreq(p, numMasked, &freqSum);\r
-    freqSum += hiCnt;\r
-    count = rc->GetThreshold(rc, freqSum);\r
-    \r
-    if (count < hiCnt)\r
-    {\r
-      Byte symbol;\r
-      CPpmd_State **pps = ps;\r
-      for (hiCnt = 0; (hiCnt += (*pps)->Freq) <= count; pps++);\r
-      s = *pps;\r
-      rc->Decode(rc, hiCnt - s->Freq, s->Freq);\r
-      Ppmd_See_Update(see);\r
-      p->FoundState = s;\r
-      symbol = s->Symbol;\r
-      Ppmd7_Update2(p);\r
-      return symbol;\r
-    }\r
-    if (count >= freqSum)\r
-      return -2;\r
-    rc->Decode(rc, hiCnt, freqSum - hiCnt);\r
-    see->Summ = (UInt16)(see->Summ + freqSum);\r
-    do { MASK(ps[--i]->Symbol) = 0; } while (i != 0);\r
-  }\r
-}\r
diff --git a/deps/lzma-16.04/C/Ppmd7Enc.c b/deps/lzma-16.04/C/Ppmd7Enc.c
deleted file mode 100644 (file)
index 9b49e5d..0000000
+++ /dev/null
@@ -1,187 +0,0 @@
-/* Ppmd7Enc.c -- PPMdH Encoder\r
-2015-09-28 : Igor Pavlov : Public domain\r
-This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "Ppmd7.h"\r
-\r
-#define kTopValue (1 << 24)\r
-\r
-void Ppmd7z_RangeEnc_Init(CPpmd7z_RangeEnc *p)\r
-{\r
-  p->Low = 0;\r
-  p->Range = 0xFFFFFFFF;\r
-  p->Cache = 0;\r
-  p->CacheSize = 1;\r
-}\r
-\r
-static void RangeEnc_ShiftLow(CPpmd7z_RangeEnc *p)\r
-{\r
-  if ((UInt32)p->Low < (UInt32)0xFF000000 || (unsigned)(p->Low >> 32) != 0)\r
-  {\r
-    Byte temp = p->Cache;\r
-    do\r
-    {\r
-      p->Stream->Write(p->Stream, (Byte)(temp + (Byte)(p->Low >> 32)));\r
-      temp = 0xFF;\r
-    }\r
-    while (--p->CacheSize != 0);\r
-    p->Cache = (Byte)((UInt32)p->Low >> 24);\r
-  }\r
-  p->CacheSize++;\r
-  p->Low = (UInt32)p->Low << 8;\r
-}\r
-\r
-static void RangeEnc_Encode(CPpmd7z_RangeEnc *p, UInt32 start, UInt32 size, UInt32 total)\r
-{\r
-  p->Low += start * (p->Range /= total);\r
-  p->Range *= size;\r
-  while (p->Range < kTopValue)\r
-  {\r
-    p->Range <<= 8;\r
-    RangeEnc_ShiftLow(p);\r
-  }\r
-}\r
-\r
-static void RangeEnc_EncodeBit_0(CPpmd7z_RangeEnc *p, UInt32 size0)\r
-{\r
-  p->Range = (p->Range >> 14) * size0;\r
-  while (p->Range < kTopValue)\r
-  {\r
-    p->Range <<= 8;\r
-    RangeEnc_ShiftLow(p);\r
-  }\r
-}\r
-\r
-static void RangeEnc_EncodeBit_1(CPpmd7z_RangeEnc *p, UInt32 size0)\r
-{\r
-  UInt32 newBound = (p->Range >> 14) * size0;\r
-  p->Low += newBound;\r
-  p->Range -= newBound;\r
-  while (p->Range < kTopValue)\r
-  {\r
-    p->Range <<= 8;\r
-    RangeEnc_ShiftLow(p);\r
-  }\r
-}\r
-\r
-void Ppmd7z_RangeEnc_FlushData(CPpmd7z_RangeEnc *p)\r
-{\r
-  unsigned i;\r
-  for (i = 0; i < 5; i++)\r
-    RangeEnc_ShiftLow(p);\r
-}\r
-\r
-\r
-#define MASK(sym) ((signed char *)charMask)[sym]\r
-\r
-void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol)\r
-{\r
-  size_t charMask[256 / sizeof(size_t)];\r
-  if (p->MinContext->NumStats != 1)\r
-  {\r
-    CPpmd_State *s = Ppmd7_GetStats(p, p->MinContext);\r
-    UInt32 sum;\r
-    unsigned i;\r
-    if (s->Symbol == symbol)\r
-    {\r
-      RangeEnc_Encode(rc, 0, s->Freq, p->MinContext->SummFreq);\r
-      p->FoundState = s;\r
-      Ppmd7_Update1_0(p);\r
-      return;\r
-    }\r
-    p->PrevSuccess = 0;\r
-    sum = s->Freq;\r
-    i = p->MinContext->NumStats - 1;\r
-    do\r
-    {\r
-      if ((++s)->Symbol == symbol)\r
-      {\r
-        RangeEnc_Encode(rc, sum, s->Freq, p->MinContext->SummFreq);\r
-        p->FoundState = s;\r
-        Ppmd7_Update1(p);\r
-        return;\r
-      }\r
-      sum += s->Freq;\r
-    }\r
-    while (--i);\r
-    \r
-    p->HiBitsFlag = p->HB2Flag[p->FoundState->Symbol];\r
-    PPMD_SetAllBitsIn256Bytes(charMask);\r
-    MASK(s->Symbol) = 0;\r
-    i = p->MinContext->NumStats - 1;\r
-    do { MASK((--s)->Symbol) = 0; } while (--i);\r
-    RangeEnc_Encode(rc, sum, p->MinContext->SummFreq - sum, p->MinContext->SummFreq);\r
-  }\r
-  else\r
-  {\r
-    UInt16 *prob = Ppmd7_GetBinSumm(p);\r
-    CPpmd_State *s = Ppmd7Context_OneState(p->MinContext);\r
-    if (s->Symbol == symbol)\r
-    {\r
-      RangeEnc_EncodeBit_0(rc, *prob);\r
-      *prob = (UInt16)PPMD_UPDATE_PROB_0(*prob);\r
-      p->FoundState = s;\r
-      Ppmd7_UpdateBin(p);\r
-      return;\r
-    }\r
-    else\r
-    {\r
-      RangeEnc_EncodeBit_1(rc, *prob);\r
-      *prob = (UInt16)PPMD_UPDATE_PROB_1(*prob);\r
-      p->InitEsc = PPMD7_kExpEscape[*prob >> 10];\r
-      PPMD_SetAllBitsIn256Bytes(charMask);\r
-      MASK(s->Symbol) = 0;\r
-      p->PrevSuccess = 0;\r
-    }\r
-  }\r
-  for (;;)\r
-  {\r
-    UInt32 escFreq;\r
-    CPpmd_See *see;\r
-    CPpmd_State *s;\r
-    UInt32 sum;\r
-    unsigned i, numMasked = p->MinContext->NumStats;\r
-    do\r
-    {\r
-      p->OrderFall++;\r
-      if (!p->MinContext->Suffix)\r
-        return; /* EndMarker (symbol = -1) */\r
-      p->MinContext = Ppmd7_GetContext(p, p->MinContext->Suffix);\r
-    }\r
-    while (p->MinContext->NumStats == numMasked);\r
-    \r
-    see = Ppmd7_MakeEscFreq(p, numMasked, &escFreq);\r
-    s = Ppmd7_GetStats(p, p->MinContext);\r
-    sum = 0;\r
-    i = p->MinContext->NumStats;\r
-    do\r
-    {\r
-      int cur = s->Symbol;\r
-      if (cur == symbol)\r
-      {\r
-        UInt32 low = sum;\r
-        CPpmd_State *s1 = s;\r
-        do\r
-        {\r
-          sum += (s->Freq & (int)(MASK(s->Symbol)));\r
-          s++;\r
-        }\r
-        while (--i);\r
-        RangeEnc_Encode(rc, low, s1->Freq, sum + escFreq);\r
-        Ppmd_See_Update(see);\r
-        p->FoundState = s1;\r
-        Ppmd7_Update2(p);\r
-        return;\r
-      }\r
-      sum += (s->Freq & (int)(MASK(cur)));\r
-      MASK(cur) = 0;\r
-      s++;\r
-    }\r
-    while (--i);\r
-    \r
-    RangeEnc_Encode(rc, sum, escFreq, sum + escFreq);\r
-    see->Summ = (UInt16)(see->Summ + sum + escFreq);\r
-  }\r
-}\r
diff --git a/deps/lzma-16.04/C/Precomp.h b/deps/lzma-16.04/C/Precomp.h
deleted file mode 100644 (file)
index edb5814..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-/* Precomp.h -- StdAfx\r
-2013-11-12 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __7Z_PRECOMP_H\r
-#define __7Z_PRECOMP_H\r
-\r
-#include "Compiler.h"\r
-/* #include "7zTypes.h" */\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/RotateDefs.h b/deps/lzma-16.04/C/RotateDefs.h
deleted file mode 100644 (file)
index 6c790e7..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/* RotateDefs.h -- Rotate functions\r
-2015-03-25 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __ROTATE_DEFS_H\r
-#define __ROTATE_DEFS_H\r
-\r
-#ifdef _MSC_VER\r
-\r
-#include <stdlib.h>\r
-\r
-/* don't use _rotl with MINGW. It can insert slow call to function. */\r
\r
-/* #if (_MSC_VER >= 1200) */\r
-#pragma intrinsic(_rotl)\r
-#pragma intrinsic(_rotr)\r
-/* #endif */\r
-\r
-#define rotlFixed(x, n) _rotl((x), (n))\r
-#define rotrFixed(x, n) _rotr((x), (n))\r
-\r
-#else\r
-\r
-/* new compilers can translate these macros to fast commands. */\r
-\r
-#define rotlFixed(x, n) (((x) << (n)) | ((x) >> (32 - (n))))\r
-#define rotrFixed(x, n) (((x) >> (n)) | ((x) << (32 - (n))))\r
-\r
-#endif\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/Sha256.c b/deps/lzma-16.04/C/Sha256.c
deleted file mode 100644 (file)
index 47e2f42..0000000
+++ /dev/null
@@ -1,248 +0,0 @@
-/* Crypto/Sha256.c -- SHA-256 Hash\r
-2015-11-14 : Igor Pavlov : Public domain\r
-This code is based on public domain code from Wei Dai's Crypto++ library. */\r
-\r
-#include "Precomp.h"\r
-\r
-#include <string.h>\r
-\r
-#include "CpuArch.h"\r
-#include "RotateDefs.h"\r
-#include "Sha256.h"\r
-\r
-/* define it for speed optimization */\r
-#ifndef _SFX\r
-#define _SHA256_UNROLL\r
-#define _SHA256_UNROLL2\r
-#endif\r
-\r
-/* #define _SHA256_UNROLL2 */\r
-\r
-void Sha256_Init(CSha256 *p)\r
-{\r
-  p->state[0] = 0x6a09e667;\r
-  p->state[1] = 0xbb67ae85;\r
-  p->state[2] = 0x3c6ef372;\r
-  p->state[3] = 0xa54ff53a;\r
-  p->state[4] = 0x510e527f;\r
-  p->state[5] = 0x9b05688c;\r
-  p->state[6] = 0x1f83d9ab;\r
-  p->state[7] = 0x5be0cd19;\r
-  p->count = 0;\r
-}\r
-\r
-#define S0(x) (rotrFixed(x, 2) ^ rotrFixed(x,13) ^ rotrFixed(x, 22))\r
-#define S1(x) (rotrFixed(x, 6) ^ rotrFixed(x,11) ^ rotrFixed(x, 25))\r
-#define s0(x) (rotrFixed(x, 7) ^ rotrFixed(x,18) ^ (x >> 3))\r
-#define s1(x) (rotrFixed(x,17) ^ rotrFixed(x,19) ^ (x >> 10))\r
-\r
-#define blk0(i) (W[i])\r
-#define blk2(i) (W[i] += s1(W[((i)-2)&15]) + W[((i)-7)&15] + s0(W[((i)-15)&15]))\r
-\r
-#define Ch(x,y,z) (z^(x&(y^z)))\r
-#define Maj(x,y,z) ((x&y)|(z&(x|y)))\r
-\r
-#ifdef _SHA256_UNROLL2\r
-\r
-#define R(a,b,c,d,e,f,g,h, i) \\r
-    h += S1(e) + Ch(e,f,g) + K[(i)+(j)] + (j ? blk2(i) : blk0(i)); \\r
-    d += h; \\r
-    h += S0(a) + Maj(a, b, c)\r
-\r
-#define RX_8(i) \\r
-  R(a,b,c,d,e,f,g,h, i); \\r
-  R(h,a,b,c,d,e,f,g, i+1); \\r
-  R(g,h,a,b,c,d,e,f, i+2); \\r
-  R(f,g,h,a,b,c,d,e, i+3); \\r
-  R(e,f,g,h,a,b,c,d, i+4); \\r
-  R(d,e,f,g,h,a,b,c, i+5); \\r
-  R(c,d,e,f,g,h,a,b, i+6); \\r
-  R(b,c,d,e,f,g,h,a, i+7)\r
-\r
-#define RX_16  RX_8(0); RX_8(8);\r
-\r
-#else\r
-\r
-#define a(i) T[(0-(i))&7]\r
-#define b(i) T[(1-(i))&7]\r
-#define c(i) T[(2-(i))&7]\r
-#define d(i) T[(3-(i))&7]\r
-#define e(i) T[(4-(i))&7]\r
-#define f(i) T[(5-(i))&7]\r
-#define g(i) T[(6-(i))&7]\r
-#define h(i) T[(7-(i))&7]\r
-\r
-#define R(i) \\r
-    h(i) += S1(e(i)) + Ch(e(i),f(i),g(i)) + K[(i)+(j)] + (j ? blk2(i) : blk0(i)); \\r
-    d(i) += h(i); \\r
-    h(i) += S0(a(i)) + Maj(a(i), b(i), c(i)) \\r
-\r
-#ifdef _SHA256_UNROLL\r
-\r
-#define RX_8(i)  R(i+0); R(i+1); R(i+2); R(i+3); R(i+4); R(i+5); R(i+6); R(i+7);\r
-#define RX_16  RX_8(0); RX_8(8);\r
-\r
-#else\r
-\r
-#define RX_16  unsigned i; for (i = 0; i < 16; i++) { R(i); }\r
-\r
-#endif\r
-\r
-#endif\r
-\r
-static const UInt32 K[64] = {\r
-  0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,\r
-  0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\r
-  0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,\r
-  0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\r
-  0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,\r
-  0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\r
-  0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,\r
-  0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\r
-  0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,\r
-  0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\r
-  0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,\r
-  0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\r
-  0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,\r
-  0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\r
-  0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,\r
-  0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\r
-};\r
-\r
-static void Sha256_WriteByteBlock(CSha256 *p)\r
-{\r
-  UInt32 W[16];\r
-  unsigned j;\r
-  UInt32 *state;\r
-\r
-  #ifdef _SHA256_UNROLL2\r
-  UInt32 a,b,c,d,e,f,g,h;\r
-  #else\r
-  UInt32 T[8];\r
-  #endif\r
-\r
-  for (j = 0; j < 16; j += 4)\r
-  {\r
-    const Byte *ccc = p->buffer + j * 4;\r
-    W[j    ] = GetBe32(ccc);\r
-    W[j + 1] = GetBe32(ccc + 4);\r
-    W[j + 2] = GetBe32(ccc + 8);\r
-    W[j + 3] = GetBe32(ccc + 12);\r
-  }\r
-\r
-  state = p->state;\r
-\r
-  #ifdef _SHA256_UNROLL2\r
-  a = state[0];\r
-  b = state[1];\r
-  c = state[2];\r
-  d = state[3];\r
-  e = state[4];\r
-  f = state[5];\r
-  g = state[6];\r
-  h = state[7];\r
-  #else\r
-  for (j = 0; j < 8; j++)\r
-    T[j] = state[j];\r
-  #endif\r
-\r
-  for (j = 0; j < 64; j += 16)\r
-  {\r
-    RX_16\r
-  }\r
-\r
-  #ifdef _SHA256_UNROLL2\r
-  state[0] += a;\r
-  state[1] += b;\r
-  state[2] += c;\r
-  state[3] += d;\r
-  state[4] += e;\r
-  state[5] += f;\r
-  state[6] += g;\r
-  state[7] += h;\r
-  #else\r
-  for (j = 0; j < 8; j++)\r
-    state[j] += T[j];\r
-  #endif\r
-  \r
-  /* Wipe variables */\r
-  /* memset(W, 0, sizeof(W)); */\r
-  /* memset(T, 0, sizeof(T)); */\r
-}\r
-\r
-#undef S0\r
-#undef S1\r
-#undef s0\r
-#undef s1\r
-\r
-void Sha256_Update(CSha256 *p, const Byte *data, size_t size)\r
-{\r
-  if (size == 0)\r
-    return;\r
-\r
-  {\r
-    unsigned pos = (unsigned)p->count & 0x3F;\r
-    unsigned num;\r
-    \r
-    p->count += size;\r
-    \r
-    num = 64 - pos;\r
-    if (num > size)\r
-    {\r
-      memcpy(p->buffer + pos, data, size);\r
-      return;\r
-    }\r
-    \r
-    size -= num;\r
-    memcpy(p->buffer + pos, data, num);\r
-    data += num;\r
-  }\r
-\r
-  for (;;)\r
-  {\r
-    Sha256_WriteByteBlock(p);\r
-    if (size < 64)\r
-      break;\r
-    size -= 64;\r
-    memcpy(p->buffer, data, 64);\r
-    data += 64;\r
-  }\r
-\r
-  if (size != 0)\r
-    memcpy(p->buffer, data, size);\r
-}\r
-\r
-void Sha256_Final(CSha256 *p, Byte *digest)\r
-{\r
-  unsigned pos = (unsigned)p->count & 0x3F;\r
-  unsigned i;\r
-  \r
-  p->buffer[pos++] = 0x80;\r
-  \r
-  while (pos != (64 - 8))\r
-  {\r
-    pos &= 0x3F;\r
-    if (pos == 0)\r
-      Sha256_WriteByteBlock(p);\r
-    p->buffer[pos++] = 0;\r
-  }\r
-\r
-  {\r
-    UInt64 numBits = (p->count << 3);\r
-    SetBe32(p->buffer + 64 - 8, (UInt32)(numBits >> 32));\r
-    SetBe32(p->buffer + 64 - 4, (UInt32)(numBits));\r
-  }\r
-  \r
-  Sha256_WriteByteBlock(p);\r
-\r
-  for (i = 0; i < 8; i += 2)\r
-  {\r
-    UInt32 v0 = p->state[i];\r
-    UInt32 v1 = p->state[i + 1];\r
-    SetBe32(digest    , v0);\r
-    SetBe32(digest + 4, v1);\r
-    digest += 8;\r
-  }\r
-  \r
-  Sha256_Init(p);\r
-}\r
diff --git a/deps/lzma-16.04/C/Sha256.h b/deps/lzma-16.04/C/Sha256.h
deleted file mode 100644 (file)
index 7f17ccf..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Sha256.h -- SHA-256 Hash\r
-2013-01-18 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __CRYPTO_SHA256_H\r
-#define __CRYPTO_SHA256_H\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-#define SHA256_DIGEST_SIZE 32\r
-\r
-typedef struct\r
-{\r
-  UInt32 state[8];\r
-  UInt64 count;\r
-  Byte buffer[64];\r
-} CSha256;\r
-\r
-void Sha256_Init(CSha256 *p);\r
-void Sha256_Update(CSha256 *p, const Byte *data, size_t size);\r
-void Sha256_Final(CSha256 *p, Byte *digest);\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/Sort.c b/deps/lzma-16.04/C/Sort.c
deleted file mode 100644 (file)
index 73dcbf0..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/* Sort.c -- Sort functions\r
-2014-04-05 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "Sort.h"\r
-\r
-#define HeapSortDown(p, k, size, temp) \\r
-  { for (;;) { \\r
-    size_t s = (k << 1); \\r
-    if (s > size) break; \\r
-    if (s < size && p[s + 1] > p[s]) s++; \\r
-    if (temp >= p[s]) break; \\r
-    p[k] = p[s]; k = s; \\r
-  } p[k] = temp; }\r
-\r
-void HeapSort(UInt32 *p, size_t size)\r
-{\r
-  if (size <= 1)\r
-    return;\r
-  p--;\r
-  {\r
-    size_t i = size / 2;\r
-    do\r
-    {\r
-      UInt32 temp = p[i];\r
-      size_t k = i;\r
-      HeapSortDown(p, k, size, temp)\r
-    }\r
-    while (--i != 0);\r
-  }\r
-  /*\r
-  do\r
-  {\r
-    size_t k = 1;\r
-    UInt32 temp = p[size];\r
-    p[size--] = p[1];\r
-    HeapSortDown(p, k, size, temp)\r
-  }\r
-  while (size > 1);\r
-  */\r
-  while (size > 3)\r
-  {\r
-    UInt32 temp = p[size];\r
-    size_t k = (p[3] > p[2]) ? 3 : 2;\r
-    p[size--] = p[1];\r
-    p[1] = p[k];\r
-    HeapSortDown(p, k, size, temp)\r
-  }\r
-  {\r
-    UInt32 temp = p[size];\r
-    p[size] = p[1];\r
-    if (size > 2 && p[2] < temp)\r
-    {\r
-      p[1] = p[2];\r
-      p[2] = temp;\r
-    }\r
-    else\r
-      p[1] = temp;\r
-  }\r
-}\r
-\r
-void HeapSort64(UInt64 *p, size_t size)\r
-{\r
-  if (size <= 1)\r
-    return;\r
-  p--;\r
-  {\r
-    size_t i = size / 2;\r
-    do\r
-    {\r
-      UInt64 temp = p[i];\r
-      size_t k = i;\r
-      HeapSortDown(p, k, size, temp)\r
-    }\r
-    while (--i != 0);\r
-  }\r
-  /*\r
-  do\r
-  {\r
-    size_t k = 1;\r
-    UInt64 temp = p[size];\r
-    p[size--] = p[1];\r
-    HeapSortDown(p, k, size, temp)\r
-  }\r
-  while (size > 1);\r
-  */\r
-  while (size > 3)\r
-  {\r
-    UInt64 temp = p[size];\r
-    size_t k = (p[3] > p[2]) ? 3 : 2;\r
-    p[size--] = p[1];\r
-    p[1] = p[k];\r
-    HeapSortDown(p, k, size, temp)\r
-  }\r
-  {\r
-    UInt64 temp = p[size];\r
-    p[size] = p[1];\r
-    if (size > 2 && p[2] < temp)\r
-    {\r
-      p[1] = p[2];\r
-      p[2] = temp;\r
-    }\r
-    else\r
-      p[1] = temp;\r
-  }\r
-}\r
-\r
-/*\r
-#define HeapSortRefDown(p, vals, n, size, temp) \\r
-  { size_t k = n; UInt32 val = vals[temp]; for (;;) { \\r
-    size_t s = (k << 1); \\r
-    if (s > size) break; \\r
-    if (s < size && vals[p[s + 1]] > vals[p[s]]) s++; \\r
-    if (val >= vals[p[s]]) break; \\r
-    p[k] = p[s]; k = s; \\r
-  } p[k] = temp; }\r
-\r
-void HeapSortRef(UInt32 *p, UInt32 *vals, size_t size)\r
-{\r
-  if (size <= 1)\r
-    return;\r
-  p--;\r
-  {\r
-    size_t i = size / 2;\r
-    do\r
-    {\r
-      UInt32 temp = p[i];\r
-      HeapSortRefDown(p, vals, i, size, temp);\r
-    }\r
-    while (--i != 0);\r
-  }\r
-  do\r
-  {\r
-    UInt32 temp = p[size];\r
-    p[size--] = p[1];\r
-    HeapSortRefDown(p, vals, 1, size, temp);\r
-  }\r
-  while (size > 1);\r
-}\r
-*/\r
diff --git a/deps/lzma-16.04/C/Sort.h b/deps/lzma-16.04/C/Sort.h
deleted file mode 100644 (file)
index 7209d78..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Sort.h -- Sort functions\r
-2014-04-05 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __7Z_SORT_H\r
-#define __7Z_SORT_H\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-void HeapSort(UInt32 *p, size_t size);\r
-void HeapSort64(UInt64 *p, size_t size);\r
-\r
-/* void HeapSortRef(UInt32 *p, UInt32 *vals, size_t size); */\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/Threads.c b/deps/lzma-16.04/C/Threads.c
deleted file mode 100644 (file)
index ece07e6..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/* Threads.c -- multithreading library\r
-2014-09-21 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#ifndef UNDER_CE\r
-#include <process.h>\r
-#endif\r
-\r
-#include "Threads.h"\r
-\r
-static WRes GetError()\r
-{\r
-  DWORD res = GetLastError();\r
-  return (res) ? (WRes)(res) : 1;\r
-}\r
-\r
-WRes HandleToWRes(HANDLE h) { return (h != 0) ? 0 : GetError(); }\r
-WRes BOOLToWRes(BOOL v) { return v ? 0 : GetError(); }\r
-\r
-WRes HandlePtr_Close(HANDLE *p)\r
-{\r
-  if (*p != NULL)\r
-    if (!CloseHandle(*p))\r
-      return GetError();\r
-  *p = NULL;\r
-  return 0;\r
-}\r
-\r
-WRes Handle_WaitObject(HANDLE h) { return (WRes)WaitForSingleObject(h, INFINITE); }\r
-\r
-WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param)\r
-{\r
-  /* Windows Me/98/95: threadId parameter may not be NULL in _beginthreadex/CreateThread functions */\r
-  \r
-  #ifdef UNDER_CE\r
-  \r
-  DWORD threadId;\r
-  *p = CreateThread(0, 0, func, param, 0, &threadId);\r
-\r
-  #else\r
-\r
-  unsigned threadId;\r
-  *p = (HANDLE)_beginthreadex(NULL, 0, func, param, 0, &threadId);\r
-   \r
-  #endif\r
-\r
-  /* maybe we must use errno here, but probably GetLastError() is also OK. */\r
-  return HandleToWRes(*p);\r
-}\r
-\r
-WRes Event_Create(CEvent *p, BOOL manualReset, int signaled)\r
-{\r
-  *p = CreateEvent(NULL, manualReset, (signaled ? TRUE : FALSE), NULL);\r
-  return HandleToWRes(*p);\r
-}\r
-\r
-WRes Event_Set(CEvent *p) { return BOOLToWRes(SetEvent(*p)); }\r
-WRes Event_Reset(CEvent *p) { return BOOLToWRes(ResetEvent(*p)); }\r
-\r
-WRes ManualResetEvent_Create(CManualResetEvent *p, int signaled) { return Event_Create(p, TRUE, signaled); }\r
-WRes AutoResetEvent_Create(CAutoResetEvent *p, int signaled) { return Event_Create(p, FALSE, signaled); }\r
-WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p) { return ManualResetEvent_Create(p, 0); }\r
-WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p) { return AutoResetEvent_Create(p, 0); }\r
-\r
-\r
-WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount)\r
-{\r
-  *p = CreateSemaphore(NULL, (LONG)initCount, (LONG)maxCount, NULL);\r
-  return HandleToWRes(*p);\r
-}\r
-\r
-static WRes Semaphore_Release(CSemaphore *p, LONG releaseCount, LONG *previousCount)\r
-  { return BOOLToWRes(ReleaseSemaphore(*p, releaseCount, previousCount)); }\r
-WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num)\r
-  { return Semaphore_Release(p, (LONG)num, NULL); }\r
-WRes Semaphore_Release1(CSemaphore *p) { return Semaphore_ReleaseN(p, 1); }\r
-\r
-WRes CriticalSection_Init(CCriticalSection *p)\r
-{\r
-  /* InitializeCriticalSection can raise only STATUS_NO_MEMORY exception */\r
-  #ifdef _MSC_VER\r
-  __try\r
-  #endif\r
-  {\r
-    InitializeCriticalSection(p);\r
-    /* InitializeCriticalSectionAndSpinCount(p, 0); */\r
-  }\r
-  #ifdef _MSC_VER\r
-  __except (EXCEPTION_EXECUTE_HANDLER) { return 1; }\r
-  #endif\r
-  return 0;\r
-}\r
diff --git a/deps/lzma-16.04/C/Threads.h b/deps/lzma-16.04/C/Threads.h
deleted file mode 100644 (file)
index e927208..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Threads.h -- multithreading library\r
-2013-11-12 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __7Z_THREADS_H\r
-#define __7Z_THREADS_H\r
-\r
-#ifdef _WIN32\r
-#include <windows.h>\r
-#endif\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-WRes HandlePtr_Close(HANDLE *h);\r
-WRes Handle_WaitObject(HANDLE h);\r
-\r
-typedef HANDLE CThread;\r
-#define Thread_Construct(p) *(p) = NULL\r
-#define Thread_WasCreated(p) (*(p) != NULL)\r
-#define Thread_Close(p) HandlePtr_Close(p)\r
-#define Thread_Wait(p) Handle_WaitObject(*(p))\r
-\r
-typedef\r
-#ifdef UNDER_CE\r
-  DWORD\r
-#else\r
-  unsigned\r
-#endif\r
-  THREAD_FUNC_RET_TYPE;\r
-\r
-#define THREAD_FUNC_CALL_TYPE MY_STD_CALL\r
-#define THREAD_FUNC_DECL THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE\r
-typedef THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE * THREAD_FUNC_TYPE)(void *);\r
-WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param);\r
-\r
-typedef HANDLE CEvent;\r
-typedef CEvent CAutoResetEvent;\r
-typedef CEvent CManualResetEvent;\r
-#define Event_Construct(p) *(p) = NULL\r
-#define Event_IsCreated(p) (*(p) != NULL)\r
-#define Event_Close(p) HandlePtr_Close(p)\r
-#define Event_Wait(p) Handle_WaitObject(*(p))\r
-WRes Event_Set(CEvent *p);\r
-WRes Event_Reset(CEvent *p);\r
-WRes ManualResetEvent_Create(CManualResetEvent *p, int signaled);\r
-WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p);\r
-WRes AutoResetEvent_Create(CAutoResetEvent *p, int signaled);\r
-WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p);\r
-\r
-typedef HANDLE CSemaphore;\r
-#define Semaphore_Construct(p) (*p) = NULL\r
-#define Semaphore_Close(p) HandlePtr_Close(p)\r
-#define Semaphore_Wait(p) Handle_WaitObject(*(p))\r
-WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount);\r
-WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num);\r
-WRes Semaphore_Release1(CSemaphore *p);\r
-\r
-typedef CRITICAL_SECTION CCriticalSection;\r
-WRes CriticalSection_Init(CCriticalSection *p);\r
-#define CriticalSection_Delete(p) DeleteCriticalSection(p)\r
-#define CriticalSection_Enter(p) EnterCriticalSection(p)\r
-#define CriticalSection_Leave(p) LeaveCriticalSection(p)\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/Util/7z/7z.dsp b/deps/lzma-16.04/C/Util/7z/7z.dsp
deleted file mode 100644 (file)
index d3bf0fe..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-# Microsoft Developer Studio Project File - Name="7z" - Package Owner=<4>\r
-# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
-# ** DO NOT EDIT **\r
-\r
-# TARGTYPE "Win32 (x86) Console Application" 0x0103\r
-\r
-CFG=7z - Win32 Debug\r
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
-!MESSAGE use the Export Makefile command and run\r
-!MESSAGE \r
-!MESSAGE NMAKE /f "7z.mak".\r
-!MESSAGE \r
-!MESSAGE You can specify a configuration when running NMAKE\r
-!MESSAGE by defining the macro CFG on the command line. For example:\r
-!MESSAGE \r
-!MESSAGE NMAKE /f "7z.mak" CFG="7z - Win32 Debug"\r
-!MESSAGE \r
-!MESSAGE Possible choices for configuration are:\r
-!MESSAGE \r
-!MESSAGE "7z - Win32 Release" (based on "Win32 (x86) Console Application")\r
-!MESSAGE "7z - Win32 Debug" (based on "Win32 (x86) Console Application")\r
-!MESSAGE \r
-\r
-# Begin Project\r
-# PROP AllowPerConfigDependencies 0\r
-# PROP Scc_ProjName ""\r
-# PROP Scc_LocalPath ""\r
-CPP=cl.exe\r
-RSC=rc.exe\r
-\r
-!IF  "$(CFG)" == "7z - Win32 Release"\r
-\r
-# PROP BASE Use_MFC 0\r
-# PROP BASE Use_Debug_Libraries 0\r
-# PROP BASE Output_Dir "Release"\r
-# PROP BASE Intermediate_Dir "Release"\r
-# PROP BASE Target_Dir ""\r
-# PROP Use_MFC 0\r
-# PROP Use_Debug_Libraries 0\r
-# PROP Output_Dir "Release"\r
-# PROP Intermediate_Dir "Release"\r
-# PROP Ignore_Export_Lib 0\r
-# PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c\r
-# ADD CPP /nologo /MD /W4 /WX /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /FAcs /Yu"Precomp.h" /FD /c\r
-# ADD BASE RSC /l 0x419 /d "NDEBUG"\r
-# ADD RSC /l 0x419 /d "NDEBUG"\r
-BSC32=bscmake.exe\r
-# ADD BASE BSC32 /nologo\r
-# ADD BSC32 /nologo\r
-LINK32=link.exe\r
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\r
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"c:\util\7zDec.exe" /opt:NOWIN98\r
-# SUBTRACT LINK32 /pdb:none\r
-\r
-!ELSEIF  "$(CFG)" == "7z - Win32 Debug"\r
-\r
-# PROP BASE Use_MFC 0\r
-# PROP BASE Use_Debug_Libraries 1\r
-# PROP BASE Output_Dir "Debug"\r
-# PROP BASE Intermediate_Dir "Debug"\r
-# PROP BASE Target_Dir ""\r
-# PROP Use_MFC 0\r
-# PROP Use_Debug_Libraries 1\r
-# PROP Output_Dir "Debug"\r
-# PROP Intermediate_Dir "Debug"\r
-# PROP Ignore_Export_Lib 0\r
-# PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c\r
-# ADD CPP /nologo /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_SZ_ALLOC_DEBUG2" /D "_SZ_NO_INT_64_A" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Yu"Precomp.h" /FD /GZ /c\r
-# ADD BASE RSC /l 0x419 /d "_DEBUG"\r
-# ADD RSC /l 0x419 /d "_DEBUG"\r
-BSC32=bscmake.exe\r
-# ADD BASE BSC32 /nologo\r
-# ADD BSC32 /nologo\r
-LINK32=link.exe\r
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\r
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"c:\util\7zDec.exe" /pdbtype:sept\r
-\r
-!ENDIF \r
-\r
-# Begin Target\r
-\r
-# Name "7z - Win32 Release"\r
-# Name "7z - Win32 Debug"\r
-# Begin Group "Common"\r
-\r
-# PROP Default_Filter ""\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7z.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zAlloc.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zAlloc.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zArcIn.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zBuf.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zBuf.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zCrc.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zCrc.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zCrcOpt.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zDec.c\r
-# ADD CPP /D "_7ZIP_PPMD_SUPPPORT"\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zFile.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zFile.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zStream.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zTypes.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Bcj2.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Bcj2.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Bra.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Bra.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Bra86.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\BraIA64.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\CpuArch.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\CpuArch.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Delta.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Delta.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Lzma2Dec.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Lzma2Dec.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzmaDec.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzmaDec.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Ppmd.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Ppmd7.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Ppmd7.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Ppmd7Dec.c\r
-# End Source File\r
-# End Group\r
-# Begin Group "Spec"\r
-\r
-# PROP Default_Filter ""\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Compiler.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\Precomp.c\r
-# ADD CPP /Yc"Precomp.h"\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\Precomp.h\r
-# End Source File\r
-# End Group\r
-# Begin Source File\r
-\r
-SOURCE=.\7zMain.c\r
-# End Source File\r
-# End Target\r
-# End Project\r
diff --git a/deps/lzma-16.04/C/Util/7z/7z.dsw b/deps/lzma-16.04/C/Util/7z/7z.dsw
deleted file mode 100644 (file)
index 23089fb..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00\r
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r
-\r
-###############################################################################\r
-\r
-Project: "7z"=.\7z.dsp - Package Owner=<4>\r
-\r
-Package=<5>\r
-{{{\r
-}}}\r
-\r
-Package=<4>\r
-{{{\r
-}}}\r
-\r
-###############################################################################\r
-\r
-Global:\r
-\r
-Package=<5>\r
-{{{\r
-}}}\r
-\r
-Package=<3>\r
-{{{\r
-}}}\r
-\r
-###############################################################################\r
-\r
diff --git a/deps/lzma-16.04/C/Util/7z/7zMain.c b/deps/lzma-16.04/C/Util/7z/7zMain.c
deleted file mode 100644 (file)
index 92bce0a..0000000
+++ /dev/null
@@ -1,604 +0,0 @@
-/* 7zMain.c - Test application for 7z Decoder\r
-2016-05-16 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-\r
-#include "../../7z.h"\r
-#include "../../7zAlloc.h"\r
-#include "../../7zBuf.h"\r
-#include "../../7zCrc.h"\r
-#include "../../7zFile.h"\r
-#include "../../7zVersion.h"\r
-\r
-#ifndef USE_WINDOWS_FILE\r
-/* for mkdir */\r
-#ifdef _WIN32\r
-#include <direct.h>\r
-#else\r
-#include <sys/stat.h>\r
-#include <errno.h>\r
-#endif\r
-#endif\r
-\r
-static ISzAlloc g_Alloc = { SzAlloc, SzFree };\r
-\r
-static int Buf_EnsureSize(CBuf *dest, size_t size)\r
-{\r
-  if (dest->size >= size)\r
-    return 1;\r
-  Buf_Free(dest, &g_Alloc);\r
-  return Buf_Create(dest, size, &g_Alloc);\r
-}\r
-\r
-#ifndef _WIN32\r
-#define _USE_UTF8\r
-#endif\r
-\r
-/* #define _USE_UTF8 */\r
-\r
-#ifdef _USE_UTF8\r
-\r
-#define _UTF8_START(n) (0x100 - (1 << (7 - (n))))\r
-\r
-#define _UTF8_RANGE(n) (((UInt32)1) << ((n) * 5 + 6))\r
-\r
-#define _UTF8_HEAD(n, val) ((Byte)(_UTF8_START(n) + (val >> (6 * (n)))))\r
-#define _UTF8_CHAR(n, val) ((Byte)(0x80 + (((val) >> (6 * (n))) & 0x3F)))\r
-\r
-static size_t Utf16_To_Utf8_Calc(const UInt16 *src, const UInt16 *srcLim)\r
-{\r
-  size_t size = 0;\r
-  for (;;)\r
-  {\r
-    UInt32 val;\r
-    if (src == srcLim)\r
-      return size;\r
-    \r
-    size++;\r
-    val = *src++;\r
-   \r
-    if (val < 0x80)\r
-      continue;\r
-\r
-    if (val < _UTF8_RANGE(1))\r
-    {\r
-      size++;\r
-      continue;\r
-    }\r
-\r
-    if (val >= 0xD800 && val < 0xDC00 && src != srcLim)\r
-    {\r
-      UInt32 c2 = *src;\r
-      if (c2 >= 0xDC00 && c2 < 0xE000)\r
-      {\r
-        src++;\r
-        size += 3;\r
-        continue;\r
-      }\r
-    }\r
-\r
-    size += 2;\r
-  }\r
-}\r
-\r
-static Byte *Utf16_To_Utf8(Byte *dest, const UInt16 *src, const UInt16 *srcLim)\r
-{\r
-  for (;;)\r
-  {\r
-    UInt32 val;\r
-    if (src == srcLim)\r
-      return dest;\r
-    \r
-    val = *src++;\r
-    \r
-    if (val < 0x80)\r
-    {\r
-      *dest++ = (char)val;\r
-      continue;\r
-    }\r
-\r
-    if (val < _UTF8_RANGE(1))\r
-    {\r
-      dest[0] = _UTF8_HEAD(1, val);\r
-      dest[1] = _UTF8_CHAR(0, val);\r
-      dest += 2;\r
-      continue;\r
-    }\r
-\r
-    if (val >= 0xD800 && val < 0xDC00 && src != srcLim)\r
-    {\r
-      UInt32 c2 = *src;\r
-      if (c2 >= 0xDC00 && c2 < 0xE000)\r
-      {\r
-        src++;\r
-        val = (((val - 0xD800) << 10) | (c2 - 0xDC00)) + 0x10000;\r
-        dest[0] = _UTF8_HEAD(3, val);\r
-        dest[1] = _UTF8_CHAR(2, val);\r
-        dest[2] = _UTF8_CHAR(1, val);\r
-        dest[3] = _UTF8_CHAR(0, val);\r
-        dest += 4;\r
-        continue;\r
-      }\r
-    }\r
-    \r
-    dest[0] = _UTF8_HEAD(2, val);\r
-    dest[1] = _UTF8_CHAR(1, val);\r
-    dest[2] = _UTF8_CHAR(0, val);\r
-    dest += 3;\r
-  }\r
-}\r
-\r
-static SRes Utf16_To_Utf8Buf(CBuf *dest, const UInt16 *src, size_t srcLen)\r
-{\r
-  size_t destLen = Utf16_To_Utf8_Calc(src, src + srcLen);\r
-  destLen += 1;\r
-  if (!Buf_EnsureSize(dest, destLen))\r
-    return SZ_ERROR_MEM;\r
-  *Utf16_To_Utf8(dest->data, src, src + srcLen) = 0;\r
-  return SZ_OK;\r
-}\r
-\r
-#endif\r
-\r
-static SRes Utf16_To_Char(CBuf *buf, const UInt16 *s\r
-    #ifndef _USE_UTF8\r
-    , UINT codePage\r
-    #endif\r
-    )\r
-{\r
-  unsigned len = 0;\r
-  for (len = 0; s[len] != 0; len++);\r
-\r
-  #ifndef _USE_UTF8\r
-  {\r
-    unsigned size = len * 3 + 100;\r
-    if (!Buf_EnsureSize(buf, size))\r
-      return SZ_ERROR_MEM;\r
-    {\r
-      buf->data[0] = 0;\r
-      if (len != 0)\r
-      {\r
-        char defaultChar = '_';\r
-        BOOL defUsed;\r
-        unsigned numChars = 0;\r
-        numChars = WideCharToMultiByte(codePage, 0, s, len, (char *)buf->data, size, &defaultChar, &defUsed);\r
-        if (numChars == 0 || numChars >= size)\r
-          return SZ_ERROR_FAIL;\r
-        buf->data[numChars] = 0;\r
-      }\r
-      return SZ_OK;\r
-    }\r
-  }\r
-  #else\r
-  return Utf16_To_Utf8Buf(buf, s, len);\r
-  #endif\r
-}\r
-\r
-#ifdef _WIN32\r
-  #ifndef USE_WINDOWS_FILE\r
-    static UINT g_FileCodePage = CP_ACP;\r
-  #endif\r
-  #define MY_FILE_CODE_PAGE_PARAM ,g_FileCodePage\r
-#else\r
-  #define MY_FILE_CODE_PAGE_PARAM\r
-#endif\r
-\r
-static WRes MyCreateDir(const UInt16 *name)\r
-{\r
-  #ifdef USE_WINDOWS_FILE\r
-  \r
-  return CreateDirectoryW(name, NULL) ? 0 : GetLastError();\r
-  \r
-  #else\r
-\r
-  CBuf buf;\r
-  WRes res;\r
-  Buf_Init(&buf);\r
-  RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM));\r
-\r
-  res =\r
-  #ifdef _WIN32\r
-  _mkdir((const char *)buf.data)\r
-  #else\r
-  mkdir((const char *)buf.data, 0777)\r
-  #endif\r
-  == 0 ? 0 : errno;\r
-  Buf_Free(&buf, &g_Alloc);\r
-  return res;\r
-  \r
-  #endif\r
-}\r
-\r
-static WRes OutFile_OpenUtf16(CSzFile *p, const UInt16 *name)\r
-{\r
-  #ifdef USE_WINDOWS_FILE\r
-  return OutFile_OpenW(p, name);\r
-  #else\r
-  CBuf buf;\r
-  WRes res;\r
-  Buf_Init(&buf);\r
-  RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM));\r
-  res = OutFile_Open(p, (const char *)buf.data);\r
-  Buf_Free(&buf, &g_Alloc);\r
-  return res;\r
-  #endif\r
-}\r
-\r
-static SRes PrintString(const UInt16 *s)\r
-{\r
-  CBuf buf;\r
-  SRes res;\r
-  Buf_Init(&buf);\r
-  res = Utf16_To_Char(&buf, s\r
-      #ifndef _USE_UTF8\r
-      , CP_OEMCP\r
-      #endif\r
-      );\r
-  if (res == SZ_OK)\r
-    fputs((const char *)buf.data, stdout);\r
-  Buf_Free(&buf, &g_Alloc);\r
-  return res;\r
-}\r
-\r
-static void UInt64ToStr(UInt64 value, char *s)\r
-{\r
-  char temp[32];\r
-  int pos = 0;\r
-  do\r
-  {\r
-    temp[pos++] = (char)('0' + (unsigned)(value % 10));\r
-    value /= 10;\r
-  }\r
-  while (value != 0);\r
-  do\r
-    *s++ = temp[--pos];\r
-  while (pos);\r
-  *s = '\0';\r
-}\r
-\r
-static char *UIntToStr(char *s, unsigned value, int numDigits)\r
-{\r
-  char temp[16];\r
-  int pos = 0;\r
-  do\r
-    temp[pos++] = (char)('0' + (value % 10));\r
-  while (value /= 10);\r
-  for (numDigits -= pos; numDigits > 0; numDigits--)\r
-    *s++ = '0';\r
-  do\r
-    *s++ = temp[--pos];\r
-  while (pos);\r
-  *s = '\0';\r
-  return s;\r
-}\r
-\r
-static void UIntToStr_2(char *s, unsigned value)\r
-{\r
-  s[0] = (char)('0' + (value / 10));\r
-  s[1] = (char)('0' + (value % 10));\r
-}\r
-\r
-#define PERIOD_4 (4 * 365 + 1)\r
-#define PERIOD_100 (PERIOD_4 * 25 - 1)\r
-#define PERIOD_400 (PERIOD_100 * 4 + 1)\r
-\r
-static void ConvertFileTimeToString(const CNtfsFileTime *nt, char *s)\r
-{\r
-  unsigned year, mon, hour, min, sec;\r
-  Byte ms[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };\r
-  unsigned t;\r
-  UInt32 v;\r
-  UInt64 v64 = nt->Low | ((UInt64)nt->High << 32);\r
-  v64 /= 10000000;\r
-  sec = (unsigned)(v64 % 60); v64 /= 60;\r
-  min = (unsigned)(v64 % 60); v64 /= 60;\r
-  hour = (unsigned)(v64 % 24); v64 /= 24;\r
-\r
-  v = (UInt32)v64;\r
-\r
-  year = (unsigned)(1601 + v / PERIOD_400 * 400);\r
-  v %= PERIOD_400;\r
-\r
-  t = v / PERIOD_100; if (t ==  4) t =  3; year += t * 100; v -= t * PERIOD_100;\r
-  t = v / PERIOD_4;   if (t == 25) t = 24; year += t * 4;   v -= t * PERIOD_4;\r
-  t = v / 365;        if (t ==  4) t =  3; year += t;       v -= t * 365;\r
-\r
-  if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))\r
-    ms[1] = 29;\r
-  for (mon = 0;; mon++)\r
-  {\r
-    unsigned d = ms[mon];\r
-    if (v < d)\r
-      break;\r
-    v -= d;\r
-  }\r
-  s = UIntToStr(s, year, 4); *s++ = '-';\r
-  UIntToStr_2(s, mon + 1); s[2] = '-'; s += 3;\r
-  UIntToStr_2(s, (unsigned)v + 1); s[2] = ' '; s += 3;\r
-  UIntToStr_2(s, hour); s[2] = ':'; s += 3;\r
-  UIntToStr_2(s, min); s[2] = ':'; s += 3;\r
-  UIntToStr_2(s, sec); s[2] = 0;\r
-}\r
-\r
-void PrintError(char *sz)\r
-{\r
-  printf("\nERROR: %s\n", sz);\r
-}\r
-\r
-static void GetAttribString(UInt32 wa, Bool isDir, char *s)\r
-{\r
-  #ifdef USE_WINDOWS_FILE\r
-  s[0] = (char)(((wa & FILE_ATTRIBUTE_DIRECTORY) != 0 || isDir) ? 'D' : '.');\r
-  s[1] = (char)(((wa & FILE_ATTRIBUTE_READONLY ) != 0) ? 'R': '.');\r
-  s[2] = (char)(((wa & FILE_ATTRIBUTE_HIDDEN   ) != 0) ? 'H': '.');\r
-  s[3] = (char)(((wa & FILE_ATTRIBUTE_SYSTEM   ) != 0) ? 'S': '.');\r
-  s[4] = (char)(((wa & FILE_ATTRIBUTE_ARCHIVE  ) != 0) ? 'A': '.');\r
-  s[5] = 0;\r
-  #else\r
-  s[0] = (char)(((wa & (1 << 4)) != 0 || isDir) ? 'D' : '.');\r
-  s[1] = 0;\r
-  #endif\r
-}\r
-\r
-// #define NUM_PARENTS_MAX 128\r
-\r
-int MY_CDECL main(int numargs, char *args[])\r
-{\r
-  CFileInStream archiveStream;\r
-  CLookToRead lookStream;\r
-  CSzArEx db;\r
-  SRes res;\r
-  ISzAlloc allocImp;\r
-  ISzAlloc allocTempImp;\r
-  UInt16 *temp = NULL;\r
-  size_t tempSize = 0;\r
-  // UInt32 parents[NUM_PARENTS_MAX];\r
-\r
-  printf("\n7z ANSI-C Decoder " MY_VERSION_COPYRIGHT_DATE "\n\n");\r
-\r
-  if (numargs == 1)\r
-  {\r
-    printf(\r
-      "Usage: 7zDec <command> <archive_name>\n\n"\r
-      "<Commands>\n"\r
-      "  e: Extract files from archive (without using directory names)\n"\r
-      "  l: List contents of archive\n"\r
-      "  t: Test integrity of archive\n"\r
-      "  x: eXtract files with full paths\n");\r
-    return 0;\r
-  }\r
-  \r
-  if (numargs < 3)\r
-  {\r
-    PrintError("incorrect command");\r
-    return 1;\r
-  }\r
-\r
-  #if defined(_WIN32) && !defined(USE_WINDOWS_FILE) && !defined(UNDER_CE)\r
-  g_FileCodePage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;\r
-  #endif\r
-\r
-  allocImp.Alloc = SzAlloc;\r
-  allocImp.Free = SzFree;\r
-\r
-  allocTempImp.Alloc = SzAllocTemp;\r
-  allocTempImp.Free = SzFreeTemp;\r
-\r
-  #ifdef UNDER_CE\r
-  if (InFile_OpenW(&archiveStream.file, L"\test.7z"))\r
-  #else\r
-  if (InFile_Open(&archiveStream.file, args[2]))\r
-  #endif\r
-  {\r
-    PrintError("can not open input file");\r
-    return 1;\r
-  }\r
-\r
-  FileInStream_CreateVTable(&archiveStream);\r
-  LookToRead_CreateVTable(&lookStream, False);\r
-  \r
-  lookStream.realStream = &archiveStream.s;\r
-  LookToRead_Init(&lookStream);\r
-\r
-  CrcGenerateTable();\r
-\r
-  SzArEx_Init(&db);\r
-  \r
-  res = SzArEx_Open(&db, &lookStream.s, &allocImp, &allocTempImp);\r
-  \r
-  if (res == SZ_OK)\r
-  {\r
-    char *command = args[1];\r
-    int listCommand = 0, testCommand = 0, fullPaths = 0;\r
-    \r
-    if (strcmp(command, "l") == 0) listCommand = 1;\r
-    else if (strcmp(command, "t") == 0) testCommand = 1;\r
-    else if (strcmp(command, "e") == 0) { }\r
-    else if (strcmp(command, "x") == 0) { fullPaths = 1; }\r
-    else\r
-    {\r
-      PrintError("incorrect command");\r
-      res = SZ_ERROR_FAIL;\r
-    }\r
-\r
-    if (res == SZ_OK)\r
-    {\r
-      UInt32 i;\r
-\r
-      /*\r
-      if you need cache, use these 3 variables.\r
-      if you use external function, you can make these variable as static.\r
-      */\r
-      UInt32 blockIndex = 0xFFFFFFFF; /* it can have any value before first call (if outBuffer = 0) */\r
-      Byte *outBuffer = 0; /* it must be 0 before first call for each new archive. */\r
-      size_t outBufferSize = 0;  /* it can have any value before first call (if outBuffer = 0) */\r
-\r
-      for (i = 0; i < db.NumFiles; i++)\r
-      {\r
-        size_t offset = 0;\r
-        size_t outSizeProcessed = 0;\r
-        // const CSzFileItem *f = db.Files + i;\r
-        size_t len;\r
-        unsigned isDir = SzArEx_IsDir(&db, i);\r
-        if (listCommand == 0 && isDir && !fullPaths)\r
-          continue;\r
-        len = SzArEx_GetFileNameUtf16(&db, i, NULL);\r
-        // len = SzArEx_GetFullNameLen(&db, i);\r
-\r
-        if (len > tempSize)\r
-        {\r
-          SzFree(NULL, temp);\r
-          tempSize = len;\r
-          temp = (UInt16 *)SzAlloc(NULL, tempSize * sizeof(temp[0]));\r
-          if (!temp)\r
-          {\r
-            res = SZ_ERROR_MEM;\r
-            break;\r
-          }\r
-        }\r
-\r
-        SzArEx_GetFileNameUtf16(&db, i, temp);\r
-        /*\r
-        if (SzArEx_GetFullNameUtf16_Back(&db, i, temp + len) != temp)\r
-        {\r
-          res = SZ_ERROR_FAIL;\r
-          break;\r
-        }\r
-        */\r
-\r
-        if (listCommand)\r
-        {\r
-          char attr[8], s[32], t[32];\r
-          UInt64 fileSize;\r
-\r
-          GetAttribString(SzBitWithVals_Check(&db.Attribs, i) ? db.Attribs.Vals[i] : 0, isDir, attr);\r
-\r
-          fileSize = SzArEx_GetFileSize(&db, i);\r
-          UInt64ToStr(fileSize, s);\r
-          \r
-          if (SzBitWithVals_Check(&db.MTime, i))\r
-            ConvertFileTimeToString(&db.MTime.Vals[i], t);\r
-          else\r
-          {\r
-            size_t j;\r
-            for (j = 0; j < 19; j++)\r
-              t[j] = ' ';\r
-            t[j] = '\0';\r
-          }\r
-          \r
-          printf("%s %s %10s  ", t, attr, s);\r
-          res = PrintString(temp);\r
-          if (res != SZ_OK)\r
-            break;\r
-          if (isDir)\r
-            printf("/");\r
-          printf("\n");\r
-          continue;\r
-        }\r
-\r
-        fputs(testCommand ?\r
-            "Testing    ":\r
-            "Extracting ",\r
-            stdout);\r
-        res = PrintString(temp);\r
-        if (res != SZ_OK)\r
-          break;\r
-        \r
-        if (isDir)\r
-          printf("/");\r
-        else\r
-        {\r
-          res = SzArEx_Extract(&db, &lookStream.s, i,\r
-              &blockIndex, &outBuffer, &outBufferSize,\r
-              &offset, &outSizeProcessed,\r
-              &allocImp, &allocTempImp);\r
-          if (res != SZ_OK)\r
-            break;\r
-        }\r
-        \r
-        if (!testCommand)\r
-        {\r
-          CSzFile outFile;\r
-          size_t processedSize;\r
-          size_t j;\r
-          UInt16 *name = (UInt16 *)temp;\r
-          const UInt16 *destPath = (const UInt16 *)name;\r
\r
-          for (j = 0; name[j] != 0; j++)\r
-            if (name[j] == '/')\r
-            {\r
-              if (fullPaths)\r
-              {\r
-                name[j] = 0;\r
-                MyCreateDir(name);\r
-                name[j] = CHAR_PATH_SEPARATOR;\r
-              }\r
-              else\r
-                destPath = name + j + 1;\r
-            }\r
-    \r
-          if (isDir)\r
-          {\r
-            MyCreateDir(destPath);\r
-            printf("\n");\r
-            continue;\r
-          }\r
-          else if (OutFile_OpenUtf16(&outFile, destPath))\r
-          {\r
-            PrintError("can not open output file");\r
-            res = SZ_ERROR_FAIL;\r
-            break;\r
-          }\r
-\r
-          processedSize = outSizeProcessed;\r
-          \r
-          if (File_Write(&outFile, outBuffer + offset, &processedSize) != 0 || processedSize != outSizeProcessed)\r
-          {\r
-            PrintError("can not write output file");\r
-            res = SZ_ERROR_FAIL;\r
-            break;\r
-          }\r
-          \r
-          if (File_Close(&outFile))\r
-          {\r
-            PrintError("can not close output file");\r
-            res = SZ_ERROR_FAIL;\r
-            break;\r
-          }\r
-          \r
-          #ifdef USE_WINDOWS_FILE\r
-          if (SzBitWithVals_Check(&db.Attribs, i))\r
-            SetFileAttributesW(destPath, db.Attribs.Vals[i]);\r
-          #endif\r
-        }\r
-        printf("\n");\r
-      }\r
-      IAlloc_Free(&allocImp, outBuffer);\r
-    }\r
-  }\r
-\r
-  SzArEx_Free(&db, &allocImp);\r
-  SzFree(NULL, temp);\r
-\r
-  File_Close(&archiveStream.file);\r
-  \r
-  if (res == SZ_OK)\r
-  {\r
-    printf("\nEverything is Ok\n");\r
-    return 0;\r
-  }\r
-  \r
-  if (res == SZ_ERROR_UNSUPPORTED)\r
-    PrintError("decoder doesn't support this archive");\r
-  else if (res == SZ_ERROR_MEM)\r
-    PrintError("can not allocate memory");\r
-  else if (res == SZ_ERROR_CRC)\r
-    PrintError("CRC error");\r
-  else\r
-    printf("\nERROR #%d\n", res);\r
-  \r
-  return 1;\r
-}\r
diff --git a/deps/lzma-16.04/C/Util/7z/Precomp.c b/deps/lzma-16.04/C/Util/7z/Precomp.c
deleted file mode 100644 (file)
index 34b60f8..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-/* Precomp.c -- StdAfx\r
-2013-01-21 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
diff --git a/deps/lzma-16.04/C/Util/7z/Precomp.h b/deps/lzma-16.04/C/Util/7z/Precomp.h
deleted file mode 100644 (file)
index 9f398d0..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-/* Precomp.h -- StdAfx\r
-2013-06-16 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __7Z_PRECOMP_H\r
-#define __7Z_PRECOMP_H\r
-\r
-#include "../../Compiler.h"\r
-#include "../../7zTypes.h"\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/Util/7z/makefile b/deps/lzma-16.04/C/Util/7z/makefile
deleted file mode 100644 (file)
index f4a54af..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-CFLAGS = $(CFLAGS) -D_7ZIP_PPMD_SUPPPORT\r
-\r
-PROG = 7zDec.exe\r
-\r
-C_OBJS = \\r
-  $O\7zAlloc.obj \\r
-  $O\7zBuf.obj \\r
-  $O\7zCrc.obj \\r
-  $O\7zCrcOpt.obj \\r
-  $O\7zFile.obj \\r
-  $O\7zDec.obj \\r
-  $O\7zArcIn.obj \\r
-  $O\7zStream.obj \\r
-  $O\Bcj2.obj \\r
-  $O\Bra.obj \\r
-  $O\Bra86.obj \\r
-  $O\BraIA64.obj \\r
-  $O\CpuArch.obj \\r
-  $O\Delta.obj \\r
-  $O\Lzma2Dec.obj \\r
-  $O\LzmaDec.obj \\r
-  $O\Ppmd7.obj \\r
-  $O\Ppmd7Dec.obj \\r
-\r
-7Z_OBJS = \\r
-  $O\7zMain.obj \\r
-\r
-OBJS = \\r
-  $O\Precomp.obj \\r
-  $(7Z_OBJS) \\r
-  $(C_OBJS) \\r
-\r
-!include "../../../CPP/Build.mak"\r
-\r
-$(7Z_OBJS): $(*B).c\r
-       $(CCOMPL_USE)\r
-$(C_OBJS): ../../$(*B).c\r
-       $(CCOMPL_USE)\r
-$O\Precomp.obj: Precomp.c\r
-       $(CCOMPL_PCH)\r
diff --git a/deps/lzma-16.04/C/Util/7z/makefile.gcc b/deps/lzma-16.04/C/Util/7z/makefile.gcc
deleted file mode 100644 (file)
index f707935..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-PROG = 7zDec\r
-CXX = gcc\r
-LIB =\r
-RM = rm -f\r
-CFLAGS = -c -O2 -Wall\r
-\r
-OBJS = 7zMain.o 7zAlloc.o 7zArcIn.o 7zBuf.o 7zBuf2.o 7zCrc.o 7zCrcOpt.o 7zDec.o CpuArch.o Delta.o LzmaDec.o Lzma2Dec.o Bra.o Bra86.o BraIA64.o Bcj2.o Ppmd7.o Ppmd7Dec.o 7zFile.o 7zStream.o\r
-\r
-all: $(PROG)\r
-\r
-$(PROG): $(OBJS)\r
-       $(CXX) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIB)\r
-\r
-7zMain.o: 7zMain.c\r
-       $(CXX) $(CFLAGS) 7zMain.c\r
-\r
-7zAlloc.o: ../../7zAlloc.c\r
-       $(CXX) $(CFLAGS) ../../7zAlloc.c\r
-\r
-7zArcIn.o: ../../7zArcIn.c\r
-       $(CXX) $(CFLAGS) ../../7zArcIn.c\r
-\r
-7zBuf.o: ../../7zBuf.c\r
-       $(CXX) $(CFLAGS) ../../7zBuf.c\r
-\r
-7zBuf2.o: ../../7zBuf2.c\r
-       $(CXX) $(CFLAGS) ../../7zBuf2.c\r
-\r
-7zCrc.o: ../../7zCrc.c\r
-       $(CXX) $(CFLAGS) ../../7zCrc.c\r
-\r
-7zCrcOpt.o: ../../7zCrc.c\r
-       $(CXX) $(CFLAGS) ../../7zCrcOpt.c\r
-\r
-7zDec.o: ../../7zDec.c\r
-       $(CXX) $(CFLAGS) -D_7ZIP_PPMD_SUPPPORT ../../7zDec.c\r
-\r
-CpuArch.o: ../../CpuArch.c\r
-       $(CXX) $(CFLAGS) ../../CpuArch.c\r
-\r
-Delta.o: ../../Delta.c\r
-       $(CXX) $(CFLAGS) ../../Delta.c\r
-\r
-LzmaDec.o: ../../LzmaDec.c\r
-       $(CXX) $(CFLAGS) ../../LzmaDec.c\r
-\r
-Lzma2Dec.o: ../../Lzma2Dec.c\r
-       $(CXX) $(CFLAGS) ../../Lzma2Dec.c\r
-\r
-Bra.o: ../../Bra.c\r
-       $(CXX) $(CFLAGS) ../../Bra.c\r
-\r
-Bra86.o: ../../Bra86.c\r
-       $(CXX) $(CFLAGS) ../../Bra86.c\r
-\r
-BraIA64.o: ../../BraIA64.c\r
-       $(CXX) $(CFLAGS) ../../BraIA64.c\r
-\r
-Bcj2.o: ../../Bcj2.c\r
-       $(CXX) $(CFLAGS) ../../Bcj2.c\r
-\r
-Ppmd7.o: ../../Ppmd7.c\r
-       $(CXX) $(CFLAGS) ../../Ppmd7.c\r
-\r
-Ppmd7Dec.o: ../../Ppmd7Dec.c\r
-       $(CXX) $(CFLAGS) ../../Ppmd7Dec.c\r
-\r
-7zFile.o: ../../7zFile.c\r
-       $(CXX) $(CFLAGS) ../../7zFile.c\r
-\r
-7zStream.o: ../../7zStream.c\r
-       $(CXX) $(CFLAGS) ../../7zStream.c\r
-\r
-clean:\r
-       -$(RM) $(PROG) $(OBJS)\r
diff --git a/deps/lzma-16.04/C/Util/Lzma/LzmaUtil.c b/deps/lzma-16.04/C/Util/Lzma/LzmaUtil.c
deleted file mode 100644 (file)
index 98331b4..0000000
+++ /dev/null
@@ -1,250 +0,0 @@
-/* LzmaUtil.c -- Test application for LZMA compression\r
-2015-11-08 : Igor Pavlov : Public domain */\r
-\r
-#include "../../Precomp.h"\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-\r
-#include "../../Alloc.h"\r
-#include "../../7zFile.h"\r
-#include "../../7zVersion.h"\r
-#include "../../LzmaDec.h"\r
-#include "../../LzmaEnc.h"\r
-\r
-const char *kCantReadMessage = "Can not read input file";\r
-const char *kCantWriteMessage = "Can not write output file";\r
-const char *kCantAllocateMessage = "Can not allocate memory";\r
-const char *kDataErrorMessage = "Data error";\r
-\r
-void PrintHelp(char *buffer)\r
-{\r
-  strcat(buffer, "\nLZMA Utility " MY_VERSION_COPYRIGHT_DATE "\n"\r
-      "\nUsage:  lzma <e|d> inputFile outputFile\n"\r
-             "  e: encode file\n"\r
-             "  d: decode file\n");\r
-}\r
-\r
-int PrintError(char *buffer, const char *message)\r
-{\r
-  strcat(buffer, "\nError: ");\r
-  strcat(buffer, message);\r
-  strcat(buffer, "\n");\r
-  return 1;\r
-}\r
-\r
-int PrintErrorNumber(char *buffer, SRes val)\r
-{\r
-  sprintf(buffer + strlen(buffer), "\nError code: %x\n", (unsigned)val);\r
-  return 1;\r
-}\r
-\r
-int PrintUserError(char *buffer)\r
-{\r
-  return PrintError(buffer, "Incorrect command");\r
-}\r
-\r
-#define IN_BUF_SIZE (1 << 16)\r
-#define OUT_BUF_SIZE (1 << 16)\r
-\r
-static SRes Decode2(CLzmaDec *state, ISeqOutStream *outStream, ISeqInStream *inStream,\r
-    UInt64 unpackSize)\r
-{\r
-  int thereIsSize = (unpackSize != (UInt64)(Int64)-1);\r
-  Byte inBuf[IN_BUF_SIZE];\r
-  Byte outBuf[OUT_BUF_SIZE];\r
-  size_t inPos = 0, inSize = 0, outPos = 0;\r
-  LzmaDec_Init(state);\r
-  for (;;)\r
-  {\r
-    if (inPos == inSize)\r
-    {\r
-      inSize = IN_BUF_SIZE;\r
-      RINOK(inStream->Read(inStream, inBuf, &inSize));\r
-      inPos = 0;\r
-    }\r
-    {\r
-      SRes res;\r
-      SizeT inProcessed = inSize - inPos;\r
-      SizeT outProcessed = OUT_BUF_SIZE - outPos;\r
-      ELzmaFinishMode finishMode = LZMA_FINISH_ANY;\r
-      ELzmaStatus status;\r
-      if (thereIsSize && outProcessed > unpackSize)\r
-      {\r
-        outProcessed = (SizeT)unpackSize;\r
-        finishMode = LZMA_FINISH_END;\r
-      }\r
-      \r
-      res = LzmaDec_DecodeToBuf(state, outBuf + outPos, &outProcessed,\r
-        inBuf + inPos, &inProcessed, finishMode, &status);\r
-      inPos += inProcessed;\r
-      outPos += outProcessed;\r
-      unpackSize -= outProcessed;\r
-      \r
-      if (outStream)\r
-        if (outStream->Write(outStream, outBuf, outPos) != outPos)\r
-          return SZ_ERROR_WRITE;\r
-        \r
-      outPos = 0;\r
-      \r
-      if (res != SZ_OK || (thereIsSize && unpackSize == 0))\r
-        return res;\r
-      \r
-      if (inProcessed == 0 && outProcessed == 0)\r
-      {\r
-        if (thereIsSize || status != LZMA_STATUS_FINISHED_WITH_MARK)\r
-          return SZ_ERROR_DATA;\r
-        return res;\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-static SRes Decode(ISeqOutStream *outStream, ISeqInStream *inStream)\r
-{\r
-  UInt64 unpackSize;\r
-  int i;\r
-  SRes res = 0;\r
-\r
-  CLzmaDec state;\r
-\r
-  /* header: 5 bytes of LZMA properties and 8 bytes of uncompressed size */\r
-  unsigned char header[LZMA_PROPS_SIZE + 8];\r
-\r
-  /* Read and parse header */\r
-\r
-  RINOK(SeqInStream_Read(inStream, header, sizeof(header)));\r
-\r
-  unpackSize = 0;\r
-  for (i = 0; i < 8; i++)\r
-    unpackSize += (UInt64)header[LZMA_PROPS_SIZE + i] << (i * 8);\r
-\r
-  LzmaDec_Construct(&state);\r
-  RINOK(LzmaDec_Allocate(&state, header, LZMA_PROPS_SIZE, &g_Alloc));\r
-  res = Decode2(&state, outStream, inStream, unpackSize);\r
-  LzmaDec_Free(&state, &g_Alloc);\r
-  return res;\r
-}\r
-\r
-static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 fileSize, char *rs)\r
-{\r
-  CLzmaEncHandle enc;\r
-  SRes res;\r
-  CLzmaEncProps props;\r
-\r
-  UNUSED_VAR(rs);\r
-\r
-  enc = LzmaEnc_Create(&g_Alloc);\r
-  if (enc == 0)\r
-    return SZ_ERROR_MEM;\r
-\r
-  LzmaEncProps_Init(&props);\r
-  res = LzmaEnc_SetProps(enc, &props);\r
-\r
-  if (res == SZ_OK)\r
-  {\r
-    Byte header[LZMA_PROPS_SIZE + 8];\r
-    size_t headerSize = LZMA_PROPS_SIZE;\r
-    int i;\r
-\r
-    res = LzmaEnc_WriteProperties(enc, header, &headerSize);\r
-    for (i = 0; i < 8; i++)\r
-      header[headerSize++] = (Byte)(fileSize >> (8 * i));\r
-    if (outStream->Write(outStream, header, headerSize) != headerSize)\r
-      res = SZ_ERROR_WRITE;\r
-    else\r
-    {\r
-      if (res == SZ_OK)\r
-        res = LzmaEnc_Encode(enc, outStream, inStream, NULL, &g_Alloc, &g_Alloc);\r
-    }\r
-  }\r
-  LzmaEnc_Destroy(enc, &g_Alloc, &g_Alloc);\r
-  return res;\r
-}\r
-\r
-int main2(int numArgs, const char *args[], char *rs)\r
-{\r
-  CFileSeqInStream inStream;\r
-  CFileOutStream outStream;\r
-  char c;\r
-  int res;\r
-  int encodeMode;\r
-  Bool useOutFile = False;\r
-\r
-  FileSeqInStream_CreateVTable(&inStream);\r
-  File_Construct(&inStream.file);\r
-\r
-  FileOutStream_CreateVTable(&outStream);\r
-  File_Construct(&outStream.file);\r
-\r
-  if (numArgs == 1)\r
-  {\r
-    PrintHelp(rs);\r
-    return 0;\r
-  }\r
-\r
-  if (numArgs < 3 || numArgs > 4 || strlen(args[1]) != 1)\r
-    return PrintUserError(rs);\r
-\r
-  c = args[1][0];\r
-  encodeMode = (c == 'e' || c == 'E');\r
-  if (!encodeMode && c != 'd' && c != 'D')\r
-    return PrintUserError(rs);\r
-\r
-  {\r
-    size_t t4 = sizeof(UInt32);\r
-    size_t t8 = sizeof(UInt64);\r
-    if (t4 != 4 || t8 != 8)\r
-      return PrintError(rs, "Incorrect UInt32 or UInt64");\r
-  }\r
-\r
-  if (InFile_Open(&inStream.file, args[2]) != 0)\r
-    return PrintError(rs, "Can not open input file");\r
-\r
-  if (numArgs > 3)\r
-  {\r
-    useOutFile = True;\r
-    if (OutFile_Open(&outStream.file, args[3]) != 0)\r
-      return PrintError(rs, "Can not open output file");\r
-  }\r
-  else if (encodeMode)\r
-    PrintUserError(rs);\r
-\r
-  if (encodeMode)\r
-  {\r
-    UInt64 fileSize;\r
-    File_GetLength(&inStream.file, &fileSize);\r
-    res = Encode(&outStream.s, &inStream.s, fileSize, rs);\r
-  }\r
-  else\r
-  {\r
-    res = Decode(&outStream.s, useOutFile ? &inStream.s : NULL);\r
-  }\r
-\r
-  if (useOutFile)\r
-    File_Close(&outStream.file);\r
-  File_Close(&inStream.file);\r
-\r
-  if (res != SZ_OK)\r
-  {\r
-    if (res == SZ_ERROR_MEM)\r
-      return PrintError(rs, kCantAllocateMessage);\r
-    else if (res == SZ_ERROR_DATA)\r
-      return PrintError(rs, kDataErrorMessage);\r
-    else if (res == SZ_ERROR_WRITE)\r
-      return PrintError(rs, kCantWriteMessage);\r
-    else if (res == SZ_ERROR_READ)\r
-      return PrintError(rs, kCantReadMessage);\r
-    return PrintErrorNumber(rs, res);\r
-  }\r
-  return 0;\r
-}\r
-\r
-int MY_CDECL main(int numArgs, const char *args[])\r
-{\r
-  char rs[800] = { 0 };\r
-  int res = main2(numArgs, args, rs);\r
-  fputs(rs, stdout);\r
-  return res;\r
-}\r
diff --git a/deps/lzma-16.04/C/Util/Lzma/LzmaUtil.dsp b/deps/lzma-16.04/C/Util/Lzma/LzmaUtil.dsp
deleted file mode 100644 (file)
index df1f0cb..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-# Microsoft Developer Studio Project File - Name="LzmaUtil" - Package Owner=<4>\r
-# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
-# ** DO NOT EDIT **\r
-\r
-# TARGTYPE "Win32 (x86) Console Application" 0x0103\r
-\r
-CFG=LzmaUtil - Win32 Debug\r
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
-!MESSAGE use the Export Makefile command and run\r
-!MESSAGE \r
-!MESSAGE NMAKE /f "LzmaUtil.mak".\r
-!MESSAGE \r
-!MESSAGE You can specify a configuration when running NMAKE\r
-!MESSAGE by defining the macro CFG on the command line. For example:\r
-!MESSAGE \r
-!MESSAGE NMAKE /f "LzmaUtil.mak" CFG="LzmaUtil - Win32 Debug"\r
-!MESSAGE \r
-!MESSAGE Possible choices for configuration are:\r
-!MESSAGE \r
-!MESSAGE "LzmaUtil - Win32 Release" (based on "Win32 (x86) Console Application")\r
-!MESSAGE "LzmaUtil - Win32 Debug" (based on "Win32 (x86) Console Application")\r
-!MESSAGE \r
-\r
-# Begin Project\r
-# PROP AllowPerConfigDependencies 0\r
-# PROP Scc_ProjName ""\r
-# PROP Scc_LocalPath ""\r
-CPP=cl.exe\r
-RSC=rc.exe\r
-\r
-!IF  "$(CFG)" == "LzmaUtil - Win32 Release"\r
-\r
-# PROP BASE Use_MFC 0\r
-# PROP BASE Use_Debug_Libraries 0\r
-# PROP BASE Output_Dir "Release"\r
-# PROP BASE Intermediate_Dir "Release"\r
-# PROP BASE Target_Dir ""\r
-# PROP Use_MFC 0\r
-# PROP Use_Debug_Libraries 0\r
-# PROP Output_Dir "Release"\r
-# PROP Intermediate_Dir "Release"\r
-# PROP Ignore_Export_Lib 0\r
-# PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c\r
-# ADD CPP /nologo /MT /W4 /WX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c\r
-# SUBTRACT CPP /YX\r
-# ADD BASE RSC /l 0x419 /d "NDEBUG"\r
-# ADD RSC /l 0x419 /d "NDEBUG"\r
-BSC32=bscmake.exe\r
-# ADD BASE BSC32 /nologo\r
-# ADD BSC32 /nologo\r
-LINK32=link.exe\r
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\r
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"c:\util\7lzma.exe"\r
-\r
-!ELSEIF  "$(CFG)" == "LzmaUtil - Win32 Debug"\r
-\r
-# PROP BASE Use_MFC 0\r
-# PROP BASE Use_Debug_Libraries 1\r
-# PROP BASE Output_Dir "Debug"\r
-# PROP BASE Intermediate_Dir "Debug"\r
-# PROP BASE Target_Dir ""\r
-# PROP Use_MFC 0\r
-# PROP Use_Debug_Libraries 1\r
-# PROP Output_Dir "Debug"\r
-# PROP Intermediate_Dir "Debug"\r
-# PROP Ignore_Export_Lib 0\r
-# PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c\r
-# ADD CPP /nologo /MTd /W4 /WX /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c\r
-# SUBTRACT CPP /YX\r
-# ADD BASE RSC /l 0x419 /d "_DEBUG"\r
-# ADD RSC /l 0x419 /d "_DEBUG"\r
-BSC32=bscmake.exe\r
-# ADD BASE BSC32 /nologo\r
-# ADD BSC32 /nologo\r
-LINK32=link.exe\r
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\r
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"c:\util\7lzma.exe" /pdbtype:sept\r
-\r
-!ENDIF \r
-\r
-# Begin Target\r
-\r
-# Name "LzmaUtil - Win32 Release"\r
-# Name "LzmaUtil - Win32 Debug"\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zFile.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zFile.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zStream.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zVersion.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Alloc.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Alloc.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\CpuArch.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzFind.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzFind.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzFindMt.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzFindMt.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzHash.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzmaDec.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzmaDec.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzmaEnc.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzmaEnc.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\LzmaUtil.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Threads.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Threads.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Types.h\r
-# End Source File\r
-# End Target\r
-# End Project\r
diff --git a/deps/lzma-16.04/C/Util/Lzma/LzmaUtil.dsw b/deps/lzma-16.04/C/Util/Lzma/LzmaUtil.dsw
deleted file mode 100644 (file)
index f435487..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00\r
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r
-\r
-###############################################################################\r
-\r
-Project: "LzmaUtil"=.\LzmaUtil.dsp - Package Owner=<4>\r
-\r
-Package=<5>\r
-{{{\r
-}}}\r
-\r
-Package=<4>\r
-{{{\r
-}}}\r
-\r
-###############################################################################\r
-\r
-Global:\r
-\r
-Package=<5>\r
-{{{\r
-}}}\r
-\r
-Package=<3>\r
-{{{\r
-}}}\r
-\r
-###############################################################################\r
-\r
diff --git a/deps/lzma-16.04/C/Util/Lzma/makefile b/deps/lzma-16.04/C/Util/Lzma/makefile
deleted file mode 100644 (file)
index 3b825f2..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-# MY_STATIC_LINK=1\r
-PROG = LZMAc.exe\r
-\r
-CFLAGS = $(CFLAGS) \\r
-\r
-LIB_OBJS = \\r
-  $O\LzmaUtil.obj \\r
-\r
-C_OBJS = \\r
-  $O\Alloc.obj \\r
-  $O\LzFind.obj \\r
-  $O\LzFindMt.obj \\r
-  $O\LzmaDec.obj \\r
-  $O\LzmaEnc.obj \\r
-  $O\7zFile.obj \\r
-  $O\7zStream.obj \\r
-  $O\Threads.obj \\r
-\r
-OBJS = \\r
-  $(LIB_OBJS) \\r
-  $(C_OBJS) \\r
-\r
-!include "../../../CPP/Build.mak"\r
-\r
-$(LIB_OBJS): $(*B).c\r
-       $(COMPL_O2)\r
-$(C_OBJS): ../../$(*B).c\r
-       $(COMPL_O2)\r
diff --git a/deps/lzma-16.04/C/Util/Lzma/makefile.gcc b/deps/lzma-16.04/C/Util/Lzma/makefile.gcc
deleted file mode 100644 (file)
index 12a72bb..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-PROG = lzma\r
-CXX = g++\r
-LIB =\r
-RM = rm -f\r
-CFLAGS = -c -O2 -Wall -D_7ZIP_ST\r
-\r
-OBJS = \\r
-  LzmaUtil.o \\r
-  Alloc.o \\r
-  LzFind.o \\r
-  LzmaDec.o \\r
-  LzmaEnc.o \\r
-  7zFile.o \\r
-  7zStream.o \\r
-\r
-\r
-all: $(PROG)\r
-\r
-$(PROG): $(OBJS)\r
-       $(CXX) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIB) $(LIB2)\r
-\r
-LzmaUtil.o: LzmaUtil.c\r
-       $(CXX) $(CFLAGS) LzmaUtil.c\r
-\r
-Alloc.o: ../../Alloc.c\r
-       $(CXX) $(CFLAGS) ../../Alloc.c\r
-\r
-LzFind.o: ../../LzFind.c\r
-       $(CXX) $(CFLAGS) ../../LzFind.c\r
-\r
-LzmaDec.o: ../../LzmaDec.c\r
-       $(CXX) $(CFLAGS) ../../LzmaDec.c\r
-\r
-LzmaEnc.o: ../../LzmaEnc.c\r
-       $(CXX) $(CFLAGS) ../../LzmaEnc.c\r
-\r
-7zFile.o: ../../7zFile.c\r
-       $(CXX) $(CFLAGS) ../../7zFile.c\r
-\r
-7zStream.o: ../../7zStream.c\r
-       $(CXX) $(CFLAGS) ../../7zStream.c\r
-\r
-clean:\r
-       -$(RM) $(PROG) $(OBJS)\r
diff --git a/deps/lzma-16.04/C/Util/LzmaLib/LzmaLib.def b/deps/lzma-16.04/C/Util/LzmaLib/LzmaLib.def
deleted file mode 100644 (file)
index 43b9597..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-EXPORTS\r
-  LzmaCompress\r
-  LzmaUncompress\r
-\r
diff --git a/deps/lzma-16.04/C/Util/LzmaLib/LzmaLib.dsp b/deps/lzma-16.04/C/Util/LzmaLib/LzmaLib.dsp
deleted file mode 100644 (file)
index 0d4c981..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-# Microsoft Developer Studio Project File - Name="LzmaLib" - Package Owner=<4>\r
-# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
-# ** DO NOT EDIT **\r
-\r
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102\r
-\r
-CFG=LzmaLib - Win32 Debug\r
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
-!MESSAGE use the Export Makefile command and run\r
-!MESSAGE \r
-!MESSAGE NMAKE /f "LzmaLib.mak".\r
-!MESSAGE \r
-!MESSAGE You can specify a configuration when running NMAKE\r
-!MESSAGE by defining the macro CFG on the command line. For example:\r
-!MESSAGE \r
-!MESSAGE NMAKE /f "LzmaLib.mak" CFG="LzmaLib - Win32 Debug"\r
-!MESSAGE \r
-!MESSAGE Possible choices for configuration are:\r
-!MESSAGE \r
-!MESSAGE "LzmaLib - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")\r
-!MESSAGE "LzmaLib - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")\r
-!MESSAGE \r
-\r
-# Begin Project\r
-# PROP AllowPerConfigDependencies 0\r
-# PROP Scc_ProjName ""\r
-# PROP Scc_LocalPath ""\r
-CPP=cl.exe\r
-MTL=midl.exe\r
-RSC=rc.exe\r
-\r
-!IF  "$(CFG)" == "LzmaLib - Win32 Release"\r
-\r
-# PROP BASE Use_MFC 0\r
-# PROP BASE Use_Debug_Libraries 0\r
-# PROP BASE Output_Dir "Release"\r
-# PROP BASE Intermediate_Dir "Release"\r
-# PROP BASE Target_Dir ""\r
-# PROP Use_MFC 0\r
-# PROP Use_Debug_Libraries 0\r
-# PROP Output_Dir "Release"\r
-# PROP Intermediate_Dir "Release"\r
-# PROP Ignore_Export_Lib 0\r
-# PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /YX /FD /c\r
-# ADD CPP /nologo /Gr /MT /W3 /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /FD /c\r
-# SUBTRACT CPP /YX\r
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
-# ADD BASE RSC /l 0x419 /d "NDEBUG"\r
-# ADD RSC /l 0x419 /d "NDEBUG"\r
-BSC32=bscmake.exe\r
-# ADD BASE BSC32 /nologo\r
-# ADD BSC32 /nologo\r
-LINK32=link.exe\r
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386\r
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Util\LZMA.dll" /opt:NOWIN98\r
-# SUBTRACT LINK32 /pdb:none\r
-\r
-!ELSEIF  "$(CFG)" == "LzmaLib - Win32 Debug"\r
-\r
-# PROP BASE Use_MFC 0\r
-# PROP BASE Use_Debug_Libraries 1\r
-# PROP BASE Output_Dir "Debug"\r
-# PROP BASE Intermediate_Dir "Debug"\r
-# PROP BASE Target_Dir ""\r
-# PROP Use_MFC 0\r
-# PROP Use_Debug_Libraries 1\r
-# PROP Output_Dir "Debug"\r
-# PROP Intermediate_Dir "Debug"\r
-# PROP Ignore_Export_Lib 0\r
-# PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /YX /FD /GZ /c\r
-# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /D "COMPRESS_MF_MT" /FD /GZ /c\r
-# SUBTRACT CPP /YX\r
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32\r
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32\r
-# ADD BASE RSC /l 0x419 /d "_DEBUG"\r
-# ADD RSC /l 0x419 /d "_DEBUG"\r
-BSC32=bscmake.exe\r
-# ADD BASE BSC32 /nologo\r
-# ADD BSC32 /nologo\r
-LINK32=link.exe\r
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept\r
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Util\LZMA.dll" /pdbtype:sept\r
-\r
-!ENDIF \r
-\r
-# Begin Target\r
-\r
-# Name "LzmaLib - Win32 Release"\r
-# Name "LzmaLib - Win32 Debug"\r
-# Begin Group "Spec"\r
-\r
-# PROP Default_Filter ""\r
-# Begin Source File\r
-\r
-SOURCE=.\LzmaLib.def\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\LzmaLibExports.c\r
-# End Source File\r
-# End Group\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zTypes.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Alloc.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Alloc.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\IStream.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzFind.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzFind.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzFindMt.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzFindMt.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzHash.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzmaDec.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzmaDec.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzmaEnc.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzmaEnc.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzmaLib.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzmaLib.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\resource.rc\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Threads.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Threads.h\r
-# End Source File\r
-# End Target\r
-# End Project\r
diff --git a/deps/lzma-16.04/C/Util/LzmaLib/LzmaLib.dsw b/deps/lzma-16.04/C/Util/LzmaLib/LzmaLib.dsw
deleted file mode 100644 (file)
index f6c5559..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00\r
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r
-\r
-###############################################################################\r
-\r
-Project: "LzmaLib"=.\LzmaLib.dsp - Package Owner=<4>\r
-\r
-Package=<5>\r
-{{{\r
-}}}\r
-\r
-Package=<4>\r
-{{{\r
-}}}\r
-\r
-###############################################################################\r
-\r
-Global:\r
-\r
-Package=<5>\r
-{{{\r
-}}}\r
-\r
-Package=<3>\r
-{{{\r
-}}}\r
-\r
-###############################################################################\r
-\r
diff --git a/deps/lzma-16.04/C/Util/LzmaLib/LzmaLibExports.c b/deps/lzma-16.04/C/Util/LzmaLib/LzmaLibExports.c
deleted file mode 100644 (file)
index 02600c7..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-/* LzmaLibExports.c -- LZMA library DLL Entry point\r
-2015-11-08 : Igor Pavlov : Public domain */\r
-\r
-#include "../../Precomp.h"\r
-\r
-#include <windows.h>\r
-\r
-BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)\r
-{\r
-  UNUSED_VAR(hInstance);\r
-  UNUSED_VAR(dwReason);\r
-  UNUSED_VAR(lpReserved);\r
-  return TRUE;\r
-}\r
diff --git a/deps/lzma-16.04/C/Util/LzmaLib/makefile b/deps/lzma-16.04/C/Util/LzmaLib/makefile
deleted file mode 100644 (file)
index e0f3114..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-MY_STATIC_LINK=1\r
-SLIB = sLZMA.lib\r
-PROG = LZMA.dll\r
-SLIBPATH = $O\$(SLIB)\r
-\r
-DEF_FILE = LzmaLib.def\r
-CFLAGS = $(CFLAGS) \\r
-\r
-LIB_OBJS = \\r
-  $O\LzmaLibExports.obj \\r
-\r
-C_OBJS = \\r
-  $O\Alloc.obj \\r
-  $O\LzFind.obj \\r
-  $O\LzFindMt.obj \\r
-  $O\LzmaDec.obj \\r
-  $O\LzmaEnc.obj \\r
-  $O\LzmaLib.obj \\r
-  $O\Threads.obj \\r
-\r
-OBJS = \\r
-  $(LIB_OBJS) \\r
-  $(C_OBJS) \\r
-  $O\resource.res\r
-\r
-!include "../../../CPP/Build.mak"\r
-\r
-$(SLIBPATH): $O $(OBJS)\r
-       lib -out:$(SLIBPATH) $(OBJS) $(LIBS)\r
-\r
-$(LIB_OBJS): $(*B).c\r
-       $(COMPL_O2)\r
-$(C_OBJS): ../../$(*B).c\r
-       $(COMPL_O2)\r
diff --git a/deps/lzma-16.04/C/Util/LzmaLib/resource.rc b/deps/lzma-16.04/C/Util/LzmaLib/resource.rc
deleted file mode 100644 (file)
index d95e3f3..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "../../7zVersion.rc"\r
-\r
-MY_VERSION_INFO_DLL("LZMA library", "LZMA")\r
diff --git a/deps/lzma-16.04/C/Util/SfxSetup/Precomp.c b/deps/lzma-16.04/C/Util/SfxSetup/Precomp.c
deleted file mode 100644 (file)
index 34b60f8..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-/* Precomp.c -- StdAfx\r
-2013-01-21 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
diff --git a/deps/lzma-16.04/C/Util/SfxSetup/Precomp.h b/deps/lzma-16.04/C/Util/SfxSetup/Precomp.h
deleted file mode 100644 (file)
index 9f398d0..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-/* Precomp.h -- StdAfx\r
-2013-06-16 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __7Z_PRECOMP_H\r
-#define __7Z_PRECOMP_H\r
-\r
-#include "../../Compiler.h"\r
-#include "../../7zTypes.h"\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/Util/SfxSetup/SfxSetup.c b/deps/lzma-16.04/C/Util/SfxSetup/SfxSetup.c
deleted file mode 100644 (file)
index 50e57ae..0000000
+++ /dev/null
@@ -1,626 +0,0 @@
-/* SfxSetup.c - 7z SFX Setup\r
-2016-05-16 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#ifndef UNICODE\r
-#define UNICODE\r
-#endif\r
-\r
-#ifndef _UNICODE\r
-#define _UNICODE\r
-#endif\r
-\r
-#ifdef _CONSOLE\r
-#include <stdio.h>\r
-#endif\r
-\r
-#include "../../7z.h"\r
-#include "../../7zAlloc.h"\r
-#include "../../7zCrc.h"\r
-#include "../../7zFile.h"\r
-#include "../../CpuArch.h"\r
-#include "../../DllSecur.h"\r
-\r
-#define k_EXE_ExtIndex 2\r
-\r
-static const char * const kExts[] =\r
-{\r
-    "bat"\r
-  , "cmd"\r
-  , "exe"\r
-  , "inf"\r
-  , "msi"\r
-  #ifdef UNDER_CE\r
-  , "cab"\r
-  #endif\r
-  , "html"\r
-  , "htm"\r
-};\r
-\r
-static const char * const kNames[] =\r
-{\r
-    "setup"\r
-  , "install"\r
-  , "run"\r
-  , "start"\r
-};\r
-\r
-static unsigned FindExt(const wchar_t *s, unsigned *extLen)\r
-{\r
-  unsigned len = (unsigned)wcslen(s);\r
-  unsigned i;\r
-  for (i = len; i > 0; i--)\r
-  {\r
-    if (s[i - 1] == '.')\r
-    {\r
-      *extLen = len - i;\r
-      return i - 1;\r
-    }\r
-  }\r
-  *extLen = 0;\r
-  return len;\r
-}\r
-\r
-#define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) -= 0x20 : (c)))\r
-\r
-static unsigned FindItem(const char * const *items, unsigned num, const wchar_t *s, unsigned len)\r
-{\r
-  unsigned i;\r
-  for (i = 0; i < num; i++)\r
-  {\r
-    const char *item = items[i];\r
-    unsigned itemLen = (unsigned)strlen(item);\r
-    unsigned j;\r
-    if (len != itemLen)\r
-      continue;\r
-    for (j = 0; j < len; j++)\r
-    {\r
-      unsigned c = (Byte)item[j];\r
-      if (c != s[j] && MAKE_CHAR_UPPER(c) != s[j])\r
-        break;\r
-    }\r
-    if (j == len)\r
-      return i;\r
-  }\r
-  return i;\r
-}\r
-\r
-#ifdef _CONSOLE\r
-static BOOL WINAPI HandlerRoutine(DWORD ctrlType)\r
-{\r
-  UNUSED_VAR(ctrlType);\r
-  return TRUE;\r
-}\r
-#endif\r
-\r
-static void PrintErrorMessage(const char *message)\r
-{\r
-  #ifdef _CONSOLE\r
-  printf("\n7-Zip Error: %s\n", message);\r
-  #else\r
-  #ifdef UNDER_CE\r
-  WCHAR messageW[256 + 4];\r
-  unsigned i;\r
-  for (i = 0; i < 256 && message[i] != 0; i++)\r
-    messageW[i] = message[i];\r
-  messageW[i] = 0;\r
-  MessageBoxW(0, messageW, L"7-Zip Error", MB_ICONERROR);\r
-  #else\r
-  MessageBoxA(0, message, "7-Zip Error", MB_ICONERROR);\r
-  #endif\r
-  #endif\r
-}\r
-\r
-static WRes MyCreateDir(const WCHAR *name)\r
-{\r
-  return CreateDirectoryW(name, NULL) ? 0 : GetLastError();\r
-}\r
-\r
-#ifdef UNDER_CE\r
-#define kBufferSize (1 << 13)\r
-#else\r
-#define kBufferSize (1 << 15)\r
-#endif\r
-\r
-#define kSignatureSearchLimit (1 << 22)\r
-\r
-static Bool FindSignature(CSzFile *stream, UInt64 *resPos)\r
-{\r
-  Byte buf[kBufferSize];\r
-  size_t numPrevBytes = 0;\r
-  *resPos = 0;\r
-  for (;;)\r
-  {\r
-    size_t processed, pos;\r
-    if (*resPos > kSignatureSearchLimit)\r
-      return False;\r
-    processed = kBufferSize - numPrevBytes;\r
-    if (File_Read(stream, buf + numPrevBytes, &processed) != 0)\r
-      return False;\r
-    processed += numPrevBytes;\r
-    if (processed < k7zStartHeaderSize ||\r
-        (processed == k7zStartHeaderSize && numPrevBytes != 0))\r
-      return False;\r
-    processed -= k7zStartHeaderSize;\r
-    for (pos = 0; pos <= processed; pos++)\r
-    {\r
-      for (; pos <= processed && buf[pos] != '7'; pos++);\r
-      if (pos > processed)\r
-        break;\r
-      if (memcmp(buf + pos, k7zSignature, k7zSignatureSize) == 0)\r
-        if (CrcCalc(buf + pos + 12, 20) == GetUi32(buf + pos + 8))\r
-        {\r
-          *resPos += pos;\r
-          return True;\r
-        }\r
-    }\r
-    *resPos += processed;\r
-    numPrevBytes = k7zStartHeaderSize;\r
-    memmove(buf, buf + processed, k7zStartHeaderSize);\r
-  }\r
-}\r
-\r
-static Bool DoesFileOrDirExist(const WCHAR *path)\r
-{\r
-  WIN32_FIND_DATAW fd;\r
-  HANDLE handle;\r
-  handle = FindFirstFileW(path, &fd);\r
-  if (handle == INVALID_HANDLE_VALUE)\r
-    return False;\r
-  FindClose(handle);\r
-  return True;\r
-}\r
-\r
-static WRes RemoveDirWithSubItems(WCHAR *path)\r
-{\r
-  WIN32_FIND_DATAW fd;\r
-  HANDLE handle;\r
-  WRes res = 0;\r
-  size_t len = wcslen(path);\r
-  wcscpy(path + len, L"*");\r
-  handle = FindFirstFileW(path, &fd);\r
-  path[len] = L'\0';\r
-  if (handle == INVALID_HANDLE_VALUE)\r
-    return GetLastError();\r
-  \r
-  for (;;)\r
-  {\r
-    if (wcscmp(fd.cFileName, L".") != 0 &&\r
-        wcscmp(fd.cFileName, L"..") != 0)\r
-    {\r
-      wcscpy(path + len, fd.cFileName);\r
-      if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)\r
-      {\r
-        wcscat(path, WSTRING_PATH_SEPARATOR);\r
-        res = RemoveDirWithSubItems(path);\r
-      }\r
-      else\r
-      {\r
-        SetFileAttributesW(path, 0);\r
-        if (DeleteFileW(path) == 0)\r
-          res = GetLastError();\r
-      }\r
-    \r
-      if (res != 0)\r
-        break;\r
-    }\r
-  \r
-    if (!FindNextFileW(handle, &fd))\r
-    {\r
-      res = GetLastError();\r
-      if (res == ERROR_NO_MORE_FILES)\r
-        res = 0;\r
-      break;\r
-    }\r
-  }\r
-  \r
-  path[len] = L'\0';\r
-  FindClose(handle);\r
-  if (res == 0)\r
-  {\r
-    if (!RemoveDirectoryW(path))\r
-      res = GetLastError();\r
-  }\r
-  return res;\r
-}\r
-\r
-#ifdef _CONSOLE\r
-int MY_CDECL main()\r
-#else\r
-int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,\r
-  #ifdef UNDER_CE\r
-  LPWSTR\r
-  #else\r
-  LPSTR\r
-  #endif\r
-  lpCmdLine, int nCmdShow)\r
-#endif\r
-{\r
-  CFileInStream archiveStream;\r
-  CLookToRead lookStream;\r
-  CSzArEx db;\r
-  SRes res = SZ_OK;\r
-  ISzAlloc allocImp;\r
-  ISzAlloc allocTempImp;\r
-  WCHAR sfxPath[MAX_PATH + 2];\r
-  WCHAR path[MAX_PATH * 3 + 2];\r
-  #ifndef UNDER_CE\r
-  WCHAR workCurDir[MAX_PATH + 32];\r
-  #endif\r
-  size_t pathLen;\r
-  DWORD winRes;\r
-  const wchar_t *cmdLineParams;\r
-  const char *errorMessage = NULL;\r
-  Bool useShellExecute = True;\r
-  DWORD exitCode = 0;\r
-\r
-  LoadSecurityDlls();\r
-\r
-  #ifdef _CONSOLE\r
-  SetConsoleCtrlHandler(HandlerRoutine, TRUE);\r
-  #else\r
-  UNUSED_VAR(hInstance);\r
-  UNUSED_VAR(hPrevInstance);\r
-  UNUSED_VAR(lpCmdLine);\r
-  UNUSED_VAR(nCmdShow);\r
-  #endif\r
-\r
-  CrcGenerateTable();\r
-\r
-  allocImp.Alloc = SzAlloc;\r
-  allocImp.Free = SzFree;\r
-\r
-  allocTempImp.Alloc = SzAllocTemp;\r
-  allocTempImp.Free = SzFreeTemp;\r
-\r
-  FileInStream_CreateVTable(&archiveStream);\r
-  LookToRead_CreateVTable(&lookStream, False);\r
\r
-  winRes = GetModuleFileNameW(NULL, sfxPath, MAX_PATH);\r
-  if (winRes == 0 || winRes > MAX_PATH)\r
-    return 1;\r
-  {\r
-    cmdLineParams = GetCommandLineW();\r
-    #ifndef UNDER_CE\r
-    {\r
-      Bool quoteMode = False;\r
-      for (;; cmdLineParams++)\r
-      {\r
-        wchar_t c = *cmdLineParams;\r
-        if (c == L'\"')\r
-          quoteMode = !quoteMode;\r
-        else if (c == 0 || (c == L' ' && !quoteMode))\r
-          break;\r
-      }\r
-    }\r
-    #endif\r
-  }\r
-\r
-  {\r
-    unsigned i;\r
-    DWORD d;\r
-    winRes = GetTempPathW(MAX_PATH, path);\r
-    if (winRes == 0 || winRes > MAX_PATH)\r
-      return 1;\r
-    pathLen = wcslen(path);\r
-    d = (GetTickCount() << 12) ^ (GetCurrentThreadId() << 14) ^ GetCurrentProcessId();\r
-    \r
-    for (i = 0;; i++, d += GetTickCount())\r
-    {\r
-      if (i >= 100)\r
-      {\r
-        res = SZ_ERROR_FAIL;\r
-        break;\r
-      }\r
-      wcscpy(path + pathLen, L"7z");\r
-\r
-      {\r
-        wchar_t *s = path + wcslen(path);\r
-        UInt32 value = d;\r
-        unsigned k;\r
-        for (k = 0; k < 8; k++)\r
-        {\r
-          unsigned t = value & 0xF;\r
-          value >>= 4;\r
-          s[7 - k] = (wchar_t)((t < 10) ? ('0' + t) : ('A' + (t - 10)));\r
-        }\r
-        s[k] = '\0';\r
-      }\r
-\r
-      if (DoesFileOrDirExist(path))\r
-        continue;\r
-      if (CreateDirectoryW(path, NULL))\r
-      {\r
-        wcscat(path, WSTRING_PATH_SEPARATOR);\r
-        pathLen = wcslen(path);\r
-        break;\r
-      }\r
-      if (GetLastError() != ERROR_ALREADY_EXISTS)\r
-      {\r
-        res = SZ_ERROR_FAIL;\r
-        break;\r
-      }\r
-    }\r
-    \r
-    #ifndef UNDER_CE\r
-    wcscpy(workCurDir, path);\r
-    #endif\r
-    if (res != SZ_OK)\r
-      errorMessage = "Can't create temp folder";\r
-  }\r
-\r
-  if (res != SZ_OK)\r
-  {\r
-    if (!errorMessage)\r
-      errorMessage = "Error";\r
-    PrintErrorMessage(errorMessage);\r
-    return 1;\r
-  }\r
-\r
-  if (InFile_OpenW(&archiveStream.file, sfxPath) != 0)\r
-  {\r
-    errorMessage = "can not open input file";\r
-    res = SZ_ERROR_FAIL;\r
-  }\r
-  else\r
-  {\r
-    UInt64 pos = 0;\r
-    if (!FindSignature(&archiveStream.file, &pos))\r
-      res = SZ_ERROR_FAIL;\r
-    else if (File_Seek(&archiveStream.file, (Int64 *)&pos, SZ_SEEK_SET) != 0)\r
-      res = SZ_ERROR_FAIL;\r
-    if (res != 0)\r
-      errorMessage = "Can't find 7z archive";\r
-  }\r
-\r
-  if (res == SZ_OK)\r
-  {\r
-    lookStream.realStream = &archiveStream.s;\r
-    LookToRead_Init(&lookStream);\r
-  }\r
-\r
-  SzArEx_Init(&db);\r
-  if (res == SZ_OK)\r
-  {\r
-    res = SzArEx_Open(&db, &lookStream.s, &allocImp, &allocTempImp);\r
-  }\r
-  \r
-  if (res == SZ_OK)\r
-  {\r
-    UInt32 executeFileIndex = (UInt32)(Int32)-1;\r
-    UInt32 minPrice = 1 << 30;\r
-    UInt32 i;\r
-    UInt32 blockIndex = 0xFFFFFFFF; /* it can have any value before first call (if outBuffer = 0) */\r
-    Byte *outBuffer = 0; /* it must be 0 before first call for each new archive. */\r
-    size_t outBufferSize = 0;  /* it can have any value before first call (if outBuffer = 0) */\r
-    \r
-    for (i = 0; i < db.NumFiles; i++)\r
-    {\r
-      size_t offset = 0;\r
-      size_t outSizeProcessed = 0;\r
-      WCHAR *temp;\r
-\r
-      if (SzArEx_GetFileNameUtf16(&db, i, NULL) >= MAX_PATH)\r
-      {\r
-        res = SZ_ERROR_FAIL;\r
-        break;\r
-      }\r
-      \r
-      temp = path + pathLen;\r
-      \r
-      SzArEx_GetFileNameUtf16(&db, i, temp);\r
-      {\r
-        res = SzArEx_Extract(&db, &lookStream.s, i,\r
-          &blockIndex, &outBuffer, &outBufferSize,\r
-          &offset, &outSizeProcessed,\r
-          &allocImp, &allocTempImp);\r
-        if (res != SZ_OK)\r
-          break;\r
-      }\r
-      {\r
-        CSzFile outFile;\r
-        size_t processedSize;\r
-        size_t j;\r
-        size_t nameStartPos = 0;\r
-        for (j = 0; temp[j] != 0; j++)\r
-        {\r
-          if (temp[j] == '/')\r
-          {\r
-            temp[j] = 0;\r
-            MyCreateDir(path);\r
-            temp[j] = CHAR_PATH_SEPARATOR;\r
-            nameStartPos = j + 1;\r
-          }\r
-        }\r
-\r
-        if (SzArEx_IsDir(&db, i))\r
-        {\r
-          MyCreateDir(path);\r
-          continue;\r
-        }\r
-        else\r
-        {\r
-          unsigned extLen;\r
-          const WCHAR *name = temp + nameStartPos;\r
-          unsigned len = (unsigned)wcslen(name);\r
-          unsigned nameLen = FindExt(temp + nameStartPos, &extLen);\r
-          unsigned extPrice = FindItem(kExts, sizeof(kExts) / sizeof(kExts[0]), name + len - extLen, extLen);\r
-          unsigned namePrice = FindItem(kNames, sizeof(kNames) / sizeof(kNames[0]), name, nameLen);\r
-\r
-          unsigned price = namePrice + extPrice * 64 + (nameStartPos == 0 ? 0 : (1 << 12));\r
-          if (minPrice > price)\r
-          {\r
-            minPrice = price;\r
-            executeFileIndex = i;\r
-            useShellExecute = (extPrice != k_EXE_ExtIndex);\r
-          }\r
-         \r
-          if (DoesFileOrDirExist(path))\r
-          {\r
-            errorMessage = "Duplicate file";\r
-            res = SZ_ERROR_FAIL;\r
-            break;\r
-          }\r
-          if (OutFile_OpenW(&outFile, path))\r
-          {\r
-            errorMessage = "Can't open output file";\r
-            res = SZ_ERROR_FAIL;\r
-            break;\r
-          }\r
-        }\r
-  \r
-        processedSize = outSizeProcessed;\r
-        if (File_Write(&outFile, outBuffer + offset, &processedSize) != 0 || processedSize != outSizeProcessed)\r
-        {\r
-          errorMessage = "Can't write output file";\r
-          res = SZ_ERROR_FAIL;\r
-        }\r
-        \r
-        #ifdef USE_WINDOWS_FILE\r
-        if (SzBitWithVals_Check(&db.MTime, i))\r
-        {\r
-          const CNtfsFileTime *t = db.MTime.Vals + i;\r
-          FILETIME mTime;\r
-          mTime.dwLowDateTime = t->Low;\r
-          mTime.dwHighDateTime = t->High;\r
-          SetFileTime(outFile.handle, NULL, NULL, &mTime);\r
-        }\r
-        #endif\r
-        \r
-        {\r
-          SRes res2 = File_Close(&outFile);\r
-          if (res != SZ_OK)\r
-            break;\r
-          if (res2 != SZ_OK)\r
-          {\r
-            res = res2;\r
-            break;\r
-          }\r
-        }\r
-        #ifdef USE_WINDOWS_FILE\r
-        if (SzBitWithVals_Check(&db.Attribs, i))\r
-          SetFileAttributesW(path, db.Attribs.Vals[i]);\r
-        #endif\r
-      }\r
-    }\r
-\r
-    if (res == SZ_OK)\r
-    {\r
-      if (executeFileIndex == (UInt32)(Int32)-1)\r
-      {\r
-        errorMessage = "There is no file to execute";\r
-        res = SZ_ERROR_FAIL;\r
-      }\r
-      else\r
-      {\r
-        WCHAR *temp = path + pathLen;\r
-        UInt32 j;\r
-        SzArEx_GetFileNameUtf16(&db, executeFileIndex, temp);\r
-        for (j = 0; temp[j] != 0; j++)\r
-          if (temp[j] == '/')\r
-            temp[j] = CHAR_PATH_SEPARATOR;\r
-      }\r
-    }\r
-    IAlloc_Free(&allocImp, outBuffer);\r
-  }\r
-  SzArEx_Free(&db, &allocImp);\r
-\r
-  File_Close(&archiveStream.file);\r
-\r
-  if (res == SZ_OK)\r
-  {\r
-    HANDLE hProcess = 0;\r
-    \r
-    #ifndef UNDER_CE\r
-    WCHAR oldCurDir[MAX_PATH + 2];\r
-    oldCurDir[0] = 0;\r
-    {\r
-      DWORD needLen = GetCurrentDirectory(MAX_PATH + 1, oldCurDir);\r
-      if (needLen == 0 || needLen > MAX_PATH)\r
-        oldCurDir[0] = 0;\r
-      SetCurrentDirectory(workCurDir);\r
-    }\r
-    #endif\r
-    \r
-    if (useShellExecute)\r
-    {\r
-      SHELLEXECUTEINFO ei;\r
-      UINT32 executeRes;\r
-      BOOL success;\r
-      \r
-      memset(&ei, 0, sizeof(ei));\r
-      ei.cbSize = sizeof(ei);\r
-      ei.lpFile = path;\r
-      ei.fMask = SEE_MASK_NOCLOSEPROCESS\r
-          #ifndef UNDER_CE\r
-          | SEE_MASK_FLAG_DDEWAIT\r
-          #endif\r
-          /* | SEE_MASK_NO_CONSOLE */\r
-          ;\r
-      if (wcslen(cmdLineParams) != 0)\r
-        ei.lpParameters = cmdLineParams;\r
-      ei.nShow = SW_SHOWNORMAL; /* SW_HIDE; */\r
-      success = ShellExecuteEx(&ei);\r
-      executeRes = (UINT32)(UINT_PTR)ei.hInstApp;\r
-      if (!success || (executeRes <= 32 && executeRes != 0))  /* executeRes = 0 in Windows CE */\r
-        res = SZ_ERROR_FAIL;\r
-      else\r
-        hProcess = ei.hProcess;\r
-    }\r
-    else\r
-    {\r
-      STARTUPINFOW si;\r
-      PROCESS_INFORMATION pi;\r
-      WCHAR cmdLine[MAX_PATH * 3];\r
-\r
-      wcscpy(cmdLine, path);\r
-      wcscat(cmdLine, cmdLineParams);\r
-      memset(&si, 0, sizeof(si));\r
-      si.cb = sizeof(si);\r
-      if (CreateProcessW(NULL, cmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) == 0)\r
-        res = SZ_ERROR_FAIL;\r
-      else\r
-      {\r
-        CloseHandle(pi.hThread);\r
-        hProcess = pi.hProcess;\r
-      }\r
-    }\r
-    \r
-    if (hProcess != 0)\r
-    {\r
-      WaitForSingleObject(hProcess, INFINITE);\r
-      if (!GetExitCodeProcess(hProcess, &exitCode))\r
-        exitCode = 1;\r
-      CloseHandle(hProcess);\r
-    }\r
-    \r
-    #ifndef UNDER_CE\r
-    SetCurrentDirectory(oldCurDir);\r
-    #endif\r
-  }\r
-\r
-  path[pathLen] = L'\0';\r
-  RemoveDirWithSubItems(path);\r
-\r
-  if (res == SZ_OK)\r
-    return (int)exitCode;\r
-  \r
-  {\r
-    if (res == SZ_ERROR_UNSUPPORTED)\r
-      errorMessage = "Decoder doesn't support this archive";\r
-    else if (res == SZ_ERROR_MEM)\r
-      errorMessage = "Can't allocate required memory";\r
-    else if (res == SZ_ERROR_CRC)\r
-      errorMessage = "CRC error";\r
-    else\r
-    {\r
-      if (!errorMessage)\r
-        errorMessage = "ERROR";\r
-    }\r
\r
-    if (errorMessage)\r
-      PrintErrorMessage(errorMessage);\r
-  }\r
-  return 1;\r
-}\r
diff --git a/deps/lzma-16.04/C/Util/SfxSetup/SfxSetup.dsp b/deps/lzma-16.04/C/Util/SfxSetup/SfxSetup.dsp
deleted file mode 100644 (file)
index be9de6d..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-# Microsoft Developer Studio Project File - Name="SfxSetup" - Package Owner=<4>\r
-# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
-# ** DO NOT EDIT **\r
-\r
-# TARGTYPE "Win32 (x86) Application" 0x0101\r
-\r
-CFG=SfxSetup - Win32 Debug\r
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
-!MESSAGE use the Export Makefile command and run\r
-!MESSAGE \r
-!MESSAGE NMAKE /f "SfxSetup.mak".\r
-!MESSAGE \r
-!MESSAGE You can specify a configuration when running NMAKE\r
-!MESSAGE by defining the macro CFG on the command line. For example:\r
-!MESSAGE \r
-!MESSAGE NMAKE /f "SfxSetup.mak" CFG="SfxSetup - Win32 Debug"\r
-!MESSAGE \r
-!MESSAGE Possible choices for configuration are:\r
-!MESSAGE \r
-!MESSAGE "SfxSetup - Win32 Release" (based on "Win32 (x86) Application")\r
-!MESSAGE "SfxSetup - Win32 Debug" (based on "Win32 (x86) Application")\r
-!MESSAGE \r
-\r
-# Begin Project\r
-# PROP AllowPerConfigDependencies 0\r
-# PROP Scc_ProjName ""\r
-# PROP Scc_LocalPath ""\r
-CPP=cl.exe\r
-MTL=midl.exe\r
-RSC=rc.exe\r
-\r
-!IF  "$(CFG)" == "SfxSetup - Win32 Release"\r
-\r
-# PROP BASE Use_MFC 0\r
-# PROP BASE Use_Debug_Libraries 0\r
-# PROP BASE Output_Dir "Release"\r
-# PROP BASE Intermediate_Dir "Release"\r
-# PROP BASE Target_Dir ""\r
-# PROP Use_MFC 0\r
-# PROP Use_Debug_Libraries 0\r
-# PROP Output_Dir "Release"\r
-# PROP Intermediate_Dir "Release"\r
-# PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c\r
-# ADD CPP /nologo /W4 /WX /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /Yu"Precomp.h" /FD /c\r
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
-# ADD BASE RSC /l 0x419 /d "NDEBUG"\r
-# ADD RSC /l 0x419 /d "NDEBUG"\r
-BSC32=bscmake.exe\r
-# ADD BASE BSC32 /nologo\r
-# ADD BSC32 /nologo\r
-LINK32=link.exe\r
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386\r
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386\r
-\r
-!ELSEIF  "$(CFG)" == "SfxSetup - Win32 Debug"\r
-\r
-# PROP BASE Use_MFC 0\r
-# PROP BASE Use_Debug_Libraries 1\r
-# PROP BASE Output_Dir "Debug"\r
-# PROP BASE Intermediate_Dir "Debug"\r
-# PROP BASE Target_Dir ""\r
-# PROP Use_MFC 0\r
-# PROP Use_Debug_Libraries 1\r
-# PROP Output_Dir "Debug"\r
-# PROP Intermediate_Dir "Debug"\r
-# PROP Ignore_Export_Lib 0\r
-# PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c\r
-# ADD CPP /nologo /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /Yu"Precomp.h" /FD /GZ /c\r
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32\r
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32\r
-# ADD BASE RSC /l 0x419 /d "_DEBUG"\r
-# ADD RSC /l 0x419 /d "_DEBUG"\r
-BSC32=bscmake.exe\r
-# ADD BASE BSC32 /nologo\r
-# ADD BSC32 /nologo\r
-LINK32=link.exe\r
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept\r
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept\r
-\r
-!ENDIF \r
-\r
-# Begin Target\r
-\r
-# Name "SfxSetup - Win32 Release"\r
-# Name "SfxSetup - Win32 Debug"\r
-# Begin Group "Common"\r
-\r
-# PROP Default_Filter ""\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7z.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zAlloc.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zAlloc.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zArcIn.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zBuf.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zBuf.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zCrc.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zCrc.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zCrcOpt.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zDec.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zFile.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zFile.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zStream.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\7zTypes.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Bcj2.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Bcj2.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Bra.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Bra.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Bra86.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\BraIA64.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\CpuArch.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\CpuArch.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Delta.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Delta.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\DllSecur.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\DllSecur.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Lzma2Dec.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\Lzma2Dec.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzmaDec.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=..\..\LzmaDec.h\r
-# End Source File\r
-# End Group\r
-# Begin Group "Spec"\r
-\r
-# PROP Default_Filter ""\r
-# Begin Source File\r
-\r
-SOURCE=.\Precomp.c\r
-# ADD CPP /Yc"Precomp.h"\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\Precomp.h\r
-# End Source File\r
-# End Group\r
-# Begin Source File\r
-\r
-SOURCE=.\SfxSetup.c\r
-# End Source File\r
-# End Target\r
-# End Project\r
diff --git a/deps/lzma-16.04/C/Util/SfxSetup/SfxSetup.dsw b/deps/lzma-16.04/C/Util/SfxSetup/SfxSetup.dsw
deleted file mode 100644 (file)
index 128fcdd..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00\r
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r
-\r
-###############################################################################\r
-\r
-Project: "SfxSetup"=.\SfxSetup.dsp - Package Owner=<4>\r
-\r
-Package=<5>\r
-{{{\r
-}}}\r
-\r
-Package=<4>\r
-{{{\r
-}}}\r
-\r
-###############################################################################\r
-\r
-Global:\r
-\r
-Package=<5>\r
-{{{\r
-}}}\r
-\r
-Package=<3>\r
-{{{\r
-}}}\r
-\r
-###############################################################################\r
-\r
diff --git a/deps/lzma-16.04/C/Util/SfxSetup/makefile b/deps/lzma-16.04/C/Util/SfxSetup/makefile
deleted file mode 100644 (file)
index 6985944..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-PROG = 7zS2.sfx\r
-\r
-C_OBJS = \\r
-  $O\7zAlloc.obj \\r
-  $O\7zArcIn.obj \\r
-  $O\7zBuf.obj \\r
-  $O\7zBuf2.obj \\r
-  $O\7zCrc.obj \\r
-  $O\7zCrcOpt.obj \\r
-  $O\7zFile.obj \\r
-  $O\7zDec.obj \\r
-  $O\7zStream.obj \\r
-  $O\Bcj2.obj \\r
-  $O\Bra.obj \\r
-  $O\Bra86.obj \\r
-  $O\BraIA64.obj \\r
-  $O\CpuArch.obj \\r
-  $O\Delta.obj \\r
-  $O\DllSecur.obj \\r
-  $O\Lzma2Dec.obj \\r
-  $O\LzmaDec.obj \\r
-\r
-7Z_OBJS = \\r
-  $O\SfxSetup.obj \\r
-\r
-OBJS = \\r
-  $(7Z_OBJS) \\r
-  $(C_OBJS) \\r
-  $O\resource.res\r
-\r
-!include "../../../CPP/Build.mak"\r
-\r
-$(7Z_OBJS): $(*B).c\r
-       $(COMPL_O1)\r
-$(C_OBJS): ../../$(*B).c\r
-       $(COMPL_O1)\r
diff --git a/deps/lzma-16.04/C/Util/SfxSetup/makefile_con b/deps/lzma-16.04/C/Util/SfxSetup/makefile_con
deleted file mode 100644 (file)
index cb2c1a4..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-PROG = 7zS2con.sfx\r
-CFLAGS = $(CFLAGS) -D_CONSOLE\r
-\r
-C_OBJS = \\r
-  $O\7zAlloc.obj \\r
-  $O\7zArcIn.obj \\r
-  $O\7zBuf.obj \\r
-  $O\7zBuf2.obj \\r
-  $O\7zCrc.obj \\r
-  $O\7zCrcOpt.obj \\r
-  $O\7zFile.obj \\r
-  $O\7zDec.obj \\r
-  $O\7zStream.obj \\r
-  $O\Bcj2.obj \\r
-  $O\Bra.obj \\r
-  $O\Bra86.obj \\r
-  $O\BraIA64.obj \\r
-  $O\CpuArch.obj \\r
-  $O\Delta.obj \\r
-  $O\DllSecur.obj \\r
-  $O\Lzma2Dec.obj \\r
-  $O\LzmaDec.obj \\r
-\r
-7Z_OBJS = \\r
-  $O\SfxSetup.obj \\r
-\r
-OBJS = \\r
-  $(7Z_OBJS) \\r
-  $(C_OBJS) \\r
-  $O\resource.res\r
-\r
-!include "../../../CPP/Build.mak"\r
-\r
-$(7Z_OBJS): $(*B).c\r
-       $(COMPL_O1)\r
-$(C_OBJS): ../../$(*B).c\r
-       $(COMPL_O1)\r
diff --git a/deps/lzma-16.04/C/Util/SfxSetup/resource.rc b/deps/lzma-16.04/C/Util/SfxSetup/resource.rc
deleted file mode 100644 (file)
index 64f4e2c..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "../../7zVersion.rc"\r
-\r
-MY_VERSION_INFO_APP("7z Setup SFX small", "7zS2.sfx")\r
-\r
-1  ICON "setup.ico"\r
diff --git a/deps/lzma-16.04/C/Util/SfxSetup/setup.ico b/deps/lzma-16.04/C/Util/SfxSetup/setup.ico
deleted file mode 100644 (file)
index dbb6ca8..0000000
Binary files a/deps/lzma-16.04/C/Util/SfxSetup/setup.ico and /dev/null differ
diff --git a/deps/lzma-16.04/C/Xz.c b/deps/lzma-16.04/C/Xz.c
deleted file mode 100644 (file)
index 92144db..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Xz.c - Xz\r
-2015-05-01 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "7zCrc.h"\r
-#include "CpuArch.h"\r
-#include "Xz.h"\r
-#include "XzCrc64.h"\r
-\r
-const Byte XZ_SIG[XZ_SIG_SIZE] = { 0xFD, '7', 'z', 'X', 'Z', 0 };\r
-const Byte XZ_FOOTER_SIG[XZ_FOOTER_SIG_SIZE] = { 'Y', 'Z' };\r
-\r
-unsigned Xz_WriteVarInt(Byte *buf, UInt64 v)\r
-{\r
-  unsigned i = 0;\r
-  do\r
-  {\r
-    buf[i++] = (Byte)((v & 0x7F) | 0x80);\r
-    v >>= 7;\r
-  }\r
-  while (v != 0);\r
-  buf[i - 1] &= 0x7F;\r
-  return i;\r
-}\r
-\r
-void Xz_Construct(CXzStream *p)\r
-{\r
-  p->numBlocks = p->numBlocksAllocated = 0;\r
-  p->blocks = 0;\r
-  p->flags = 0;\r
-}\r
-\r
-void Xz_Free(CXzStream *p, ISzAlloc *alloc)\r
-{\r
-  alloc->Free(alloc, p->blocks);\r
-  p->numBlocks = p->numBlocksAllocated = 0;\r
-  p->blocks = 0;\r
-}\r
-\r
-unsigned XzFlags_GetCheckSize(CXzStreamFlags f)\r
-{\r
-  unsigned t = XzFlags_GetCheckType(f);\r
-  return (t == 0) ? 0 : (4 << ((t - 1) / 3));\r
-}\r
-\r
-void XzCheck_Init(CXzCheck *p, unsigned mode)\r
-{\r
-  p->mode = mode;\r
-  switch (mode)\r
-  {\r
-    case XZ_CHECK_CRC32: p->crc = CRC_INIT_VAL; break;\r
-    case XZ_CHECK_CRC64: p->crc64 = CRC64_INIT_VAL; break;\r
-    case XZ_CHECK_SHA256: Sha256_Init(&p->sha); break;\r
-  }\r
-}\r
-\r
-void XzCheck_Update(CXzCheck *p, const void *data, size_t size)\r
-{\r
-  switch (p->mode)\r
-  {\r
-    case XZ_CHECK_CRC32: p->crc = CrcUpdate(p->crc, data, size); break;\r
-    case XZ_CHECK_CRC64: p->crc64 = Crc64Update(p->crc64, data, size); break;\r
-    case XZ_CHECK_SHA256: Sha256_Update(&p->sha, (const Byte *)data, size); break;\r
-  }\r
-}\r
-\r
-int XzCheck_Final(CXzCheck *p, Byte *digest)\r
-{\r
-  switch (p->mode)\r
-  {\r
-    case XZ_CHECK_CRC32:\r
-      SetUi32(digest, CRC_GET_DIGEST(p->crc));\r
-      break;\r
-    case XZ_CHECK_CRC64:\r
-    {\r
-      int i;\r
-      UInt64 v = CRC64_GET_DIGEST(p->crc64);\r
-      for (i = 0; i < 8; i++, v >>= 8)\r
-        digest[i] = (Byte)(v & 0xFF);\r
-      break;\r
-    }\r
-    case XZ_CHECK_SHA256:\r
-      Sha256_Final(&p->sha, digest);\r
-      break;\r
-    default:\r
-      return 0;\r
-  }\r
-  return 1;\r
-}\r
diff --git a/deps/lzma-16.04/C/Xz.h b/deps/lzma-16.04/C/Xz.h
deleted file mode 100644 (file)
index 6937bea..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-/* Xz.h - Xz interface\r
-2015-05-01 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __XZ_H\r
-#define __XZ_H\r
-\r
-#include "Sha256.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-#define XZ_ID_Subblock 1\r
-#define XZ_ID_Delta 3\r
-#define XZ_ID_X86 4\r
-#define XZ_ID_PPC 5\r
-#define XZ_ID_IA64 6\r
-#define XZ_ID_ARM 7\r
-#define XZ_ID_ARMT 8\r
-#define XZ_ID_SPARC 9\r
-#define XZ_ID_LZMA2 0x21\r
-\r
-unsigned Xz_ReadVarInt(const Byte *p, size_t maxSize, UInt64 *value);\r
-unsigned Xz_WriteVarInt(Byte *buf, UInt64 v);\r
-\r
-/* ---------- xz block ---------- */\r
-\r
-#define XZ_BLOCK_HEADER_SIZE_MAX 1024\r
-\r
-#define XZ_NUM_FILTERS_MAX 4\r
-#define XZ_BF_NUM_FILTERS_MASK 3\r
-#define XZ_BF_PACK_SIZE (1 << 6)\r
-#define XZ_BF_UNPACK_SIZE (1 << 7)\r
-\r
-#define XZ_FILTER_PROPS_SIZE_MAX 20\r
-\r
-typedef struct\r
-{\r
-  UInt64 id;\r
-  UInt32 propsSize;\r
-  Byte props[XZ_FILTER_PROPS_SIZE_MAX];\r
-} CXzFilter;\r
-\r
-typedef struct\r
-{\r
-  UInt64 packSize;\r
-  UInt64 unpackSize;\r
-  Byte flags;\r
-  CXzFilter filters[XZ_NUM_FILTERS_MAX];\r
-} CXzBlock;\r
-\r
-#define XzBlock_GetNumFilters(p) (((p)->flags & XZ_BF_NUM_FILTERS_MASK) + 1)\r
-#define XzBlock_HasPackSize(p)   (((p)->flags & XZ_BF_PACK_SIZE) != 0)\r
-#define XzBlock_HasUnpackSize(p) (((p)->flags & XZ_BF_UNPACK_SIZE) != 0)\r
-\r
-SRes XzBlock_Parse(CXzBlock *p, const Byte *header);\r
-SRes XzBlock_ReadHeader(CXzBlock *p, ISeqInStream *inStream, Bool *isIndex, UInt32 *headerSizeRes);\r
-\r
-/* ---------- xz stream ---------- */\r
-\r
-#define XZ_SIG_SIZE 6\r
-#define XZ_FOOTER_SIG_SIZE 2\r
-\r
-extern const Byte XZ_SIG[XZ_SIG_SIZE];\r
-extern const Byte XZ_FOOTER_SIG[XZ_FOOTER_SIG_SIZE];\r
-\r
-#define XZ_STREAM_FLAGS_SIZE 2\r
-#define XZ_STREAM_CRC_SIZE 4\r
-\r
-#define XZ_STREAM_HEADER_SIZE (XZ_SIG_SIZE + XZ_STREAM_FLAGS_SIZE + XZ_STREAM_CRC_SIZE)\r
-#define XZ_STREAM_FOOTER_SIZE (XZ_FOOTER_SIG_SIZE + XZ_STREAM_FLAGS_SIZE + XZ_STREAM_CRC_SIZE + 4)\r
-\r
-#define XZ_CHECK_MASK 0xF\r
-#define XZ_CHECK_NO 0\r
-#define XZ_CHECK_CRC32 1\r
-#define XZ_CHECK_CRC64 4\r
-#define XZ_CHECK_SHA256 10\r
-\r
-typedef struct\r
-{\r
-  unsigned mode;\r
-  UInt32 crc;\r
-  UInt64 crc64;\r
-  CSha256 sha;\r
-} CXzCheck;\r
-\r
-void XzCheck_Init(CXzCheck *p, unsigned mode);\r
-void XzCheck_Update(CXzCheck *p, const void *data, size_t size);\r
-int XzCheck_Final(CXzCheck *p, Byte *digest);\r
-\r
-typedef UInt16 CXzStreamFlags;\r
-\r
-#define XzFlags_IsSupported(f) ((f) <= XZ_CHECK_MASK)\r
-#define XzFlags_GetCheckType(f) ((f) & XZ_CHECK_MASK)\r
-#define XzFlags_HasDataCrc32(f) (Xz_GetCheckType(f) == XZ_CHECK_CRC32)\r
-unsigned XzFlags_GetCheckSize(CXzStreamFlags f);\r
-\r
-SRes Xz_ParseHeader(CXzStreamFlags *p, const Byte *buf);\r
-SRes Xz_ReadHeader(CXzStreamFlags *p, ISeqInStream *inStream);\r
-\r
-typedef struct\r
-{\r
-  UInt64 unpackSize;\r
-  UInt64 totalSize;\r
-} CXzBlockSizes;\r
-\r
-typedef struct\r
-{\r
-  CXzStreamFlags flags;\r
-  size_t numBlocks;\r
-  size_t numBlocksAllocated;\r
-  CXzBlockSizes *blocks;\r
-  UInt64 startOffset;\r
-} CXzStream;\r
-\r
-void Xz_Construct(CXzStream *p);\r
-void Xz_Free(CXzStream *p, ISzAlloc *alloc);\r
-\r
-#define XZ_SIZE_OVERFLOW ((UInt64)(Int64)-1)\r
-\r
-UInt64 Xz_GetUnpackSize(const CXzStream *p);\r
-UInt64 Xz_GetPackSize(const CXzStream *p);\r
-\r
-typedef struct\r
-{\r
-  size_t num;\r
-  size_t numAllocated;\r
-  CXzStream *streams;\r
-} CXzs;\r
-\r
-void Xzs_Construct(CXzs *p);\r
-void Xzs_Free(CXzs *p, ISzAlloc *alloc);\r
-SRes Xzs_ReadBackward(CXzs *p, ILookInStream *inStream, Int64 *startOffset, ICompressProgress *progress, ISzAlloc *alloc);\r
-\r
-UInt64 Xzs_GetNumBlocks(const CXzs *p);\r
-UInt64 Xzs_GetUnpackSize(const CXzs *p);\r
-\r
-typedef enum\r
-{\r
-  CODER_STATUS_NOT_SPECIFIED,               /* use main error code instead */\r
-  CODER_STATUS_FINISHED_WITH_MARK,          /* stream was finished with end mark. */\r
-  CODER_STATUS_NOT_FINISHED,                /* stream was not finished */\r
-  CODER_STATUS_NEEDS_MORE_INPUT             /* you must provide more input bytes */\r
-} ECoderStatus;\r
-\r
-typedef enum\r
-{\r
-  CODER_FINISH_ANY,   /* finish at any point */\r
-  CODER_FINISH_END    /* block must be finished at the end */\r
-} ECoderFinishMode;\r
-\r
-typedef struct _IStateCoder\r
-{\r
-  void *p;\r
-  void (*Free)(void *p, ISzAlloc *alloc);\r
-  SRes (*SetProps)(void *p, const Byte *props, size_t propSize, ISzAlloc *alloc);\r
-  void (*Init)(void *p);\r
-  SRes (*Code)(void *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,\r
-      int srcWasFinished, ECoderFinishMode finishMode, int *wasFinished);\r
-} IStateCoder;\r
-\r
-#define MIXCODER_NUM_FILTERS_MAX 4\r
-\r
-typedef struct\r
-{\r
-  ISzAlloc *alloc;\r
-  Byte *buf;\r
-  unsigned numCoders;\r
-  int finished[MIXCODER_NUM_FILTERS_MAX - 1];\r
-  size_t pos[MIXCODER_NUM_FILTERS_MAX - 1];\r
-  size_t size[MIXCODER_NUM_FILTERS_MAX - 1];\r
-  UInt64 ids[MIXCODER_NUM_FILTERS_MAX];\r
-  IStateCoder coders[MIXCODER_NUM_FILTERS_MAX];\r
-} CMixCoder;\r
-\r
-void MixCoder_Construct(CMixCoder *p, ISzAlloc *alloc);\r
-void MixCoder_Free(CMixCoder *p);\r
-void MixCoder_Init(CMixCoder *p);\r
-SRes MixCoder_SetFromMethod(CMixCoder *p, unsigned coderIndex, UInt64 methodId);\r
-SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen,\r
-    const Byte *src, SizeT *srcLen, int srcWasFinished,\r
-    ECoderFinishMode finishMode, ECoderStatus *status);\r
-\r
-typedef enum\r
-{\r
-  XZ_STATE_STREAM_HEADER,\r
-  XZ_STATE_STREAM_INDEX,\r
-  XZ_STATE_STREAM_INDEX_CRC,\r
-  XZ_STATE_STREAM_FOOTER,\r
-  XZ_STATE_STREAM_PADDING,\r
-  XZ_STATE_BLOCK_HEADER,\r
-  XZ_STATE_BLOCK,\r
-  XZ_STATE_BLOCK_FOOTER\r
-} EXzState;\r
-\r
-typedef struct\r
-{\r
-  EXzState state;\r
-  UInt32 pos;\r
-  unsigned alignPos;\r
-  unsigned indexPreSize;\r
-\r
-  CXzStreamFlags streamFlags;\r
-  \r
-  UInt32 blockHeaderSize;\r
-  UInt64 packSize;\r
-  UInt64 unpackSize;\r
-\r
-  UInt64 numBlocks;\r
-  UInt64 indexSize;\r
-  UInt64 indexPos;\r
-  UInt64 padSize;\r
-\r
-  UInt64 numStartedStreams;\r
-  UInt64 numFinishedStreams;\r
-  UInt64 numTotalBlocks;\r
-\r
-  UInt32 crc;\r
-  CMixCoder decoder;\r
-  CXzBlock block;\r
-  CXzCheck check;\r
-  CSha256 sha;\r
-  Byte shaDigest[SHA256_DIGEST_SIZE];\r
-  Byte buf[XZ_BLOCK_HEADER_SIZE_MAX];\r
-} CXzUnpacker;\r
-\r
-void XzUnpacker_Construct(CXzUnpacker *p, ISzAlloc *alloc);\r
-void XzUnpacker_Init(CXzUnpacker *p);\r
-void XzUnpacker_Free(CXzUnpacker *p);\r
-\r
-/*\r
-finishMode:\r
-  It has meaning only if the decoding reaches output limit (*destLen).\r
-  CODER_FINISH_ANY - use smallest number of input bytes\r
-  CODER_FINISH_END - read EndOfStream marker after decoding\r
-\r
-Returns:\r
-  SZ_OK\r
-    status:\r
-      CODER_STATUS_NOT_FINISHED,\r
-      CODER_STATUS_NEEDS_MORE_INPUT - maybe there are more xz streams,\r
-                                      call XzUnpacker_IsStreamWasFinished to check that current stream was finished\r
-  SZ_ERROR_MEM  - Memory allocation error\r
-  SZ_ERROR_DATA - Data error\r
-  SZ_ERROR_UNSUPPORTED - Unsupported method or method properties\r
-  SZ_ERROR_CRC  - CRC error\r
-  // SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).\r
-\r
-  SZ_ERROR_NO_ARCHIVE - the error with xz Stream Header with one of the following reasons:\r
-     - xz Stream Signature failure\r
-     - CRC32 of xz Stream Header is failed\r
-     - The size of Stream padding is not multiple of four bytes.\r
-    It's possible to get that error, if xz stream was finished and the stream\r
-    contains some another data. In that case you can call XzUnpacker_GetExtraSize()\r
-    function to get real size of xz stream.\r
-*/\r
-\r
-\r
-SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,\r
-    const Byte *src, SizeT *srcLen, ECoderFinishMode finishMode,\r
-    ECoderStatus *status);\r
-\r
-Bool XzUnpacker_IsStreamWasFinished(CXzUnpacker *p);\r
-\r
-/*\r
-Call XzUnpacker_GetExtraSize after XzUnpacker_Code function to detect real size of\r
-xz stream in two cases:\r
-XzUnpacker_Code() returns:\r
-  res == SZ_OK && status == CODER_STATUS_NEEDS_MORE_INPUT\r
-  res == SZ_ERROR_NO_ARCHIVE\r
-*/\r
-\r
-UInt64 XzUnpacker_GetExtraSize(CXzUnpacker *p);\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/XzCrc64.c b/deps/lzma-16.04/C/XzCrc64.c
deleted file mode 100644 (file)
index bd0cf5a..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/* XzCrc64.c -- CRC64 calculation\r
-2015-03-01 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "XzCrc64.h"\r
-#include "CpuArch.h"\r
-\r
-#define kCrc64Poly UINT64_CONST(0xC96C5795D7870F42)\r
-\r
-#ifdef MY_CPU_LE\r
-  #define CRC_NUM_TABLES 4\r
-#else\r
-  #define CRC_NUM_TABLES 5\r
-  #define CRC_UINT64_SWAP(v) \\r
-      ((v >> 56) \\r
-    | ((v >> 40) & ((UInt64)0xFF <<  8)) \\r
-    | ((v >> 24) & ((UInt64)0xFF << 16)) \\r
-    | ((v >>  8) & ((UInt64)0xFF << 24)) \\r
-    | ((v <<  8) & ((UInt64)0xFF << 32)) \\r
-    | ((v << 24) & ((UInt64)0xFF << 40)) \\r
-    | ((v << 40) & ((UInt64)0xFF << 48)) \\r
-    | ((v << 56)))\r
-\r
-  UInt64 MY_FAST_CALL XzCrc64UpdateT1_BeT4(UInt64 v, const void *data, size_t size, const UInt64 *table);\r
-#endif\r
-\r
-#ifndef MY_CPU_BE\r
-  UInt64 MY_FAST_CALL XzCrc64UpdateT4(UInt64 v, const void *data, size_t size, const UInt64 *table);\r
-#endif\r
-\r
-typedef UInt64 (MY_FAST_CALL *CRC_FUNC)(UInt64 v, const void *data, size_t size, const UInt64 *table);\r
-\r
-static CRC_FUNC g_Crc64Update;\r
-UInt64 g_Crc64Table[256 * CRC_NUM_TABLES];\r
-\r
-UInt64 MY_FAST_CALL Crc64Update(UInt64 v, const void *data, size_t size)\r
-{\r
-  return g_Crc64Update(v, data, size, g_Crc64Table);\r
-}\r
-\r
-UInt64 MY_FAST_CALL Crc64Calc(const void *data, size_t size)\r
-{\r
-  return g_Crc64Update(CRC64_INIT_VAL, data, size, g_Crc64Table) ^ CRC64_INIT_VAL;\r
-}\r
-\r
-void MY_FAST_CALL Crc64GenerateTable()\r
-{\r
-  UInt32 i;\r
-  for (i = 0; i < 256; i++)\r
-  {\r
-    UInt64 r = i;\r
-    unsigned j;\r
-    for (j = 0; j < 8; j++)\r
-      r = (r >> 1) ^ (kCrc64Poly & ~((r & 1) - 1));\r
-    g_Crc64Table[i] = r;\r
-  }\r
-  for (; i < 256 * CRC_NUM_TABLES; i++)\r
-  {\r
-    UInt64 r = g_Crc64Table[i - 256];\r
-    g_Crc64Table[i] = g_Crc64Table[r & 0xFF] ^ (r >> 8);\r
-  }\r
-  \r
-  #ifdef MY_CPU_LE\r
-\r
-  g_Crc64Update = XzCrc64UpdateT4;\r
-\r
-  #else\r
-  {\r
-    #ifndef MY_CPU_BE\r
-    UInt32 k = 1;\r
-    if (*(const Byte *)&k == 1)\r
-      g_Crc64Update = XzCrc64UpdateT4;\r
-    else\r
-    #endif\r
-    {\r
-      for (i = 256 * CRC_NUM_TABLES - 1; i >= 256; i--)\r
-      {\r
-        UInt64 x = g_Crc64Table[i - 256];\r
-        g_Crc64Table[i] = CRC_UINT64_SWAP(x);\r
-      }\r
-      g_Crc64Update = XzCrc64UpdateT1_BeT4;\r
-    }\r
-  }\r
-  #endif\r
-}\r
diff --git a/deps/lzma-16.04/C/XzCrc64.h b/deps/lzma-16.04/C/XzCrc64.h
deleted file mode 100644 (file)
index 71b10d5..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/* XzCrc64.h -- CRC64 calculation\r
-2013-01-18 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __XZ_CRC64_H\r
-#define __XZ_CRC64_H\r
-\r
-#include <stddef.h>\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-extern UInt64 g_Crc64Table[];\r
-\r
-void MY_FAST_CALL Crc64GenerateTable(void);\r
-\r
-#define CRC64_INIT_VAL UINT64_CONST(0xFFFFFFFFFFFFFFFF)\r
-#define CRC64_GET_DIGEST(crc) ((crc) ^ CRC64_INIT_VAL)\r
-#define CRC64_UPDATE_BYTE(crc, b) (g_Crc64Table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))\r
-\r
-UInt64 MY_FAST_CALL Crc64Update(UInt64 crc, const void *data, size_t size);\r
-UInt64 MY_FAST_CALL Crc64Calc(const void *data, size_t size);\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/XzCrc64Opt.c b/deps/lzma-16.04/C/XzCrc64Opt.c
deleted file mode 100644 (file)
index 97d086e..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/* XzCrc64Opt.c -- CRC64 calculation\r
-2015-03-01 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include "CpuArch.h"\r
-\r
-#ifndef MY_CPU_BE\r
-\r
-#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))\r
-\r
-UInt64 MY_FAST_CALL XzCrc64UpdateT4(UInt64 v, const void *data, size_t size, const UInt64 *table)\r
-{\r
-  const Byte *p = (const Byte *)data;\r
-  for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++)\r
-    v = CRC_UPDATE_BYTE_2(v, *p);\r
-  for (; size >= 4; size -= 4, p += 4)\r
-  {\r
-    UInt32 d = (UInt32)v ^ *(const UInt32 *)p;\r
-    v = (v >> 32)\r
-        ^ table[0x300 + ((d      ) & 0xFF)]\r
-        ^ table[0x200 + ((d >>  8) & 0xFF)]\r
-        ^ table[0x100 + ((d >> 16) & 0xFF)]\r
-        ^ table[0x000 + ((d >> 24))];\r
-  }\r
-  for (; size > 0; size--, p++)\r
-    v = CRC_UPDATE_BYTE_2(v, *p);\r
-  return v;\r
-}\r
-\r
-#endif\r
-\r
-\r
-#ifndef MY_CPU_LE\r
-\r
-#define CRC_UINT64_SWAP(v) \\r
-      ((v >> 56) \\r
-    | ((v >> 40) & ((UInt64)0xFF <<  8)) \\r
-    | ((v >> 24) & ((UInt64)0xFF << 16)) \\r
-    | ((v >>  8) & ((UInt64)0xFF << 24)) \\r
-    | ((v <<  8) & ((UInt64)0xFF << 32)) \\r
-    | ((v << 24) & ((UInt64)0xFF << 40)) \\r
-    | ((v << 40) & ((UInt64)0xFF << 48)) \\r
-    | ((v << 56)))\r
-\r
-#define CRC_UPDATE_BYTE_2_BE(crc, b) (table[(Byte)((crc) >> 56) ^ (b)] ^ ((crc) << 8))\r
-\r
-UInt64 MY_FAST_CALL XzCrc64UpdateT1_BeT4(UInt64 v, const void *data, size_t size, const UInt64 *table)\r
-{\r
-  const Byte *p = (const Byte *)data;\r
-  table += 0x100;\r
-  v = CRC_UINT64_SWAP(v);\r
-  for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++)\r
-    v = CRC_UPDATE_BYTE_2_BE(v, *p);\r
-  for (; size >= 4; size -= 4, p += 4)\r
-  {\r
-    UInt32 d = (UInt32)(v >> 32) ^ *(const UInt32 *)p;\r
-    v = (v << 32)\r
-        ^ table[0x000 + ((d      ) & 0xFF)]\r
-        ^ table[0x100 + ((d >>  8) & 0xFF)]\r
-        ^ table[0x200 + ((d >> 16) & 0xFF)]\r
-        ^ table[0x300 + ((d >> 24))];\r
-  }\r
-  for (; size > 0; size--, p++)\r
-    v = CRC_UPDATE_BYTE_2_BE(v, *p);\r
-  return CRC_UINT64_SWAP(v);\r
-}\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/XzDec.c b/deps/lzma-16.04/C/XzDec.c
deleted file mode 100644 (file)
index 29831b0..0000000
+++ /dev/null
@@ -1,913 +0,0 @@
-/* XzDec.c -- Xz Decode\r
-2015-11-09 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-/* #define XZ_DUMP */\r
-\r
-#ifdef XZ_DUMP\r
-#include <stdio.h>\r
-#endif\r
-\r
-#include <stdlib.h>\r
-#include <string.h>\r
-\r
-#include "7zCrc.h"\r
-#include "Alloc.h"\r
-#include "Bra.h"\r
-#include "CpuArch.h"\r
-#include "Delta.h"\r
-#include "Lzma2Dec.h"\r
-\r
-#ifdef USE_SUBBLOCK\r
-#include "Bcj3Dec.c"\r
-#include "SbDec.c"\r
-#endif\r
-\r
-#include "Xz.h"\r
-\r
-#define XZ_CHECK_SIZE_MAX 64\r
-\r
-#define CODER_BUF_SIZE (1 << 17)\r
-\r
-unsigned Xz_ReadVarInt(const Byte *p, size_t maxSize, UInt64 *value)\r
-{\r
-  unsigned i, limit;\r
-  *value = 0;\r
-  limit = (maxSize > 9) ? 9 : (unsigned)maxSize;\r
-\r
-  for (i = 0; i < limit;)\r
-  {\r
-    Byte b = p[i];\r
-    *value |= (UInt64)(b & 0x7F) << (7 * i++);\r
-    if ((b & 0x80) == 0)\r
-      return (b == 0 && i != 1) ? 0 : i;\r
-  }\r
-  return 0;\r
-}\r
-\r
-/* ---------- BraState ---------- */\r
-\r
-#define BRA_BUF_SIZE (1 << 14)\r
-\r
-typedef struct\r
-{\r
-  size_t bufPos;\r
-  size_t bufConv;\r
-  size_t bufTotal;\r
-\r
-  UInt32 methodId;\r
-  int encodeMode;\r
-  UInt32 delta;\r
-  UInt32 ip;\r
-  UInt32 x86State;\r
-  Byte deltaState[DELTA_STATE_SIZE];\r
-\r
-  Byte buf[BRA_BUF_SIZE];\r
-} CBraState;\r
-\r
-static void BraState_Free(void *pp, ISzAlloc *alloc)\r
-{\r
-  alloc->Free(alloc, pp);\r
-}\r
-\r
-static SRes BraState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAlloc *alloc)\r
-{\r
-  CBraState *p = ((CBraState *)pp);\r
-  UNUSED_VAR(alloc);\r
-  p->ip = 0;\r
-  if (p->methodId == XZ_ID_Delta)\r
-  {\r
-    if (propSize != 1)\r
-      return SZ_ERROR_UNSUPPORTED;\r
-    p->delta = (unsigned)props[0] + 1;\r
-  }\r
-  else\r
-  {\r
-    if (propSize == 4)\r
-    {\r
-      UInt32 v = GetUi32(props);\r
-      switch (p->methodId)\r
-      {\r
-        case XZ_ID_PPC:\r
-        case XZ_ID_ARM:\r
-        case XZ_ID_SPARC:\r
-          if ((v & 3) != 0)\r
-            return SZ_ERROR_UNSUPPORTED;\r
-          break;\r
-        case XZ_ID_ARMT:\r
-          if ((v & 1) != 0)\r
-            return SZ_ERROR_UNSUPPORTED;\r
-          break;\r
-        case XZ_ID_IA64:\r
-          if ((v & 0xF) != 0)\r
-            return SZ_ERROR_UNSUPPORTED;\r
-          break;\r
-      }\r
-      p->ip = v;\r
-    }\r
-    else if (propSize != 0)\r
-      return SZ_ERROR_UNSUPPORTED;\r
-  }\r
-  return SZ_OK;\r
-}\r
-\r
-static void BraState_Init(void *pp)\r
-{\r
-  CBraState *p = ((CBraState *)pp);\r
-  p->bufPos = p->bufConv = p->bufTotal = 0;\r
-  x86_Convert_Init(p->x86State);\r
-  if (p->methodId == XZ_ID_Delta)\r
-    Delta_Init(p->deltaState);\r
-}\r
-\r
-#define CASE_BRA_CONV(isa) case XZ_ID_ ## isa: p->bufConv = isa ## _Convert(p->buf, p->bufTotal, p->ip, p->encodeMode); break;\r
-\r
-static SRes BraState_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,\r
-    int srcWasFinished, ECoderFinishMode finishMode, int *wasFinished)\r
-{\r
-  CBraState *p = ((CBraState *)pp);\r
-  SizeT destLenOrig = *destLen;\r
-  SizeT srcLenOrig = *srcLen;\r
-  UNUSED_VAR(finishMode);\r
-  *destLen = 0;\r
-  *srcLen = 0;\r
-  *wasFinished = 0;\r
-  while (destLenOrig > 0)\r
-  {\r
-    if (p->bufPos != p->bufConv)\r
-    {\r
-      size_t curSize = p->bufConv - p->bufPos;\r
-      if (curSize > destLenOrig)\r
-        curSize = destLenOrig;\r
-      memcpy(dest, p->buf + p->bufPos, curSize);\r
-      p->bufPos += curSize;\r
-      *destLen += curSize;\r
-      dest += curSize;\r
-      destLenOrig -= curSize;\r
-      continue;\r
-    }\r
-    p->bufTotal -= p->bufPos;\r
-    memmove(p->buf, p->buf + p->bufPos, p->bufTotal);\r
-    p->bufPos = 0;\r
-    p->bufConv = 0;\r
-    {\r
-      size_t curSize = BRA_BUF_SIZE - p->bufTotal;\r
-      if (curSize > srcLenOrig)\r
-        curSize = srcLenOrig;\r
-      memcpy(p->buf + p->bufTotal, src, curSize);\r
-      *srcLen += curSize;\r
-      src += curSize;\r
-      srcLenOrig -= curSize;\r
-      p->bufTotal += curSize;\r
-    }\r
-    if (p->bufTotal == 0)\r
-      break;\r
-    switch (p->methodId)\r
-    {\r
-      case XZ_ID_Delta:\r
-        if (p->encodeMode)\r
-          Delta_Encode(p->deltaState, p->delta, p->buf, p->bufTotal);\r
-        else\r
-          Delta_Decode(p->deltaState, p->delta, p->buf, p->bufTotal);\r
-        p->bufConv = p->bufTotal;\r
-        break;\r
-      case XZ_ID_X86:\r
-        p->bufConv = x86_Convert(p->buf, p->bufTotal, p->ip, &p->x86State, p->encodeMode);\r
-        break;\r
-      CASE_BRA_CONV(PPC)\r
-      CASE_BRA_CONV(IA64)\r
-      CASE_BRA_CONV(ARM)\r
-      CASE_BRA_CONV(ARMT)\r
-      CASE_BRA_CONV(SPARC)\r
-      default:\r
-        return SZ_ERROR_UNSUPPORTED;\r
-    }\r
-    p->ip += (UInt32)p->bufConv;\r
-\r
-    if (p->bufConv == 0)\r
-    {\r
-      if (!srcWasFinished)\r
-        break;\r
-      p->bufConv = p->bufTotal;\r
-    }\r
-  }\r
-  if (p->bufTotal == p->bufPos && srcLenOrig == 0 && srcWasFinished)\r
-    *wasFinished = 1;\r
-  return SZ_OK;\r
-}\r
-\r
-SRes BraState_SetFromMethod(IStateCoder *p, UInt64 id, int encodeMode, ISzAlloc *alloc)\r
-{\r
-  CBraState *decoder;\r
-  if (id != XZ_ID_Delta &&\r
-      id != XZ_ID_X86 &&\r
-      id != XZ_ID_PPC &&\r
-      id != XZ_ID_IA64 &&\r
-      id != XZ_ID_ARM &&\r
-      id != XZ_ID_ARMT &&\r
-      id != XZ_ID_SPARC)\r
-    return SZ_ERROR_UNSUPPORTED;\r
-  p->p = 0;\r
-  decoder = (CBraState *)alloc->Alloc(alloc, sizeof(CBraState));\r
-  if (decoder == 0)\r
-    return SZ_ERROR_MEM;\r
-  decoder->methodId = (UInt32)id;\r
-  decoder->encodeMode = encodeMode;\r
-  p->p = decoder;\r
-  p->Free = BraState_Free;\r
-  p->SetProps = BraState_SetProps;\r
-  p->Init = BraState_Init;\r
-  p->Code = BraState_Code;\r
-  return SZ_OK;\r
-}\r
-\r
-/* ---------- SbState ---------- */\r
-\r
-#ifdef USE_SUBBLOCK\r
-\r
-static void SbState_Free(void *pp, ISzAlloc *alloc)\r
-{\r
-  CSbDec *p = (CSbDec *)pp;\r
-  SbDec_Free(p);\r
-  alloc->Free(alloc, pp);\r
-}\r
-\r
-static SRes SbState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAlloc *alloc)\r
-{\r
-  UNUSED_VAR(pp);\r
-  UNUSED_VAR(props);\r
-  UNUSED_VAR(alloc);\r
-  return (propSize == 0) ? SZ_OK : SZ_ERROR_UNSUPPORTED;\r
-}\r
-\r
-static void SbState_Init(void *pp)\r
-{\r
-  SbDec_Init((CSbDec *)pp);\r
-}\r
-\r
-static SRes SbState_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,\r
-    int srcWasFinished, ECoderFinishMode finishMode, int *wasFinished)\r
-{\r
-  CSbDec *p = (CSbDec *)pp;\r
-  SRes res;\r
-  UNUSED_VAR(srcWasFinished);\r
-  p->dest = dest;\r
-  p->destLen = *destLen;\r
-  p->src = src;\r
-  p->srcLen = *srcLen;\r
-  p->finish = finishMode; /* change it */\r
-  res = SbDec_Decode((CSbDec *)pp);\r
-  *destLen -= p->destLen;\r
-  *srcLen -= p->srcLen;\r
-  *wasFinished = (*destLen == 0 && *srcLen == 0); /* change it */\r
-  return res;\r
-}\r
-\r
-SRes SbState_SetFromMethod(IStateCoder *p, ISzAlloc *alloc)\r
-{\r
-  CSbDec *decoder;\r
-  p->p = 0;\r
-  decoder = alloc->Alloc(alloc, sizeof(CSbDec));\r
-  if (decoder == 0)\r
-    return SZ_ERROR_MEM;\r
-  p->p = decoder;\r
-  p->Free = SbState_Free;\r
-  p->SetProps = SbState_SetProps;\r
-  p->Init = SbState_Init;\r
-  p->Code = SbState_Code;\r
-  SbDec_Construct(decoder);\r
-  SbDec_SetAlloc(decoder, alloc);\r
-  return SZ_OK;\r
-}\r
-#endif\r
-\r
-/* ---------- Lzma2State ---------- */\r
-\r
-static void Lzma2State_Free(void *pp, ISzAlloc *alloc)\r
-{\r
-  Lzma2Dec_Free((CLzma2Dec *)pp, alloc);\r
-  alloc->Free(alloc, pp);\r
-}\r
-\r
-static SRes Lzma2State_SetProps(void *pp, const Byte *props, size_t propSize, ISzAlloc *alloc)\r
-{\r
-  if (propSize != 1)\r
-    return SZ_ERROR_UNSUPPORTED;\r
-  return Lzma2Dec_Allocate((CLzma2Dec *)pp, props[0], alloc);\r
-}\r
-\r
-static void Lzma2State_Init(void *pp)\r
-{\r
-  Lzma2Dec_Init((CLzma2Dec *)pp);\r
-}\r
-\r
-static SRes Lzma2State_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,\r
-    int srcWasFinished, ECoderFinishMode finishMode, int *wasFinished)\r
-{\r
-  ELzmaStatus status;\r
-  /* ELzmaFinishMode fm = (finishMode == LZMA_FINISH_ANY) ? LZMA_FINISH_ANY : LZMA_FINISH_END; */\r
-  SRes res = Lzma2Dec_DecodeToBuf((CLzma2Dec *)pp, dest, destLen, src, srcLen, (ELzmaFinishMode)finishMode, &status);\r
-  UNUSED_VAR(srcWasFinished);\r
-  *wasFinished = (status == LZMA_STATUS_FINISHED_WITH_MARK);\r
-  return res;\r
-}\r
-\r
-static SRes Lzma2State_SetFromMethod(IStateCoder *p, ISzAlloc *alloc)\r
-{\r
-  CLzma2Dec *decoder = (CLzma2Dec *)alloc->Alloc(alloc, sizeof(CLzma2Dec));\r
-  p->p = decoder;\r
-  if (decoder == 0)\r
-    return SZ_ERROR_MEM;\r
-  p->Free = Lzma2State_Free;\r
-  p->SetProps = Lzma2State_SetProps;\r
-  p->Init = Lzma2State_Init;\r
-  p->Code = Lzma2State_Code;\r
-  Lzma2Dec_Construct(decoder);\r
-  return SZ_OK;\r
-}\r
-\r
-\r
-void MixCoder_Construct(CMixCoder *p, ISzAlloc *alloc)\r
-{\r
-  unsigned i;\r
-  p->alloc = alloc;\r
-  p->buf = NULL;\r
-  p->numCoders = 0;\r
-  for (i = 0; i < MIXCODER_NUM_FILTERS_MAX; i++)\r
-    p->coders[i].p = NULL;\r
-}\r
-\r
-void MixCoder_Free(CMixCoder *p)\r
-{\r
-  unsigned i;\r
-  for (i = 0; i < p->numCoders; i++)\r
-  {\r
-    IStateCoder *sc = &p->coders[i];\r
-    if (p->alloc && sc->p)\r
-      sc->Free(sc->p, p->alloc);\r
-  }\r
-  p->numCoders = 0;\r
-  if (p->buf)\r
-  {\r
-    p->alloc->Free(p->alloc, p->buf);\r
-    p->buf = NULL; /* 9.31: the BUG was fixed */\r
-  }\r
-}\r
-\r
-void MixCoder_Init(CMixCoder *p)\r
-{\r
-  unsigned i;\r
-  for (i = 0; i < MIXCODER_NUM_FILTERS_MAX - 1; i++)\r
-  {\r
-    p->size[i] = 0;\r
-    p->pos[i] = 0;\r
-    p->finished[i] = 0;\r
-  }\r
-  for (i = 0; i < p->numCoders; i++)\r
-  {\r
-    IStateCoder *coder = &p->coders[i];\r
-    coder->Init(coder->p);\r
-  }\r
-}\r
-\r
-SRes MixCoder_SetFromMethod(CMixCoder *p, unsigned coderIndex, UInt64 methodId)\r
-{\r
-  IStateCoder *sc = &p->coders[coderIndex];\r
-  p->ids[coderIndex] = methodId;\r
-  switch (methodId)\r
-  {\r
-    case XZ_ID_LZMA2: return Lzma2State_SetFromMethod(sc, p->alloc);\r
-    #ifdef USE_SUBBLOCK\r
-    case XZ_ID_Subblock: return SbState_SetFromMethod(sc, p->alloc);\r
-    #endif\r
-  }\r
-  if (coderIndex == 0)\r
-    return SZ_ERROR_UNSUPPORTED;\r
-  return BraState_SetFromMethod(sc, methodId, 0, p->alloc);\r
-}\r
-\r
-SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen,\r
-    const Byte *src, SizeT *srcLen, int srcWasFinished,\r
-    ECoderFinishMode finishMode, ECoderStatus *status)\r
-{\r
-  SizeT destLenOrig = *destLen;\r
-  SizeT srcLenOrig = *srcLen;\r
-  Bool allFinished = True;\r
-  *destLen = 0;\r
-  *srcLen = 0;\r
-  *status = CODER_STATUS_NOT_FINISHED;\r
-\r
-  if (!p->buf)\r
-  {\r
-    p->buf = (Byte *)p->alloc->Alloc(p->alloc, CODER_BUF_SIZE * (MIXCODER_NUM_FILTERS_MAX - 1));\r
-    if (!p->buf)\r
-      return SZ_ERROR_MEM;\r
-  }\r
-\r
-  if (p->numCoders != 1)\r
-    finishMode = CODER_FINISH_ANY;\r
-\r
-  for (;;)\r
-  {\r
-    Bool processed = False;\r
-    unsigned i;\r
-    /*\r
-    if (p->numCoders == 1 && *destLen == destLenOrig && finishMode == LZMA_FINISH_ANY)\r
-      break;\r
-    */\r
-\r
-    for (i = 0; i < p->numCoders; i++)\r
-    {\r
-      SRes res;\r
-      IStateCoder *coder = &p->coders[i];\r
-      Byte *destCur;\r
-      SizeT destLenCur, srcLenCur;\r
-      const Byte *srcCur;\r
-      int srcFinishedCur;\r
-      int encodingWasFinished;\r
-      \r
-      if (i == 0)\r
-      {\r
-        srcCur = src;\r
-        srcLenCur = srcLenOrig - *srcLen;\r
-        srcFinishedCur = srcWasFinished;\r
-      }\r
-      else\r
-      {\r
-        srcCur = p->buf + (CODER_BUF_SIZE * (i - 1)) + p->pos[i - 1];\r
-        srcLenCur = p->size[i - 1] - p->pos[i - 1];\r
-        srcFinishedCur = p->finished[i - 1];\r
-      }\r
-      \r
-      if (i == p->numCoders - 1)\r
-      {\r
-        destCur = dest;\r
-        destLenCur = destLenOrig - *destLen;\r
-      }\r
-      else\r
-      {\r
-        if (p->pos[i] != p->size[i])\r
-          continue;\r
-        destCur = p->buf + (CODER_BUF_SIZE * i);\r
-        destLenCur = CODER_BUF_SIZE;\r
-      }\r
-      \r
-      res = coder->Code(coder->p, destCur, &destLenCur, srcCur, &srcLenCur, srcFinishedCur, finishMode, &encodingWasFinished);\r
-\r
-      if (!encodingWasFinished)\r
-        allFinished = False;\r
-\r
-      if (i == 0)\r
-      {\r
-        *srcLen += srcLenCur;\r
-        src += srcLenCur;\r
-      }\r
-      else\r
-      {\r
-        p->pos[i - 1] += srcLenCur;\r
-      }\r
-\r
-      if (i == p->numCoders - 1)\r
-      {\r
-        *destLen += destLenCur;\r
-        dest += destLenCur;\r
-      }\r
-      else\r
-      {\r
-        p->size[i] = destLenCur;\r
-        p->pos[i] = 0;\r
-        p->finished[i] = encodingWasFinished;\r
-      }\r
-      \r
-      if (res != SZ_OK)\r
-        return res;\r
-\r
-      if (destLenCur != 0 || srcLenCur != 0)\r
-        processed = True;\r
-    }\r
-    if (!processed)\r
-      break;\r
-  }\r
-  if (allFinished)\r
-    *status = CODER_STATUS_FINISHED_WITH_MARK;\r
-  return SZ_OK;\r
-}\r
-\r
-SRes Xz_ParseHeader(CXzStreamFlags *p, const Byte *buf)\r
-{\r
-  *p = (CXzStreamFlags)GetBe16(buf + XZ_SIG_SIZE);\r
-  if (CrcCalc(buf + XZ_SIG_SIZE, XZ_STREAM_FLAGS_SIZE) !=\r
-      GetUi32(buf + XZ_SIG_SIZE + XZ_STREAM_FLAGS_SIZE))\r
-    return SZ_ERROR_NO_ARCHIVE;\r
-  return XzFlags_IsSupported(*p) ? SZ_OK : SZ_ERROR_UNSUPPORTED;\r
-}\r
-\r
-static Bool Xz_CheckFooter(CXzStreamFlags flags, UInt64 indexSize, const Byte *buf)\r
-{\r
-  return\r
-      indexSize == (((UInt64)GetUi32(buf + 4) + 1) << 2) &&\r
-      (GetUi32(buf) == CrcCalc(buf + 4, 6) &&\r
-      flags == GetBe16(buf + 8) &&\r
-      memcmp(buf + 10, XZ_FOOTER_SIG, XZ_FOOTER_SIG_SIZE) == 0);\r
-}\r
-\r
-#define READ_VARINT_AND_CHECK(buf, pos, size, res) \\r
-  { unsigned s = Xz_ReadVarInt(buf + pos, size - pos, res); \\r
-  if (s == 0) return SZ_ERROR_ARCHIVE; pos += s; }\r
-\r
-\r
-SRes XzBlock_Parse(CXzBlock *p, const Byte *header)\r
-{\r
-  unsigned pos;\r
-  unsigned numFilters, i;\r
-  unsigned headerSize = (unsigned)header[0] << 2;\r
-\r
-  if (CrcCalc(header, headerSize) != GetUi32(header + headerSize))\r
-    return SZ_ERROR_ARCHIVE;\r
-\r
-  pos = 1;\r
-  if (pos == headerSize)\r
-    return SZ_ERROR_ARCHIVE;\r
-  p->flags = header[pos++];\r
-\r
-  if (XzBlock_HasPackSize(p))\r
-  {\r
-    READ_VARINT_AND_CHECK(header, pos, headerSize, &p->packSize);\r
-    if (p->packSize == 0 || p->packSize + headerSize >= (UInt64)1 << 63)\r
-      return SZ_ERROR_ARCHIVE;\r
-  }\r
-\r
-  if (XzBlock_HasUnpackSize(p))\r
-    READ_VARINT_AND_CHECK(header, pos, headerSize, &p->unpackSize);\r
-\r
-  numFilters = XzBlock_GetNumFilters(p);\r
-  for (i = 0; i < numFilters; i++)\r
-  {\r
-    CXzFilter *filter = p->filters + i;\r
-    UInt64 size;\r
-    READ_VARINT_AND_CHECK(header, pos, headerSize, &filter->id);\r
-    READ_VARINT_AND_CHECK(header, pos, headerSize, &size);\r
-    if (size > headerSize - pos || size > XZ_FILTER_PROPS_SIZE_MAX)\r
-      return SZ_ERROR_ARCHIVE;\r
-    filter->propsSize = (UInt32)size;\r
-    memcpy(filter->props, header + pos, (size_t)size);\r
-    pos += (unsigned)size;\r
-\r
-    #ifdef XZ_DUMP\r
-    printf("\nf[%u] = %2X: ", i, (unsigned)filter->id);\r
-    {\r
-      unsigned i;\r
-      for (i = 0; i < size; i++)\r
-        printf(" %2X", filter->props[i]);\r
-    }\r
-    #endif\r
-  }\r
-\r
-  while (pos < headerSize)\r
-    if (header[pos++] != 0)\r
-      return SZ_ERROR_ARCHIVE;\r
-  return SZ_OK;\r
-}\r
-\r
-SRes XzDec_Init(CMixCoder *p, const CXzBlock *block)\r
-{\r
-  unsigned i;\r
-  Bool needReInit = True;\r
-  unsigned numFilters = XzBlock_GetNumFilters(block);\r
-  \r
-  if (numFilters == p->numCoders)\r
-  {\r
-    for (i = 0; i < numFilters; i++)\r
-      if (p->ids[i] != block->filters[numFilters - 1 - i].id)\r
-        break;\r
-    needReInit = (i != numFilters);\r
-  }\r
-  \r
-  if (needReInit)\r
-  {\r
-    MixCoder_Free(p);\r
-    p->numCoders = numFilters;\r
-    for (i = 0; i < numFilters; i++)\r
-    {\r
-      const CXzFilter *f = &block->filters[numFilters - 1 - i];\r
-      RINOK(MixCoder_SetFromMethod(p, i, f->id));\r
-    }\r
-  }\r
-  \r
-  for (i = 0; i < numFilters; i++)\r
-  {\r
-    const CXzFilter *f = &block->filters[numFilters - 1 - i];\r
-    IStateCoder *sc = &p->coders[i];\r
-    RINOK(sc->SetProps(sc->p, f->props, f->propsSize, p->alloc));\r
-  }\r
-  \r
-  MixCoder_Init(p);\r
-  return SZ_OK;\r
-}\r
-\r
-void XzUnpacker_Init(CXzUnpacker *p)\r
-{\r
-  p->state = XZ_STATE_STREAM_HEADER;\r
-  p->pos = 0;\r
-  p->numStartedStreams = 0;\r
-  p->numFinishedStreams = 0;\r
-  p->numTotalBlocks = 0;\r
-  p->padSize = 0;\r
-}\r
-\r
-void XzUnpacker_Construct(CXzUnpacker *p, ISzAlloc *alloc)\r
-{\r
-  MixCoder_Construct(&p->decoder, alloc);\r
-  XzUnpacker_Init(p);\r
-}\r
-\r
-void XzUnpacker_Free(CXzUnpacker *p)\r
-{\r
-  MixCoder_Free(&p->decoder);\r
-}\r
-\r
-SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,\r
-    const Byte *src, SizeT *srcLen, ECoderFinishMode finishMode, ECoderStatus *status)\r
-{\r
-  SizeT destLenOrig = *destLen;\r
-  SizeT srcLenOrig = *srcLen;\r
-  *destLen = 0;\r
-  *srcLen = 0;\r
-  *status = CODER_STATUS_NOT_SPECIFIED;\r
-  for (;;)\r
-  {\r
-    SizeT srcRem = srcLenOrig - *srcLen;\r
-\r
-    if (p->state == XZ_STATE_BLOCK)\r
-    {\r
-      SizeT destLen2 = destLenOrig - *destLen;\r
-      SizeT srcLen2 = srcLenOrig - *srcLen;\r
-      SRes res;\r
-      if (srcLen2 == 0 && destLen2 == 0)\r
-      {\r
-        *status = CODER_STATUS_NOT_FINISHED;\r
-        return SZ_OK;\r
-      }\r
-      \r
-      res = MixCoder_Code(&p->decoder, dest, &destLen2, src, &srcLen2, False, finishMode, status);\r
-      XzCheck_Update(&p->check, dest, destLen2);\r
-      \r
-      (*srcLen) += srcLen2;\r
-      src += srcLen2;\r
-      p->packSize += srcLen2;\r
-      \r
-      (*destLen) += destLen2;\r
-      dest += destLen2;\r
-      p->unpackSize += destLen2;\r
-      \r
-      RINOK(res);\r
-      \r
-      if (*status == CODER_STATUS_FINISHED_WITH_MARK)\r
-      {\r
-        Byte temp[32];\r
-        unsigned num = Xz_WriteVarInt(temp, p->packSize + p->blockHeaderSize + XzFlags_GetCheckSize(p->streamFlags));\r
-        num += Xz_WriteVarInt(temp + num, p->unpackSize);\r
-        Sha256_Update(&p->sha, temp, num);\r
-        p->indexSize += num;\r
-        p->numBlocks++;\r
-        \r
-        p->state = XZ_STATE_BLOCK_FOOTER;\r
-        p->pos = 0;\r
-        p->alignPos = 0;\r
-      }\r
-      else if (srcLen2 == 0 && destLen2 == 0)\r
-        return SZ_OK;\r
-      \r
-      continue;\r
-    }\r
-\r
-    if (srcRem == 0)\r
-    {\r
-      *status = CODER_STATUS_NEEDS_MORE_INPUT;\r
-      return SZ_OK;\r
-    }\r
-\r
-    switch (p->state)\r
-    {\r
-      case XZ_STATE_STREAM_HEADER:\r
-      {\r
-        if (p->pos < XZ_STREAM_HEADER_SIZE)\r
-        {\r
-          if (p->pos < XZ_SIG_SIZE && *src != XZ_SIG[p->pos])\r
-            return SZ_ERROR_NO_ARCHIVE;\r
-          p->buf[p->pos++] = *src++;\r
-          (*srcLen)++;\r
-        }\r
-        else\r
-        {\r
-          RINOK(Xz_ParseHeader(&p->streamFlags, p->buf));\r
-          p->numStartedStreams++;\r
-          p->state = XZ_STATE_BLOCK_HEADER;\r
-          Sha256_Init(&p->sha);\r
-          p->indexSize = 0;\r
-          p->numBlocks = 0;\r
-          p->pos = 0;\r
-        }\r
-        break;\r
-      }\r
-\r
-      case XZ_STATE_BLOCK_HEADER:\r
-      {\r
-        if (p->pos == 0)\r
-        {\r
-          p->buf[p->pos++] = *src++;\r
-          (*srcLen)++;\r
-          if (p->buf[0] == 0)\r
-          {\r
-            p->indexPreSize = 1 + Xz_WriteVarInt(p->buf + 1, p->numBlocks);\r
-            p->indexPos = p->indexPreSize;\r
-            p->indexSize += p->indexPreSize;\r
-            Sha256_Final(&p->sha, p->shaDigest);\r
-            Sha256_Init(&p->sha);\r
-            p->crc = CrcUpdate(CRC_INIT_VAL, p->buf, p->indexPreSize);\r
-            p->state = XZ_STATE_STREAM_INDEX;\r
-          }\r
-          p->blockHeaderSize = ((UInt32)p->buf[0] << 2) + 4;\r
-        }\r
-        else if (p->pos != p->blockHeaderSize)\r
-        {\r
-          UInt32 cur = p->blockHeaderSize - p->pos;\r
-          if (cur > srcRem)\r
-            cur = (UInt32)srcRem;\r
-          memcpy(p->buf + p->pos, src, cur);\r
-          p->pos += cur;\r
-          (*srcLen) += cur;\r
-          src += cur;\r
-        }\r
-        else\r
-        {\r
-          RINOK(XzBlock_Parse(&p->block, p->buf));\r
-          p->numTotalBlocks++;\r
-          p->state = XZ_STATE_BLOCK;\r
-          p->packSize = 0;\r
-          p->unpackSize = 0;\r
-          XzCheck_Init(&p->check, XzFlags_GetCheckType(p->streamFlags));\r
-          RINOK(XzDec_Init(&p->decoder, &p->block));\r
-        }\r
-        break;\r
-      }\r
-\r
-      case XZ_STATE_BLOCK_FOOTER:\r
-      {\r
-        if (((p->packSize + p->alignPos) & 3) != 0)\r
-        {\r
-          (*srcLen)++;\r
-          p->alignPos++;\r
-          if (*src++ != 0)\r
-            return SZ_ERROR_CRC;\r
-        }\r
-        else\r
-        {\r
-          UInt32 checkSize = XzFlags_GetCheckSize(p->streamFlags);\r
-          UInt32 cur = checkSize - p->pos;\r
-          if (cur != 0)\r
-          {\r
-            if (cur > srcRem)\r
-              cur = (UInt32)srcRem;\r
-            memcpy(p->buf + p->pos, src, cur);\r
-            p->pos += cur;\r
-            (*srcLen) += cur;\r
-            src += cur;\r
-          }\r
-          else\r
-          {\r
-            Byte digest[XZ_CHECK_SIZE_MAX];\r
-            p->state = XZ_STATE_BLOCK_HEADER;\r
-            p->pos = 0;\r
-            if (XzCheck_Final(&p->check, digest) && memcmp(digest, p->buf, checkSize) != 0)\r
-              return SZ_ERROR_CRC;\r
-          }\r
-        }\r
-        break;\r
-      }\r
-\r
-      case XZ_STATE_STREAM_INDEX:\r
-      {\r
-        if (p->pos < p->indexPreSize)\r
-        {\r
-          (*srcLen)++;\r
-          if (*src++ != p->buf[p->pos++])\r
-            return SZ_ERROR_CRC;\r
-        }\r
-        else\r
-        {\r
-          if (p->indexPos < p->indexSize)\r
-          {\r
-            UInt64 cur = p->indexSize - p->indexPos;\r
-            if (srcRem > cur)\r
-              srcRem = (SizeT)cur;\r
-            p->crc = CrcUpdate(p->crc, src, srcRem);\r
-            Sha256_Update(&p->sha, src, srcRem);\r
-            (*srcLen) += srcRem;\r
-            src += srcRem;\r
-            p->indexPos += srcRem;\r
-          }\r
-          else if ((p->indexPos & 3) != 0)\r
-          {\r
-            Byte b = *src++;\r
-            p->crc = CRC_UPDATE_BYTE(p->crc, b);\r
-            (*srcLen)++;\r
-            p->indexPos++;\r
-            p->indexSize++;\r
-            if (b != 0)\r
-              return SZ_ERROR_CRC;\r
-          }\r
-          else\r
-          {\r
-            Byte digest[SHA256_DIGEST_SIZE];\r
-            p->state = XZ_STATE_STREAM_INDEX_CRC;\r
-            p->indexSize += 4;\r
-            p->pos = 0;\r
-            Sha256_Final(&p->sha, digest);\r
-            if (memcmp(digest, p->shaDigest, SHA256_DIGEST_SIZE) != 0)\r
-              return SZ_ERROR_CRC;\r
-          }\r
-        }\r
-        break;\r
-      }\r
-\r
-      case XZ_STATE_STREAM_INDEX_CRC:\r
-      {\r
-        if (p->pos < 4)\r
-        {\r
-          (*srcLen)++;\r
-          p->buf[p->pos++] = *src++;\r
-        }\r
-        else\r
-        {\r
-          p->state = XZ_STATE_STREAM_FOOTER;\r
-          p->pos = 0;\r
-          if (CRC_GET_DIGEST(p->crc) != GetUi32(p->buf))\r
-            return SZ_ERROR_CRC;\r
-        }\r
-        break;\r
-      }\r
-\r
-      case XZ_STATE_STREAM_FOOTER:\r
-      {\r
-        UInt32 cur = XZ_STREAM_FOOTER_SIZE - p->pos;\r
-        if (cur > srcRem)\r
-          cur = (UInt32)srcRem;\r
-        memcpy(p->buf + p->pos, src, cur);\r
-        p->pos += cur;\r
-        (*srcLen) += cur;\r
-        src += cur;\r
-        if (p->pos == XZ_STREAM_FOOTER_SIZE)\r
-        {\r
-          p->state = XZ_STATE_STREAM_PADDING;\r
-          p->numFinishedStreams++;\r
-          p->padSize = 0;\r
-          if (!Xz_CheckFooter(p->streamFlags, p->indexSize, p->buf))\r
-            return SZ_ERROR_CRC;\r
-        }\r
-        break;\r
-      }\r
-\r
-      case XZ_STATE_STREAM_PADDING:\r
-      {\r
-        if (*src != 0)\r
-        {\r
-          if (((UInt32)p->padSize & 3) != 0)\r
-            return SZ_ERROR_NO_ARCHIVE;\r
-          p->pos = 0;\r
-          p->state = XZ_STATE_STREAM_HEADER;\r
-        }\r
-        else\r
-        {\r
-          (*srcLen)++;\r
-          src++;\r
-          p->padSize++;\r
-        }\r
-        break;\r
-      }\r
-      \r
-      case XZ_STATE_BLOCK: break; /* to disable GCC warning */\r
-    }\r
-  }\r
-  /*\r
-  if (p->state == XZ_STATE_FINISHED)\r
-    *status = CODER_STATUS_FINISHED_WITH_MARK;\r
-  return SZ_OK;\r
-  */\r
-}\r
-\r
-Bool XzUnpacker_IsStreamWasFinished(CXzUnpacker *p)\r
-{\r
-  return (p->state == XZ_STATE_STREAM_PADDING) && (((UInt32)p->padSize & 3) == 0);\r
-}\r
-\r
-UInt64 XzUnpacker_GetExtraSize(CXzUnpacker *p)\r
-{\r
-  UInt64 num = 0;\r
-  if (p->state == XZ_STATE_STREAM_PADDING)\r
-    num += p->padSize;\r
-  else if (p->state == XZ_STATE_STREAM_HEADER)\r
-    num += p->padSize + p->pos;\r
-  return num;\r
-}\r
diff --git a/deps/lzma-16.04/C/XzEnc.c b/deps/lzma-16.04/C/XzEnc.c
deleted file mode 100644 (file)
index 2e5a003..0000000
+++ /dev/null
@@ -1,538 +0,0 @@
-/* XzEnc.c -- Xz Encode\r
-2015-09-16 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include <stdlib.h>\r
-#include <string.h>\r
-\r
-#include "7zCrc.h"\r
-#include "Alloc.h"\r
-#include "Bra.h"\r
-#include "CpuArch.h"\r
-\r
-#ifdef USE_SUBBLOCK\r
-#include "Bcj3Enc.c"\r
-#include "SbFind.c"\r
-#include "SbEnc.c"\r
-#endif\r
-\r
-#include "XzEnc.h"\r
-\r
-#define XzBlock_ClearFlags(p)       (p)->flags = 0;\r
-#define XzBlock_SetNumFilters(p, n) (p)->flags |= ((n) - 1);\r
-#define XzBlock_SetHasPackSize(p)   (p)->flags |= XZ_BF_PACK_SIZE;\r
-#define XzBlock_SetHasUnpackSize(p) (p)->flags |= XZ_BF_UNPACK_SIZE;\r
-\r
-static SRes WriteBytes(ISeqOutStream *s, const void *buf, UInt32 size)\r
-{\r
-  return (s->Write(s, buf, size) == size) ? SZ_OK : SZ_ERROR_WRITE;\r
-}\r
-\r
-static SRes WriteBytesAndCrc(ISeqOutStream *s, const void *buf, UInt32 size, UInt32 *crc)\r
-{\r
-  *crc = CrcUpdate(*crc, buf, size);\r
-  return WriteBytes(s, buf, size);\r
-}\r
-\r
-static SRes Xz_WriteHeader(CXzStreamFlags f, ISeqOutStream *s)\r
-{\r
-  UInt32 crc;\r
-  Byte header[XZ_STREAM_HEADER_SIZE];\r
-  memcpy(header, XZ_SIG, XZ_SIG_SIZE);\r
-  header[XZ_SIG_SIZE] = (Byte)(f >> 8);\r
-  header[XZ_SIG_SIZE + 1] = (Byte)(f & 0xFF);\r
-  crc = CrcCalc(header + XZ_SIG_SIZE, XZ_STREAM_FLAGS_SIZE);\r
-  SetUi32(header + XZ_SIG_SIZE + XZ_STREAM_FLAGS_SIZE, crc);\r
-  return WriteBytes(s, header, XZ_STREAM_HEADER_SIZE);\r
-}\r
-\r
-\r
-static SRes XzBlock_WriteHeader(const CXzBlock *p, ISeqOutStream *s)\r
-{\r
-  Byte header[XZ_BLOCK_HEADER_SIZE_MAX];\r
-\r
-  unsigned pos = 1;\r
-  unsigned numFilters, i;\r
-  header[pos++] = p->flags;\r
-\r
-  if (XzBlock_HasPackSize(p)) pos += Xz_WriteVarInt(header + pos, p->packSize);\r
-  if (XzBlock_HasUnpackSize(p)) pos += Xz_WriteVarInt(header + pos, p->unpackSize);\r
-  numFilters = XzBlock_GetNumFilters(p);\r
-  \r
-  for (i = 0; i < numFilters; i++)\r
-  {\r
-    const CXzFilter *f = &p->filters[i];\r
-    pos += Xz_WriteVarInt(header + pos, f->id);\r
-    pos += Xz_WriteVarInt(header + pos, f->propsSize);\r
-    memcpy(header + pos, f->props, f->propsSize);\r
-    pos += f->propsSize;\r
-  }\r
-\r
-  while ((pos & 3) != 0)\r
-    header[pos++] = 0;\r
-\r
-  header[0] = (Byte)(pos >> 2);\r
-  SetUi32(header + pos, CrcCalc(header, pos));\r
-  return WriteBytes(s, header, pos + 4);\r
-}\r
-\r
-\r
-static SRes Xz_WriteFooter(CXzStream *p, ISeqOutStream *s)\r
-{\r
-  Byte buf[32];\r
-  UInt64 globalPos;\r
-  {\r
-    UInt32 crc = CRC_INIT_VAL;\r
-    unsigned pos = 1 + Xz_WriteVarInt(buf + 1, p->numBlocks);\r
-    size_t i;\r
-\r
-    globalPos = pos;\r
-    buf[0] = 0;\r
-    RINOK(WriteBytesAndCrc(s, buf, pos, &crc));\r
-\r
-    for (i = 0; i < p->numBlocks; i++)\r
-    {\r
-      const CXzBlockSizes *block = &p->blocks[i];\r
-      pos = Xz_WriteVarInt(buf, block->totalSize);\r
-      pos += Xz_WriteVarInt(buf + pos, block->unpackSize);\r
-      globalPos += pos;\r
-      RINOK(WriteBytesAndCrc(s, buf, pos, &crc));\r
-    }\r
-    \r
-    pos = ((unsigned)globalPos & 3);\r
-    \r
-    if (pos != 0)\r
-    {\r
-      buf[0] = buf[1] = buf[2] = 0;\r
-      RINOK(WriteBytesAndCrc(s, buf, 4 - pos, &crc));\r
-      globalPos += 4 - pos;\r
-    }\r
-    {\r
-      SetUi32(buf, CRC_GET_DIGEST(crc));\r
-      RINOK(WriteBytes(s, buf, 4));\r
-      globalPos += 4;\r
-    }\r
-  }\r
-\r
-  {\r
-    UInt32 indexSize = (UInt32)((globalPos >> 2) - 1);\r
-    SetUi32(buf + 4, indexSize);\r
-    buf[8] = (Byte)(p->flags >> 8);\r
-    buf[9] = (Byte)(p->flags & 0xFF);\r
-    SetUi32(buf, CrcCalc(buf + 4, 6));\r
-    memcpy(buf + 10, XZ_FOOTER_SIG, XZ_FOOTER_SIG_SIZE);\r
-    return WriteBytes(s, buf, 12);\r
-  }\r
-}\r
-\r
-\r
-static SRes Xz_AddIndexRecord(CXzStream *p, UInt64 unpackSize, UInt64 totalSize, ISzAlloc *alloc)\r
-{\r
-  if (!p->blocks || p->numBlocksAllocated == p->numBlocks)\r
-  {\r
-    size_t num = p->numBlocks * 2 + 1;\r
-    size_t newSize = sizeof(CXzBlockSizes) * num;\r
-    CXzBlockSizes *blocks;\r
-    if (newSize / sizeof(CXzBlockSizes) != num)\r
-      return SZ_ERROR_MEM;\r
-    blocks = (CXzBlockSizes *)alloc->Alloc(alloc, newSize);\r
-    if (!blocks)\r
-      return SZ_ERROR_MEM;\r
-    if (p->numBlocks != 0)\r
-    {\r
-      memcpy(blocks, p->blocks, p->numBlocks * sizeof(CXzBlockSizes));\r
-      alloc->Free(alloc, p->blocks);\r
-    }\r
-    p->blocks = blocks;\r
-    p->numBlocksAllocated = num;\r
-  }\r
-  {\r
-    CXzBlockSizes *block = &p->blocks[p->numBlocks++];\r
-    block->unpackSize = unpackSize;\r
-    block->totalSize = totalSize;\r
-  }\r
-  return SZ_OK;\r
-}\r
-\r
-\r
-/* ---------- CSeqCheckInStream ---------- */\r
-\r
-typedef struct\r
-{\r
-  ISeqInStream p;\r
-  ISeqInStream *realStream;\r
-  UInt64 processed;\r
-  CXzCheck check;\r
-} CSeqCheckInStream;\r
-\r
-static void SeqCheckInStream_Init(CSeqCheckInStream *p, unsigned mode)\r
-{\r
-  p->processed = 0;\r
-  XzCheck_Init(&p->check, mode);\r
-}\r
-\r
-static void SeqCheckInStream_GetDigest(CSeqCheckInStream *p, Byte *digest)\r
-{\r
-  XzCheck_Final(&p->check, digest);\r
-}\r
-\r
-static SRes SeqCheckInStream_Read(void *pp, void *data, size_t *size)\r
-{\r
-  CSeqCheckInStream *p = (CSeqCheckInStream *)pp;\r
-  SRes res = p->realStream->Read(p->realStream, data, size);\r
-  XzCheck_Update(&p->check, data, *size);\r
-  p->processed += *size;\r
-  return res;\r
-}\r
-\r
-\r
-/* ---------- CSeqSizeOutStream ---------- */\r
-\r
-typedef struct\r
-{\r
-  ISeqOutStream p;\r
-  ISeqOutStream *realStream;\r
-  UInt64 processed;\r
-} CSeqSizeOutStream;\r
-\r
-static size_t MyWrite(void *pp, const void *data, size_t size)\r
-{\r
-  CSeqSizeOutStream *p = (CSeqSizeOutStream *)pp;\r
-  size = p->realStream->Write(p->realStream, data, size);\r
-  p->processed += size;\r
-  return size;\r
-}\r
-\r
-\r
-/* ---------- CSeqInFilter ---------- */\r
-\r
-#define FILTER_BUF_SIZE (1 << 20)\r
-\r
-typedef struct\r
-{\r
-  ISeqInStream p;\r
-  ISeqInStream *realStream;\r
-  IStateCoder StateCoder;\r
-  Byte *buf;\r
-  size_t curPos;\r
-  size_t endPos;\r
-  int srcWasFinished;\r
-} CSeqInFilter;\r
-\r
-static SRes SeqInFilter_Read(void *pp, void *data, size_t *size)\r
-{\r
-  CSeqInFilter *p = (CSeqInFilter *)pp;\r
-  size_t sizeOriginal = *size;\r
-  if (sizeOriginal == 0)\r
-    return SZ_OK;\r
-  *size = 0;\r
-  \r
-  for (;;)\r
-  {\r
-    if (!p->srcWasFinished && p->curPos == p->endPos)\r
-    {\r
-      p->curPos = 0;\r
-      p->endPos = FILTER_BUF_SIZE;\r
-      RINOK(p->realStream->Read(p->realStream, p->buf, &p->endPos));\r
-      if (p->endPos == 0)\r
-        p->srcWasFinished = 1;\r
-    }\r
-    {\r
-      SizeT srcLen = p->endPos - p->curPos;\r
-      int wasFinished;\r
-      SRes res;\r
-      *size = sizeOriginal;\r
-      res = p->StateCoder.Code(p->StateCoder.p, data, size, p->buf + p->curPos, &srcLen,\r
-        p->srcWasFinished, CODER_FINISH_ANY, &wasFinished);\r
-      p->curPos += srcLen;\r
-      if (*size != 0 || srcLen == 0 || res != 0)\r
-        return res;\r
-    }\r
-  }\r
-}\r
-\r
-static void SeqInFilter_Construct(CSeqInFilter *p)\r
-{\r
-  p->buf = NULL;\r
-  p->p.Read = SeqInFilter_Read;\r
-}\r
-\r
-static void SeqInFilter_Free(CSeqInFilter *p)\r
-{\r
-  if (p->buf)\r
-  {\r
-    g_Alloc.Free(&g_Alloc, p->buf);\r
-    p->buf = NULL;\r
-  }\r
-}\r
-\r
-SRes BraState_SetFromMethod(IStateCoder *p, UInt64 id, int encodeMode, ISzAlloc *alloc);\r
-\r
-static SRes SeqInFilter_Init(CSeqInFilter *p, const CXzFilter *props)\r
-{\r
-  if (!p->buf)\r
-  {\r
-    p->buf = g_Alloc.Alloc(&g_Alloc, FILTER_BUF_SIZE);\r
-    if (!p->buf)\r
-      return SZ_ERROR_MEM;\r
-  }\r
-  p->curPos = p->endPos = 0;\r
-  p->srcWasFinished = 0;\r
-  RINOK(BraState_SetFromMethod(&p->StateCoder, props->id, 1, &g_Alloc));\r
-  RINOK(p->StateCoder.SetProps(p->StateCoder.p, props->props, props->propsSize, &g_Alloc));\r
-  p->StateCoder.Init(p->StateCoder.p);\r
-  return SZ_OK;\r
-}\r
-\r
-\r
-/* ---------- CSbEncInStream ---------- */\r
-\r
-#ifdef USE_SUBBLOCK\r
-\r
-typedef struct\r
-{\r
-  ISeqInStream p;\r
-  ISeqInStream *inStream;\r
-  CSbEnc enc;\r
-} CSbEncInStream;\r
-\r
-static SRes SbEncInStream_Read(void *pp, void *data, size_t *size)\r
-{\r
-  CSbEncInStream *p = (CSbEncInStream *)pp;\r
-  size_t sizeOriginal = *size;\r
-  if (sizeOriginal == 0)\r
-    return S_OK;\r
-  \r
-  for (;;)\r
-  {\r
-    if (p->enc.needRead && !p->enc.readWasFinished)\r
-    {\r
-      size_t processed = p->enc.needReadSizeMax;\r
-      RINOK(p->inStream->Read(p->inStream, p->enc.buf + p->enc.readPos, &processed));\r
-      p->enc.readPos += processed;\r
-      if (processed == 0)\r
-      {\r
-        p->enc.readWasFinished = True;\r
-        p->enc.isFinalFinished = True;\r
-      }\r
-      p->enc.needRead = False;\r
-    }\r
-  \r
-    *size = sizeOriginal;\r
-    RINOK(SbEnc_Read(&p->enc, data, size));\r
-    if (*size != 0 || !p->enc.needRead)\r
-      return S_OK;\r
-  }\r
-}\r
-\r
-void SbEncInStream_Construct(CSbEncInStream *p, ISzAlloc *alloc)\r
-{\r
-  SbEnc_Construct(&p->enc, alloc);\r
-  p->p.Read = SbEncInStream_Read;\r
-}\r
-\r
-SRes SbEncInStream_Init(CSbEncInStream *p)\r
-{\r
-  return SbEnc_Init(&p->enc);\r
-}\r
-\r
-void SbEncInStream_Free(CSbEncInStream *p)\r
-{\r
-  SbEnc_Free(&p->enc);\r
-}\r
-\r
-#endif\r
-\r
-\r
-typedef struct\r
-{\r
-  CLzma2EncHandle lzma2;\r
-  #ifdef USE_SUBBLOCK\r
-  CSbEncInStream sb;\r
-  #endif\r
-  CSeqInFilter filter;\r
-  ISzAlloc *alloc;\r
-  ISzAlloc *bigAlloc;\r
-} CLzma2WithFilters;\r
-\r
-\r
-static void Lzma2WithFilters_Construct(CLzma2WithFilters *p, ISzAlloc *alloc, ISzAlloc *bigAlloc)\r
-{\r
-  p->alloc = alloc;\r
-  p->bigAlloc = bigAlloc;\r
-  p->lzma2 = NULL;\r
-  #ifdef USE_SUBBLOCK\r
-  SbEncInStream_Construct(&p->sb, alloc);\r
-  #endif\r
-  SeqInFilter_Construct(&p->filter);\r
-}\r
-\r
-static SRes Lzma2WithFilters_Create(CLzma2WithFilters *p)\r
-{\r
-  p->lzma2 = Lzma2Enc_Create(p->alloc, p->bigAlloc);\r
-  if (!p->lzma2)\r
-    return SZ_ERROR_MEM;\r
-  return SZ_OK;\r
-}\r
-\r
-static void Lzma2WithFilters_Free(CLzma2WithFilters *p)\r
-{\r
-  SeqInFilter_Free(&p->filter);\r
-  #ifdef USE_SUBBLOCK\r
-  SbEncInStream_Free(&p->sb);\r
-  #endif\r
-  if (p->lzma2)\r
-  {\r
-    Lzma2Enc_Destroy(p->lzma2);\r
-    p->lzma2 = NULL;\r
-  }\r
-}\r
-\r
-\r
-void XzProps_Init(CXzProps *p)\r
-{\r
-  p->lzma2Props = NULL;\r
-  p->filterProps = NULL;\r
-  p->checkId = XZ_CHECK_CRC32;\r
-}\r
-\r
-void XzFilterProps_Init(CXzFilterProps *p)\r
-{\r
-  p->id = 0;\r
-  p->delta = 0;\r
-  p->ip = 0;\r
-  p->ipDefined = False;\r
-}\r
-\r
-\r
-static SRes Xz_Compress(CXzStream *xz, CLzma2WithFilters *lzmaf,\r
-    ISeqOutStream *outStream, ISeqInStream *inStream,\r
-    const CXzProps *props, ICompressProgress *progress)\r
-{\r
-  xz->flags = (Byte)props->checkId;\r
-\r
-  RINOK(Lzma2Enc_SetProps(lzmaf->lzma2, props->lzma2Props));\r
-  RINOK(Xz_WriteHeader(xz->flags, outStream));\r
-\r
-  {\r
-    CSeqCheckInStream checkInStream;\r
-    CSeqSizeOutStream seqSizeOutStream;\r
-    CXzBlock block;\r
-    unsigned filterIndex = 0;\r
-    CXzFilter *filter = NULL;\r
-    const CXzFilterProps *fp = props->filterProps;\r
-    \r
-    XzBlock_ClearFlags(&block);\r
-    XzBlock_SetNumFilters(&block, 1 + (fp ? 1 : 0));\r
-    \r
-    if (fp)\r
-    {\r
-      filter = &block.filters[filterIndex++];\r
-      filter->id = fp->id;\r
-      filter->propsSize = 0;\r
-      \r
-      if (fp->id == XZ_ID_Delta)\r
-      {\r
-        filter->props[0] = (Byte)(fp->delta - 1);\r
-        filter->propsSize = 1;\r
-      }\r
-      else if (fp->ipDefined)\r
-      {\r
-        SetUi32(filter->props, fp->ip);\r
-        filter->propsSize = 4;\r
-      }\r
-    }\r
-\r
-    {\r
-      CXzFilter *f = &block.filters[filterIndex++];\r
-      f->id = XZ_ID_LZMA2;\r
-      f->propsSize = 1;\r
-      f->props[0] = Lzma2Enc_WriteProperties(lzmaf->lzma2);\r
-    }\r
-\r
-    seqSizeOutStream.p.Write = MyWrite;\r
-    seqSizeOutStream.realStream = outStream;\r
-    seqSizeOutStream.processed = 0;\r
-    \r
-    RINOK(XzBlock_WriteHeader(&block, &seqSizeOutStream.p));\r
-    \r
-    checkInStream.p.Read = SeqCheckInStream_Read;\r
-    checkInStream.realStream = inStream;\r
-    SeqCheckInStream_Init(&checkInStream, XzFlags_GetCheckType(xz->flags));\r
-    \r
-    if (fp)\r
-    {\r
-      #ifdef USE_SUBBLOCK\r
-      if (fp->id == XZ_ID_Subblock)\r
-      {\r
-        lzmaf->sb.inStream = &checkInStream.p;\r
-        RINOK(SbEncInStream_Init(&lzmaf->sb));\r
-      }\r
-      else\r
-      #endif\r
-      {\r
-        lzmaf->filter.realStream = &checkInStream.p;\r
-        RINOK(SeqInFilter_Init(&lzmaf->filter, filter));\r
-      }\r
-    }\r
-\r
-    {\r
-      UInt64 packPos = seqSizeOutStream.processed;\r
-      \r
-      SRes res = Lzma2Enc_Encode(lzmaf->lzma2, &seqSizeOutStream.p,\r
-          fp ?\r
-            #ifdef USE_SUBBLOCK\r
-            (fp->id == XZ_ID_Subblock) ? &lzmaf->sb.p:\r
-            #endif\r
-            &lzmaf->filter.p:\r
-            &checkInStream.p,\r
-          progress);\r
-      \r
-      RINOK(res);\r
-      block.unpackSize = checkInStream.processed;\r
-      block.packSize = seqSizeOutStream.processed - packPos;\r
-    }\r
-\r
-    {\r
-      unsigned padSize = 0;\r
-      Byte buf[128];\r
-      while ((((unsigned)block.packSize + padSize) & 3) != 0)\r
-        buf[padSize++] = 0;\r
-      SeqCheckInStream_GetDigest(&checkInStream, buf + padSize);\r
-      RINOK(WriteBytes(&seqSizeOutStream.p, buf, padSize + XzFlags_GetCheckSize(xz->flags)));\r
-      RINOK(Xz_AddIndexRecord(xz, block.unpackSize, seqSizeOutStream.processed - padSize, &g_Alloc));\r
-    }\r
-  }\r
-  return Xz_WriteFooter(xz, outStream);\r
-}\r
-\r
-\r
-SRes Xz_Encode(ISeqOutStream *outStream, ISeqInStream *inStream,\r
-    const CXzProps *props, ICompressProgress *progress)\r
-{\r
-  SRes res;\r
-  CXzStream xz;\r
-  CLzma2WithFilters lzmaf;\r
-  Xz_Construct(&xz);\r
-  Lzma2WithFilters_Construct(&lzmaf, &g_Alloc, &g_BigAlloc);\r
-  res = Lzma2WithFilters_Create(&lzmaf);\r
-  if (res == SZ_OK)\r
-    res = Xz_Compress(&xz, &lzmaf, outStream, inStream, props, progress);\r
-  Lzma2WithFilters_Free(&lzmaf);\r
-  Xz_Free(&xz, &g_Alloc);\r
-  return res;\r
-}\r
-\r
-\r
-SRes Xz_EncodeEmpty(ISeqOutStream *outStream)\r
-{\r
-  SRes res;\r
-  CXzStream xz;\r
-  Xz_Construct(&xz);\r
-  res = Xz_WriteHeader(xz.flags, outStream);\r
-  if (res == SZ_OK)\r
-    res = Xz_WriteFooter(&xz, outStream);\r
-  Xz_Free(&xz, &g_Alloc);\r
-  return res;\r
-}\r
diff --git a/deps/lzma-16.04/C/XzEnc.h b/deps/lzma-16.04/C/XzEnc.h
deleted file mode 100644 (file)
index e9cea34..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/* XzEnc.h -- Xz Encode\r
-2011-02-07 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __XZ_ENC_H\r
-#define __XZ_ENC_H\r
-\r
-#include "Lzma2Enc.h"\r
-\r
-#include "Xz.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-typedef struct\r
-{\r
-  UInt32 id;\r
-  UInt32 delta;\r
-  UInt32 ip;\r
-  int ipDefined;\r
-} CXzFilterProps;\r
-\r
-void XzFilterProps_Init(CXzFilterProps *p);\r
-\r
-typedef struct\r
-{\r
-  const CLzma2EncProps *lzma2Props;\r
-  const CXzFilterProps *filterProps;\r
-  unsigned checkId;\r
-} CXzProps;\r
-\r
-void XzProps_Init(CXzProps *p);\r
-\r
-SRes Xz_Encode(ISeqOutStream *outStream, ISeqInStream *inStream,\r
-    const CXzProps *props, ICompressProgress *progress);\r
-\r
-SRes Xz_EncodeEmpty(ISeqOutStream *outStream);\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r
diff --git a/deps/lzma-16.04/C/XzIn.c b/deps/lzma-16.04/C/XzIn.c
deleted file mode 100644 (file)
index aaa0597..0000000
+++ /dev/null
@@ -1,313 +0,0 @@
-/* XzIn.c - Xz input\r
-2015-11-08 : Igor Pavlov : Public domain */\r
-\r
-#include "Precomp.h"\r
-\r
-#include <string.h>\r
-\r
-#include "7zCrc.h"\r
-#include "CpuArch.h"\r
-#include "Xz.h"\r
-\r
-SRes Xz_ReadHeader(CXzStreamFlags *p, ISeqInStream *inStream)\r
-{\r
-  Byte sig[XZ_STREAM_HEADER_SIZE];\r
-  RINOK(SeqInStream_Read2(inStream, sig, XZ_STREAM_HEADER_SIZE, SZ_ERROR_NO_ARCHIVE));\r
-  if (memcmp(sig, XZ_SIG, XZ_SIG_SIZE) != 0)\r
-    return SZ_ERROR_NO_ARCHIVE;\r
-  return Xz_ParseHeader(p, sig);\r
-}\r
-\r
-#define READ_VARINT_AND_CHECK(buf, pos, size, res) \\r
-  { unsigned s = Xz_ReadVarInt(buf + pos, size - pos, res); \\r
-  if (s == 0) return SZ_ERROR_ARCHIVE; pos += s; }\r
-\r
-SRes XzBlock_ReadHeader(CXzBlock *p, ISeqInStream *inStream, Bool *isIndex, UInt32 *headerSizeRes)\r
-{\r
-  Byte header[XZ_BLOCK_HEADER_SIZE_MAX];\r
-  unsigned headerSize;\r
-  *headerSizeRes = 0;\r
-  RINOK(SeqInStream_ReadByte(inStream, &header[0]));\r
-  headerSize = ((unsigned)header[0] << 2) + 4;\r
-  if (headerSize == 0)\r
-  {\r
-    *headerSizeRes = 1;\r
-    *isIndex = True;\r
-    return SZ_OK;\r
-  }\r
-\r
-  *isIndex = False;\r
-  *headerSizeRes = headerSize;\r
-  RINOK(SeqInStream_Read(inStream, header + 1, headerSize - 1));\r
-  return XzBlock_Parse(p, header);\r
-}\r
-\r
-#define ADD_SIZE_CHECH(size, val) \\r
-  { UInt64 newSize = size + (val); if (newSize < size) return XZ_SIZE_OVERFLOW; size = newSize; }\r
-\r
-UInt64 Xz_GetUnpackSize(const CXzStream *p)\r
-{\r
-  UInt64 size = 0;\r
-  size_t i;\r
-  for (i = 0; i < p->numBlocks; i++)\r
-    ADD_SIZE_CHECH(size, p->blocks[i].unpackSize);\r
-  return size;\r
-}\r
-\r
-UInt64 Xz_GetPackSize(const CXzStream *p)\r
-{\r
-  UInt64 size = 0;\r
-  size_t i;\r
-  for (i = 0; i < p->numBlocks; i++)\r
-    ADD_SIZE_CHECH(size, (p->blocks[i].totalSize + 3) & ~(UInt64)3);\r
-  return size;\r
-}\r
-\r
-/*\r
-SRes XzBlock_ReadFooter(CXzBlock *p, CXzStreamFlags f, ISeqInStream *inStream)\r
-{\r
-  return SeqInStream_Read(inStream, p->check, XzFlags_GetCheckSize(f));\r
-}\r
-*/\r
-\r
-static SRes Xz_ReadIndex2(CXzStream *p, const Byte *buf, size_t size, ISzAlloc *alloc)\r
-{\r
-  size_t numBlocks, pos = 1;\r
-  UInt32 crc;\r
-\r
-  if (size < 5 || buf[0] != 0)\r
-    return SZ_ERROR_ARCHIVE;\r
-\r
-  size -= 4;\r
-  crc = CrcCalc(buf, size);\r
-  if (crc != GetUi32(buf + size))\r
-    return SZ_ERROR_ARCHIVE;\r
-\r
-  {\r
-    UInt64 numBlocks64;\r
-    READ_VARINT_AND_CHECK(buf, pos, size, &numBlocks64);\r
-    numBlocks = (size_t)numBlocks64;\r
-    if (numBlocks != numBlocks64 || numBlocks * 2 > size)\r
-      return SZ_ERROR_ARCHIVE;\r
-  }\r
-  \r
-  Xz_Free(p, alloc);\r
-  if (numBlocks != 0)\r
-  {\r
-    size_t i;\r
-    p->numBlocks = numBlocks;\r
-    p->numBlocksAllocated = numBlocks;\r
-    p->blocks = alloc->Alloc(alloc, sizeof(CXzBlockSizes) * numBlocks);\r
-    if (p->blocks == 0)\r
-      return SZ_ERROR_MEM;\r
-    for (i = 0; i < numBlocks; i++)\r
-    {\r
-      CXzBlockSizes *block = &p->blocks[i];\r
-      READ_VARINT_AND_CHECK(buf, pos, size, &block->totalSize);\r
-      READ_VARINT_AND_CHECK(buf, pos, size, &block->unpackSize);\r
-      if (block->totalSize == 0)\r
-        return SZ_ERROR_ARCHIVE;\r
-    }\r
-  }\r
-  while ((pos & 3) != 0)\r
-    if (buf[pos++] != 0)\r
-      return SZ_ERROR_ARCHIVE;\r
-  return (pos == size) ? SZ_OK : SZ_ERROR_ARCHIVE;\r
-}\r
-\r
-static SRes Xz_ReadIndex(CXzStream *p, ILookInStream *stream, UInt64 indexSize, ISzAlloc *alloc)\r
-{\r
-  SRes res;\r
-  size_t size;\r
-  Byte *buf;\r
-  if (indexSize > ((UInt32)1 << 31))\r
-    return SZ_ERROR_UNSUPPORTED;\r
-  size = (size_t)indexSize;\r
-  if (size != indexSize)\r
-    return SZ_ERROR_UNSUPPORTED;\r
-  buf = alloc->Alloc(alloc, size);\r
-  if (buf == 0)\r
-    return SZ_ERROR_MEM;\r
-  res = LookInStream_Read2(stream, buf, size, SZ_ERROR_UNSUPPORTED);\r
-  if (res == SZ_OK)\r
-    res = Xz_ReadIndex2(p, buf, size, alloc);\r
-  alloc->Free(alloc, buf);\r
-  return res;\r
-}\r
-\r
-static SRes LookInStream_SeekRead_ForArc(ILookInStream *stream, UInt64 offset, void *buf, size_t size)\r
-{\r
-  RINOK(LookInStream_SeekTo(stream, offset));\r
-  return LookInStream_Read(stream, buf, size);\r
-  /* return LookInStream_Read2(stream, buf, size, SZ_ERROR_NO_ARCHIVE); */\r
-}\r
-\r
-static SRes Xz_ReadBackward(CXzStream *p, ILookInStream *stream, Int64 *startOffset, ISzAlloc *alloc)\r
-{\r
-  UInt64 indexSize;\r
-  Byte buf[XZ_STREAM_FOOTER_SIZE];\r
-  UInt64 pos = *startOffset;\r
-\r
-  if ((pos & 3) != 0 || pos < XZ_STREAM_FOOTER_SIZE)\r
-    return SZ_ERROR_NO_ARCHIVE;\r
-\r
-  pos -= XZ_STREAM_FOOTER_SIZE;\r
-  RINOK(LookInStream_SeekRead_ForArc(stream, pos, buf, XZ_STREAM_FOOTER_SIZE));\r
-  \r
-  if (memcmp(buf + 10, XZ_FOOTER_SIG, XZ_FOOTER_SIG_SIZE) != 0)\r
-  {\r
-    UInt32 total = 0;\r
-    pos += XZ_STREAM_FOOTER_SIZE;\r
-    \r
-    for (;;)\r
-    {\r
-      size_t i;\r
-      #define TEMP_BUF_SIZE (1 << 10)\r
-      Byte temp[TEMP_BUF_SIZE];\r
-      \r
-      i = (pos > TEMP_BUF_SIZE) ? TEMP_BUF_SIZE : (size_t)pos;\r
-      pos -= i;\r
-      RINOK(LookInStream_SeekRead_ForArc(stream, pos, temp, i));\r
-      total += (UInt32)i;\r
-      for (; i != 0; i--)\r
-        if (temp[i - 1] != 0)\r
-          break;\r
-      if (i != 0)\r
-      {\r
-        if ((i & 3) != 0)\r
-          return SZ_ERROR_NO_ARCHIVE;\r
-        pos += i;\r
-        break;\r
-      }\r
-      if (pos < XZ_STREAM_FOOTER_SIZE || total > (1 << 16))\r
-        return SZ_ERROR_NO_ARCHIVE;\r
-    }\r
-    \r
-    if (pos < XZ_STREAM_FOOTER_SIZE)\r
-      return SZ_ERROR_NO_ARCHIVE;\r
-    pos -= XZ_STREAM_FOOTER_SIZE;\r
-    RINOK(LookInStream_SeekRead_ForArc(stream, pos, buf, XZ_STREAM_FOOTER_SIZE));\r
-    if (memcmp(buf + 10, XZ_FOOTER_SIG, XZ_FOOTER_SIG_SIZE) != 0)\r
-      return SZ_ERROR_NO_ARCHIVE;\r
-  }\r
-  \r
-  p->flags = (CXzStreamFlags)GetBe16(buf + 8);\r
-\r
-  if (!XzFlags_IsSupported(p->flags))\r
-    return SZ_ERROR_UNSUPPORTED;\r
-\r
-  if (GetUi32(buf) != CrcCalc(buf + 4, 6))\r
-    return SZ_ERROR_ARCHIVE;\r
-\r
-  indexSize = ((UInt64)GetUi32(buf + 4) + 1) << 2;\r
-\r
-  if (pos < indexSize)\r
-    return SZ_ERROR_ARCHIVE;\r
-\r
-  pos -= indexSize;\r
-  RINOK(LookInStream_SeekTo(stream, pos));\r
-  RINOK(Xz_ReadIndex(p, stream, indexSize, alloc));\r
-\r
-  {\r
-    UInt64 totalSize = Xz_GetPackSize(p);\r
-    if (totalSize == XZ_SIZE_OVERFLOW\r
-        || totalSize >= ((UInt64)1 << 63)\r
-        || pos < totalSize + XZ_STREAM_HEADER_SIZE)\r
-      return SZ_ERROR_ARCHIVE;\r
-    pos -= (totalSize + XZ_STREAM_HEADER_SIZE);\r
-    RINOK(LookInStream_SeekTo(stream, pos));\r
-    *startOffset = pos;\r
-  }\r
-  {\r
-    CXzStreamFlags headerFlags;\r
-    CSecToRead secToRead;\r
-    SecToRead_CreateVTable(&secToRead);\r
-    secToRead.realStream = stream;\r
-\r
-    RINOK(Xz_ReadHeader(&headerFlags, &secToRead.s));\r
-    return (p->flags == headerFlags) ? SZ_OK : SZ_ERROR_ARCHIVE;\r
-  }\r
-}\r
-\r
-\r
-/* ---------- Xz Streams ---------- */\r
-\r
-void Xzs_Construct(CXzs *p)\r
-{\r
-  p->num = p->numAllocated = 0;\r
-  p->streams = 0;\r
-}\r
-\r
-void Xzs_Free(CXzs *p, ISzAlloc *alloc)\r
-{\r
-  size_t i;\r
-  for (i = 0; i < p->num; i++)\r
-    Xz_Free(&p->streams[i], alloc);\r
-  alloc->Free(alloc, p->streams);\r
-  p->num = p->numAllocated = 0;\r
-  p->streams = 0;\r
-}\r
-\r
-UInt64 Xzs_GetNumBlocks(const CXzs *p)\r
-{\r
-  UInt64 num = 0;\r
-  size_t i;\r
-  for (i = 0; i < p->num; i++)\r
-    num += p->streams[i].numBlocks;\r
-  return num;\r
-}\r
-\r
-UInt64 Xzs_GetUnpackSize(const CXzs *p)\r
-{\r
-  UInt64 size = 0;\r
-  size_t i;\r
-  for (i = 0; i < p->num; i++)\r
-    ADD_SIZE_CHECH(size, Xz_GetUnpackSize(&p->streams[i]));\r
-  return size;\r
-}\r
-\r
-/*\r
-UInt64 Xzs_GetPackSize(const CXzs *p)\r
-{\r
-  UInt64 size = 0;\r
-  size_t i;\r
-  for (i = 0; i < p->num; i++)\r
-    ADD_SIZE_CHECH(size, Xz_GetTotalSize(&p->streams[i]));\r
-  return size;\r
-}\r
-*/\r
-\r
-SRes Xzs_ReadBackward(CXzs *p, ILookInStream *stream, Int64 *startOffset, ICompressProgress *progress, ISzAlloc *alloc)\r
-{\r
-  Int64 endOffset = 0;\r
-  RINOK(stream->Seek(stream, &endOffset, SZ_SEEK_END));\r
-  *startOffset = endOffset;\r
-  for (;;)\r
-  {\r
-    CXzStream st;\r
-    SRes res;\r
-    Xz_Construct(&st);\r
-    res = Xz_ReadBackward(&st, stream, startOffset, alloc);\r
-    st.startOffset = *startOffset;\r
-    RINOK(res);\r
-    if (p->num == p->numAllocated)\r
-    {\r
-      size_t newNum = p->num + p->num / 4 + 1;\r
-      Byte *data = (Byte *)alloc->Alloc(alloc, newNum * sizeof(CXzStream));\r
-      if (data == 0)\r
-        return SZ_ERROR_MEM;\r
-      p->numAllocated = newNum;\r
-      if (p->num != 0)\r
-        memcpy(data, p->streams, p->num * sizeof(CXzStream));\r
-      alloc->Free(alloc, p->streams);\r
-      p->streams = (CXzStream *)data;\r
-    }\r
-    p->streams[p->num++] = st;\r
-    if (*startOffset == 0)\r
-      break;\r
-    RINOK(LookInStream_SeekTo(stream, *startOffset));\r
-    if (progress && progress->Progress(progress, endOffset - *startOffset, (UInt64)(Int64)-1) != SZ_OK)\r
-      return SZ_ERROR_PROGRESS;\r
-  }\r
-  return SZ_OK;\r
-}\r
diff --git a/deps/lzma-16.04/DOC/7zC.txt b/deps/lzma-16.04/DOC/7zC.txt
deleted file mode 100644 (file)
index 4927678..0000000
+++ /dev/null
@@ -1,187 +0,0 @@
-7z ANSI-C Decoder 9.35\r
-----------------------\r
-\r
-7z ANSI-C provides 7z/LZMA decoding.\r
-7z ANSI-C version is simplified version ported from C++ code.\r
-\r
-LZMA is default and general compression method of 7z format\r
-in 7-Zip compression program (www.7-zip.org). LZMA provides high \r
-compression ratio and very fast decompression.\r
-\r
-\r
-LICENSE\r
--------\r
-\r
-7z ANSI-C Decoder is part of the LZMA SDK.\r
-LZMA SDK is written and placed in the public domain by Igor Pavlov.\r
-\r
-Files\r
----------------------\r
-\r
-7zDecode.*   - Low level 7z decoding\r
-7zExtract.*  - High level 7z decoding\r
-7zHeader.*   - .7z format constants\r
-7zIn.*       - .7z archive opening\r
-7zItem.*     - .7z structures\r
-7zMain.c     - Test application\r
-\r
-\r
-How To Use\r
-----------\r
-\r
-You can create .7z archive with 7z.exe, 7za.exe or 7zr.exe:\r
-\r
-  7z.exe a archive.7z *.htm -r -mx -m0fb=255\r
-\r
-If you have big number of files in archive, and you need fast extracting, \r
-you can use partly-solid archives:\r
-  \r
-  7za.exe a archive.7z *.htm -ms=512K -r -mx -m0fb=255 -m0d=512K\r
-\r
-In that example 7-Zip will use 512KB solid blocks. So it needs to decompress only \r
-512KB for extracting one file from such archive.\r
-\r
-\r
-Limitations of current version of 7z ANSI-C Decoder\r
----------------------------------------------------\r
-\r
- - It reads only "FileName", "Size", "LastWriteTime" and "CRC" information for each file in archive.\r
- - It supports only LZMA and Copy (no compression) methods with BCJ or BCJ2 filters.\r
- - It converts original UTF-16 Unicode file names to UTF-8 Unicode file names.\r
\r
-These limitations will be fixed in future versions.\r
-\r
-\r
-Using 7z ANSI-C Decoder Test application:\r
------------------------------------------\r
-\r
-Usage: 7zDec <command> <archive_name>\r
-\r
-<Command>:\r
-  e: Extract files from archive\r
-  l: List contents of archive\r
-  t: Test integrity of archive\r
-\r
-Example: \r
-\r
-  7zDec l archive.7z\r
-\r
-lists contents of archive.7z\r
-\r
-  7zDec e archive.7z\r
-\r
-extracts files from archive.7z to current folder.\r
-\r
-\r
-How to use .7z Decoder\r
-----------------------\r
-\r
-Memory allocation\r
-~~~~~~~~~~~~~~~~~\r
-\r
-7z Decoder uses two memory pools:\r
-1) Temporary pool\r
-2) Main pool\r
-Such scheme can allow you to avoid fragmentation of allocated blocks.\r
-\r
-\r
-Steps for using 7z decoder\r
---------------------------\r
-\r
-Use code at 7zMain.c as example.\r
-\r
-1) Declare variables:\r
-  inStream                 /* implements ILookInStream interface */\r
-  CSzArEx db;              /* 7z archive database structure */\r
-  ISzAlloc allocImp;       /* memory functions for main pool */\r
-  ISzAlloc allocTempImp;   /* memory functions for temporary pool */\r
-\r
-2) call CrcGenerateTable(); function to initialize CRC structures.\r
-\r
-3) call SzArEx_Init(&db); function to initialize db structures.\r
-\r
-4) call SzArEx_Open(&db, inStream, &allocMain, &allocTemp) to open archive\r
-\r
-This function opens archive "inStream" and reads headers to "db".\r
-All items in "db" will be allocated with "allocMain" functions.\r
-SzArEx_Open function allocates and frees temporary structures by "allocTemp" functions.\r
-\r
-5) List items or Extract items\r
-\r
-  Listing code:\r
-  ~~~~~~~~~~~~~\r
-\r
-    Use SzArEx_GetFileNameUtf16 function. Look example code in C\Util\7z\7zMain.c file. \r
-    \r
-\r
-  Extracting code:\r
-  ~~~~~~~~~~~~~~~~\r
-\r
-  SZ_RESULT SzAr_Extract(\r
-    CArchiveDatabaseEx *db,\r
-    ILookInStream *inStream, \r
-    UInt32 fileIndex,         /* index of file */\r
-    UInt32 *blockIndex,       /* index of solid block */\r
-    Byte **outBuffer,         /* pointer to pointer to output buffer (allocated with allocMain) */\r
-    size_t *outBufferSize,    /* buffer size for output buffer */\r
-    size_t *offset,           /* offset of stream for required file in *outBuffer */\r
-    size_t *outSizeProcessed, /* size of file in *outBuffer */\r
-    ISzAlloc *allocMain,\r
-    ISzAlloc *allocTemp);\r
-\r
-  If you need to decompress more than one file, you can send these values from previous call:\r
-    blockIndex, \r
-    outBuffer, \r
-    outBufferSize,\r
-  You can consider "outBuffer" as cache of solid block. If your archive is solid, \r
-  it will increase decompression speed.\r
-\r
-  After decompressing you must free "outBuffer":\r
-  allocImp.Free(outBuffer);\r
-\r
-6) call SzArEx_Free(&db, allocImp.Free) to free allocated items in "db".\r
-\r
-\r
-\r
-\r
-Memory requirements for .7z decoding \r
-------------------------------------\r
-\r
-Memory usage for Archive opening:\r
-  - Temporary pool:\r
-     - Memory for uncompressed .7z headers\r
-     - some other temporary blocks\r
-  - Main pool:\r
-     - Memory for database: \r
-       Estimated size of one file structures in solid archive:\r
-         - Size (4 or 8 Bytes)\r
-         - CRC32 (4 bytes)\r
-         - LastWriteTime (8 bytes)\r
-         - Some file information (4 bytes)\r
-         - File Name (variable length) + pointer + allocation structures\r
-\r
-Memory usage for archive Decompressing:\r
-  - Temporary pool:\r
-     - Memory for LZMA decompressing structures\r
-  - Main pool:\r
-     - Memory for decompressed solid block\r
-     - Memory for temprorary buffers, if BCJ2 fileter is used. Usually these \r
-       temprorary buffers can be about 15% of solid block size. \r
-  \r
-\r
-7z Decoder doesn't allocate memory for compressed blocks. \r
-Instead of this, you must allocate buffer with desired \r
-size before calling 7z Decoder. Use 7zMain.c as example.\r
-\r
-\r
-Defines\r
--------\r
-\r
-_SZ_ALLOC_DEBUG   - define it if you want to debug alloc/free operations to stderr.\r
-\r
-\r
----\r
-\r
-http://www.7-zip.org\r
-http://www.7-zip.org/sdk.html\r
-http://www.7-zip.org/support.html\r
diff --git a/deps/lzma-16.04/DOC/7zFormat.txt b/deps/lzma-16.04/DOC/7zFormat.txt
deleted file mode 100644 (file)
index 6b8678f..0000000
+++ /dev/null
@@ -1,469 +0,0 @@
-7z Format description (4.59)\r
-----------------------------\r
-\r
-This file contains description of 7z archive format. \r
-7z archive can contain files compressed with any method.\r
-See "Methods.txt" for description for defined compressing methods.\r
-\r
-\r
-Format structure Overview\r
--------------------------\r
-\r
-Some fields can be optional.\r
-\r
-Archive structure\r
-~~~~~~~~~~~~~~~~~  \r
-SignatureHeader\r
-[PackedStreams]\r
-[PackedStreamsForHeaders]\r
-[\r
-  Header \r
-  or \r
-  {\r
-    Packed Header\r
-    HeaderInfo\r
-  }\r
-]\r
-\r
-\r
-\r
-Header structure\r
-~~~~~~~~~~~~~~~~  \r
-{\r
-  ArchiveProperties\r
-  AdditionalStreams\r
-  {\r
-    PackInfo\r
-    {\r
-      PackPos\r
-      NumPackStreams\r
-      Sizes[NumPackStreams]\r
-      CRCs[NumPackStreams]\r
-    }\r
-    CodersInfo\r
-    {\r
-      NumFolders\r
-      Folders[NumFolders]\r
-      {\r
-        NumCoders\r
-        CodersInfo[NumCoders]\r
-        {\r
-          ID\r
-          NumInStreams;\r
-          NumOutStreams;\r
-          PropertiesSize\r
-          Properties[PropertiesSize]\r
-        }\r
-        NumBindPairs\r
-        BindPairsInfo[NumBindPairs]\r
-        {\r
-          InIndex;\r
-          OutIndex;\r
-        }\r
-        PackedIndices\r
-      }\r
-      UnPackSize[Folders][Folders.NumOutstreams]\r
-      CRCs[NumFolders]\r
-    }\r
-    SubStreamsInfo\r
-    {\r
-      NumUnPackStreamsInFolders[NumFolders];\r
-      UnPackSizes[]\r
-      CRCs[]\r
-    }\r
-  }\r
-  MainStreamsInfo\r
-  {\r
-    (Same as in AdditionalStreams)\r
-  }\r
-  FilesInfo\r
-  {\r
-    NumFiles\r
-    Properties[]\r
-    {\r
-      ID\r
-      Size\r
-      Data\r
-    }\r
-  }\r
-}\r
-\r
-HeaderInfo structure\r
-~~~~~~~~~~~~~~~~~~~~\r
-{\r
-  (Same as in AdditionalStreams)\r
-}\r
-\r
-\r
-\r
-Notes about Notation and encoding\r
----------------------------------\r
-\r
-7z uses little endian encoding.\r
-\r
-7z archive format has optional headers that are marked as\r
-[]\r
-Header\r
-[]\r
-\r
-REAL_UINT64 means real UINT64.\r
-\r
-UINT64 means real UINT64 encoded with the following scheme:\r
-\r
-  Size of encoding sequence depends from first byte:\r
-  First_Byte  Extra_Bytes        Value\r
-  (binary)   \r
-  0xxxxxxx               : ( xxxxxxx           )\r
-  10xxxxxx    BYTE y[1]  : (  xxxxxx << (8 * 1)) + y\r
-  110xxxxx    BYTE y[2]  : (   xxxxx << (8 * 2)) + y\r
-  ...\r
-  1111110x    BYTE y[6]  : (       x << (8 * 6)) + y\r
-  11111110    BYTE y[7]  :                         y\r
-  11111111    BYTE y[8]  :                         y\r
-\r
-\r
-\r
-Property IDs\r
-------------\r
-\r
-0x00 = kEnd\r
-\r
-0x01 = kHeader\r
-\r
-0x02 = kArchiveProperties\r
-    \r
-0x03 = kAdditionalStreamsInfo\r
-0x04 = kMainStreamsInfo\r
-0x05 = kFilesInfo\r
-    \r
-0x06 = kPackInfo\r
-0x07 = kUnPackInfo\r
-0x08 = kSubStreamsInfo\r
-\r
-0x09 = kSize\r
-0x0A = kCRC\r
-\r
-0x0B = kFolder\r
-\r
-0x0C = kCodersUnPackSize\r
-0x0D = kNumUnPackStream\r
-\r
-0x0E = kEmptyStream\r
-0x0F = kEmptyFile\r
-0x10 = kAnti\r
-\r
-0x11 = kName\r
-0x12 = kCTime\r
-0x13 = kATime\r
-0x14 = kMTime\r
-0x15 = kWinAttributes\r
-0x16 = kComment\r
-\r
-0x17 = kEncodedHeader\r
-\r
-0x18 = kStartPos\r
-0x19 = kDummy\r
-\r
-\r
-7z format headers\r
------------------\r
-\r
-SignatureHeader\r
-~~~~~~~~~~~~~~~\r
-  BYTE kSignature[6] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C};\r
-\r
-  ArchiveVersion\r
-  {\r
-    BYTE Major;   // now = 0\r
-    BYTE Minor;   // now = 2\r
-  };\r
-\r
-  UINT32 StartHeaderCRC;\r
-\r
-  StartHeader\r
-  {\r
-    REAL_UINT64 NextHeaderOffset\r
-    REAL_UINT64 NextHeaderSize\r
-    UINT32 NextHeaderCRC\r
-  }\r
-\r
-\r
-...........................\r
-\r
-\r
-ArchiveProperties\r
-~~~~~~~~~~~~~~~~~\r
-BYTE NID::kArchiveProperties (0x02)\r
-for (;;)\r
-{\r
-  BYTE PropertyType;\r
-  if (aType == 0)\r
-    break;\r
-  UINT64 PropertySize;\r
-  BYTE PropertyData[PropertySize];\r
-}\r
-\r
-\r
-Digests (NumStreams)\r
-~~~~~~~~~~~~~~~~~~~~~\r
-  BYTE AllAreDefined\r
-  if (AllAreDefined == 0)\r
-  {\r
-    for(NumStreams)\r
-      BIT Defined\r
-  }\r
-  UINT32 CRCs[NumDefined]\r
-\r
-\r
-PackInfo\r
-~~~~~~~~~~~~\r
-  BYTE NID::kPackInfo  (0x06)\r
-  UINT64 PackPos\r
-  UINT64 NumPackStreams\r
-\r
-  []\r
-  BYTE NID::kSize    (0x09)\r
-  UINT64 PackSizes[NumPackStreams]\r
-  []\r
-\r
-  []\r
-  BYTE NID::kCRC      (0x0A)\r
-  PackStreamDigests[NumPackStreams]\r
-  []\r
-\r
-  BYTE NID::kEnd\r
-\r
-\r
-Folder\r
-~~~~~~\r
-  UINT64 NumCoders;\r
-  for (NumCoders)\r
-  {\r
-    BYTE \r
-    {\r
-      0:3 CodecIdSize\r
-      4:  Is Complex Coder\r
-      5:  There Are Attributes\r
-      6:  Reserved\r
-      7:  There are more alternative methods. (Not used anymore, must be 0).\r
-    } \r
-    BYTE CodecId[CodecIdSize]\r
-    if (Is Complex Coder)\r
-    {\r
-      UINT64 NumInStreams;\r
-      UINT64 NumOutStreams;\r
-    }\r
-    if (There Are Attributes)\r
-    {\r
-      UINT64 PropertiesSize\r
-      BYTE Properties[PropertiesSize]\r
-    }\r
-  }\r
-    \r
-  NumBindPairs = NumOutStreamsTotal - 1;\r
-\r
-  for (NumBindPairs)\r
-  {\r
-    UINT64 InIndex;\r
-    UINT64 OutIndex;\r
-  }\r
-\r
-  NumPackedStreams = NumInStreamsTotal - NumBindPairs;\r
-  if (NumPackedStreams > 1)\r
-    for(NumPackedStreams)\r
-    {\r
-      UINT64 Index;\r
-    };\r
-\r
-\r
-\r
-\r
-Coders Info\r
-~~~~~~~~~~~\r
-\r
-  BYTE NID::kUnPackInfo  (0x07)\r
-\r
-\r
-  BYTE NID::kFolder  (0x0B)\r
-  UINT64 NumFolders\r
-  BYTE External\r
-  switch(External)\r
-  {\r
-    case 0:\r
-      Folders[NumFolders]\r
-    case 1:\r
-      UINT64 DataStreamIndex\r
-  }\r
-\r
-\r
-  BYTE ID::kCodersUnPackSize  (0x0C)\r
-  for(Folders)\r
-    for(Folder.NumOutStreams)\r
-     UINT64 UnPackSize;\r
-\r
-\r
-  []\r
-  BYTE NID::kCRC   (0x0A)\r
-  UnPackDigests[NumFolders]\r
-  []\r
-\r
-  \r
-\r
-  BYTE NID::kEnd\r
-\r
-\r
-\r
-SubStreams Info\r
-~~~~~~~~~~~~~~\r
-  BYTE NID::kSubStreamsInfo; (0x08)\r
-\r
-  []\r
-  BYTE NID::kNumUnPackStream; (0x0D)\r
-  UINT64 NumUnPackStreamsInFolders[NumFolders];\r
-  []\r
-\r
-\r
-  []\r
-  BYTE NID::kSize  (0x09)\r
-  UINT64 UnPackSizes[]\r
-  []\r
-\r
-\r
-  []\r
-  BYTE NID::kCRC  (0x0A)\r
-  Digests[Number of streams with unknown CRC]\r
-  []\r
-\r
-  \r
-  BYTE NID::kEnd\r
-\r
-\r
-Streams Info\r
-~~~~~~~~~~~~\r
-\r
-  []\r
-  PackInfo\r
-  []\r
-\r
-\r
-  []\r
-  CodersInfo\r
-  []\r
-\r
-\r
-  []\r
-  SubStreamsInfo\r
-  []\r
-\r
-  BYTE NID::kEnd\r
-\r
-\r
-FilesInfo\r
-~~~~~~~~~\r
-  BYTE NID::kFilesInfo;  (0x05)\r
-  UINT64 NumFiles\r
-\r
-  for (;;)\r
-  {\r
-    BYTE PropertyType;\r
-    if (aType == 0)\r
-      break;\r
-\r
-    UINT64 Size;\r
-\r
-    switch(PropertyType)\r
-    {\r
-      kEmptyStream:   (0x0E)\r
-        for(NumFiles)\r
-          BIT IsEmptyStream\r
-\r
-      kEmptyFile:     (0x0F)\r
-        for(EmptyStreams)\r
-          BIT IsEmptyFile\r
-\r
-      kAnti:          (0x10)\r
-        for(EmptyStreams)\r
-          BIT IsAntiFile\r
-      \r
-      case kCTime: (0x12)\r
-      case kATime: (0x13)\r
-      case kMTime: (0x14)\r
-        BYTE AllAreDefined\r
-        if (AllAreDefined == 0)\r
-        {\r
-          for(NumFiles)\r
-            BIT TimeDefined\r
-        }\r
-        BYTE External;\r
-        if(External != 0)\r
-          UINT64 DataIndex\r
-        []\r
-        for(Definded Items)\r
-          UINT64 Time\r
-        []\r
-      \r
-      kNames:     (0x11)\r
-        BYTE External;\r
-        if(External != 0)\r
-          UINT64 DataIndex\r
-        []\r
-        for(Files)\r
-        {\r
-          wchar_t Names[NameSize];\r
-          wchar_t 0;\r
-        }\r
-        []\r
-\r
-      kAttributes:  (0x15)\r
-        BYTE AllAreDefined\r
-        if (AllAreDefined == 0)\r
-        {\r
-          for(NumFiles)\r
-            BIT AttributesAreDefined\r
-        }\r
-        BYTE External;\r
-        if(External != 0)\r
-          UINT64 DataIndex\r
-        []\r
-        for(Definded Attributes)\r
-          UINT32 Attributes\r
-        []\r
-    }\r
-  }\r
-\r
-\r
-Header\r
-~~~~~~\r
-  BYTE NID::kHeader (0x01)\r
-\r
-  []\r
-  ArchiveProperties\r
-  []\r
-\r
-  []\r
-  BYTE NID::kAdditionalStreamsInfo; (0x03)\r
-  StreamsInfo\r
-  []\r
-\r
-  []\r
-  BYTE NID::kMainStreamsInfo;    (0x04)\r
-  StreamsInfo\r
-  []\r
-\r
-  []\r
-  FilesInfo\r
-  []\r
-\r
-  BYTE NID::kEnd\r
-\r
-\r
-HeaderInfo\r
-~~~~~~~~~~\r
-  []\r
-  BYTE NID::kEncodedHeader; (0x17)\r
-  StreamsInfo for Encoded Header\r
-  []\r
-\r
-\r
----\r
-End of document\r
diff --git a/deps/lzma-16.04/DOC/Methods.txt b/deps/lzma-16.04/DOC/Methods.txt
deleted file mode 100644 (file)
index 3ca9057..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-7-Zip method IDs for 7z and xz archives\r
----------------------------------------\r
-\r
-Version: 16.03\r
-Date: 2016-09-27\r
-\r
-Each compression or crypto method in 7z is associated with unique binary value (ID).\r
-The length of ID in bytes is arbitrary but it can not exceed 63 bits (8 bytes).\r
-\r
-xz and 7z formats use same ID map.\r
-\r
-If you want to add some new ID, you have two ways:\r
-  1) Write request for allocating IDs to 7-Zip developers.\r
-  2) Generate 8-bytes ID:\r
-\r
-    3F ZZ ZZ ZZ ZZ ZZ MM MM \r
-\r
-    3F              - Prefix for random IDs (1 byte)\r
-    ZZ ZZ ZZ ZZ ZZ  - Developer ID (5 bytes). Use real random bytes. \r
-                      \r
-    MM MM           - Method ID (2 bytes)\r
-\r
-    You can notify 7-Zip developers about your Developer ID / Method ID.\r
-\r
-    Note: Use new ID, if old codec can not decode data encoded with new version.\r
-\r
-\r
-List of defined IDs\r
--------------------\r
-      \r
-00 - Copy\r
-\r
-03 - Delta\r
-04 - BCJ (x86)\r
-05 - PPC (big-endian)\r
-06 - IA64\r
-07 - ARM (little-endian)\r
-08 - ARMT (little-endian)\r
-09 - SPARC\r
-\r
-21 - LZMA2\r
-          \r
-02.. - Common\r
-   03 [Swap]\r
-      - 2 Swap2\r
-      - 4 Swap4\r
-\r
-03.. - 7z\r
-   01 - \r
-      01 - LZMA\r
-  \r
-   03 - [Branch Codecs]\r
-      01 - [x86 Codecs]\r
-         03  - BCJ\r
-         1B  - BCJ2 (4 packed streams)\r
-      02 - \r
-         05 - PPC (big-endian)\r
-      03 - \r
-         01 - Alpha\r
-      04 - \r
-         01 - IA64\r
-      05 - \r
-         01 - ARM (little-endian)\r
-      06 - \r
-         05 - M68 (big-endian)\r
-      07 - \r
-         01 - ARMT (little-endian)\r
-      08 - \r
-         05 - SPARC\r
-\r
-   04 - \r
-      01 - PPMD\r
-\r
-   7F -\r
-      01 - experimental method.\r
-\r
-\r
-04.. - Misc codecs\r
-\r
-   00 - Reserved\r
-\r
-   01 - [Zip]\r
-      00 - Copy (not used. Use {00} instead)\r
-      01 - Shrink\r
-      06 - Implode\r
-      08 - Deflate\r
-      09 - Deflate64\r
-      0A - Imploding\r
-      0C - BZip2 (not used. Use {040202} instead)\r
-      0E - LZMA (LZMA-zip)\r
-      5F - xz\r
-      60 - Jpeg\r
-      61 - WavPack\r
-      62 - PPMd (PPMd-zip)\r
-      63 - wzAES\r
-\r
-   02 - \r
-      02 - BZip2\r
-\r
-   03 - [Rar]\r
-      01 - Rar1\r
-      02 - Rar2\r
-      03 - Rar3\r
-      05 - Rar5\r
-\r
-   04 - [Arj]\r
-      01 - Arj(1,2,3)\r
-      02 - Arj4\r
-\r
-   05 - [Z]\r
-\r
-   06 - [Lzh]\r
-\r
-   07 - Reserved for 7z\r
-\r
-   08 - [Cab]\r
-\r
-   09 - [NSIS]\r
-      01 - DeflateNSIS\r
-      02 - BZip2NSIS\r
-\r
-   F7 - External codecs (that are not included to 7-Zip)\r
-\r
-      0x xx - reserved\r
-      10 xx - reserved (LZHAM)\r
-      11 xx - reserved (Zstd)\r
-\r
-\r
-06.. - Crypto \r
-\r
-   F0 - Ciphers without hashing algo\r
-\r
-      01 - [AES]\r
-         0x - AES-128\r
-         4x - AES-192\r
-         8x - AES-256\r
-         Cx - AES\r
-\r
-         x0 - ECB\r
-         x1 - CBC\r
-         x2 - CFB\r
-         x3 - OFB\r
-         x4 - CTR\r
-\r
-   F1 - Combine Ciphers\r
-\r
-      01 - [Zip]\r
-         01 - ZipCrypto (Main Zip crypto algo)\r
-\r
-      03 - [RAR]\r
-         02 - \r
-         03 - Rar29AES (AES-128 + modified SHA-1)\r
-\r
-      07 - [7z]\r
-         01 - 7zAES (AES-256 + SHA-256)\r
-\r
-\r
----\r
-End of document\r
diff --git a/deps/lzma-16.04/DOC/installer.txt b/deps/lzma-16.04/DOC/installer.txt
deleted file mode 100644 (file)
index 70ad7dc..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-7-Zip for installers 9.38\r
--------------------------\r
-\r
-7-Zip is a file archiver for Windows NT/2000/2003/2008/XP/Vista/7/8/10. \r
-\r
-7-Zip for installers is part of LZMA SDK.\r
-LZMA SDK is written and placed in the public domain by Igor Pavlov.\r
-\r
-It's allowed to join 7-Zip SFX module with another software.\r
-It's allowed to change resources of 7-Zip's SFX modules.\r
-\r
-\r
-HOW to use\r
------------\r
-\r
-7zr.exe is reduced version of 7za.exe of 7-Zip.\r
-7zr.exe supports only format with these codecs: LZMA, LZMA2, BCJ, BCJ2, ARM, Copy.\r
-\r
-Example of compressing command for installation packages:\r
-\r
-7zr a archive.7z files\r
-\r
-7zSD.sfx is SFX module for installers. 7zSD.sfx uses msvcrt.dll.\r
-\r
-SFX modules for installers allow to create installation program. \r
-Such module extracts archive to temp folder and then runs specified program and removes \r
-temp files after program finishing. Self-extract archive for installers must be created \r
-as joining 3 files: SFX_Module, Installer_Config, 7z_Archive. \r
-Installer_Config is optional file. You can use the following command to create installer \r
-self-extract archive:\r
-\r
-copy /b 7zSD.sfx + config.txt + archive.7z archive.exe\r
-\r
-The smallest installation package size can be achieved, if installation files was \r
-uncompressed before including to 7z archive.\r
-\r
--y switch for installer module (at runtime) specifies quiet mode for extracting.\r
-\r
-Installer Config file format\r
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
-Config file contains commands for Installer. File begins from string \r
-;!@Install@!UTF-8! and ends with ;!@InstallEnd@!. File must be written \r
-in UTF-8 encoding. File contains string pairs: \r
-\r
-ID_String="Value"\r
-\r
-ID_String          Description \r
-\r
-Title              Title for messages \r
-BeginPrompt        Begin Prompt message \r
-Progress           Value can be "yes" or "no". Default value is "yes". \r
-RunProgram         Command for executing. Default value is "setup.exe". \r
-                   Substring %%T will be replaced with path to temporary \r
-                   folder, where files were extracted \r
-Directory          Directory prefix for "RunProgram". Default value is ".\\" \r
-ExecuteFile        Name of file for executing \r
-ExecuteParameters  Parameters for "ExecuteFile" \r
-\r
-\r
-You can omit any string pair.\r
-\r
-There are two ways to run program: RunProgram and ExecuteFile. \r
-Use RunProgram, if you want to run some program from .7z archive. \r
-Use ExecuteFile, if you want to open some document from .7z archive or \r
-if you want to execute some command from Windows.\r
-\r
-If you use RunProgram and if you specify empty directory prefix: Directory="", \r
-the system searches for the executable file in the following sequence:\r
-\r
-1. The directory from which the application (installer) loaded. \r
-2. The temporary folder, where files were extracted. \r
-3. The Windows system directory. \r
-\r
-\r
-Config file Examples\r
-~~~~~~~~~~~~~~~~~~~~\r
-\r
-;!@Install@!UTF-8!\r
-Title="7-Zip 4.00"\r
-BeginPrompt="Do you want to install the 7-Zip 4.00?"\r
-RunProgram="setup.exe"\r
-;!@InstallEnd@!\r
-\r
-\r
-\r
-;!@Install@!UTF-8!\r
-Title="7-Zip 4.00"\r
-BeginPrompt="Do you want to install the 7-Zip 4.00?"\r
-ExecuteFile="7zip.msi"\r
-;!@InstallEnd@!\r
-\r
-\r
-\r
-;!@Install@!UTF-8!\r
-Title="7-Zip 4.01 Update"\r
-BeginPrompt="Do you want to install the 7-Zip 4.01 Update?"\r
-ExecuteFile="msiexec.exe"\r
-ExecuteParameters="/i 7zip.msi REINSTALL=ALL REINSTALLMODE=vomus"\r
-;!@InstallEnd@!\r
-\r
-\r
-\r
-Small SFX modules for installers\r
---------------------------------\r
-\r
-7zS2.sfx     - small SFX module (GUI version)\r
-7zS2con.sfx  - small SFX module (Console version)\r
-\r
-Small SFX modules support this codecs: LZMA, LZMA2, BCJ, BCJ2, ARM, COPY\r
-\r
-Small SFX module is similar to common SFX module for installers.\r
-The difference (what's new in small version):\r
- - Smaller size (30 KB vs 100 KB)\r
- - C source code instead of Ã‘++\r
- - No installer Configuration file\r
- - No extracting progress window\r
- - It decompresses solid 7z blocks (it can be whole 7z archive) to RAM.\r
-   So user that calls SFX installer must have free RAM of size of largest \r
-   solid 7z block (size of 7z archive at simplest case).\r
-\r
-How to use\r
-----------\r
-\r
-copy /b 7zS2.sfx + archive.7z sfx.exe\r
-\r
-When you run installer sfx module (sfx.exe)\r
-1) It creates "7zNNNNNNNN" temp folder in system temp folder.\r
-2) It extracts .7z archive to that folder\r
-3) It executes one file from "7zNNNNNNNN" temp folder. \r
-4) It removes "7zNNNNNNNN" temp folder\r
-\r
-You can send parameters to installer, and installer will transfer them to extracted .exe file.\r
-\r
-Small SFX uses 3 levels of priorities to select file to execute:\r
-\r
-  1) Files in root folder have higher priority than files in subfolders.\r
-  2) File extension priorities (from high to low priority order): \r
-       bat, cmd, exe, inf, msi, cab (under Windows CE), html, htm\r
-  3) File name priorities (from high to low priority order): \r
-       setup, install, run, start\r
-\r
-Windows CE (ARM) version of 7zS2.sfx is included to 7-Zip for Windows Mobile package.\r
-\r
-\r
-Examples\r
---------\r
-\r
-1) To create compressed console 7-Zip:\r
-\r
-7zr a c.7z 7z.exe 7z.dll -mx\r
-copy /b 7zS2con.sfx + c.7z 7zCompr.exe\r
-7zCompr.exe b -md22\r
-\r
-\r
-2) To create compressed GUI 7-Zip:\r
-\r
-7zr a g.7z 7zg.exe 7z.dll -mx\r
-copy /b 7zS2.sfx + g.7z 7zgCompr.exe\r
-7zgCompr.exe b -md22\r
-\r
-\r
-3) To open some file:\r
-\r
-7zr a h.7z readme.txt -mx\r
-copy /b 7zS2.sfx + h.7z 7zTxt.exe \r
-7zTxt.exe\r
diff --git a/deps/lzma-16.04/DOC/lzma-history.txt b/deps/lzma-16.04/DOC/lzma-history.txt
deleted file mode 100644 (file)
index 603a9e8..0000000
+++ /dev/null
@@ -1,363 +0,0 @@
-HISTORY of the LZMA SDK\r
------------------------\r
-\r
-16.04          2016-10-04\r
--------------------------\r
-- The bug was fixed in DllSecur.c.\r
-\r
-\r
-16.03          2016-09-28\r
--------------------------\r
-- SFX modules now use some protection against DLL preloading attack.\r
-- Some bugs in 7z code were fixed.\r
-\r
-\r
-16.02          2016-05-21\r
--------------------------\r
-- The BUG in 16.00 - 16.01 was fixed:\r
-  Split Handler (SplitHandler.cpp) returned incorrect \r
-  total size value (kpidSize) for split archives.\r
-\r
-\r
-16.01          2016-05-19\r
--------------------------      \r
-- Some internal changes to reduce the number of compiler warnings.\r
-\r
-\r
-16.00          2016-05-10\r
--------------------------      \r
-- Some bugs were fixed.\r
-\r
-\r
-15.12          2015-11-19\r
--------------------------      \r
-- The BUG in C version of 7z decoder was fixed:\r
-  7zDec.c : SzDecodeLzma2()\r
-  7z decoder could mistakenly report about decoding error for some 7z archives\r
-  that use LZMA2 compression method.\r
-  The probability to get that mistaken decoding error report was about \r
-  one error per 16384 solid blocks for solid blocks larger than 16 KB (compressed size). \r
-- The BUG (in 9.26-15.11) in C version of 7z decoder was fixed:\r
-  7zArcIn.c : SzReadHeader2()\r
-  7z decoder worked incorrectly for 7z archives that contain \r
-  empty solid blocks, that can be placed to 7z archive, if some file is \r
-  unavailable for reading during archive creation.\r
-\r
-\r
-15.09 beta     2015-10-16\r
--------------------------      \r
-- The BUG in LZMA / LZMA2 encoding code was fixed.\r
-  The BUG in LzFind.c::MatchFinder_ReadBlock() function.\r
-  If input data size is larger than (4 GiB - dictionary_size),\r
-  the following code worked incorrectly:\r
-  -  LZMA : LzmaEnc_MemEncode(), LzmaEncode() : LZMA encoding functions \r
-     for compressing from memory to memory. \r
-     That BUG is not related to LZMA encoder version that works via streams.\r
-  -  LZMA2 : multi-threaded version of LZMA2 encoder worked incorrectly, if \r
-     default value of chunk size (CLzma2EncProps::blockSize) is changed \r
-     to value larger than (4 GiB - dictionary_size).\r
-\r
-\r
-9.38 beta      2015-01-03\r
--------------------------      \r
-- The BUG in 9.31-9.37 was fixed:\r
-  IArchiveGetRawProps interface was disabled for 7z archives.\r
-- The BUG in 9.26-9.36 was fixed:\r
-  Some code in CPP\7zip\Archive\7z\ worked correctly only under Windows.\r
-\r
-\r
-9.36 beta      2014-12-26\r
--------------------------      \r
-- The BUG in command line version was fixed:\r
-  7-Zip created temporary archive in current folder during update archive\r
-  operation, if -w{Path} switch was not specified. \r
-  The fixed 7-Zip creates temporary archive in folder that contains updated archive.\r
-- The BUG in 9.33-9.35 was fixed:\r
-  7-Zip silently ignored file reading errors during 7z or gz archive creation,\r
-  and the created archive contained only part of file that was read before error.\r
-  The fixed 7-Zip stops archive creation and it reports about error.\r
-\r
-\r
-9.35 beta      2014-12-07\r
--------------------------      \r
-- 7zr.exe now support AES encryption.\r
-- SFX mudules were added to LZMA SDK\r
-- Some bugs were fixed.\r
-\r
-\r
-9.21 beta      2011-04-11\r
--------------------------      \r
-- New class FString for file names at file systems.\r
-- Speed optimization in CRC code for big-endian CPUs.\r
-- The BUG in Lzma2Dec.c was fixed:\r
-    Lzma2Decode function didn't work.\r
-\r
-\r
-9.18 beta      2010-11-02\r
--------------------------      \r
-- New small SFX module for installers (SfxSetup).\r
-\r
-\r
-9.12 beta      2010-03-24\r
--------------------------\r
-- The BUG in LZMA SDK 9.* was fixed: LZMA2 codec didn't work,\r
-  if more than 10 threads were used (or more than 20 threads in some modes).\r
-\r
-\r
-9.11 beta      2010-03-15\r
--------------------------\r
-- PPMd compression method support\r
-   \r
-\r
-9.09           2009-12-12\r
--------------------------\r
-- The bug was fixed:\r
-   Utf16_To_Utf8 funstions in UTFConvert.cpp and 7zMain.c\r
-   incorrectly converted surrogate characters (the code >= 0x10000) to UTF-8.\r
-- Some bugs were fixed\r
-\r
-\r
-9.06           2009-08-17\r
--------------------------\r
-- Some changes in ANSI-C 7z Decoder interfaces.\r
-\r
-\r
-9.04           2009-05-30\r
--------------------------\r
-- LZMA2 compression method support\r
-- xz format support\r
-\r
-\r
-4.65           2009-02-03\r
--------------------------\r
-- Some minor fixes\r
-\r
-\r
-4.63           2008-12-31\r
--------------------------\r
-- Some minor fixes\r
-\r
-\r
-4.61 beta      2008-11-23\r
--------------------------\r
-- The bug in ANSI-C LZMA Decoder was fixed:\r
-    If encoded stream was corrupted, decoder could access memory \r
-    outside of allocated range.\r
-- Some changes in ANSI-C 7z Decoder interfaces.\r
-- LZMA SDK is placed in the public domain.\r
-\r
-\r
-4.60 beta      2008-08-19\r
--------------------------\r
-- Some minor fixes.\r
-\r
-\r
-4.59 beta      2008-08-13\r
--------------------------\r
-- The bug was fixed:\r
-    LZMA Encoder in fast compression mode could access memory outside of \r
-    allocated range in some rare cases.\r
-\r
-\r
-4.58 beta      2008-05-05\r
--------------------------\r
-- ANSI-C LZMA Decoder was rewritten for speed optimizations.\r
-- ANSI-C LZMA Encoder was included to LZMA SDK.\r
-- C++ LZMA code now is just wrapper over ANSI-C code.\r
-\r
-\r
-4.57           2007-12-12\r
--------------------------\r
-- Speed optimizations in Ã‘++ LZMA Decoder. \r
-- Small changes for more compatibility with some C/C++ compilers.\r
-\r
-\r
-4.49 beta      2007-07-05\r
--------------------------\r
-- .7z ANSI-C Decoder:\r
-     - now it supports BCJ and BCJ2 filters\r
-     - now it supports files larger than 4 GB.\r
-     - now it supports "Last Write Time" field for files.\r
-- C++ code for .7z archives compressing/decompressing from 7-zip \r
-  was included to LZMA SDK.\r
-  \r
-\r
-4.43           2006-06-04\r
--------------------------\r
-- Small changes for more compatibility with some C/C++ compilers.\r
-  \r
-\r
-4.42           2006-05-15\r
--------------------------\r
-- Small changes in .h files in ANSI-C version.\r
-  \r
-\r
-4.39 beta      2006-04-14\r
--------------------------\r
-- The bug in versions 4.33b:4.38b was fixed:\r
-  C++ version of LZMA encoder could not correctly compress \r
-  files larger than 2 GB with HC4 match finder (-mfhc4).\r
-  \r
-\r
-4.37 beta      2005-04-06\r
--------------------------\r
-- Fixes in C++ code: code could no be compiled if _NO_EXCEPTIONS was defined. \r
-\r
-\r
-4.35 beta      2005-03-02\r
--------------------------\r
-- The bug was fixed in C++ version of LZMA Decoder:\r
-    If encoded stream was corrupted, decoder could access memory \r
-    outside of allocated range.\r
-\r
-\r
-4.34 beta      2006-02-27\r
--------------------------\r
-- Compressing speed and memory requirements for compressing were increased\r
-- LZMA now can use only these match finders: HC4, BT2, BT3, BT4\r
-\r
-\r
-4.32           2005-12-09\r
--------------------------\r
-- Java version of LZMA SDK was included\r
-\r
-\r
-4.30           2005-11-20\r
--------------------------\r
-- Compression ratio was improved in -a2 mode\r
-- Speed optimizations for compressing in -a2 mode\r
-- -fb switch now supports values up to 273\r
-- The bug in 7z_C (7zIn.c) was fixed:\r
-  It used Alloc/Free functions from different memory pools.\r
-  So if program used two memory pools, it worked incorrectly.\r
-- 7z_C: .7z format supporting was improved\r
-- LZMA# SDK (C#.NET version) was included\r
-\r
-\r
-4.27 (Updated) 2005-09-21\r
--------------------------\r
-- Some GUIDs/interfaces in C++ were changed.\r
- IStream.h:\r
-   ISequentialInStream::Read now works as old ReadPart\r
-   ISequentialOutStream::Write now works as old WritePart\r
-\r
-\r
-4.27           2005-08-07\r
--------------------------\r
-- The bug in LzmaDecodeSize.c was fixed:\r
-   if _LZMA_IN_CB and _LZMA_OUT_READ were defined,\r
-   decompressing worked incorrectly.\r
-\r
-\r
-4.26           2005-08-05\r
--------------------------\r
-- Fixes in 7z_C code and LzmaTest.c:\r
-  previous versions could work incorrectly,\r
-  if malloc(0) returns 0\r
-\r
-\r
-4.23           2005-06-29\r
--------------------------\r
-- Small fixes in C++ code\r
-\r
-\r
-4.22           2005-06-10\r
--------------------------\r
-- Small fixes\r
-\r
-\r
-4.21           2005-06-08\r
--------------------------\r
-- Interfaces for ANSI-C LZMA Decoder (LzmaDecode.c) were changed\r
-- New additional version of ANSI-C LZMA Decoder with zlib-like interface:\r
-    - LzmaStateDecode.h\r
-    - LzmaStateDecode.c\r
-    - LzmaStateTest.c\r
-- ANSI-C LZMA Decoder now can decompress files larger than 4 GB\r
-\r
-\r
-4.17           2005-04-18\r
--------------------------\r
-- New example for RAM->RAM compressing/decompressing: \r
-  LZMA + BCJ (filter for x86 code):\r
-    - LzmaRam.h\r
-    - LzmaRam.cpp\r
-    - LzmaRamDecode.h\r
-    - LzmaRamDecode.c\r
-    - -f86 switch for lzma.exe\r
-\r
-\r
-4.16           2005-03-29\r
--------------------------\r
-- The bug was fixed in LzmaDecode.c (ANSI-C LZMA Decoder): \r
-   If _LZMA_OUT_READ was defined, and if encoded stream was corrupted,\r
-   decoder could access memory outside of allocated range.\r
-- Speed optimization of ANSI-C LZMA Decoder (now it's about 20% faster).\r
-  Old version of LZMA Decoder now is in file LzmaDecodeSize.c. \r
-  LzmaDecodeSize.c can provide slightly smaller code than LzmaDecode.c\r
-- Small speed optimization in LZMA C++ code\r
-- filter for SPARC's code was added\r
-- Simplified version of .7z ANSI-C Decoder was included\r
-\r
-\r
-4.06           2004-09-05\r
--------------------------\r
-- The bug in v4.05 was fixed:\r
-    LZMA-Encoder didn't release output stream in some cases.\r
-\r
-\r
-4.05           2004-08-25\r
--------------------------\r
-- Source code of filters for x86, IA-64, ARM, ARM-Thumb \r
-  and PowerPC code was included to SDK\r
-- Some internal minor changes\r
-\r
-\r
-4.04           2004-07-28\r
--------------------------\r
-- More compatibility with some C++ compilers\r
-\r
-\r
-4.03           2004-06-18\r
--------------------------\r
-- "Benchmark" command was added. It measures compressing \r
-  and decompressing speed and shows rating values. \r
-  Also it checks hardware errors.\r
-\r
-\r
-4.02           2004-06-10\r
--------------------------\r
-- C++ LZMA Encoder/Decoder code now is more portable\r
-  and it can be compiled by GCC on Linux.\r
-\r
-\r
-4.01           2004-02-15\r
--------------------------\r
-- Some detection of data corruption was enabled.\r
-    LzmaDecode.c / RangeDecoderReadByte\r
-    .....\r
-    {\r
-      rd->ExtraBytes = 1;\r
-      return 0xFF;\r
-    }\r
-\r
-\r
-4.00           2004-02-13\r
--------------------------\r
-- Original version of LZMA SDK\r
-\r
-\r
-\r
-HISTORY of the LZMA\r
--------------------\r
-  2001-2008:  Improvements to LZMA compressing/decompressing code, \r
-              keeping compatibility with original LZMA format\r
-  1996-2001:  Development of LZMA compression format\r
-\r
-  Some milestones:\r
-\r
-  2001-08-30: LZMA compression was added to 7-Zip\r
-  1999-01-02: First version of 7-Zip was released\r
-  \r
-\r
-End of document\r
diff --git a/deps/lzma-16.04/DOC/lzma-sdk.txt b/deps/lzma-16.04/DOC/lzma-sdk.txt
deleted file mode 100644 (file)
index 86fef24..0000000
+++ /dev/null
@@ -1,357 +0,0 @@
-LZMA SDK 16.04\r
---------------\r
-\r
-LZMA SDK provides the documentation, samples, header files,\r
-libraries, and tools you need to develop applications that \r
-use 7z / LZMA / LZMA2 / XZ compression.\r
-\r
-LZMA is an improved version of famous LZ77 compression algorithm. \r
-It was improved in way of maximum increasing of compression ratio,\r
-keeping high decompression speed and low memory requirements for \r
-decompressing.\r
-\r
-LZMA2 is a LZMA based compression method. LZMA2 provides better \r
-multithreading support for compression than LZMA and some other improvements.\r
-\r
-7z is a file format for data compression and file archiving.\r
-7z is a main file format for 7-Zip compression program (www.7-zip.org).\r
-7z format supports different compression methods: LZMA, LZMA2 and others.\r
-7z also supports AES-256 based encryption.\r
-\r
-XZ is a file format for data compression that uses LZMA2 compression.\r
-XZ format provides additional features: SHA/CRC check, filters for \r
-improved compression ratio, splitting to blocks and streams,\r
-\r
-\r
-\r
-LICENSE\r
--------\r
-\r
-LZMA SDK is written and placed in the public domain by Igor Pavlov.\r
-\r
-Some code in LZMA SDK is based on public domain code from another developers:\r
-  1) PPMd var.H (2001): Dmitry Shkarin\r
-  2) SHA-256: Wei Dai (Crypto++ library)\r
-\r
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute the \r
-original LZMA SDK code, either in source code form or as a compiled binary, for \r
-any purpose, commercial or non-commercial, and by any means.\r
-\r
-LZMA SDK code is compatible with open source licenses, for example, you can \r
-include it to GNU GPL or GNU LGPL code.\r
-\r
-\r
-LZMA SDK Contents\r
------------------\r
-\r
-  Source code:\r
-\r
-    - C / C++ / C# / Java   - LZMA compression and decompression\r
-    - C / C++               - LZMA2 compression and decompression\r
-    - C / C++               - XZ compression and decompression\r
-    - C                     - 7z decompression\r
-    -     C++               - 7z compression and decompression\r
-    - C                     - small SFXs for installers (7z decompression)\r
-    -     C++               - SFXs and SFXs for installers (7z decompression)\r
-\r
-  Precomiled binaries:\r
-\r
-    - console programs for lzma / 7z / xz compression and decompression\r
-    - SFX modules for installers.\r
-\r
-\r
-UNIX/Linux version \r
-------------------\r
-To compile C++ version of file->file LZMA encoding, go to directory\r
-CPP/7zip/Bundles/LzmaCon\r
-and call make to recompile it:\r
-  make -f makefile.gcc clean all\r
-\r
-In some UNIX/Linux versions you must compile LZMA with static libraries.\r
-To compile with static libraries, you can use \r
-LIB = -lm -static\r
-\r
-Also you can use p7zip (port of 7-Zip for POSIX systems like Unix or Linux):\r
-  \r
-  http://p7zip.sourceforge.net/\r
-\r
-\r
-Files\r
------\r
-\r
-DOC/7zC.txt          - 7z ANSI-C Decoder description\r
-DOC/7zFormat.txt     - 7z Format description\r
-DOC/installer.txt    - information about 7-Zip for installers\r
-DOC/lzma.txt         - LZMA compression description\r
-DOC/lzma-sdk.txt     - LZMA SDK description (this file)\r
-DOC/lzma-history.txt - history of LZMA SDK\r
-DOC/lzma-specification.txt - Specification of LZMA\r
-DOC/Methods.txt      - Compression method IDs for .7z\r
-\r
-bin/installer/   - example script to create installer that uses SFX module,\r
-\r
-bin/7zdec.exe    - simplified 7z archive decoder\r
-bin/7zr.exe      - 7-Zip console program (reduced version)\r
-bin/x64/7zr.exe  - 7-Zip console program (reduced version) (x64 version)\r
-bin/lzma.exe     - file->file LZMA encoder/decoder for Windows\r
-bin/7zS2.sfx     - small SFX module for installers (GUI version)\r
-bin/7zS2con.sfx  - small SFX module for installers (Console version)\r
-bin/7zSD.sfx     - SFX module for installers.\r
-\r
-\r
-7zDec.exe\r
----------\r
-7zDec.exe is simplified 7z archive decoder.\r
-It supports only LZMA, LZMA2, and PPMd methods.\r
-7zDec decodes whole solid block from 7z archive to RAM.\r
-The RAM consumption can be high.\r
-\r
-\r
-\r
-\r
-Source code structure\r
----------------------\r
-\r
-\r
-Asm/ - asm files (optimized code for CRC calculation and Intel-AES encryption)\r
-\r
-C/  - C files (compression / decompression and other)\r
-  Util/\r
-    7z       - 7z decoder program (decoding 7z files)\r
-    Lzma     - LZMA program (file->file LZMA encoder/decoder).\r
-    LzmaLib  - LZMA library (.DLL for Windows)\r
-    SfxSetup - small SFX module for installers \r
-\r
-CPP/ -- CPP files\r
-\r
-  Common  - common files for C++ projects\r
-  Windows - common files for Windows related code\r
-\r
-  7zip    - files related to 7-Zip\r
-\r
-    Archive - files related to archiving\r
-\r
-      Common   - common files for archive handling\r
-      7z       - 7z C++ Encoder/Decoder\r
-\r
-    Bundles  - Modules that are bundles of other modules (files)\r
-  \r
-      Alone7z       - 7zr.exe: Standalone 7-Zip console program (reduced version)\r
-      Format7zExtractR  - 7zxr.dll: Reduced version of 7z DLL: extracting from 7z/LZMA/BCJ/BCJ2.\r
-      Format7zR         - 7zr.dll:  Reduced version of 7z DLL: extracting/compressing to 7z/LZMA/BCJ/BCJ2\r
-      LzmaCon       - lzma.exe: LZMA compression/decompression\r
-      LzmaSpec      - example code for LZMA Specification\r
-      SFXCon        - 7zCon.sfx: Console 7z SFX module\r
-      SFXSetup      - 7zS.sfx: 7z SFX module for installers\r
-      SFXWin        - 7z.sfx: GUI 7z SFX module\r
-\r
-    Common   - common files for 7-Zip\r
-\r
-    Compress - files for compression/decompression\r
-\r
-    Crypto   - files for encryption / decompression\r
-\r
-    UI       - User Interface files\r
-         \r
-      Client7z - Test application for 7za.dll, 7zr.dll, 7zxr.dll\r
-      Common   - Common UI files\r
-      Console  - Code for console program (7z.exe)\r
-      Explorer    - Some code from 7-Zip Shell extension\r
-      FileManager - Some GUI code from 7-Zip File Manager\r
-      GUI         - Some GUI code from 7-Zip\r
-\r
-\r
-CS/ - C# files\r
-  7zip\r
-    Common   - some common files for 7-Zip\r
-    Compress - files related to compression/decompression\r
-      LZ     - files related to LZ (Lempel-Ziv) compression algorithm\r
-      LZMA         - LZMA compression/decompression\r
-      LzmaAlone    - file->file LZMA compression/decompression\r
-      RangeCoder   - Range Coder (special code of compression/decompression)\r
-\r
-Java/  - Java files\r
-  SevenZip\r
-    Compression    - files related to compression/decompression\r
-      LZ           - files related to LZ (Lempel-Ziv) compression algorithm\r
-      LZMA         - LZMA compression/decompression\r
-      RangeCoder   - Range Coder (special code of compression/decompression)\r
-\r
-\r
-Note: \r
-  Asm / C / C++ source code of LZMA SDK is part of 7-Zip's source code.\r
-  7-Zip's source code can be downloaded from 7-Zip's SourceForge page:\r
-\r
-  http://sourceforge.net/projects/sevenzip/\r
-\r
-\r
-\r
-LZMA features\r
--------------\r
-  - Variable dictionary size (up to 1 GB)\r
-  - Estimated compressing speed: about 2 MB/s on 2 GHz CPU\r
-  - Estimated decompressing speed: \r
-      - 20-30 MB/s on modern 2 GHz cpu\r
-      - 1-2 MB/s on 200 MHz simple RISC cpu: (ARM, MIPS, PowerPC)\r
-  - Small memory requirements for decompressing (16 KB + DictionarySize)\r
-  - Small code size for decompressing: 5-8 KB\r
-\r
-LZMA decoder uses only integer operations and can be \r
-implemented in any modern 32-bit CPU (or on 16-bit CPU with some conditions).\r
-\r
-Some critical operations that affect the speed of LZMA decompression:\r
-  1) 32*16 bit integer multiply\r
-  2) Mispredicted branches (penalty mostly depends from pipeline length)\r
-  3) 32-bit shift and arithmetic operations\r
-\r
-The speed of LZMA decompressing mostly depends from CPU speed.\r
-Memory speed has no big meaning. But if your CPU has small data cache, \r
-overall weight of memory speed will slightly increase.\r
-\r
-\r
-How To Use\r
-----------\r
-\r
-Using LZMA encoder/decoder executable\r
---------------------------------------\r
-\r
-Usage:  LZMA <e|d> inputFile outputFile [<switches>...]\r
-\r
-  e: encode file\r
-\r
-  d: decode file\r
-\r
-  b: Benchmark. There are two tests: compressing and decompressing \r
-     with LZMA method. Benchmark shows rating in MIPS (million \r
-     instructions per second). Rating value is calculated from \r
-     measured speed and it is normalized with Intel's Core 2 results.\r
-     Also Benchmark checks possible hardware errors (RAM \r
-     errors in most cases). Benchmark uses these settings:\r
-     (-a1, -d21, -fb32, -mfbt4). You can change only -d parameter. \r
-     Also you can change the number of iterations. Example for 30 iterations:\r
-       LZMA b 30\r
-     Default number of iterations is 10.\r
-\r
-<Switches>\r
-  \r
-\r
-  -a{N}:  set compression mode 0 = fast, 1 = normal\r
-          default: 1 (normal)\r
-\r
-  d{N}:   Sets Dictionary size - [0, 30], default: 23 (8MB)\r
-          The maximum value for dictionary size is 1 GB = 2^30 bytes.\r
-          Dictionary size is calculated as DictionarySize = 2^N bytes. \r
-          For decompressing file compressed by LZMA method with dictionary \r
-          size D = 2^N you need about D bytes of memory (RAM).\r
-\r
-  -fb{N}: set number of fast bytes - [5, 273], default: 128\r
-          Usually big number gives a little bit better compression ratio \r
-          and slower compression process.\r
-\r
-  -lc{N}: set number of literal context bits - [0, 8], default: 3\r
-          Sometimes lc=4 gives gain for big files.\r
-\r
-  -lp{N}: set number of literal pos bits - [0, 4], default: 0\r
-          lp switch is intended for periodical data when period is \r
-          equal 2^N. For example, for 32-bit (4 bytes) \r
-          periodical data you can use lp=2. Often it's better to set lc0, \r
-          if you change lp switch.\r
-\r
-  -pb{N}: set number of pos bits - [0, 4], default: 2\r
-          pb switch is intended for periodical data \r
-          when period is equal 2^N.\r
-\r
-  -mf{MF_ID}: set Match Finder. Default: bt4. \r
-              Algorithms from hc* group doesn't provide good compression \r
-              ratio, but they often works pretty fast in combination with \r
-              fast mode (-a0).\r
-\r
-              Memory requirements depend from dictionary size \r
-              (parameter "d" in table below). \r
-\r
-               MF_ID     Memory                   Description\r
-\r
-                bt2    d *  9.5 + 4MB  Binary Tree with 2 bytes hashing.\r
-                bt3    d * 11.5 + 4MB  Binary Tree with 3 bytes hashing.\r
-                bt4    d * 11.5 + 4MB  Binary Tree with 4 bytes hashing.\r
-                hc4    d *  7.5 + 4MB  Hash Chain with 4 bytes hashing.\r
-\r
-  -eos:   write End Of Stream marker. By default LZMA doesn't write \r
-          eos marker, since LZMA decoder knows uncompressed size \r
-          stored in .lzma file header.\r
-\r
-  -si:    Read data from stdin (it will write End Of Stream marker).\r
-  -so:    Write data to stdout\r
-\r
-\r
-Examples:\r
-\r
-1) LZMA e file.bin file.lzma -d16 -lc0 \r
-\r
-compresses file.bin to file.lzma with 64 KB dictionary (2^16=64K)  \r
-and 0 literal context bits. -lc0 allows to reduce memory requirements \r
-for decompression.\r
-\r
-\r
-2) LZMA e file.bin file.lzma -lc0 -lp2\r
-\r
-compresses file.bin to file.lzma with settings suitable \r
-for 32-bit periodical data (for example, ARM or MIPS code).\r
-\r
-3) LZMA d file.lzma file.bin\r
-\r
-decompresses file.lzma to file.bin.\r
-\r
-\r
-Compression ratio hints\r
------------------------\r
-\r
-Recommendations\r
----------------\r
-\r
-To increase the compression ratio for LZMA compressing it's desirable \r
-to have aligned data (if it's possible) and also it's desirable to locate\r
-data in such order, where code is grouped in one place and data is \r
-grouped in other place (it's better than such mixing: code, data, code,\r
-data, ...).\r
-\r
-\r
-Filters\r
--------\r
-You can increase the compression ratio for some data types, using\r
-special filters before compressing. For example, it's possible to \r
-increase the compression ratio on 5-10% for code for those CPU ISAs: \r
-x86, IA-64, ARM, ARM-Thumb, PowerPC, SPARC.\r
-\r
-You can find C source code of such filters in C/Bra*.* files\r
-\r
-You can check the compression ratio gain of these filters with such \r
-7-Zip commands (example for ARM code):\r
-No filter:\r
-  7z a a1.7z a.bin -m0=lzma\r
-\r
-With filter for little-endian ARM code:\r
-  7z a a2.7z a.bin -m0=arm -m1=lzma        \r
-\r
-It works in such manner:\r
-Compressing    = Filter_encoding + LZMA_encoding\r
-Decompressing  = LZMA_decoding + Filter_decoding\r
-\r
-Compressing and decompressing speed of such filters is very high,\r
-so it will not increase decompressing time too much.\r
-Moreover, it reduces decompression time for LZMA_decoding, \r
-since compression ratio with filtering is higher.\r
-\r
-These filters convert CALL (calling procedure) instructions \r
-from relative offsets to absolute addresses, so such data becomes more \r
-compressible.\r
-\r
-For some ISAs (for example, for MIPS) it's impossible to get gain from such filter.\r
-\r
-\r
-\r
----\r
-\r
-http://www.7-zip.org\r
-http://www.7-zip.org/sdk.html\r
-http://www.7-zip.org/support.html\r
diff --git a/deps/lzma-16.04/DOC/lzma-specification.txt b/deps/lzma-16.04/DOC/lzma-specification.txt
deleted file mode 100644 (file)
index b6796df..0000000
+++ /dev/null
@@ -1,1176 +0,0 @@
-LZMA specification (DRAFT version)\r
-----------------------------------\r
-\r
-Author: Igor Pavlov\r
-Date: 2015-06-14\r
-\r
-This specification defines the format of LZMA compressed data and lzma file format.\r
-\r
-Notation \r
---------\r
-\r
-We use the syntax of C++ programming language.\r
-We use the following types in C++ code:\r
-  unsigned - unsigned integer, at least 16 bits in size\r
-  int      - signed integer, at least 16 bits in size\r
-  UInt64   - 64-bit unsigned integer\r
-  UInt32   - 32-bit unsigned integer\r
-  UInt16   - 16-bit unsigned integer\r
-  Byte     - 8-bit unsigned integer\r
-  bool     - boolean type with two possible values: false, true\r
-\r
-\r
-lzma file format\r
-================\r
-\r
-The lzma file contains the raw LZMA stream and the header with related properties.\r
-\r
-The files in that format use ".lzma" extension.\r
-\r
-The lzma file format layout:\r
-\r
-Offset Size Description\r
-\r
-  0     1   LZMA model properties (lc, lp, pb) in encoded form\r
-  1     4   Dictionary size (32-bit unsigned integer, little-endian)\r
-  5     8   Uncompressed size (64-bit unsigned integer, little-endian)\r
- 13         Compressed data (LZMA stream)\r
-\r
-LZMA properties:\r
-\r
-    name  Range          Description\r
-\r
-      lc  [0, 8]         the number of "literal context" bits\r
-      lp  [0, 4]         the number of "literal pos" bits\r
-      pb  [0, 4]         the number of "pos" bits\r
-dictSize  [0, 2^32 - 1]  the dictionary size \r
-\r
-The following code encodes LZMA properties:\r
-\r
-void EncodeProperties(Byte *properties)\r
-{\r
-  properties[0] = (Byte)((pb * 5 + lp) * 9 + lc);\r
-  Set_UInt32_LittleEndian(properties + 1, dictSize);\r
-}\r
-\r
-If the value of dictionary size in properties is smaller than (1 << 12),\r
-the LZMA decoder must set the dictionary size variable to (1 << 12).\r
-\r
-#define LZMA_DIC_MIN (1 << 12)\r
-\r
-  unsigned lc, pb, lp;\r
-  UInt32 dictSize;\r
-  UInt32 dictSizeInProperties;\r
-\r
-  void DecodeProperties(const Byte *properties)\r
-  {\r
-    unsigned d = properties[0];\r
-    if (d >= (9 * 5 * 5))\r
-      throw "Incorrect LZMA properties";\r
-    lc = d % 9;\r
-    d /= 9;\r
-    pb = d / 5;\r
-    lp = d % 5;\r
-    dictSizeInProperties = 0;\r
-    for (int i = 0; i < 4; i++)\r
-      dictSizeInProperties |= (UInt32)properties[i + 1] << (8 * i);\r
-    dictSize = dictSizeInProperties;\r
-    if (dictSize < LZMA_DIC_MIN)\r
-      dictSize = LZMA_DIC_MIN;\r
-  }\r
-\r
-If "Uncompressed size" field contains ones in all 64 bits, it means that\r
-uncompressed size is unknown and there is the "end marker" in stream,\r
-that indicates the end of decoding point.\r
-In opposite case, if the value from "Uncompressed size" field is not\r
-equal to ((2^64) - 1), the LZMA stream decoding must be finished after\r
-specified number of bytes (Uncompressed size) is decoded. And if there \r
-is the "end marker", the LZMA decoder must read that marker also.\r
-\r
-\r
-The new scheme to encode LZMA properties\r
-----------------------------------------\r
-\r
-If LZMA compression is used for some another format, it's recommended to\r
-use a new improved scheme to encode LZMA properties. That new scheme was\r
-used in xz format that uses the LZMA2 compression algorithm.\r
-The LZMA2 is a new compression algorithm that is based on the LZMA algorithm.\r
-\r
-The dictionary size in LZMA2 is encoded with just one byte and LZMA2 supports\r
-only reduced set of dictionary sizes:\r
-  (2 << 11), (3 << 11),\r
-  (2 << 12), (3 << 12),\r
-  ...\r
-  (2 << 30), (3 << 30),\r
-  (2 << 31) - 1\r
-\r
-The dictionary size can be extracted from encoded value with the following code:\r
-\r
-  dictSize = (p == 40) ? 0xFFFFFFFF : (((UInt32)2 | ((p) & 1)) << ((p) / 2 + 11));\r
-\r
-Also there is additional limitation (lc + lp <= 4) in LZMA2 for values of \r
-"lc" and "lp" properties:\r
-\r
-  if (lc + lp > 4)\r
-    throw "Unsupported properties: (lc + lp) > 4";\r
-\r
-There are some advantages for LZMA decoder with such (lc + lp) value\r
-limitation. It reduces the maximum size of tables allocated by decoder.\r
-And it reduces the complexity of initialization procedure, that can be \r
-important to keep high speed of decoding of big number of small LZMA streams.\r
-\r
-It's recommended to use that limitation (lc + lp <= 4) for any new format\r
-that uses LZMA compression. Note that the combinations of "lc" and "lp" \r
-parameters, where (lc + lp > 4), can provide significant improvement in \r
-compression ratio only in some rare cases.\r
-\r
-The LZMA properties can be encoded into two bytes in new scheme:\r
-\r
-Offset Size Description\r
-\r
-  0     1   The dictionary size encoded with LZMA2 scheme\r
-  1     1   LZMA model properties (lc, lp, pb) in encoded form\r
-\r
-\r
-The RAM usage \r
-=============\r
-\r
-The RAM usage for LZMA decoder is determined by the following parts:\r
-\r
-1) The Sliding Window (from 4 KiB to 4 GiB).\r
-2) The probability model counter arrays (arrays of 16-bit variables).\r
-3) Some additional state variables (about 10 variables of 32-bit integers).\r
-\r
-\r
-The RAM usage for Sliding Window\r
---------------------------------\r
-\r
-There are two main scenarios of decoding:\r
-\r
-1) The decoding of full stream to one RAM buffer.\r
-\r
-  If we decode full LZMA stream to one output buffer in RAM, the decoder \r
-  can use that output buffer as sliding window. So the decoder doesn't \r
-  need additional buffer allocated for sliding window.\r
-\r
-2) The decoding to some external storage.\r
-\r
-  If we decode LZMA stream to external storage, the decoder must allocate\r
-  the buffer for sliding window. The size of that buffer must be equal \r
-  or larger than the value of dictionary size from properties of LZMA stream.\r
-\r
-In this specification we describe the code for decoding to some external\r
-storage. The optimized version of code for decoding of full stream to one\r
-output RAM buffer can require some minor changes in code.\r
-\r
-\r
-The RAM usage for the probability model counters\r
-------------------------------------------------\r
-\r
-The size of the probability model counter arrays is calculated with the \r
-following formula:\r
-\r
-size_of_prob_arrays = 1846 + 768 * (1 << (lp + lc))\r
-\r
-Each probability model counter is 11-bit unsigned integer.\r
-If we use 16-bit integer variables (2-byte integers) for these probability \r
-model counters, the RAM usage required by probability model counter arrays \r
-can be estimated with the following formula:\r
-\r
-  RAM = 4 KiB + 1.5 KiB * (1 << (lp + lc))\r
-\r
-For example, for default LZMA parameters (lp = 0 and lc = 3), the RAM usage is\r
-\r
-  RAM_lc3_lp0 = 4 KiB + 1.5 KiB * 8 = 16 KiB\r
-\r
-The maximum RAM state usage is required for decoding the stream with lp = 4 \r
-and lc = 8:\r
-\r
-  RAM_lc8_lp4 = 4 KiB + 1.5 KiB * 4096 = 6148 KiB\r
-\r
-If the decoder uses LZMA2's limited property condition \r
-(lc + lp <= 4), the RAM usage will be not larger than\r
-\r
-  RAM_lc_lp_4 = 4 KiB + 1.5 KiB * 16 = 28 KiB\r
-\r
-\r
-The RAM usage for encoder\r
--------------------------\r
-\r
-There are many variants for LZMA encoding code.\r
-These variants have different values for memory consumption.\r
-Note that memory consumption for LZMA Encoder can not be \r
-smaller than memory consumption of LZMA Decoder for same stream.\r
-\r
-The RAM usage required by modern effective implementation of \r
-LZMA Encoder can be estimated with the following formula:\r
-\r
-  Encoder_RAM_Usage = 4 MiB + 11 * dictionarySize.\r
-\r
-But there are some modes of the encoder that require less memory.\r
-\r
-\r
-LZMA Decoding\r
-=============\r
-\r
-The LZMA compression algorithm uses LZ-based compression with Sliding Window\r
-and Range Encoding as entropy coding method.\r
-\r
-\r
-Sliding Window\r
---------------\r
-\r
-LZMA uses Sliding Window compression similar to LZ77 algorithm.\r
-\r
-LZMA stream must be decoded to the sequence that consists\r
-of MATCHES and LITERALS:\r
-  \r
-  - a LITERAL is a 8-bit character (one byte).\r
-    The decoder just puts that LITERAL to the uncompressed stream.\r
-  \r
-  - a MATCH is a pair of two numbers (DISTANCE-LENGTH pair).\r
-    The decoder takes one byte exactly "DISTANCE" characters behind\r
-    current position in the uncompressed stream and puts it to \r
-    uncompressed stream. The decoder must repeat it "LENGTH" times.\r
-\r
-The "DISTANCE" can not be larger than dictionary size.\r
-And the "DISTANCE" can not be larger than the number of bytes in\r
-the uncompressed stream that were decoded before that match.\r
-\r
-In this specification we use cyclic buffer to implement Sliding Window\r
-for LZMA decoder:\r
-\r
-class COutWindow\r
-{\r
-  Byte *Buf;\r
-  UInt32 Pos;\r
-  UInt32 Size;\r
-  bool IsFull;\r
-\r
-public:\r
-  unsigned TotalPos;\r
-  COutStream OutStream;\r
-\r
-  COutWindow(): Buf(NULL) {}\r
-  ~COutWindow() { delete []Buf; }\r
\r
-  void Create(UInt32 dictSize)\r
-  {\r
-    Buf = new Byte[dictSize];\r
-    Pos = 0;\r
-    Size = dictSize;\r
-    IsFull = false;\r
-    TotalPos = 0;\r
-  }\r
-\r
-  void PutByte(Byte b)\r
-  {\r
-    TotalPos++;\r
-    Buf[Pos++] = b;\r
-    if (Pos == Size)\r
-    {\r
-      Pos = 0;\r
-      IsFull = true;\r
-    }\r
-    OutStream.WriteByte(b);\r
-  }\r
-\r
-  Byte GetByte(UInt32 dist) const\r
-  {\r
-    return Buf[dist <= Pos ? Pos - dist : Size - dist + Pos];\r
-  }\r
-\r
-  void CopyMatch(UInt32 dist, unsigned len)\r
-  {\r
-    for (; len > 0; len--)\r
-      PutByte(GetByte(dist));\r
-  }\r
-\r
-  bool CheckDistance(UInt32 dist) const\r
-  {\r
-    return dist <= Pos || IsFull;\r
-  }\r
-\r
-  bool IsEmpty() const\r
-  {\r
-    return Pos == 0 && !IsFull;\r
-  }\r
-};\r
-\r
-\r
-In another implementation it's possible to use one buffer that contains \r
-Sliding Window and the whole data stream after uncompressing.\r
-\r
-\r
-Range Decoder\r
--------------\r
-\r
-LZMA algorithm uses Range Encoding (1) as entropy coding method.\r
-\r
-LZMA stream contains just one very big number in big-endian encoding.\r
-LZMA decoder uses the Range Decoder to extract a sequence of binary\r
-symbols from that big number.\r
-\r
-The state of the Range Decoder:\r
-\r
-struct CRangeDecoder\r
-{\r
-  UInt32 Range; \r
-  UInt32 Code;\r
-  InputStream *InStream;\r
-\r
-  bool Corrupted;\r
-}\r
-\r
-The notes about UInt32 type for the "Range" and "Code" variables:\r
-\r
-  It's possible to use 64-bit (unsigned or signed) integer type\r
-  for the "Range" and the "Code" variables instead of 32-bit unsigned,\r
-  but some additional code must be used to truncate the values to \r
-  low 32-bits after some operations.\r
-\r
-  If the programming language does not support 32-bit unsigned integer type \r
-  (like in case of JAVA language), it's possible to use 32-bit signed integer, \r
-  but some code must be changed. For example, it's required to change the code\r
-  that uses comparison operations for UInt32 variables in this specification.\r
-\r
-The Range Decoder can be in some states that can be treated as \r
-"Corruption" in LZMA stream. The Range Decoder uses the variable "Corrupted":\r
-\r
-  (Corrupted == false), if the Range Decoder has not detected any corruption.\r
-  (Corrupted == true), if the Range Decoder has detected some corruption.\r
-\r
-The reference LZMA Decoder ignores the value of the "Corrupted" variable.\r
-So it continues to decode the stream, even if the corruption can be detected\r
-in the Range Decoder. To provide the full compatibility with output of the \r
-reference LZMA Decoder, another LZMA Decoder implementations must also \r
-ignore the value of the "Corrupted" variable.\r
-\r
-The LZMA Encoder is required to create only such LZMA streams, that will not \r
-lead the Range Decoder to states, where the "Corrupted" variable is set to true.\r
-\r
-The Range Decoder reads first 5 bytes from input stream to initialize\r
-the state:\r
-\r
-bool CRangeDecoder::Init()\r
-{\r
-  Corrupted = false;\r
-  Range = 0xFFFFFFFF;\r
-  Code = 0;\r
-\r
-  Byte b = InStream->ReadByte();\r
-  \r
-  for (int i = 0; i < 4; i++)\r
-    Code = (Code << 8) | InStream->ReadByte();\r
-  \r
-  if (b != 0 || Code == Range)\r
-    Corrupted = true;\r
-  return b == 0;\r
-}\r
-\r
-The LZMA Encoder always writes ZERO in initial byte of compressed stream.\r
-That scheme allows to simplify the code of the Range Encoder in the \r
-LZMA Encoder. If initial byte is not equal to ZERO, the LZMA Decoder must\r
-stop decoding and report error.\r
-\r
-After the last bit of data was decoded by Range Decoder, the value of the\r
-"Code" variable must be equal to 0. The LZMA Decoder must check it by \r
-calling the IsFinishedOK() function:\r
-\r
-  bool IsFinishedOK() const { return Code == 0; }\r
-\r
-If there is corruption in data stream, there is big probability that\r
-the "Code" value will be not equal to 0 in the Finish() function. So that\r
-check in the IsFinishedOK() function provides very good feature for \r
-corruption detection.\r
-\r
-The value of the "Range" variable before each bit decoding can not be smaller \r
-than ((UInt32)1 << 24). The Normalize() function keeps the "Range" value in \r
-described range.\r
-\r
-#define kTopValue ((UInt32)1 << 24)\r
-\r
-void CRangeDecoder::Normalize()\r
-{\r
-  if (Range < kTopValue)\r
-  {\r
-    Range <<= 8;\r
-    Code = (Code << 8) | InStream->ReadByte();\r
-  }\r
-}\r
-\r
-Notes: if the size of the "Code" variable is larger than 32 bits, it's\r
-required to keep only low 32 bits of the "Code" variable after the change\r
-in Normalize() function.\r
-\r
-If the LZMA Stream is not corrupted, the value of the "Code" variable is\r
-always smaller than value of the "Range" variable.\r
-But the Range Decoder ignores some types of corruptions, so the value of\r
-the "Code" variable can be equal or larger than value of the "Range" variable\r
-for some "Corrupted" archives.\r
-\r
-\r
-LZMA uses Range Encoding only with binary symbols of two types:\r
-  1) binary symbols with fixed and equal probabilities (direct bits)\r
-  2) binary symbols with predicted probabilities\r
-\r
-The DecodeDirectBits() function decodes the sequence of direct bits:\r
-\r
-UInt32 CRangeDecoder::DecodeDirectBits(unsigned numBits)\r
-{\r
-  UInt32 res = 0;\r
-  do\r
-  {\r
-    Range >>= 1;\r
-    Code -= Range;\r
-    UInt32 t = 0 - ((UInt32)Code >> 31);\r
-    Code += Range & t;\r
-    \r
-    if (Code == Range)\r
-      Corrupted = true;\r
-    \r
-    Normalize();\r
-    res <<= 1;\r
-    res += t + 1;\r
-  }\r
-  while (--numBits);\r
-  return res;\r
-}\r
-\r
-\r
-The Bit Decoding with Probability Model\r
----------------------------------------\r
-\r
-The task of Bit Probability Model is to estimate probabilities of binary\r
-symbols. And then it provides the Range Decoder with that information.\r
-The better prediction provides better compression ratio.\r
-The Bit Probability Model uses statistical data of previous decoded\r
-symbols.\r
-\r
-That estimated probability is presented as 11-bit unsigned integer value\r
-that represents the probability of symbol "0".\r
-\r
-#define kNumBitModelTotalBits 11\r
-\r
-Mathematical probabilities can be presented with the following formulas:\r
-     probability(symbol_0) = prob / 2048.\r
-     probability(symbol_1) =  1 - Probability(symbol_0) =  \r
-                           =  1 - prob / 2048 =  \r
-                           =  (2048 - prob) / 2048\r
-where the "prob" variable contains 11-bit integer probability counter.\r
-\r
-It's recommended to use 16-bit unsigned integer type, to store these 11-bit\r
-probability values:\r
-\r
-typedef UInt16 CProb;\r
-\r
-Each probability value must be initialized with value ((1 << 11) / 2),\r
-that represents the state, where probabilities of symbols 0 and 1 \r
-are equal to 0.5:\r
-\r
-#define PROB_INIT_VAL ((1 << kNumBitModelTotalBits) / 2)\r
-\r
-The INIT_PROBS macro is used to initialize the array of CProb variables:\r
-\r
-#define INIT_PROBS(p) \\r
- { for (unsigned i = 0; i < sizeof(p) / sizeof(p[0]); i++) p[i] = PROB_INIT_VAL; }\r
-\r
-\r
-The DecodeBit() function decodes one bit.\r
-The LZMA decoder provides the pointer to CProb variable that contains \r
-information about estimated probability for symbol 0 and the Range Decoder \r
-updates that CProb variable after decoding. The Range Decoder increases \r
-estimated probability of the symbol that was decoded:\r
-\r
-#define kNumMoveBits 5\r
-\r
-unsigned CRangeDecoder::DecodeBit(CProb *prob)\r
-{\r
-  unsigned v = *prob;\r
-  UInt32 bound = (Range >> kNumBitModelTotalBits) * v;\r
-  unsigned symbol;\r
-  if (Code < bound)\r
-  {\r
-    v += ((1 << kNumBitModelTotalBits) - v) >> kNumMoveBits;\r
-    Range = bound;\r
-    symbol = 0;\r
-  }\r
-  else\r
-  {\r
-    v -= v >> kNumMoveBits;\r
-    Code -= bound;\r
-    Range -= bound;\r
-    symbol = 1;\r
-  }\r
-  *prob = (CProb)v;\r
-  Normalize();\r
-  return symbol;\r
-}\r
-\r
-\r
-The Binary Tree of bit model counters\r
--------------------------------------\r
-\r
-LZMA uses a tree of Bit model variables to decode symbol that needs\r
-several bits for storing. There are two versions of such trees in LZMA:\r
-  1) the tree that decodes bits from high bit to low bit (the normal scheme).\r
-  2) the tree that decodes bits from low bit to high bit (the reverse scheme).\r
-\r
-Each binary tree structure supports different size of decoded symbol\r
-(the size of binary sequence that contains value of symbol).\r
-If that size of decoded symbol is "NumBits" bits, the tree structure \r
-uses the array of (2 << NumBits) counters of CProb type. \r
-But only ((2 << NumBits) - 1) items are used by encoder and decoder.\r
-The first item (the item with index equal to 0) in array is unused.\r
-That scheme with unused array's item allows to simplify the code.\r
-\r
-unsigned BitTreeReverseDecode(CProb *probs, unsigned numBits, CRangeDecoder *rc)\r
-{\r
-  unsigned m = 1;\r
-  unsigned symbol = 0;\r
-  for (unsigned i = 0; i < numBits; i++)\r
-  {\r
-    unsigned bit = rc->DecodeBit(&probs[m]);\r
-    m <<= 1;\r
-    m += bit;\r
-    symbol |= (bit << i);\r
-  }\r
-  return symbol;\r
-}\r
-\r
-template <unsigned NumBits>\r
-class CBitTreeDecoder\r
-{\r
-  CProb Probs[(unsigned)1 << NumBits];\r
-\r
-public:\r
-\r
-  void Init()\r
-  {\r
-    INIT_PROBS(Probs);\r
-  }\r
-\r
-  unsigned Decode(CRangeDecoder *rc)\r
-  {\r
-    unsigned m = 1;\r
-    for (unsigned i = 0; i < NumBits; i++)\r
-      m = (m << 1) + rc->DecodeBit(&Probs[m]);\r
-    return m - ((unsigned)1 << NumBits);\r
-  }\r
-\r
-  unsigned ReverseDecode(CRangeDecoder *rc)\r
-  {\r
-    return BitTreeReverseDecode(Probs, NumBits, rc);\r
-  }\r
-};\r
-\r
-\r
-LZ part of LZMA \r
----------------\r
-\r
-LZ part of LZMA describes details about the decoding of MATCHES and LITERALS.\r
-\r
-\r
-The Literal Decoding\r
---------------------\r
-\r
-The LZMA Decoder uses (1 << (lc + lp)) tables with CProb values, where \r
-each table contains 0x300 CProb values:\r
-\r
-  CProb *LitProbs;\r
-\r
-  void CreateLiterals()\r
-  {\r
-    LitProbs = new CProb[(UInt32)0x300 << (lc + lp)];\r
-  }\r
-  \r
-  void InitLiterals()\r
-  {\r
-    UInt32 num = (UInt32)0x300 << (lc + lp);\r
-    for (UInt32 i = 0; i < num; i++)\r
-      LitProbs[i] = PROB_INIT_VAL;\r
-  }\r
-\r
-To select the table for decoding it uses the context that consists of\r
-(lc) high bits from previous literal and (lp) low bits from value that\r
-represents current position in outputStream.\r
-\r
-If (State > 7), the Literal Decoder also uses "matchByte" that represents \r
-the byte in OutputStream at position the is the DISTANCE bytes before \r
-current position, where the DISTANCE is the distance in DISTANCE-LENGTH pair\r
-of latest decoded match.\r
-\r
-The following code decodes one literal and puts it to Sliding Window buffer:\r
-\r
-  void DecodeLiteral(unsigned state, UInt32 rep0)\r
-  {\r
-    unsigned prevByte = 0;\r
-    if (!OutWindow.IsEmpty())\r
-      prevByte = OutWindow.GetByte(1);\r
-    \r
-    unsigned symbol = 1;\r
-    unsigned litState = ((OutWindow.TotalPos & ((1 << lp) - 1)) << lc) + (prevByte >> (8 - lc));\r
-    CProb *probs = &LitProbs[(UInt32)0x300 * litState];\r
-    \r
-    if (state >= 7)\r
-    {\r
-      unsigned matchByte = OutWindow.GetByte(rep0 + 1);\r
-      do\r
-      {\r
-        unsigned matchBit = (matchByte >> 7) & 1;\r
-        matchByte <<= 1;\r
-        unsigned bit = RangeDec.DecodeBit(&probs[((1 + matchBit) << 8) + symbol]);\r
-        symbol = (symbol << 1) | bit;\r
-        if (matchBit != bit)\r
-          break;\r
-      }\r
-      while (symbol < 0x100);\r
-    }\r
-    while (symbol < 0x100)\r
-      symbol = (symbol << 1) | RangeDec.DecodeBit(&probs[symbol]);\r
-    OutWindow.PutByte((Byte)(symbol - 0x100));\r
-  }\r
-\r
-\r
-The match length decoding\r
--------------------------\r
-\r
-The match length decoder returns normalized (zero-based value) \r
-length of match. That value can be converted to real length of the match \r
-with the following code:\r
-\r
-#define kMatchMinLen 2\r
-\r
-    matchLen = len + kMatchMinLen;\r
-\r
-The match length decoder can return the values from 0 to 271.\r
-And the corresponded real match length values can be in the range \r
-from 2 to 273.\r
-\r
-The following scheme is used for the match length encoding:\r
-\r
-  Binary encoding    Binary Tree structure    Zero-based match length \r
-  sequence                                    (binary + decimal):\r
-\r
-  0 xxx              LowCoder[posState]       xxx\r
-  1 0 yyy            MidCoder[posState]       yyy + 8\r
-  1 1 zzzzzzzz       HighCoder                zzzzzzzz + 16\r
-\r
-LZMA uses bit model variable "Choice" to decode the first selection bit.\r
-\r
-If the first selection bit is equal to 0, the decoder uses binary tree \r
-  LowCoder[posState] to decode 3-bit zero-based match length (xxx).\r
-\r
-If the first selection bit is equal to 1, the decoder uses bit model \r
-  variable "Choice2" to decode the second selection bit.\r
-\r
-  If the second selection bit is equal to 0, the decoder uses binary tree \r
-    MidCoder[posState] to decode 3-bit "yyy" value, and zero-based match\r
-    length is equal to (yyy + 8).\r
-\r
-  If the second selection bit is equal to 1, the decoder uses binary tree \r
-    HighCoder to decode 8-bit "zzzzzzzz" value, and zero-based \r
-    match length is equal to (zzzzzzzz + 16).\r
-\r
-LZMA uses "posState" value as context to select the binary tree \r
-from LowCoder and MidCoder binary tree arrays:\r
-\r
-    unsigned posState = OutWindow.TotalPos & ((1 << pb) - 1);\r
-\r
-The full code of the length decoder:\r
-\r
-class CLenDecoder\r
-{\r
-  CProb Choice;\r
-  CProb Choice2;\r
-  CBitTreeDecoder<3> LowCoder[1 << kNumPosBitsMax];\r
-  CBitTreeDecoder<3> MidCoder[1 << kNumPosBitsMax];\r
-  CBitTreeDecoder<8> HighCoder;\r
-\r
-public:\r
-\r
-  void Init()\r
-  {\r
-    Choice = PROB_INIT_VAL;\r
-    Choice2 = PROB_INIT_VAL;\r
-    HighCoder.Init();\r
-    for (unsigned i = 0; i < (1 << kNumPosBitsMax); i++)\r
-    {\r
-      LowCoder[i].Init();\r
-      MidCoder[i].Init();\r
-    }\r
-  }\r
-\r
-  unsigned Decode(CRangeDecoder *rc, unsigned posState)\r
-  {\r
-    if (rc->DecodeBit(&Choice) == 0)\r
-      return LowCoder[posState].Decode(rc);\r
-    if (rc->DecodeBit(&Choice2) == 0)\r
-      return 8 + MidCoder[posState].Decode(rc);\r
-    return 16 + HighCoder.Decode(rc);\r
-  }\r
-};\r
-\r
-The LZMA decoder uses two instances of CLenDecoder class.\r
-The first instance is for the matches of "Simple Match" type,\r
-and the second instance is for the matches of "Rep Match" type:\r
-\r
-  CLenDecoder LenDecoder;\r
-  CLenDecoder RepLenDecoder;\r
-\r
-\r
-The match distance decoding\r
----------------------------\r
-\r
-LZMA supports dictionary sizes up to 4 GiB minus 1.\r
-The value of match distance (decoded by distance decoder) can be \r
-from 1 to 2^32. But the distance value that is equal to 2^32 is used to\r
-indicate the "End of stream" marker. So real largest match distance \r
-that is used for LZ-window match is (2^32 - 1).\r
-\r
-LZMA uses normalized match length (zero-based length) \r
-to calculate the context state "lenState" do decode the distance value:\r
-\r
-#define kNumLenToPosStates 4\r
-\r
-    unsigned lenState = len;\r
-    if (lenState > kNumLenToPosStates - 1)\r
-      lenState = kNumLenToPosStates - 1;\r
-\r
-The distance decoder returns the "dist" value that is zero-based value \r
-of match distance. The real match distance can be calculated with the\r
-following code:\r
-  \r
-  matchDistance = dist + 1; \r
-\r
-The state of the distance decoder and the initialization code: \r
-\r
-  #define kEndPosModelIndex 14\r
-  #define kNumFullDistances (1 << (kEndPosModelIndex >> 1))\r
-  #define kNumAlignBits 4\r
-\r
-  CBitTreeDecoder<6> PosSlotDecoder[kNumLenToPosStates];\r
-  CProb PosDecoders[1 + kNumFullDistances - kEndPosModelIndex];\r
-  CBitTreeDecoder<kNumAlignBits> AlignDecoder;\r
-\r
-  void InitDist()\r
-  {\r
-    for (unsigned i = 0; i < kNumLenToPosStates; i++)\r
-      PosSlotDecoder[i].Init();\r
-    AlignDecoder.Init();\r
-    INIT_PROBS(PosDecoders);\r
-  }\r
-\r
-At first stage the distance decoder decodes 6-bit "posSlot" value with bit\r
-tree decoder from PosSlotDecoder array. It's possible to get 2^6=64 different \r
-"posSlot" values.\r
-\r
-    unsigned posSlot = PosSlotDecoder[lenState].Decode(&RangeDec);\r
-\r
-The encoding scheme for distance value is shown in the following table:\r
-\r
-posSlot (decimal) /\r
-      zero-based distance (binary)\r
- 0    0\r
- 1    1\r
- 2    10\r
- 3    11\r
-\r
- 4    10 x\r
- 5    11 x\r
- 6    10 xx\r
- 7    11 xx\r
- 8    10 xxx\r
- 9    11 xxx\r
-10    10 xxxx\r
-11    11 xxxx\r
-12    10 xxxxx\r
-13    11 xxxxx\r
-\r
-14    10 yy zzzz\r
-15    11 yy zzzz\r
-16    10 yyy zzzz\r
-17    11 yyy zzzz\r
-...\r
-62    10 yyyyyyyyyyyyyyyyyyyyyyyyyy zzzz\r
-63    11 yyyyyyyyyyyyyyyyyyyyyyyyyy zzzz\r
-\r
-where \r
-  "x ... x" means the sequence of binary symbols encoded with binary tree and \r
-      "Reverse" scheme. It uses separated binary tree for each posSlot from 4 to 13.\r
-  "y" means direct bit encoded with range coder.\r
-  "zzzz" means the sequence of four binary symbols encoded with binary\r
-      tree with "Reverse" scheme, where one common binary tree "AlignDecoder"\r
-      is used for all posSlot values.\r
-\r
-If (posSlot < 4), the "dist" value is equal to posSlot value.\r
-\r
-If (posSlot >= 4), the decoder uses "posSlot" value to calculate the value of\r
-  the high bits of "dist" value and the number of the low bits.\r
-\r
-  If (4 <= posSlot < kEndPosModelIndex), the decoder uses bit tree decoders.\r
-    (one separated bit tree decoder per one posSlot value) and "Reverse" scheme.\r
-    In this implementation we use one CProb array "PosDecoders" that contains \r
-    all CProb variables for all these bit decoders.\r
-  \r
-  if (posSlot >= kEndPosModelIndex), the middle bits are decoded as direct \r
-    bits from RangeDecoder and the low 4 bits are decoded with a bit tree \r
-    decoder "AlignDecoder" with "Reverse" scheme.\r
-\r
-The code to decode zero-based match distance:\r
-  \r
-  unsigned DecodeDistance(unsigned len)\r
-  {\r
-    unsigned lenState = len;\r
-    if (lenState > kNumLenToPosStates - 1)\r
-      lenState = kNumLenToPosStates - 1;\r
-    \r
-    unsigned posSlot = PosSlotDecoder[lenState].Decode(&RangeDec);\r
-    if (posSlot < 4)\r
-      return posSlot;\r
-    \r
-    unsigned numDirectBits = (unsigned)((posSlot >> 1) - 1);\r
-    UInt32 dist = ((2 | (posSlot & 1)) << numDirectBits);\r
-    if (posSlot < kEndPosModelIndex)\r
-      dist += BitTreeReverseDecode(PosDecoders + dist - posSlot, numDirectBits, &RangeDec);\r
-    else\r
-    {\r
-      dist += RangeDec.DecodeDirectBits(numDirectBits - kNumAlignBits) << kNumAlignBits;\r
-      dist += AlignDecoder.ReverseDecode(&RangeDec);\r
-    }\r
-    return dist;\r
-  }\r
-\r
-\r
-\r
-LZMA Decoding modes\r
--------------------\r
-\r
-There are 2 types of LZMA streams:\r
-\r
-1) The stream with "End of stream" marker.\r
-2) The stream without "End of stream" marker.\r
-\r
-And the LZMA Decoder supports 3 modes of decoding:\r
-\r
-1) The unpack size is undefined. The LZMA decoder stops decoding after \r
-   getting "End of stream" marker. \r
-   The input variables for that case:\r
-    \r
-      markerIsMandatory = true\r
-      unpackSizeDefined = false\r
-      unpackSize contains any value\r
-\r
-2) The unpack size is defined and LZMA decoder supports both variants, \r
-   where the stream can contain "End of stream" marker or the stream is\r
-   finished without "End of stream" marker. The LZMA decoder must detect \r
-   any of these situations.\r
-   The input variables for that case:\r
-    \r
-      markerIsMandatory = false\r
-      unpackSizeDefined = true\r
-      unpackSize contains unpack size\r
-\r
-3) The unpack size is defined and the LZMA stream must contain \r
-   "End of stream" marker\r
-   The input variables for that case:\r
-    \r
-      markerIsMandatory = true\r
-      unpackSizeDefined = true\r
-      unpackSize contains unpack size\r
-\r
-\r
-The main loop of decoder\r
-------------------------\r
-\r
-The main loop of LZMA decoder:\r
-\r
-Initialize the LZMA state.\r
-loop\r
-{\r
-  // begin of loop\r
-  Check "end of stream" conditions.\r
-  Decode Type of MATCH / LITERAL. \r
-    If it's LITERAL, decode LITERAL value and put the LITERAL to Window.\r
-    If it's MATCH, decode the length of match and the match distance. \r
-        Check error conditions, check end of stream conditions and copy\r
-        the sequence of match bytes from sliding window to current position\r
-        in window.\r
-  Go to begin of loop\r
-}\r
-\r
-The reference implementation of LZMA decoder uses "unpackSize" variable\r
-to keep the number of remaining bytes in output stream. So it reduces \r
-"unpackSize" value after each decoded LITERAL or MATCH.\r
-\r
-The following code contains the "end of stream" condition check at the start\r
-of the loop:\r
-\r
-    if (unpackSizeDefined && unpackSize == 0 && !markerIsMandatory)\r
-      if (RangeDec.IsFinishedOK())\r
-        return LZMA_RES_FINISHED_WITHOUT_MARKER;\r
-\r
-LZMA uses three types of matches:\r
-\r
-1) "Simple Match" -     the match with distance value encoded with bit models.\r
-\r
-2) "Rep Match" -        the match that uses the distance from distance\r
-                        history table.\r
-\r
-3) "Short Rep Match" -  the match of single byte length, that uses the latest \r
-                        distance from distance history table.\r
-\r
-The LZMA decoder keeps the history of latest 4 match distances that were used \r
-by decoder. That set of 4 variables contains zero-based match distances and \r
-these variables are initialized with zero values:\r
-\r
-  UInt32 rep0 = 0, rep1 = 0, rep2 = 0, rep3 = 0;\r
-\r
-The LZMA decoder uses binary model variables to select type of MATCH or LITERAL:\r
-\r
-#define kNumStates 12\r
-#define kNumPosBitsMax 4\r
-\r
-  CProb IsMatch[kNumStates << kNumPosBitsMax];\r
-  CProb IsRep[kNumStates];\r
-  CProb IsRepG0[kNumStates];\r
-  CProb IsRepG1[kNumStates];\r
-  CProb IsRepG2[kNumStates];\r
-  CProb IsRep0Long[kNumStates << kNumPosBitsMax];\r
-\r
-The decoder uses "state" variable value to select exact variable \r
-from "IsRep", "IsRepG0", "IsRepG1" and "IsRepG2" arrays.\r
-The "state" variable can get the value from 0 to 11.\r
-Initial value for "state" variable is zero:\r
-\r
-  unsigned state = 0;\r
-\r
-The "state" variable is updated after each LITERAL or MATCH with one of the\r
-following functions:\r
-\r
-unsigned UpdateState_Literal(unsigned state)\r
-{\r
-  if (state < 4) return 0;\r
-  else if (state < 10) return state - 3;\r
-  else return state - 6;\r
-}\r
-unsigned UpdateState_Match   (unsigned state) { return state < 7 ? 7 : 10; }\r
-unsigned UpdateState_Rep     (unsigned state) { return state < 7 ? 8 : 11; }\r
-unsigned UpdateState_ShortRep(unsigned state) { return state < 7 ? 9 : 11; }\r
-\r
-The decoder calculates "state2" variable value to select exact variable from \r
-"IsMatch" and "IsRep0Long" arrays:\r
-\r
-unsigned posState = OutWindow.TotalPos & ((1 << pb) - 1);\r
-unsigned state2 = (state << kNumPosBitsMax) + posState;\r
-\r
-The decoder uses the following code flow scheme to select exact \r
-type of LITERAL or MATCH:\r
-\r
-IsMatch[state2] decode\r
-  0 - the Literal\r
-  1 - the Match\r
-    IsRep[state] decode\r
-      0 - Simple Match\r
-      1 - Rep Match\r
-        IsRepG0[state] decode\r
-          0 - the distance is rep0\r
-            IsRep0Long[state2] decode\r
-              0 - Short Rep Match\r
-              1 - Rep Match 0\r
-          1 - \r
-            IsRepG1[state] decode\r
-              0 - Rep Match 1\r
-              1 - \r
-                IsRepG2[state] decode\r
-                  0 - Rep Match 2\r
-                  1 - Rep Match 3\r
-\r
-\r
-LITERAL symbol\r
---------------\r
-If the value "0" was decoded with IsMatch[state2] decoding, we have "LITERAL" type.\r
-\r
-At first the LZMA decoder must check that it doesn't exceed \r
-specified uncompressed size:\r
-\r
-      if (unpackSizeDefined && unpackSize == 0)\r
-        return LZMA_RES_ERROR;\r
-\r
-Then it decodes literal value and puts it to sliding window:\r
-\r
-      DecodeLiteral(state, rep0);\r
-\r
-Then the decoder must update the "state" value and "unpackSize" value;\r
-\r
-      state = UpdateState_Literal(state);\r
-      unpackSize--;\r
-\r
-Then the decoder must go to the begin of main loop to decode next Match or Literal.\r
-\r
-\r
-Simple Match\r
-------------\r
-\r
-If the value "1" was decoded with IsMatch[state2] decoding,\r
-we have the "Simple Match" type.\r
-\r
-The distance history table is updated with the following scheme:\r
-    \r
-      rep3 = rep2;\r
-      rep2 = rep1;\r
-      rep1 = rep0;\r
-\r
-The zero-based length is decoded with "LenDecoder":\r
-\r
-      len = LenDecoder.Decode(&RangeDec, posState);\r
-\r
-The state is update with UpdateState_Match function:\r
-\r
-      state = UpdateState_Match(state);\r
-\r
-and the new "rep0" value is decoded with DecodeDistance:\r
-\r
-      rep0 = DecodeDistance(len);\r
-\r
-That "rep0" will be used as zero-based distance for current match.\r
-\r
-If the value of "rep0" is equal to 0xFFFFFFFF, it means that we have \r
-"End of stream" marker, so we can stop decoding and check finishing \r
-condition in Range Decoder:\r
-\r
-      if (rep0 == 0xFFFFFFFF)\r
-        return RangeDec.IsFinishedOK() ?\r
-            LZMA_RES_FINISHED_WITH_MARKER :\r
-            LZMA_RES_ERROR;\r
-\r
-If uncompressed size is defined, LZMA decoder must check that it doesn't \r
-exceed that specified uncompressed size:\r
-\r
-      if (unpackSizeDefined && unpackSize == 0)\r
-        return LZMA_RES_ERROR;\r
-\r
-Also the decoder must check that "rep0" value is not larger than dictionary size\r
-and is not larger than the number of already decoded bytes:\r
-\r
-      if (rep0 >= dictSize || !OutWindow.CheckDistance(rep0))\r
-        return LZMA_RES_ERROR;\r
-\r
-Then the decoder must copy match bytes as described in \r
-"The match symbols copying" section.\r
-\r
-\r
-Rep Match\r
----------\r
-\r
-If the LZMA decoder has decoded the value "1" with IsRep[state] variable,\r
-we have "Rep Match" type.\r
-\r
-At first the LZMA decoder must check that it doesn't exceed \r
-specified uncompressed size:\r
-\r
-      if (unpackSizeDefined && unpackSize == 0)\r
-        return LZMA_RES_ERROR;\r
-\r
-Also the decoder must return error, if the LZ window is empty:\r
-\r
-      if (OutWindow.IsEmpty())\r
-        return LZMA_RES_ERROR;\r
-\r
-If the match type is "Rep Match", the decoder uses one of the 4 variables of\r
-distance history table to get the value of distance for current match.\r
-And there are 4 corresponding ways of decoding flow. \r
-\r
-The decoder updates the distance history with the following scheme \r
-depending from type of match:\r
-\r
-- "Rep Match 0" or "Short Rep Match":\r
-      ; LZMA doesn't update the distance history    \r
-\r
-- "Rep Match 1":\r
-      UInt32 dist = rep1;\r
-      rep1 = rep0;\r
-      rep0 = dist;\r
-\r
-- "Rep Match 2":\r
-      UInt32 dist = rep2;\r
-      rep2 = rep1;\r
-      rep1 = rep0;\r
-      rep0 = dist;\r
-\r
-- "Rep Match 3":\r
-      UInt32 dist = rep3;\r
-      rep3 = rep2;\r
-      rep2 = rep1;\r
-      rep1 = rep0;\r
-      rep0 = dist;\r
-\r
-Then the decoder decodes exact subtype of "Rep Match" using "IsRepG0", "IsRep0Long",\r
-"IsRepG1", "IsRepG2".\r
-\r
-If the subtype is "Short Rep Match", the decoder updates the state, puts \r
-the one byte from window to current position in window and goes to next \r
-MATCH/LITERAL symbol (the begin of main loop):\r
-\r
-          state = UpdateState_ShortRep(state);\r
-          OutWindow.PutByte(OutWindow.GetByte(rep0 + 1));\r
-          unpackSize--;\r
-          continue;\r
-\r
-In other cases (Rep Match 0/1/2/3), it decodes the zero-based \r
-length of match with "RepLenDecoder" decoder:\r
-\r
-      len = RepLenDecoder.Decode(&RangeDec, posState);\r
-\r
-Then it updates the state:\r
-\r
-      state = UpdateState_Rep(state);\r
-\r
-Then the decoder must copy match bytes as described in \r
-"The Match symbols copying" section.\r
-\r
-\r
-The match symbols copying\r
--------------------------\r
-\r
-If we have the match (Simple Match or Rep Match 0/1/2/3), the decoder must\r
-copy the sequence of bytes with calculated match distance and match length.\r
-If uncompressed size is defined, LZMA decoder must check that it doesn't \r
-exceed that specified uncompressed size:\r
-\r
-    len += kMatchMinLen;\r
-    bool isError = false;\r
-    if (unpackSizeDefined && unpackSize < len)\r
-    {\r
-      len = (unsigned)unpackSize;\r
-      isError = true;\r
-    }\r
-    OutWindow.CopyMatch(rep0 + 1, len);\r
-    unpackSize -= len;\r
-    if (isError)\r
-      return LZMA_RES_ERROR;\r
-\r
-Then the decoder must go to the begin of main loop to decode next MATCH or LITERAL.\r
-\r
-\r
-\r
-NOTES\r
------\r
-\r
-This specification doesn't describe the variant of decoder implementation \r
-that supports partial decoding. Such partial decoding case can require some \r
-changes in "end of stream" condition checks code. Also such code \r
-can use additional status codes, returned by decoder.\r
-\r
-This specification uses C++ code with templates to simplify describing.\r
-The optimized version of LZMA decoder doesn't need templates.\r
-Such optimized version can use just two arrays of CProb variables:\r
-  1) The dynamic array of CProb variables allocated for the Literal Decoder.\r
-  2) The one common array that contains all other CProb variables.\r
-\r
-\r
-References:      \r
-\r
-1. G. N. N. Martin, Range encoding: an algorithm for removing redundancy \r
-   from a digitized message, Video & Data Recording Conference, \r
-   Southampton, UK, July 24-27, 1979.\r
diff --git a/deps/lzma-16.04/DOC/lzma.txt b/deps/lzma-16.04/DOC/lzma.txt
deleted file mode 100644 (file)
index f9a80ae..0000000
+++ /dev/null
@@ -1,328 +0,0 @@
-LZMA compression\r
-----------------\r
-Version: 9.35\r
-\r
-This file describes LZMA encoding and decoding functions written in C language.\r
-\r
-LZMA is an improved version of famous LZ77 compression algorithm. \r
-It was improved in way of maximum increasing of compression ratio,\r
-keeping high decompression speed and low memory requirements for \r
-decompressing.\r
-\r
-Note: you can read also LZMA Specification (lzma-specification.txt from LZMA SDK)\r
-\r
-Also you can look source code for LZMA encoding and decoding:\r
-  C/Util/Lzma/LzmaUtil.c\r
-\r
-\r
-LZMA compressed file format\r
----------------------------\r
-Offset Size Description\r
-  0     1   Special LZMA properties (lc,lp, pb in encoded form)\r
-  1     4   Dictionary size (little endian)\r
-  5     8   Uncompressed size (little endian). -1 means unknown size\r
- 13         Compressed data\r
-\r
-\r
-\r
-ANSI-C LZMA Decoder\r
-~~~~~~~~~~~~~~~~~~~\r
-\r
-Please note that interfaces for ANSI-C code were changed in LZMA SDK 4.58.\r
-If you want to use old interfaces you can download previous version of LZMA SDK\r
-from sourceforge.net site.\r
-\r
-To use ANSI-C LZMA Decoder you need the following files:\r
-1) LzmaDec.h + LzmaDec.c + Types.h\r
-\r
-Look example code:\r
-  C/Util/Lzma/LzmaUtil.c\r
-\r
-\r
-Memory requirements for LZMA decoding\r
--------------------------------------\r
-\r
-Stack usage of LZMA decoding function for local variables is not \r
-larger than 200-400 bytes.\r
-\r
-LZMA Decoder uses dictionary buffer and internal state structure.\r
-Internal state structure consumes\r
-  state_size = (4 + (1.5 << (lc + lp))) KB\r
-by default (lc=3, lp=0), state_size = 16 KB.\r
-\r
-\r
-How To decompress data\r
-----------------------\r
-\r
-LZMA Decoder (ANSI-C version) now supports 2 interfaces:\r
-1) Single-call Decompressing\r
-2) Multi-call State Decompressing (zlib-like interface)\r
-\r
-You must use external allocator:\r
-Example:\r
-void *SzAlloc(void *p, size_t size) { p = p; return malloc(size); }\r
-void SzFree(void *p, void *address) { p = p; free(address); }\r
-ISzAlloc alloc = { SzAlloc, SzFree };\r
-\r
-You can use p = p; operator to disable compiler warnings.\r
-\r
-\r
-Single-call Decompressing\r
--------------------------\r
-When to use: RAM->RAM decompressing\r
-Compile files: LzmaDec.h + LzmaDec.c + Types.h\r
-Compile defines: no defines\r
-Memory Requirements:\r
-  - Input buffer: compressed size\r
-  - Output buffer: uncompressed size\r
-  - LZMA Internal Structures: state_size (16 KB for default settings) \r
-\r
-Interface:\r
-  int LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,\r
-      const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, \r
-      ELzmaStatus *status, ISzAlloc *alloc);\r
-  In: \r
-    dest     - output data\r
-    destLen  - output data size\r
-    src      - input data\r
-    srcLen   - input data size\r
-    propData - LZMA properties  (5 bytes)\r
-    propSize - size of propData buffer (5 bytes)\r
-    finishMode - It has meaning only if the decoding reaches output limit (*destLen).\r
-         LZMA_FINISH_ANY - Decode just destLen bytes.\r
-         LZMA_FINISH_END - Stream must be finished after (*destLen).\r
-                           You can use LZMA_FINISH_END, when you know that \r
-                           current output buffer covers last bytes of stream. \r
-    alloc    - Memory allocator.\r
-\r
-  Out: \r
-    destLen  - processed output size \r
-    srcLen   - processed input size \r
-\r
-  Output:\r
-    SZ_OK\r
-      status:\r
-        LZMA_STATUS_FINISHED_WITH_MARK\r
-        LZMA_STATUS_NOT_FINISHED \r
-        LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK\r
-    SZ_ERROR_DATA - Data error\r
-    SZ_ERROR_MEM  - Memory allocation error\r
-    SZ_ERROR_UNSUPPORTED - Unsupported properties\r
-    SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).\r
-\r
-  If LZMA decoder sees end_marker before reaching output limit, it returns OK result,\r
-  and output value of destLen will be less than output buffer size limit.\r
-\r
-  You can use multiple checks to test data integrity after full decompression:\r
-    1) Check Result and "status" variable.\r
-    2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize.\r
-    3) Check that output(srcLen) = compressedSize, if you know real compressedSize. \r
-       You must use correct finish mode in that case. */ \r
-\r
-\r
-Multi-call State Decompressing (zlib-like interface)\r
-----------------------------------------------------\r
-\r
-When to use: file->file decompressing \r
-Compile files: LzmaDec.h + LzmaDec.c + Types.h\r
-\r
-Memory Requirements:\r
- - Buffer for input stream: any size (for example, 16 KB)\r
- - Buffer for output stream: any size (for example, 16 KB)\r
- - LZMA Internal Structures: state_size (16 KB for default settings) \r
- - LZMA dictionary (dictionary size is encoded in LZMA properties header)\r
-\r
-1) read LZMA properties (5 bytes) and uncompressed size (8 bytes, little-endian) to header:\r
-   unsigned char header[LZMA_PROPS_SIZE + 8];\r
-   ReadFile(inFile, header, sizeof(header)\r
-\r
-2) Allocate CLzmaDec structures (state + dictionary) using LZMA properties\r
-\r
-  CLzmaDec state;\r
-  LzmaDec_Constr(&state);\r
-  res = LzmaDec_Allocate(&state, header, LZMA_PROPS_SIZE, &g_Alloc);\r
-  if (res != SZ_OK)\r
-    return res;\r
-\r
-3) Init LzmaDec structure before any new LZMA stream. And call LzmaDec_DecodeToBuf in loop\r
-\r
-  LzmaDec_Init(&state);\r
-  for (;;)\r
-  {\r
-    ... \r
-    int res = LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, \r
-        const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode);\r
-    ...\r
-  }\r
-\r
-\r
-4) Free all allocated structures\r
-  LzmaDec_Free(&state, &g_Alloc);\r
-\r
-Look example code:\r
-  C/Util/Lzma/LzmaUtil.c\r
-\r
-\r
-How To compress data\r
---------------------\r
-\r
-Compile files: \r
-  Types.h\r
-  Threads.h    \r
-  LzmaEnc.h\r
-  LzmaEnc.c\r
-  LzFind.h\r
-  LzFind.c\r
-  LzFindMt.h\r
-  LzFindMt.c\r
-  LzHash.h\r
-\r
-Memory Requirements:\r
-  - (dictSize * 11.5 + 6 MB) + state_size\r
-\r
-Lzma Encoder can use two memory allocators:\r
-1) alloc - for small arrays.\r
-2) allocBig - for big arrays.\r
-\r
-For example, you can use Large RAM Pages (2 MB) in allocBig allocator for \r
-better compression speed. Note that Windows has bad implementation for \r
-Large RAM Pages. \r
-It's OK to use same allocator for alloc and allocBig.\r
-\r
-\r
-Single-call Compression with callbacks\r
---------------------------------------\r
-\r
-Look example code:\r
-  C/Util/Lzma/LzmaUtil.c\r
-\r
-When to use: file->file compressing \r
-\r
-1) you must implement callback structures for interfaces:\r
-ISeqInStream\r
-ISeqOutStream\r
-ICompressProgress\r
-ISzAlloc\r
-\r
-static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }\r
-static void SzFree(void *p, void *address) {  p = p; MyFree(address); }\r
-static ISzAlloc g_Alloc = { SzAlloc, SzFree };\r
-\r
-  CFileSeqInStream inStream;\r
-  CFileSeqOutStream outStream;\r
-\r
-  inStream.funcTable.Read = MyRead;\r
-  inStream.file = inFile;\r
-  outStream.funcTable.Write = MyWrite;\r
-  outStream.file = outFile;\r
-\r
-\r
-2) Create CLzmaEncHandle object;\r
-\r
-  CLzmaEncHandle enc;\r
-\r
-  enc = LzmaEnc_Create(&g_Alloc);\r
-  if (enc == 0)\r
-    return SZ_ERROR_MEM;\r
-\r
-\r
-3) initialize CLzmaEncProps properties;\r
-\r
-  LzmaEncProps_Init(&props);\r
-\r
-  Then you can change some properties in that structure.\r
-\r
-4) Send LZMA properties to LZMA Encoder\r
-\r
-  res = LzmaEnc_SetProps(enc, &props);\r
-\r
-5) Write encoded properties to header\r
-\r
-    Byte header[LZMA_PROPS_SIZE + 8];\r
-    size_t headerSize = LZMA_PROPS_SIZE;\r
-    UInt64 fileSize;\r
-    int i;\r
-\r
-    res = LzmaEnc_WriteProperties(enc, header, &headerSize);\r
-    fileSize = MyGetFileLength(inFile);\r
-    for (i = 0; i < 8; i++)\r
-      header[headerSize++] = (Byte)(fileSize >> (8 * i));\r
-    MyWriteFileAndCheck(outFile, header, headerSize)\r
-\r
-6) Call encoding function:\r
-      res = LzmaEnc_Encode(enc, &outStream.funcTable, &inStream.funcTable, \r
-        NULL, &g_Alloc, &g_Alloc);\r
-\r
-7) Destroy LZMA Encoder Object\r
-  LzmaEnc_Destroy(enc, &g_Alloc, &g_Alloc);\r
-\r
-\r
-If callback function return some error code, LzmaEnc_Encode also returns that code\r
-or it can return the code like SZ_ERROR_READ, SZ_ERROR_WRITE or SZ_ERROR_PROGRESS.\r
-\r
-\r
-Single-call RAM->RAM Compression\r
---------------------------------\r
-\r
-Single-call RAM->RAM Compression is similar to Compression with callbacks,\r
-but you provide pointers to buffers instead of pointers to stream callbacks:\r
-\r
-SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,\r
-    const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, \r
-    ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);\r
-\r
-Return code:\r
-  SZ_OK               - OK\r
-  SZ_ERROR_MEM        - Memory allocation error \r
-  SZ_ERROR_PARAM      - Incorrect paramater\r
-  SZ_ERROR_OUTPUT_EOF - output buffer overflow\r
-  SZ_ERROR_THREAD     - errors in multithreading functions (only for Mt version)\r
-\r
-\r
-\r
-Defines\r
--------\r
-\r
-_LZMA_SIZE_OPT - Enable some optimizations in LZMA Decoder to get smaller executable code.\r
-\r
-_LZMA_PROB32   - It can increase the speed on some 32-bit CPUs, but memory usage for \r
-                 some structures will be doubled in that case.\r
-\r
-_LZMA_UINT32_IS_ULONG  - Define it if int is 16-bit on your compiler and long is 32-bit.\r
-\r
-_LZMA_NO_SYSTEM_SIZE_T  - Define it if you don't want to use size_t type.\r
-\r
-\r
-_7ZIP_PPMD_SUPPPORT - Define it if you don't want to support PPMD method in AMSI-C .7z decoder.\r
-\r
-\r
-C++ LZMA Encoder/Decoder \r
-~~~~~~~~~~~~~~~~~~~~~~~~\r
-C++ LZMA code use COM-like interfaces. So if you want to use it, \r
-you can study basics of COM/OLE.\r
-C++ LZMA code is just wrapper over ANSI-C code.\r
-\r
-\r
-C++ Notes\r
-~~~~~~~~~~~~~~~~~~~~~~~~\r
-If you use some C++ code folders in 7-Zip (for example, C++ code for .7z handling),\r
-you must check that you correctly work with "new" operator.\r
-7-Zip can be compiled with MSVC 6.0 that doesn't throw "exception" from "new" operator.\r
-So 7-Zip uses "CPP\Common\NewHandler.cpp" that redefines "new" operator:\r
-operator new(size_t size)\r
-{\r
-  void *p = ::malloc(size);\r
-  if (p == 0)\r
-    throw CNewException();\r
-  return p;\r
-}\r
-If you use MSCV that throws exception for "new" operator, you can compile without \r
-"NewHandler.cpp". So standard exception will be used. Actually some code of \r
-7-Zip catches any exception in internal code and converts it to HRESULT code.\r
-So you don't need to catch CNewException, if you call COM interfaces of 7-Zip.\r
-\r
----\r
-\r
-http://www.7-zip.org\r
-http://www.7-zip.org/sdk.html\r
-http://www.7-zip.org/support.html\r
diff --git a/deps/mman/.gitignore b/deps/mman/.gitignore
deleted file mode 100644 (file)
index 5f778db..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-x64
-mman.VC.db
\ No newline at end of file
diff --git a/deps/mman/.gitrepo b/deps/mman/.gitrepo
deleted file mode 100644 (file)
index 7e6585b..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-; DO NOT EDIT (unless you know what you are doing)
-;
-; This subdirectory is a git "subrepo", and this file is maintained by the
-; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme
-;
-[subrepo]
-       remote = https://github.com/witwall/mman-win32
-       branch = master
-       commit = 2d1c576e62b99e85d99407e1a88794c6e44c3310
-       parent = 19599a744a114b242c401d5ac1f0bcfc369453ee
-       method = merge
-       cmdver = 0.4.1
diff --git a/deps/mman/.vs/mman/v14/.suo b/deps/mman/.vs/mman/v14/.suo
deleted file mode 100644 (file)
index 57e963c..0000000
Binary files a/deps/mman/.vs/mman/v14/.suo and /dev/null differ
diff --git a/deps/mman/CMakeLists.txt b/deps/mman/CMakeLists.txt
deleted file mode 100644 (file)
index 72b9c26..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-project (mman-win32 C)
-
-cmake_minimum_required (VERSION 2.8)
-
-option (BUILD_SHARED_LIBS "shared/static libs" ON) 
-option (BUILD_TESTS "tests?" OFF)
-
-set (headers mman.h)
-set (sources mman.c)
-
-add_library (mman ${sources})
-
-if (BUILD_SHARED_LIBS)
-       target_compile_definitions(mman
-               PUBLIC MMAN_LIBRARY_DLL
-               PRIVATE MMAN_LIBRARY
-       )
-endif()
-
-install (TARGETS mman RUNTIME DESTINATION bin
-                      LIBRARY DESTINATION lib${LIB_SUFFIX}
-                      ARCHIVE DESTINATION lib${LIB_SUFFIX})
-
-install (FILES ${headers} DESTINATION include/sys)
-
-if (BUILD_TESTS)
-  enable_testing ()
-  add_executable (t_mman test.c)
-  target_link_libraries (t_mman mman)
-  add_test (NAME t_mman COMMAND t_mman${CMAKE_EXECUTABLE_SUFFIX})
-endif ()
-
-
diff --git a/deps/mman/Makefile b/deps/mman/Makefile
deleted file mode 100644 (file)
index f6af361..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#
-# mman-win32 (mingw32) Makefile
-#
-include config.mak
-
-CFLAGS=-Wall -O3 -fomit-frame-pointer
-
-ifeq ($(BUILD_STATIC),yes)
-       TARGETS+=libmman.a
-       INSTALL+=static-install
-endif
-
-ifeq ($(BUILD_SHARED),yes)
-       TARGETS+=libmman.dll
-       INSTALL+=shared-install
-       CFLAGS+=-DMMAN_LIBRARY_DLL -DMMAN_LIBRARY
-endif
-
-ifeq ($(BUILD_MSVC),yes)
-       SHFLAGS+=-Wl,--output-def,libmman.def
-       INSTALL+=lib-install
-endif
-
-all: $(TARGETS)
-
-mman.o: mman.c mman.h
-       $(CC) -o mman.o -c mman.c $(CFLAGS)
-
-libmman.a: mman.o
-       $(AR) cru libmman.a mman.o
-       $(RANLIB) libmman.a
-
-libmman.dll: mman.o
-       $(CC) -shared -o libmman.dll mman.o -Wl,--out-implib,libmman.dll.a
-
-header-install:
-       mkdir -p $(DESTDIR)$(incdir)
-       cp mman.h $(DESTDIR)$(incdir)
-
-static-install: header-install
-       mkdir -p $(DESTDIR)$(libdir)
-       cp libmman.a $(DESTDIR)$(libdir)
-
-shared-install: header-install
-       mkdir -p $(DESTDIR)$(libdir)
-       cp libmman.dll.a $(DESTDIR)$(libdir)
-       mkdir -p $(DESTDIR)$(bindir)
-       cp libmman.dll $(DESTDIR)$(bindir)
-
-lib-install:
-       mkdir -p $(DESTDIR)$(libdir)
-       cp libmman.lib $(DESTDIR)$(libdir)
-
-install: $(INSTALL)
-
-test.exe: test.c mman.c mman.h
-       $(CC) -o test.exe test.c -L. -lmman
-
-test: $(TARGETS) test.exe
-       test.exe
-
-clean::
-       rm -f mman.o libmman.a libmman.dll.a libmman.dll libmman.def libmman.lib test.exe *.dat
-
-distclean: clean
-       rm -f config.mak
-
-.PHONY: clean distclean install test
diff --git a/deps/mman/README.md b/deps/mman/README.md
deleted file mode 100644 (file)
index 9df50e3..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-mman-win32
-==========
-
-mman library for Windows. mirror of https://code.google.com/p/mman-win32/
-
-A light implementation of the mmap functions for MinGW.
-
-The mmap-win32 library implements a wrapper for mmap functions around the memory mapping Windows API.
-
-License: MIT License
diff --git a/deps/mman/UpgradeLog.htm b/deps/mman/UpgradeLog.htm
deleted file mode 100644 (file)
index c15fdf0..0000000
Binary files a/deps/mman/UpgradeLog.htm and /dev/null differ
diff --git a/deps/mman/configure b/deps/mman/configure
deleted file mode 100755 (executable)
index 665cb1e..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-#!/bin/sh
-# mmap-win32 configure script
-#
-# Parts copied from FFmpeg's configure
-#
-
-set_all(){
-    value=$1
-    shift
-    for var in $*; do
-        eval $var=$value
-    done
-}
-
-enable(){
-    set_all yes $*
-}
-
-disable(){
-    set_all no $*
-}
-
-enabled(){
-    eval test "x\$$1" = "xyes"
-}
-
-disabled(){
-    eval test "x\$$1" = "xno"
-}
-
-show_help(){
-  echo "Usage: configure [options]"
-  echo "Options: [defaults in brackets after descriptions]"
-  echo "All \"enable\" options have \"disable\" counterparts"
-  echo
-  echo "  --help                    print this message"
-  echo "  --prefix=PREFIX           install in PREFIX [$PREFIX]"
-  echo "  --bindir=DIR              install binaries in DIR [$PREFIX/bin]"
-  echo "  --libdir=DIR              install libs in DIR [$PREFIX/lib]"
-  echo "  --incdir=DIR              install includes in DIR [$PREFIX/include]"
-  echo "  --enable-static           build static libraries [yes]"
-  echo "  --enable-shared           build shared libraries [no]"
-  echo "  --enable-msvc             create msvc-compatible import lib [auto]"
-  echo
-  echo "  --cc=CC                   use C compiler CC [$cc_default]"
-  echo "  --cross-prefix=PREFIX     use PREFIX for compilation tools [$cross_prefix]"
-  exit 1
-}
-
-die_unknown(){
-    echo "Unknown option \"$1\"."
-    echo "See $0 --help for available options."
-    exit 1
-}
-
-PREFIX="/mingw"
-ar="ar"
-cc_default="gcc"
-ranlib="ranlib"
-strip="strip"
-
-DEFAULT="msvc
-"
-
-DEFAULT_YES="static
-    stripping
-"
-
-DEFAULT_NO="shared
-"
-
-CMDLINE_SELECT="$DEFAULT
-    $DEFAULT_NO
-    $DEFAULT_YES
-"
-
-enable  $DEFAULT_YES
-disable $DEFAULT_NO
-
-for opt do
-    optval="${opt#*=}"
-    case "$opt" in
-    --help)
-        show_help
-    ;;
-    --prefix=*)
-        PREFIX="$optval"
-    ;;
-    --bindir=*)
-        bindir="$optval"
-    ;;
-    --libdir=*)
-        libdir="$optval"
-    ;;
-    --incdir=*)
-        incdir="$optval"
-    ;;
-    --cc=*)
-        cc="$optval"
-    ;;
-    --cross-prefix=*)
-        cross_prefix="$optval"
-    ;;
-    --enable-?*|--disable-?*)
-        eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
-        echo "$CMDLINE_SELECT" | grep -q "^ *$option\$" || die_unknown $opt
-        $action $option
-    ;;
-    *)
-        die_unknown $opt
-    ;;
-    esac
-done
-
-bindir="${PREFIX}/bin"
-libdir="${PREFIX}/lib"
-incdir="${PREFIX}/include/sys"
-ar="${cross_prefix}${ar}"
-cc_default="${cross_prefix}${cc_default}"
-ranlib="${cross_prefix}${ranlib}"
-strip="${cross_prefix}${strip}"
-
-if ! test -z $cc; then
-    cc_default="${cc}"
-fi
-cc="${cc_default}"
-
-disabled static && disabled shared && {
-    echo "At least one library type must be set.";
-    exit 1;
-}
-
-if enabled msvc; then
-    lib /? > /dev/null 2>&1 /dev/null || {
-        echo "MSVC's lib command not found."
-        echo "Make sure MSVC is installed and its bin folder is in your \$PATH."
-        exit 1
-    }
-fi
-
-if ! enabled stripping; then
-    strip="echo ignoring strip"
-fi
-
-enabled msvc && libcmd="lib" || libcmd="echo ignoring lib"
-
-echo "# Automatically generated by configure" > config.mak
-echo "PREFIX=$PREFIX" >> config.mak
-echo "bindir=$bindir" >> config.mak
-echo "libdir=$libdir" >> config.mak
-echo "incdir=$incdir" >> config.mak
-echo "AR=$ar" >> config.mak
-echo "CC=$cc" >> config.mak
-echo "RANLIB=$ranlib" >> config.mak
-echo "STRIP=$strip" >> config.mak
-echo "BUILD_STATIC=$static" >> config.mak
-echo "BUILD_SHARED=$shared" >> config.mak
-echo "BUILD_MSVC=$msvc" >> config.mak
-echo "LIBCMD=$libcmd" >> config.mak
-
-echo "prefix: $PREFIX"
-echo "bindir: $bindir"
-echo "libdir: $libdir"
-echo "incdir: $incdir"
-echo "ar:     $ar"
-echo "cc:     $cc"
-echo "ranlib: $ranlib"
-echo "strip:  $strip"
-echo "static: $static"
-echo "shared: $shared"
diff --git a/deps/mman/mman-win32.pro b/deps/mman/mman-win32.pro
deleted file mode 100644 (file)
index b58b4d9..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-QT -= core gui\r
-\r
-TARGET = mman\r
-TEMPLATE = lib\r
-\r
-DEFINES += MMAN_LIBRARY_DLL\r
-DEFINES += MMAN_LIBRARY\r
-\r
-HEADERS += \\r
-    mman.h\r
-\r
-SOURCES += \\r
-    mman.c\r
diff --git a/deps/mman/mman.c b/deps/mman/mman.c
deleted file mode 100644 (file)
index e71666c..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-
-#include <windows.h>
-#include <errno.h>
-#include <io.h>
-
-#include "mman.h"
-
-#ifndef FILE_MAP_EXECUTE
-#define FILE_MAP_EXECUTE    0x0020
-#endif /* FILE_MAP_EXECUTE */
-
-static int __map_mman_error(const DWORD err, const int deferr)
-{
-    if (err == 0)
-        return 0;
-    //TODO: implement
-    return err;
-}
-
-static DWORD __map_mmap_prot_page(const int prot)
-{
-    DWORD protect = 0;
-    
-    if (prot == PROT_NONE)
-        return protect;
-        
-    if ((prot & PROT_EXEC) != 0)
-    {
-        protect = ((prot & PROT_WRITE) != 0) ? 
-                    PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_READ;
-    }
-    else
-    {
-        protect = ((prot & PROT_WRITE) != 0) ?
-                    PAGE_READWRITE : PAGE_READONLY;
-    }
-    
-    return protect;
-}
-
-static DWORD __map_mmap_prot_file(const int prot)
-{
-    DWORD desiredAccess = 0;
-    
-    if (prot == PROT_NONE)
-        return desiredAccess;
-        
-    if ((prot & PROT_READ) != 0)
-        desiredAccess |= FILE_MAP_READ;
-    if ((prot & PROT_WRITE) != 0)
-        desiredAccess |= FILE_MAP_WRITE;
-    if ((prot & PROT_EXEC) != 0)
-        desiredAccess |= FILE_MAP_EXECUTE;
-    
-    return desiredAccess;
-}
-
-void* mmap(void *addr, size_t len, int prot, int flags, int fildes, OffsetType off)
-{
-    HANDLE fm, h;
-    
-    void * map = MAP_FAILED;
-    
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable: 4293)
-#endif
-
-    const DWORD dwFileOffsetLow = (sizeof(OffsetType) <= sizeof(DWORD)) ?
-                    (DWORD)off : (DWORD)(off & 0xFFFFFFFFL);
-    const DWORD dwFileOffsetHigh = (sizeof(OffsetType) <= sizeof(DWORD)) ?
-                    (DWORD)0 : (DWORD)((off >> 32) & 0xFFFFFFFFL);
-    const DWORD protect = __map_mmap_prot_page(prot);
-    const DWORD desiredAccess = __map_mmap_prot_file(prot);
-
-    const OffsetType maxSize = off + (OffsetType)len;
-
-    const DWORD dwMaxSizeLow = (sizeof(OffsetType) <= sizeof(DWORD)) ?
-                    (DWORD)maxSize : (DWORD)(maxSize & 0xFFFFFFFFL);
-    const DWORD dwMaxSizeHigh = (sizeof(OffsetType) <= sizeof(DWORD)) ?
-                    (DWORD)0 : (DWORD)((maxSize >> 32) & 0xFFFFFFFFL);
-
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
-
-    errno = 0;
-    
-    if (len == 0 
-        /* Usupported protection combinations */
-        || prot == PROT_EXEC)
-    {
-        errno = EINVAL;
-        return MAP_FAILED;
-    }
-    
-    h = ((flags & MAP_ANONYMOUS) == 0) ? 
-                    (HANDLE)_get_osfhandle(fildes) : INVALID_HANDLE_VALUE;
-
-    if ((flags & MAP_ANONYMOUS) == 0 && h == INVALID_HANDLE_VALUE)
-    {
-        errno = EBADF;
-        return MAP_FAILED;
-    }
-
-    fm = CreateFileMapping(h, NULL, protect, dwMaxSizeHigh, dwMaxSizeLow, NULL);
-
-    if (fm == NULL)
-    {
-        errno = __map_mman_error(GetLastError(), EPERM);
-        return MAP_FAILED;
-    }
-  
-    if ((flags & MAP_FIXED) == 0)
-    {
-        map = MapViewOfFile(fm, desiredAccess, dwFileOffsetHigh, dwFileOffsetLow, len);
-    }
-    else
-    {
-        map = MapViewOfFileEx(fm, desiredAccess, dwFileOffsetHigh, dwFileOffsetLow, len, addr);
-    }
-
-    CloseHandle(fm);
-  
-    if (map == NULL)
-    {
-        errno = __map_mman_error(GetLastError(), EPERM);
-        return MAP_FAILED;
-    }
-
-    return map;
-}
-
-int munmap(void *addr, size_t len)
-{
-    if (UnmapViewOfFile(addr))
-        return 0;
-        
-    errno =  __map_mman_error(GetLastError(), EPERM);
-    
-    return -1;
-}
-
-int _mprotect(void *addr, size_t len, int prot)
-{
-    DWORD newProtect = __map_mmap_prot_page(prot);
-    DWORD oldProtect = 0;
-    
-    if (VirtualProtect(addr, len, newProtect, &oldProtect))
-        return 0;
-    
-    errno =  __map_mman_error(GetLastError(), EPERM);
-    
-    return -1;
-}
-
-int msync(void *addr, size_t len, int flags)
-{
-    if (FlushViewOfFile(addr, len))
-        return 0;
-    
-    errno =  __map_mman_error(GetLastError(), EPERM);
-    
-    return -1;
-}
-
-int mlock(const void *addr, size_t len)
-{
-    if (VirtualLock((LPVOID)addr, len))
-        return 0;
-        
-    errno =  __map_mman_error(GetLastError(), EPERM);
-    
-    return -1;
-}
-
-int munlock(const void *addr, size_t len)
-{
-    if (VirtualUnlock((LPVOID)addr, len))
-        return 0;
-        
-    errno =  __map_mman_error(GetLastError(), EPERM);
-    
-    return -1;
-}
diff --git a/deps/mman/mman.h b/deps/mman/mman.h
deleted file mode 100644 (file)
index 047d3a0..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * sys/mman.h
- * mman-win32
- */
-
-#ifndef _SYS_MMAN_H_
-#define _SYS_MMAN_H_
-
-#ifndef _WIN32_WINNT           // Allow use of features specific to Windows XP or later.                   
-#define _WIN32_WINNT 0x0501    // Change this to the appropriate value to target other versions of Windows.
-#endif                                         
-
-/* All the headers include this file. */
-#ifndef _MSC_VER
-#include <_mingw.h>
-#endif
-
-#if defined(MMAN_LIBRARY_DLL)
-/* Windows shared libraries (DLL) must be declared export when building the lib and import when building the 
-application which links against the library. */
-#if defined(MMAN_LIBRARY)
-#define MMANSHARED_EXPORT __declspec(dllexport)
-#else
-#define MMANSHARED_EXPORT __declspec(dllimport)
-#endif /* MMAN_LIBRARY */
-#else
-/* Static libraries do not require a __declspec attribute.*/
-#define MMANSHARED_EXPORT
-#endif /* MMAN_LIBRARY_DLL */
-
-/* Determine offset type */
-#include <stdint.h>
-#if defined(_WIN64)
-typedef int64_t OffsetType;
-#else
-typedef uint32_t OffsetType;
-#endif
-
-#include <sys/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define PROT_NONE       0
-#define PROT_READ       1
-#define PROT_WRITE      2
-#define PROT_EXEC       4
-
-#define MAP_FILE        0
-#define MAP_SHARED      1
-#define MAP_PRIVATE     2
-#define MAP_TYPE        0xf
-#define MAP_FIXED       0x10
-#define MAP_ANONYMOUS   0x20
-#define MAP_ANON        MAP_ANONYMOUS
-
-#define MAP_FAILED      ((void *)-1)
-
-/* Flags for msync. */
-#define MS_ASYNC        1
-#define MS_SYNC         2
-#define MS_INVALIDATE   4
-
-MMANSHARED_EXPORT void*   mmap(void *addr, size_t len, int prot, int flags, int fildes, OffsetType off);
-MMANSHARED_EXPORT int     munmap(void *addr, size_t len);
-MMANSHARED_EXPORT int     _mprotect(void *addr, size_t len, int prot);
-MMANSHARED_EXPORT int     msync(void *addr, size_t len, int flags);
-MMANSHARED_EXPORT int     mlock(const void *addr, size_t len);
-MMANSHARED_EXPORT int     munlock(const void *addr, size_t len);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*  _SYS_MMAN_H_ */
diff --git a/deps/mman/mman.sln b/deps/mman/mman.sln
deleted file mode 100644 (file)
index 69fb506..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.25420.1
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mman", "mman.vcxproj", "{592F578E-6F24-47C0-9F6C-07BC9B730E27}"
-EndProject
-Global
-       GlobalSection(SolutionConfigurationPlatforms) = preSolution
-               Debug|x64 = Debug|x64
-               Debug|x86 = Debug|x86
-               Release|x64 = Release|x64
-               Release|x86 = Release|x86
-       EndGlobalSection
-       GlobalSection(ProjectConfigurationPlatforms) = postSolution
-               {592F578E-6F24-47C0-9F6C-07BC9B730E27}.Debug|x64.ActiveCfg = Debug|x64
-               {592F578E-6F24-47C0-9F6C-07BC9B730E27}.Debug|x64.Build.0 = Debug|x64
-               {592F578E-6F24-47C0-9F6C-07BC9B730E27}.Debug|x86.ActiveCfg = Debug|Win32
-               {592F578E-6F24-47C0-9F6C-07BC9B730E27}.Debug|x86.Build.0 = Debug|Win32
-               {592F578E-6F24-47C0-9F6C-07BC9B730E27}.Release|x64.ActiveCfg = Release|x64
-               {592F578E-6F24-47C0-9F6C-07BC9B730E27}.Release|x64.Build.0 = Release|x64
-               {592F578E-6F24-47C0-9F6C-07BC9B730E27}.Release|x86.ActiveCfg = Release|Win32
-               {592F578E-6F24-47C0-9F6C-07BC9B730E27}.Release|x86.Build.0 = Release|Win32
-       EndGlobalSection
-       GlobalSection(SolutionProperties) = preSolution
-               HideSolutionNode = FALSE
-       EndGlobalSection
-EndGlobal
diff --git a/deps/mman/mman.vcxproj b/deps/mman/mman.vcxproj
deleted file mode 100644 (file)
index e8dffa2..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup Label="ProjectConfigurations">
-    <ProjectConfiguration Include="Debug|Win32">
-      <Configuration>Debug</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Release|Win32">
-      <Configuration>Release</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Debug|x64">
-      <Configuration>Debug</Configuration>
-      <Platform>x64</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Release|x64">
-      <Configuration>Release</Configuration>
-      <Platform>x64</Platform>
-    </ProjectConfiguration>
-  </ItemGroup>
-  <PropertyGroup Label="Globals">
-    <ProjectGuid>{592F578E-6F24-47C0-9F6C-07BC9B730E27}</ProjectGuid>
-    <Keyword>Win32Proj</Keyword>
-    <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
-    <ConfigurationType>Application</ConfigurationType>
-    <UseDebugLibraries>true</UseDebugLibraries>
-    <PlatformToolset>v140</PlatformToolset>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-    <ConfigurationType>Application</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <PlatformToolset>v140</PlatformToolset>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
-    <ConfigurationType>StaticLibrary</ConfigurationType>
-    <UseDebugLibraries>true</UseDebugLibraries>
-    <PlatformToolset>v140</PlatformToolset>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
-    <ConfigurationType>StaticLibrary</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <PlatformToolset>v140</PlatformToolset>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
-  <ImportGroup Label="ExtensionSettings">
-  </ImportGroup>
-  <ImportGroup Label="Shared">
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <PropertyGroup Label="UserMacros" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <LinkIncremental>true</LinkIncremental>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <LinkIncremental>true</LinkIncremental>
-  </PropertyGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <ClCompile>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
-      <WarningLevel>Level3</WarningLevel>
-      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
-      <Optimization>Disabled</Optimization>
-    </ClCompile>
-    <Link>
-      <TargetMachine>MachineX86</TargetMachine>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <SubSystem>Console</SubSystem>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <ClCompile>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
-      <WarningLevel>Level3</WarningLevel>
-      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
-    </ClCompile>
-    <Link>
-      <TargetMachine>MachineX86</TargetMachine>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <SubSystem>Console</SubSystem>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
-    <ClCompile>
-      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
-    </ClCompile>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
-    <ClCompile>
-      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
-    </ClCompile>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <ClCompile Include="mman.c" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="mman.h" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="UpgradeLog.htm" />
-  </ItemGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-  <ImportGroup Label="ExtensionTargets">
-  </ImportGroup>
-</Project>
\ No newline at end of file
diff --git a/deps/mman/mman.vcxproj.filters b/deps/mman/mman.vcxproj.filters
deleted file mode 100644 (file)
index a08c8d5..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup>
-    <Filter Include="Source Files">
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
-      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
-    </Filter>
-    <Filter Include="Header Files">
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
-      <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
-    </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
-    </Filter>
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="mman.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="mman.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="UpgradeLog.htm" />
-  </ItemGroup>
-</Project>
\ No newline at end of file
diff --git a/deps/mman/mman.vcxproj.user b/deps/mman/mman.vcxproj.user
deleted file mode 100644 (file)
index abe8dd8..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <PropertyGroup />
-</Project>
\ No newline at end of file
diff --git a/deps/mman/test.c b/deps/mman/test.c
deleted file mode 100644 (file)
index 9374b9f..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-
-#include "mman.h"
-
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-
-#ifndef NULL
-#define NULL    (void*)0
-#endif
-
-const char* map_file_name = "map_file.dat";
-
-int test_anon_map_readwrite()
-{    
-    void* map = mmap(NULL, 1024, PROT_READ | PROT_WRITE,
-                     MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-    if (map == MAP_FAILED)
-    {
-        printf("mmap (MAP_ANONYMOUS, PROT_READ | PROT_WRITE) returned unexpected error: %d\n", errno);
-        return -1;
-    }
-        
-    *((unsigned char*)map) = 1;
-    
-    int result = munmap(map, 1024);
-    
-    if (result != 0)
-        printf("munmap (MAP_ANONYMOUS, PROT_READ | PROT_WRITE) returned unexpected error: %d\n", errno);
-        
-    return result;
-}
-
-int test_anon_map_readonly()
-{    
-    void* map = mmap(NULL, 1024, PROT_READ,
-                     MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-    if (map == MAP_FAILED)
-    {
-        printf("mmap (MAP_ANONYMOUS, PROT_READ) returned unexpected error: %d\n", errno);
-        return -1;
-    }
-        
-    *((unsigned char*)map) = 1;
-    
-    int result = munmap(map, 1024);
-    
-    if (result != 0)
-        printf("munmap (MAP_ANONYMOUS, PROT_READ) returned unexpected error: %d\n", errno);
-        
-    return result;
-}
-
-int test_anon_map_writeonly()
-{    
-    void* map = mmap(NULL, 1024, PROT_WRITE,
-                     MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-    if (map == MAP_FAILED)
-    {
-        printf("mmap (MAP_ANONYMOUS, PROT_WRITE) returned unexpected error: %d\n", errno);
-        return -1;
-    }
-        
-    *((unsigned char*)map) = 1;
-    
-    int result = munmap(map, 1024);
-    
-    if (result != 0)
-        printf("munmap (MAP_ANONYMOUS, PROT_WRITE) returned unexpected error: %d\n", errno);
-        
-    return result;
-}
-
-int test_anon_map_readonly_nowrite()
-{    
-    void* map = mmap(NULL, 1024, PROT_READ,
-                     MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-    if (map == MAP_FAILED)
-    {
-        printf("mmap (MAP_ANONYMOUS, PROT_READ) returned unexpected error: %d\n", errno);
-        return -1;
-    }
-    
-    if (*((unsigned char*)map) != 0)
-        printf("test_anon_map_readonly_nowrite (MAP_ANONYMOUS, PROT_READ) returned unexpected value: %d\n", 
-                (int)*((unsigned char*)map));
-        
-    int result = munmap(map, 1024);
-    
-    if (result != 0)
-        printf("munmap (MAP_ANONYMOUS, PROT_READ) returned unexpected error: %d\n", errno);
-        
-    return result;
-}
-
-int test_file_map_readwrite()
-{
-    mode_t mode = S_IRUSR | S_IWUSR;
-    int o = open(map_file_name, O_TRUNC | O_BINARY | O_RDWR | O_CREAT, mode);
-
-    void* map = mmap(NULL, 1024, PROT_READ | PROT_WRITE, MAP_PRIVATE, o, 0);
-    if (map == MAP_FAILED)
-    {
-        printf("mmap returned unexpected error: %d\n", errno);
-        return -1;
-    }
-
-    *((unsigned char*)map) = 1;
-    
-    int result = munmap(map, 1024);
-    
-    if (result != 0)
-        printf("munmap returned unexpected error: %d\n", errno);
-    
-    close(o);
-    
-    /*TODO: get file info and content and compare it with the sources conditions */
-    unlink(map_file_name);
-    
-    return result;
-}
-
-int test_file_map_mlock_munlock()
-{
-    const size_t map_size = 1024;
-    
-    int result = 0;
-    mode_t mode = S_IRUSR | S_IWUSR;
-    int o = open(map_file_name, O_TRUNC | O_BINARY | O_RDWR | O_CREAT, mode);
-    if (o == -1)
-    {
-        printf("unable to create file %s: %d\n", map_file_name, errno);
-        return -1;
-    }
-
-    void* map = mmap(NULL, map_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, o, 0);
-    if (map == MAP_FAILED)
-    {
-        printf("mmap returned unexpected error: %d\n", errno);
-        result = -1;
-        goto done_close;
-    }
-     
-    if (mlock(map, map_size) != 0)
-    {
-        printf("mlock returned unexpected error: %d\n", errno);
-        result = -1;
-        goto done_munmap;        
-    }
-    
-    *((unsigned char*)map) = 1;
-    
-    if (munlock(map, map_size) != 0)
-    {
-        printf("munlock returned unexpected error: %d\n", errno);
-        result = -1;
-    }
-    
-done_munmap:
-    result = munmap(map, map_size);
-    
-    if (result != 0)
-        printf("munmap returned unexpected error: %d\n", errno);
-        
-done_close:
-    close(o);
-    
-    unlink(map_file_name);
-done:
-    return result;
-}
-
-int test_file_map_msync()
-{
-    const size_t map_size = 1024;
-    
-    int result = 0;
-    mode_t mode = S_IRUSR | S_IWUSR;
-    int o = open(map_file_name, O_TRUNC | O_BINARY | O_RDWR | O_CREAT, mode);
-    if (o == -1)
-    {
-        printf("unable to create file %s: %d\n", map_file_name, errno);
-        return -1;
-    }
-
-    void* map = mmap(NULL, map_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, o, 0);
-    if (map == MAP_FAILED)
-    {
-        printf("mmap returned unexpected error: %d\n", errno);
-        result = -1;
-        goto done_close;
-    }
-     
-    *((unsigned char*)map) = 1;
-
-    if (msync(map, map_size, MS_SYNC) != 0)
-    {
-        printf("msync returned unexpected error: %d\n", errno);
-        result = -1;
-    }
-    
-    result = munmap(map, map_size);
-    
-    if (result != 0)
-        printf("munmap returned unexpected error: %d\n", errno);
-        
-done_close:
-    close(o);
-    
-    unlink(map_file_name);
-done:
-    return result;
-}
-
-#define EXEC_TEST(name) \
-    if (name() != 0) { result = -1; printf( #name ": fail\n"); } \
-    else { printf(#name ": pass\n"); }
-
-int main()
-{
-    int result = 0;
-    
-    EXEC_TEST(test_anon_map_readwrite);
-    //NOTE: this test must cause an access violation exception
-    //EXEC_TEST(test_anon_map_readonly);
-    EXEC_TEST(test_anon_map_readonly_nowrite);
-    EXEC_TEST(test_anon_map_writeonly);
-    
-    EXEC_TEST(test_file_map_readwrite);
-    EXEC_TEST(test_file_map_mlock_munlock);
-    EXEC_TEST(test_file_map_msync);
-    //TODO: EXEC_TEST(test_file_map_mprotect);
-    
-    return result;
-}
diff --git a/deps/zlib/adler32.c b/deps/zlib/adler32.c
deleted file mode 100644 (file)
index cccb3a2..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/* adler32.c -- compute the Adler-32 checksum of a data stream
- * Copyright (C) 1995-2003 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#define ZLIB_INTERNAL
-#include <stdint.h>
-#include <stddef.h>
-#include "zutil.h"
-
-#define BASE 65521UL    /* largest prime smaller than 65536 */
-#define NMAX 5552
-/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
-
-#define DO1(buf,i)  {s1 += buf[i]; s2 += s1;}
-#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
-#define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
-#define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);
-#define DO16(buf)   DO8(buf,0); DO8(buf,8);
-
-#ifdef NO_DIVIDE
-#  define MOD(a) \
-   do { \
-      if (a >= (BASE << 16)) a -= (BASE << 16); \
-      if (a >= (BASE << 15)) a -= (BASE << 15); \
-      if (a >= (BASE << 14)) a -= (BASE << 14); \
-      if (a >= (BASE << 13)) a -= (BASE << 13); \
-      if (a >= (BASE << 12)) a -= (BASE << 12); \
-      if (a >= (BASE << 11)) a -= (BASE << 11); \
-      if (a >= (BASE << 10)) a -= (BASE << 10); \
-      if (a >= (BASE << 9)) a -= (BASE << 9); \
-      if (a >= (BASE << 8)) a -= (BASE << 8); \
-      if (a >= (BASE << 7)) a -= (BASE << 7); \
-      if (a >= (BASE << 6)) a -= (BASE << 6); \
-      if (a >= (BASE << 5)) a -= (BASE << 5); \
-      if (a >= (BASE << 4)) a -= (BASE << 4); \
-      if (a >= (BASE << 3)) a -= (BASE << 3); \
-      if (a >= (BASE << 2)) a -= (BASE << 2); \
-      if (a >= (BASE << 1)) a -= (BASE << 1); \
-      if (a >= BASE) a -= BASE; \
-   } while (0)
-#else
-#  define MOD(a) a %= BASE
-#endif
-
-/* ========================================================================= */
-uLong adler32(uLong adler, const Bytef *buf, uInt len)
-{
-   uint32_t s1 = adler & 0xffff;
-   uint32_t s2 = (adler >> 16) & 0xffff;
-   int k;
-
-   if (buf == NULL)
-      return 1L;
-
-   while (len > 0) {
-      k = len < NMAX ? (int)len : NMAX;
-      len -= k;
-      while (k >= 16) {
-         DO16(buf);
-         buf += 16;
-         k -= 16;
-      }
-      if (k != 0) do {
-         s1 += *buf++;
-         s2 += s1;
-      } while (--k);
-      MOD(s1);
-      MOD(s2);
-   }
-   return (s2 << 16) | s1;
-}
-
diff --git a/deps/zlib/compress.c b/deps/zlib/compress.c
deleted file mode 100644 (file)
index 48465bd..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/* compress.c -- compress a memory buffer
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#define ZLIB_INTERNAL
-#include "zlib.h"
-
-/* ===========================================================================
-   Compresses the source buffer into the destination buffer. The level
-   parameter has the same meaning as in deflateInit.  sourceLen is the byte
-   length of the source buffer. Upon entry, destLen is the total size of the
-   destination buffer, which must be at least 0.1% larger than sourceLen plus
-   12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
-
-   compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
-   memory, Z_BUF_ERROR if there was not enough room in the output buffer,
-   Z_STREAM_ERROR if the level parameter is invalid.
-   */
-int ZEXPORT compress2 (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level)
-{
-   z_stream stream;
-   int err;
-
-   stream.next_in = (Bytef *)source;
-   stream.avail_in = (uInt)sourceLen;
-#ifdef MAXSEG_64K
-   /* Check for source > 64K on 16-bit machine: */
-   if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
-#endif
-   stream.next_out = dest;
-   stream.avail_out = (uInt)*destLen;
-   if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
-
-   stream.zalloc = Z_NULL;
-   stream.zfree = Z_NULL;
-   stream.opaque = (voidpf)0;
-
-   err = deflateInit(&stream, level);
-   if (err != Z_OK) return err;
-
-   err = deflate(&stream, Z_FINISH);
-   if (err != Z_STREAM_END) {
-      deflateEnd(&stream);
-      return err == Z_OK ? Z_BUF_ERROR : err;
-   }
-   *destLen = stream.total_out;
-
-   err = deflateEnd(&stream);
-   return err;
-}
-
-/* ===========================================================================
-*/
-int ZEXPORT compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
-{
-   return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
-}
-
-/* ===========================================================================
-   If the default memLevel or windowBits for deflateInit() is changed, then
-   this function needs to be updated.
-   */
-uLong ZEXPORT compressBound (uLong sourceLen)
-{
-   return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
-      (sourceLen >> 25) + 13;
-}
diff --git a/deps/zlib/crc32.c b/deps/zlib/crc32.c
deleted file mode 100644 (file)
index 73369a2..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-#ifndef _S_CRC32_H
-#define _S_CRC32_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-   static const unsigned long crc_table[256] = {
-      0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
-      0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
-      0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
-      0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
-      0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
-      0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
-      0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
-      0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
-      0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
-      0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
-      0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
-      0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
-      0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
-      0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
-      0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
-      0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
-      0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
-      0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
-      0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
-      0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
-      0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
-      0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
-      0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
-      0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
-      0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
-      0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
-      0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
-      0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
-      0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
-      0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
-      0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
-      0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
-      0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
-      0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
-      0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
-      0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
-      0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
-      0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
-      0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
-      0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
-      0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
-      0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
-      0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
-      0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
-      0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
-      0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
-      0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
-      0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
-      0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
-      0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
-      0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
-      0x2d02ef8dL
-   };
-
-#define DO1_CRC32(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
-#define DO2_CRC32(buf) DO1_CRC32(buf); DO1_CRC32(buf);
-#define DO4_CRC32(buf) DO2_CRC32(buf); DO2_CRC32(buf);
-#define DO8_CRC32(buf) DO4_CRC32(buf); DO4_CRC32(buf);
-
-   unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned int len)
-   {
-      if (buf == 0) return 0L;
-      crc = crc ^ 0xffffffffL;
-      while (len >= 8)
-      {
-         DO8_CRC32(buf);
-         len -= 8;
-      }
-      if (len) do {
-         DO1_CRC32(buf);
-      } while (--len);
-      return crc ^ 0xffffffffL;
-   }
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/deps/zlib/deflate.c b/deps/zlib/deflate.c
deleted file mode 100644 (file)
index f8fbc48..0000000
+++ /dev/null
@@ -1,1913 +0,0 @@
-/* deflate.c -- compress data using the deflation algorithm
- * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- *  ALGORITHM
- *
- *      The "deflation" process depends on being able to identify portions
- *      of the input text which are identical to earlier input (within a
- *      sliding window trailing behind the input currently being processed).
- *
- *      The most straightforward technique turns out to be the fastest for
- *      most input files: try all possible matches and select the longest.
- *      The key feature of this algorithm is that insertions into the string
- *      dictionary are very simple and thus fast, and deletions are avoided
- *      completely. Insertions are performed at each input character, whereas
- *      string matches are performed only when the previous match ends. So it
- *      is preferable to spend more time in matches to allow very fast string
- *      insertions and avoid deletions. The matching algorithm for small
- *      strings is inspired from that of Rabin & Karp. A brute force approach
- *      is used to find longer strings when a small match has been found.
- *      A similar algorithm is used in comic (by Jan-Mark Wams) and freeze
- *      (by Leonid Broukhis).
- *         A previous version of this file used a more sophisticated algorithm
- *      (by Fiala and Greene) which is guaranteed to run in linear amortized
- *      time, but has a larger average cost, uses more memory and is patented.
- *      However the F&G algorithm may be faster for some highly redundant
- *      files if the parameter max_chain_length (described below) is too large.
- *
- *  ACKNOWLEDGEMENTS
- *
- *      The idea of lazy evaluation of matches is due to Jan-Mark Wams, and
- *      I found it in 'freeze' written by Leonid Broukhis.
- *      Thanks to many people for bug reports and testing.
- *
- *  REFERENCES
- *
- *      Deutsch, L.P.,"DEFLATE Compressed Data Format Specification".
- *      Available in http://tools.ietf.org/html/rfc1951
- *
- *      A description of the Rabin and Karp algorithm is given in the book
- *         "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
- *
- *      Fiala,E.R., and Greene,D.H.
- *         Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595
- *
- */
-
-/* @(#) $Id$ */
-
-#include "deflate.h"
-
-const char deflate_copyright[] =
-" deflate 1.2.8 Copyright 1995-2013 Jean-loup Gailly and Mark Adler ";
-/*
-   If you use the zlib library in a product, an acknowledgment is welcome
-   in the documentation of your product. If for some reason you cannot
-   include such an acknowledgment, I would appreciate that you keep this
-   copyright string in the executable of your product.
-   */
-
-/* ===========================================================================
- *  Function prototypes.
- */
-typedef enum {
-   need_more,      /* block not completed, need more input or more output */
-   block_done,     /* block flush performed */
-   finish_started, /* finish started, need only more output at next deflate */
-   finish_done     /* finish done, accept no more input or output */
-} block_state;
-
-typedef block_state (*compress_func) OF((deflate_state *s, int flush));
-/* Compression function. Returns the block state after the call. */
-
-local void fill_window    OF((deflate_state *s));
-local block_state deflate_stored OF((deflate_state *s, int flush));
-local block_state deflate_fast   OF((deflate_state *s, int flush));
-#ifndef FASTEST
-local block_state deflate_slow   OF((deflate_state *s, int flush));
-#endif
-local block_state deflate_rle    OF((deflate_state *s, int flush));
-local block_state deflate_huff   OF((deflate_state *s, int flush));
-local void lm_init        OF((deflate_state *s));
-local void putShortMSB    OF((deflate_state *s, uInt b));
-local void flush_pending  OF((z_streamp strm));
-local int read_buf        OF((z_streamp strm, Bytef *buf, unsigned size));
-#ifdef ASMV
-void match_init OF((void)); /* asm code initialization */
-uInt longest_match  OF((deflate_state *s, IPos cur_match));
-#else
-local uInt longest_match  OF((deflate_state *s, IPos cur_match));
-#endif
-
-#ifdef DEBUG
-local  void check_match OF((deflate_state *s, IPos start, IPos match,
-         int length));
-#endif
-
-/* ===========================================================================
- * Local data
- */
-
-#define NIL 0
-/* Tail of hash chains */
-
-#ifndef TOO_FAR
-#  define TOO_FAR 4096
-#endif
-/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
-
-/* Values for max_lazy_match, good_match and max_chain_length, depending on
- * the desired pack level (0..9). The values given below have been tuned to
- * exclude worst case performance for pathological files. Better values may be
- * found for specific files.
- */
-typedef struct config_s {
-   ush good_length; /* reduce lazy search above this match length */
-   ush max_lazy;    /* do not perform lazy search above this match length */
-   ush nice_length; /* quit search above this match length */
-   ush max_chain;
-   compress_func func;
-} config;
-
-#ifdef FASTEST
-local const config configuration_table[2] = {
-   /*      good lazy nice chain */
-   /* 0 */ {0,    0,  0,    0, deflate_stored},  /* store only */
-   /* 1 */ {4,    4,  8,    4, deflate_fast}}; /* max speed, no lazy matches */
-#else
-local const config configuration_table[10] = {
-   /*      good lazy nice chain */
-   /* 0 */ {0,    0,  0,    0, deflate_stored},  /* store only */
-   /* 1 */ {4,    4,  8,    4, deflate_fast}, /* max speed, no lazy matches */
-   /* 2 */ {4,    5, 16,    8, deflate_fast},
-   /* 3 */ {4,    6, 32,   32, deflate_fast},
-
-   /* 4 */ {4,    4, 16,   16, deflate_slow},  /* lazy matches */
-   /* 5 */ {8,   16, 32,   32, deflate_slow},
-   /* 6 */ {8,   16, 128, 128, deflate_slow},
-   /* 7 */ {8,   32, 128, 256, deflate_slow},
-   /* 8 */ {32, 128, 258, 1024, deflate_slow},
-   /* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */
-#endif
-
-/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4
- * For deflate_fast() (levels <= 3) good is ignored and lazy has a different
- * meaning.
- */
-
-#define EQUAL 0
-/* result of memcmp for equal strings */
-
-/* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */
-#define RANK(f) (((f) << 1) - ((f) > 4 ? 9 : 0))
-
-/* ===========================================================================
- * Update a hash value with the given input byte
- * IN  assertion: all calls to to UPDATE_HASH are made with consecutive
- *    input characters, so that a running hash key can be computed from the
- *    previous key instead of complete recalculation each time.
- */
-#define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)
-
-
-/* ===========================================================================
- * Insert string str in the dictionary and set match_head to the previous head
- * of the hash chain (the most recent string with same hash key). Return
- * the previous length of the hash chain.
- * If this file is compiled with -DFASTEST, the compression level is forced
- * to 1, and no hash chains are maintained.
- * IN  assertion: all calls to to INSERT_STRING are made with consecutive
- *    input characters and the first MIN_MATCH bytes of str are valid
- *    (except for the last MIN_MATCH-1 bytes of the input file).
- */
-#ifdef FASTEST
-#define INSERT_STRING(s, str, match_head) \
-   (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
-    match_head = s->head[s->ins_h], \
-    s->head[s->ins_h] = (Pos)(str))
-#else
-#define INSERT_STRING(s, str, match_head) \
-   (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
-    match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \
-    s->head[s->ins_h] = (Pos)(str))
-#endif
-
-/* ===========================================================================
- * Initialize the hash table (avoiding 64K overflow for 16 bit systems).
- * prev[] will be initialized on the fly.
- */
-#define CLEAR_HASH(s) \
-   s->head[s->hash_size-1] = NIL; \
-zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
-
-int ZEXPORT deflateResetKeep (z_streamp strm);
-
-int ZEXPORT deflatePending (z_streamp strm, unsigned *pending, int *bits);
-
-/* ========================================================================= */
-int ZEXPORT deflateInit_(z_streamp strm, int level, const char *version, int stream_size)
-{
-   return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
-         Z_DEFAULT_STRATEGY, version, stream_size);
-   /* To do: ignore strm->next_in if we use it as window */
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy,
-      const char *version, int stream_size)
-{
-   deflate_state *s;
-   int wrap = 1;
-   static const char my_version[] = ZLIB_VERSION;
-
-   ushf *overlay;
-   /* We overlay pending_buf and d_buf+l_buf. This works since the average
-    * output size for (length,distance) codes is <= 24 bits.
-    */
-
-   if (version == Z_NULL || version[0] != my_version[0] ||
-         stream_size != sizeof(z_stream)) {
-      return Z_VERSION_ERROR;
-   }
-   if (strm == Z_NULL) return Z_STREAM_ERROR;
-
-   strm->msg = Z_NULL;
-   if (strm->zalloc == (alloc_func)0) {
-#ifdef Z_SOLO
-      return Z_STREAM_ERROR;
-#else
-      strm->zalloc = zcalloc;
-      strm->opaque = (voidpf)0;
-#endif
-   }
-   if (strm->zfree == NULL)
-#ifdef Z_SOLO
-      return Z_STREAM_ERROR;
-#else
-   strm->zfree = zcfree;
-#endif
-
-#ifdef FASTEST
-   if (level != 0) level = 1;
-#else
-   if (level == Z_DEFAULT_COMPRESSION) level = 6;
-#endif
-
-   if (windowBits < 0) { /* suppress zlib wrapper */
-      wrap = 0;
-      windowBits = -windowBits;
-   }
-#ifdef GZIP
-   else if (windowBits > 15) {
-      wrap = 2;       /* write gzip wrapper instead */
-      windowBits -= 16;
-   }
-#endif
-   if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
-         windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
-         strategy < 0 || strategy > Z_FIXED) {
-      return Z_STREAM_ERROR;
-   }
-   if (windowBits == 8) windowBits = 9;  /* until 256-byte window bug fixed */
-   s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
-   if (s == Z_NULL) return Z_MEM_ERROR;
-   strm->state = (struct internal_state*)s;
-   s->strm = strm;
-
-   s->wrap = wrap;
-   s->gzhead = Z_NULL;
-   s->w_bits = windowBits;
-   s->w_size = 1 << s->w_bits;
-   s->w_mask = s->w_size - 1;
-
-   s->hash_bits = memLevel + 7;
-   s->hash_size = 1 << s->hash_bits;
-   s->hash_mask = s->hash_size - 1;
-   s->hash_shift =  ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
-
-   s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
-   s->prev   = (Posf *)  ZALLOC(strm, s->w_size, sizeof(Pos));
-   s->head   = (Posf *)  ZALLOC(strm, s->hash_size, sizeof(Pos));
-
-   s->high_water = 0;      /* nothing written to s->window yet */
-
-   s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
-
-   overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
-   s->pending_buf = (uchf *) overlay;
-   s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L);
-
-   if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
-         s->pending_buf == Z_NULL) {
-      s->status = FINISH_STATE;
-      strm->msg = ERR_MSG(Z_MEM_ERROR);
-      deflateEnd (strm);
-      return Z_MEM_ERROR;
-   }
-   s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
-   s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
-
-   s->level = level;
-   s->strategy = strategy;
-   s->method = (Byte)method;
-
-   return deflateReset(strm);
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateSetDictionary (z_streamp strm, const Bytef *dictionary, uInt dictLength)
-{
-   deflate_state *s;
-   uInt str, n;
-   int wrap;
-   unsigned avail;
-   unsigned char *next;
-
-   if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL)
-      return Z_STREAM_ERROR;
-   s = (deflate_state*)strm->state;
-   wrap = s->wrap;
-   if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead)
-      return Z_STREAM_ERROR;
-
-   /* when using zlib wrappers, compute Adler-32 for provided dictionary */
-   if (wrap == 1)
-      strm->adler = adler32(strm->adler, dictionary, dictLength);
-   s->wrap = 0;                    /* avoid computing Adler-32 in read_buf */
-
-   /* if dictionary would fill window, just replace the history */
-   if (dictLength >= s->w_size) {
-      if (wrap == 0) {            /* already empty otherwise */
-         CLEAR_HASH(s);
-         s->strstart = 0;
-         s->block_start = 0L;
-         s->insert = 0;
-      }
-      dictionary += dictLength - s->w_size;  /* use the tail */
-      dictLength = s->w_size;
-   }
-
-   /* insert dictionary into window and hash */
-   avail = strm->avail_in;
-   next = strm->next_in;
-   strm->avail_in = dictLength;
-   strm->next_in = (Bytef *)dictionary;
-   fill_window(s);
-   while (s->lookahead >= MIN_MATCH) {
-      str = s->strstart;
-      n = s->lookahead - (MIN_MATCH-1);
-      do {
-         UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
-#ifndef FASTEST
-         s->prev[str & s->w_mask] = s->head[s->ins_h];
-#endif
-         s->head[s->ins_h] = (Pos)str;
-         str++;
-      } while (--n);
-      s->strstart = str;
-      s->lookahead = MIN_MATCH-1;
-      fill_window(s);
-   }
-   s->strstart += s->lookahead;
-   s->block_start = (long)s->strstart;
-   s->insert = s->lookahead;
-   s->lookahead = 0;
-   s->match_length = s->prev_length = MIN_MATCH-1;
-   s->match_available = 0;
-   strm->next_in = next;
-   strm->avail_in = avail;
-   s->wrap = wrap;
-   return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateResetKeep (z_streamp strm)
-{
-   deflate_state *s;
-
-   if (strm == Z_NULL || strm->state == Z_NULL ||
-         strm->zalloc == Z_NULL || strm->zfree == Z_NULL) {
-      return Z_STREAM_ERROR;
-   }
-
-   strm->total_in = strm->total_out = 0;
-   strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */
-   strm->data_type = Z_UNKNOWN;
-
-   s = (deflate_state *)strm->state;
-   s->pending = 0;
-   s->pending_out = s->pending_buf;
-
-   if (s->wrap < 0) {
-      s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
-   }
-   s->status = s->wrap ? INIT_STATE : BUSY_STATE;
-   strm->adler =
-#ifdef GZIP
-      s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
-#endif
-      adler32(0L, Z_NULL, 0);
-   s->last_flush = Z_NO_FLUSH;
-
-   _tr_init(s);
-
-   return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateReset (z_streamp strm)
-{
-   int ret;
-
-   ret = deflateResetKeep(strm);
-   if (ret == Z_OK)
-      lm_init((deflate_state*)strm->state);
-   return ret;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateSetHeader (z_streamp strm, gz_headerp head)
-{
-   struct internal_state_deflate *state = (struct internal_state_deflate*)strm->state;
-   if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
-   if (state->wrap != 2)
-      return Z_STREAM_ERROR;
-   state->gzhead = head;
-   return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflatePending (z_streamp strm, unsigned *pending, int *bits)
-{
-   struct internal_state_deflate *state = (struct internal_state_deflate*)strm->state;
-   if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
-   if (pending != Z_NULL)
-      *pending = state->pending;
-   if (bits != Z_NULL)
-      *bits = state->bi_valid;
-   return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflatePrime (z_streamp strm, int bits, int value)
-{
-   deflate_state *s;
-   int put;
-
-   if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
-   s = (deflate_state*)strm->state;
-   if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))
-      return Z_BUF_ERROR;
-   do {
-      put = Buf_size - s->bi_valid;
-      if (put > bits)
-         put = bits;
-      s->bi_buf |= (ush)((value & ((1 << put) - 1)) << s->bi_valid);
-      s->bi_valid += put;
-      _tr_flush_bits(s);
-      value >>= put;
-      bits -= put;
-   } while (bits);
-   return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateParams(z_streamp strm, int level, int strategy)
-{
-   deflate_state *s;
-   compress_func func;
-   int err = Z_OK;
-
-   if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
-   s = (deflate_state*)strm->state;
-
-#ifdef FASTEST
-   if (level != 0) level = 1;
-#else
-   if (level == Z_DEFAULT_COMPRESSION) level = 6;
-#endif
-   if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
-      return Z_STREAM_ERROR;
-   }
-   func = configuration_table[s->level].func;
-
-   if ((strategy != s->strategy || func != configuration_table[level].func) &&
-         strm->total_in != 0) {
-      /* Flush the last buffer: */
-      err = deflate(strm, Z_BLOCK);
-      if (err == Z_BUF_ERROR && s->pending == 0)
-         err = Z_OK;
-   }
-   if (s->level != level) {
-      s->level = level;
-      s->max_lazy_match   = configuration_table[level].max_lazy;
-      s->good_match       = configuration_table[level].good_length;
-      s->nice_match       = configuration_table[level].nice_length;
-      s->max_chain_length = configuration_table[level].max_chain;
-   }
-   s->strategy = strategy;
-   return err;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy, int nice_length, int max_chain)
-{
-   deflate_state *s;
-
-   if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
-   s = (deflate_state*)strm->state;
-   s->good_match = good_length;
-   s->max_lazy_match = max_lazy;
-   s->nice_match = nice_length;
-   s->max_chain_length = max_chain;
-   return Z_OK;
-}
-
-/* =========================================================================
- * For the default windowBits of 15 and memLevel of 8, this function returns
- * a close to exact, as well as small, upper bound on the compressed size.
- * They are coded as constants here for a reason--if the #define's are
- * changed, then this function needs to be changed as well.  The return
- * value for 15 and 8 only works for those exact settings.
- *
- * For any setting other than those defaults for windowBits and memLevel,
- * the value returned is a conservative worst case for the maximum expansion
- * resulting from using fixed blocks instead of stored blocks, which deflate
- * can emit on compressed data for some combinations of the parameters.
- *
- * This function could be more sophisticated to provide closer upper bounds for
- * every combination of windowBits and memLevel.  But even the conservative
- * upper bound of about 14% expansion does not seem onerous for output buffer
- * allocation.
- */
-uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen)
-{
-   deflate_state *s;
-   uLong complen, wraplen;
-   Bytef *str;
-
-   /* conservative upper bound for compressed data */
-   complen = sourceLen +
-      ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5;
-
-   /* if can't get parameters, return conservative bound plus zlib wrapper */
-   if (strm == Z_NULL || strm->state == Z_NULL)
-      return complen + 6;
-
-   /* compute wrapper length */
-   s = (deflate_state*)strm->state;
-   switch (s->wrap) {
-      case 0:                                 /* raw deflate */
-         wraplen = 0;
-         break;
-      case 1:                                 /* zlib wrapper */
-         wraplen = 6 + (s->strstart ? 4 : 0);
-         break;
-      case 2:                                 /* gzip wrapper */
-         wraplen = 18;
-         if (s->gzhead != Z_NULL) {          /* user-supplied gzip header */
-            if (s->gzhead->extra != Z_NULL)
-               wraplen += 2 + s->gzhead->extra_len;
-            str = s->gzhead->name;
-            if (str != Z_NULL)
-               do {
-                  wraplen++;
-               } while (*str++);
-            str = s->gzhead->comment;
-            if (str != Z_NULL)
-               do {
-                  wraplen++;
-               } while (*str++);
-            if (s->gzhead->hcrc)
-               wraplen += 2;
-         }
-         break;
-      default:                                /* for compiler happiness */
-         wraplen = 6;
-   }
-
-   /* if not default parameters, return conservative bound */
-   if (s->w_bits != 15 || s->hash_bits != 8 + 7)
-      return complen + wraplen;
-
-   /* default settings: return tight bound for that case */
-   return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
-      (sourceLen >> 25) + 13 - 6 + wraplen;
-}
-
-/* =========================================================================
- * Put a short in the pending buffer. The 16-bit value is put in MSB order.
- * IN assertion: the stream state is correct and there is enough room in
- * pending_buf.
- */
-local void putShortMSB (deflate_state *s, uInt b)
-{
-   put_byte(s, (Byte)(b >> 8));
-   put_byte(s, (Byte)(b & 0xff));
-}
-
-/* =========================================================================
- * Flush as much pending output as possible. All deflate() output goes
- * through this function so some applications may wish to modify it
- * to avoid allocating a large strm->next_out buffer and copying into it.
- * (See also read_buf()).
- */
-local void flush_pending(z_streamp strm)
-{
-   unsigned len;
-   deflate_state *s = (deflate_state*)strm->state;
-
-   _tr_flush_bits(s);
-   len = s->pending;
-   if (len > strm->avail_out) len = strm->avail_out;
-   if (len == 0) return;
-
-   zmemcpy(strm->next_out, s->pending_out, len);
-   strm->next_out  += len;
-   s->pending_out  += len;
-   strm->total_out += len;
-   strm->avail_out  -= len;
-   s->pending -= len;
-   if (s->pending == 0) {
-      s->pending_out = s->pending_buf;
-   }
-}
-
-/* ========================================================================= */
-int ZEXPORT deflate (z_streamp strm, int flush)
-{
-   int old_flush; /* value of flush param for previous deflate call */
-   deflate_state *s;
-
-   if (strm == Z_NULL || strm->state == Z_NULL ||
-         flush > Z_BLOCK || flush < 0) {
-      return Z_STREAM_ERROR;
-   }
-   s = (deflate_state*)strm->state;
-
-   if (strm->next_out == Z_NULL ||
-         (strm->next_in == Z_NULL && strm->avail_in != 0) ||
-         (s->status == FINISH_STATE && flush != Z_FINISH)) {
-      ERR_RETURN(strm, Z_STREAM_ERROR);
-   }
-   if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
-
-   s->strm = strm; /* just in case */
-   old_flush = s->last_flush;
-   s->last_flush = flush;
-
-   /* Write the header */
-   if (s->status == INIT_STATE) {
-#ifdef GZIP
-      if (s->wrap == 2) {
-         strm->adler = crc32(0L, Z_NULL, 0);
-         put_byte(s, 31);
-         put_byte(s, 139);
-         put_byte(s, 8);
-         if (s->gzhead == Z_NULL) {
-            put_byte(s, 0);
-            put_byte(s, 0);
-            put_byte(s, 0);
-            put_byte(s, 0);
-            put_byte(s, 0);
-            put_byte(s, s->level == 9 ? 2 :
-                  (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
-                   4 : 0));
-            put_byte(s, OS_CODE);
-            s->status = BUSY_STATE;
-         }
-         else {
-            put_byte(s, (s->gzhead->text ? 1 : 0) +
-                  (s->gzhead->hcrc ? 2 : 0) +
-                  (s->gzhead->extra == Z_NULL ? 0 : 4) +
-                  (s->gzhead->name == Z_NULL ? 0 : 8) +
-                  (s->gzhead->comment == Z_NULL ? 0 : 16)
-                  );
-            put_byte(s, (Byte)(s->gzhead->time & 0xff));
-            put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
-            put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
-            put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
-            put_byte(s, s->level == 9 ? 2 :
-                  (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
-                   4 : 0));
-            put_byte(s, s->gzhead->os & 0xff);
-            if (s->gzhead->extra != Z_NULL) {
-               put_byte(s, s->gzhead->extra_len & 0xff);
-               put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
-            }
-            if (s->gzhead->hcrc)
-               strm->adler = crc32(strm->adler, s->pending_buf,
-                     s->pending);
-            s->gzindex = 0;
-            s->status = EXTRA_STATE;
-         }
-      }
-      else
-#endif
-      {
-         uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
-         uInt level_flags;
-
-         if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
-            level_flags = 0;
-         else if (s->level < 6)
-            level_flags = 1;
-         else if (s->level == 6)
-            level_flags = 2;
-         else
-            level_flags = 3;
-         header |= (level_flags << 6);
-         if (s->strstart != 0) header |= PRESET_DICT;
-         header += 31 - (header % 31);
-
-         s->status = BUSY_STATE;
-         putShortMSB(s, header);
-
-         /* Save the adler32 of the preset dictionary: */
-         if (s->strstart != 0) {
-            putShortMSB(s, (uInt)(strm->adler >> 16));
-            putShortMSB(s, (uInt)(strm->adler & 0xffff));
-         }
-         strm->adler = adler32(0L, Z_NULL, 0);
-      }
-   }
-#ifdef GZIP
-   if (s->status == EXTRA_STATE) {
-      if (s->gzhead->extra != Z_NULL) {
-         uInt beg = s->pending;  /* start of bytes to update crc */
-
-         while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {
-            if (s->pending == s->pending_buf_size) {
-               if (s->gzhead->hcrc && s->pending > beg)
-                  strm->adler = crc32(strm->adler, s->pending_buf + beg,
-                        s->pending - beg);
-               flush_pending(strm);
-               beg = s->pending;
-               if (s->pending == s->pending_buf_size)
-                  break;
-            }
-            put_byte(s, s->gzhead->extra[s->gzindex]);
-            s->gzindex++;
-         }
-         if (s->gzhead->hcrc && s->pending > beg)
-            strm->adler = crc32(strm->adler, s->pending_buf + beg,
-                  s->pending - beg);
-         if (s->gzindex == s->gzhead->extra_len) {
-            s->gzindex = 0;
-            s->status = NAME_STATE;
-         }
-      }
-      else
-         s->status = NAME_STATE;
-   }
-   if (s->status == NAME_STATE) {
-      if (s->gzhead->name != Z_NULL) {
-         uInt beg = s->pending;  /* start of bytes to update crc */
-         int val;
-
-         do {
-            if (s->pending == s->pending_buf_size) {
-               if (s->gzhead->hcrc && s->pending > beg)
-                  strm->adler = crc32(strm->adler, s->pending_buf + beg,
-                        s->pending - beg);
-               flush_pending(strm);
-               beg = s->pending;
-               if (s->pending == s->pending_buf_size) {
-                  val = 1;
-                  break;
-               }
-            }
-            val = s->gzhead->name[s->gzindex++];
-            put_byte(s, val);
-         } while (val != 0);
-         if (s->gzhead->hcrc && s->pending > beg)
-            strm->adler = crc32(strm->adler, s->pending_buf + beg,
-                  s->pending - beg);
-         if (val == 0) {
-            s->gzindex = 0;
-            s->status = COMMENT_STATE;
-         }
-      }
-      else
-         s->status = COMMENT_STATE;
-   }
-   if (s->status == COMMENT_STATE) {
-      if (s->gzhead->comment != Z_NULL) {
-         uInt beg = s->pending;  /* start of bytes to update crc */
-         int val;
-
-         do {
-            if (s->pending == s->pending_buf_size) {
-               if (s->gzhead->hcrc && s->pending > beg)
-                  strm->adler = crc32(strm->adler, s->pending_buf + beg,
-                        s->pending - beg);
-               flush_pending(strm);
-               beg = s->pending;
-               if (s->pending == s->pending_buf_size) {
-                  val = 1;
-                  break;
-               }
-            }
-            val = s->gzhead->comment[s->gzindex++];
-            put_byte(s, val);
-         } while (val != 0);
-         if (s->gzhead->hcrc && s->pending > beg)
-            strm->adler = crc32(strm->adler, s->pending_buf + beg,
-                  s->pending - beg);
-         if (val == 0)
-            s->status = HCRC_STATE;
-      }
-      else
-         s->status = HCRC_STATE;
-   }
-   if (s->status == HCRC_STATE) {
-      if (s->gzhead->hcrc) {
-         if (s->pending + 2 > s->pending_buf_size)
-            flush_pending(strm);
-         if (s->pending + 2 <= s->pending_buf_size) {
-            put_byte(s, (Byte)(strm->adler & 0xff));
-            put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
-            strm->adler = crc32(0L, Z_NULL, 0);
-            s->status = BUSY_STATE;
-         }
-      }
-      else
-         s->status = BUSY_STATE;
-   }
-#endif
-
-   /* Flush as much pending output as possible */
-   if (s->pending != 0) {
-      flush_pending(strm);
-      if (strm->avail_out == 0) {
-         /* Since avail_out is 0, deflate will be called again with
-          * more output space, but possibly with both pending and
-          * avail_in equal to zero. There won't be anything to do,
-          * but this is not an error situation so make sure we
-          * return OK instead of BUF_ERROR at next call of deflate:
-          */
-         s->last_flush = -1;
-         return Z_OK;
-      }
-
-      /* Make sure there is something to do and avoid duplicate consecutive
-       * flushes. For repeated and useless calls with Z_FINISH, we keep
-       * returning Z_STREAM_END instead of Z_BUF_ERROR.
-       */
-   } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
-         flush != Z_FINISH) {
-      ERR_RETURN(strm, Z_BUF_ERROR);
-   }
-
-   /* User must not provide more input after the first FINISH: */
-   if (s->status == FINISH_STATE && strm->avail_in != 0) {
-      ERR_RETURN(strm, Z_BUF_ERROR);
-   }
-
-   /* Start a new block or continue the current one.
-   */
-   if (strm->avail_in != 0 || s->lookahead != 0 ||
-         (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
-      block_state bstate;
-
-      bstate = s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) :
-         (s->strategy == Z_RLE ? deflate_rle(s, flush) :
-          (*(configuration_table[s->level].func))(s, flush));
-
-      if (bstate == finish_started || bstate == finish_done) {
-         s->status = FINISH_STATE;
-      }
-      if (bstate == need_more || bstate == finish_started) {
-         if (strm->avail_out == 0) {
-            s->last_flush = -1; /* avoid BUF_ERROR next call, see above */
-         }
-         return Z_OK;
-         /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
-          * of deflate should use the same flush parameter to make sure
-          * that the flush is complete. So we don't have to output an
-          * empty block here, this will be done at next call. This also
-          * ensures that for a very small output buffer, we emit at most
-          * one empty block.
-          */
-      }
-      if (bstate == block_done) {
-         if (flush == Z_PARTIAL_FLUSH) {
-            _tr_align(s);
-         } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */
-            _tr_stored_block(s, (char*)0, 0L, 0);
-            /* For a full flush, this empty block will be recognized
-             * as a special marker by inflate_sync().
-             */
-            if (flush == Z_FULL_FLUSH) {
-               CLEAR_HASH(s);             /* forget history */
-               if (s->lookahead == 0) {
-                  s->strstart = 0;
-                  s->block_start = 0L;
-                  s->insert = 0;
-               }
-            }
-         }
-         flush_pending(strm);
-         if (strm->avail_out == 0) {
-            s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
-            return Z_OK;
-         }
-      }
-   }
-   Assert(strm->avail_out > 0, "bug2");
-
-   if (flush != Z_FINISH) return Z_OK;
-   if (s->wrap <= 0) return Z_STREAM_END;
-
-   /* Write the trailer */
-#ifdef GZIP
-   if (s->wrap == 2) {
-      put_byte(s, (Byte)(strm->adler & 0xff));
-      put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
-      put_byte(s, (Byte)((strm->adler >> 16) & 0xff));
-      put_byte(s, (Byte)((strm->adler >> 24) & 0xff));
-      put_byte(s, (Byte)(strm->total_in & 0xff));
-      put_byte(s, (Byte)((strm->total_in >> 8) & 0xff));
-      put_byte(s, (Byte)((strm->total_in >> 16) & 0xff));
-      put_byte(s, (Byte)((strm->total_in >> 24) & 0xff));
-   }
-   else
-#endif
-   {
-      putShortMSB(s, (uInt)(strm->adler >> 16));
-      putShortMSB(s, (uInt)(strm->adler & 0xffff));
-   }
-   flush_pending(strm);
-   /* If avail_out is zero, the application will call deflate again
-    * to flush the rest.
-    */
-   if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
-   return s->pending != 0 ? Z_OK : Z_STREAM_END;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateEnd (z_streamp strm)
-{
-   struct internal_state_deflate *state;
-   int status;
-
-   if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
-   state = (struct internal_state_deflate*)strm->state;
-
-   status = state->status;
-   if (status != INIT_STATE &&
-         status != EXTRA_STATE &&
-         status != NAME_STATE &&
-         status != COMMENT_STATE &&
-         status != HCRC_STATE &&
-         status != BUSY_STATE &&
-         status != FINISH_STATE) {
-      return Z_STREAM_ERROR;
-   }
-
-   /* Deallocate in reverse order of allocations: */
-   TRY_FREE(strm, state->pending_buf);
-   TRY_FREE(strm, state->head);
-   TRY_FREE(strm, state->prev);
-   TRY_FREE(strm, state->window);
-
-   ZFREE(strm, state);
-   state = Z_NULL;
-
-   return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
-}
-
-/* =========================================================================
- * Copy the source state to the destination state.
- * To simplify the source, this is not supported for 16-bit MSDOS (which
- * doesn't have enough memory anyway to duplicate compression states).
- */
-int ZEXPORT deflateCopy (z_streamp dest, z_streamp source)
-{
-#ifdef MAXSEG_64K
-   return Z_STREAM_ERROR;
-#else
-   deflate_state *ds;
-   deflate_state *ss;
-   ushf *overlay;
-
-
-   if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
-      return Z_STREAM_ERROR;
-   }
-
-   ss = (deflate_state*)source->state;
-
-   zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
-
-   ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
-   if (ds == Z_NULL) return Z_MEM_ERROR;
-   dest->state = (struct internal_state FAR *) ds;
-   zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state));
-   ds->strm = dest;
-
-   ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
-   ds->prev   = (Posf *)  ZALLOC(dest, ds->w_size, sizeof(Pos));
-   ds->head   = (Posf *)  ZALLOC(dest, ds->hash_size, sizeof(Pos));
-   overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2);
-   ds->pending_buf = (uchf *) overlay;
-
-   if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
-         ds->pending_buf == Z_NULL) {
-      deflateEnd (dest);
-      return Z_MEM_ERROR;
-   }
-   /* following zmemcpy do not work for 16-bit MSDOS */
-   zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
-   zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));
-   zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));
-   zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
-
-   ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
-   ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush);
-   ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize;
-
-   ds->l_desc.dyn_tree = ds->dyn_ltree;
-   ds->d_desc.dyn_tree = ds->dyn_dtree;
-   ds->bl_desc.dyn_tree = ds->bl_tree;
-
-   return Z_OK;
-#endif /* MAXSEG_64K */
-}
-
-/* ===========================================================================
- * Read a new buffer from the current input stream, update the adler32
- * and total number of bytes read.  All deflate() input goes through
- * this function so some applications may wish to modify it to avoid
- * allocating a large strm->next_in buffer and copying from it.
- * (See also flush_pending()).
- */
-local int read_buf(z_streamp strm, Bytef *buf, unsigned size)
-{
-   struct internal_state_deflate *state = (struct internal_state_deflate*)strm->state;
-   unsigned len = strm->avail_in;
-
-   if (len > size) len = size;
-   if (len == 0) return 0;
-
-   strm->avail_in  -= len;
-
-   zmemcpy(buf, strm->next_in, len);
-   if (state->wrap == 1) {
-      strm->adler = adler32(strm->adler, buf, len);
-   }
-#ifdef GZIP
-   else if (state->wrap == 2) {
-      strm->adler = crc32(strm->adler, buf, len);
-   }
-#endif
-   strm->next_in  += len;
-   strm->total_in += len;
-
-   return (int)len;
-}
-
-/* ===========================================================================
- * Initialize the "longest match" routines for a new zlib stream
- */
-local void lm_init (deflate_state *s)
-{
-   s->window_size = (ulg)2L*s->w_size;
-
-   CLEAR_HASH(s);
-
-   /* Set the default configuration parameters:
-   */
-   s->max_lazy_match   = configuration_table[s->level].max_lazy;
-   s->good_match       = configuration_table[s->level].good_length;
-   s->nice_match       = configuration_table[s->level].nice_length;
-   s->max_chain_length = configuration_table[s->level].max_chain;
-
-   s->strstart = 0;
-   s->block_start = 0L;
-   s->lookahead = 0;
-   s->insert = 0;
-   s->match_length = s->prev_length = MIN_MATCH-1;
-   s->match_available = 0;
-   s->ins_h = 0;
-#ifndef FASTEST
-#ifdef ASMV
-   match_init(); /* initialize the asm code */
-#endif
-#endif
-}
-
-#ifndef FASTEST
-/* ===========================================================================
- * Set match_start to the longest match starting at the given string and
- * return its length. Matches shorter or equal to prev_length are discarded,
- * in which case the result is equal to prev_length and match_start is
- * garbage.
- * IN assertions: cur_match is the head of the hash chain for the current
- *   string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
- * OUT assertion: the match length is not greater than s->lookahead.
- */
-#ifndef ASMV
-/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
- * match.S. The code will be functionally equivalent.
- */
-local uInt longest_match(deflate_state *s, IPos cur_match)
-{
-   unsigned chain_length = s->max_chain_length;/* max hash chain length */
-   register Bytef *scan = s->window + s->strstart; /* current string */
-   register Bytef *match;                       /* matched string */
-   register int len;                           /* length of current match */
-   int best_len = s->prev_length;              /* best match length so far */
-   int nice_match = s->nice_match;             /* stop if match long enough */
-   IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
-      s->strstart - (IPos)MAX_DIST(s) : NIL;
-   /* Stop when cur_match becomes <= limit. To simplify the code,
-    * we prevent matches with the string of window index 0.
-    */
-   Posf *prev = s->prev;
-   uInt wmask = s->w_mask;
-
-#ifdef UNALIGNED_OK
-   /* Compare two bytes at a time. Note: this is not always beneficial.
-    * Try with and without -DUNALIGNED_OK to check.
-    */
-   register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
-   register ush scan_start = *(ushf*)scan;
-   register ush scan_end   = *(ushf*)(scan+best_len-1);
-#else
-   register Bytef *strend = s->window + s->strstart + MAX_MATCH;
-   register Byte scan_end1  = scan[best_len-1];
-   register Byte scan_end   = scan[best_len];
-#endif
-
-   /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
-    * It is easy to get rid of this optimization if necessary.
-    */
-   Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
-
-   /* Do not waste too much time if we already have a good match: */
-   if (s->prev_length >= s->good_match) {
-      chain_length >>= 2;
-   }
-   /* Do not look for matches beyond the end of the input. This is necessary
-    * to make deflate deterministic.
-    */
-   if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
-
-   Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
-
-   do {
-      Assert(cur_match < s->strstart, "no future");
-      match = s->window + cur_match;
-
-      /* Skip to next match if the match length cannot increase
-       * or if the match length is less than 2.  Note that the checks below
-       * for insufficient lookahead only occur occasionally for performance
-       * reasons.  Therefore uninitialized memory will be accessed, and
-       * conditional jumps will be made that depend on those values.
-       * However the length of the match is limited to the lookahead, so
-       * the output of deflate is not affected by the uninitialized values.
-       */
-#if (defined(UNALIGNED_OK) && MAX_MATCH == 258)
-      /* This code assumes sizeof(unsigned short) == 2. Do not use
-       * UNALIGNED_OK if your compiler uses a different size.
-       */
-      if (*(ushf*)(match+best_len-1) != scan_end ||
-            *(ushf*)match != scan_start) continue;
-
-      /* It is not necessary to compare scan[2] and match[2] since they are
-       * always equal when the other bytes match, given that the hash keys
-       * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
-       * strstart+3, +5, ... up to strstart+257. We check for insufficient
-       * lookahead only every 4th comparison; the 128th check will be made
-       * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is
-       * necessary to put more guard bytes at the end of the window, or
-       * to check more often for insufficient lookahead.
-       */
-      Assert(scan[2] == match[2], "scan[2]?");
-      scan++, match++;
-      do {
-      } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
-            *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
-            *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
-            *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
-            scan < strend);
-      /* The funny "do {}" generates better code on most compilers */
-
-      /* Here, scan <= window+strstart+257 */
-      Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
-      if (*scan == *match) scan++;
-
-      len = (MAX_MATCH - 1) - (int)(strend-scan);
-      scan = strend - (MAX_MATCH-1);
-
-#else /* UNALIGNED_OK */
-
-      if (match[best_len]   != scan_end  ||
-            match[best_len-1] != scan_end1 ||
-            *match            != *scan     ||
-            *++match          != scan[1])      continue;
-
-      /* The check at best_len-1 can be removed because it will be made
-       * again later. (This heuristic is not always a win.)
-       * It is not necessary to compare scan[2] and match[2] since they
-       * are always equal when the other bytes match, given that
-       * the hash keys are equal and that HASH_BITS >= 8.
-       */
-      scan += 2, match++;
-      Assert(*scan == *match, "match[2]?");
-
-      /* We check for insufficient lookahead only every 8th comparison;
-       * the 256th check will be made at strstart+258.
-       */
-      do {
-      } while (*++scan == *++match && *++scan == *++match &&
-            *++scan == *++match && *++scan == *++match &&
-            *++scan == *++match && *++scan == *++match &&
-            *++scan == *++match && *++scan == *++match &&
-            scan < strend);
-
-      Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
-
-      len = MAX_MATCH - (int)(strend - scan);
-      scan = strend - MAX_MATCH;
-
-#endif /* UNALIGNED_OK */
-
-      if (len > best_len) {
-         s->match_start = cur_match;
-         best_len = len;
-         if (len >= nice_match) break;
-#ifdef UNALIGNED_OK
-         scan_end = *(ushf*)(scan+best_len-1);
-#else
-         scan_end1  = scan[best_len-1];
-         scan_end   = scan[best_len];
-#endif
-      }
-   } while ((cur_match = prev[cur_match & wmask]) > limit
-         && --chain_length != 0);
-
-   if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
-   return s->lookahead;
-}
-#endif /* ASMV */
-
-#else /* FASTEST */
-
-/* ---------------------------------------------------------------------------
- * Optimized version for FASTEST only
- */
-local uInt longest_match(s, cur_match)
-   deflate_state *s;
-   IPos cur_match;                             /* current match */
-{
-   register Bytef *scan = s->window + s->strstart; /* current string */
-   register Bytef *match;                       /* matched string */
-   register int len;                           /* length of current match */
-   register Bytef *strend = s->window + s->strstart + MAX_MATCH;
-
-   /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
-    * It is easy to get rid of this optimization if necessary.
-    */
-   Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
-
-   Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
-
-   Assert(cur_match < s->strstart, "no future");
-
-   match = s->window + cur_match;
-
-   /* Return failure if the match length is less than 2:
-   */
-   if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1;
-
-   /* The check at best_len-1 can be removed because it will be made
-    * again later. (This heuristic is not always a win.)
-    * It is not necessary to compare scan[2] and match[2] since they
-    * are always equal when the other bytes match, given that
-    * the hash keys are equal and that HASH_BITS >= 8.
-    */
-   scan += 2, match += 2;
-   Assert(*scan == *match, "match[2]?");
-
-   /* We check for insufficient lookahead only every 8th comparison;
-    * the 256th check will be made at strstart+258.
-    */
-   do {
-   } while (*++scan == *++match && *++scan == *++match &&
-         *++scan == *++match && *++scan == *++match &&
-         *++scan == *++match && *++scan == *++match &&
-         *++scan == *++match && *++scan == *++match &&
-         scan < strend);
-
-   Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
-
-   len = MAX_MATCH - (int)(strend - scan);
-
-   if (len < MIN_MATCH) return MIN_MATCH - 1;
-
-   s->match_start = cur_match;
-   return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
-}
-
-#endif /* FASTEST */
-
-#ifdef DEBUG
-/* ===========================================================================
- * Check that the match at match_start is indeed a match.
- */
-local void check_match(s, start, match, length)
-   deflate_state *s;
-   IPos start, match;
-   int length;
-{
-   /* check that the match is indeed a match */
-   if (zmemcmp(s->window + match,
-            s->window + start, length) != EQUAL) {
-      fprintf(stderr, " start %u, match %u, length %d\n",
-            start, match, length);
-      do {
-         fprintf(stderr, "%c%c", s->window[match++], s->window[start++]);
-      } while (--length != 0);
-      z_error("invalid match");
-   }
-   if (z_verbose > 1) {
-      fprintf(stderr,"\\[%d,%d]", start-match, length);
-      do { putc(s->window[start++], stderr); } while (--length != 0);
-   }
-}
-#else
-#  define check_match(s, start, match, length)
-#endif /* DEBUG */
-
-/* ===========================================================================
- * Fill the window when the lookahead becomes insufficient.
- * Updates strstart and lookahead.
- *
- * IN assertion: lookahead < MIN_LOOKAHEAD
- * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
- *    At least one byte has been read, or avail_in == 0; reads are
- *    performed for at least two bytes (required for the zip translate_eol
- *    option -- not supported here).
- */
-local void fill_window(deflate_state *s)
-{
-   register unsigned n, m;
-   register Posf *p;
-   unsigned more;    /* Amount of free space at the end of the window. */
-   uInt wsize = s->w_size;
-
-   Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
-
-   do {
-      more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
-
-      /* Deal with !@#$% 64K limit: */
-      if (sizeof(int) <= 2) {
-         if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
-            more = wsize;
-
-         } else if (more == (unsigned)(-1)) {
-            /* Very unlikely, but possible on 16 bit machine if
-             * strstart == 0 && lookahead == 1 (input done a byte at time)
-             */
-            more--;
-         }
-      }
-
-      /* If the window is almost full and there is insufficient lookahead,
-       * move the upper half to the lower one to make room in the upper half.
-       */
-      if (s->strstart >= wsize+MAX_DIST(s)) {
-
-         zmemcpy(s->window, s->window+wsize, (unsigned)wsize);
-         s->match_start -= wsize;
-         s->strstart    -= wsize; /* we now have strstart >= MAX_DIST */
-         s->block_start -= (long) wsize;
-
-         /* Slide the hash table (could be avoided with 32 bit values
-            at the expense of memory usage). We slide even when level == 0
-            to keep the hash table consistent if we switch back to level > 0
-            later. (Using level 0 permanently is not an optimal usage of
-            zlib, so we don't care about this pathological case.)
-            */
-         n = s->hash_size;
-         p = &s->head[n];
-         do {
-            m = *--p;
-            *p = (Pos)(m >= wsize ? m-wsize : NIL);
-         } while (--n);
-
-         n = wsize;
-#ifndef FASTEST
-         p = &s->prev[n];
-         do {
-            m = *--p;
-            *p = (Pos)(m >= wsize ? m-wsize : NIL);
-            /* If n is not on any hash chain, prev[n] is garbage but
-             * its value will never be used.
-             */
-         } while (--n);
-#endif
-         more += wsize;
-      }
-      if (s->strm->avail_in == 0) break;
-
-      /* If there was no sliding:
-       *    strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
-       *    more == window_size - lookahead - strstart
-       * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
-       * => more >= window_size - 2*WSIZE + 2
-       * In the BIG_MEM or MMAP case (not yet supported),
-       *   window_size == input_size + MIN_LOOKAHEAD  &&
-       *   strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
-       * Otherwise, window_size == 2*WSIZE so more >= 2.
-       * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
-       */
-      Assert(more >= 2, "more < 2");
-
-      n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
-      s->lookahead += n;
-
-      /* Initialize the hash value now that we have some input: */
-      if (s->lookahead + s->insert >= MIN_MATCH) {
-         uInt str = s->strstart - s->insert;
-         s->ins_h = s->window[str];
-         UPDATE_HASH(s, s->ins_h, s->window[str + 1]);
-#if MIN_MATCH != 3
-         Call UPDATE_HASH() MIN_MATCH-3 more times
-#endif
-            while (s->insert) {
-               UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
-#ifndef FASTEST
-               s->prev[str & s->w_mask] = s->head[s->ins_h];
-#endif
-               s->head[s->ins_h] = (Pos)str;
-               str++;
-               s->insert--;
-               if (s->lookahead + s->insert < MIN_MATCH)
-                  break;
-            }
-      }
-      /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
-       * but this is not important since only literal bytes will be emitted.
-       */
-
-   } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
-
-   /* If the WIN_INIT bytes after the end of the current data have never been
-    * written, then zero those bytes in order to avoid memory check reports of
-    * the use of uninitialized (or uninitialised as Julian writes) bytes by
-    * the longest match routines.  Update the high water mark for the next
-    * time through here.  WIN_INIT is set to MAX_MATCH since the longest match
-    * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
-    */
-   if (s->high_water < s->window_size) {
-      ulg curr = s->strstart + (ulg)(s->lookahead);
-      ulg init;
-
-      if (s->high_water < curr) {
-         /* Previous high water mark below current data -- zero WIN_INIT
-          * bytes or up to end of window, whichever is less.
-          */
-         init = s->window_size - curr;
-         if (init > WIN_INIT)
-            init = WIN_INIT;
-         zmemzero(s->window + curr, (unsigned)init);
-         s->high_water = curr + init;
-      }
-      else if (s->high_water < (ulg)curr + WIN_INIT) {
-         /* High water mark at or above current data, but below current data
-          * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
-          * to end of window, whichever is less.
-          */
-         init = (ulg)curr + WIN_INIT - s->high_water;
-         if (init > s->window_size - s->high_water)
-            init = s->window_size - s->high_water;
-         zmemzero(s->window + s->high_water, (unsigned)init);
-         s->high_water += init;
-      }
-   }
-
-   Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
-         "not enough room for search");
-}
-
-/* ===========================================================================
- * Flush the current block, with given end-of-file flag.
- * IN assertion: strstart is set to the end of the current match.
- */
-#define FLUSH_BLOCK_ONLY(s, last) { \
-   _tr_flush_block(s, (s->block_start >= 0L ? \
-            (charf *)&s->window[(unsigned)s->block_start] : \
-            (charf *)Z_NULL), \
-         (ulg)((long)s->strstart - s->block_start), \
-         (last)); \
-   s->block_start = s->strstart; \
-   flush_pending(s->strm); \
-   Tracev((stderr,"[FLUSH]")); \
-}
-
-/* Same but force premature exit if necessary. */
-#define FLUSH_BLOCK(s, last) { \
-   FLUSH_BLOCK_ONLY(s, last); \
-   if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
-}
-
-/* ===========================================================================
- * Copy without compression as much as possible from the input stream, return
- * the current block state.
- * This function does not insert new strings in the dictionary since
- * uncompressible data is probably not useful. This function is used
- * only for the level=0 compression option.
- * NOTE: this function should be optimized to avoid extra copying from
- * window to pending_buf.
- */
-local block_state deflate_stored(deflate_state *s, int flush)
-{
-   /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
-    * to pending_buf_size, and each stored block has a 5 byte header:
-    */
-   ulg max_block_size = 0xffff;
-   ulg max_start;
-
-   if (max_block_size > s->pending_buf_size - 5) {
-      max_block_size = s->pending_buf_size - 5;
-   }
-
-   /* Copy as much as possible from input to output: */
-   for (;;) {
-      /* Fill the window as much as possible: */
-      if (s->lookahead <= 1) {
-
-         Assert(s->strstart < s->w_size+MAX_DIST(s) ||
-               s->block_start >= (long)s->w_size, "slide too late");
-
-         fill_window(s);
-         if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;
-
-         if (s->lookahead == 0) break; /* flush the current block */
-      }
-      Assert(s->block_start >= 0L, "block gone");
-
-      s->strstart += s->lookahead;
-      s->lookahead = 0;
-
-      /* Emit a stored block if pending_buf will be full: */
-      max_start = s->block_start + max_block_size;
-      if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
-         /* strstart == 0 is possible when wraparound on 16-bit machine */
-         s->lookahead = (uInt)(s->strstart - max_start);
-         s->strstart = (uInt)max_start;
-         FLUSH_BLOCK(s, 0);
-      }
-      /* Flush if we may have to slide, otherwise block_start may become
-       * negative and the data will be gone:
-       */
-      if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {
-         FLUSH_BLOCK(s, 0);
-      }
-   }
-   s->insert = 0;
-   if (flush == Z_FINISH) {
-      FLUSH_BLOCK(s, 1);
-      return finish_done;
-   }
-   if ((long)s->strstart > s->block_start)
-      FLUSH_BLOCK(s, 0);
-   return block_done;
-}
-
-/* ===========================================================================
- * Compress as much as possible from the input stream, return the current
- * block state.
- * This function does not perform lazy evaluation of matches and inserts
- * new strings in the dictionary only for unmatched strings or for short
- * matches. It is used only for the fast compression options.
- */
-local block_state deflate_fast(deflate_state *s, int flush)
-{
-   IPos hash_head;       /* head of the hash chain */
-   int bflush;           /* set if current block must be flushed */
-
-   for (;;) {
-      /* Make sure that we always have enough lookahead, except
-       * at the end of the input file. We need MAX_MATCH bytes
-       * for the next match, plus MIN_MATCH bytes to insert the
-       * string following the next match.
-       */
-      if (s->lookahead < MIN_LOOKAHEAD) {
-         fill_window(s);
-         if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
-            return need_more;
-         }
-         if (s->lookahead == 0) break; /* flush the current block */
-      }
-
-      /* Insert the string window[strstart .. strstart+2] in the
-       * dictionary, and set hash_head to the head of the hash chain:
-       */
-      hash_head = NIL;
-      if (s->lookahead >= MIN_MATCH) {
-         INSERT_STRING(s, s->strstart, hash_head);
-      }
-
-      /* Find the longest match, discarding those <= prev_length.
-       * At this point we have always match_length < MIN_MATCH
-       */
-      if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
-         /* To simplify the code, we prevent matches with the string
-          * of window index 0 (in particular we have to avoid a match
-          * of the string with itself at the start of the input file).
-          */
-         s->match_length = longest_match (s, hash_head);
-         /* longest_match() sets match_start */
-      }
-      if (s->match_length >= MIN_MATCH) {
-         check_match(s, s->strstart, s->match_start, s->match_length);
-
-         _tr_tally_dist(s, s->strstart - s->match_start,
-               s->match_length - MIN_MATCH, bflush);
-
-         s->lookahead -= s->match_length;
-
-         /* Insert new strings in the hash table only if the match length
-          * is not too large. This saves time but degrades compression.
-          */
-#ifndef FASTEST
-         if (s->match_length <= s->max_insert_length &&
-               s->lookahead >= MIN_MATCH) {
-            s->match_length--; /* string at strstart already in table */
-            do {
-               s->strstart++;
-               INSERT_STRING(s, s->strstart, hash_head);
-               /* strstart never exceeds WSIZE-MAX_MATCH, so there are
-                * always MIN_MATCH bytes ahead.
-                */
-            } while (--s->match_length != 0);
-            s->strstart++;
-         } else
-#endif
-         {
-            s->strstart += s->match_length;
-            s->match_length = 0;
-            s->ins_h = s->window[s->strstart];
-            UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
-#if MIN_MATCH != 3
-            Call UPDATE_HASH() MIN_MATCH-3 more times
-#endif
-               /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
-                * matter since it will be recomputed at next deflate call.
-                */
-         }
-      } else {
-         /* No match, output a literal byte */
-         Tracevv((stderr,"%c", s->window[s->strstart]));
-         _tr_tally_lit (s, s->window[s->strstart], bflush);
-         s->lookahead--;
-         s->strstart++;
-      }
-      if (bflush) FLUSH_BLOCK(s, 0);
-   }
-   s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
-   if (flush == Z_FINISH) {
-      FLUSH_BLOCK(s, 1);
-      return finish_done;
-   }
-   if (s->last_lit)
-      FLUSH_BLOCK(s, 0);
-   return block_done;
-}
-
-#ifndef FASTEST
-/* ===========================================================================
- * Same as above, but achieves better compression. We use a lazy
- * evaluation for matches: a match is finally adopted only if there is
- * no better match at the next window position.
- */
-local block_state deflate_slow(deflate_state *s, int flush)
-{
-   IPos hash_head;          /* head of hash chain */
-   int bflush;              /* set if current block must be flushed */
-
-   /* Process the input block. */
-   for (;;) {
-      /* Make sure that we always have enough lookahead, except
-       * at the end of the input file. We need MAX_MATCH bytes
-       * for the next match, plus MIN_MATCH bytes to insert the
-       * string following the next match.
-       */
-      if (s->lookahead < MIN_LOOKAHEAD) {
-         fill_window(s);
-         if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
-            return need_more;
-         }
-         if (s->lookahead == 0) break; /* flush the current block */
-      }
-
-      /* Insert the string window[strstart .. strstart+2] in the
-       * dictionary, and set hash_head to the head of the hash chain:
-       */
-      hash_head = NIL;
-      if (s->lookahead >= MIN_MATCH) {
-         INSERT_STRING(s, s->strstart, hash_head);
-      }
-
-      /* Find the longest match, discarding those <= prev_length.
-      */
-      s->prev_length = s->match_length, s->prev_match = s->match_start;
-      s->match_length = MIN_MATCH-1;
-
-      if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
-            s->strstart - hash_head <= MAX_DIST(s)) {
-         /* To simplify the code, we prevent matches with the string
-          * of window index 0 (in particular we have to avoid a match
-          * of the string with itself at the start of the input file).
-          */
-         s->match_length = longest_match (s, hash_head);
-         /* longest_match() sets match_start */
-
-         if (s->match_length <= 5 && (s->strategy == Z_FILTERED
-#if TOO_FAR <= 32767
-                  || (s->match_length == MIN_MATCH &&
-                     s->strstart - s->match_start > TOO_FAR)
-#endif
-                  )) {
-
-            /* If prev_match is also MIN_MATCH, match_start is garbage
-             * but we will ignore the current match anyway.
-             */
-            s->match_length = MIN_MATCH-1;
-         }
-      }
-      /* If there was a match at the previous step and the current
-       * match is not better, output the previous match:
-       */
-      if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
-         uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
-         /* Do not insert strings in hash table beyond this. */
-
-         check_match(s, s->strstart-1, s->prev_match, s->prev_length);
-
-         _tr_tally_dist(s, s->strstart -1 - s->prev_match,
-               s->prev_length - MIN_MATCH, bflush);
-
-         /* Insert in hash table all strings up to the end of the match.
-          * strstart-1 and strstart are already inserted. If there is not
-          * enough lookahead, the last two strings are not inserted in
-          * the hash table.
-          */
-         s->lookahead -= s->prev_length-1;
-         s->prev_length -= 2;
-         do {
-            if (++s->strstart <= max_insert) {
-               INSERT_STRING(s, s->strstart, hash_head);
-            }
-         } while (--s->prev_length != 0);
-         s->match_available = 0;
-         s->match_length = MIN_MATCH-1;
-         s->strstart++;
-
-         if (bflush) FLUSH_BLOCK(s, 0);
-
-      } else if (s->match_available) {
-         /* If there was no match at the previous position, output a
-          * single literal. If there was a match but the current match
-          * is longer, truncate the previous match to a single literal.
-          */
-         Tracevv((stderr,"%c", s->window[s->strstart-1]));
-         _tr_tally_lit(s, s->window[s->strstart-1], bflush);
-         if (bflush) {
-            FLUSH_BLOCK_ONLY(s, 0);
-         }
-         s->strstart++;
-         s->lookahead--;
-         if (s->strm->avail_out == 0) return need_more;
-      } else {
-         /* There is no previous match to compare with, wait for
-          * the next step to decide.
-          */
-         s->match_available = 1;
-         s->strstart++;
-         s->lookahead--;
-      }
-   }
-   Assert (flush != Z_NO_FLUSH, "no flush?");
-   if (s->match_available) {
-      Tracevv((stderr,"%c", s->window[s->strstart-1]));
-      _tr_tally_lit(s, s->window[s->strstart-1], bflush);
-      s->match_available = 0;
-   }
-   s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
-   if (flush == Z_FINISH) {
-      FLUSH_BLOCK(s, 1);
-      return finish_done;
-   }
-   if (s->last_lit)
-      FLUSH_BLOCK(s, 0);
-   return block_done;
-}
-#endif /* FASTEST */
-
-/* ===========================================================================
- * For Z_RLE, simply look for runs of bytes, generate matches only of distance
- * one.  Do not maintain a hash table.  (It will be regenerated if this run of
- * deflate switches away from Z_RLE.)
- */
-local block_state deflate_rle(deflate_state *s, int flush)
-{
-   int bflush;             /* set if current block must be flushed */
-   uInt prev;              /* byte at distance one to match */
-   Bytef *scan, *strend;   /* scan goes up to strend for length of run */
-
-   for (;;) {
-      /* Make sure that we always have enough lookahead, except
-       * at the end of the input file. We need MAX_MATCH bytes
-       * for the longest run, plus one for the unrolled loop.
-       */
-      if (s->lookahead <= MAX_MATCH) {
-         fill_window(s);
-         if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) {
-            return need_more;
-         }
-         if (s->lookahead == 0) break; /* flush the current block */
-      }
-
-      /* See how many times the previous byte repeats */
-      s->match_length = 0;
-      if (s->lookahead >= MIN_MATCH && s->strstart > 0) {
-         scan = s->window + s->strstart - 1;
-         prev = *scan;
-         if (prev == *++scan && prev == *++scan && prev == *++scan) {
-            strend = s->window + s->strstart + MAX_MATCH;
-            do {
-            } while (prev == *++scan && prev == *++scan &&
-                  prev == *++scan && prev == *++scan &&
-                  prev == *++scan && prev == *++scan &&
-                  prev == *++scan && prev == *++scan &&
-                  scan < strend);
-            s->match_length = MAX_MATCH - (int)(strend - scan);
-            if (s->match_length > s->lookahead)
-               s->match_length = s->lookahead;
-         }
-         Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan");
-      }
-
-      /* Emit match if have run of MIN_MATCH or longer, else emit literal */
-      if (s->match_length >= MIN_MATCH) {
-         check_match(s, s->strstart, s->strstart - 1, s->match_length);
-
-         _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush);
-
-         s->lookahead -= s->match_length;
-         s->strstart += s->match_length;
-         s->match_length = 0;
-      } else {
-         /* No match, output a literal byte */
-         Tracevv((stderr,"%c", s->window[s->strstart]));
-         _tr_tally_lit (s, s->window[s->strstart], bflush);
-         s->lookahead--;
-         s->strstart++;
-      }
-      if (bflush) FLUSH_BLOCK(s, 0);
-   }
-   s->insert = 0;
-   if (flush == Z_FINISH) {
-      FLUSH_BLOCK(s, 1);
-      return finish_done;
-   }
-   if (s->last_lit)
-      FLUSH_BLOCK(s, 0);
-   return block_done;
-}
-
-/* ===========================================================================
- * For Z_HUFFMAN_ONLY, do not look for matches.  Do not maintain a hash table.
- * (It will be regenerated if this run of deflate switches away from Huffman.)
- */
-local block_state deflate_huff(deflate_state *s, int flush)
-{
-   int bflush;             /* set if current block must be flushed */
-
-   for (;;) {
-      /* Make sure that we have a literal to write. */
-      if (s->lookahead == 0) {
-         fill_window(s);
-         if (s->lookahead == 0) {
-            if (flush == Z_NO_FLUSH)
-               return need_more;
-            break;      /* flush the current block */
-         }
-      }
-
-      /* Output a literal byte */
-      s->match_length = 0;
-      Tracevv((stderr,"%c", s->window[s->strstart]));
-      _tr_tally_lit (s, s->window[s->strstart], bflush);
-      s->lookahead--;
-      s->strstart++;
-      if (bflush) FLUSH_BLOCK(s, 0);
-   }
-   s->insert = 0;
-   if (flush == Z_FINISH) {
-      FLUSH_BLOCK(s, 1);
-      return finish_done;
-   }
-   if (s->last_lit)
-      FLUSH_BLOCK(s, 0);
-   return block_done;
-}
diff --git a/deps/zlib/deflate.h b/deps/zlib/deflate.h
deleted file mode 100644 (file)
index 82fe93e..0000000
+++ /dev/null
@@ -1,346 +0,0 @@
-/* deflate.h -- internal compression state
- * Copyright (C) 1995-2012 Jean-loup Gailly
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
-   part of the implementation of the compression library and is
-   subject to change. Applications should only use zlib.h.
- */
-
-/* @(#) $Id$ */
-
-#ifndef DEFLATE_H
-#define DEFLATE_H
-
-#include "zutil.h"
-
-/* define NO_GZIP when compiling if you want to disable gzip header and
-   trailer creation by deflate().  NO_GZIP would be used to avoid linking in
-   the crc code when it is not needed.  For shared libraries, gzip encoding
-   should be left enabled. */
-#ifndef NO_GZIP
-#  define GZIP
-#endif
-
-/* ===========================================================================
- * Internal compression state.
- */
-
-#define LENGTH_CODES 29
-/* number of length codes, not counting the special END_BLOCK code */
-
-#define LITERALS  256
-/* number of literal bytes 0..255 */
-
-#define L_CODES (LITERALS+1+LENGTH_CODES)
-/* number of Literal or Length codes, including the END_BLOCK code */
-
-#define D_CODES   30
-/* number of distance codes */
-
-#define BL_CODES  19
-/* number of codes used to transfer the bit lengths */
-
-#define HEAP_SIZE (2*L_CODES+1)
-/* maximum heap size */
-
-#define MAX_BITS 15
-/* All codes must not exceed MAX_BITS bits */
-
-#define Buf_size 16
-/* size of bit buffer in bi_buf */
-
-#define INIT_STATE    42
-#define EXTRA_STATE   69
-#define NAME_STATE    73
-#define COMMENT_STATE 91
-#define HCRC_STATE   103
-#define BUSY_STATE   113
-#define FINISH_STATE 666
-/* Stream status */
-
-
-/* Data structure describing a single value and its code string. */
-typedef struct ct_data_s {
-    union {
-        ush  freq;       /* frequency count */
-        ush  code;       /* bit string */
-    } fc;
-    union {
-        ush  dad;        /* father node in Huffman tree */
-        ush  len;        /* length of bit string */
-    } dl;
-} FAR ct_data;
-
-#define Freq fc.freq
-#define Code fc.code
-#define Dad  dl.dad
-#define Len  dl.len
-
-typedef struct static_tree_desc_s  static_tree_desc;
-
-typedef struct tree_desc_s {
-    ct_data *dyn_tree;           /* the dynamic tree */
-    int     max_code;            /* largest code with non zero frequency */
-    static_tree_desc *stat_desc; /* the corresponding static tree */
-} FAR tree_desc;
-
-typedef ush Pos;
-typedef Pos FAR Posf;
-typedef unsigned IPos;
-
-/* A Pos is an index in the character window. We use short instead of int to
- * save space in the various tables. IPos is used only for parameter passing.
- */
-
-typedef struct internal_state_deflate {
-    z_streamp strm;      /* pointer back to this zlib stream */
-    int   status;        /* as the name implies */
-    Bytef *pending_buf;  /* output still pending */
-    ulg   pending_buf_size; /* size of pending_buf */
-    Bytef *pending_out;  /* next pending byte to output to the stream */
-    uInt   pending;      /* nb of bytes in the pending buffer */
-    int   wrap;          /* bit 0 true for zlib, bit 1 true for gzip */
-    gz_headerp  gzhead;  /* gzip header information to write */
-    uInt   gzindex;      /* where in extra, name, or comment */
-    Byte  method;        /* can only be DEFLATED */
-    int   last_flush;    /* value of flush param for previous deflate call */
-
-                /* used by deflate.c: */
-
-    uInt  w_size;        /* LZ77 window size (32K by default) */
-    uInt  w_bits;        /* log2(w_size)  (8..16) */
-    uInt  w_mask;        /* w_size - 1 */
-
-    Bytef *window;
-    /* Sliding window. Input bytes are read into the second half of the window,
-     * and move to the first half later to keep a dictionary of at least wSize
-     * bytes. With this organization, matches are limited to a distance of
-     * wSize-MAX_MATCH bytes, but this ensures that IO is always
-     * performed with a length multiple of the block size. Also, it limits
-     * the window size to 64K, which is quite useful on MSDOS.
-     * To do: use the user input buffer as sliding window.
-     */
-
-    ulg window_size;
-    /* Actual size of window: 2*wSize, except when the user input buffer
-     * is directly used as sliding window.
-     */
-
-    Posf *prev;
-    /* Link to older string with same hash index. To limit the size of this
-     * array to 64K, this link is maintained only for the last 32K strings.
-     * An index in this array is thus a window index modulo 32K.
-     */
-
-    Posf *head; /* Heads of the hash chains or NIL. */
-
-    uInt  ins_h;          /* hash index of string to be inserted */
-    uInt  hash_size;      /* number of elements in hash table */
-    uInt  hash_bits;      /* log2(hash_size) */
-    uInt  hash_mask;      /* hash_size-1 */
-
-    uInt  hash_shift;
-    /* Number of bits by which ins_h must be shifted at each input
-     * step. It must be such that after MIN_MATCH steps, the oldest
-     * byte no longer takes part in the hash key, that is:
-     *   hash_shift * MIN_MATCH >= hash_bits
-     */
-
-    long block_start;
-    /* Window position at the beginning of the current output block. Gets
-     * negative when the window is moved backwards.
-     */
-
-    uInt match_length;           /* length of best match */
-    IPos prev_match;             /* previous match */
-    int match_available;         /* set if previous match exists */
-    uInt strstart;               /* start of string to insert */
-    uInt match_start;            /* start of matching string */
-    uInt lookahead;              /* number of valid bytes ahead in window */
-
-    uInt prev_length;
-    /* Length of the best match at previous step. Matches not greater than this
-     * are discarded. This is used in the lazy match evaluation.
-     */
-
-    uInt max_chain_length;
-    /* To speed up deflation, hash chains are never searched beyond this
-     * length.  A higher limit improves compression ratio but degrades the
-     * speed.
-     */
-
-    uInt max_lazy_match;
-    /* Attempt to find a better match only when the current match is strictly
-     * smaller than this value. This mechanism is used only for compression
-     * levels >= 4.
-     */
-#   define max_insert_length  max_lazy_match
-    /* Insert new strings in the hash table only if the match length is not
-     * greater than this length. This saves time but degrades compression.
-     * max_insert_length is used only for compression levels <= 3.
-     */
-
-    int level;    /* compression level (1..9) */
-    int strategy; /* favor or force Huffman coding*/
-
-    uInt good_match;
-    /* Use a faster search when the previous match is longer than this */
-
-    int nice_match; /* Stop searching when current match exceeds this */
-
-                /* used by trees.c: */
-    /* Didn't use ct_data typedef below to suppress compiler warning */
-    struct ct_data_s dyn_ltree[HEAP_SIZE];   /* literal and length tree */
-    struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
-    struct ct_data_s bl_tree[2*BL_CODES+1];  /* Huffman tree for bit lengths */
-
-    struct tree_desc_s l_desc;               /* desc. for literal tree */
-    struct tree_desc_s d_desc;               /* desc. for distance tree */
-    struct tree_desc_s bl_desc;              /* desc. for bit length tree */
-
-    ush bl_count[MAX_BITS+1];
-    /* number of codes at each bit length for an optimal tree */
-
-    int heap[2*L_CODES+1];      /* heap used to build the Huffman trees */
-    int heap_len;               /* number of elements in the heap */
-    int heap_max;               /* element of largest frequency */
-    /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
-     * The same heap array is used to build all trees.
-     */
-
-    uch depth[2*L_CODES+1];
-    /* Depth of each subtree used as tie breaker for trees of equal frequency
-     */
-
-    uchf *l_buf;          /* buffer for literals or lengths */
-
-    uInt  lit_bufsize;
-    /* Size of match buffer for literals/lengths.  There are 4 reasons for
-     * limiting lit_bufsize to 64K:
-     *   - frequencies can be kept in 16 bit counters
-     *   - if compression is not successful for the first block, all input
-     *     data is still in the window so we can still emit a stored block even
-     *     when input comes from standard input.  (This can also be done for
-     *     all blocks if lit_bufsize is not greater than 32K.)
-     *   - if compression is not successful for a file smaller than 64K, we can
-     *     even emit a stored file instead of a stored block (saving 5 bytes).
-     *     This is applicable only for zip (not gzip or zlib).
-     *   - creating new Huffman trees less frequently may not provide fast
-     *     adaptation to changes in the input data statistics. (Take for
-     *     example a binary file with poorly compressible code followed by
-     *     a highly compressible string table.) Smaller buffer sizes give
-     *     fast adaptation but have of course the overhead of transmitting
-     *     trees more frequently.
-     *   - I can't count above 4
-     */
-
-    uInt last_lit;      /* running index in l_buf */
-
-    ushf *d_buf;
-    /* Buffer for distances. To simplify the code, d_buf and l_buf have
-     * the same number of elements. To use different lengths, an extra flag
-     * array would be necessary.
-     */
-
-    ulg opt_len;        /* bit length of current block with optimal trees */
-    ulg static_len;     /* bit length of current block with static trees */
-    uInt matches;       /* number of string matches in current block */
-    uInt insert;        /* bytes at end of window left to insert */
-
-#ifdef DEBUG
-    ulg compressed_len; /* total bit length of compressed file mod 2^32 */
-    ulg bits_sent;      /* bit length of compressed data sent mod 2^32 */
-#endif
-
-    ush bi_buf;
-    /* Output buffer. bits are inserted starting at the bottom (least
-     * significant bits).
-     */
-    int bi_valid;
-    /* Number of valid bits in bi_buf.  All bits above the last valid bit
-     * are always zero.
-     */
-
-    ulg high_water;
-    /* High water mark offset in window for initialized bytes -- bytes above
-     * this are set to zero in order to avoid memory check warnings when
-     * longest match routines access bytes past the input.  This is then
-     * updated to the new high water mark.
-     */
-
-} deflate_state;
-
-/* Output a byte on the stream.
- * IN assertion: there is enough room in pending_buf.
- */
-#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
-
-
-#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
-/* Minimum amount of lookahead, except at the end of the input file.
- * See deflate.c for comments about the MIN_MATCH+1.
- */
-
-#define MAX_DIST(s)  ((s)->w_size-MIN_LOOKAHEAD)
-/* In order to simplify the code, particularly on 16 bit machines, match
- * distances are limited to MAX_DIST instead of WSIZE.
- */
-
-#define WIN_INIT MAX_MATCH
-/* Number of bytes after end of data in window to initialize in order to avoid
-   memory checker errors from longest match routines */
-
-        /* in trees.c */
-void ZLIB_INTERNAL _tr_init OF((deflate_state *s));
-int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
-void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf,
-                        ulg stored_len, int last));
-void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s));
-void ZLIB_INTERNAL _tr_align OF((deflate_state *s));
-void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
-                        ulg stored_len, int last));
-
-#define d_code(dist) \
-   ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
-/* Mapping from a distance to a distance code. dist is the distance - 1 and
- * must not have side effects. _dist_code[256] and _dist_code[257] are never
- * used.
- */
-
-#ifndef DEBUG
-/* Inline versions of _tr_tally for speed: */
-
-#if defined(GEN_TREES_H) || !defined(STDC)
-  extern uch ZLIB_INTERNAL _length_code[];
-  extern uch ZLIB_INTERNAL _dist_code[];
-#else
-  extern const uch ZLIB_INTERNAL _length_code[];
-  extern const uch ZLIB_INTERNAL _dist_code[];
-#endif
-
-# define _tr_tally_lit(s, c, flush) \
-  { uch cc = (c); \
-    s->d_buf[s->last_lit] = 0; \
-    s->l_buf[s->last_lit++] = cc; \
-    s->dyn_ltree[cc].Freq++; \
-    flush = (s->last_lit == s->lit_bufsize-1); \
-   }
-# define _tr_tally_dist(s, distance, length, flush) \
-  { uch len = (length); \
-    ush dist = (distance); \
-    s->d_buf[s->last_lit] = dist; \
-    s->l_buf[s->last_lit++] = len; \
-    dist--; \
-    s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
-    s->dyn_dtree[d_code(dist)].Freq++; \
-    flush = (s->last_lit == s->lit_bufsize-1); \
-  }
-#else
-# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
-# define _tr_tally_dist(s, distance, length, flush) \
-              flush = _tr_tally(s, distance, length)
-#endif
-
-#endif /* DEFLATE_H */
diff --git a/deps/zlib/gzclose.c b/deps/zlib/gzclose.c
deleted file mode 100644 (file)
index edeee03..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/* gzclose.c -- zlib gzclose() function
- * Copyright (C) 2004, 2010 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#include "gzguts.h"
-
-extern int gzclose_w(gzFile file);
-extern int gzclose_r(gzFile file);
-
-/* gzclose() is in a separate file so that it is linked in only if it is used.
-   That way the other gzclose functions can be used instead to avoid linking in
-   unneeded compression or decompression routines. */
-int gzclose(gzFile file)
-{
-#ifndef NO_GZCOMPRESS
-   gz_statep state;
-
-   if (file == NULL)
-      return Z_STREAM_ERROR;
-   state = (gz_statep)file;
-
-   return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file);
-#else
-   return gzclose_r(file);
-#endif
-}
diff --git a/deps/zlib/gzfile.h b/deps/zlib/gzfile.h
deleted file mode 100644 (file)
index 2df4842..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-
-#ifndef _GZFILE_H
-#define _GZFILE_H
-
-struct gzFile_s
-{
-   unsigned have;
-   unsigned char *next;
-   z_off64_t pos;
-};
-
-#endif
diff --git a/deps/zlib/gzguts.h b/deps/zlib/gzguts.h
deleted file mode 100644 (file)
index 6068d41..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-/* gzguts.h -- zlib internal header definitions for gz* operations
- * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#ifndef _GZGUTS_H
-#define _GZGUTS_H
-
-#ifdef _LARGEFILE64_SOURCE
-#  ifndef _LARGEFILE_SOURCE
-#    define _LARGEFILE_SOURCE 1
-#  endif
-#  ifdef _FILE_OFFSET_BITS
-#    undef _FILE_OFFSET_BITS
-#  endif
-#endif
-
-#ifdef HAVE_HIDDEN
-#  define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
-#else
-#  define ZLIB_INTERNAL
-#endif
-
-#include <stdio.h>
-#include "zlib.h"
-#ifdef STDC
-#  include <string.h>
-#  include <stdlib.h>
-#  include <limits.h>
-#endif
-#include <fcntl.h>
-
-#ifdef _WIN32
-#  include <stddef.h>
-#else
-#  include <unistd.h>
-#endif
-
-#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)
-#  include <io.h>
-#endif
-
-#ifdef WINAPI_FAMILY
-#  define open _open
-#  define read _read
-#  define write _write
-#  define close _close
-#endif
-
-#ifdef NO_DEFLATE       /* for compatibility with old definition */
-#  define NO_GZCOMPRESS
-#endif
-
-#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
-#  ifndef HAVE_VSNPRINTF
-#    define HAVE_VSNPRINTF
-#  endif
-#endif
-
-#if defined(__CYGWIN__)
-#  ifndef HAVE_VSNPRINTF
-#    define HAVE_VSNPRINTF
-#  endif
-#endif
-
-#if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410)
-#  ifndef HAVE_VSNPRINTF
-#    define HAVE_VSNPRINTF
-#  endif
-#endif
-
-#ifndef HAVE_VSNPRINTF
-#  ifdef MSDOS
-/* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
-   but for now we just assume it doesn't. */
-#    define NO_vsnprintf
-#  endif
-#  ifdef __TURBOC__
-#    define NO_vsnprintf
-#  endif
-#  ifdef WIN32
-/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
-#    if !defined(vsnprintf) && !defined(NO_vsnprintf)
-#      if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
-#         define vsnprintf _vsnprintf
-#      endif
-#    endif
-#  endif
-#  ifdef __SASC
-#    define NO_vsnprintf
-#  endif
-#  ifdef VMS
-#    define NO_vsnprintf
-#  endif
-#  ifdef __OS400__
-#    define NO_vsnprintf
-#  endif
-#  ifdef __MVS__
-#    define NO_vsnprintf
-#  endif
-#endif
-
-/* unlike snprintf (which is required in C99, yet still not supported by
-   Microsoft more than a decade later!), _snprintf does not guarantee null
-   termination of the result -- however this is only used in gzlib.c where
-   the result is assured to fit in the space provided */
-#ifdef _MSC_VER
-#  define snprintf _snprintf
-#endif
-
-#ifndef local
-#  define local static
-#endif
-/* compile with -Dlocal if your debugger can't find static symbols */
-
-/* gz* functions always use library allocation functions */
-#ifndef STDC
-  extern voidp  malloc OF((uInt size));
-  extern void   free   OF((voidpf ptr));
-#endif
-
-/* get errno and strerror definition */
-#if defined UNDER_CE
-#  include <windows.h>
-#  define zstrerror() gz_strwinerror((DWORD)GetLastError())
-#else
-#  ifndef NO_STRERROR
-#    include <errno.h>
-#    define zstrerror() strerror(errno)
-#  else
-#    define zstrerror() "stdio error (consult errno)"
-#  endif
-#endif
-
-/* provide prototypes for these when building zlib without LFS */
-#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
-#ifndef z_off64_t
-#define z_off64_t z_off_t
-#endif
-
-    gzFile gzopen64 OF((const char *, const char *));
-    z_off64_t gzseek64 OF((gzFile, z_off64_t, int));
-    z_off64_t gztell64 OF((gzFile));
-    z_off64_t gzoffset64 OF((gzFile));
-#endif
-
-/* default memLevel */
-#if MAX_MEM_LEVEL >= 8
-#  define DEF_MEM_LEVEL 8
-#else
-#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL
-#endif
-
-/* default i/o buffer size -- double this for output when reading (this and
-   twice this must be able to fit in an unsigned type) */
-#define GZBUFSIZE 8192
-
-/* gzip modes, also provide a little integrity check on the passed structure */
-#define GZ_NONE 0
-#define GZ_READ 7247
-#define GZ_WRITE 31153
-#define GZ_APPEND 1     /* mode set to GZ_WRITE after the file is opened */
-
-/* values for gz_state how */
-#define LOOK 0      /* look for a gzip header */
-#define MODE_COPY 1      /* copy input directly */
-#define MODE_GZIP 2      /* decompress a gzip stream */
-
-#include "gzfile.h"
-
-/* internal gzip file state data structure */
-typedef struct {
-        /* exposed contents for gzgetc() macro */
-    struct gzFile_s x;      /* "x" for exposed */
-                            /* x.have: number of bytes available at x.next */
-                            /* x.next: next output data to deliver or write */
-                            /* x.pos: current position in uncompressed data */
-        /* used for both reading and writing */
-    int mode;               /* see gzip modes above */
-    int fd;                 /* file descriptor */
-    char *path;             /* path or fd for error messages */
-    unsigned size;          /* buffer size, zero if not allocated yet */
-    unsigned want;          /* requested buffer size, default is GZBUFSIZE */
-    unsigned char *in;      /* input buffer */
-    unsigned char *out;     /* output buffer (double-sized when reading) */
-    int direct;             /* 0 if processing gzip, 1 if transparent */
-        /* just for reading */
-    int how;                /* 0: get header, 1: copy, 2: decompress */
-    z_off64_t start;        /* where the gzip data started, for rewinding */
-    int eof;                /* true if end of input file reached */
-    int past;               /* true if read requested past end */
-        /* just for writing */
-    int level;              /* compression level */
-    int strategy;           /* compression strategy */
-        /* seek request */
-    z_off64_t skip;         /* amount to skip (already rewound if backwards) */
-    int seek;               /* true if seek request pending */
-        /* error information */
-    int err;                /* error code */
-    char *msg;              /* error message */
-        /* zlib inflate or deflate stream */
-    z_stream strm;          /* stream structure in-place (not a pointer) */
-} gz_state;
-typedef gz_state FAR *gz_statep;
-
-/* shared functions */
-void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *));
-#if defined UNDER_CE
-char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error));
-#endif
-
-/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
-   value -- needed when comparing unsigned to z_off64_t, which is signed
-   (possible z_off64_t types off_t, off64_t, and long are all signed) */
-#ifdef INT_MAX
-#  define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
-#else
-unsigned ZLIB_INTERNAL gz_intmax OF((void));
-#  define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
-#endif
-
-#endif
diff --git a/deps/zlib/gzlib.c b/deps/zlib/gzlib.c
deleted file mode 100644 (file)
index 7443a75..0000000
+++ /dev/null
@@ -1,604 +0,0 @@
-/* gzlib.c -- zlib functions common to reading and writing gzip files
- * Copyright (C) 2004, 2010, 2011, 2012, 2013 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#include "gzguts.h"
-
-#if defined(_WIN32) && !defined(__BORLANDC__)
-#  define LSEEK _lseeki64
-#else
-#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
-#  define LSEEK lseek64
-#else
-#  define LSEEK lseek
-#endif
-#endif
-
-/* Forward declarations */
-z_off_t ZEXPORT gzoffset(gzFile file);
-int ZEXPORT gzbuffer(gzFile file, unsigned size);
-
-/* Local functions */
-local void gz_reset OF((gz_statep));
-local gzFile gz_open OF((const void *, int, const char *));
-
-#if defined UNDER_CE
-
-/* Map the Windows error number in ERROR to a locale-dependent error message
-   string and return a pointer to it.  Typically, the values for ERROR come
-   from GetLastError.
-
-   The string pointed to shall not be modified by the application, but may be
-   overwritten by a subsequent call to gz_strwinerror
-
-   The gz_strwinerror function does not change the current setting of
-   GetLastError. */
-char ZLIB_INTERNAL *gz_strwinerror (error)
-   DWORD error;
-{
-   static char buf[1024];
-
-   wchar_t *msgbuf;
-   DWORD lasterr = GetLastError();
-   DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
-         | FORMAT_MESSAGE_ALLOCATE_BUFFER,
-         NULL,
-         error,
-         0, /* Default language */
-         (LPVOID)&msgbuf,
-         0,
-         NULL);
-   if (chars != 0) {
-      /* If there is an \r\n appended, zap it.  */
-      if (chars >= 2
-            && msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n') {
-         chars -= 2;
-         msgbuf[chars] = 0;
-      }
-
-      if (chars > sizeof (buf) - 1) {
-         chars = sizeof (buf) - 1;
-         msgbuf[chars] = 0;
-      }
-
-      wcstombs(buf, msgbuf, chars + 1);
-      LocalFree(msgbuf);
-   }
-   else {
-      sprintf(buf, "unknown win32 error (%ld)", error);
-   }
-
-   SetLastError(lasterr);
-   return buf;
-}
-
-#endif /* UNDER_CE */
-
-/* Reset gzip file state */
-local void gz_reset(gz_statep state)
-{
-   state->x.have = 0;              /* no output data available */
-   if (state->mode == GZ_READ) {   /* for reading ... */
-      state->eof = 0;             /* not at end of file */
-      state->past = 0;            /* have not read past end yet */
-      state->how = LOOK;          /* look for gzip header */
-   }
-   state->seek = 0;                /* no seek request pending */
-   gz_error(state, Z_OK, NULL);    /* clear error */
-   state->x.pos = 0;               /* no uncompressed data yet */
-   state->strm.avail_in = 0;       /* no input data yet */
-}
-
-/* Open a gzip file either by name or file descriptor. */
-local gzFile gz_open(const void *path, int fd, const char *mode)
-{
-   gz_statep state;
-   size_t len;
-   int oflag;
-#ifdef O_CLOEXEC
-   int cloexec = 0;
-#endif
-#ifdef O_EXCL
-   int exclusive = 0;
-#endif
-
-   /* check input */
-   if (path == NULL)
-      return NULL;
-
-   /* allocate gzFile structure to return */
-   state = (gz_statep)malloc(sizeof(gz_state));
-   if (state == NULL)
-      return NULL;
-   state->size = 0;            /* no buffers allocated yet */
-   state->want = GZBUFSIZE;    /* requested buffer size */
-   state->msg = NULL;          /* no error message yet */
-
-   /* interpret mode */
-   state->mode = GZ_NONE;
-   state->level = Z_DEFAULT_COMPRESSION;
-   state->strategy = Z_DEFAULT_STRATEGY;
-   state->direct = 0;
-   while (*mode) {
-      if (*mode >= '0' && *mode <= '9')
-         state->level = *mode - '0';
-      else
-         switch (*mode) {
-            case 'r':
-               state->mode = GZ_READ;
-               break;
-#ifndef NO_GZCOMPRESS
-            case 'w':
-               state->mode = GZ_WRITE;
-               break;
-            case 'a':
-               state->mode = GZ_APPEND;
-               break;
-#endif
-            case '+':       /* can't read and write at the same time */
-               free(state);
-               return NULL;
-            case 'b':       /* ignore -- will request binary anyway */
-               break;
-#ifdef O_CLOEXEC
-            case 'e':
-               cloexec = 1;
-               break;
-#endif
-#ifdef O_EXCL
-            case 'x':
-               exclusive = 1;
-               break;
-#endif
-            case 'f':
-               state->strategy = Z_FILTERED;
-               break;
-            case 'h':
-               state->strategy = Z_HUFFMAN_ONLY;
-               break;
-            case 'R':
-               state->strategy = Z_RLE;
-               break;
-            case 'F':
-               state->strategy = Z_FIXED;
-               break;
-            case 'T':
-               state->direct = 1;
-               break;
-            default:        /* could consider as an error, but just ignore */
-               ;
-         }
-      mode++;
-   }
-
-   /* must provide an "r", "w", or "a" */
-   if (state->mode == GZ_NONE) {
-      free(state);
-      return NULL;
-   }
-
-   /* can't force transparent read */
-   if (state->mode == GZ_READ) {
-      if (state->direct) {
-         free(state);
-         return NULL;
-      }
-      state->direct = 1;      /* for empty file */
-   }
-
-   /* save the path name for error messages */
-#ifdef _WIN32
-   if (fd == -2) {
-      len = wcstombs(NULL, (const wchar_t*)path, 0);
-      if (len == (size_t)-1)
-         len = 0;
-   }
-   else
-#endif
-      len = strlen((const char *)path);
-   state->path = (char *)malloc(len + 1);
-   if (state->path == NULL) {
-      free(state);
-      return NULL;
-   }
-#ifdef _WIN32
-   if (fd == -2)
-      if (len)
-         wcstombs(state->path, (const wchar_t*)path, len + 1);
-      else
-         *(state->path) = 0;
-   else
-#endif
-#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
-      snprintf(state->path, len + 1, "%s", (const char *)path);
-#else
-   strlcpy(state->path, path, sizeof(state->path));
-#endif
-
-   /* compute the flags for open() */
-   oflag =
-#ifdef O_LARGEFILE
-      O_LARGEFILE |
-#endif
-#ifdef O_BINARY
-      O_BINARY |
-#endif
-#ifdef O_CLOEXEC
-      (cloexec ? O_CLOEXEC : 0) |
-#endif
-      (state->mode == GZ_READ ?
-       O_RDONLY :
-       (O_WRONLY | O_CREAT |
-#ifdef O_EXCL
-        (exclusive ? O_EXCL : 0) |
-#endif
-        (state->mode == GZ_WRITE ?
-         O_TRUNC :
-         O_APPEND)));
-
-   /* open the file with the appropriate flags (or just use fd) */
-   state->fd = fd > -1 ? fd : (
-#ifdef _WIN32
-         fd == -2 ? _wopen((const wchar_t*)path, oflag, 0666) :
-#endif
-         open((const char *)path, oflag, 0666));
-   if (state->fd == -1) {
-      free(state->path);
-      free(state);
-      return NULL;
-   }
-   if (state->mode == GZ_APPEND)
-      state->mode = GZ_WRITE;         /* simplify later checks */
-
-   /* save the current position for rewinding (only if reading) */
-   if (state->mode == GZ_READ) {
-      state->start = LSEEK(state->fd, 0, SEEK_CUR);
-      if (state->start == -1) state->start = 0;
-   }
-
-   /* initialize stream */
-   gz_reset(state);
-
-   /* return stream */
-   return (gzFile)state;
-}
-
-/* -- see zlib.h -- */
-gzFile ZEXPORT gzopen(const char *path, const char *mode)
-{
-   return gz_open(path, -1, mode);
-}
-
-/* -- see zlib.h -- */
-gzFile ZEXPORT gzopen64(const char *path, const char *mode)
-{
-   return gz_open(path, -1, mode);
-}
-
-/* -- see zlib.h -- */
-gzFile ZEXPORT gzdopen(int fd, const char *mode)
-{
-   char *path;         /* identifier for error messages */
-   gzFile gz;
-
-   if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL)
-      return NULL;
-#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
-   snprintf(path, 7 + 3 * sizeof(int), "<fd:%d>", fd); /* for debugging */
-#else
-   sprintf(path, "<fd:%d>", fd);   /* for debugging */
-#endif
-   gz = gz_open(path, fd, mode);
-   free(path);
-   return gz;
-}
-
-/* -- see zlib.h -- */
-#ifdef _WIN32
-gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode)
-{
-   return gz_open(path, -2, mode);
-}
-#endif
-
-/* -- see zlib.h -- */
-int ZEXPORT gzbuffer(gzFile file, unsigned size)
-{
-   gz_statep state;
-
-   /* get internal structure and check integrity */
-   if (file == NULL)
-      return -1;
-   state = (gz_statep)file;
-   if (state->mode != GZ_READ && state->mode != GZ_WRITE)
-      return -1;
-
-   /* make sure we haven't already allocated memory */
-   if (state->size != 0)
-      return -1;
-
-   /* check and set requested size */
-   if (size < 2)
-      size = 2;               /* need two bytes to check magic header */
-   state->want = size;
-   return 0;
-}
-
-/* -- see zlib.h -- */
-int ZEXPORT gzrewind(gzFile file)
-{
-   gz_statep state;
-
-   /* get internal structure */
-   if (file == NULL)
-      return -1;
-   state = (gz_statep)file;
-
-   /* check that we're reading and that there's no error */
-   if (state->mode != GZ_READ ||
-         (state->err != Z_OK && state->err != Z_BUF_ERROR))
-      return -1;
-
-   /* back up and start over */
-   if (LSEEK(state->fd, state->start, SEEK_SET) == -1)
-      return -1;
-   gz_reset(state);
-   return 0;
-}
-
-/* -- see zlib.h -- */
-z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence)
-{
-   unsigned n;
-   z_off64_t ret;
-   gz_statep state;
-
-   /* get internal structure and check integrity */
-   if (file == NULL)
-      return -1;
-   state = (gz_statep)file;
-   if (state->mode != GZ_READ && state->mode != GZ_WRITE)
-      return -1;
-
-   /* check that there's no error */
-   if (state->err != Z_OK && state->err != Z_BUF_ERROR)
-      return -1;
-
-   /* can only seek from start or relative to current position */
-   if (whence != SEEK_SET && whence != SEEK_CUR)
-      return -1;
-
-   /* normalize offset to a SEEK_CUR specification */
-   if (whence == SEEK_SET)
-      offset -= state->x.pos;
-   else if (state->seek)
-      offset += state->skip;
-   state->seek = 0;
-
-   /* if within raw area while reading, just go there */
-   if (state->mode == GZ_READ && state->how == MODE_COPY &&
-         state->x.pos + offset >= 0) {
-      ret = LSEEK(state->fd, offset - state->x.have, SEEK_CUR);
-      if (ret == -1)
-         return -1;
-      state->x.have = 0;
-      state->eof = 0;
-      state->past = 0;
-      state->seek = 0;
-      gz_error(state, Z_OK, NULL);
-      state->strm.avail_in = 0;
-      state->x.pos += offset;
-      return state->x.pos;
-   }
-
-   /* calculate skip amount, rewinding if needed for back seek when reading */
-   if (offset < 0) {
-      if (state->mode != GZ_READ)         /* writing -- can't go backwards */
-         return -1;
-      offset += state->x.pos;
-      if (offset < 0)                     /* before start of file! */
-         return -1;
-      if (gzrewind(file) == -1)           /* rewind, then skip to offset */
-         return -1;
-   }
-
-   /* if reading, skip what's in output buffer (one less gzgetc() check) */
-   if (state->mode == GZ_READ) {
-      n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > offset ?
-         (unsigned)offset : state->x.have;
-      state->x.have -= n;
-      state->x.next += n;
-      state->x.pos += n;
-      offset -= n;
-   }
-
-   /* request skip (if not zero) */
-   if (offset) {
-      state->seek = 1;
-      state->skip = offset;
-   }
-   return state->x.pos + offset;
-}
-
-/* -- see zlib.h -- */
-z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence)
-{
-   z_off64_t ret;
-
-   ret = gzseek64(file, (z_off64_t)offset, whence);
-   return ret == (z_off_t)ret ? (z_off_t)ret : -1;
-}
-
-/* -- see zlib.h -- */
-z_off64_t ZEXPORT gztell64(gzFile file)
-{
-   gz_statep state;
-
-   /* get internal structure and check integrity */
-   if (file == NULL)
-      return -1;
-   state = (gz_statep)file;
-   if (state->mode != GZ_READ && state->mode != GZ_WRITE)
-      return -1;
-
-   /* return position */
-   return state->x.pos + (state->seek ? state->skip : 0);
-}
-
-/* -- see zlib.h -- */
-z_off_t ZEXPORT gztell(gzFile file)
-{
-   z_off64_t ret;
-
-   ret = gztell64(file);
-   return ret == (z_off_t)ret ? (z_off_t)ret : -1;
-}
-
-/* -- see zlib.h -- */
-z_off64_t ZEXPORT gzoffset64(gzFile file)
-{
-   z_off64_t offset;
-   gz_statep state;
-
-   /* get internal structure and check integrity */
-   if (file == NULL)
-      return -1;
-   state = (gz_statep)file;
-   if (state->mode != GZ_READ && state->mode != GZ_WRITE)
-      return -1;
-
-   /* compute and return effective offset in file */
-   offset = LSEEK(state->fd, 0, SEEK_CUR);
-   if (offset == -1)
-      return -1;
-   if (state->mode == GZ_READ)             /* reading */
-      offset -= state->strm.avail_in;     /* don't count buffered input */
-   return offset;
-}
-
-/* -- see zlib.h -- */
-z_off_t ZEXPORT gzoffset(gzFile file)
-{
-   z_off64_t ret = gzoffset64(file);
-   return ret == (z_off_t)ret ? (z_off_t)ret : -1;
-}
-
-/* -- see zlib.h -- */
-int ZEXPORT gzeof(gzFile file)
-{
-   gz_statep state;
-
-   /* get internal structure and check integrity */
-   if (file == NULL)
-      return 0;
-   state = (gz_statep)file;
-   if (state->mode != GZ_READ && state->mode != GZ_WRITE)
-      return 0;
-
-   /* return end-of-file state */
-   return state->mode == GZ_READ ? state->past : 0;
-}
-
-/* -- see zlib.h -- */
-const char * ZEXPORT gzerror(gzFile file, int *errnum)
-{
-   gz_statep state;
-
-   /* get internal structure and check integrity */
-   if (file == NULL)
-      return NULL;
-   state = (gz_statep)file;
-   if (state->mode != GZ_READ && state->mode != GZ_WRITE)
-      return NULL;
-
-   /* return error information */
-   if (errnum != NULL)
-      *errnum = state->err;
-   return state->err == Z_MEM_ERROR ? "out of memory" :
-      (state->msg == NULL ? "" : state->msg);
-}
-
-/* -- see zlib.h -- */
-void ZEXPORT gzclearerr(gzFile file)
-{
-   gz_statep state;
-
-   /* get internal structure and check integrity */
-   if (file == NULL)
-      return;
-   state = (gz_statep)file;
-   if (state->mode != GZ_READ && state->mode != GZ_WRITE)
-      return;
-
-   /* clear error and end-of-file */
-   if (state->mode == GZ_READ) {
-      state->eof = 0;
-      state->past = 0;
-   }
-   gz_error(state, Z_OK, NULL);
-}
-
-/* Create an error message in allocated memory and set state->err and
-   state->msg accordingly.  Free any previous error message already there.  Do
-   not try to free or allocate space if the error is Z_MEM_ERROR (out of
-   memory).  Simply save the error message as a static string.  If there is an
-   allocation failure constructing the error message, then convert the error to
-   out of memory. */
-void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
-{
-   /* free previously allocated message and clear */
-   if (state->msg != NULL) {
-      if (state->err != Z_MEM_ERROR)
-         free(state->msg);
-      state->msg = NULL;
-   }
-
-   /* if fatal, set state->x.have to 0 so that the gzgetc() macro fails */
-   if (err != Z_OK && err != Z_BUF_ERROR)
-      state->x.have = 0;
-
-   /* set error code, and if no message, then done */
-   state->err = err;
-   if (msg == NULL)
-      return;
-
-   /* for an out of memory error, return literal string when requested */
-   if (err == Z_MEM_ERROR)
-      return;
-
-   /* construct error message with path */
-   if ((state->msg = (char *)malloc(strlen(state->path) + strlen(msg) + 3)) ==
-         NULL) {
-      state->err = Z_MEM_ERROR;
-      return;
-   }
-#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
-   snprintf(state->msg, strlen(state->path) + strlen(msg) + 3,
-         "%s%s%s", state->path, ": ", msg);
-#else
-   strlcpy(state->msg, state->path, sizeof(state->msg));
-   strlcat(state->msg, ": ", sizeof(state->msg));
-   strlcat(state->msg, msg, sizeof(state->msg));
-#endif
-   return;
-}
-
-#ifndef INT_MAX
-/* portably return maximum value for an int (when limits.h presumed not
-   available) -- we need to do this to cover cases where 2's complement not
-   used, since C standard permits 1's complement and sign-bit representations,
-   otherwise we could just use ((unsigned)-1) >> 1 */
-unsigned ZLIB_INTERNAL gz_intmax()
-{
-   unsigned p, q;
-
-   p = 1;
-   do {
-      q = p;
-      p <<= 1;
-      p++;
-   } while (p > q);
-   return q >> 1;
-}
-#endif
diff --git a/deps/zlib/gzread.c b/deps/zlib/gzread.c
deleted file mode 100644 (file)
index 7f6ec7e..0000000
+++ /dev/null
@@ -1,575 +0,0 @@
-/* gzread.c -- zlib functions for reading gzip files
- * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#include "gzguts.h"
-
-/* Local functions */
-local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *));
-local int gz_avail OF((gz_statep));
-local int gz_look OF((gz_statep));
-local int gz_decomp OF((gz_statep));
-local int gz_fetch OF((gz_statep));
-local int gz_skip OF((gz_statep, z_off64_t));
-
-int ZEXPORT gzgetc_(gzFile file);
-
-/* Use read() to load a buffer -- return -1 on error, otherwise 0.  Read from
-   state->fd, and update state->eof, state->err, and state->msg as appropriate.
-   This function needs to loop on read(), since read() is not guaranteed to
-   read the number of bytes requested, depending on the type of descriptor. */
-local int gz_load(gz_statep state, unsigned char *buf, unsigned len, unsigned *have)
-{
-   int ret;
-
-   *have = 0;
-   do {
-      ret = read(state->fd, buf + *have, len - *have);
-      if (ret <= 0)
-         break;
-      *have += ret;
-   } while (*have < len);
-   if (ret < 0) {
-      gz_error(state, Z_ERRNO, zstrerror());
-      return -1;
-   }
-   if (ret == 0)
-      state->eof = 1;
-   return 0;
-}
-
-/* Load up input buffer and set eof flag if last data loaded -- return -1 on
-   error, 0 otherwise.  Note that the eof flag is set when the end of the input
-   file is reached, even though there may be unused data in the buffer.  Once
-   that data has been used, no more attempts will be made to read the file.
-   If strm->avail_in != 0, then the current data is moved to the beginning of
-   the input buffer, and then the remainder of the buffer is loaded with the
-   available data from the input file. */
-local int gz_avail(gz_statep state)
-{
-   unsigned got;
-   z_streamp strm = &(state->strm);
-
-   if (state->err != Z_OK && state->err != Z_BUF_ERROR)
-      return -1;
-   if (state->eof == 0) {
-      if (strm->avail_in) {       /* copy what's there to the start */
-         unsigned char *p = state->in;
-         unsigned const char *q = strm->next_in;
-         unsigned n = strm->avail_in;
-         do {
-            *p++ = *q++;
-         } while (--n);
-      }
-      if (gz_load(state, state->in + strm->avail_in,
-               state->size - strm->avail_in, &got) == -1)
-         return -1;
-      strm->avail_in += got;
-      strm->next_in = state->in;
-   }
-   return 0;
-}
-
-/* Look for gzip header, set up for inflate or copy.  state->x.have must be 0.
-   If this is the first time in, allocate required memory.  state->how will be
-   left unchanged if there is no more input data available, will be set to COPY
-   if there is no gzip header and direct copying will be performed, or it will
-   be set to GZIP for decompression.  If direct copying, then leftover input
-   data from the input buffer will be copied to the output buffer.  In that
-   case, all further file reads will be directly to either the output buffer or
-   a user buffer.  If decompressing, the inflate state will be initialized.
-   gz_look() will return 0 on success or -1 on failure. */
-local int gz_look(gz_statep state)
-{
-   z_streamp strm = &(state->strm);
-
-   /* allocate read buffers and inflate memory */
-   if (state->size == 0) {
-      /* allocate buffers */
-      state->in = (unsigned char *)malloc(state->want);
-      state->out = (unsigned char *)malloc(state->want << 1);
-      if (state->in == NULL || state->out == NULL) {
-         if (state->out != NULL)
-            free(state->out);
-         if (state->in != NULL)
-            free(state->in);
-         gz_error(state, Z_MEM_ERROR, "out of memory");
-         return -1;
-      }
-      state->size = state->want;
-
-      /* allocate inflate memory */
-      state->strm.zalloc = Z_NULL;
-      state->strm.zfree = Z_NULL;
-      state->strm.opaque = Z_NULL;
-      state->strm.avail_in = 0;
-      state->strm.next_in = Z_NULL;
-      if (inflateInit2(&(state->strm), 15 + 16) != Z_OK) {    /* gunzip */
-         free(state->out);
-         free(state->in);
-         state->size = 0;
-         gz_error(state, Z_MEM_ERROR, "out of memory");
-         return -1;
-      }
-   }
-
-   /* get at least the magic bytes in the input buffer */
-   if (strm->avail_in < 2) {
-      if (gz_avail(state) == -1)
-         return -1;
-      if (strm->avail_in == 0)
-         return 0;
-   }
-
-   /* look for gzip magic bytes -- if there, do gzip decoding (note: there is
-      a logical dilemma here when considering the case of a partially written
-      gzip file, to wit, if a single 31 byte is written, then we cannot tell
-      whether this is a single-byte file, or just a partially written gzip
-      file -- for here we assume that if a gzip file is being written, then
-      the header will be written in a single operation, so that reading a
-      single byte is sufficient indication that it is not a gzip file) */
-   if (strm->avail_in > 1 &&
-         strm->next_in[0] == 31 && strm->next_in[1] == 139) {
-      inflateReset(strm);
-      state->how = MODE_GZIP;
-      state->direct = 0;
-      return 0;
-   }
-
-   /* no gzip header -- if we were decoding gzip before, then this is trailing
-      garbage.  Ignore the trailing garbage and finish. */
-   if (state->direct == 0) {
-      strm->avail_in = 0;
-      state->eof = 1;
-      state->x.have = 0;
-      return 0;
-   }
-
-   /* doing raw i/o, copy any leftover input to output -- this assumes that
-      the output buffer is larger than the input buffer, which also assures
-      space for gzungetc() */
-   state->x.next = state->out;
-   if (strm->avail_in) {
-      memcpy(state->x.next, strm->next_in, strm->avail_in);
-      state->x.have = strm->avail_in;
-      strm->avail_in = 0;
-   }
-   state->how = MODE_COPY;
-   state->direct = 1;
-   return 0;
-}
-
-/* Decompress from input to the provided next_out and avail_out in the state.
-   On return, state->x.have and state->x.next point to the just decompressed
-   data.  If the gzip stream completes, state->how is reset to LOOK to look for
-   the next gzip stream or raw data, once state->x.have is depleted.  Returns 0
-   on success, -1 on failure. */
-local int gz_decomp(gz_statep state)
-{
-   int ret = Z_OK;
-   unsigned had;
-   z_streamp strm = &(state->strm);
-
-   /* fill output buffer up to end of deflate stream */
-   had = strm->avail_out;
-   do {
-      /* get more input for inflate() */
-      if (strm->avail_in == 0 && gz_avail(state) == -1)
-         return -1;
-      if (strm->avail_in == 0) {
-         gz_error(state, Z_BUF_ERROR, "unexpected end of file");
-         break;
-      }
-
-      /* decompress and handle errors */
-      ret = inflate(strm, Z_NO_FLUSH);
-      if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) {
-         gz_error(state, Z_STREAM_ERROR,
-               "internal error: inflate stream corrupt");
-         return -1;
-      }
-      if (ret == Z_MEM_ERROR) {
-         gz_error(state, Z_MEM_ERROR, "out of memory");
-         return -1;
-      }
-      if (ret == Z_DATA_ERROR) {              /* deflate stream invalid */
-         gz_error(state, Z_DATA_ERROR,
-               strm->msg == NULL ? "compressed data error" : strm->msg);
-         return -1;
-      }
-   } while (strm->avail_out && ret != Z_STREAM_END);
-
-   /* update available output */
-   state->x.have = had - strm->avail_out;
-   state->x.next = strm->next_out - state->x.have;
-
-   /* if the gzip stream completed successfully, look for another */
-   if (ret == Z_STREAM_END)
-      state->how = LOOK;
-
-   /* good decompression */
-   return 0;
-}
-
-/* Fetch data and put it in the output buffer.  Assumes state->x.have is 0.
-   Data is either copied from the input file or decompressed from the input
-   file depending on state->how.  If state->how is LOOK, then a gzip header is
-   looked for to determine whether to copy or decompress.  Returns -1 on error,
-   otherwise 0.  gz_fetch() will leave state->how as COPY or GZIP unless the
-   end of the input file has been reached and all data has been processed.  */
-local int gz_fetch(gz_statep state)
-{
-   z_streamp strm = &(state->strm);
-
-   do {
-      switch(state->how) {
-         case LOOK:      /* -> LOOK, MODE_COPY (only if never GZIP), or MODE_GZIP */
-            if (gz_look(state) == -1)
-               return -1;
-            if (state->how == LOOK)
-               return 0;
-            break;
-         case MODE_COPY:      /* -> MODE_COPY */
-            if (gz_load(state, state->out, state->size << 1, &(state->x.have))
-                  == -1)
-               return -1;
-            state->x.next = state->out;
-            return 0;
-         case MODE_GZIP:      /* -> GZIP or LOOK (if end of gzip stream) */
-            strm->avail_out = state->size << 1;
-            strm->next_out = state->out;
-            if (gz_decomp(state) == -1)
-               return -1;
-      }
-   } while (state->x.have == 0 && (!state->eof || strm->avail_in));
-   return 0;
-}
-
-/* Skip len uncompressed bytes of output.  Return -1 on error, 0 on success. */
-local int gz_skip(gz_statep state, z_off64_t len)
-{
-   unsigned n;
-
-   /* skip over len bytes or reach end-of-file, whichever comes first */
-   while (len)
-      /* skip over whatever is in output buffer */
-      if (state->x.have) {
-         n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > len ?
-            (unsigned)len : state->x.have;
-         state->x.have -= n;
-         state->x.next += n;
-         state->x.pos += n;
-         len -= n;
-      }
-
-   /* output buffer empty -- return if we're at the end of the input */
-      else if (state->eof && state->strm.avail_in == 0)
-         break;
-
-   /* need more data to skip -- load up output buffer */
-      else {
-         /* get more output, looking for header if required */
-         if (gz_fetch(state) == -1)
-            return -1;
-      }
-   return 0;
-}
-
-/* -- see zlib.h -- */
-int ZEXPORT gzread(gzFile file, voidp buf, unsigned len)
-{
-   unsigned got, n;
-   gz_statep state;
-   z_streamp strm;
-
-   /* get internal structure */
-   if (file == NULL)
-      return -1;
-   state = (gz_statep)file;
-   strm = &(state->strm);
-
-   /* check that we're reading and that there's no (serious) error */
-   if (state->mode != GZ_READ ||
-         (state->err != Z_OK && state->err != Z_BUF_ERROR))
-      return -1;
-
-   /* since an int is returned, make sure len fits in one, otherwise return
-      with an error (this avoids the flaw in the interface) */
-   if ((int)len < 0) {
-      gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
-      return -1;
-   }
-
-   /* if len is zero, avoid unnecessary operations */
-   if (len == 0)
-      return 0;
-
-   /* process a skip request */
-   if (state->seek) {
-      state->seek = 0;
-      if (gz_skip(state, state->skip) == -1)
-         return -1;
-   }
-
-   /* get len bytes to buf, or less than len if at the end */
-   got = 0;
-   n = 0;
-   do {
-      /* first just try copying data from the output buffer */
-      if (state->x.have) {
-         n = state->x.have > len ? len : state->x.have;
-         memcpy(buf, state->x.next, n);
-         state->x.next += n;
-         state->x.have -= n;
-      }
-
-      /* output buffer empty -- return if we're at the end of the input */
-      else if (state->eof && strm->avail_in == 0) {
-         state->past = 1;        /* tried to read past end */
-         break;
-      }
-
-      /* need output data -- for small len or new stream load up our output
-         buffer */
-      else if (state->how == LOOK || len < (state->size << 1)) {
-         /* get more output, looking for header if required */
-         if (gz_fetch(state) == -1)
-            return -1;
-         continue;       /* no progress yet -- go back to copy above */
-         /* the copy above assures that we will leave with space in the
-            output buffer, allowing at least one gzungetc() to succeed */
-      }
-
-      /* large len -- read directly into user buffer */
-      else if (state->how == MODE_COPY) {      /* read directly */
-         if (gz_load(state, (unsigned char *)buf, len, &n) == -1)
-            return -1;
-      }
-
-      /* large len -- decompress directly into user buffer */
-      else {  /* state->how == GZIP */
-         strm->avail_out = len;
-         strm->next_out = (unsigned char *)buf;
-         if (gz_decomp(state) == -1)
-            return -1;
-         n = state->x.have;
-         state->x.have = 0;
-      }
-
-      /* update progress */
-      len -= n;
-      buf = (char *)buf + n;
-      got += n;
-      state->x.pos += n;
-   } while (len);
-
-   /* return number of bytes read into user buffer (will fit in int) */
-   return (int)got;
-}
-
-/* -- see zlib.h -- */
-#ifdef Z_PREFIX_SET
-#  undef z_gzgetc
-#else
-#  undef gzgetc
-#endif
-int ZEXPORT gzgetc(gzFile file)
-{
-   int ret;
-   unsigned char buf[1];
-   gz_statep state;
-
-   /* get internal structure */
-   if (file == NULL)
-      return -1;
-   state = (gz_statep)file;
-
-   /* check that we're reading and that there's no (serious) error */
-   if (state->mode != GZ_READ ||
-         (state->err != Z_OK && state->err != Z_BUF_ERROR))
-      return -1;
-
-   /* try output buffer (no need to check for skip request) */
-   if (state->x.have) {
-      state->x.have--;
-      state->x.pos++;
-      return *(state->x.next)++;
-   }
-
-   /* nothing there -- try gzread() */
-   ret = gzread(file, buf, 1);
-   return ret < 1 ? -1 : buf[0];
-}
-
-int ZEXPORT gzgetc_(gzFile file)
-{
-   return gzgetc(file);
-}
-
-/* -- see zlib.h -- */
-int ZEXPORT gzungetc(int c, gzFile file)
-{
-   gz_statep state;
-
-   /* get internal structure */
-   if (file == NULL)
-      return -1;
-   state = (gz_statep)file;
-
-   /* check that we're reading and that there's no (serious) error */
-   if (state->mode != GZ_READ ||
-         (state->err != Z_OK && state->err != Z_BUF_ERROR))
-      return -1;
-
-   /* process a skip request */
-   if (state->seek) {
-      state->seek = 0;
-      if (gz_skip(state, state->skip) == -1)
-         return -1;
-   }
-
-   /* can't push EOF */
-   if (c < 0)
-      return -1;
-
-   /* if output buffer empty, put byte at end (allows more pushing) */
-   if (state->x.have == 0) {
-      state->x.have = 1;
-      state->x.next = state->out + (state->size << 1) - 1;
-      state->x.next[0] = c;
-      state->x.pos--;
-      state->past = 0;
-      return c;
-   }
-
-   /* if no room, give up (must have already done a gzungetc()) */
-   if (state->x.have == (state->size << 1)) {
-      gz_error(state, Z_DATA_ERROR, "out of room to push characters");
-      return -1;
-   }
-
-   /* slide output data if needed and insert byte before existing data */
-   if (state->x.next == state->out) {
-      unsigned char *src = state->out + state->x.have;
-      unsigned char *dest = state->out + (state->size << 1);
-      while (src > state->out)
-         *--dest = *--src;
-      state->x.next = dest;
-   }
-   state->x.have++;
-   state->x.next--;
-   state->x.next[0] = c;
-   state->x.pos--;
-   state->past = 0;
-   return c;
-}
-
-/* -- see zlib.h -- */
-char * ZEXPORT gzgets(gzFile file, char *buf, int len)
-{
-   unsigned left, n;
-   char *str;
-   unsigned char *eol;
-   gz_statep state;
-
-   /* check parameters and get internal structure */
-   if (file == NULL || buf == NULL || len < 1)
-      return NULL;
-   state = (gz_statep)file;
-
-   /* check that we're reading and that there's no (serious) error */
-   if (state->mode != GZ_READ ||
-         (state->err != Z_OK && state->err != Z_BUF_ERROR))
-      return NULL;
-
-   /* process a skip request */
-   if (state->seek) {
-      state->seek = 0;
-      if (gz_skip(state, state->skip) == -1)
-         return NULL;
-   }
-
-   /* copy output bytes up to new line or len - 1, whichever comes first --
-      append a terminating zero to the string (we don't check for a zero in
-      the contents, let the user worry about that) */
-   str = buf;
-   left = (unsigned)len - 1;
-   if (left) do {
-      /* assure that something is in the output buffer */
-      if (state->x.have == 0 && gz_fetch(state) == -1)
-         return NULL;                /* error */
-      if (state->x.have == 0) {       /* end of file */
-         state->past = 1;            /* read past end */
-         break;                      /* return what we have */
-      }
-
-      /* look for end-of-line in current output buffer */
-      n = state->x.have > left ? left : state->x.have;
-      eol = (unsigned char *)memchr(state->x.next, '\n', n);
-      if (eol != NULL)
-         n = (unsigned)(eol - state->x.next) + 1;
-
-      /* copy through end-of-line, or remainder if not found */
-      memcpy(buf, state->x.next, n);
-      state->x.have -= n;
-      state->x.next += n;
-      state->x.pos += n;
-      left -= n;
-      buf += n;
-   } while (left && eol == NULL);
-
-   /* return terminated string, or if nothing, end of file */
-   if (buf == str)
-      return NULL;
-   buf[0] = 0;
-   return str;
-}
-
-/* -- see zlib.h -- */
-int ZEXPORT gzdirect(gzFile file)
-{
-   gz_statep state;
-
-   /* get internal structure */
-   if (file == NULL)
-      return 0;
-   state = (gz_statep)file;
-
-   /* if the state is not known, but we can find out, then do so (this is
-      mainly for right after a gzopen() or gzdopen()) */
-   if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0)
-      (void)gz_look(state);
-
-   /* return 1 if transparent, 0 if processing a gzip stream */
-   return state->direct;
-}
-
-/* -- see zlib.h -- */
-int gzclose_r(gzFile file)
-{
-   int ret, err;
-   gz_statep state;
-
-   /* get internal structure */
-   if (file == NULL)
-      return Z_STREAM_ERROR;
-   state = (gz_statep)file;
-
-   /* check that we're reading */
-   if (state->mode != GZ_READ)
-      return Z_STREAM_ERROR;
-
-   /* free memory and close file */
-   if (state->size) {
-      inflateEnd(&(state->strm));
-      free(state->out);
-      free(state->in);
-   }
-   err = state->err == Z_BUF_ERROR ? Z_BUF_ERROR : Z_OK;
-   gz_error(state, Z_OK, NULL);
-   free(state->path);
-   ret = close(state->fd);
-   free(state);
-   return ret ? Z_ERRNO : err;
-}
diff --git a/deps/zlib/gzwrite.c b/deps/zlib/gzwrite.c
deleted file mode 100644 (file)
index 61b217e..0000000
+++ /dev/null
@@ -1,557 +0,0 @@
-/* gzwrite.c -- zlib functions for writing gzip files
- * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#include "gzguts.h"
-
-/* Local functions */
-local int gz_init OF((gz_statep));
-local int gz_comp OF((gz_statep, int));
-local int gz_zero OF((gz_statep, z_off64_t));
-
-int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va);
-
-/* Initialize state for writing a gzip file.  Mark initialization by setting
-   state->size to non-zero.  Return -1 on failure or 0 on success. */
-local int gz_init(gz_statep state)
-{
-    int ret;
-    z_streamp strm = &(state->strm);
-
-    /* allocate input buffer */
-    state->in = (unsigned char *)malloc(state->want);
-    if (state->in == NULL) {
-        gz_error(state, Z_MEM_ERROR, "out of memory");
-        return -1;
-    }
-
-    /* only need output buffer and deflate state if compressing */
-    if (!state->direct) {
-        /* allocate output buffer */
-        state->out = (unsigned char *)malloc(state->want);
-        if (state->out == NULL) {
-            free(state->in);
-            gz_error(state, Z_MEM_ERROR, "out of memory");
-            return -1;
-        }
-
-        /* allocate deflate memory, set up for gzip compression */
-        strm->zalloc = Z_NULL;
-        strm->zfree = Z_NULL;
-        strm->opaque = Z_NULL;
-        ret = deflateInit2(strm, state->level, Z_DEFLATED,
-                           MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy);
-        if (ret != Z_OK) {
-            free(state->out);
-            free(state->in);
-            gz_error(state, Z_MEM_ERROR, "out of memory");
-            return -1;
-        }
-    }
-
-    /* mark state as initialized */
-    state->size = state->want;
-
-    /* initialize write buffer if compressing */
-    if (!state->direct) {
-        strm->avail_out = state->size;
-        strm->next_out = state->out;
-        state->x.next = strm->next_out;
-    }
-    return 0;
-}
-
-/* Compress whatever is at avail_in and next_in and write to the output file.
-   Return -1 if there is an error writing to the output file, otherwise 0.
-   flush is assumed to be a valid deflate() flush value.  If flush is Z_FINISH,
-   then the deflate() state is reset to start a new gzip stream.  If gz->direct
-   is true, then simply write to the output file without compressing, and
-   ignore flush. */
-local int gz_comp(gz_statep state, int flush)
-{
-    int ret, got;
-    unsigned have;
-    z_streamp strm = &(state->strm);
-
-    /* allocate memory if this is the first time through */
-    if (state->size == 0 && gz_init(state) == -1)
-        return -1;
-
-    /* write directly if requested */
-    if (state->direct) {
-        got = write(state->fd, strm->next_in, strm->avail_in);
-        if (got < 0 || (unsigned)got != strm->avail_in) {
-            gz_error(state, Z_ERRNO, zstrerror());
-            return -1;
-        }
-        strm->avail_in = 0;
-        return 0;
-    }
-
-    /* run deflate() on provided input until it produces no more output */
-    ret = Z_OK;
-    do {
-        /* write out current buffer contents if full, or if flushing, but if
-           doing Z_FINISH then don't write until we get to Z_STREAM_END */
-        if (strm->avail_out == 0 || (flush != Z_NO_FLUSH &&
-            (flush != Z_FINISH || ret == Z_STREAM_END))) {
-            have = (unsigned)(strm->next_out - state->x.next);
-            if (have && ((got = write(state->fd, state->x.next, have)) < 0 ||
-                         (unsigned)got != have)) {
-                gz_error(state, Z_ERRNO, zstrerror());
-                return -1;
-            }
-            if (strm->avail_out == 0) {
-                strm->avail_out = state->size;
-                strm->next_out = state->out;
-            }
-            state->x.next = strm->next_out;
-        }
-
-        /* compress */
-        have = strm->avail_out;
-        ret = deflate(strm, flush);
-        if (ret == Z_STREAM_ERROR) {
-            gz_error(state, Z_STREAM_ERROR,
-                      "internal error: deflate stream corrupt");
-            return -1;
-        }
-        have -= strm->avail_out;
-    } while (have);
-
-    /* if that completed a deflate stream, allow another to start */
-    if (flush == Z_FINISH)
-        deflateReset(strm);
-
-    /* all done, no errors */
-    return 0;
-}
-
-/* Compress len zeros to output.  Return -1 on error, 0 on success. */
-local int gz_zero(gz_statep state, z_off64_t len)
-{
-    int first;
-    unsigned n;
-    z_streamp strm = &(state->strm);
-
-    /* consume whatever's left in the input buffer */
-    if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
-        return -1;
-
-    /* compress len zeros (len guaranteed > 0) */
-    first = 1;
-    while (len) {
-        n = GT_OFF(state->size) || (z_off64_t)state->size > len ?
-            (unsigned)len : state->size;
-        if (first) {
-            memset(state->in, 0, n);
-            first = 0;
-        }
-        strm->avail_in = n;
-        strm->next_in = state->in;
-        state->x.pos += n;
-        if (gz_comp(state, Z_NO_FLUSH) == -1)
-            return -1;
-        len -= n;
-    }
-    return 0;
-}
-
-/* -- see zlib.h -- */
-int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len)
-{
-    unsigned put = len;
-    gz_statep state;
-    z_streamp strm;
-
-    /* get internal structure */
-    if (file == NULL)
-        return 0;
-    state = (gz_statep)file;
-    strm = &(state->strm);
-
-    /* check that we're writing and that there's no error */
-    if (state->mode != GZ_WRITE || state->err != Z_OK)
-        return 0;
-
-    /* since an int is returned, make sure len fits in one, otherwise return
-       with an error (this avoids the flaw in the interface) */
-    if ((int)len < 0) {
-        gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
-        return 0;
-    }
-
-    /* if len is zero, avoid unnecessary operations */
-    if (len == 0)
-        return 0;
-
-    /* allocate memory if this is the first time through */
-    if (state->size == 0 && gz_init(state) == -1)
-        return 0;
-
-    /* check for seek request */
-    if (state->seek) {
-        state->seek = 0;
-        if (gz_zero(state, state->skip) == -1)
-            return 0;
-    }
-
-    /* for small len, copy to input buffer, otherwise compress directly */
-    if (len < state->size) {
-        /* copy to input buffer, compress when full */
-        do {
-            unsigned have, copy;
-
-            if (strm->avail_in == 0)
-                strm->next_in = state->in;
-            have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
-            copy = state->size - have;
-            if (copy > len)
-                copy = len;
-            memcpy(state->in + have, buf, copy);
-            strm->avail_in += copy;
-            state->x.pos += copy;
-            buf = (const char *)buf + copy;
-            len -= copy;
-            if (len && gz_comp(state, Z_NO_FLUSH) == -1)
-                return 0;
-        } while (len);
-    }
-    else {
-        /* consume whatever's left in the input buffer */
-        if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
-            return 0;
-
-        /* directly compress user buffer to file */
-        strm->avail_in = len;
-        strm->next_in = (Bytef *)buf;
-        state->x.pos += len;
-        if (gz_comp(state, Z_NO_FLUSH) == -1)
-            return 0;
-    }
-
-    /* input was all buffered or compressed (put will fit in int) */
-    return (int)put;
-}
-
-/* -- see zlib.h -- */
-int ZEXPORT gzputc(gzFile file, int c)
-{
-    unsigned have;
-    unsigned char buf[1];
-    gz_statep state;
-    z_streamp strm;
-
-    /* get internal structure */
-    if (file == NULL)
-        return -1;
-    state = (gz_statep)file;
-    strm = &(state->strm);
-
-    /* check that we're writing and that there's no error */
-    if (state->mode != GZ_WRITE || state->err != Z_OK)
-        return -1;
-
-    /* check for seek request */
-    if (state->seek) {
-        state->seek = 0;
-        if (gz_zero(state, state->skip) == -1)
-            return -1;
-    }
-
-    /* try writing to input buffer for speed (state->size == 0 if buffer not
-       initialized) */
-    if (state->size) {
-        if (strm->avail_in == 0)
-            strm->next_in = state->in;
-        have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
-        if (have < state->size) {
-            state->in[have] = c;
-            strm->avail_in++;
-            state->x.pos++;
-            return c & 0xff;
-        }
-    }
-
-    /* no room in buffer or not initialized, use gz_write() */
-    buf[0] = c;
-    if (gzwrite(file, buf, 1) != 1)
-        return -1;
-    return c & 0xff;
-}
-
-/* -- see zlib.h -- */
-int ZEXPORT gzputs(gzFile file, const char *str)
-{
-    int ret;
-    unsigned len;
-
-    /* write string */
-    len = (unsigned)strlen(str);
-    ret = gzwrite(file, str, len);
-    return ret == 0 && len != 0 ? -1 : ret;
-}
-
-#if defined(STDC) || defined(Z_HAVE_STDARG_H)
-#include <stdarg.h>
-
-/* -- see zlib.h -- */
-int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
-{
-    int size, len;
-    gz_statep state;
-    z_streamp strm;
-
-    /* get internal structure */
-    if (file == NULL)
-        return -1;
-    state = (gz_statep)file;
-    strm = &(state->strm);
-
-    /* check that we're writing and that there's no error */
-    if (state->mode != GZ_WRITE || state->err != Z_OK)
-        return 0;
-
-    /* make sure we have some buffer space */
-    if (state->size == 0 && gz_init(state) == -1)
-        return 0;
-
-    /* check for seek request */
-    if (state->seek) {
-        state->seek = 0;
-        if (gz_zero(state, state->skip) == -1)
-            return 0;
-    }
-
-    /* consume whatever's left in the input buffer */
-    if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
-        return 0;
-
-    /* do the printf() into the input buffer, put length in len */
-    size = (int)(state->size);
-    state->in[size - 1] = 0;
-#ifdef NO_vsnprintf
-#  ifdef HAS_vsprintf_void
-    (void)vsprintf((char *)(state->in), format, va);
-    for (len = 0; len < size; len++)
-        if (state->in[len] == 0) break;
-#  else
-    len = vsprintf((char *)(state->in), format, va);
-#  endif
-#else
-#  ifdef HAS_vsnprintf_void
-    (void)vsnprintf((char *)(state->in), size, format, va);
-    len = strlen((char *)(state->in));
-#  else
-    len = vsnprintf((char *)(state->in), size, format, va);
-#  endif
-#endif
-
-    /* check that printf() results fit in buffer */
-    if (len <= 0 || len >= (int)size || state->in[size - 1] != 0)
-        return 0;
-
-    /* update buffer and position, defer compression until needed */
-    strm->avail_in = (unsigned)len;
-    strm->next_in = state->in;
-    state->x.pos += len;
-    return len;
-}
-
-int ZEXPORTVA gzprintf(gzFile file, const char *format, ...)
-{
-    va_list va;
-    int ret;
-
-    va_start(va, format);
-    ret = gzvprintf(file, format, va);
-    va_end(va);
-    return ret;
-}
-
-#else /* !STDC && !Z_HAVE_STDARG_H */
-
-/* -- see zlib.h -- */
-int ZEXPORTVA gzprintf (gzFile file, const char *format, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10,
-                       int a11, int a12, int a13, int a14, int a15, int a16, int a17, int a18, int a19, int a20)
-{
-    int size, len;
-    gz_statep state;
-    z_streamp strm;
-
-    /* get internal structure */
-    if (file == NULL)
-        return -1;
-    state = (gz_statep)file;
-    strm = &(state->strm);
-
-    /* check that can really pass pointer in ints */
-    if (sizeof(int) != sizeof(void *))
-        return 0;
-
-    /* check that we're writing and that there's no error */
-    if (state->mode != GZ_WRITE || state->err != Z_OK)
-        return 0;
-
-    /* make sure we have some buffer space */
-    if (state->size == 0 && gz_init(state) == -1)
-        return 0;
-
-    /* check for seek request */
-    if (state->seek) {
-        state->seek = 0;
-        if (gz_zero(state, state->skip) == -1)
-            return 0;
-    }
-
-    /* consume whatever's left in the input buffer */
-    if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
-        return 0;
-
-    /* do the printf() into the input buffer, put length in len */
-    size = (int)(state->size);
-    state->in[size - 1] = 0;
-#ifdef NO_snprintf
-#  ifdef HAS_sprintf_void
-    sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8,
-            a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
-    for (len = 0; len < size; len++)
-        if (state->in[len] == 0) break;
-#  else
-    len = sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8,
-                  a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
-#  endif
-#else
-#  ifdef HAS_snprintf_void
-    snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6, a7, a8,
-             a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
-    len = strlen((char *)(state->in));
-#  else
-    len = snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6,
-                   a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18,
-                   a19, a20);
-#  endif
-#endif
-
-    /* check that printf() results fit in buffer */
-    if (len <= 0 || len >= (int)size || state->in[size - 1] != 0)
-        return 0;
-
-    /* update buffer and position, defer compression until needed */
-    strm->avail_in = (unsigned)len;
-    strm->next_in = state->in;
-    state->x.pos += len;
-    return len;
-}
-
-#endif
-
-/* -- see zlib.h -- */
-int ZEXPORT gzflush(gzFile file, int flush)
-{
-    gz_statep state;
-
-    /* get internal structure */
-    if (file == NULL)
-        return -1;
-    state = (gz_statep)file;
-
-    /* check that we're writing and that there's no error */
-    if (state->mode != GZ_WRITE || state->err != Z_OK)
-        return Z_STREAM_ERROR;
-
-    /* check flush parameter */
-    if (flush < 0 || flush > Z_FINISH)
-        return Z_STREAM_ERROR;
-
-    /* check for seek request */
-    if (state->seek) {
-        state->seek = 0;
-        if (gz_zero(state, state->skip) == -1)
-            return -1;
-    }
-
-    /* compress remaining data with requested flush */
-    gz_comp(state, flush);
-    return state->err;
-}
-
-/* -- see zlib.h -- */
-int ZEXPORT gzsetparams(gzFile file, int level, int strategy)
-{
-    gz_statep state;
-    z_streamp strm;
-
-    /* get internal structure */
-    if (file == NULL)
-        return Z_STREAM_ERROR;
-    state = (gz_statep)file;
-    strm = &(state->strm);
-
-    /* check that we're writing and that there's no error */
-    if (state->mode != GZ_WRITE || state->err != Z_OK)
-        return Z_STREAM_ERROR;
-
-    /* if no change is requested, then do nothing */
-    if (level == state->level && strategy == state->strategy)
-        return Z_OK;
-
-    /* check for seek request */
-    if (state->seek) {
-        state->seek = 0;
-        if (gz_zero(state, state->skip) == -1)
-            return -1;
-    }
-
-    /* change compression parameters for subsequent input */
-    if (state->size) {
-        /* flush previous input with previous parameters before changing */
-        if (strm->avail_in && gz_comp(state, Z_PARTIAL_FLUSH) == -1)
-            return state->err;
-        deflateParams(strm, level, strategy);
-    }
-    state->level = level;
-    state->strategy = strategy;
-    return Z_OK;
-}
-
-/* -- see zlib.h -- */
-int gzclose_w(gzFile file)
-{
-    int ret = Z_OK;
-    gz_statep state;
-
-    /* get internal structure */
-    if (file == NULL)
-        return Z_STREAM_ERROR;
-    state = (gz_statep)file;
-
-    /* check that we're writing */
-    if (state->mode != GZ_WRITE)
-        return Z_STREAM_ERROR;
-
-    /* check for seek request */
-    if (state->seek) {
-        state->seek = 0;
-        if (gz_zero(state, state->skip) == -1)
-            ret = state->err;
-    }
-
-    /* flush, free memory, and close file */
-    if (gz_comp(state, Z_FINISH) == -1)
-        ret = state->err;
-    if (state->size) {
-        if (!state->direct) {
-            (void)deflateEnd(&(state->strm));
-            free(state->out);
-        }
-        free(state->in);
-    }
-    gz_error(state, Z_OK, NULL);
-    free(state->path);
-    if (close(state->fd) == -1)
-        ret = Z_ERRNO;
-    free(state);
-    return ret;
-}
diff --git a/deps/zlib/infback.c b/deps/zlib/infback.c
deleted file mode 100644 (file)
index 7206cde..0000000
+++ /dev/null
@@ -1,628 +0,0 @@
-/* infback.c -- inflate using a call-back interface
- * Copyright (C) 1995-2011 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
-   This code is largely copied from inflate.c.  Normally either infback.o or
-   inflate.o would be linked into an application--not both.  The interface
-   with inffast.c is retained so that optimized assembler-coded versions of
-   inflate_fast() can be used with either inflate.c or infback.c.
-   */
-
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-/* function prototypes */
-local void fixedtables OF((struct inflate_state FAR *state));
-
-/*
-   strm provides memory allocation functions in zalloc and zfree, or
-   Z_NULL to use the library memory allocation functions.
-
-   windowBits is in the range 8..15, and window is a user-supplied
-   window and output buffer that is 2**windowBits bytes.
-   */
-int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, unsigned char FAR *window, const char *version, int stream_size)
-{
-   struct inflate_state FAR *state;
-
-   if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
-         stream_size != (int)(sizeof(z_stream)))
-      return Z_VERSION_ERROR;
-   if (strm == Z_NULL || window == Z_NULL ||
-         windowBits < 8 || windowBits > 15)
-      return Z_STREAM_ERROR;
-   strm->msg = Z_NULL;                 /* in case we return an error */
-   if (strm->zalloc == (alloc_func)0) {
-#ifdef Z_SOLO
-      return Z_STREAM_ERROR;
-#else
-      strm->zalloc = zcalloc;
-      strm->opaque = (voidpf)0;
-#endif
-   }
-   if (strm->zfree == Z_NULL)
-#ifdef Z_SOLO
-      return Z_STREAM_ERROR;
-#else
-   strm->zfree = zcfree;
-#endif
-   state = (struct inflate_state FAR *)ZALLOC(strm, 1,
-         sizeof(struct inflate_state));
-   if (state == Z_NULL) return Z_MEM_ERROR;
-   Tracev((stderr, "inflate: allocated\n"));
-   strm->state = (struct internal_state FAR *)state;
-   state->dmax = 32768U;
-   state->wbits = windowBits;
-   state->wsize = 1U << windowBits;
-   state->window = window;
-   state->wnext = 0;
-   state->whave = 0;
-   return Z_OK;
-}
-
-/*
-   Return state with length and distance decoding tables and index sizes set to
-   fixed code decoding.  Normally this returns fixed tables from inffixed.h.
-   If BUILDFIXED is defined, then instead this routine builds the tables the
-   first time it's called, and returns those tables the first time and
-   thereafter.  This reduces the size of the code by about 2K bytes, in
-   exchange for a little execution time.  However, BUILDFIXED should not be
-   used for threaded applications, since the rewriting of the tables and virgin
-   may not be thread-safe.
-   */
-local void fixedtables(struct inflate_state FAR *state)
-{
-#ifdef BUILDFIXED
-   static int virgin = 1;
-   static code *lenfix, *distfix;
-   static code fixed[544];
-
-   /* build fixed huffman tables if first call (may not be thread safe) */
-   if (virgin) {
-      unsigned sym, bits;
-      static code *next;
-
-      /* literal/length table */
-      sym = 0;
-      while (sym < 144) state->lens[sym++] = 8;
-      while (sym < 256) state->lens[sym++] = 9;
-      while (sym < 280) state->lens[sym++] = 7;
-      while (sym < 288) state->lens[sym++] = 8;
-      next = fixed;
-      lenfix = next;
-      bits = 9;
-      inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
-
-      /* distance table */
-      sym = 0;
-      while (sym < 32) state->lens[sym++] = 5;
-      distfix = next;
-      bits = 5;
-      inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
-
-      /* do this just once */
-      virgin = 0;
-   }
-#else /* !BUILDFIXED */
-#   include "inffixed.h"
-#endif /* BUILDFIXED */
-   state->lencode = lenfix;
-   state->lenbits = 9;
-   state->distcode = distfix;
-   state->distbits = 5;
-}
-
-/* Macros for inflateBack(): */
-
-/* Load returned state from inflate_fast() */
-#define LOAD() \
-   do { \
-      put = strm->next_out; \
-      left = strm->avail_out; \
-      next = strm->next_in; \
-      have = strm->avail_in; \
-      hold = state->hold; \
-      bits = state->bits; \
-   } while (0)
-
-/* Set state from registers for inflate_fast() */
-#define RESTORE() \
-   do { \
-      strm->next_out = put; \
-      strm->avail_out = left; \
-      strm->next_in = next; \
-      strm->avail_in = have; \
-      state->hold = hold; \
-      state->bits = bits; \
-   } while (0)
-
-/* Clear the input bit accumulator */
-#define INITBITS() \
-   do { \
-      hold = 0; \
-      bits = 0; \
-   } while (0)
-
-/* Assure that some input is available.  If input is requested, but denied,
-   then return a Z_BUF_ERROR from inflateBack(). */
-#define PULL() \
-   do { \
-      if (have == 0) { \
-         have = in(in_desc, &next); \
-         if (have == 0) { \
-            next = Z_NULL; \
-            ret = Z_BUF_ERROR; \
-            goto inf_leave; \
-         } \
-      } \
-   } while (0)
-
-/* Get a byte of input into the bit accumulator, or return from inflateBack()
-   with an error if there is no input available. */
-#define PULLBYTE() \
-   do { \
-      PULL(); \
-      have--; \
-      hold += (unsigned long)(*next++) << bits; \
-      bits += 8; \
-   } while (0)
-
-/* Assure that there are at least n bits in the bit accumulator.  If there is
-   not enough available input to do that, then return from inflateBack() with
-   an error. */
-#define NEEDBITS(n) \
-   do { \
-      while (bits < (unsigned)(n)) \
-      PULLBYTE(); \
-   } while (0)
-
-/* Return the low n bits of the bit accumulator (n < 16) */
-#define BITS(n) \
-   ((unsigned)hold & ((1U << (n)) - 1))
-
-/* Remove n bits from the bit accumulator */
-#define DROPBITS(n) \
-   do { \
-      hold >>= (n); \
-      bits -= (unsigned)(n); \
-   } while (0)
-
-/* Remove zero to seven bits as needed to go to a byte boundary */
-#define BYTEBITS() \
-   do { \
-      hold >>= bits & 7; \
-      bits -= bits & 7; \
-   } while (0)
-
-/* Assure that some output space is available, by writing out the window
-   if it's full.  If the write fails, return from inflateBack() with a
-   Z_BUF_ERROR. */
-#define ROOM() \
-   do { \
-      if (left == 0) { \
-         put = state->window; \
-         left = state->wsize; \
-         state->whave = left; \
-         if (out(out_desc, put, left)) { \
-            ret = Z_BUF_ERROR; \
-            goto inf_leave; \
-         } \
-      } \
-   } while (0)
-
-/*
-   strm provides the memory allocation functions and window buffer on input,
-   and provides information on the unused input on return.  For Z_DATA_ERROR
-   returns, strm will also provide an error message.
-
-   in() and out() are the call-back input and output functions.  When
-   inflateBack() needs more input, it calls in().  When inflateBack() has
-   filled the window with output, or when it completes with data in the
-   window, it calls out() to write out the data.  The application must not
-   change the provided input until in() is called again or inflateBack()
-   returns.  The application must not change the window/output buffer until
-   inflateBack() returns.
-
-   in() and out() are called with a descriptor parameter provided in the
-   inflateBack() call.  This parameter can be a structure that provides the
-   information required to do the read or write, as well as accumulated
-   information on the input and output such as totals and check values.
-
-   in() should return zero on failure.  out() should return non-zero on
-   failure.  If either in() or out() fails, than inflateBack() returns a
-   Z_BUF_ERROR.  strm->next_in can be checked for Z_NULL to see whether it
-   was in() or out() that caused in the error.  Otherwise,  inflateBack()
-   returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format
-   error, or Z_MEM_ERROR if it could not allocate memory for the state.
-   inflateBack() can also return Z_STREAM_ERROR if the input parameters
-   are not correct, i.e. strm is Z_NULL or the state was not initialized.
-   */
-int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc, out_func out, void FAR *out_desc)
-{
-   struct inflate_state FAR *state;
-   z_const unsigned char FAR *next;    /* next input */
-   unsigned char FAR *put;     /* next output */
-   unsigned have, left;        /* available input and output */
-   unsigned long hold;         /* bit buffer */
-   unsigned bits;              /* bits in bit buffer */
-   unsigned copy;              /* number of stored or match bytes to copy */
-   unsigned char FAR *from;    /* where to copy match bytes from */
-   code here;                  /* current decoding table entry */
-   code last;                  /* parent table entry */
-   unsigned len;               /* length to copy for repeats, bits to drop */
-   int ret;                    /* return code */
-   static const unsigned short order[19] = /* permutation of code lengths */
-   {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-
-   /* Check that the strm exists and that the state was initialized */
-   if (strm == Z_NULL || strm->state == Z_NULL)
-      return Z_STREAM_ERROR;
-   state = (struct inflate_state FAR *)strm->state;
-
-   /* Reset the state */
-   strm->msg = Z_NULL;
-   state->mode = TYPE;
-   state->last = 0;
-   state->whave = 0;
-   next = strm->next_in;
-   have = next != Z_NULL ? strm->avail_in : 0;
-   hold = 0;
-   bits = 0;
-   put = state->window;
-   left = state->wsize;
-
-   /* Inflate until end of block marked as last */
-   for (;;)
-      switch (state->mode) {
-         case TYPE:
-            /* determine and dispatch block type */
-            if (state->last) {
-               BYTEBITS();
-               state->mode = DONE;
-               break;
-            }
-            NEEDBITS(3);
-            state->last = BITS(1);
-            DROPBITS(1);
-            switch (BITS(2)) {
-               case 0:                             /* stored block */
-                  Tracev((stderr, "inflate:     stored block%s\n",
-                           state->last ? " (last)" : ""));
-                  state->mode = STORED;
-                  break;
-               case 1:                             /* fixed block */
-                  fixedtables(state);
-                  Tracev((stderr, "inflate:     fixed codes block%s\n",
-                           state->last ? " (last)" : ""));
-                  state->mode = LEN;              /* decode codes */
-                  break;
-               case 2:                             /* dynamic block */
-                  Tracev((stderr, "inflate:     dynamic codes block%s\n",
-                           state->last ? " (last)" : ""));
-                  state->mode = TABLE;
-                  break;
-               case 3:
-                  strm->msg = (char *)"invalid block type";
-                  state->mode = BAD;
-            }
-            DROPBITS(2);
-            break;
-
-         case STORED:
-            /* get and verify stored block length */
-            BYTEBITS();                         /* go to byte boundary */
-            NEEDBITS(32);
-            if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
-               strm->msg = (char *)"invalid stored block lengths";
-               state->mode = BAD;
-               break;
-            }
-            state->length = (unsigned)hold & 0xffff;
-            Tracev((stderr, "inflate:       stored length %u\n",
-                     state->length));
-            INITBITS();
-
-            /* copy stored block from input to output */
-            while (state->length != 0) {
-               copy = state->length;
-               PULL();
-               ROOM();
-               if (copy > have) copy = have;
-               if (copy > left) copy = left;
-               zmemcpy(put, next, copy);
-               have -= copy;
-               next += copy;
-               left -= copy;
-               put += copy;
-               state->length -= copy;
-            }
-            Tracev((stderr, "inflate:       stored end\n"));
-            state->mode = TYPE;
-            break;
-
-         case TABLE:
-            /* get dynamic table entries descriptor */
-            NEEDBITS(14);
-            state->nlen = BITS(5) + 257;
-            DROPBITS(5);
-            state->ndist = BITS(5) + 1;
-            DROPBITS(5);
-            state->ncode = BITS(4) + 4;
-            DROPBITS(4);
-#ifndef PKZIP_BUG_WORKAROUND
-            if (state->nlen > 286 || state->ndist > 30) {
-               strm->msg = (char *)"too many length or distance symbols";
-               state->mode = BAD;
-               break;
-            }
-#endif
-            Tracev((stderr, "inflate:       table sizes ok\n"));
-
-            /* get code length code lengths (not a typo) */
-            state->have = 0;
-            while (state->have < state->ncode) {
-               NEEDBITS(3);
-               state->lens[order[state->have++]] = (unsigned short)BITS(3);
-               DROPBITS(3);
-            }
-            while (state->have < 19)
-               state->lens[order[state->have++]] = 0;
-            state->next = state->codes;
-            state->lencode = (code const FAR *)(state->next);
-            state->lenbits = 7;
-            ret = inflate_table(CODES, state->lens, 19, &(state->next),
-                  &(state->lenbits), state->work);
-            if (ret) {
-               strm->msg = (char *)"invalid code lengths set";
-               state->mode = BAD;
-               break;
-            }
-            Tracev((stderr, "inflate:       code lengths ok\n"));
-
-            /* get length and distance code code lengths */
-            state->have = 0;
-            while (state->have < state->nlen + state->ndist) {
-               for (;;) {
-                  here = state->lencode[BITS(state->lenbits)];
-                  if ((unsigned)(here.bits) <= bits) break;
-                  PULLBYTE();
-               }
-               if (here.val < 16) {
-                  DROPBITS(here.bits);
-                  state->lens[state->have++] = here.val;
-               }
-               else {
-                  if (here.val == 16) {
-                     NEEDBITS(here.bits + 2);
-                     DROPBITS(here.bits);
-                     if (state->have == 0) {
-                        strm->msg = (char *)"invalid bit length repeat";
-                        state->mode = BAD;
-                        break;
-                     }
-                     len = (unsigned)(state->lens[state->have - 1]);
-                     copy = 3 + BITS(2);
-                     DROPBITS(2);
-                  }
-                  else if (here.val == 17) {
-                     NEEDBITS(here.bits + 3);
-                     DROPBITS(here.bits);
-                     len = 0;
-                     copy = 3 + BITS(3);
-                     DROPBITS(3);
-                  }
-                  else {
-                     NEEDBITS(here.bits + 7);
-                     DROPBITS(here.bits);
-                     len = 0;
-                     copy = 11 + BITS(7);
-                     DROPBITS(7);
-                  }
-                  if (state->have + copy > state->nlen + state->ndist) {
-                     strm->msg = (char *)"invalid bit length repeat";
-                     state->mode = BAD;
-                     break;
-                  }
-                  while (copy--)
-                     state->lens[state->have++] = (unsigned short)len;
-               }
-            }
-
-            /* handle error breaks in while */
-            if (state->mode == BAD) break;
-
-            /* check for end-of-block code (better have one) */
-            if (state->lens[256] == 0) {
-               strm->msg = (char *)"invalid code -- missing end-of-block";
-               state->mode = BAD;
-               break;
-            }
-
-            /* build code tables -- note: do not change the lenbits or distbits
-               values here (9 and 6) without reading the comments in inftrees.h
-               concerning the ENOUGH constants, which depend on those values */
-            state->next = state->codes;
-            state->lencode = (code const FAR *)(state->next);
-            state->lenbits = 9;
-            ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
-                  &(state->lenbits), state->work);
-            if (ret) {
-               strm->msg = (char *)"invalid literal/lengths set";
-               state->mode = BAD;
-               break;
-            }
-            state->distcode = (code const FAR *)(state->next);
-            state->distbits = 6;
-            ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
-                  &(state->next), &(state->distbits), state->work);
-            if (ret) {
-               strm->msg = (char *)"invalid distances set";
-               state->mode = BAD;
-               break;
-            }
-            Tracev((stderr, "inflate:       codes ok\n"));
-            state->mode = LEN;
-
-         case LEN:
-            /* use inflate_fast() if we have enough input and output */
-            if (have >= 6 && left >= 258) {
-               RESTORE();
-               if (state->whave < state->wsize)
-                  state->whave = state->wsize - left;
-               inflate_fast(strm, state->wsize);
-               LOAD();
-               break;
-            }
-
-            /* get a literal, length, or end-of-block code */
-            for (;;) {
-               here = state->lencode[BITS(state->lenbits)];
-               if ((unsigned)(here.bits) <= bits) break;
-               PULLBYTE();
-            }
-            if (here.op && (here.op & 0xf0) == 0) {
-               last = here;
-               for (;;) {
-                  here = state->lencode[last.val +
-                     (BITS(last.bits + last.op) >> last.bits)];
-                  if ((unsigned)(last.bits + here.bits) <= bits) break;
-                  PULLBYTE();
-               }
-               DROPBITS(last.bits);
-            }
-            DROPBITS(here.bits);
-            state->length = (unsigned)here.val;
-
-            /* process literal */
-            if (here.op == 0) {
-               Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
-                        "inflate:         literal '%c'\n" :
-                        "inflate:         literal 0x%02x\n", here.val));
-               ROOM();
-               *put++ = (unsigned char)(state->length);
-               left--;
-               state->mode = LEN;
-               break;
-            }
-
-            /* process end of block */
-            if (here.op & 32) {
-               Tracevv((stderr, "inflate:         end of block\n"));
-               state->mode = TYPE;
-               break;
-            }
-
-            /* invalid code */
-            if (here.op & 64) {
-               strm->msg = (char *)"invalid literal/length code";
-               state->mode = BAD;
-               break;
-            }
-
-            /* length code -- get extra bits, if any */
-            state->extra = (unsigned)(here.op) & 15;
-            if (state->extra != 0) {
-               NEEDBITS(state->extra);
-               state->length += BITS(state->extra);
-               DROPBITS(state->extra);
-            }
-            Tracevv((stderr, "inflate:         length %u\n", state->length));
-
-            /* get distance code */
-            for (;;) {
-               here = state->distcode[BITS(state->distbits)];
-               if ((unsigned)(here.bits) <= bits) break;
-               PULLBYTE();
-            }
-            if ((here.op & 0xf0) == 0) {
-               last = here;
-               for (;;) {
-                  here = state->distcode[last.val +
-                     (BITS(last.bits + last.op) >> last.bits)];
-                  if ((unsigned)(last.bits + here.bits) <= bits) break;
-                  PULLBYTE();
-               }
-               DROPBITS(last.bits);
-            }
-            DROPBITS(here.bits);
-            if (here.op & 64) {
-               strm->msg = (char *)"invalid distance code";
-               state->mode = BAD;
-               break;
-            }
-            state->offset = (unsigned)here.val;
-
-            /* get distance extra bits, if any */
-            state->extra = (unsigned)(here.op) & 15;
-            if (state->extra != 0) {
-               NEEDBITS(state->extra);
-               state->offset += BITS(state->extra);
-               DROPBITS(state->extra);
-            }
-            if (state->offset > state->wsize - (state->whave < state->wsize ?
-                     left : 0)) {
-               strm->msg = (char *)"invalid distance too far back";
-               state->mode = BAD;
-               break;
-            }
-            Tracevv((stderr, "inflate:         distance %u\n", state->offset));
-
-            /* copy match from window to output */
-            do {
-               ROOM();
-               copy = state->wsize - state->offset;
-               if (copy < left) {
-                  from = put + copy;
-                  copy = left - copy;
-               }
-               else {
-                  from = put - state->offset;
-                  copy = left;
-               }
-               if (copy > state->length) copy = state->length;
-               state->length -= copy;
-               left -= copy;
-               do {
-                  *put++ = *from++;
-               } while (--copy);
-            } while (state->length != 0);
-            break;
-
-         case DONE:
-            /* inflate stream terminated properly -- write leftover output */
-            ret = Z_STREAM_END;
-            if (left < state->wsize) {
-               if (out(out_desc, state->window, state->wsize - left))
-                  ret = Z_BUF_ERROR;
-            }
-            goto inf_leave;
-
-         case BAD:
-            ret = Z_DATA_ERROR;
-            goto inf_leave;
-
-         default:                /* can't happen, but makes compilers happy */
-            ret = Z_STREAM_ERROR;
-            goto inf_leave;
-      }
-
-   /* Return unused input */
-inf_leave:
-   strm->next_in = next;
-   strm->avail_in = have;
-   return ret;
-}
-
-int ZEXPORT inflateBackEnd(z_streamp strm)
-{
-   if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == Z_NULL)
-      return Z_STREAM_ERROR;
-   ZFREE(strm, strm->state);
-   strm->state = Z_NULL;
-   Tracev((stderr, "inflate: end\n"));
-   return Z_OK;
-}
diff --git a/deps/zlib/inffast.c b/deps/zlib/inffast.c
deleted file mode 100644 (file)
index a88859f..0000000
+++ /dev/null
@@ -1,338 +0,0 @@
-/* inffast.c -- fast decoding
- * Copyright (C) 1995-2008, 2010, 2013 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-#ifndef ASMINF
-
-/* Allow machine dependent optimization for post-increment or pre-increment.
-   Based on testing to date,
-   Pre-increment preferred for:
-   - PowerPC G3 (Adler)
-   - MIPS R5000 (Randers-Pehrson)
-   Post-increment preferred for:
-   - none
-   No measurable difference:
-   - Pentium III (Anderson)
-   - M68060 (Nikl)
-   */
-#ifdef POSTINC
-#  define OFF 0
-#  define PUP(a) *(a)++
-#else
-#  define OFF 1
-#  define PUP(a) *++(a)
-#endif
-
-/*
-   Decode literal, length, and distance codes and write out the resulting
-   literal and match bytes until either not enough input or output is
-   available, an end-of-block is encountered, or a data error is encountered.
-   When large enough input and output buffers are supplied to inflate(), for
-   example, a 16K input buffer and a 64K output buffer, more than 95% of the
-   inflate execution time is spent in this routine.
-
-   Entry assumptions:
-
-   state->mode == LEN
-   strm->avail_in >= 6
-   strm->avail_out >= 258
-   start >= strm->avail_out
-   state->bits < 8
-
-   On return, state->mode is one of:
-
-   LEN -- ran out of enough output space or enough available input
-   TYPE -- reached end of block code, inflate() to interpret next block
-   BAD -- error in block data
-
-Notes:
-
-- The maximum input bits used by a length/distance pair is 15 bits for the
-length code, 5 bits for the length extra, 15 bits for the distance code,
-and 13 bits for the distance extra.  This totals 48 bits, or six bytes.
-Therefore if strm->avail_in >= 6, then there is enough input to avoid
-checking for available input while decoding.
-
-- The maximum bytes that a single length/distance pair can output is 258
-bytes, which is the maximum length that can be coded.  inflate_fast()
-requires strm->avail_out >= 258 for each loop to avoid checking for
-output space.
-*/
-void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start)
-{
-   struct inflate_state FAR *state;
-   unsigned char FAR *in;      /* local strm->next_in */
-   unsigned char FAR *last;    /* have enough input while in < last */
-   unsigned char FAR *out;     /* local strm->next_out */
-   unsigned char FAR *beg;     /* inflate()'s initial strm->next_out */
-   unsigned char FAR *end;     /* while out < end, enough space available */
-#ifdef INFLATE_STRICT
-   unsigned dmax;              /* maximum distance from zlib header */
-#endif
-   unsigned wsize;             /* window size or zero if not using window */
-   unsigned whave;             /* valid bytes in the window */
-   unsigned wnext;             /* window write index */
-   unsigned char FAR *window;  /* allocated sliding window, if wsize != 0 */
-   unsigned long hold;         /* local strm->hold */
-   unsigned bits;              /* local strm->bits */
-   code const FAR *lcode;      /* local strm->lencode */
-   code const FAR *dcode;      /* local strm->distcode */
-   unsigned lmask;             /* mask for first level of length codes */
-   unsigned dmask;             /* mask for first level of distance codes */
-   code here;                  /* retrieved table entry */
-   unsigned op;                /* code bits, operation, extra bits, or */
-   /*  window position, window bytes to copy */
-   unsigned len;               /* match length, unused bytes */
-   unsigned dist;              /* match distance */
-   unsigned char FAR *from;    /* where to copy match from */
-
-   /* copy state to local variables */
-   state = (struct inflate_state FAR *)strm->state;
-   in = strm->next_in - OFF;
-   last = in + (strm->avail_in - 5);
-   out = strm->next_out - OFF;
-   beg = out - (start - strm->avail_out);
-   end = out + (strm->avail_out - 257);
-#ifdef INFLATE_STRICT
-   dmax = state->dmax;
-#endif
-   wsize = state->wsize;
-   whave = state->whave;
-   wnext = state->wnext;
-   window = state->window;
-   hold = state->hold;
-   bits = state->bits;
-   lcode = state->lencode;
-   dcode = state->distcode;
-   lmask = (1U << state->lenbits) - 1;
-   dmask = (1U << state->distbits) - 1;
-
-   /* decode literals and length/distances until end-of-block or not enough
-      input data or output space */
-   do {
-      if (bits < 15) {
-         hold += (unsigned long)(PUP(in)) << bits;
-         bits += 8;
-         hold += (unsigned long)(PUP(in)) << bits;
-         bits += 8;
-      }
-      here = lcode[hold & lmask];
-dolen:
-      op = (unsigned)(here.bits);
-      hold >>= op;
-      bits -= op;
-      op = (unsigned)(here.op);
-      if (op == 0) {                          /* literal */
-         Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
-                  "inflate:         literal '%c'\n" :
-                  "inflate:         literal 0x%02x\n", here.val));
-         PUP(out) = (unsigned char)(here.val);
-      }
-      else if (op & 16) {                     /* length base */
-         len = (unsigned)(here.val);
-         op &= 15;                           /* number of extra bits */
-         if (op) {
-            if (bits < op) {
-               hold += (unsigned long)(PUP(in)) << bits;
-               bits += 8;
-            }
-            len += (unsigned)hold & ((1U << op) - 1);
-            hold >>= op;
-            bits -= op;
-         }
-         Tracevv((stderr, "inflate:         length %u\n", len));
-         if (bits < 15) {
-            hold += (unsigned long)(PUP(in)) << bits;
-            bits += 8;
-            hold += (unsigned long)(PUP(in)) << bits;
-            bits += 8;
-         }
-         here = dcode[hold & dmask];
-dodist:
-         op = (unsigned)(here.bits);
-         hold >>= op;
-         bits -= op;
-         op = (unsigned)(here.op);
-         if (op & 16) {                      /* distance base */
-            dist = (unsigned)(here.val);
-            op &= 15;                       /* number of extra bits */
-            if (bits < op) {
-               hold += (unsigned long)(PUP(in)) << bits;
-               bits += 8;
-               if (bits < op) {
-                  hold += (unsigned long)(PUP(in)) << bits;
-                  bits += 8;
-               }
-            }
-            dist += (unsigned)hold & ((1U << op) - 1);
-#ifdef INFLATE_STRICT
-            if (dist > dmax) {
-               strm->msg = (char *)"invalid distance too far back";
-               state->mode = BAD;
-               break;
-            }
-#endif
-            hold >>= op;
-            bits -= op;
-            Tracevv((stderr, "inflate:         distance %u\n", dist));
-            op = (unsigned)(out - beg);     /* max distance in output */
-            if (dist > op) {                /* see if copy from window */
-               op = dist - op;             /* distance back in window */
-               if (op > whave) {
-                  if (state->sane) {
-                     strm->msg =
-                        (char *)"invalid distance too far back";
-                     state->mode = BAD;
-                     break;
-                  }
-#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
-                  if (len <= op - whave) {
-                     do {
-                        PUP(out) = 0;
-                     } while (--len);
-                     continue;
-                  }
-                  len -= op - whave;
-                  do {
-                     PUP(out) = 0;
-                  } while (--op > whave);
-                  if (op == 0) {
-                     from = out - dist;
-                     do {
-                        PUP(out) = PUP(from);
-                     } while (--len);
-                     continue;
-                  }
-#endif
-               }
-               from = window - OFF;
-               if (wnext == 0) {           /* very common case */
-                  from += wsize - op;
-                  if (op < len) {         /* some from window */
-                     len -= op;
-                     do {
-                        PUP(out) = PUP(from);
-                     } while (--op);
-                     from = out - dist;  /* rest from output */
-                  }
-               }
-               else if (wnext < op) {      /* wrap around window */
-                  from += wsize + wnext - op;
-                  op -= wnext;
-                  if (op < len) {         /* some from end of window */
-                     len -= op;
-                     do {
-                        PUP(out) = PUP(from);
-                     } while (--op);
-                     from = window - OFF;
-                     if (wnext < len) {  /* some from start of window */
-                        op = wnext;
-                        len -= op;
-                        do {
-                           PUP(out) = PUP(from);
-                        } while (--op);
-                        from = out - dist;      /* rest from output */
-                     }
-                  }
-               }
-               else {                      /* contiguous in window */
-                  from += wnext - op;
-                  if (op < len) {         /* some from window */
-                     len -= op;
-                     do {
-                        PUP(out) = PUP(from);
-                     } while (--op);
-                     from = out - dist;  /* rest from output */
-                  }
-               }
-               while (len > 2) {
-                  PUP(out) = PUP(from);
-                  PUP(out) = PUP(from);
-                  PUP(out) = PUP(from);
-                  len -= 3;
-               }
-               if (len) {
-                  PUP(out) = PUP(from);
-                  if (len > 1)
-                     PUP(out) = PUP(from);
-               }
-            }
-            else {
-               from = out - dist;          /* copy direct from output */
-               do {                        /* minimum length is three */
-                  PUP(out) = PUP(from);
-                  PUP(out) = PUP(from);
-                  PUP(out) = PUP(from);
-                  len -= 3;
-               } while (len > 2);
-               if (len) {
-                  PUP(out) = PUP(from);
-                  if (len > 1)
-                     PUP(out) = PUP(from);
-               }
-            }
-         }
-         else if ((op & 64) == 0) {          /* 2nd level distance code */
-            here = dcode[here.val + (hold & ((1U << op) - 1))];
-            goto dodist;
-         }
-         else {
-            strm->msg = (char *)"invalid distance code";
-            state->mode = BAD;
-            break;
-         }
-      }
-      else if ((op & 64) == 0) {              /* 2nd level length code */
-         here = lcode[here.val + (hold & ((1U << op) - 1))];
-         goto dolen;
-      }
-      else if (op & 32) {                     /* end-of-block */
-         Tracevv((stderr, "inflate:         end of block\n"));
-         state->mode = TYPE;
-         break;
-      }
-      else {
-         strm->msg = (char *)"invalid literal/length code";
-         state->mode = BAD;
-         break;
-      }
-   } while (in < last && out < end);
-
-   /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
-   len = bits >> 3;
-   in -= len;
-   bits -= len << 3;
-   hold &= (1U << bits) - 1;
-
-   /* update state and return */
-   strm->next_in = in + OFF;
-   strm->next_out = out + OFF;
-   strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
-   strm->avail_out = (unsigned)(out < end ?
-         257 + (end - out) : 257 - (out - end));
-   state->hold = hold;
-   state->bits = bits;
-   return;
-}
-
-/*
-   inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
-   - Using bit fields for code structure
-   - Different op definition to avoid & for extra bits (do & for table bits)
-   - Three separate decoding do-loops for direct, window, and wnext == 0
-   - Special case for distance > 1 copies to do overlapped load and store copy
-   - Explicit branch predictions (based on measured branch probabilities)
-   - Deferring match copy and interspersed it with decoding subsequent codes
-   - Swapping literal/length else
-   - Swapping window/direct else
-   - Larger unrolled copy loops (three is about right)
-   - Moving len -= 3 statement into middle of loop
-   */
-
-#endif /* !ASMINF */
diff --git a/deps/zlib/inffast.h b/deps/zlib/inffast.h
deleted file mode 100644 (file)
index 169a85a..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/* inffast.h -- header to use inffast.c
- * Copyright (C) 1995-2003, 2010 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
-   part of the implementation of the compression library and is
-   subject to change. Applications should only use zlib.h.
- */
-#ifndef _INFFAST_H
-#define _INFFAST_H
-
-void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start));
-
-#endif
diff --git a/deps/zlib/inffixed.h b/deps/zlib/inffixed.h
deleted file mode 100644 (file)
index 238a55f..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-#ifndef _INFFIXED_H
-#define _INFFIXED_H
-
-/* inffixed.h -- table for decoding fixed codes
-     * Generated automatically by makefixed().
-     */
-
-    /* WARNING: this file should *not* be used by applications.
-       It is part of the implementation of this library and is
-       subject to change. Applications should only use zlib.h.
-     */
-
-    static const code lenfix[512] = {
-        {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
-        {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
-        {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
-        {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
-        {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
-        {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
-        {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
-        {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
-        {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
-        {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
-        {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
-        {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
-        {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
-        {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
-        {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
-        {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
-        {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
-        {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
-        {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
-        {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
-        {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
-        {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
-        {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
-        {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
-        {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
-        {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
-        {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
-        {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
-        {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
-        {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
-        {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
-        {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
-        {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
-        {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
-        {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
-        {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
-        {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
-        {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
-        {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
-        {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
-        {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
-        {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
-        {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
-        {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
-        {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
-        {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
-        {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
-        {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
-        {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
-        {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
-        {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
-        {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
-        {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
-        {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
-        {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
-        {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
-        {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
-        {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
-        {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
-        {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
-        {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
-        {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
-        {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
-        {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
-        {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
-        {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
-        {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
-        {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
-        {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
-        {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
-        {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
-        {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
-        {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
-        {0,9,255}
-    };
-
-    static const code distfix[32] = {
-        {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
-        {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
-        {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
-        {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
-        {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
-        {22,5,193},{64,5,0}
-    };
-
-#endif
diff --git a/deps/zlib/inflate.c b/deps/zlib/inflate.c
deleted file mode 100644 (file)
index 0b4f0b7..0000000
+++ /dev/null
@@ -1,1489 +0,0 @@
-/* inflate.c -- zlib decompression
- * Copyright (C) 1995-2012 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- * Change history:
- *
- * 1.2.beta0    24 Nov 2002
- * - First version -- complete rewrite of inflate to simplify code, avoid
- *   creation of window when not needed, minimize use of window when it is
- *   needed, make inffast.c even faster, implement gzip decoding, and to
- *   improve code readability and style over the previous zlib inflate code
- *
- * 1.2.beta1    25 Nov 2002
- * - Use pointers for available input and output checking in inffast.c
- * - Remove input and output counters in inffast.c
- * - Change inffast.c entry and loop from avail_in >= 7 to >= 6
- * - Remove unnecessary second byte pull from length extra in inffast.c
- * - Unroll direct copy to three copies per loop in inffast.c
- *
- * 1.2.beta2    4 Dec 2002
- * - Change external routine names to reduce potential conflicts
- * - Correct filename to inffixed.h for fixed tables in inflate.c
- * - Make hbuf[] unsigned char to match parameter type in inflate.c
- * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset)
- *   to avoid negation problem on Alphas (64 bit) in inflate.c
- *
- * 1.2.beta3    22 Dec 2002
- * - Add comments on state->bits assertion in inffast.c
- * - Add comments on op field in inftrees.h
- * - Fix bug in reuse of allocated window after inflateReset()
- * - Remove bit fields--back to byte structure for speed
- * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths
- * - Change post-increments to pre-increments in inflate_fast(), PPC biased?
- * - Add compile time option, POSTINC, to use post-increments instead (Intel?)
- * - Make MATCH copy in inflate() much faster for when inflate_fast() not used
- * - Use local copies of stream next and avail values, as well as local bit
- *   buffer and bit count in inflate()--for speed when inflate_fast() not used
- *
- * 1.2.beta4    1 Jan 2003
- * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings
- * - Move a comment on output buffer sizes from inffast.c to inflate.c
- * - Add comments in inffast.c to introduce the inflate_fast() routine
- * - Rearrange window copies in inflate_fast() for speed and simplification
- * - Unroll last copy for window match in inflate_fast()
- * - Use local copies of window variables in inflate_fast() for speed
- * - Pull out common wnext == 0 case for speed in inflate_fast()
- * - Make op and len in inflate_fast() unsigned for consistency
- * - Add FAR to lcode and dcode declarations in inflate_fast()
- * - Simplified bad distance check in inflate_fast()
- * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new
- *   source file infback.c to provide a call-back interface to inflate for
- *   programs like gzip and unzip -- uses window as output buffer to avoid
- *   window copying
- *
- * 1.2.beta5    1 Jan 2003
- * - Improved inflateBack() interface to allow the caller to provide initial
- *   input in strm.
- * - Fixed stored blocks bug in inflateBack()
- *
- * 1.2.beta6    4 Jan 2003
- * - Added comments in inffast.c on effectiveness of POSTINC
- * - Typecasting all around to reduce compiler warnings
- * - Changed loops from while (1) or do {} while (1) to for (;;), again to
- *   make compilers happy
- * - Changed type of window in inflateBackInit() to unsigned char *
- *
- * 1.2.beta7    27 Jan 2003
- * - Changed many types to unsigned or unsigned short to avoid warnings
- * - Added inflateCopy() function
- *
- * 1.2.0        9 Mar 2003
- * - Changed inflateBack() interface to provide separate opaque descriptors
- *   for the in() and out() functions
- * - Changed inflateBack() argument and in_func typedef to swap the length
-   *   and buffer address return values for the input function
-* - Check next_in and next_out for Z_NULL on entry to inflate()
-   *
-   * The history for versions after 1.2.0 are in ChangeLog in zlib distribution.
-   */
-
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-#ifdef MAKEFIXED
-#  ifndef BUILDFIXED
-#    define BUILDFIXED
-#  endif
-#endif
-
-#ifndef Z_TREES
-#define Z_TREES 6
-#endif
-
-   /* function prototypes */
-int ZEXPORT inflateReset2(z_streamp strm, int windowBits);
-   local void fixedtables OF((struct inflate_state FAR *state));
-   local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
-            unsigned copy));
-#ifdef BUILDFIXED
-void makefixed OF((void));
-#endif
-local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
-         unsigned len));
-
-long ZEXPORT inflateMark(z_streamp strm);
-
-int ZEXPORT inflateResetKeep(z_streamp strm);
-
-int ZEXPORT inflateUndermine(z_streamp strm, int subvert);
-
-int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary, uInt *dictLength);
-
-int ZEXPORT inflateResetKeep(z_streamp strm)
-{
-   struct inflate_state FAR *state;
-
-   if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
-   state = (struct inflate_state FAR *)strm->state;
-   strm->total_in = strm->total_out = state->total = 0;
-   strm->msg = Z_NULL;
-   if (state->wrap)        /* to support ill-conceived Java test suite */
-      strm->adler = state->wrap & 1;
-   state->mode = HEAD;
-   state->last = 0;
-   state->havedict = 0;
-   state->dmax = 32768U;
-   state->head = Z_NULL;
-   state->hold = 0;
-   state->bits = 0;
-   state->lencode = state->distcode = state->next = state->codes;
-   state->sane = 1;
-   state->back = -1;
-   Tracev((stderr, "inflate: reset\n"));
-   return Z_OK;
-}
-
-int ZEXPORT inflateReset(z_streamp strm)
-{
-   struct inflate_state FAR *state;
-
-   if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
-   state = (struct inflate_state FAR *)strm->state;
-   state->wsize = 0;
-   state->whave = 0;
-   state->wnext = 0;
-   return inflateResetKeep(strm);
-}
-
-int ZEXPORT inflateReset2(z_streamp strm, int windowBits)
-{
-   int wrap;
-   struct inflate_state FAR *state = NULL;
-
-   /* get the state */
-   if (strm == Z_NULL || strm->state == Z_NULL)
-          return Z_STREAM_ERROR;
-   state = (struct inflate_state FAR *)strm->state;
-
-   /* extract wrap request from windowBits parameter */
-   if (windowBits < 0) {
-      wrap = 0;
-      windowBits = -windowBits;
-   }
-   else {
-      wrap = (windowBits >> 4) + 1;
-#ifdef GUNZIP
-      if (windowBits < 48)
-         windowBits &= 15;
-#endif
-   }
-
-   /* set number of window bits, free window if different */
-   if (windowBits && (windowBits < 8 || windowBits > 15))
-      return Z_STREAM_ERROR;
-   if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
-      ZFREE(strm, state->window);
-      state->window = Z_NULL;
-   }
-
-   /* update state and reset the rest of it */
-   state->wrap = wrap;
-   state->wbits = (unsigned)windowBits;
-   return inflateReset(strm);
-}
-
-int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, const char *version, int stream_size)
-{
-   int ret;
-   struct inflate_state FAR *state;
-
-   if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
-         stream_size != (int)(sizeof(z_stream)))
-      return Z_VERSION_ERROR;
-   if (strm == Z_NULL) return Z_STREAM_ERROR;
-   strm->msg = Z_NULL;                 /* in case we return an error */
-   if (strm->zalloc == (alloc_func)0) {
-#ifdef Z_SOLO
-      return Z_STREAM_ERROR;
-#else
-      strm->zalloc = zcalloc;
-      strm->opaque = (voidpf)0;
-#endif
-   }
-   if (strm->zfree == Z_NULL)
-#ifdef Z_SOLO
-      return Z_STREAM_ERROR;
-#else
-   strm->zfree = zcfree;
-#endif
-   state = (struct inflate_state FAR *)
-      ZALLOC(strm, 1, sizeof(struct inflate_state));
-   if (state == Z_NULL) return Z_MEM_ERROR;
-   Tracev((stderr, "inflate: allocated\n"));
-   strm->state = (struct internal_state FAR *)state;
-   state->window = Z_NULL;
-   ret = inflateReset2(strm, windowBits);
-   if (ret != Z_OK) {
-      ZFREE(strm, state);
-      strm->state = Z_NULL;
-   }
-   return ret;
-}
-
-int ZEXPORT inflateInit_(z_streamp strm, const char *version, int stream_size)
-{
-   return inflateInit2_(strm, DEF_WBITS, version, stream_size);
-}
-
-int ZEXPORT inflatePrime(z_streamp strm, int bits, int value)
-{
-   struct inflate_state FAR *state;
-
-   if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
-   state = (struct inflate_state FAR *)strm->state;
-   if (bits < 0) {
-      state->hold = 0;
-      state->bits = 0;
-      return Z_OK;
-   }
-   if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
-   value &= (1L << bits) - 1;
-   state->hold += value << state->bits;
-   state->bits += bits;
-   return Z_OK;
-}
-
-/*
-   Return state with length and distance decoding tables and index sizes set to
-   fixed code decoding.  Normally this returns fixed tables from inffixed.h.
-   If BUILDFIXED is defined, then instead this routine builds the tables the
-   first time it's called, and returns those tables the first time and
-   thereafter.  This reduces the size of the code by about 2K bytes, in
-   exchange for a little execution time.  However, BUILDFIXED should not be
-   used for threaded applications, since the rewriting of the tables and virgin
-   may not be thread-safe.
-   */
-local void fixedtables(struct inflate_state FAR *state)
-{
-#ifdef BUILDFIXED
-   static int virgin = 1;
-   static code *lenfix, *distfix;
-   static code fixed[544];
-
-   /* build fixed huffman tables if first call (may not be thread safe) */
-   if (virgin) {
-      unsigned sym, bits;
-      static code *next;
-
-      /* literal/length table */
-      sym = 0;
-      while (sym < 144) state->lens[sym++] = 8;
-      while (sym < 256) state->lens[sym++] = 9;
-      while (sym < 280) state->lens[sym++] = 7;
-      while (sym < 288) state->lens[sym++] = 8;
-      next = fixed;
-      lenfix = next;
-      bits = 9;
-      inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
-
-      /* distance table */
-      sym = 0;
-      while (sym < 32) state->lens[sym++] = 5;
-      distfix = next;
-      bits = 5;
-      inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
-
-      /* do this just once */
-      virgin = 0;
-   }
-#else /* !BUILDFIXED */
-#   include "inffixed.h"
-#endif /* BUILDFIXED */
-   state->lencode = lenfix;
-   state->lenbits = 9;
-   state->distcode = distfix;
-   state->distbits = 5;
-}
-
-#ifdef MAKEFIXED
-#include <stdio.h>
-
-/*
-   Write out the inffixed.h that is #include'd above.  Defining MAKEFIXED also
-   defines BUILDFIXED, so the tables are built on the fly.  makefixed() writes
-   those tables to stdout, which would be piped to inffixed.h.  A small program
-   can simply call makefixed to do this:
-
-   void makefixed(void);
-
-   int main(void)
-   {
-   makefixed();
-   return 0;
-   }
-
-   Then that can be linked with zlib built with MAKEFIXED defined and run:
-
-   a.out > inffixed.h
-   */
-void makefixed(void)
-{
-   unsigned low, size;
-   struct inflate_state state;
-
-   fixedtables(&state);
-   puts("    /* inffixed.h -- table for decoding fixed codes");
-   puts("     * Generated automatically by makefixed().");
-   puts("     */");
-   puts("");
-   puts("    /* WARNING: this file should *not* be used by applications.");
-   puts("       It is part of the implementation of this library and is");
-   puts("       subject to change. Applications should only use zlib.h.");
-   puts("     */");
-   puts("");
-   size = 1U << 9;
-   printf("    static const code lenfix[%u] = {", size);
-   low = 0;
-   for (;;) {
-      if ((low % 7) == 0) printf("\n        ");
-      printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op,
-            state.lencode[low].bits, state.lencode[low].val);
-      if (++low == size) break;
-      putchar(',');
-   }
-   puts("\n    };");
-   size = 1U << 5;
-   printf("\n    static const code distfix[%u] = {", size);
-   low = 0;
-   for (;;) {
-      if ((low % 6) == 0) printf("\n        ");
-      printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits,
-            state.distcode[low].val);
-      if (++low == size) break;
-      putchar(',');
-   }
-   puts("\n    };");
-}
-#endif /* MAKEFIXED */
-
-/*
-   Update the window with the last wsize (normally 32K) bytes written before
-   returning.  If window does not exist yet, create it.  This is only called
-   when a window is already in use, or when output has been written during this
-   inflate call, but the end of the deflate stream has not been reached yet.
-   It is also called to create a window for dictionary data when a dictionary
-   is loaded.
-
-   Providing output buffers larger than 32K to inflate() should provide a speed
-   advantage, since only the last 32K of output is copied to the sliding window
-   upon return from inflate(), and since all distances after the first 32K of
-   output will fall in the output data, making match copies simpler and faster.
-   The advantage may be dependent on the size of the processor's data caches.
-   */
-local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy)
-{
-   struct inflate_state FAR *state;
-   unsigned dist;
-
-   state = (struct inflate_state FAR *)strm->state;
-
-   /* if it hasn't been done already, allocate space for the window */
-   if (state->window == Z_NULL) {
-      state->window = (unsigned char FAR *)
-         ZALLOC(strm, 1U << state->wbits,
-               sizeof(unsigned char));
-      if (state->window == Z_NULL) return 1;
-   }
-
-   /* if window not in use yet, initialize */
-   if (state->wsize == 0) {
-      state->wsize = 1U << state->wbits;
-      state->wnext = 0;
-      state->whave = 0;
-   }
-
-   /* copy state->wsize or less output bytes into the circular window */
-   if (copy >= state->wsize) {
-      zmemcpy(state->window, end - state->wsize, state->wsize);
-      state->wnext = 0;
-      state->whave = state->wsize;
-   }
-   else {
-      dist = state->wsize - state->wnext;
-      if (dist > copy) dist = copy;
-      zmemcpy(state->window + state->wnext, end - copy, dist);
-      copy -= dist;
-      if (copy) {
-         zmemcpy(state->window, end - copy, copy);
-         state->wnext = copy;
-         state->whave = state->wsize;
-      }
-      else {
-         state->wnext += dist;
-         if (state->wnext == state->wsize) state->wnext = 0;
-         if (state->whave < state->wsize) state->whave += dist;
-      }
-   }
-   return 0;
-}
-
-/* Macros for inflate(): */
-
-/* check function to use adler32() for zlib or crc32() for gzip */
-#ifdef GUNZIP
-#  define UPDATE(check, buf, len) \
-   (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
-#else
-#  define UPDATE(check, buf, len) adler32(check, buf, len)
-#endif
-
-/* check macros for header crc */
-#ifdef GUNZIP
-#  define CRC2(check, word) \
-   do { \
-      hbuf[0] = (unsigned char)(word); \
-      hbuf[1] = (unsigned char)((word) >> 8); \
-      check = crc32(check, hbuf, 2); \
-   } while (0)
-
-#  define CRC4(check, word) \
-   do { \
-      hbuf[0] = (unsigned char)(word); \
-      hbuf[1] = (unsigned char)((word) >> 8); \
-      hbuf[2] = (unsigned char)((word) >> 16); \
-      hbuf[3] = (unsigned char)((word) >> 24); \
-      check = crc32(check, hbuf, 4); \
-   } while (0)
-#endif
-
-/* Load registers with state in inflate() for speed */
-#define LOAD() \
-   do { \
-      put = strm->next_out; \
-      left = strm->avail_out; \
-      next = strm->next_in; \
-      have = strm->avail_in; \
-      hold = state->hold; \
-      bits = state->bits; \
-   } while (0)
-
-/* Restore state from registers in inflate() */
-#define RESTORE() \
-   do { \
-      strm->next_out = put; \
-      strm->avail_out = left; \
-      strm->next_in = next; \
-      strm->avail_in = have; \
-      state->hold = hold; \
-      state->bits = bits; \
-   } while (0)
-
-/* Clear the input bit accumulator */
-#define INITBITS() \
-   do { \
-      hold = 0; \
-      bits = 0; \
-   } while (0)
-
-/* Get a byte of input into the bit accumulator, or return from inflate()
-   if there is no input available. */
-#define PULLBYTE() \
-   do { \
-      if (have == 0) goto inf_leave; \
-      have--; \
-      hold += (unsigned long)(*next++) << bits; \
-      bits += 8; \
-   } while (0)
-
-/* Assure that there are at least n bits in the bit accumulator.  If there is
-   not enough available input to do that, then return from inflate(). */
-#define NEEDBITS(n) \
-   do { \
-      while (bits < (unsigned)(n)) \
-      PULLBYTE(); \
-   } while (0)
-
-/* Return the low n bits of the bit accumulator (n < 16) */
-#define BITS(n) \
-   ((unsigned)hold & ((1U << (n)) - 1))
-
-/* Remove n bits from the bit accumulator */
-#define DROPBITS(n) \
-   do { \
-      hold >>= (n); \
-      bits -= (unsigned)(n); \
-   } while (0)
-
-/* Remove zero to seven bits as needed to go to a byte boundary */
-#define BYTEBITS() \
-   do { \
-      hold >>= bits & 7; \
-      bits -= bits & 7; \
-   } while (0)
-
-/*
-   inflate() uses a state machine to process as much input data and generate as
-   much output data as possible before returning.  The state machine is
-   structured roughly as follows:
-
-   for (;;) switch (state) {
-   ...
-   case STATEn:
-   if (not enough input data or output space to make progress)
-   return;
-   ... make progress ...
-   state = STATEm;
-   break;
-   ...
-   }
-
-   so when inflate() is called again, the same case is attempted again, and
-   if the appropriate resources are provided, the machine proceeds to the
-   next state.  The NEEDBITS() macro is usually the way the state evaluates
-   whether it can proceed or should return.  NEEDBITS() does the return if
-   the requested bits are not available.  The typical use of the BITS macros
-is:
-
-NEEDBITS(n);
-... do something with BITS(n) ...
-DROPBITS(n);
-
-where NEEDBITS(n) either returns from inflate() if there isn't enough
-input left to load n bits into the accumulator, or it continues.  BITS(n)
-gives the low n bits in the accumulator.  When done, DROPBITS(n) drops
-the low n bits off the accumulator.  INITBITS() clears the accumulator
-and sets the number of available bits to zero.  BYTEBITS() discards just
-enough bits to put the accumulator on a byte boundary.  After BYTEBITS()
-and a NEEDBITS(8), then BITS(8) would return the next byte in the stream.
-
-NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return
-if there is no input available.  The decoding of variable length codes uses
-PULLBYTE() directly in order to pull just enough bytes to decode the next
-code, and no more.
-
-Some states loop until they get enough input, making sure that enough
-state information is maintained to continue the loop where it left off
-if NEEDBITS() returns in the loop.  For example, want, need, and keep
-would all have to actually be part of the saved state in case NEEDBITS()
-returns:
-
-case STATEw:
-while (want < need) {
-NEEDBITS(n);
-keep[want++] = BITS(n);
-DROPBITS(n);
-}
-state = STATEx;
-case STATEx:
-
-As shown above, if the next state is also the next case, then the break
-is omitted.
-
-A state may also return if there is not enough output space available to
-complete that state.  Those states are copying stored data, writing a
-literal byte, and copying a matching string.
-
-When returning, a "goto inf_leave" is used to update the total counters,
-update the check value, and determine whether any progress has been made
-during that inflate() call in order to return the proper return code.
-Progress is defined as a change in either strm->avail_in or strm->avail_out.
-When there is a window, goto inf_leave will update the window with the last
-output written.  If a goto inf_leave occurs in the middle of decompression
-and there is no window currently, goto inf_leave will create one and copy
-output to the window for the next call of inflate().
-
-In this implementation, the flush parameter of inflate() only affects the
-return code (per zlib.h).  inflate() always writes as much as possible to
-strm->next_out, given the space available and the provided input--the effect
-documented in zlib.h of Z_SYNC_FLUSH.  Furthermore, inflate() always defers
-the allocation of and copying into a sliding window until necessary, which
-provides the effect documented in zlib.h for Z_FINISH when the entire input
-stream available.  So the only thing the flush parameter actually does is:
-when flush is set to Z_FINISH, inflate() cannot return Z_OK.  Instead it
-will return Z_BUF_ERROR if it has not reached the end of the stream.
-*/
-
-int ZEXPORT inflate(z_streamp strm, int flush)
-{
-   struct inflate_state FAR *state;
-   unsigned char FAR *next;    /* next input */
-   unsigned char FAR *put;     /* next output */
-   unsigned have, left;        /* available input and output */
-   unsigned long hold;         /* bit buffer */
-   unsigned bits;              /* bits in bit buffer */
-   unsigned in, out;           /* save starting available input and output */
-   unsigned copy;              /* number of stored or match bytes to copy */
-   unsigned char FAR *from;    /* where to copy match bytes from */
-   code here;                  /* current decoding table entry */
-   code last;                  /* parent table entry */
-   unsigned len;               /* length to copy for repeats, bits to drop */
-   int ret;                    /* return code */
-#ifdef GUNZIP
-   unsigned char hbuf[4];      /* buffer for gzip header crc calculation */
-#endif
-   static const unsigned short order[19] = /* permutation of code lengths */
-   {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-
-   if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL ||
-         (strm->next_in == Z_NULL && strm->avail_in != 0))
-      return Z_STREAM_ERROR;
-
-   state = (struct inflate_state FAR *)strm->state;
-   if (state->mode == TYPE) state->mode = TYPEDO;      /* skip check */
-   LOAD();
-   in = have;
-   out = left;
-   ret = Z_OK;
-   for (;;)
-      switch (state->mode) {
-         case HEAD:
-            if (state->wrap == 0) {
-               state->mode = TYPEDO;
-               break;
-            }
-            NEEDBITS(16);
-#ifdef GUNZIP
-            if ((state->wrap & 2) && hold == 0x8b1f) {  /* gzip header */
-               state->check = crc32(0L, Z_NULL, 0);
-               CRC2(state->check, hold);
-               INITBITS();
-               state->mode = FLAGS;
-               break;
-            }
-            state->flags = 0;           /* expect zlib header */
-            if (state->head != Z_NULL)
-               state->head->done = -1;
-            if (!(state->wrap & 1) ||   /* check if zlib header allowed */
-#else
-                  if (
-#endif
-                     ((BITS(8) << 8) + (hold >> 8)) % 31) {
-                  strm->msg = (char *)"incorrect header check";
-                  state->mode = BAD;
-                  break;
-                  }
-                  if (BITS(4) != Z_DEFLATED) {
-                  strm->msg = (char *)"unknown compression method";
-                  state->mode = BAD;
-                  break;
-                  }
-                  DROPBITS(4);
-                  len = BITS(4) + 8;
-                  if (state->wbits == 0)
-                  state->wbits = len;
-                  else if (len > state->wbits) {
-                  strm->msg = (char *)"invalid window size";
-                  state->mode = BAD;
-                  break;
-                  }
-                  state->dmax = 1U << len;
-                  Tracev((stderr, "inflate:   zlib header ok\n"));
-                  strm->adler = state->check = adler32(0L, Z_NULL, 0);
-                  state->mode = hold & 0x200 ? DICTID : TYPE;
-                  INITBITS();
-                  break;
-#ifdef GUNZIP
-         case FLAGS:
-                  NEEDBITS(16);
-                  state->flags = (int)(hold);
-                  if ((state->flags & 0xff) != Z_DEFLATED) {
-                     strm->msg = (char *)"unknown compression method";
-                     state->mode = BAD;
-                     break;
-                  }
-                  if (state->flags & 0xe000) {
-                     strm->msg = (char *)"unknown header flags set";
-                     state->mode = BAD;
-                     break;
-                  }
-                  if (state->head != Z_NULL)
-                     state->head->text = (int)((hold >> 8) & 1);
-                  if (state->flags & 0x0200) CRC2(state->check, hold);
-                  INITBITS();
-                  state->mode = TIME;
-         case TIME:
-                  NEEDBITS(32);
-                  if (state->head != Z_NULL)
-                     state->head->time = hold;
-                  if (state->flags & 0x0200) CRC4(state->check, hold);
-                  INITBITS();
-                  state->mode = OS;
-         case OS:
-                  NEEDBITS(16);
-                  if (state->head != Z_NULL) {
-                     state->head->xflags = (int)(hold & 0xff);
-                     state->head->os = (int)(hold >> 8);
-                  }
-                  if (state->flags & 0x0200) CRC2(state->check, hold);
-                  INITBITS();
-                  state->mode = EXLEN;
-         case EXLEN:
-                  if (state->flags & 0x0400) {
-                     NEEDBITS(16);
-                     state->length = (unsigned)(hold);
-                     if (state->head != Z_NULL)
-                        state->head->extra_len = (unsigned)hold;
-                     if (state->flags & 0x0200) CRC2(state->check, hold);
-                     INITBITS();
-                  }
-                  else if (state->head != Z_NULL)
-                     state->head->extra = Z_NULL;
-                  state->mode = EXTRA;
-         case EXTRA:
-                  if (state->flags & 0x0400) {
-                     copy = state->length;
-                     if (copy > have) copy = have;
-                     if (copy) {
-                        if (state->head != Z_NULL &&
-                              state->head->extra != Z_NULL) {
-                           len = state->head->extra_len - state->length;
-                           zmemcpy(state->head->extra + len, next,
-                                 len + copy > state->head->extra_max ?
-                                 state->head->extra_max - len : copy);
-                        }
-                        if (state->flags & 0x0200)
-                           state->check = crc32(state->check, next, copy);
-                        have -= copy;
-                        next += copy;
-                        state->length -= copy;
-                     }
-                     if (state->length) goto inf_leave;
-                  }
-                  state->length = 0;
-                  state->mode = NAME;
-         case NAME:
-                  if (state->flags & 0x0800) {
-                     if (have == 0) goto inf_leave;
-                     copy = 0;
-                     do {
-                        len = (unsigned)(next[copy++]);
-                        if (state->head != Z_NULL &&
-                              state->head->name != Z_NULL &&
-                              state->length < state->head->name_max)
-                           state->head->name[state->length++] = len;
-                     } while (len && copy < have);
-                     if (state->flags & 0x0200)
-                        state->check = crc32(state->check, next, copy);
-                     have -= copy;
-                     next += copy;
-                     if (len) goto inf_leave;
-                  }
-                  else if (state->head != Z_NULL)
-                     state->head->name = Z_NULL;
-                  state->length = 0;
-                  state->mode = COMMENT;
-         case COMMENT:
-                  if (state->flags & 0x1000) {
-                     if (have == 0) goto inf_leave;
-                     copy = 0;
-                     do {
-                        len = (unsigned)(next[copy++]);
-                        if (state->head != Z_NULL &&
-                              state->head->comment != Z_NULL &&
-                              state->length < state->head->comm_max)
-                           state->head->comment[state->length++] = len;
-                     } while (len && copy < have);
-                     if (state->flags & 0x0200)
-                        state->check = crc32(state->check, next, copy);
-                     have -= copy;
-                     next += copy;
-                     if (len) goto inf_leave;
-                  }
-                  else if (state->head != Z_NULL)
-                     state->head->comment = Z_NULL;
-                  state->mode = HCRC;
-         case HCRC:
-                  if (state->flags & 0x0200) {
-                     NEEDBITS(16);
-                     if (hold != (state->check & 0xffff)) {
-                        strm->msg = (char *)"header crc mismatch";
-                        state->mode = BAD;
-                        break;
-                     }
-                     INITBITS();
-                  }
-                  if (state->head != Z_NULL) {
-                     state->head->hcrc = (int)((state->flags >> 9) & 1);
-                     state->head->done = 1;
-                  }
-                  strm->adler = state->check = crc32(0L, Z_NULL, 0);
-                  state->mode = TYPE;
-                  break;
-#endif
-         case DICTID:
-                  NEEDBITS(32);
-                  strm->adler = state->check = ZSWAP32(hold);
-                  INITBITS();
-                  state->mode = DICT;
-         case DICT:
-                  if (state->havedict == 0) {
-                     RESTORE();
-                     return Z_NEED_DICT;
-                  }
-                  strm->adler = state->check = adler32(0L, Z_NULL, 0);
-                  state->mode = TYPE;
-         case TYPE:
-                  if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
-         case TYPEDO:
-                  if (state->last) {
-                     BYTEBITS();
-                     state->mode = CHECK;
-                     break;
-                  }
-                  NEEDBITS(3);
-                  state->last = BITS(1);
-                  DROPBITS(1);
-                  switch (BITS(2)) {
-                     case 0:                             /* stored block */
-                        Tracev((stderr, "inflate:     stored block%s\n",
-                                 state->last ? " (last)" : ""));
-                        state->mode = STORED;
-                        break;
-                     case 1:                             /* fixed block */
-                        fixedtables(state);
-                        Tracev((stderr, "inflate:     fixed codes block%s\n",
-                                 state->last ? " (last)" : ""));
-                        state->mode = LEN_;             /* decode codes */
-                        if (flush == Z_TREES) {
-                           DROPBITS(2);
-                           goto inf_leave;
-                        }
-                        break;
-                     case 2:                             /* dynamic block */
-                        Tracev((stderr, "inflate:     dynamic codes block%s\n",
-                                 state->last ? " (last)" : ""));
-                        state->mode = TABLE;
-                        break;
-                     case 3:
-                        strm->msg = (char *)"invalid block type";
-                        state->mode = BAD;
-                  }
-                  DROPBITS(2);
-                  break;
-         case STORED:
-                  BYTEBITS();                         /* go to byte boundary */
-                  NEEDBITS(32);
-                  if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
-                     strm->msg = (char *)"invalid stored block lengths";
-                     state->mode = BAD;
-                     break;
-                  }
-                  state->length = (unsigned)hold & 0xffff;
-                  Tracev((stderr, "inflate:       stored length %u\n",
-                           state->length));
-                  INITBITS();
-                  state->mode = COPY_;
-                  if (flush == Z_TREES) goto inf_leave;
-         case COPY_:
-                  state->mode = COPY;
-         case COPY:
-                  copy = state->length;
-                  if (copy) {
-                     if (copy > have) copy = have;
-                     if (copy > left) copy = left;
-                     if (copy == 0) goto inf_leave;
-                     zmemcpy(put, next, copy);
-                     have -= copy;
-                     next += copy;
-                     left -= copy;
-                     put += copy;
-                     state->length -= copy;
-                     break;
-                  }
-                  Tracev((stderr, "inflate:       stored end\n"));
-                  state->mode = TYPE;
-                  break;
-         case TABLE:
-                  NEEDBITS(14);
-                  state->nlen = BITS(5) + 257;
-                  DROPBITS(5);
-                  state->ndist = BITS(5) + 1;
-                  DROPBITS(5);
-                  state->ncode = BITS(4) + 4;
-                  DROPBITS(4);
-#ifndef PKZIP_BUG_WORKAROUND
-                  if (state->nlen > 286 || state->ndist > 30) {
-                     strm->msg = (char *)"too many length or distance symbols";
-                     state->mode = BAD;
-                     break;
-                  }
-#endif
-                  Tracev((stderr, "inflate:       table sizes ok\n"));
-                  state->have = 0;
-                  state->mode = LENLENS;
-         case LENLENS:
-                  while (state->have < state->ncode) {
-                     NEEDBITS(3);
-                     state->lens[order[state->have++]] = (unsigned short)BITS(3);
-                     DROPBITS(3);
-                  }
-                  while (state->have < 19)
-                     state->lens[order[state->have++]] = 0;
-                  state->next = state->codes;
-                  state->lencode = (const code FAR *)(state->next);
-                  state->lenbits = 7;
-                  ret = inflate_table(CODES, state->lens, 19, &(state->next),
-                        &(state->lenbits), state->work);
-                  if (ret) {
-                     strm->msg = (char *)"invalid code lengths set";
-                     state->mode = BAD;
-                     break;
-                  }
-                  Tracev((stderr, "inflate:       code lengths ok\n"));
-                  state->have = 0;
-                  state->mode = CODELENS;
-         case CODELENS:
-                  while (state->have < state->nlen + state->ndist) {
-                     for (;;) {
-                        here = state->lencode[BITS(state->lenbits)];
-                        if ((unsigned)(here.bits) <= bits) break;
-                        PULLBYTE();
-                     }
-                     if (here.val < 16) {
-                        DROPBITS(here.bits);
-                        state->lens[state->have++] = here.val;
-                     }
-                     else {
-                        if (here.val == 16) {
-                           NEEDBITS(here.bits + 2);
-                           DROPBITS(here.bits);
-                           if (state->have == 0) {
-                              strm->msg = (char *)"invalid bit length repeat";
-                              state->mode = BAD;
-                              break;
-                           }
-                           len = state->lens[state->have - 1];
-                           copy = 3 + BITS(2);
-                           DROPBITS(2);
-                        }
-                        else if (here.val == 17) {
-                           NEEDBITS(here.bits + 3);
-                           DROPBITS(here.bits);
-                           len = 0;
-                           copy = 3 + BITS(3);
-                           DROPBITS(3);
-                        }
-                        else {
-                           NEEDBITS(here.bits + 7);
-                           DROPBITS(here.bits);
-                           len = 0;
-                           copy = 11 + BITS(7);
-                           DROPBITS(7);
-                        }
-                        if (state->have + copy > state->nlen + state->ndist) {
-                           strm->msg = (char *)"invalid bit length repeat";
-                           state->mode = BAD;
-                           break;
-                        }
-                        while (copy--)
-                           state->lens[state->have++] = (unsigned short)len;
-                     }
-                  }
-
-                  /* handle error breaks in while */
-                  if (state->mode == BAD) break;
-
-                  /* check for end-of-block code (better have one) */
-                  if (state->lens[256] == 0) {
-                     strm->msg = (char *)"invalid code -- missing end-of-block";
-                     state->mode = BAD;
-                     break;
-                  }
-
-                  /* build code tables -- note: do not change the lenbits or distbits
-                     values here (9 and 6) without reading the comments in inftrees.h
-                     concerning the ENOUGH constants, which depend on those values */
-                  state->next = state->codes;
-                  state->lencode = (const code FAR *)(state->next);
-                  state->lenbits = 9;
-                  ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
-                        &(state->lenbits), state->work);
-                  if (ret) {
-                     strm->msg = (char *)"invalid literal/lengths set";
-                     state->mode = BAD;
-                     break;
-                  }
-                  state->distcode = (const code FAR *)(state->next);
-                  state->distbits = 6;
-                  ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
-                        &(state->next), &(state->distbits), state->work);
-                  if (ret) {
-                     strm->msg = (char *)"invalid distances set";
-                     state->mode = BAD;
-                     break;
-                  }
-                  Tracev((stderr, "inflate:       codes ok\n"));
-                  state->mode = LEN_;
-                  if (flush == Z_TREES) goto inf_leave;
-         case LEN_:
-                  state->mode = LEN;
-         case LEN:
-                  if (have >= 6 && left >= 258) {
-                     RESTORE();
-                     inflate_fast(strm, out);
-                     LOAD();
-                     if (state->mode == TYPE)
-                        state->back = -1;
-                     break;
-                  }
-                  state->back = 0;
-                  for (;;) {
-                     here = state->lencode[BITS(state->lenbits)];
-                     if ((unsigned)(here.bits) <= bits) break;
-                     PULLBYTE();
-                  }
-                  if (here.op && (here.op & 0xf0) == 0) {
-                     last = here;
-                     for (;;) {
-                        here = state->lencode[last.val +
-                           (BITS(last.bits + last.op) >> last.bits)];
-                        if ((unsigned)(last.bits + here.bits) <= bits) break;
-                        PULLBYTE();
-                     }
-                     DROPBITS(last.bits);
-                     state->back += last.bits;
-                  }
-                  DROPBITS(here.bits);
-                  state->back += here.bits;
-                  state->length = (unsigned)here.val;
-                  if ((int)(here.op) == 0) {
-                     Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
-                              "inflate:         literal '%c'\n" :
-                              "inflate:         literal 0x%02x\n", here.val));
-                     state->mode = LIT;
-                     break;
-                  }
-                  if (here.op & 32) {
-                     Tracevv((stderr, "inflate:         end of block\n"));
-                     state->back = -1;
-                     state->mode = TYPE;
-                     break;
-                  }
-                  if (here.op & 64) {
-                     strm->msg = (char *)"invalid literal/length code";
-                     state->mode = BAD;
-                     break;
-                  }
-                  state->extra = (unsigned)(here.op) & 15;
-                  state->mode = LENEXT;
-         case LENEXT:
-                  if (state->extra) {
-                     NEEDBITS(state->extra);
-                     state->length += BITS(state->extra);
-                     DROPBITS(state->extra);
-                     state->back += state->extra;
-                  }
-                  Tracevv((stderr, "inflate:         length %u\n", state->length));
-                  state->was = state->length;
-                  state->mode = DIST;
-         case DIST:
-                  for (;;) {
-                     here = state->distcode[BITS(state->distbits)];
-                     if ((unsigned)(here.bits) <= bits) break;
-                     PULLBYTE();
-                  }
-                  if ((here.op & 0xf0) == 0) {
-                     last = here;
-                     for (;;) {
-                        here = state->distcode[last.val +
-                           (BITS(last.bits + last.op) >> last.bits)];
-                        if ((unsigned)(last.bits + here.bits) <= bits) break;
-                        PULLBYTE();
-                     }
-                     DROPBITS(last.bits);
-                     state->back += last.bits;
-                  }
-                  DROPBITS(here.bits);
-                  state->back += here.bits;
-                  if (here.op & 64) {
-                     strm->msg = (char *)"invalid distance code";
-                     state->mode = BAD;
-                     break;
-                  }
-                  state->offset = (unsigned)here.val;
-                  state->extra = (unsigned)(here.op) & 15;
-                  state->mode = DISTEXT;
-         case DISTEXT:
-                  if (state->extra) {
-                     NEEDBITS(state->extra);
-                     state->offset += BITS(state->extra);
-                     DROPBITS(state->extra);
-                     state->back += state->extra;
-                  }
-#ifdef INFLATE_STRICT
-                  if (state->offset > state->dmax) {
-                     strm->msg = (char *)"invalid distance too far back";
-                     state->mode = BAD;
-                     break;
-                  }
-#endif
-                  Tracevv((stderr, "inflate:         distance %u\n", state->offset));
-                  state->mode = MATCH;
-         case MATCH:
-                  if (left == 0) goto inf_leave;
-                  copy = out - left;
-                  if (state->offset > copy) {         /* copy from window */
-                     copy = state->offset - copy;
-                     if (copy > state->whave) {
-                        if (state->sane) {
-                           strm->msg = (char *)"invalid distance too far back";
-                           state->mode = BAD;
-                           break;
-                        }
-#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
-                        Trace((stderr, "inflate.c too far\n"));
-                        copy -= state->whave;
-                        if (copy > state->length) copy = state->length;
-                        if (copy > left) copy = left;
-                        left -= copy;
-                        state->length -= copy;
-                        do {
-                           *put++ = 0;
-                        } while (--copy);
-                        if (state->length == 0) state->mode = LEN;
-                        break;
-#endif
-                     }
-                     if (copy > state->wnext) {
-                        copy -= state->wnext;
-                        from = state->window + (state->wsize - copy);
-                     }
-                     else
-                        from = state->window + (state->wnext - copy);
-                     if (copy > state->length) copy = state->length;
-                  }
-                  else {                              /* copy from output */
-                     from = put - state->offset;
-                     copy = state->length;
-                  }
-                  if (copy > left) copy = left;
-                  left -= copy;
-                  state->length -= copy;
-                  do {
-                     *put++ = *from++;
-                  } while (--copy);
-                  if (state->length == 0) state->mode = LEN;
-                  break;
-         case LIT:
-                  if (left == 0) goto inf_leave;
-                  *put++ = (unsigned char)(state->length);
-                  left--;
-                  state->mode = LEN;
-                  break;
-         case CHECK:
-                  if (state->wrap) {
-                     NEEDBITS(32);
-                     out -= left;
-                     strm->total_out += out;
-                     state->total += out;
-                     if (out)
-                        strm->adler = state->check =
-                           UPDATE(state->check, put - out, out);
-                     out = left;
-                     if ((
-#ifdef GUNZIP
-                              state->flags ? hold :
-#endif
-                              ZSWAP32(hold)) != state->check) {
-                        strm->msg = (char *)"incorrect data check";
-                        state->mode = BAD;
-                        break;
-                     }
-                     INITBITS();
-                     Tracev((stderr, "inflate:   check matches trailer\n"));
-                  }
-#ifdef GUNZIP
-                  state->mode = LENGTH;
-         case LENGTH:
-                  if (state->wrap && state->flags) {
-                     NEEDBITS(32);
-                     if (hold != (state->total & 0xffffffffUL)) {
-                        strm->msg = (char *)"incorrect length check";
-                        state->mode = BAD;
-                        break;
-                     }
-                     INITBITS();
-                     Tracev((stderr, "inflate:   length matches trailer\n"));
-                  }
-#endif
-                  state->mode = DONE;
-         case DONE:
-                  ret = Z_STREAM_END;
-                  goto inf_leave;
-         case BAD:
-                  ret = Z_DATA_ERROR;
-                  goto inf_leave;
-         case MEM:
-                  return Z_MEM_ERROR;
-         case SYNC:
-         default:
-                  return Z_STREAM_ERROR;
-      }
-
-   /*
-      Return from inflate(), updating the total counts and the check value.
-      If there was no progress during the inflate() call, return a buffer
-      error.  Call updatewindow() to create and/or update the window state.
-Note: a memory error from inflate() is non-recoverable.
-*/
-inf_leave:
-   RESTORE();
-   if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
-            (state->mode < CHECK || flush != Z_FINISH)))
-      if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {
-         state->mode = MEM;
-         return Z_MEM_ERROR;
-      }
-   in -= strm->avail_in;
-   out -= strm->avail_out;
-   strm->total_in += in;
-   strm->total_out += out;
-   state->total += out;
-   if (state->wrap && out)
-      strm->adler = state->check =
-         UPDATE(state->check, strm->next_out - out, out);
-   strm->data_type = state->bits + (state->last ? 64 : 0) +
-      (state->mode == TYPE ? 128 : 0) +
-      (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
-   if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
-      ret = Z_BUF_ERROR;
-   return ret;
-}
-
-int ZEXPORT inflateEnd(z_streamp strm)
-{
-   struct inflate_state FAR *state;
-   if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == Z_NULL)
-      return Z_STREAM_ERROR;
-   state = (struct inflate_state FAR *)strm->state;
-   if (state->window != Z_NULL) ZFREE(strm, state->window);
-   ZFREE(strm, strm->state);
-   strm->state = Z_NULL;
-   Tracev((stderr, "inflate: end\n"));
-   return Z_OK;
-}
-
-int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary, uInt *dictLength)
-{
-   struct inflate_state FAR *state;
-
-   /* check state */
-   if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
-   state = (struct inflate_state FAR *)strm->state;
-
-   /* copy dictionary */
-   if (state->whave && dictionary != Z_NULL) {
-      zmemcpy(dictionary, state->window + state->wnext,
-            state->whave - state->wnext);
-      zmemcpy(dictionary + state->whave - state->wnext,
-            state->window, state->wnext);
-   }
-   if (dictLength != Z_NULL)
-      *dictLength = state->whave;
-   return Z_OK;
-}
-
-int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary, uInt dictLength)
-{
-   struct inflate_state FAR *state;
-   unsigned long dictid;
-   int ret;
-
-   /* check state */
-   if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
-   state = (struct inflate_state FAR *)strm->state;
-   if (state->wrap != 0 && state->mode != DICT)
-      return Z_STREAM_ERROR;
-
-   /* check for correct dictionary identifier */
-   if (state->mode == DICT) {
-      dictid = adler32(0L, Z_NULL, 0);
-      dictid = adler32(dictid, dictionary, dictLength);
-      if (dictid != state->check)
-         return Z_DATA_ERROR;
-   }
-
-   /* copy dictionary to window using updatewindow(), which will amend the
-      existing dictionary if appropriate */
-   ret = updatewindow(strm, dictionary + dictLength, dictLength);
-   if (ret) {
-      state->mode = MEM;
-      return Z_MEM_ERROR;
-   }
-   state->havedict = 1;
-   Tracev((stderr, "inflate:   dictionary set\n"));
-   return Z_OK;
-}
-
-int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head)
-{
-   struct inflate_state FAR *state;
-
-   /* check state */
-   if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
-   state = (struct inflate_state FAR *)strm->state;
-   if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
-
-   /* save header structure */
-   state->head = head;
-   head->done = 0;
-   return Z_OK;
-}
-
-/*
-   Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff.  Return when found
-   or when out of input.  When called, *have is the number of pattern bytes
-   found in order so far, in 0..3.  On return *have is updated to the new
-   state.  If on return *have equals four, then the pattern was found and the
-   return value is how many bytes were read including the last byte of the
-   pattern.  If *have is less than four, then the pattern has not been found
-   yet and the return value is len.  In the latter case, syncsearch() can be
-   called again with more data and the *have state.  *have is initialized to
-   zero for the first call.
-   */
-local unsigned syncsearch(unsigned FAR *have, const unsigned char FAR *buf, unsigned len)
-{
-   unsigned got;
-   unsigned next;
-
-   got = *have;
-   next = 0;
-   while (next < len && got < 4) {
-      if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))
-         got++;
-      else if (buf[next])
-         got = 0;
-      else
-         got = 4 - got;
-      next++;
-   }
-   *have = got;
-   return next;
-}
-
-int ZEXPORT inflateSync(z_streamp strm)
-{
-   unsigned len;               /* number of bytes to look at or looked at */
-   unsigned long in, out;      /* temporary to save total_in and total_out */
-   unsigned char buf[4];       /* to restore bit buffer to byte string */
-   struct inflate_state FAR *state;
-
-   /* check parameters */
-   if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
-   state = (struct inflate_state FAR *)strm->state;
-   if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
-
-   /* if first time, start search in bit buffer */
-   if (state->mode != SYNC) {
-      state->mode = SYNC;
-      state->hold <<= state->bits & 7;
-      state->bits -= state->bits & 7;
-      len = 0;
-      while (state->bits >= 8) {
-         buf[len++] = (unsigned char)(state->hold);
-         state->hold >>= 8;
-         state->bits -= 8;
-      }
-      state->have = 0;
-      syncsearch(&(state->have), buf, len);
-   }
-
-   /* search available input */
-   len = syncsearch(&(state->have), strm->next_in, strm->avail_in);
-   strm->avail_in -= len;
-   strm->next_in += len;
-   strm->total_in += len;
-
-   /* return no joy or set up to restart inflate() on a new block */
-   if (state->have != 4) return Z_DATA_ERROR;
-   in = strm->total_in;  out = strm->total_out;
-   inflateReset(strm);
-   strm->total_in = in;  strm->total_out = out;
-   state->mode = TYPE;
-   return Z_OK;
-}
-
-/*
-   Returns true if inflate is currently at the end of a block generated by
-   Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
-   implementation to provide an additional safety check. PPP uses
-   Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored
-   block. When decompressing, PPP checks that at the end of input packet,
-   inflate is waiting for these length bytes.
-   */
-int ZEXPORT inflateSyncPoint(z_streamp strm)
-{
-   struct inflate_state FAR *state;
-
-   if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
-   state = (struct inflate_state FAR *)strm->state;
-   return state->mode == STORED && state->bits == 0;
-}
-
-int ZEXPORT inflateCopy(z_streamp dest, z_streamp source)
-{
-   struct inflate_state FAR *state;
-   struct inflate_state FAR *copy;
-   unsigned char FAR *window;
-   unsigned wsize;
-
-   /* check input */
-   if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL ||
-         source->zalloc == Z_NULL || source->zfree == Z_NULL)
-      return Z_STREAM_ERROR;
-   state = (struct inflate_state FAR *)source->state;
-
-   /* allocate space */
-   copy = (struct inflate_state FAR *)
-      ZALLOC(source, 1, sizeof(struct inflate_state));
-   if (copy == Z_NULL) return Z_MEM_ERROR;
-   window = Z_NULL;
-   if (state->window != Z_NULL) {
-      window = (unsigned char FAR *)
-         ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
-      if (window == Z_NULL) {
-         ZFREE(source, copy);
-         return Z_MEM_ERROR;
-      }
-   }
-
-   /* copy state */
-   zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
-   zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));
-   if (state->lencode >= state->codes &&
-         state->lencode <= state->codes + ENOUGH - 1) {
-      copy->lencode = copy->codes + (state->lencode - state->codes);
-      copy->distcode = copy->codes + (state->distcode - state->codes);
-   }
-   copy->next = copy->codes + (state->next - state->codes);
-   if (window != Z_NULL) {
-      wsize = 1U << state->wbits;
-      zmemcpy(window, state->window, wsize);
-   }
-   copy->window = window;
-   dest->state = (struct internal_state FAR *)copy;
-   return Z_OK;
-}
-
-int ZEXPORT inflateUndermine(z_streamp strm, int subvert)
-{
-   struct inflate_state FAR *state = NULL;
-
-   if (strm == Z_NULL || strm->state == Z_NULL)
-          return Z_STREAM_ERROR;
-   state = (struct inflate_state FAR *)strm->state;
-   state->sane = !subvert;
-#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
-   return Z_OK;
-#else
-   state->sane = 1;
-   return Z_DATA_ERROR;
-#endif
-}
-
-long ZEXPORT inflateMark(z_streamp strm)
-{
-   struct inflate_state FAR *state = NULL;
-
-   if (strm == Z_NULL || strm->state == Z_NULL)
-          return -1L << 16;
-   state = (struct inflate_state FAR *)strm->state;
-   return ((long)(state->back) << 16) +
-      (state->mode == COPY ? state->length :
-       (state->mode == MATCH ? state->was - state->length : 0));
-}
diff --git a/deps/zlib/inflate.h b/deps/zlib/inflate.h
deleted file mode 100644 (file)
index dbc173a..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/* inflate.h -- internal inflate state definition
- * Copyright (C) 1995-2009 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
-   part of the implementation of the compression library and is
-   subject to change. Applications should only use zlib.h.
- */
-
-/* define NO_GZIP when compiling if you want to disable gzip header and
-   trailer decoding by inflate().  NO_GZIP would be used to avoid linking in
-   the crc code when it is not needed.  For shared libraries, gzip decoding
-   should be left enabled. */
-#ifndef _INFLATE_H
-#define _INFLATE_H
-
-#ifndef NO_GZIP
-#  define GUNZIP
-#endif
-
-/* Possible inflate modes between inflate() calls */
-typedef enum {
-    HEAD,       /* i: waiting for magic header */
-    FLAGS,      /* i: waiting for method and flags (gzip) */
-    TIME,       /* i: waiting for modification time (gzip) */
-    OS,         /* i: waiting for extra flags and operating system (gzip) */
-    EXLEN,      /* i: waiting for extra length (gzip) */
-    EXTRA,      /* i: waiting for extra bytes (gzip) */
-    NAME,       /* i: waiting for end of file name (gzip) */
-    COMMENT,    /* i: waiting for end of comment (gzip) */
-    HCRC,       /* i: waiting for header crc (gzip) */
-    DICTID,     /* i: waiting for dictionary check value */
-    DICT,       /* waiting for inflateSetDictionary() call */
-        TYPE,       /* i: waiting for type bits, including last-flag bit */
-        TYPEDO,     /* i: same, but skip check to exit inflate on new block */
-        STORED,     /* i: waiting for stored size (length and complement) */
-        COPY_,      /* i/o: same as COPY below, but only first time in */
-        COPY,       /* i/o: waiting for input or output to copy stored block */
-        TABLE,      /* i: waiting for dynamic block table lengths */
-        LENLENS,    /* i: waiting for code length code lengths */
-        CODELENS,   /* i: waiting for length/lit and distance code lengths */
-            LEN_,       /* i: same as LEN below, but only first time in */
-            LEN,        /* i: waiting for length/lit/eob code */
-            LENEXT,     /* i: waiting for length extra bits */
-            DIST,       /* i: waiting for distance code */
-            DISTEXT,    /* i: waiting for distance extra bits */
-            MATCH,      /* o: waiting for output space to copy string */
-            LIT,        /* o: waiting for output space to write literal */
-    CHECK,      /* i: waiting for 32-bit check value */
-    LENGTH,     /* i: waiting for 32-bit length (gzip) */
-    DONE,       /* finished check, done -- remain here until reset */
-    BAD,        /* got a data error -- remain here until reset */
-    MEM,        /* got an inflate() memory error -- remain here until reset */
-    SYNC        /* looking for synchronization bytes to restart inflate() */
-} inflate_mode;
-
-/*
-    State transitions between above modes -
-
-    (most modes can go to BAD or MEM on error -- not shown for clarity)
-
-    Process header:
-        HEAD -> (gzip) or (zlib) or (raw)
-        (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT ->
-                  HCRC -> TYPE
-        (zlib) -> DICTID or TYPE
-        DICTID -> DICT -> TYPE
-        (raw) -> TYPEDO
-    Read deflate blocks:
-            TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK
-            STORED -> COPY_ -> COPY -> TYPE
-            TABLE -> LENLENS -> CODELENS -> LEN_
-            LEN_ -> LEN
-    Read deflate codes in fixed or dynamic block:
-                LEN -> LENEXT or LIT or TYPE
-                LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
-                LIT -> LEN
-    Process trailer:
-        CHECK -> LENGTH -> DONE
- */
-
-/* state maintained between inflate() calls.  Approximately 10K bytes. */
-struct inflate_state {
-    inflate_mode mode;          /* current inflate mode */
-    int last;                   /* true if processing last block */
-    int wrap;                   /* bit 0 true for zlib, bit 1 true for gzip */
-    int havedict;               /* true if dictionary provided */
-    int flags;                  /* gzip header method and flags (0 if zlib) */
-    unsigned dmax;              /* zlib header max distance (INFLATE_STRICT) */
-    unsigned long check;        /* protected copy of check value */
-    unsigned long total;        /* protected copy of output count */
-    gz_headerp head;            /* where to save gzip header information */
-        /* sliding window */
-    unsigned wbits;             /* log base 2 of requested window size */
-    unsigned wsize;             /* window size or zero if not using window */
-    unsigned whave;             /* valid bytes in the window */
-    unsigned wnext;             /* window write index */
-    unsigned char FAR *window;  /* allocated sliding window, if needed */
-        /* bit accumulator */
-    unsigned long hold;         /* input bit accumulator */
-    unsigned bits;              /* number of bits in "in" */
-        /* for string and stored block copying */
-    unsigned length;            /* literal or length of data to copy */
-    unsigned offset;            /* distance back to copy string from */
-        /* for table and code decoding */
-    unsigned extra;             /* extra bits needed */
-        /* fixed and dynamic code tables */
-    code const FAR *lencode;    /* starting table for length/literal codes */
-    code const FAR *distcode;   /* starting table for distance codes */
-    unsigned lenbits;           /* index bits for lencode */
-    unsigned distbits;          /* index bits for distcode */
-        /* dynamic table building */
-    unsigned ncode;             /* number of code length code lengths */
-    unsigned nlen;              /* number of length code lengths */
-    unsigned ndist;             /* number of distance code lengths */
-    unsigned have;              /* number of code lengths in lens[] */
-    code FAR *next;             /* next available space in codes[] */
-    unsigned short lens[320];   /* temporary storage for code lengths */
-    unsigned short work[288];   /* work area for code table building */
-    code codes[ENOUGH];         /* space for code tables */
-    int sane;                   /* if false, allow invalid distance too far */
-    int back;                   /* bits back of last unprocessed length/lit */
-    unsigned was;               /* initial length of match */
-};
-
-#endif
diff --git a/deps/zlib/inftrees.c b/deps/zlib/inftrees.c
deleted file mode 100644 (file)
index 8b8a964..0000000
+++ /dev/null
@@ -1,300 +0,0 @@
-/* inftrees.c -- generate Huffman trees for efficient decoding
- * Copyright (C) 1995-2013 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-
-#define MAXBITS 15
-
-const char inflate_copyright[] =
-" inflate 1.2.8 Copyright 1995-2013 Mark Adler ";
-/*
-   If you use the zlib library in a product, an acknowledgment is welcome
-   in the documentation of your product. If for some reason you cannot
-   include such an acknowledgment, I would appreciate that you keep this
-   copyright string in the executable of your product.
-   */
-
-/*
-   Build a set of tables to decode the provided canonical Huffman code.
-   The code lengths are lens[0..codes-1].  The result starts at *table,
-   whose indices are 0..2^bits-1.  work is a writable array of at least
-   lens shorts, which is used as a work area.  type is the type of code
-   to be generated, CODES, LENS, or DISTS.  On return, zero is success,
-   -1 is an invalid code, and +1 means that ENOUGH isn't enough.  table
-   on return points to the next available entry's address.  bits is the
-   requested root table index bits, and on return it is the actual root
-   table index bits.  It will differ if the request is greater than the
-   longest code or if it is less than the shortest code.
-   */
-int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, unsigned codes, code FAR * FAR *table, unsigned FAR *bits, unsigned short FAR *work)
-{
-   unsigned len;               /* a code's length in bits */
-   unsigned sym;               /* index of code symbols */
-   unsigned min, max;          /* minimum and maximum code lengths */
-   unsigned root;              /* number of index bits for root table */
-   unsigned curr;              /* number of index bits for current table */
-   unsigned drop;              /* code bits to drop for sub-table */
-   int left;                   /* number of prefix codes available */
-   unsigned used;              /* code entries in table used */
-   unsigned huff;              /* Huffman code */
-   unsigned incr;              /* for incrementing code, index */
-   unsigned fill;              /* index for replicating entries */
-   unsigned low;               /* low bits for current root entry */
-   unsigned mask;              /* mask for low root bits */
-   code here;                  /* table entry for duplication */
-   code FAR *next;             /* next available space in table */
-   const unsigned short FAR *base;     /* base value table to use */
-   const unsigned short FAR *extra;    /* extra bits table to use */
-   int end;                    /* use base and extra for symbol > end */
-   unsigned short count[MAXBITS+1];    /* number of codes of each length */
-   unsigned short offs[MAXBITS+1];     /* offsets in table for each length */
-   static const unsigned short lbase[31] = { /* Length codes 257..285 base */
-      3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
-      35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
-   static const unsigned short lext[31] = { /* Length codes 257..285 extra */
-      16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
-      19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78};
-   static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
-      1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
-      257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
-      8193, 12289, 16385, 24577, 0, 0};
-   static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
-      16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
-      23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
-      28, 28, 29, 29, 64, 64};
-
-   /*
-      Process a set of code lengths to create a canonical Huffman code.  The
-      code lengths are lens[0..codes-1].  Each length corresponds to the
-      symbols 0..codes-1.  The Huffman code is generated by first sorting the
-      symbols by length from short to long, and retaining the symbol order
-      for codes with equal lengths.  Then the code starts with all zero bits
-      for the first code of the shortest length, and the codes are integer
-      increments for the same length, and zeros are appended as the length
-      increases.  For the deflate format, these bits are stored backwards
-      from their more natural integer increment ordering, and so when the
-      decoding tables are built in the large loop below, the integer codes
-      are incremented backwards.
-
-      This routine assumes, but does not check, that all of the entries in
-      lens[] are in the range 0..MAXBITS.  The caller must assure this.
-      1..MAXBITS is interpreted as that code length.  zero means that that
-      symbol does not occur in this code.
-
-      The codes are sorted by computing a count of codes for each length,
-      creating from that a table of starting indices for each length in the
-      sorted table, and then entering the symbols in order in the sorted
-      table.  The sorted table is work[], with that space being provided by
-      the caller.
-
-      The length counts are used for other purposes as well, i.e. finding
-      the minimum and maximum length codes, determining if there are any
-      codes at all, checking for a valid set of lengths, and looking ahead
-      at length counts to determine sub-table sizes when building the
-      decoding tables.
-      */
-
-   /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
-   for (len = 0; len <= MAXBITS; len++)
-      count[len] = 0;
-   for (sym = 0; sym < codes; sym++)
-      count[lens[sym]]++;
-
-   /* bound code lengths, force root to be within code lengths */
-   root = *bits;
-   for (max = MAXBITS; max >= 1; max--)
-      if (count[max] != 0) break;
-   if (root > max) root = max;
-   if (max == 0) {                     /* no symbols to code at all */
-      here.op = (unsigned char)64;    /* invalid code marker */
-      here.bits = (unsigned char)1;
-      here.val = (unsigned short)0;
-      *(*table)++ = here;             /* make a table to force an error */
-      *(*table)++ = here;
-      *bits = 1;
-      return 0;     /* no symbols, but wait for decoding to report error */
-   }
-   for (min = 1; min < max; min++)
-      if (count[min] != 0) break;
-   if (root < min) root = min;
-
-   /* check for an over-subscribed or incomplete set of lengths */
-   left = 1;
-   for (len = 1; len <= MAXBITS; len++) {
-      left <<= 1;
-      left -= count[len];
-      if (left < 0) return -1;        /* over-subscribed */
-   }
-   if (left > 0 && (type == CODES || max != 1))
-      return -1;                      /* incomplete set */
-
-   /* generate offsets into symbol table for each length for sorting */
-   offs[1] = 0;
-   for (len = 1; len < MAXBITS; len++)
-      offs[len + 1] = offs[len] + count[len];
-
-   /* sort symbols by length, by symbol order within each length */
-   for (sym = 0; sym < codes; sym++)
-      if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
-
-   /*
-      Create and fill in decoding tables.  In this loop, the table being
-      filled is at next and has curr index bits.  The code being used is huff
-      with length len.  That code is converted to an index by dropping drop
-      bits off of the bottom.  For codes where len is less than drop + curr,
-      those top drop + curr - len bits are incremented through all values to
-      fill the table with replicated entries.
-
-      root is the number of index bits for the root table.  When len exceeds
-      root, sub-tables are created pointed to by the root entry with an index
-      of the low root bits of huff.  This is saved in low to check for when a
-      new sub-table should be started.  drop is zero when the root table is
-      being filled, and drop is root when sub-tables are being filled.
-
-      When a new sub-table is needed, it is necessary to look ahead in the
-      code lengths to determine what size sub-table is needed.  The length
-      counts are used for this, and so count[] is decremented as codes are
-      entered in the tables.
-
-      used keeps track of how many table entries have been allocated from the
-      provided *table space.  It is checked for LENS and DIST tables against
-      the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
-      the initial root table size constants.  See the comments in inftrees.h
-      for more information.
-
-      sym increments through all symbols, and the loop terminates when
-      all codes of length max, i.e. all codes, have been processed.  This
-      routine permits incomplete codes, so another loop after this one fills
-      in the rest of the decoding tables with invalid code markers.
-      */
-
-   /* set up for code type */
-   switch (type) {
-      case CODES:
-         base = extra = work;    /* dummy value--not used */
-         end = 19;
-         break;
-      case LENS:
-         base = lbase;
-         base -= 257;
-         extra = lext;
-         extra -= 257;
-         end = 256;
-         break;
-      default:            /* DISTS */
-         base = dbase;
-         extra = dext;
-         end = -1;
-   }
-
-   /* initialize state for loop */
-   huff = 0;                   /* starting code */
-   sym = 0;                    /* starting code symbol */
-   len = min;                  /* starting code length */
-   next = *table;              /* current table to fill in */
-   curr = root;                /* current table index bits */
-   drop = 0;                   /* current bits to drop from code for index */
-   low = (unsigned)(-1);       /* trigger new sub-table when len > root */
-   used = 1U << root;          /* use root table entries */
-   mask = used - 1;            /* mask for comparing low */
-
-   /* check available table space */
-   if ((type == LENS && used > ENOUGH_LENS) ||
-         (type == DISTS && used > ENOUGH_DISTS))
-      return 1;
-
-   /* process all codes and make table entries */
-   for (;;) {
-      /* create table entry */
-      here.bits = (unsigned char)(len - drop);
-      if ((int)(work[sym]) < end) {
-         here.op = (unsigned char)0;
-         here.val = work[sym];
-      }
-      else if ((int)(work[sym]) > end) {
-         here.op = (unsigned char)(extra[work[sym]]);
-         here.val = base[work[sym]];
-      }
-      else {
-         here.op = (unsigned char)(32 + 64);         /* end of block */
-         here.val = 0;
-      }
-
-      /* replicate for those indices with low len bits equal to huff */
-      incr = 1U << (len - drop);
-      fill = 1U << curr;
-      min = fill;                 /* save offset to next table */
-      do {
-         fill -= incr;
-         next[(huff >> drop) + fill] = here;
-      } while (fill != 0);
-
-      /* backwards increment the len-bit code huff */
-      incr = 1U << (len - 1);
-      while (huff & incr)
-         incr >>= 1;
-      if (incr != 0) {
-         huff &= incr - 1;
-         huff += incr;
-      }
-      else
-         huff = 0;
-
-      /* go to next symbol, update count, len */
-      sym++;
-      if (--(count[len]) == 0) {
-         if (len == max) break;
-         len = lens[work[sym]];
-      }
-
-      /* create new sub-table if needed */
-      if (len > root && (huff & mask) != low) {
-         /* if first time, transition to sub-tables */
-         if (drop == 0)
-            drop = root;
-
-         /* increment past last table */
-         next += min;            /* here min is 1 << curr */
-
-         /* determine length of next table */
-         curr = len - drop;
-         left = (int)(1 << curr);
-         while (curr + drop < max) {
-            left -= count[curr + drop];
-            if (left <= 0) break;
-            curr++;
-            left <<= 1;
-         }
-
-         /* check for enough space */
-         used += 1U << curr;
-         if ((type == LENS && used > ENOUGH_LENS) ||
-               (type == DISTS && used > ENOUGH_DISTS))
-            return 1;
-
-         /* point entry in root table to sub-table */
-         low = huff & mask;
-         (*table)[low].op = (unsigned char)curr;
-         (*table)[low].bits = (unsigned char)root;
-         (*table)[low].val = (unsigned short)(next - *table);
-      }
-   }
-
-   /* fill in remaining table entry if code is incomplete (guaranteed to have
-      at most one remaining entry, since if the code is incomplete, the
-      maximum code length that was allowed to get this far is one bit) */
-   if (huff != 0) {
-      here.op = (unsigned char)64;            /* invalid code marker */
-      here.bits = (unsigned char)(len - drop);
-      here.val = (unsigned short)0;
-      next[huff] = here;
-   }
-
-   /* set return parameters */
-   *table += used;
-   *bits = root;
-   return 0;
-}
diff --git a/deps/zlib/inftrees.h b/deps/zlib/inftrees.h
deleted file mode 100644 (file)
index cd9e67c..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/* inftrees.h -- header to use inftrees.c
- * Copyright (C) 1995-2005, 2010 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
-   part of the implementation of the compression library and is
-   subject to change. Applications should only use zlib.h.
- */
-
-#ifndef _INFTREES_H
-#define _INFTREES_H
-
-/* Structure for decoding tables.  Each entry provides either the
-   information needed to do the operation requested by the code that
-   indexed that table entry, or it provides a pointer to another
-   table that indexes more bits of the code.  op indicates whether
-   the entry is a pointer to another table, a literal, a length or
-   distance, an end-of-block, or an invalid code.  For a table
-   pointer, the low four bits of op is the number of index bits of
-   that table.  For a length or distance, the low four bits of op
-   is the number of extra bits to get after the code.  bits is
-   the number of bits in this code or part of the code to drop off
-   of the bit buffer.  val is the actual byte to output in the case
-   of a literal, the base length or distance, or the offset from
-   the current table to the next table.  Each entry is four bytes. */
-typedef struct {
-    unsigned char op;           /* operation, extra bits, table bits */
-    unsigned char bits;         /* bits in this part of the code */
-    unsigned short val;         /* offset in table or code value */
-} code;
-
-/* op values as set by inflate_table():
-    00000000 - literal
-    0000tttt - table link, tttt != 0 is the number of table index bits
-    0001eeee - length or distance, eeee is the number of extra bits
-    01100000 - end of block
-    01000000 - invalid code
- */
-
-/* Maximum size of the dynamic table.  The maximum number of code structures is
-   1444, which is the sum of 852 for literal/length codes and 592 for distance
-   codes.  These values were found by exhaustive searches using the program
-   examples/enough.c found in the zlib distribtution.  The arguments to that
-   program are the number of symbols, the initial root table size, and the
-   maximum bit length of a code.  "enough 286 9 15" for literal/length codes
-   returns returns 852, and "enough 30 6 15" for distance codes returns 592.
-   The initial root table size (9 or 6) is found in the fifth argument of the
-   inflate_table() calls in inflate.c and infback.c.  If the root table size is
-   changed, then these maximum sizes would be need to be recalculated and
-   updated. */
-#define ENOUGH_LENS 852
-#define ENOUGH_DISTS 592
-#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
-
-/* Type of code to build for inflate_table() */
-typedef enum {
-    CODES,
-    LENS,
-    DISTS
-} codetype;
-
-int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens,
-                             unsigned codes, code FAR * FAR *table,
-                             unsigned FAR *bits, unsigned short FAR *work));
-
-#endif
diff --git a/deps/zlib/ioapi.c b/deps/zlib/ioapi.c
deleted file mode 100644 (file)
index 767ac2f..0000000
+++ /dev/null
@@ -1,236 +0,0 @@
-/* ioapi.h -- IO base function header for compress/uncompress .zip
-   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
-
-   Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
-
-   Modifications for Zip64 support
-   Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
-
-   For more info read MiniZip_info.txt
-
-*/
-
-#ifdef _WIN32
-#ifndef _CRT_SECURE_NO_WARNINGS
-#define _CRT_SECURE_NO_WARNINGS
-#endif
-#endif
-
-#include "ioapi.h"
-
-voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)
-{
-   if (pfilefunc->zfile_func64.zopen64_file != NULL)
-      return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode);
-   else
-   {
-      return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode);
-   }
-}
-
-long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)
-{
-   if (pfilefunc->zfile_func64.zseek64_file != NULL)
-      return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
-   else
-   {
-      uLong offsetTruncated = (uLong)offset;
-      if (offsetTruncated != offset)
-         return -1;
-      else
-         return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin);
-   }
-}
-
-ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)
-{
-   if (pfilefunc->zfile_func64.zseek64_file != NULL)
-      return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
-   else
-   {
-      uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
-      if ((tell_uLong) == ((uLong)-1))
-         return (ZPOS64_T)-1;
-      else
-         return tell_uLong;
-   }
-}
-
-void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32)
-{
-   p_filefunc64_32->zfile_func64.zopen64_file = NULL;
-   p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file;
-   p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
-   p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;
-   p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;
-   p_filefunc64_32->zfile_func64.ztell64_file = NULL;
-   p_filefunc64_32->zfile_func64.zseek64_file = NULL;
-   p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file;
-   p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
-   p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque;
-   p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file;
-   p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file;
-}
-
-
-
-static voidpf  ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode));
-static uLong   ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
-static uLong   ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size));
-static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream));
-static long    ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
-static int     ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream));
-static int     ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));
-
-static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
-{
-   FILE* file = NULL;
-   const char* mode_fopen = NULL;
-   if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
-      mode_fopen = "rb";
-   else
-      if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
-         mode_fopen = "r+b";
-      else
-         if (mode & ZLIB_FILEFUNC_MODE_CREATE)
-            mode_fopen = "wb";
-
-   if ((filename!=NULL) && (mode_fopen != NULL))
-      file = fopen(filename, mode_fopen);
-   return file;
-}
-
-static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode)
-{
-   FILE* file = NULL;
-   const char* mode_fopen = NULL;
-   if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
-      mode_fopen = "rb";
-   else
-      if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
-         mode_fopen = "r+b";
-      else
-         if (mode & ZLIB_FILEFUNC_MODE_CREATE)
-            mode_fopen = "wb";
-
-   if ((filename!=NULL) && (mode_fopen != NULL))
-      file = fopen((const char*)filename, mode_fopen);
-   return file;
-}
-
-
-static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
-{
-   uLong ret;
-   ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
-   return ret;
-}
-
-static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)
-{
-   uLong ret;
-   ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
-   return ret;
-}
-
-static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
-{
-   long ret;
-   ret = ftell((FILE *)stream);
-   return ret;
-}
-
-
-static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
-{
-   ZPOS64_T ret;
-   ret = ftell((FILE *)stream);
-   return ret;
-}
-
-static long ZCALLBACK fseek_file_func (voidpf  opaque, voidpf stream, uLong offset, int origin)
-{
-   int fseek_origin=0;
-   long ret;
-   switch (origin)
-   {
-      case ZLIB_FILEFUNC_SEEK_CUR :
-         fseek_origin = SEEK_CUR;
-         break;
-      case ZLIB_FILEFUNC_SEEK_END :
-         fseek_origin = SEEK_END;
-         break;
-      case ZLIB_FILEFUNC_SEEK_SET :
-         fseek_origin = SEEK_SET;
-         break;
-      default: return -1;
-   }
-   ret = 0;
-   if (fseek((FILE *)stream, offset, fseek_origin) != 0)
-      ret = -1;
-   return ret;
-}
-
-static long ZCALLBACK fseek64_file_func (voidpf  opaque, voidpf stream, ZPOS64_T offset, int origin)
-{
-   int fseek_origin=0;
-   long ret;
-   switch (origin)
-   {
-      case ZLIB_FILEFUNC_SEEK_CUR :
-         fseek_origin = SEEK_CUR;
-         break;
-      case ZLIB_FILEFUNC_SEEK_END :
-         fseek_origin = SEEK_END;
-         break;
-      case ZLIB_FILEFUNC_SEEK_SET :
-         fseek_origin = SEEK_SET;
-         break;
-      default: return -1;
-   }
-   ret = 0;
-
-   if(fseek((FILE *)stream, (long)offset, fseek_origin) != 0)
-      ret = -1;
-
-   return ret;
-}
-
-
-static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
-{
-   int ret;
-   ret = fclose((FILE *)stream);
-   return ret;
-}
-
-static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
-{
-   int ret;
-   ret = ferror((FILE *)stream);
-   return ret;
-}
-
-void fill_fopen_filefunc (zlib_filefunc_def *pzlib_filefunc_def)
-{
-   pzlib_filefunc_def->zopen_file = fopen_file_func;
-   pzlib_filefunc_def->zread_file = fread_file_func;
-   pzlib_filefunc_def->zwrite_file = fwrite_file_func;
-   pzlib_filefunc_def->ztell_file = ftell_file_func;
-   pzlib_filefunc_def->zseek_file = fseek_file_func;
-   pzlib_filefunc_def->zclose_file = fclose_file_func;
-   pzlib_filefunc_def->zerror_file = ferror_file_func;
-   pzlib_filefunc_def->opaque = NULL;
-}
-
-void fill_fopen64_filefunc (zlib_filefunc64_def*  pzlib_filefunc_def)
-{
-   pzlib_filefunc_def->zopen64_file = fopen64_file_func;
-   pzlib_filefunc_def->zread_file = fread_file_func;
-   pzlib_filefunc_def->zwrite_file = fwrite_file_func;
-   pzlib_filefunc_def->ztell64_file = ftell64_file_func;
-   pzlib_filefunc_def->zseek64_file = fseek64_file_func;
-   pzlib_filefunc_def->zclose_file = fclose_file_func;
-   pzlib_filefunc_def->zerror_file = ferror_file_func;
-   pzlib_filefunc_def->opaque = NULL;
-}
diff --git a/deps/zlib/ioapi.h b/deps/zlib/ioapi.h
deleted file mode 100644 (file)
index 8309c4c..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-/* ioapi.h -- IO base function header for compress/uncompress .zip
-   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Modifications for Zip64 support
-         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
-
-         For more info read MiniZip_info.txt
-
-         Changes
-
-    Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this)
-    Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux.
-               More if/def section may be needed to support other platforms
-    Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows.
-                          (but you should use iowin32.c for windows instead)
-
-*/
-
-#ifndef _ZLIBIOAPI64_H
-#define _ZLIBIOAPI64_H
-
-#if (!defined(_WIN32)) && (!defined(WIN32))
-
-  // Linux needs this to support file operation on files larger then 4+GB
-  // But might need better if/def to select just the platforms that needs them.
-
-        #ifndef __USE_FILE_OFFSET64
-                #define __USE_FILE_OFFSET64
-        #endif
-        #ifndef __USE_LARGEFILE64
-                #define __USE_LARGEFILE64
-        #endif
-        #ifndef _LARGEFILE64_SOURCE
-                #define _LARGEFILE64_SOURCE
-        #endif
-        #ifndef _FILE_OFFSET_BIT
-                #define _FILE_OFFSET_BIT 64
-        #endif
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "zlib.h"
-
-#if defined(USE_FILE32API)
-#define fopen64 fopen
-#define ftello64 ftell
-#define fseeko64 fseek
-#else
-#ifdef _MSC_VER
- #define fopen64 fopen
- #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))
-  #define ftello64 _ftelli64
-  #define fseeko64 _fseeki64
- #else // old MSC
-  #define ftello64 ftell
-  #define fseeko64 fseek
- #endif
-#endif
-#endif
-
-/*
-#ifndef ZPOS64_T
-  #ifdef _WIN32
-                #define ZPOS64_T fpos_t
-  #else
-    #include <stdint.h>
-    #define ZPOS64_T uint64_t
-  #endif
-#endif
-*/
-
-#ifdef HAVE_MINIZIP64_CONF_H
-#include "mz64conf.h"
-#endif
-
-/* a type choosen by DEFINE */
-#ifdef HAVE_64BIT_INT_CUSTOM
-typedef  64BIT_INT_CUSTOM_TYPE ZPOS64_T;
-#else
-#ifdef HAS_STDINT_H
-#include "stdint.h"
-typedef uint64_t ZPOS64_T;
-#else
-
-
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-typedef unsigned __int64 ZPOS64_T;
-#else
-typedef unsigned long long int ZPOS64_T;
-#endif
-#endif
-#endif
-
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#define ZLIB_FILEFUNC_SEEK_CUR (1)
-#define ZLIB_FILEFUNC_SEEK_END (2)
-#define ZLIB_FILEFUNC_SEEK_SET (0)
-
-#define ZLIB_FILEFUNC_MODE_READ      (1)
-#define ZLIB_FILEFUNC_MODE_WRITE     (2)
-#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
-
-#define ZLIB_FILEFUNC_MODE_EXISTING (4)
-#define ZLIB_FILEFUNC_MODE_CREATE   (8)
-
-
-#ifndef ZCALLBACK
- #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
-   #define ZCALLBACK CALLBACK
- #else
-   #define ZCALLBACK
- #endif
-#endif
-
-
-
-
-typedef voidpf   (ZCALLBACK *open_file_func)      OF((voidpf opaque, const char* filename, int mode));
-typedef uLong    (ZCALLBACK *read_file_func)      OF((voidpf opaque, voidpf stream, void* buf, uLong size));
-typedef uLong    (ZCALLBACK *write_file_func)     OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
-typedef int      (ZCALLBACK *close_file_func)     OF((voidpf opaque, voidpf stream));
-typedef int      (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
-
-typedef long     (ZCALLBACK *tell_file_func)      OF((voidpf opaque, voidpf stream));
-typedef long     (ZCALLBACK *seek_file_func)      OF((voidpf opaque, voidpf stream, uLong offset, int origin));
-
-
-/* here is the "old" 32 bits structure structure */
-typedef struct zlib_filefunc_def_s
-{
-    open_file_func      zopen_file;
-    read_file_func      zread_file;
-    write_file_func     zwrite_file;
-    tell_file_func      ztell_file;
-    seek_file_func      zseek_file;
-    close_file_func     zclose_file;
-    testerror_file_func zerror_file;
-    voidpf              opaque;
-} zlib_filefunc_def;
-
-typedef ZPOS64_T (ZCALLBACK *tell64_file_func)    OF((voidpf opaque, voidpf stream));
-typedef long     (ZCALLBACK *seek64_file_func)    OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
-typedef voidpf   (ZCALLBACK *open64_file_func)    OF((voidpf opaque, const void* filename, int mode));
-
-typedef struct zlib_filefunc64_def_s
-{
-    open64_file_func    zopen64_file;
-    read_file_func      zread_file;
-    write_file_func     zwrite_file;
-    tell64_file_func    ztell64_file;
-    seek64_file_func    zseek64_file;
-    close_file_func     zclose_file;
-    testerror_file_func zerror_file;
-    voidpf              opaque;
-} zlib_filefunc64_def;
-
-void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
-void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
-
-/* now internal definition, only for zip.c and unzip.h */
-typedef struct zlib_filefunc64_32_def_s
-{
-    zlib_filefunc64_def zfile_func64;
-    open_file_func      zopen32_file;
-    tell_file_func      ztell32_file;
-    seek_file_func      zseek32_file;
-} zlib_filefunc64_32_def;
-
-
-#define ZREAD64(filefunc,filestream,buf,size)     ((*((filefunc).zfile_func64.zread_file))   ((filefunc).zfile_func64.opaque,filestream,buf,size))
-#define ZWRITE64(filefunc,filestream,buf,size)    ((*((filefunc).zfile_func64.zwrite_file))  ((filefunc).zfile_func64.opaque,filestream,buf,size))
-//#define ZTELL64(filefunc,filestream)            ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))
-//#define ZSEEK64(filefunc,filestream,pos,mode)   ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))
-#define ZCLOSE64(filefunc,filestream)             ((*((filefunc).zfile_func64.zclose_file))  ((filefunc).zfile_func64.opaque,filestream))
-#define ZERROR64(filefunc,filestream)             ((*((filefunc).zfile_func64.zerror_file))  ((filefunc).zfile_func64.opaque,filestream))
-
-voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));
-long    call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));
-ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));
-
-void    fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
-
-#define ZOPEN64(filefunc,filename,mode)         (call_zopen64((&(filefunc)),(filename),(mode)))
-#define ZTELL64(filefunc,filestream)            (call_ztell64((&(filefunc)),(filestream)))
-#define ZSEEK64(filefunc,filestream,pos,mode)   (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/deps/zlib/trees.c b/deps/zlib/trees.c
deleted file mode 100644 (file)
index fa41a13..0000000
+++ /dev/null
@@ -1,1177 +0,0 @@
-/* trees.c -- output deflated data using Huffman coding
- * Copyright (C) 1995-2012 Jean-loup Gailly
- * detect_data_type() function provided freely by Cosmin Truta, 2006
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- *  ALGORITHM
- *
- *      The "deflation" process uses several Huffman trees. The more
- *      common source values are represented by shorter bit sequences.
- *
- *      Each code tree is stored in a compressed form which is itself
- * a Huffman encoding of the lengths of all the code strings (in
- * ascending order by source values).  The actual code strings are
- * reconstructed from the lengths in the inflate process, as described
- * in the deflate specification.
- *
- *  REFERENCES
- *
- *      Deutsch, L.P.,"'Deflate' Compressed Data Format Specification".
- *      Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc
- *
- *      Storer, James A.
- *          Data Compression:  Methods and Theory, pp. 49-50.
- *          Computer Science Press, 1988.  ISBN 0-7167-8156-5.
- *
- *      Sedgewick, R.
- *          Algorithms, p290.
- *          Addison-Wesley, 1983. ISBN 0-201-06672-6.
- */
-
-/* @(#) $Id$ */
-
-/* #define GEN_TREES_H */
-
-#include "deflate.h"
-
-#ifdef DEBUG
-#  include <ctype.h>
-#endif
-
-/* ===========================================================================
- * Constants
- */
-
-#define MAX_BL_BITS 7
-/* Bit length codes must not exceed MAX_BL_BITS bits */
-
-#define END_BLOCK 256
-/* end of block literal code */
-
-#define REP_3_6      16
-/* repeat previous bit length 3-6 times (2 bits of repeat count) */
-
-#define REPZ_3_10    17
-/* repeat a zero length 3-10 times  (3 bits of repeat count) */
-
-#define REPZ_11_138  18
-/* repeat a zero length 11-138 times  (7 bits of repeat count) */
-
-local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
-= {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
-
-local const int extra_dbits[D_CODES] /* extra bits for each distance code */
-= {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
-
-local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */
-= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
-
-local const uch bl_order[BL_CODES]
-= {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
-/* The lengths of the bit length codes are sent in order of decreasing
- * probability, to avoid transmitting the lengths for unused bit length codes.
- */
-
-/* ===========================================================================
- * Local data. These are initialized only once.
- */
-
-#define DIST_CODE_LEN  512 /* see definition of array dist_code below */
-
-#if defined(GEN_TREES_H) || !defined(STDC)
-/* non ANSI compilers may not accept trees.h */
-
-local ct_data static_ltree[L_CODES+2];
-/* The static literal tree. Since the bit lengths are imposed, there is no
- * need for the L_CODES extra codes used during heap construction. However
- * The codes 286 and 287 are needed to build a canonical tree (see _tr_init
- * below).
- */
-
-local ct_data static_dtree[D_CODES];
-/* The static distance tree. (Actually a trivial tree since all codes use
- * 5 bits.)
- */
-
-uch _dist_code[DIST_CODE_LEN];
-/* Distance codes. The first 256 values correspond to the distances
- * 3 .. 258, the last 256 values correspond to the top 8 bits of
- * the 15 bit distances.
- */
-
-uch _length_code[MAX_MATCH-MIN_MATCH+1];
-/* length code for each normalized match length (0 == MIN_MATCH) */
-
-local int base_length[LENGTH_CODES];
-/* First normalized length for each code (0 = MIN_MATCH) */
-
-local int base_dist[D_CODES];
-/* First normalized distance for each code (0 = distance of 1) */
-
-#else
-#  include "trees.h"
-#endif /* GEN_TREES_H */
-
-struct static_tree_desc_s {
-   const ct_data *static_tree;  /* static tree or NULL */
-   const intf *extra_bits;      /* extra bits for each code or NULL */
-   int     extra_base;          /* base index for extra_bits */
-   int     elems;               /* max number of elements in the tree */
-   int     max_length;          /* max bit length for the codes */
-};
-
-local static_tree_desc  static_l_desc =
-{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
-
-local static_tree_desc  static_d_desc =
-{static_dtree, extra_dbits, 0,          D_CODES, MAX_BITS};
-
-local static_tree_desc  static_bl_desc =
-{(const ct_data *)0, extra_blbits, 0,   BL_CODES, MAX_BL_BITS};
-
-/* ===========================================================================
- * Local (static) routines in this file.
- */
-
-local void tr_static_init OF((void));
-local void init_block     OF((deflate_state *s));
-local void pqdownheap     OF((deflate_state *s, ct_data *tree, int k));
-local void gen_bitlen     OF((deflate_state *s, tree_desc *desc));
-local void gen_codes      OF((ct_data *tree, int max_code, ushf *bl_count));
-local void build_tree     OF((deflate_state *s, tree_desc *desc));
-local void scan_tree      OF((deflate_state *s, ct_data *tree, int max_code));
-local void send_tree      OF((deflate_state *s, ct_data *tree, int max_code));
-local int  build_bl_tree  OF((deflate_state *s));
-local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
-         int blcodes));
-local void compress_block OF((deflate_state *s, const ct_data *ltree,
-         const ct_data *dtree));
-local int  detect_data_type OF((deflate_state *s));
-local unsigned bi_reverse OF((unsigned value, int length));
-local void bi_windup      OF((deflate_state *s));
-local void bi_flush       OF((deflate_state *s));
-local void copy_block     OF((deflate_state *s, charf *buf, unsigned len,
-         int header));
-
-#ifdef GEN_TREES_H
-local void gen_trees_header OF((void));
-#endif
-
-#ifndef DEBUG
-#  define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
-/* Send a code of the given tree. c and tree must not have side effects */
-
-#else /* DEBUG */
-#  define send_code(s, c, tree) \
-{ if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
-   send_bits(s, tree[c].Code, tree[c].Len); }
-#endif
-
-/* ===========================================================================
- * Output a short LSB first on the stream.
- * IN assertion: there is enough room in pendingBuf.
- */
-#define put_short(s, w) { \
-   put_byte(s, (uch)((w) & 0xff)); \
-   put_byte(s, (uch)((ush)(w) >> 8)); \
-}
-
-/* ===========================================================================
- * Send a value on a given number of bits.
- * IN assertion: length <= 16 and value fits in length bits.
- */
-#ifdef DEBUG
-local void send_bits      OF((deflate_state *s, int value, int length));
-
-local void send_bits(deflate_state *s, int value, int length)
-{
-   Tracevv((stderr," l %2d v %4x ", length, value));
-   Assert(length > 0 && length <= 15, "invalid length");
-   s->bits_sent += (ulg)length;
-
-   /* If not enough room in bi_buf, use (valid) bits from bi_buf and
-    * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
-    * unused bits in value.
-    */
-   if (s->bi_valid > (int)Buf_size - length) {
-      s->bi_buf |= (ush)value << s->bi_valid;
-      put_short(s, s->bi_buf);
-      s->bi_buf = (ush)value >> (Buf_size - s->bi_valid);
-      s->bi_valid += length - Buf_size;
-   } else {
-      s->bi_buf |= (ush)value << s->bi_valid;
-      s->bi_valid += length;
-   }
-}
-#else /* !DEBUG */
-
-#define send_bits(s, value, length) \
-{ int len = length;\
-   if (s->bi_valid > (int)Buf_size - len) {\
-      int val = value;\
-      s->bi_buf |= (ush)val << s->bi_valid;\
-      put_short(s, s->bi_buf);\
-      s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
-      s->bi_valid += len - Buf_size;\
-   } else {\
-      s->bi_buf |= (ush)(value) << s->bi_valid;\
-      s->bi_valid += len;\
-   }\
-}
-#endif /* DEBUG */
-
-
-/* the arguments must not have side effects */
-
-/* ===========================================================================
- * Initialize the various 'constant' tables.
- */
-local void tr_static_init(void)
-{
-#if defined(GEN_TREES_H) || !defined(STDC)
-   static int static_init_done = 0;
-   int n;        /* iterates over tree elements */
-   int bits;     /* bit counter */
-   int length;   /* length value */
-   int codes;    /* code value */
-   int dist;     /* distance index */
-   ush bl_count[MAX_BITS+1];
-   /* number of codes at each bit length for an optimal tree */
-
-   if (static_init_done) return;
-
-   /* For some embedded targets, global variables are not initialized: */
-#ifdef NO_INIT_GLOBAL_POINTERS
-   static_l_desc.static_tree = static_ltree;
-   static_l_desc.extra_bits = extra_lbits;
-   static_d_desc.static_tree = static_dtree;
-   static_d_desc.extra_bits = extra_dbits;
-   static_bl_desc.extra_bits = extra_blbits;
-#endif
-
-   /* Initialize the mapping length (0..255) -> length code (0..28) */
-   length = 0;
-   for (codes = 0; codes < LENGTH_CODES-1; codes++) {
-      base_length[codes] = length;
-      for (n = 0; n < (1<<extra_lbits[codes]); n++) {
-         _length_code[length++] = (uch)codes;
-      }
-   }
-   Assert (length == 256, "tr_static_init: length != 256");
-   /* Note that the length 255 (match length 258) can be represented
-    * in two different ways: code 284 + 5 bits or code 285, so we
-    * overwrite length_code[255] to use the best encoding:
-    */
-   _length_code[length-1] = (uch)codes;
-
-   /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
-   dist = 0;
-   for (codes = 0 ; codes < 16; codes++) {
-      base_dist[codes] = dist;
-      for (n = 0; n < (1<<extra_dbits[codes]); n++) {
-         _dist_code[dist++] = (uch)codes;
-      }
-   }
-   Assert (dist == 256, "tr_static_init: dist != 256");
-   dist >>= 7; /* from now on, all distances are divided by 128 */
-   for ( ; codes < D_CODES; codes++) {
-      base_dist[codes] = dist << 7;
-      for (n = 0; n < (1<<(extra_dbits[codes]-7)); n++) {
-         _dist_code[256 + dist++] = (uch)codes;
-      }
-   }
-   Assert (dist == 256, "tr_static_init: 256+dist != 512");
-
-   /* Construct the codes of the static literal tree */
-   for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
-   n = 0;
-   while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++;
-   while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++;
-   while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++;
-   while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++;
-   /* Codes 286 and 287 do not exist, but we must include them in the
-    * tree construction to get a canonical Huffman tree (longest code
-    * all ones)
-    */
-   gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count);
-
-   /* The static distance tree is trivial: */
-   for (n = 0; n < D_CODES; n++) {
-      static_dtree[n].Len = 5;
-      static_dtree[n].Code = bi_reverse((unsigned)n, 5);
-   }
-   static_init_done = 1;
-
-#  ifdef GEN_TREES_H
-   gen_trees_header();
-#  endif
-#endif /* defined(GEN_TREES_H) || !defined(STDC) */
-}
-
-/* ===========================================================================
- * Genererate the file trees.h describing the static trees.
- */
-#ifdef GEN_TREES_H
-#  ifndef DEBUG
-#    include <stdio.h>
-#  endif
-
-#  define SEPARATOR(i, last, width) \
-   ((i) == (last)? "\n};\n\n" :    \
-    ((i) % (width) == (width)-1 ? ",\n" : ", "))
-
-void gen_trees_header(void)
-{
-   FILE *header = fopen("trees.h", "w");
-   int i;
-
-   Assert (header != NULL, "Can't open trees.h");
-   fprintf(header,
-         "/* header created automatically with -DGEN_TREES_H */\n\n");
-
-   fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n");
-   for (i = 0; i < L_CODES+2; i++) {
-      fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code,
-            static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5));
-   }
-
-   fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n");
-   for (i = 0; i < D_CODES; i++) {
-      fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code,
-            static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
-   }
-
-   fprintf(header, "const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {\n");
-   for (i = 0; i < DIST_CODE_LEN; i++) {
-      fprintf(header, "%2u%s", _dist_code[i],
-            SEPARATOR(i, DIST_CODE_LEN-1, 20));
-   }
-
-   fprintf(header,
-         "const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
-   for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {
-      fprintf(header, "%2u%s", _length_code[i],
-            SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
-   }
-
-   fprintf(header, "local const int base_length[LENGTH_CODES] = {\n");
-   for (i = 0; i < LENGTH_CODES; i++) {
-      fprintf(header, "%1u%s", base_length[i],
-            SEPARATOR(i, LENGTH_CODES-1, 20));
-   }
-
-   fprintf(header, "local const int base_dist[D_CODES] = {\n");
-   for (i = 0; i < D_CODES; i++) {
-      fprintf(header, "%5u%s", base_dist[i],
-            SEPARATOR(i, D_CODES-1, 10));
-   }
-
-   fclose(header);
-}
-#endif /* GEN_TREES_H */
-
-/* ===========================================================================
- * Initialize the tree data structures for a new zlib stream.
- */
-void ZLIB_INTERNAL _tr_init(deflate_state *s)
-{
-   tr_static_init();
-
-   s->l_desc.dyn_tree = s->dyn_ltree;
-   s->l_desc.stat_desc = &static_l_desc;
-
-   s->d_desc.dyn_tree = s->dyn_dtree;
-   s->d_desc.stat_desc = &static_d_desc;
-
-   s->bl_desc.dyn_tree = s->bl_tree;
-   s->bl_desc.stat_desc = &static_bl_desc;
-
-   s->bi_buf = 0;
-   s->bi_valid = 0;
-#ifdef DEBUG
-   s->compressed_len = 0L;
-   s->bits_sent = 0L;
-#endif
-
-   /* Initialize the first block of the first file: */
-   init_block(s);
-}
-
-/* ===========================================================================
- * Initialize a new block.
- */
-local void init_block(deflate_state *s)
-{
-   int n; /* iterates over tree elements */
-
-   /* Initialize the trees. */
-   for (n = 0; n < L_CODES;  n++) s->dyn_ltree[n].Freq = 0;
-   for (n = 0; n < D_CODES;  n++) s->dyn_dtree[n].Freq = 0;
-   for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
-
-   s->dyn_ltree[END_BLOCK].Freq = 1;
-   s->opt_len = s->static_len = 0L;
-   s->last_lit = s->matches = 0;
-}
-
-#define SMALLEST 1
-/* Index within the heap array of least frequent node in the Huffman tree */
-
-
-/* ===========================================================================
- * Remove the smallest element from the heap and recreate the heap with
- * one less element. Updates heap and heap_len.
- */
-#define pqremove(s, tree, top) \
-{\
-   top = s->heap[SMALLEST]; \
-   s->heap[SMALLEST] = s->heap[s->heap_len--]; \
-   pqdownheap(s, tree, SMALLEST); \
-}
-
-/* ===========================================================================
- * Compares to subtrees, using the tree depth as tie breaker when
- * the subtrees have equal frequency. This minimizes the worst case length.
- */
-#define smaller(tree, n, m, depth) \
-   (tree[n].Freq < tree[m].Freq || \
-    (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
-
-/* ===========================================================================
- * Restore the heap property by moving down the tree starting at node k,
- * exchanging a node with the smallest of its two sons if necessary, stopping
- * when the heap property is re-established (each father smaller than its
- * two sons).
- */
-local void pqdownheap(deflate_state *s, ct_data *tree, int k)
-{
-   int v = s->heap[k];
-   int j = k << 1;  /* left son of k */
-   while (j <= s->heap_len) {
-      /* Set j to the smallest of the two sons: */
-      if (j < s->heap_len &&
-            smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {
-         j++;
-      }
-      /* Exit if v is smaller than both sons */
-      if (smaller(tree, v, s->heap[j], s->depth)) break;
-
-      /* Exchange v with the smallest son */
-      s->heap[k] = s->heap[j];  k = j;
-
-      /* And continue down the tree, setting j to the left son of k */
-      j <<= 1;
-   }
-   s->heap[k] = v;
-}
-
-/* ===========================================================================
- * Compute the optimal bit lengths for a tree and update the total bit length
- * for the current block.
- * IN assertion: the fields freq and dad are set, heap[heap_max] and
- *    above are the tree nodes sorted by increasing frequency.
- * OUT assertions: the field len is set to the optimal bit length, the
- *     array bl_count contains the frequencies for each bit length.
- *     The length opt_len is updated; static_len is also updated if stree is
- *     not null.
- */
-local void gen_bitlen(deflate_state *s, tree_desc *desc)
-{
-   ct_data *tree        = desc->dyn_tree;
-   int max_code         = desc->max_code;
-   const ct_data *stree = desc->stat_desc->static_tree;
-   const intf *extra    = desc->stat_desc->extra_bits;
-   int base             = desc->stat_desc->extra_base;
-   int max_length       = desc->stat_desc->max_length;
-   int h;              /* heap index */
-   int n, m;           /* iterate over the tree elements */
-   int bits;           /* bit length */
-   int xbits;          /* extra bits */
-   ush f;              /* frequency */
-   int overflow = 0;   /* number of elements with bit length too large */
-
-   for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0;
-
-   /* In a first pass, compute the optimal bit lengths (which may
-    * overflow in the case of the bit length tree).
-    */
-   tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
-
-   for (h = s->heap_max+1; h < HEAP_SIZE; h++) {
-      n = s->heap[h];
-      bits = tree[tree[n].Dad].Len + 1;
-      if (bits > max_length) bits = max_length, overflow++;
-      tree[n].Len = (ush)bits;
-      /* We overwrite tree[n].Dad which is no longer needed */
-
-      if (n > max_code) continue; /* not a leaf node */
-
-      s->bl_count[bits]++;
-      xbits = 0;
-      if (n >= base) xbits = extra[n-base];
-      f = tree[n].Freq;
-      s->opt_len += (ulg)f * (bits + xbits);
-      if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);
-   }
-   if (overflow == 0) return;
-
-   Trace((stderr,"\nbit length overflow\n"));
-   /* This happens for example on obj2 and pic of the Calgary corpus */
-
-   /* Find the first bit length which could increase: */
-   do {
-      bits = max_length-1;
-      while (s->bl_count[bits] == 0) bits--;
-      s->bl_count[bits]--;      /* move one leaf down the tree */
-      s->bl_count[bits+1] += 2; /* move one overflow item as its brother */
-      s->bl_count[max_length]--;
-      /* The brother of the overflow item also moves one step up,
-       * but this does not affect bl_count[max_length]
-       */
-      overflow -= 2;
-   } while (overflow > 0);
-
-   /* Now recompute all bit lengths, scanning in increasing frequency.
-    * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
-    * lengths instead of fixing only the wrong ones. This idea is taken
-    * from 'ar' written by Haruhiko Okumura.)
-    */
-   for (bits = max_length; bits != 0; bits--) {
-      n = s->bl_count[bits];
-      while (n != 0) {
-         m = s->heap[--h];
-         if (m > max_code) continue;
-         if ((unsigned) tree[m].Len != (unsigned) bits) {
-            Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
-            s->opt_len += ((long)bits - (long)tree[m].Len)
-               *(long)tree[m].Freq;
-            tree[m].Len = (ush)bits;
-         }
-         n--;
-      }
-   }
-}
-
-/* ===========================================================================
- * Generate the codes for a given tree and bit counts (which need not be
- * optimal).
- * IN assertion: the array bl_count contains the bit length statistics for
- * the given tree and the field len is set for all tree elements.
- * OUT assertion: the field code is set for all tree elements of non
- *     zero code length.
- */
-local void gen_codes (ct_data *tree, int max_code, ushf *bl_count)
-{
-   ush next_code[MAX_BITS+1]; /* next code value for each bit length */
-   ush codes = 0;              /* running code value */
-   int bits;                  /* bit index */
-   int n;                     /* code index */
-
-   /* The distribution counts are first used to generate the code values
-    * without bit reversal.
-    */
-   for (bits = 1; bits <= MAX_BITS; bits++) {
-      next_code[bits] = codes = (codes + bl_count[bits-1]) << 1;
-   }
-   /* Check that the bit counts in bl_count are consistent. The last code
-    * must be all ones.
-    */
-   Assert (codes + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
-         "inconsistent bit counts");
-   Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
-
-   for (n = 0;  n <= max_code; n++) {
-      int len = tree[n].Len;
-      if (len == 0) continue;
-      /* Now reverse the bits */
-      tree[n].Code = bi_reverse(next_code[len]++, len);
-
-      Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
-               n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
-   }
-}
-
-/* ===========================================================================
- * Construct one Huffman tree and assigns the code bit strings and lengths.
- * Update the total bit length for the current block.
- * IN assertion: the field freq is set for all tree elements.
- * OUT assertions: the fields len and code are set to the optimal bit length
- *     and corresponding code. The length opt_len is updated; static_len is
- *     also updated if stree is not null. The field max_code is set.
- */
-local void build_tree(deflate_state *s, tree_desc *desc)
-{
-   ct_data *tree         = desc->dyn_tree;
-   const ct_data *stree  = desc->stat_desc->static_tree;
-   int elems             = desc->stat_desc->elems;
-   int n, m;          /* iterate over heap elements */
-   int max_code = -1; /* largest code with non zero frequency */
-   int node;          /* new node being created */
-
-   /* Construct the initial heap, with least frequent element in
-    * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
-    * heap[0] is not used.
-    */
-   s->heap_len = 0, s->heap_max = HEAP_SIZE;
-
-   for (n = 0; n < elems; n++) {
-      if (tree[n].Freq != 0) {
-         s->heap[++(s->heap_len)] = max_code = n;
-         s->depth[n] = 0;
-      } else {
-         tree[n].Len = 0;
-      }
-   }
-
-   /* The pkzip format requires that at least one distance code exists,
-    * and that at least one bit should be sent even if there is only one
-    * possible code. So to avoid special checks later on we force at least
-    * two codes of non zero frequency.
-    */
-   while (s->heap_len < 2) {
-      node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);
-      tree[node].Freq = 1;
-      s->depth[node] = 0;
-      s->opt_len--; if (stree) s->static_len -= stree[node].Len;
-      /* node is 0 or 1 so it does not have extra bits */
-   }
-   desc->max_code = max_code;
-
-   /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
-    * establish sub-heaps of increasing lengths:
-    */
-   for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n);
-
-   /* Construct the Huffman tree by repeatedly combining the least two
-    * frequent nodes.
-    */
-   node = elems;              /* next internal node of the tree */
-   do {
-      pqremove(s, tree, n);  /* n = node of least frequency */
-      m = s->heap[SMALLEST]; /* m = node of next least frequency */
-
-      s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */
-      s->heap[--(s->heap_max)] = m;
-
-      /* Create a new node father of n and m */
-      tree[node].Freq = tree[n].Freq + tree[m].Freq;
-      s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ?
-               s->depth[n] : s->depth[m]) + 1);
-      tree[n].Dad = tree[m].Dad = (ush)node;
-#ifdef DUMP_BL_TREE
-      if (tree == s->bl_tree) {
-         fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)",
-               node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);
-      }
-#endif
-      /* and insert the new node in the heap */
-      s->heap[SMALLEST] = node++;
-      pqdownheap(s, tree, SMALLEST);
-
-   } while (s->heap_len >= 2);
-
-   s->heap[--(s->heap_max)] = s->heap[SMALLEST];
-
-   /* At this point, the fields freq and dad are set. We can now
-    * generate the bit lengths.
-    */
-   gen_bitlen(s, (tree_desc *)desc);
-
-   /* The field len is now set, we can generate the bit codes */
-   gen_codes ((ct_data *)tree, max_code, s->bl_count);
-}
-
-/* ===========================================================================
- * Scan a literal or distance tree to determine the frequencies of the codes
- * in the bit length tree.
- */
-local void scan_tree (deflate_state *s, ct_data *tree, int max_code)
-{
-   int n;                     /* iterates over all tree elements */
-   int prevlen = -1;          /* last emitted length */
-   int curlen;                /* length of current code */
-   int nextlen = tree[0].Len; /* length of next code */
-   int count = 0;             /* repeat count of the current code */
-   int max_count = 7;         /* max repeat count */
-   int min_count = 4;         /* min repeat count */
-
-   if (nextlen == 0) max_count = 138, min_count = 3;
-   tree[max_code+1].Len = (ush)0xffff; /* guard */
-
-   for (n = 0; n <= max_code; n++) {
-      curlen = nextlen; nextlen = tree[n+1].Len;
-      if (++count < max_count && curlen == nextlen) {
-         continue;
-      } else if (count < min_count) {
-         s->bl_tree[curlen].Freq += count;
-      } else if (curlen != 0) {
-         if (curlen != prevlen) s->bl_tree[curlen].Freq++;
-         s->bl_tree[REP_3_6].Freq++;
-      } else if (count <= 10) {
-         s->bl_tree[REPZ_3_10].Freq++;
-      } else {
-         s->bl_tree[REPZ_11_138].Freq++;
-      }
-      count = 0; prevlen = curlen;
-      if (nextlen == 0) {
-         max_count = 138, min_count = 3;
-      } else if (curlen == nextlen) {
-         max_count = 6, min_count = 3;
-      } else {
-         max_count = 7, min_count = 4;
-      }
-   }
-}
-
-/* ===========================================================================
- * Send a literal or distance tree in compressed form, using the codes in
- * bl_tree.
- */
-local void send_tree (deflate_state *s, ct_data *tree, int max_code)
-{
-   int n;                     /* iterates over all tree elements */
-   int prevlen = -1;          /* last emitted length */
-   int curlen;                /* length of current code */
-   int nextlen = tree[0].Len; /* length of next code */
-   int count = 0;             /* repeat count of the current code */
-   int max_count = 7;         /* max repeat count */
-   int min_count = 4;         /* min repeat count */
-
-   /* tree[max_code+1].Len = -1; */  /* guard already set */
-   if (nextlen == 0) max_count = 138, min_count = 3;
-
-   for (n = 0; n <= max_code; n++) {
-      curlen = nextlen; nextlen = tree[n+1].Len;
-      if (++count < max_count && curlen == nextlen) {
-         continue;
-      } else if (count < min_count) {
-         do { send_code(s, curlen, s->bl_tree); } while (--count != 0);
-
-      } else if (curlen != 0) {
-         if (curlen != prevlen) {
-            send_code(s, curlen, s->bl_tree); count--;
-         }
-         Assert(count >= 3 && count <= 6, " 3_6?");
-         send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2);
-
-      } else if (count <= 10) {
-         send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3);
-
-      } else {
-         send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7);
-      }
-      count = 0; prevlen = curlen;
-      if (nextlen == 0) {
-         max_count = 138, min_count = 3;
-      } else if (curlen == nextlen) {
-         max_count = 6, min_count = 3;
-      } else {
-         max_count = 7, min_count = 4;
-      }
-   }
-}
-
-/* ===========================================================================
- * Construct the Huffman tree for the bit lengths and return the index in
- * bl_order of the last bit length code to send.
- */
-local int build_bl_tree(deflate_state *s)
-{
-   int max_blindex;  /* index of last bit length code of non zero freq */
-
-   /* Determine the bit length frequencies for literal and distance trees */
-   scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code);
-   scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code);
-
-   /* Build the bit length tree: */
-   build_tree(s, (tree_desc *)(&(s->bl_desc)));
-   /* opt_len now includes the length of the tree representations, except
-    * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
-    */
-
-   /* Determine the number of bit length codes to send. The pkzip format
-    * requires that at least 4 bit length codes be sent. (appnote.txt says
-    * 3 but the actual value used is 4.)
-    */
-   for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
-      if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
-   }
-   /* Update opt_len to include the bit length tree and counts */
-   s->opt_len += 3*(max_blindex+1) + 5+5+4;
-   Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
-            s->opt_len, s->static_len));
-
-   return max_blindex;
-}
-
-/* ===========================================================================
- * Send the header for a block using dynamic Huffman trees: the counts, the
- * lengths of the bit length codes, the literal tree and the distance tree.
- * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
- */
-local void send_all_trees(deflate_state *s, int lcodes, int dcodes, int blcodes)
-{
-   int rank;                    /* index in bl_order */
-
-   Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
-   Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
-         "too many codes");
-   Tracev((stderr, "\nbl counts: "));
-   send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */
-   send_bits(s, dcodes-1,   5);
-   send_bits(s, blcodes-4,  4); /* not -3 as stated in appnote.txt */
-   for (rank = 0; rank < blcodes; rank++) {
-      Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
-      send_bits(s, s->bl_tree[bl_order[rank]].Len, 3);
-   }
-   Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
-
-   send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */
-   Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
-
-   send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */
-   Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
-}
-
-/* ===========================================================================
- * Send a stored block
- */
-void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, ulg stored_len, int last)
-{
-   send_bits(s, (STORED_BLOCK<<1)+last, 3);    /* send block type */
-#ifdef DEBUG
-   s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
-   s->compressed_len += (stored_len + 4) << 3;
-#endif
-   copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
-}
-
-/* ===========================================================================
- * Flush the bits in the bit buffer to pending output (leaves at most 7 bits)
- */
-void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s)
-{
-   bi_flush(s);
-}
-
-/* ===========================================================================
- * Send one empty static block to give enough lookahead for inflate.
- * This takes 10 bits, of which 7 may remain in the bit buffer.
- */
-void ZLIB_INTERNAL _tr_align(deflate_state *s)
-{
-   send_bits(s, STATIC_TREES<<1, 3);
-   send_code(s, END_BLOCK, static_ltree);
-#ifdef DEBUG
-   s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
-#endif
-   bi_flush(s);
-}
-
-/* ===========================================================================
- * Determine the best encoding for the current block: dynamic trees, static
- * trees or store, and output the encoded block to the zip file.
- */
-void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf, ulg stored_len, int last)
-{
-   ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
-   int max_blindex = 0;  /* index of last bit length code of non zero freq */
-
-   /* Build the Huffman trees unless a stored block is forced */
-   if (s->level > 0) {
-
-      /* Check if the file is binary or text */
-      if (s->strm->data_type == Z_UNKNOWN)
-         s->strm->data_type = detect_data_type(s);
-
-      /* Construct the literal and distance trees */
-      build_tree(s, (tree_desc *)(&(s->l_desc)));
-      Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len,
-               s->static_len));
-
-      build_tree(s, (tree_desc *)(&(s->d_desc)));
-      Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len,
-               s->static_len));
-      /* At this point, opt_len and static_len are the total bit lengths of
-       * the compressed block data, excluding the tree representations.
-       */
-
-      /* Build the bit length tree for the above two trees, and get the index
-       * in bl_order of the last bit length code to send.
-       */
-      max_blindex = build_bl_tree(s);
-
-      /* Determine the best encoding. Compute the block lengths in bytes. */
-      opt_lenb = (s->opt_len+3+7)>>3;
-      static_lenb = (s->static_len+3+7)>>3;
-
-      Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
-               opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
-               s->last_lit));
-
-      if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
-
-   } else {
-      Assert(buf != (char*)0, "lost buf");
-      opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
-   }
-
-#ifdef FORCE_STORED
-   if (buf != (char*)0) { /* force stored block */
-#else
-      if (stored_len+4 <= opt_lenb && buf != (char*)0) {
-         /* 4: two words for the lengths */
-#endif
-         /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
-          * Otherwise we can't have processed more than WSIZE input bytes since
-          * the last block flush, because compression would have been
-          * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
-          * transform a block into a stored block.
-          */
-         _tr_stored_block(s, buf, stored_len, last);
-
-#ifdef FORCE_STATIC
-      } else if (static_lenb >= 0) { /* force static trees */
-#else
-      } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
-#endif
-         send_bits(s, (STATIC_TREES<<1)+last, 3);
-         compress_block(s, (const ct_data *)static_ltree,
-               (const ct_data *)static_dtree);
-#ifdef DEBUG
-         s->compressed_len += 3 + s->static_len;
-#endif
-      } else {
-         send_bits(s, (DYN_TREES<<1)+last, 3);
-         send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
-               max_blindex+1);
-         compress_block(s, (const ct_data *)s->dyn_ltree,
-               (const ct_data *)s->dyn_dtree);
-#ifdef DEBUG
-         s->compressed_len += 3 + s->opt_len;
-#endif
-      }
-      Assert (s->compressed_len == s->bits_sent, "bad compressed size");
-      /* The above check is made mod 2^32, for files larger than 512 MB
-       * and uLong implemented on 32 bits.
-       */
-      init_block(s);
-
-      if (last) {
-         bi_windup(s);
-#ifdef DEBUG
-         s->compressed_len += 7;  /* align on byte boundary */
-#endif
-      }
-      Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
-               s->compressed_len-7*last));
-   }
-
-   /* ===========================================================================
-    * Save the match info and tally the frequency counts. Return true if
-    * the current block must be flushed.
-    */
-   int ZLIB_INTERNAL _tr_tally (deflate_state *s, unsigned dist, unsigned lc)
-   {
-      s->d_buf[s->last_lit] = (ush)dist;
-      s->l_buf[s->last_lit++] = (uch)lc;
-      if (dist == 0) {
-         /* lc is the unmatched char */
-         s->dyn_ltree[lc].Freq++;
-      } else {
-         s->matches++;
-         /* Here, lc is the match length - MIN_MATCH */
-         dist--;             /* dist = match distance - 1 */
-         Assert((ush)dist < (ush)MAX_DIST(s) &&
-               (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
-               (ush)d_code(dist) < (ush)D_CODES,  "_tr_tally: bad match");
-
-         s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++;
-         s->dyn_dtree[d_code(dist)].Freq++;
-      }
-
-#ifdef TRUNCATE_BLOCK
-      /* Try to guess if it is profitable to stop the current block here */
-      if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {
-         /* Compute an upper bound for the compressed length */
-         ulg out_length = (ulg)s->last_lit*8L;
-         ulg in_length = (ulg)((long)s->strstart - s->block_start);
-         int dcode;
-         for (dcode = 0; dcode < D_CODES; dcode++) {
-            out_length += (ulg)s->dyn_dtree[dcode].Freq *
-               (5L+extra_dbits[dcode]);
-         }
-         out_length >>= 3;
-         Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
-                  s->last_lit, in_length, out_length,
-                  100L - out_length*100L/in_length));
-         if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;
-      }
-#endif
-      return (s->last_lit == s->lit_bufsize-1);
-      /* We avoid equality with lit_bufsize because of wraparound at 64K
-       * on 16 bit machines and because stored blocks are restricted to
-       * 64K-1 bytes.
-       */
-   }
-
-   /* ===========================================================================
-    * Send the block data compressed using the given Huffman trees
-    */
-   local void compress_block(deflate_state *s, const ct_data *ltree, const ct_data *dtree)
-   {
-      unsigned dist;      /* distance of matched string */
-      int lc;             /* match length or unmatched char (if dist == 0) */
-      unsigned lx = 0;    /* running index in l_buf */
-      unsigned codes;      /* the code to send */
-      int extra;          /* number of extra bits to send */
-
-      if (s->last_lit != 0) do {
-         dist = s->d_buf[lx];
-         lc = s->l_buf[lx++];
-         if (dist == 0) {
-            send_code(s, lc, ltree); /* send a literal byte */
-            Tracecv(isgraph(lc), (stderr," '%c' ", lc));
-         } else {
-            /* Here, lc is the match length - MIN_MATCH */
-            codes = _length_code[lc];
-            send_code(s, codes + LITERALS+1, ltree); /* send the length code */
-            extra = extra_lbits[codes];
-            if (extra != 0) {
-               lc -= base_length[codes];
-               send_bits(s, lc, extra);       /* send the extra length bits */
-            }
-            dist--; /* dist is now the match distance - 1 */
-            codes = d_code(dist);
-            Assert (codes < D_CODES, "bad d_code");
-
-            send_code(s, codes, dtree);       /* send the distance code */
-            extra = extra_dbits[codes];
-            if (extra != 0) {
-               dist -= base_dist[codes];
-               send_bits(s, dist, extra);   /* send the extra distance bits */
-            }
-         } /* literal or match pair ? */
-
-         /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
-         Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
-               "pendingBuf overflow");
-
-      } while (lx < s->last_lit);
-
-      send_code(s, END_BLOCK, ltree);
-   }
-
-   /* ===========================================================================
-    * Check if the data type is TEXT or BINARY, using the following algorithm:
-    * - TEXT if the two conditions below are satisfied:
-    *    a) There are no non-portable control characters belonging to the
-    *       "black list" (0..6, 14..25, 28..31).
-    *    b) There is at least one printable character belonging to the
-    *       "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
-    * - BINARY otherwise.
-    * - The following partially-portable control characters form a
-    *   "gray list" that is ignored in this detection algorithm:
-    *   (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
-    * IN assertion: the fields Freq of dyn_ltree are set.
-    */
-   local int detect_data_type(deflate_state *s)
-   {
-      /* black_mask is the bit mask of black-listed bytes
-       * set bits 0..6, 14..25, and 28..31
-       * 0xf3ffc07f = binary 11110011111111111100000001111111
-       */
-      unsigned long black_mask = 0xf3ffc07fUL;
-      int n;
-
-      /* Check for non-textual ("black-listed") bytes. */
-      for (n = 0; n <= 31; n++, black_mask >>= 1)
-         if ((black_mask & 1) && (s->dyn_ltree[n].Freq != 0))
-            return Z_BINARY;
-
-      /* Check for textual ("white-listed") bytes. */
-      if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0
-            || s->dyn_ltree[13].Freq != 0)
-         return Z_TEXT;
-      for (n = 32; n < LITERALS; n++)
-         if (s->dyn_ltree[n].Freq != 0)
-            return Z_TEXT;
-
-      /* There are no "black-listed" or "white-listed" bytes:
-       * this stream either is empty or has tolerated ("gray-listed") bytes only.
-       */
-      return Z_BINARY;
-   }
-
-   /* ===========================================================================
-    * Reverse the first len bits of a code, using straightforward code (a faster
-    * method would use a table)
-    * IN assertion: 1 <= len <= 15
-    */
-   local unsigned bi_reverse(unsigned codes, int len)
-   {
-      register unsigned res = 0;
-      do {
-         res |= codes & 1;
-         codes >>= 1, res <<= 1;
-      } while (--len > 0);
-      return res >> 1;
-   }
-
-   /* ===========================================================================
-    * Flush the bit buffer, keeping at most 7 bits in it.
-    */
-   local void bi_flush(deflate_state *s)
-   {
-      if (s->bi_valid == 16) {
-         put_short(s, s->bi_buf);
-         s->bi_buf = 0;
-         s->bi_valid = 0;
-      } else if (s->bi_valid >= 8) {
-         put_byte(s, (Byte)s->bi_buf);
-         s->bi_buf >>= 8;
-         s->bi_valid -= 8;
-      }
-   }
-
-   /* ===========================================================================
-    * Flush the bit buffer and align the output on a byte boundary
-    */
-   local void bi_windup(deflate_state *s)
-   {
-      if (s->bi_valid > 8) {
-         put_short(s, s->bi_buf);
-      } else if (s->bi_valid > 0) {
-         put_byte(s, (Byte)s->bi_buf);
-      }
-      s->bi_buf = 0;
-      s->bi_valid = 0;
-#ifdef DEBUG
-      s->bits_sent = (s->bits_sent+7) & ~7;
-#endif
-   }
-
-   /* ===========================================================================
-    * Copy a stored block, storing first the length and its
-    * one's complement if requested.
-    */
-   local void copy_block(deflate_state *s, charf *buf, unsigned len, int header)
-   {
-      bi_windup(s);        /* align on byte boundary */
-
-      if (header) {
-         put_short(s, (ush)len);
-         put_short(s, (ush)~len);
-#ifdef DEBUG
-         s->bits_sent += 2*16;
-#endif
-      }
-#ifdef DEBUG
-      s->bits_sent += (ulg)len<<3;
-#endif
-      while (len--) {
-         put_byte(s, *buf++);
-      }
-   }
diff --git a/deps/zlib/trees.h b/deps/zlib/trees.h
deleted file mode 100644 (file)
index c0261b2..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-/* header created automatically with -DGEN_TREES_H */
-#ifndef _TREES_H
-#define _TREES_H
-
-local const ct_data static_ltree[L_CODES+2] = {
-{{ 12},{  8}}, {{140},{  8}}, {{ 76},{  8}}, {{204},{  8}}, {{ 44},{  8}},
-{{172},{  8}}, {{108},{  8}}, {{236},{  8}}, {{ 28},{  8}}, {{156},{  8}},
-{{ 92},{  8}}, {{220},{  8}}, {{ 60},{  8}}, {{188},{  8}}, {{124},{  8}},
-{{252},{  8}}, {{  2},{  8}}, {{130},{  8}}, {{ 66},{  8}}, {{194},{  8}},
-{{ 34},{  8}}, {{162},{  8}}, {{ 98},{  8}}, {{226},{  8}}, {{ 18},{  8}},
-{{146},{  8}}, {{ 82},{  8}}, {{210},{  8}}, {{ 50},{  8}}, {{178},{  8}},
-{{114},{  8}}, {{242},{  8}}, {{ 10},{  8}}, {{138},{  8}}, {{ 74},{  8}},
-{{202},{  8}}, {{ 42},{  8}}, {{170},{  8}}, {{106},{  8}}, {{234},{  8}},
-{{ 26},{  8}}, {{154},{  8}}, {{ 90},{  8}}, {{218},{  8}}, {{ 58},{  8}},
-{{186},{  8}}, {{122},{  8}}, {{250},{  8}}, {{  6},{  8}}, {{134},{  8}},
-{{ 70},{  8}}, {{198},{  8}}, {{ 38},{  8}}, {{166},{  8}}, {{102},{  8}},
-{{230},{  8}}, {{ 22},{  8}}, {{150},{  8}}, {{ 86},{  8}}, {{214},{  8}},
-{{ 54},{  8}}, {{182},{  8}}, {{118},{  8}}, {{246},{  8}}, {{ 14},{  8}},
-{{142},{  8}}, {{ 78},{  8}}, {{206},{  8}}, {{ 46},{  8}}, {{174},{  8}},
-{{110},{  8}}, {{238},{  8}}, {{ 30},{  8}}, {{158},{  8}}, {{ 94},{  8}},
-{{222},{  8}}, {{ 62},{  8}}, {{190},{  8}}, {{126},{  8}}, {{254},{  8}},
-{{  1},{  8}}, {{129},{  8}}, {{ 65},{  8}}, {{193},{  8}}, {{ 33},{  8}},
-{{161},{  8}}, {{ 97},{  8}}, {{225},{  8}}, {{ 17},{  8}}, {{145},{  8}},
-{{ 81},{  8}}, {{209},{  8}}, {{ 49},{  8}}, {{177},{  8}}, {{113},{  8}},
-{{241},{  8}}, {{  9},{  8}}, {{137},{  8}}, {{ 73},{  8}}, {{201},{  8}},
-{{ 41},{  8}}, {{169},{  8}}, {{105},{  8}}, {{233},{  8}}, {{ 25},{  8}},
-{{153},{  8}}, {{ 89},{  8}}, {{217},{  8}}, {{ 57},{  8}}, {{185},{  8}},
-{{121},{  8}}, {{249},{  8}}, {{  5},{  8}}, {{133},{  8}}, {{ 69},{  8}},
-{{197},{  8}}, {{ 37},{  8}}, {{165},{  8}}, {{101},{  8}}, {{229},{  8}},
-{{ 21},{  8}}, {{149},{  8}}, {{ 85},{  8}}, {{213},{  8}}, {{ 53},{  8}},
-{{181},{  8}}, {{117},{  8}}, {{245},{  8}}, {{ 13},{  8}}, {{141},{  8}},
-{{ 77},{  8}}, {{205},{  8}}, {{ 45},{  8}}, {{173},{  8}}, {{109},{  8}},
-{{237},{  8}}, {{ 29},{  8}}, {{157},{  8}}, {{ 93},{  8}}, {{221},{  8}},
-{{ 61},{  8}}, {{189},{  8}}, {{125},{  8}}, {{253},{  8}}, {{ 19},{  9}},
-{{275},{  9}}, {{147},{  9}}, {{403},{  9}}, {{ 83},{  9}}, {{339},{  9}},
-{{211},{  9}}, {{467},{  9}}, {{ 51},{  9}}, {{307},{  9}}, {{179},{  9}},
-{{435},{  9}}, {{115},{  9}}, {{371},{  9}}, {{243},{  9}}, {{499},{  9}},
-{{ 11},{  9}}, {{267},{  9}}, {{139},{  9}}, {{395},{  9}}, {{ 75},{  9}},
-{{331},{  9}}, {{203},{  9}}, {{459},{  9}}, {{ 43},{  9}}, {{299},{  9}},
-{{171},{  9}}, {{427},{  9}}, {{107},{  9}}, {{363},{  9}}, {{235},{  9}},
-{{491},{  9}}, {{ 27},{  9}}, {{283},{  9}}, {{155},{  9}}, {{411},{  9}},
-{{ 91},{  9}}, {{347},{  9}}, {{219},{  9}}, {{475},{  9}}, {{ 59},{  9}},
-{{315},{  9}}, {{187},{  9}}, {{443},{  9}}, {{123},{  9}}, {{379},{  9}},
-{{251},{  9}}, {{507},{  9}}, {{  7},{  9}}, {{263},{  9}}, {{135},{  9}},
-{{391},{  9}}, {{ 71},{  9}}, {{327},{  9}}, {{199},{  9}}, {{455},{  9}},
-{{ 39},{  9}}, {{295},{  9}}, {{167},{  9}}, {{423},{  9}}, {{103},{  9}},
-{{359},{  9}}, {{231},{  9}}, {{487},{  9}}, {{ 23},{  9}}, {{279},{  9}},
-{{151},{  9}}, {{407},{  9}}, {{ 87},{  9}}, {{343},{  9}}, {{215},{  9}},
-{{471},{  9}}, {{ 55},{  9}}, {{311},{  9}}, {{183},{  9}}, {{439},{  9}},
-{{119},{  9}}, {{375},{  9}}, {{247},{  9}}, {{503},{  9}}, {{ 15},{  9}},
-{{271},{  9}}, {{143},{  9}}, {{399},{  9}}, {{ 79},{  9}}, {{335},{  9}},
-{{207},{  9}}, {{463},{  9}}, {{ 47},{  9}}, {{303},{  9}}, {{175},{  9}},
-{{431},{  9}}, {{111},{  9}}, {{367},{  9}}, {{239},{  9}}, {{495},{  9}},
-{{ 31},{  9}}, {{287},{  9}}, {{159},{  9}}, {{415},{  9}}, {{ 95},{  9}},
-{{351},{  9}}, {{223},{  9}}, {{479},{  9}}, {{ 63},{  9}}, {{319},{  9}},
-{{191},{  9}}, {{447},{  9}}, {{127},{  9}}, {{383},{  9}}, {{255},{  9}},
-{{511},{  9}}, {{  0},{  7}}, {{ 64},{  7}}, {{ 32},{  7}}, {{ 96},{  7}},
-{{ 16},{  7}}, {{ 80},{  7}}, {{ 48},{  7}}, {{112},{  7}}, {{  8},{  7}},
-{{ 72},{  7}}, {{ 40},{  7}}, {{104},{  7}}, {{ 24},{  7}}, {{ 88},{  7}},
-{{ 56},{  7}}, {{120},{  7}}, {{  4},{  7}}, {{ 68},{  7}}, {{ 36},{  7}},
-{{100},{  7}}, {{ 20},{  7}}, {{ 84},{  7}}, {{ 52},{  7}}, {{116},{  7}},
-{{  3},{  8}}, {{131},{  8}}, {{ 67},{  8}}, {{195},{  8}}, {{ 35},{  8}},
-{{163},{  8}}, {{ 99},{  8}}, {{227},{  8}}
-};
-
-local const ct_data static_dtree[D_CODES] = {
-{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
-{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
-{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},
-{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},
-{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},
-{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
-};
-
-const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {
- 0,  1,  2,  3,  4,  4,  5,  5,  6,  6,  6,  6,  7,  7,  7,  7,  8,  8,  8,  8,
- 8,  8,  8,  8,  9,  9,  9,  9,  9,  9,  9,  9, 10, 10, 10, 10, 10, 10, 10, 10,
-10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
-12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
-13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
-13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
-14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
-14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
-14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
-15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
-15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
-15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,  0,  0, 16, 17,
-18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
-23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
-26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
-26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
-27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
-27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
-};
-
-const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {
- 0,  1,  2,  3,  4,  5,  6,  7,  8,  8,  9,  9, 10, 10, 11, 11, 12, 12, 12, 12,
-13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
-17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
-19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
-21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
-22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
-23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
-25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
-26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
-26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
-27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
-};
-
-local const int base_length[LENGTH_CODES] = {
-0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
-64, 80, 96, 112, 128, 160, 192, 224, 0
-};
-
-local const int base_dist[D_CODES] = {
-    0,     1,     2,     3,     4,     6,     8,    12,    16,    24,
-   32,    48,    64,    96,   128,   192,   256,   384,   512,   768,
- 1024,  1536,  2048,  3072,  4096,  6144,  8192, 12288, 16384, 24576
-};
-
-
-#endif
diff --git a/deps/zlib/uncompr.c b/deps/zlib/uncompr.c
deleted file mode 100644 (file)
index c7e30b3..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/* uncompr.c -- decompress a memory buffer
- * Copyright (C) 1995-2003, 2010 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#define ZLIB_INTERNAL
-#include "zlib.h"
-
-/* ===========================================================================
-   Decompresses the source buffer into the destination buffer.  sourceLen is
-   the byte length of the source buffer. Upon entry, destLen is the total
-   size of the destination buffer, which must be large enough to hold the
-   entire uncompressed data. (The size of the uncompressed data must have
-   been saved previously by the compressor and transmitted to the decompressor
-   by some mechanism outside the scope of this compression library.)
-   Upon exit, destLen is the actual size of the compressed buffer.
-
-   uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
-   enough memory, Z_BUF_ERROR if there was not enough room in the output
-   buffer, or Z_DATA_ERROR if the input data was corrupted.
-   */
-int ZEXPORT uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
-{
-   z_stream stream;
-   int err;
-
-   stream.next_in = (Bytef *)source;
-   stream.avail_in = (uInt)sourceLen;
-   /* Check for source > 64K on 16-bit machine: */
-   if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
-
-   stream.next_out = dest;
-   stream.avail_out = (uInt)*destLen;
-   if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
-
-   stream.zalloc = Z_NULL;
-   stream.zfree = Z_NULL;
-
-   err = inflateInit(&stream);
-   if (err != Z_OK) return err;
-
-   err = inflate(&stream, Z_FINISH);
-   if (err != Z_STREAM_END) {
-      inflateEnd(&stream);
-      if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
-         return Z_DATA_ERROR;
-      return err;
-   }
-   *destLen = stream.total_out;
-
-   err = inflateEnd(&stream);
-   return err;
-}
diff --git a/deps/zlib/unzip.c b/deps/zlib/unzip.c
deleted file mode 100644 (file)
index ba6abbf..0000000
+++ /dev/null
@@ -1,2126 +0,0 @@
-/* unzip.c -- IO for uncompress .zip files using zlib
-   Version 1.1, February 14h, 2010
-   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
-
-   Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
-
-   Modifications of Unzip for Zip64
-   Copyright (C) 2007-2008 Even Rouault
-
-   Modifications for Zip64 support on both zip and unzip
-   Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
-
-   For more info read MiniZip_info.txt
-
-
-   ------------------------------------------------------------------------------------
-   Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of
-   compatibility with older software. The following is from the original crypt.c.
-   Code woven in by Terry Thorsen 1/2003.
-
-   Copyright (c) 1990-2000 Info-ZIP.  All rights reserved.
-
-   See the accompanying file LICENSE, version 2000-Apr-09 or later
-   (the contents of which are also included in zip.h) for terms of use.
-   If, for some reason, all these files are missing, the Info-ZIP license
-   also may be found at:  ftp://ftp.info-zip.org/pub/infozip/license.html
-
-   crypt.c (full version) by Info-ZIP.      Last revised:  [see crypt.h]
-
-   The encryption/decryption parts of this source code (as opposed to the
-   non-echoing password parts) were originally written in Europe.  The
-   whole source package can be freely distributed, including from the USA.
-   (Prior to January 2000, re-export from the US was a violation of US law.)
-
-   This encryption code is a direct transcription of the algorithm from
-   Roger Schlafly, described by Phil Katz in the file appnote.txt.  This
-   file (appnote.txt) is distributed with the PKZIP program (even in the
-   version without encryption capabilities).
-
-   ------------------------------------------------------------------------------------
-
-   Changes in unzip.c
-
-   2007-2008 - Even Rouault - Addition of cpl_unzGetCurrentFileZStreamPos
-   2007-2008 - Even Rouault - Decoration of symbol names unz* -> cpl_unz*
-   2007-2008 - Even Rouault - Remove old C style function prototypes
-   2007-2008 - Even Rouault - Add unzip support for ZIP64
-
-   Copyright (C) 2007-2008 Even Rouault
-
-
-   Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again).
-   Oct-2009 - Mathias Svensson - Fixed problem if uncompressed size was > 4G and compressed size was <4G
-   should only read the compressed/uncompressed size from the Zip64 format if
-   the size from normal header was 0xFFFFFFFF
-   Oct-2009 - Mathias Svensson - Applied some bug fixes from paches recived from Gilles Vollant
-   Oct-2009 - Mathias Svensson - Applied support to unzip files with compression mathod BZIP2 (bzip2 lib is required)
-   Patch created by Daniel Borca
-
-   Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer
-
-   Copyright (C) 1998 - 2010 Gilles Vollant, Even Rouault, Mathias Svensson
-
-*/
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifndef NOUNCRYPT
-#define NOUNCRYPT
-#endif
-
-#include "zlib.h"
-#include "unzip.h"
-
-#ifdef STDC
-#  include <stddef.h>
-#  include <string.h>
-#  include <stdlib.h>
-#endif
-#ifdef NO_ERRNO_H
-extern int errno;
-#else
-#   include <errno.h>
-#endif
-
-
-#ifndef local
-#  define local static
-#endif
-/* compile with -Dlocal if your debugger can't find static symbols */
-
-
-#ifndef CASESENSITIVITYDEFAULT_NO
-#  if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES)
-#    define CASESENSITIVITYDEFAULT_NO
-#  endif
-#endif
-
-
-#ifndef UNZ_BUFSIZE
-#define UNZ_BUFSIZE (16384)
-#endif
-
-#ifndef UNZ_MAXFILENAMEINZIP
-#define UNZ_MAXFILENAMEINZIP (256)
-#endif
-
-#ifndef ALLOC
-# define ALLOC(size) (malloc(size))
-#endif
-#ifndef TRYFREE
-# define TRYFREE(p) {if (p) free(p);}
-#endif
-
-#define SIZECENTRALDIRITEM (0x2e)
-#define SIZEZIPLOCALHEADER (0x1e)
-
-
-const char unz_copyright[] =
-" unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
-
-/* unz_file_info_interntal contain internal info about a file in zipfile*/
-typedef struct unz_file_info64_internal_s
-{
-   ZPOS64_T offset_curfile;/* relative offset of local header 8 bytes */
-} unz_file_info64_internal;
-
-
-/* file_in_zip_read_info_s contain internal information about a file in zipfile,
-   when reading and decompress it */
-typedef struct
-{
-   char  *read_buffer;         /* internal buffer for compressed data */
-   z_stream stream;            /* zLib stream structure for inflate */
-
-#ifdef HAVE_BZIP2
-   bz_stream bstream;          /* bzLib stream structure for bziped */
-#endif
-
-   ZPOS64_T pos_in_zipfile;       /* position in byte on the zipfile, for fseek*/
-   uLong stream_initialised;   /* flag set if stream structure is initialised*/
-
-   ZPOS64_T offset_local_extrafield;/* offset of the local extra field */
-   uInt  size_local_extrafield;/* size of the local extra field */
-   ZPOS64_T pos_local_extrafield;   /* position in the local extra field in read*/
-   ZPOS64_T total_out_64;
-
-   uLong crc32;                /* crc32 of all data uncompressed */
-   uLong crc32_wait;           /* crc32 we must obtain after decompress all */
-   ZPOS64_T rest_read_compressed; /* number of byte to be decompressed */
-   ZPOS64_T rest_read_uncompressed;/*number of byte to be obtained after decomp*/
-   zlib_filefunc64_32_def z_filefunc;
-   voidpf filestream;        /* io structore of the zipfile */
-   uLong compression_method;   /* compression method (0==store) */
-   ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
-   int   raw;
-} file_in_zip64_read_info_s;
-
-
-/* unz64_s contain internal information about the zipfile
-*/
-typedef struct
-{
-   zlib_filefunc64_32_def z_filefunc;
-   int is64bitOpenFunction;
-   voidpf filestream;        /* io structore of the zipfile */
-   unz_global_info64 gi;       /* public global information */
-   ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
-   ZPOS64_T num_file;             /* number of the current file in the zipfile*/
-   ZPOS64_T pos_in_central_dir;   /* pos of the current file in the central dir*/
-   ZPOS64_T current_file_ok;      /* flag about the usability of the current file*/
-   ZPOS64_T central_pos;          /* position of the beginning of the central dir*/
-
-   ZPOS64_T size_central_dir;     /* size of the central directory  */
-   ZPOS64_T offset_central_dir;   /* offset of start of central directory with
-                                     respect to the starting disk number */
-
-   unz_file_info64 cur_file_info; /* public info about the current file in zip*/
-   unz_file_info64_internal cur_file_info_internal; /* private info about it*/
-   file_in_zip64_read_info_s* pfile_in_zip_read; /* structure about the current
-                                                    file if we are decompressing it */
-   int encrypted;
-
-   int isZip64;
-
-#    ifndef NOUNCRYPT
-   unsigned long keys[3];     /* keys defining the pseudo-random sequence */
-   const unsigned long* pcrc_32_tab;
-#    endif
-} unz64_s;
-
-
-#ifndef NOUNCRYPT
-#include "crypt.h"
-#endif
-
-/* ===========================================================================
-   Read a byte from a gz_stream; update next_in and avail_in. Return EOF
-   for end of file.
-   IN assertion: the stream s has been sucessfully opened for reading.
-   */
-
-
-local int unz64local_getByte OF((
-         const zlib_filefunc64_32_def* pzlib_filefunc_def,
-         voidpf filestream,
-         int *pi));
-
-local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,
-                             voidpf filestream, int *_pi)
-{
-   unsigned char c;
-   int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1);
-   if (err==1)
-   {
-      *_pi = (int)c;
-      return UNZ_OK;
-   }
-   else
-   {
-      if (ZERROR64(*pzlib_filefunc_def,filestream))
-         return UNZ_ERRNO;
-      else
-         return UNZ_EOF;
-   }
-}
-
-
-/* ===========================================================================
-   Reads a long in LSB order from the given gz_stream. Sets
-   */
-local int unz64local_getShort OF((
-         const zlib_filefunc64_32_def* pzlib_filefunc_def,
-         voidpf filestream,
-         uLong *pX));
-
-local int unz64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def,
-      voidpf filestream,
-      uLong *pX)
-{
-   uLong x ;
-   int i = 0;
-   int err;
-
-   err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-   x = (uLong)i;
-
-   if (err==UNZ_OK)
-      err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-   x |= ((uLong)i)<<8;
-
-   if (err==UNZ_OK)
-      *pX = x;
-   else
-      *pX = 0;
-   return err;
-}
-
-local int unz64local_getLong OF((
-         const zlib_filefunc64_32_def* pzlib_filefunc_def,
-         voidpf filestream,
-         uLong *pX));
-
-local int unz64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def,
-      voidpf filestream,
-      uLong *pX)
-{
-   uLong x ;
-   int i = 0;
-   int err;
-
-   err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-   x = (uLong)i;
-
-   if (err==UNZ_OK)
-      err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-   x |= ((uLong)i)<<8;
-
-   if (err==UNZ_OK)
-      err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-   x |= ((uLong)i)<<16;
-
-   if (err==UNZ_OK)
-      err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-   x += ((uLong)i)<<24;
-
-   if (err==UNZ_OK)
-      *pX = x;
-   else
-      *pX = 0;
-   return err;
-}
-
-local int unz64local_getLong64 OF((
-         const zlib_filefunc64_32_def* pzlib_filefunc_def,
-         voidpf filestream,
-         ZPOS64_T *pX));
-
-
-local int unz64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def,
-      voidpf filestream,
-      ZPOS64_T *pX)
-{
-   ZPOS64_T x ;
-   int i = 0;
-   int err;
-
-   err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-   x = (ZPOS64_T)i;
-
-   if (err==UNZ_OK)
-      err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-   x |= ((ZPOS64_T)i)<<8;
-
-   if (err==UNZ_OK)
-      err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-   x |= ((ZPOS64_T)i)<<16;
-
-   if (err==UNZ_OK)
-      err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-   x |= ((ZPOS64_T)i)<<24;
-
-   if (err==UNZ_OK)
-      err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-   x |= ((ZPOS64_T)i)<<32;
-
-   if (err==UNZ_OK)
-      err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-   x |= ((ZPOS64_T)i)<<40;
-
-   if (err==UNZ_OK)
-      err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-   x |= ((ZPOS64_T)i)<<48;
-
-   if (err==UNZ_OK)
-      err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
-   x |= ((ZPOS64_T)i)<<56;
-
-   if (err==UNZ_OK)
-      *pX = x;
-   else
-      *pX = 0;
-   return err;
-}
-
-/* My own strcmpi / strcasecmp */
-local int strcmpcasenosensitive_internal (const char* fileName1, const char* fileName2)
-{
-   for (;;)
-   {
-      char c1=*(fileName1++);
-      char c2=*(fileName2++);
-      if ((c1>='a') && (c1<='z'))
-         c1 -= 0x20;
-      if ((c2>='a') && (c2<='z'))
-         c2 -= 0x20;
-      if (c1=='\0')
-         return ((c2=='\0') ? 0 : -1);
-      if (c2=='\0')
-         return 1;
-      if (c1<c2)
-         return -1;
-      if (c1>c2)
-         return 1;
-   }
-}
-
-
-#ifdef  CASESENSITIVITYDEFAULT_NO
-#define CASESENSITIVITYDEFAULTVALUE 2
-#else
-#define CASESENSITIVITYDEFAULTVALUE 1
-#endif
-
-#ifndef STRCMPCASENOSENTIVEFUNCTION
-#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal
-#endif
-
-/*
-   Compare two filename (fileName1,fileName2).
-   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
-   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
-   or strcasecmp)
-   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
-   (like 1 on Unix, 2 on Windows)
-
-*/
-extern int ZEXPORT unzStringFileNameCompare (const char*  fileName1,
-      const char*  fileName2,
-      int iCaseSensitivity)
-
-{
-   if (iCaseSensitivity==0)
-      iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
-
-   if (iCaseSensitivity==1)
-      return strcmp(fileName1,fileName2);
-
-   return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
-}
-
-#ifndef BUFREADCOMMENT
-#define BUFREADCOMMENT (0x400)
-#endif
-
-/*
-   Locate the Central directory of a zipfile (at the end, just before
-   the global comment)
-   */
-local ZPOS64_T unz64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));
-local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
-{
-   unsigned char* buf;
-   ZPOS64_T uSizeFile;
-   ZPOS64_T uBackRead;
-   ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
-   ZPOS64_T uPosFound=0;
-
-   if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
-      return 0;
-
-
-   uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);
-
-   if (uMaxBack>uSizeFile)
-      uMaxBack = uSizeFile;
-
-   buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
-   if (buf==NULL)
-      return 0;
-
-   uBackRead = 4;
-   while (uBackRead<uMaxBack)
-   {
-      uLong uReadSize;
-      ZPOS64_T uReadPos ;
-      int i;
-      if (uBackRead+BUFREADCOMMENT>uMaxBack)
-         uBackRead = uMaxBack;
-      else
-         uBackRead+=BUFREADCOMMENT;
-      uReadPos = uSizeFile-uBackRead ;
-
-      uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
-         (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);
-      if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
-         break;
-
-      if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
-         break;
-
-      for (i=(int)uReadSize-3; (i--)>0;)
-         if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
-               ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
-         {
-            uPosFound = uReadPos+i;
-            break;
-         }
-
-      if (uPosFound!=0)
-         break;
-   }
-   TRYFREE(buf);
-   return uPosFound;
-}
-
-
-/*
-   Locate the Central directory 64 of a zipfile (at the end, just before
-   the global comment)
-   */
-local ZPOS64_T unz64local_SearchCentralDir64 OF((
-         const zlib_filefunc64_32_def* pzlib_filefunc_def,
-         voidpf filestream));
-
-local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def,
-      voidpf filestream)
-{
-   unsigned char* buf;
-   ZPOS64_T uSizeFile;
-   ZPOS64_T uBackRead;
-   ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
-   ZPOS64_T uPosFound=0;
-   uLong uL;
-   ZPOS64_T relativeOffset;
-
-   if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
-      return 0;
-
-
-   uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);
-
-   if (uMaxBack>uSizeFile)
-      uMaxBack = uSizeFile;
-
-   buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
-   if (buf==NULL)
-      return 0;
-
-   uBackRead = 4;
-   while (uBackRead<uMaxBack)
-   {
-      uLong uReadSize;
-      ZPOS64_T uReadPos;
-      int i;
-      if (uBackRead+BUFREADCOMMENT>uMaxBack)
-         uBackRead = uMaxBack;
-      else
-         uBackRead+=BUFREADCOMMENT;
-      uReadPos = uSizeFile-uBackRead ;
-
-      uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
-         (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);
-      if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
-         break;
-
-      if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
-         break;
-
-      for (i=(int)uReadSize-3; (i--)>0;)
-         if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
-               ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
-         {
-            uPosFound = uReadPos+i;
-            break;
-         }
-
-      if (uPosFound!=0)
-         break;
-   }
-   TRYFREE(buf);
-   if (uPosFound == 0)
-      return 0;
-
-   /* Zip64 end of central directory locator */
-   if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0)
-      return 0;
-
-   /* the signature, already checked */
-   if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
-      return 0;
-
-   /* number of the disk with the start of the zip64 end of  central directory */
-   if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
-      return 0;
-   if (uL != 0)
-      return 0;
-
-   /* relative offset of the zip64 end of central directory record */
-   if (unz64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=UNZ_OK)
-      return 0;
-
-   /* total number of disks */
-   if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
-      return 0;
-   if (uL != 1)
-      return 0;
-
-   /* Goto end of central directory record */
-   if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0)
-      return 0;
-
-   /* the signature */
-   if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
-      return 0;
-
-   if (uL != 0x06064b50)
-      return 0;
-
-   return relativeOffset;
-}
-
-/*
-   Open a Zip file. path contain the full pathname (by example,
-   on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer
-   "zlib/zlib114.zip".
-   If the zipfile cannot be opened (file doesn't exist or in not valid), the
-   return value is NULL.
-   Else, the return value is a unzFile Handle, usable with other function
-   of this unzip package.
-   */
-local unzFile unzOpenInternal (const void *path,
-      zlib_filefunc64_32_def* pzlib_filefunc64_32_def,
-      int is64bitOpenFunction)
-{
-   unz64_s us;
-   unz64_s *s;
-   ZPOS64_T central_pos;
-   uLong   uL;
-
-   uLong number_disk;          /* number of the current dist, used for
-                                  spaning ZIP, unsupported, always 0*/
-   uLong number_disk_with_CD;  /* number the the disk with central dir, used
-                                  for spaning ZIP, unsupported, always 0*/
-   ZPOS64_T number_entry_CD;      /* total number of entries in
-                                     the central dir
-                                     (same than number_entry on nospan) */
-
-   int err=UNZ_OK;
-
-   if (unz_copyright[0]!=' ')
-      return NULL;
-
-   us.z_filefunc.zseek32_file = NULL;
-   us.z_filefunc.ztell32_file = NULL;
-   if (pzlib_filefunc64_32_def==NULL)
-      fill_fopen64_filefunc(&us.z_filefunc.zfile_func64);
-   else
-      us.z_filefunc = *pzlib_filefunc64_32_def;
-   us.is64bitOpenFunction = is64bitOpenFunction;
-
-
-
-   us.filestream = ZOPEN64(us.z_filefunc,
-         path,
-         ZLIB_FILEFUNC_MODE_READ |
-         ZLIB_FILEFUNC_MODE_EXISTING);
-   if (us.filestream==NULL)
-      return NULL;
-
-   central_pos = unz64local_SearchCentralDir64(&us.z_filefunc,us.filestream);
-   if (central_pos)
-   {
-      uLong uS;
-      ZPOS64_T uL64;
-
-      us.isZip64 = 1;
-
-      if (ZSEEK64(us.z_filefunc, us.filestream,
-               central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
-         err=UNZ_ERRNO;
-
-      /* the signature, already checked */
-      if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
-         err=UNZ_ERRNO;
-
-      /* size of zip64 end of central directory record */
-      if (unz64local_getLong64(&us.z_filefunc, us.filestream,&uL64)!=UNZ_OK)
-         err=UNZ_ERRNO;
-
-      /* version made by */
-      if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK)
-         err=UNZ_ERRNO;
-
-      /* version needed to extract */
-      if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK)
-         err=UNZ_ERRNO;
-
-      /* number of this disk */
-      if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)
-         err=UNZ_ERRNO;
-
-      /* number of the disk with the start of the central directory */
-      if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)
-         err=UNZ_ERRNO;
-
-      /* total number of entries in the central directory on this disk */
-      if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK)
-         err=UNZ_ERRNO;
-
-      /* total number of entries in the central directory */
-      if (unz64local_getLong64(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK)
-         err=UNZ_ERRNO;
-
-      if ((number_entry_CD!=us.gi.number_entry) ||
-            (number_disk_with_CD!=0) ||
-            (number_disk!=0))
-         err=UNZ_BADZIPFILE;
-
-      /* size of the central directory */
-      if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK)
-         err=UNZ_ERRNO;
-
-      /* offset of start of central directory with respect to the
-         starting disk number */
-      if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK)
-         err=UNZ_ERRNO;
-
-      us.gi.size_comment = 0;
-   }
-   else
-   {
-      central_pos = unz64local_SearchCentralDir(&us.z_filefunc,us.filestream);
-      if (central_pos==0)
-         err=UNZ_ERRNO;
-
-      us.isZip64 = 0;
-
-      if (ZSEEK64(us.z_filefunc, us.filestream,
-               central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
-         err=UNZ_ERRNO;
-
-      /* the signature, already checked */
-      if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
-         err=UNZ_ERRNO;
-
-      /* number of this disk */
-      if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)
-         err=UNZ_ERRNO;
-
-      /* number of the disk with the start of the central directory */
-      if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)
-         err=UNZ_ERRNO;
-
-      /* total number of entries in the central dir on this disk */
-      if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
-         err=UNZ_ERRNO;
-      us.gi.number_entry = uL;
-
-      /* total number of entries in the central dir */
-      if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
-         err=UNZ_ERRNO;
-      number_entry_CD = uL;
-
-      if ((number_entry_CD!=us.gi.number_entry) ||
-            (number_disk_with_CD!=0) ||
-            (number_disk!=0))
-         err=UNZ_BADZIPFILE;
-
-      /* size of the central directory */
-      if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
-         err=UNZ_ERRNO;
-      us.size_central_dir = uL;
-
-      /* offset of start of central directory with respect to the
-         starting disk number */
-      if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
-         err=UNZ_ERRNO;
-      us.offset_central_dir = uL;
-
-      /* zipfile comment length */
-      if (unz64local_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK)
-         err=UNZ_ERRNO;
-   }
-
-   if ((central_pos<us.offset_central_dir+us.size_central_dir) &&
-         (err==UNZ_OK))
-      err=UNZ_BADZIPFILE;
-
-   if (err!=UNZ_OK)
-   {
-      ZCLOSE64(us.z_filefunc, us.filestream);
-      return NULL;
-   }
-
-   us.byte_before_the_zipfile = central_pos -
-      (us.offset_central_dir+us.size_central_dir);
-   us.central_pos = central_pos;
-   us.pfile_in_zip_read = NULL;
-   us.encrypted = 0;
-
-
-   s=(unz64_s*)ALLOC(sizeof(unz64_s));
-   if( s != NULL)
-   {
-      *s=us;
-      unzGoToFirstFile((unzFile)s);
-   }
-   return (unzFile)s;
-}
-
-
-extern unzFile ZEXPORT unzOpen2 (const char *path,
-      zlib_filefunc_def* pzlib_filefunc32_def)
-{
-   if (pzlib_filefunc32_def != NULL)
-   {
-      zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
-      fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def);
-      return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 0);
-   }
-   else
-      return unzOpenInternal(path, NULL, 0);
-}
-
-extern unzFile ZEXPORT unzOpen2_64 (const void *path,
-      zlib_filefunc64_def* pzlib_filefunc_def)
-{
-   if (pzlib_filefunc_def != NULL)
-   {
-      zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
-      zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def;
-      zlib_filefunc64_32_def_fill.ztell32_file = NULL;
-      zlib_filefunc64_32_def_fill.zseek32_file = NULL;
-      return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 1);
-   }
-   else
-      return unzOpenInternal(path, NULL, 1);
-}
-
-extern unzFile ZEXPORT unzOpen (const char *path)
-{
-   return unzOpenInternal(path, NULL, 0);
-}
-
-extern unzFile ZEXPORT unzOpen64 (const void *path)
-{
-   return unzOpenInternal(path, NULL, 1);
-}
-
-/*
-   Close a ZipFile opened with unzipOpen.
-   If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
-   these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
-   return UNZ_OK if there is no problem. */
-extern int ZEXPORT unzClose (unzFile file)
-{
-   unz64_s* s;
-   if (file==NULL)
-      return UNZ_PARAMERROR;
-   s=(unz64_s*)file;
-
-   if (s->pfile_in_zip_read!=NULL)
-      unzCloseCurrentFile(file);
-
-   ZCLOSE64(s->z_filefunc, s->filestream);
-   TRYFREE(s);
-   return UNZ_OK;
-}
-
-
-/*
-   Write info about the ZipFile in the *pglobal_info structure.
-   No preparation of the structure is needed
-   return UNZ_OK if there is no problem. */
-extern int ZEXPORT unzGetGlobalInfo64 (unzFile file, unz_global_info64* pglobal_info)
-{
-   unz64_s* s;
-   if (file==NULL)
-      return UNZ_PARAMERROR;
-   s=(unz64_s*)file;
-   *pglobal_info=s->gi;
-   return UNZ_OK;
-}
-
-extern int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info* pglobal_info32)
-{
-   unz64_s* s;
-   if (file==NULL)
-      return UNZ_PARAMERROR;
-   s=(unz64_s*)file;
-   /* to do : check if number_entry is not truncated */
-   pglobal_info32->number_entry = (uLong)s->gi.number_entry;
-   pglobal_info32->size_comment = s->gi.size_comment;
-   return UNZ_OK;
-}
-/*
-   Translate date/time from Dos format to tm_unz (readable more easilty)
-   */
-local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm)
-{
-   ZPOS64_T uDate;
-   uDate = (ZPOS64_T)(ulDosDate>>16);
-   ptm->tm_mday = (uInt)(uDate&0x1f) ;
-   ptm->tm_mon =  (uInt)((((uDate)&0x1E0)/0x20)-1) ;
-   ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
-
-   ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);
-   ptm->tm_min =  (uInt) ((ulDosDate&0x7E0)/0x20) ;
-   ptm->tm_sec =  (uInt) (2*(ulDosDate&0x1f)) ;
-}
-
-/*
-   Get Info about the current file in the zipfile, with internal only info
-   */
-local int unz64local_GetCurrentFileInfoInternal OF((unzFile file,
-         unz_file_info64 *pfile_info,
-         unz_file_info64_internal
-         *pfile_info_internal,
-         char *szFileName,
-         uLong fileNameBufferSize,
-         void *extraField,
-         uLong extraFieldBufferSize,
-         char *szComment,
-         uLong commentBufferSize));
-
-local int unz64local_GetCurrentFileInfoInternal (unzFile file,
-      unz_file_info64 *pfile_info,
-      unz_file_info64_internal
-      *pfile_info_internal,
-      char *szFileName,
-      uLong fileNameBufferSize,
-      void *extraField,
-      uLong extraFieldBufferSize,
-      char *szComment,
-      uLong commentBufferSize)
-{
-   unz64_s* s;
-   unz_file_info64 file_info;
-   unz_file_info64_internal file_info_internal;
-   int err=UNZ_OK;
-   uLong uMagic;
-   long lSeek=0;
-   uLong uL;
-
-   if (file==NULL)
-      return UNZ_PARAMERROR;
-   s=(unz64_s*)file;
-   if (ZSEEK64(s->z_filefunc, s->filestream,
-            s->pos_in_central_dir+s->byte_before_the_zipfile,
-            ZLIB_FILEFUNC_SEEK_SET)!=0)
-      err=UNZ_ERRNO;
-
-
-   /* we check the magic */
-   if (err==UNZ_OK)
-   {
-      if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
-         err=UNZ_ERRNO;
-      else if (uMagic!=0x02014b50)
-         err=UNZ_BADZIPFILE;
-   }
-
-   if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK)
-      err=UNZ_ERRNO;
-
-   if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK)
-      err=UNZ_ERRNO;
-
-   if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK)
-      err=UNZ_ERRNO;
-
-   if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK)
-      err=UNZ_ERRNO;
-
-   if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK)
-      err=UNZ_ERRNO;
-
-   unz64local_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);
-
-   if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK)
-      err=UNZ_ERRNO;
-
-   if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
-      err=UNZ_ERRNO;
-   file_info.compressed_size = uL;
-
-   if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
-      err=UNZ_ERRNO;
-   file_info.uncompressed_size = uL;
-
-   if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK)
-      err=UNZ_ERRNO;
-
-   if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK)
-      err=UNZ_ERRNO;
-
-   if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK)
-      err=UNZ_ERRNO;
-
-   if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK)
-      err=UNZ_ERRNO;
-
-   if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK)
-      err=UNZ_ERRNO;
-
-   if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK)
-      err=UNZ_ERRNO;
-
-   // relative offset of local header
-   if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
-      err=UNZ_ERRNO;
-   file_info_internal.offset_curfile = uL;
-
-   lSeek+=file_info.size_filename;
-   if ((err==UNZ_OK) && (szFileName!=NULL))
-   {
-      uLong uSizeRead ;
-      if (file_info.size_filename<fileNameBufferSize)
-      {
-         *(szFileName+file_info.size_filename)='\0';
-         uSizeRead = file_info.size_filename;
-      }
-      else
-         uSizeRead = fileNameBufferSize;
-
-      if ((file_info.size_filename>0) && (fileNameBufferSize>0))
-         if (ZREAD64(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead)
-            err=UNZ_ERRNO;
-      lSeek -= uSizeRead;
-   }
-
-   // Read extrafield
-   if ((err==UNZ_OK) && (extraField!=NULL))
-   {
-      ZPOS64_T uSizeRead ;
-      if (file_info.size_file_extra<extraFieldBufferSize)
-         uSizeRead = file_info.size_file_extra;
-      else
-         uSizeRead = extraFieldBufferSize;
-
-      if (lSeek!=0)
-      {
-         if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
-            lSeek=0;
-         else
-            err=UNZ_ERRNO;
-      }
-
-      if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
-         if (ZREAD64(s->z_filefunc, s->filestream,extraField,(uLong)uSizeRead)!=uSizeRead)
-            err=UNZ_ERRNO;
-
-      lSeek += file_info.size_file_extra - (uLong)uSizeRead;
-   }
-   else
-      lSeek += file_info.size_file_extra;
-
-
-   if ((err==UNZ_OK) && (file_info.size_file_extra != 0))
-   {
-      uLong acc = 0;
-
-      // since lSeek now points to after the extra field we need to move back
-      lSeek -= file_info.size_file_extra;
-
-      if (lSeek!=0)
-      {
-         if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
-            lSeek=0;
-         else
-            err=UNZ_ERRNO;
-      }
-
-      while(acc < file_info.size_file_extra)
-      {
-         uLong headerId;
-         uLong dataSize;
-
-         if (unz64local_getShort(&s->z_filefunc, s->filestream,&headerId) != UNZ_OK)
-            err=UNZ_ERRNO;
-
-         if (unz64local_getShort(&s->z_filefunc, s->filestream,&dataSize) != UNZ_OK)
-            err=UNZ_ERRNO;
-
-         /* ZIP64 extra fields */
-         if (headerId == 0x0001)
-         {
-            uLong tmp;
-
-            if(file_info.uncompressed_size == (ZPOS64_T)(unsigned long)-1)
-            {
-               if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)
-                  err=UNZ_ERRNO;
-            }
-
-            if(file_info.compressed_size == (ZPOS64_T)(unsigned long)-1)
-            {
-               if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK)
-                  err=UNZ_ERRNO;
-            }
-
-            if(file_info_internal.offset_curfile == (ZPOS64_T)(unsigned long)-1)
-            {
-               /* Relative Header offset */
-               if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
-                  err=UNZ_ERRNO;
-            }
-
-            if(file_info.disk_num_start == (unsigned long)-1)
-            {
-               /* Disk Start Number */
-               if (unz64local_getLong(&s->z_filefunc, s->filestream,&tmp) != UNZ_OK)
-                  err=UNZ_ERRNO;
-            }
-
-         }
-         else
-         {
-            if (ZSEEK64(s->z_filefunc, s->filestream,dataSize,ZLIB_FILEFUNC_SEEK_CUR)!=0)
-               err=UNZ_ERRNO;
-         }
-
-         acc += 2 + 2 + dataSize;
-      }
-   }
-
-   if ((err==UNZ_OK) && (szComment!=NULL))
-   {
-      uLong uSizeRead ;
-      if (file_info.size_file_comment<commentBufferSize)
-      {
-         *(szComment+file_info.size_file_comment)='\0';
-         uSizeRead = file_info.size_file_comment;
-      }
-      else
-         uSizeRead = commentBufferSize;
-
-      if (lSeek!=0)
-      {
-         if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
-            lSeek=0;
-         else
-            err=UNZ_ERRNO;
-      }
-
-      if ((file_info.size_file_comment>0) && (commentBufferSize>0))
-         if (ZREAD64(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead)
-            err=UNZ_ERRNO;
-      lSeek+=file_info.size_file_comment - uSizeRead;
-   }
-   else
-      lSeek+=file_info.size_file_comment;
-
-
-   if ((err==UNZ_OK) && (pfile_info!=NULL))
-      *pfile_info=file_info;
-
-   if ((err==UNZ_OK) && (pfile_info_internal!=NULL))
-      *pfile_info_internal=file_info_internal;
-
-   return err;
-}
-
-
-
-/*
-   Write info about the ZipFile in the *pglobal_info structure.
-   No preparation of the structure is needed
-   return UNZ_OK if there is no problem.
-   */
-extern int ZEXPORT unzGetCurrentFileInfo64 (unzFile file,
-      unz_file_info64 * pfile_info,
-      char * szFileName, uLong fileNameBufferSize,
-      void *extraField, uLong extraFieldBufferSize,
-      char* szComment,  uLong commentBufferSize)
-{
-   return unz64local_GetCurrentFileInfoInternal(file,pfile_info,NULL,
-         szFileName,fileNameBufferSize,
-         extraField,extraFieldBufferSize,
-         szComment,commentBufferSize);
-}
-
-extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
-      unz_file_info * pfile_info,
-      char * szFileName, uLong fileNameBufferSize,
-      void *extraField, uLong extraFieldBufferSize,
-      char* szComment,  uLong commentBufferSize)
-{
-   int err;
-   unz_file_info64 file_info64;
-   err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL,
-         szFileName,fileNameBufferSize,
-         extraField,extraFieldBufferSize,
-         szComment,commentBufferSize);
-   if (err==UNZ_OK)
-   {
-      pfile_info->version = file_info64.version;
-      pfile_info->version_needed = file_info64.version_needed;
-      pfile_info->flag = file_info64.flag;
-      pfile_info->compression_method = file_info64.compression_method;
-      pfile_info->dosDate = file_info64.dosDate;
-      pfile_info->crc = file_info64.crc;
-
-      pfile_info->size_filename = file_info64.size_filename;
-      pfile_info->size_file_extra = file_info64.size_file_extra;
-      pfile_info->size_file_comment = file_info64.size_file_comment;
-
-      pfile_info->disk_num_start = file_info64.disk_num_start;
-      pfile_info->internal_fa = file_info64.internal_fa;
-      pfile_info->external_fa = file_info64.external_fa;
-
-      pfile_info->tmu_date = file_info64.tmu_date,
-
-
-         pfile_info->compressed_size = (uLong)file_info64.compressed_size;
-      pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size;
-
-   }
-   return err;
-}
-/*
-   Set the current file of the zipfile to the first file.
-   return UNZ_OK if there is no problem
-   */
-extern int ZEXPORT unzGoToFirstFile (unzFile file)
-{
-   int err=UNZ_OK;
-   unz64_s* s;
-   if (file==NULL)
-      return UNZ_PARAMERROR;
-   s=(unz64_s*)file;
-   s->pos_in_central_dir=s->offset_central_dir;
-   s->num_file=0;
-   err=unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
-         &s->cur_file_info_internal,
-         NULL,0,NULL,0,NULL,0);
-   s->current_file_ok = (err == UNZ_OK);
-   return err;
-}
-
-/*
-   Set the current file of the zipfile to the next file.
-   return UNZ_OK if there is no problem
-   return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
-   */
-extern int ZEXPORT unzGoToNextFile (unzFile  file)
-{
-   unz64_s* s;
-   int err;
-
-   if (file==NULL)
-      return UNZ_PARAMERROR;
-   s=(unz64_s*)file;
-   if (!s->current_file_ok)
-      return UNZ_END_OF_LIST_OF_FILE;
-   if (s->gi.number_entry != 0xffff)    /* 2^16 files overflow hack */
-      if (s->num_file+1==s->gi.number_entry)
-         return UNZ_END_OF_LIST_OF_FILE;
-
-   s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
-      s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;
-   s->num_file++;
-   err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
-         &s->cur_file_info_internal,
-         NULL,0,NULL,0,NULL,0);
-   s->current_file_ok = (err == UNZ_OK);
-   return err;
-}
-
-
-/*
-   Try locate the file szFileName in the zipfile.
-   For the iCaseSensitivity signification, see unzipStringFileNameCompare
-
-   return value :
-   UNZ_OK if the file is found. It becomes the current file.
-   UNZ_END_OF_LIST_OF_FILE if the file is not found
-   */
-extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity)
-{
-   unz64_s* s;
-   int err;
-
-   /* We remember the 'current' position in the file so that we can jump
-    * back there if we fail.
-    */
-   unz_file_info64 cur_file_infoSaved;
-   unz_file_info64_internal cur_file_info_internalSaved;
-   ZPOS64_T num_fileSaved;
-   ZPOS64_T pos_in_central_dirSaved;
-
-
-   if (file==NULL)
-      return UNZ_PARAMERROR;
-
-   if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
-      return UNZ_PARAMERROR;
-
-   s=(unz64_s*)file;
-   if (!s->current_file_ok)
-      return UNZ_END_OF_LIST_OF_FILE;
-
-   /* Save the current state */
-   num_fileSaved = s->num_file;
-   pos_in_central_dirSaved = s->pos_in_central_dir;
-   cur_file_infoSaved = s->cur_file_info;
-   cur_file_info_internalSaved = s->cur_file_info_internal;
-
-   err = unzGoToFirstFile(file);
-
-   while (err == UNZ_OK)
-   {
-      char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
-      err = unzGetCurrentFileInfo64(file,NULL,
-            szCurrentFileName,sizeof(szCurrentFileName)-1,
-            NULL,0,NULL,0);
-      if (err == UNZ_OK)
-      {
-         if (unzStringFileNameCompare(szCurrentFileName,
-                  szFileName,iCaseSensitivity)==0)
-            return UNZ_OK;
-         err = unzGoToNextFile(file);
-      }
-   }
-
-   /* We failed, so restore the state of the 'current file' to where we
-    * were.
-    */
-   s->num_file = num_fileSaved ;
-   s->pos_in_central_dir = pos_in_central_dirSaved ;
-   s->cur_file_info = cur_file_infoSaved;
-   s->cur_file_info_internal = cur_file_info_internalSaved;
-   return err;
-}
-
-
-/*
-///////////////////////////////////////////
-// Contributed by Ryan Haksi (mailto://cryogen@infoserve.net)
-// I need random access
-//
-// Further optimization could be realized by adding an ability
-// to cache the directory in memory. The goal being a single
-// comprehensive file read to put the file I need in a memory.
-*/
-
-/*
-   typedef struct unz_file_pos_s
-   {
-   ZPOS64_T pos_in_zip_directory;   // offset in file
-   ZPOS64_T num_of_file;            // # of file
-   } unz_file_pos;
-   */
-
-extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos*  file_pos)
-{
-   unz64_s* s;
-
-   if (file==NULL || file_pos==NULL)
-      return UNZ_PARAMERROR;
-   s=(unz64_s*)file;
-   if (!s->current_file_ok)
-      return UNZ_END_OF_LIST_OF_FILE;
-
-   file_pos->pos_in_zip_directory  = s->pos_in_central_dir;
-   file_pos->num_of_file           = s->num_file;
-
-   return UNZ_OK;
-}
-
-extern int ZEXPORT unzGetFilePos(
-      unzFile file,
-      unz_file_pos* file_pos)
-{
-   unz64_file_pos file_pos64;
-   int err = unzGetFilePos64(file,&file_pos64);
-   if (err==UNZ_OK)
-   {
-      file_pos->pos_in_zip_directory = (uLong)file_pos64.pos_in_zip_directory;
-      file_pos->num_of_file = (uLong)file_pos64.num_of_file;
-   }
-   return err;
-}
-
-extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos)
-{
-   unz64_s* s;
-   int err;
-
-   if (file==NULL || file_pos==NULL)
-      return UNZ_PARAMERROR;
-   s=(unz64_s*)file;
-
-   /* jump to the right spot */
-   s->pos_in_central_dir = file_pos->pos_in_zip_directory;
-   s->num_file           = file_pos->num_of_file;
-
-   /* set the current file */
-   err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
-         &s->cur_file_info_internal,
-         NULL,0,NULL,0,NULL,0);
-   /* return results */
-   s->current_file_ok = (err == UNZ_OK);
-   return err;
-}
-
-extern int ZEXPORT unzGoToFilePos(
-      unzFile file,
-      unz_file_pos* file_pos)
-{
-   unz64_file_pos file_pos64;
-   if (file_pos == NULL)
-      return UNZ_PARAMERROR;
-
-   file_pos64.pos_in_zip_directory = file_pos->pos_in_zip_directory;
-   file_pos64.num_of_file = file_pos->num_of_file;
-   return unzGoToFilePos64(file,&file_pos64);
-}
-
-/*
-// Unzip Helper Functions - should be here?
-///////////////////////////////////////////
-*/
-
-/*
-   Read the local header of the current zipfile
-   Check the coherency of the local header and info in the end of central
-   directory about this file
-   store in *piSizeVar the size of extra info in local header
-   (filename and size of extra field data)
-   */
-local int unz64local_CheckCurrentFileCoherencyHeader (unz64_s* s, uInt* piSizeVar,
-      ZPOS64_T * poffset_local_extrafield,
-      uInt  * psize_local_extrafield)
-{
-   uLong uMagic,uData,uFlags;
-   uLong size_filename;
-   uLong size_extra_field;
-   int err=UNZ_OK;
-
-   *piSizeVar = 0;
-   *poffset_local_extrafield = 0;
-   *psize_local_extrafield = 0;
-
-   if (ZSEEK64(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile +
-            s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0)
-      return UNZ_ERRNO;
-
-
-   if (err==UNZ_OK)
-   {
-      if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
-         err=UNZ_ERRNO;
-      else if (uMagic!=0x04034b50)
-         err=UNZ_BADZIPFILE;
-   }
-
-   if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
-      err=UNZ_ERRNO;
-   /*
-      else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
-      err=UNZ_BADZIPFILE;
-      */
-   if (unz64local_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK)
-      err=UNZ_ERRNO;
-
-   if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
-      err=UNZ_ERRNO;
-   else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
-      err=UNZ_BADZIPFILE;
-
-   if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
-         /* #ifdef HAVE_BZIP2 */
-         (s->cur_file_info.compression_method!=Z_BZIP2ED) &&
-         /* #endif */
-         (s->cur_file_info.compression_method!=Z_DEFLATED))
-      err=UNZ_BADZIPFILE;
-
-   if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */
-      err=UNZ_ERRNO;
-
-   if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */
-      err=UNZ_ERRNO;
-   else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && ((uFlags & 8)==0))
-      err=UNZ_BADZIPFILE;
-
-   if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */
-      err=UNZ_ERRNO;
-   else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && ((uFlags & 8)==0))
-      err=UNZ_BADZIPFILE;
-
-   if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */
-      err=UNZ_ERRNO;
-   else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && ((uFlags & 8)==0))
-      err=UNZ_BADZIPFILE;
-
-   if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK)
-      err=UNZ_ERRNO;
-   else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
-      err=UNZ_BADZIPFILE;
-
-   *piSizeVar += (uInt)size_filename;
-
-   if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK)
-      err=UNZ_ERRNO;
-   *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
-      SIZEZIPLOCALHEADER + size_filename;
-   *psize_local_extrafield = (uInt)size_extra_field;
-
-   *piSizeVar += (uInt)size_extra_field;
-
-   return err;
-}
-
-/*
-   Open for reading data the current file in the zipfile.
-   If there is no error and the file is opened, the return value is UNZ_OK.
-   */
-extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
-      int* level, int raw, const char* password)
-{
-   int err=UNZ_OK;
-   uInt iSizeVar;
-   unz64_s* s;
-   file_in_zip64_read_info_s* pfile_in_zip_read_info;
-   ZPOS64_T offset_local_extrafield;  /* offset of the local extra field */
-   uInt  size_local_extrafield;    /* size of the local extra field */
-#    ifndef NOUNCRYPT
-   char source[12];
-#    else
-   if (password != NULL)
-      return UNZ_PARAMERROR;
-#    endif
-
-   if (file==NULL)
-      return UNZ_PARAMERROR;
-   s=(unz64_s*)file;
-   if (!s->current_file_ok)
-      return UNZ_PARAMERROR;
-
-   if (s->pfile_in_zip_read != NULL)
-      unzCloseCurrentFile(file);
-
-   if (unz64local_CheckCurrentFileCoherencyHeader(s,&iSizeVar, &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
-      return UNZ_BADZIPFILE;
-
-   pfile_in_zip_read_info = (file_in_zip64_read_info_s*)ALLOC(sizeof(file_in_zip64_read_info_s));
-   if (pfile_in_zip_read_info==NULL)
-      return UNZ_INTERNALERROR;
-
-   pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE);
-   pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
-   pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
-   pfile_in_zip_read_info->pos_local_extrafield=0;
-   pfile_in_zip_read_info->raw=raw;
-
-   if (pfile_in_zip_read_info->read_buffer==NULL)
-   {
-      TRYFREE(pfile_in_zip_read_info);
-      return UNZ_INTERNALERROR;
-   }
-
-   pfile_in_zip_read_info->stream_initialised=0;
-
-   if (method!=NULL)
-      *method = (int)s->cur_file_info.compression_method;
-
-   if (level!=NULL)
-   {
-      *level = 6;
-      switch (s->cur_file_info.flag & 0x06)
-      {
-         case 6 : *level = 1; break;
-         case 4 : *level = 2; break;
-         case 2 : *level = 9; break;
-      }
-   }
-
-   if ((s->cur_file_info.compression_method!=0) &&
-         /* #ifdef HAVE_BZIP2 */
-         (s->cur_file_info.compression_method!=Z_BZIP2ED) &&
-         /* #endif */
-         (s->cur_file_info.compression_method!=Z_DEFLATED))
-
-      err=UNZ_BADZIPFILE;
-
-   pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;
-   pfile_in_zip_read_info->crc32=0;
-   pfile_in_zip_read_info->total_out_64=0;
-   pfile_in_zip_read_info->compression_method = s->cur_file_info.compression_method;
-   pfile_in_zip_read_info->filestream=s->filestream;
-   pfile_in_zip_read_info->z_filefunc=s->z_filefunc;
-   pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;
-
-   pfile_in_zip_read_info->stream.total_out = 0;
-
-   if ((s->cur_file_info.compression_method==Z_BZIP2ED) && (!raw))
-   {
-#ifdef HAVE_BZIP2
-      pfile_in_zip_read_info->bstream.bzalloc = (void *(*) (void *, int, int))0;
-      pfile_in_zip_read_info->bstream.bzfree = (free_func)0;
-      pfile_in_zip_read_info->bstream.opaque = (voidpf)0;
-      pfile_in_zip_read_info->bstream.state = (voidpf)0;
-
-      pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
-      pfile_in_zip_read_info->stream.zfree = (free_func)0;
-      pfile_in_zip_read_info->stream.opaque = (voidpf)0;
-      pfile_in_zip_read_info->stream.next_in = (voidpf)0;
-      pfile_in_zip_read_info->stream.avail_in = 0;
-
-      err=BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0);
-      if (err == Z_OK)
-         pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED;
-      else
-      {
-         TRYFREE(pfile_in_zip_read_info);
-         return err;
-      }
-#else
-      pfile_in_zip_read_info->raw=1;
-#endif
-   }
-   else if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw))
-   {
-      pfile_in_zip_read_info->stream.zalloc = Z_NULL;
-      pfile_in_zip_read_info->stream.zfree = Z_NULL;
-      pfile_in_zip_read_info->stream.opaque = (voidpf)0;
-      pfile_in_zip_read_info->stream.next_in = 0;
-      pfile_in_zip_read_info->stream.avail_in = 0;
-
-      err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
-      if (err == Z_OK)
-         pfile_in_zip_read_info->stream_initialised=Z_DEFLATED;
-      else
-      {
-         TRYFREE(pfile_in_zip_read_info);
-         return err;
-      }
-      /* windowBits is passed < 0 to tell that there is no zlib header.
-       * Note that in this case inflate *requires* an extra "dummy" byte
-       * after the compressed stream in order to complete decompression and
-       * return Z_STREAM_END.
-       * In unzip, i don't wait absolutely Z_STREAM_END because I known the
-       * size of both compressed and uncompressed data
-       */
-   }
-   pfile_in_zip_read_info->rest_read_compressed =
-      s->cur_file_info.compressed_size ;
-   pfile_in_zip_read_info->rest_read_uncompressed =
-      s->cur_file_info.uncompressed_size ;
-
-
-   pfile_in_zip_read_info->pos_in_zipfile =
-      s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
-      iSizeVar;
-
-   pfile_in_zip_read_info->stream.avail_in = (uInt)0;
-
-   s->pfile_in_zip_read = pfile_in_zip_read_info;
-   s->encrypted = 0;
-
-#    ifndef NOUNCRYPT
-   if (password != NULL)
-   {
-      int i;
-      s->pcrc_32_tab = get_crc_table();
-      init_keys(password,s->keys,s->pcrc_32_tab);
-      if (ZSEEK64(s->z_filefunc, s->filestream,
-               s->pfile_in_zip_read->pos_in_zipfile +
-               s->pfile_in_zip_read->byte_before_the_zipfile,
-               SEEK_SET)!=0)
-         return UNZ_INTERNALERROR;
-      if(ZREAD64(s->z_filefunc, s->filestream,source, 12)<12)
-         return UNZ_INTERNALERROR;
-
-      for (i = 0; i<12; i++)
-         zdecode(s->keys,s->pcrc_32_tab,source[i]);
-
-      s->pfile_in_zip_read->pos_in_zipfile+=12;
-      s->encrypted=1;
-   }
-#    endif
-
-
-   return UNZ_OK;
-}
-
-extern int ZEXPORT unzOpenCurrentFile (unzFile file)
-{
-   return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
-}
-
-extern int ZEXPORT unzOpenCurrentFilePassword (unzFile file, const char*  password)
-{
-   return unzOpenCurrentFile3(file, NULL, NULL, 0, password);
-}
-
-extern int ZEXPORT unzOpenCurrentFile2 (unzFile file, int* method, int* level, int raw)
-{
-   return unzOpenCurrentFile3(file, method, level, raw, NULL);
-}
-
-/** Addition for GDAL : START */
-
-extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64( unzFile file)
-{
-   unz64_s* s;
-   file_in_zip64_read_info_s* pfile_in_zip_read_info;
-   s=(unz64_s*)file;
-   if (file==NULL)
-      return 0; //UNZ_PARAMERROR;
-   pfile_in_zip_read_info=s->pfile_in_zip_read;
-   if (pfile_in_zip_read_info==NULL)
-      return 0; //UNZ_PARAMERROR;
-   return pfile_in_zip_read_info->pos_in_zipfile +
-      pfile_in_zip_read_info->byte_before_the_zipfile;
-}
-
-/** Addition for GDAL : END */
-
-/*
-   Read bytes from the current file.
-   buf contain buffer where data must be copied
-   len the size of buf.
-
-   return the number of byte copied if somes bytes are copied
-   return 0 if the end of file was reached
-   return <0 with error code if there is an error
-   (UNZ_ERRNO for IO error, or zLib error for uncompress error)
-   */
-extern int ZEXPORT unzReadCurrentFile  (unzFile file, voidp buf, unsigned len)
-{
-   int err=UNZ_OK;
-   uInt iRead = 0;
-   unz64_s* s;
-   file_in_zip64_read_info_s* pfile_in_zip_read_info;
-   if (file==NULL)
-      return UNZ_PARAMERROR;
-   s=(unz64_s*)file;
-   pfile_in_zip_read_info=s->pfile_in_zip_read;
-
-   if (pfile_in_zip_read_info==NULL)
-      return UNZ_PARAMERROR;
-
-
-   if (pfile_in_zip_read_info->read_buffer == NULL)
-      return UNZ_END_OF_LIST_OF_FILE;
-   if (len==0)
-      return 0;
-
-   pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
-
-   pfile_in_zip_read_info->stream.avail_out = (uInt)len;
-
-   if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&
-         (!(pfile_in_zip_read_info->raw)))
-      pfile_in_zip_read_info->stream.avail_out =
-         (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
-
-   if ((len>pfile_in_zip_read_info->rest_read_compressed+
-            pfile_in_zip_read_info->stream.avail_in) &&
-         (pfile_in_zip_read_info->raw))
-      pfile_in_zip_read_info->stream.avail_out =
-         (uInt)pfile_in_zip_read_info->rest_read_compressed+
-         pfile_in_zip_read_info->stream.avail_in;
-
-   while (pfile_in_zip_read_info->stream.avail_out>0)
-   {
-      if ((pfile_in_zip_read_info->stream.avail_in==0) &&
-            (pfile_in_zip_read_info->rest_read_compressed>0))
-      {
-         uInt uReadThis = UNZ_BUFSIZE;
-         if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
-            uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
-         if (uReadThis == 0)
-            return UNZ_EOF;
-         if (ZSEEK64(pfile_in_zip_read_info->z_filefunc,
-                  pfile_in_zip_read_info->filestream,
-                  pfile_in_zip_read_info->pos_in_zipfile +
-                  pfile_in_zip_read_info->byte_before_the_zipfile,
-                  ZLIB_FILEFUNC_SEEK_SET)!=0)
-            return UNZ_ERRNO;
-         if (ZREAD64(pfile_in_zip_read_info->z_filefunc,
-                  pfile_in_zip_read_info->filestream,
-                  pfile_in_zip_read_info->read_buffer,
-                  uReadThis)!=uReadThis)
-            return UNZ_ERRNO;
-
-
-#            ifndef NOUNCRYPT
-         if(s->encrypted)
-         {
-            uInt i;
-            for(i=0;i<uReadThis;i++)
-               pfile_in_zip_read_info->read_buffer[i] =
-                  zdecode(s->keys,s->pcrc_32_tab,
-                        pfile_in_zip_read_info->read_buffer[i]);
-         }
-#            endif
-
-
-         pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
-
-         pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
-
-         pfile_in_zip_read_info->stream.next_in =
-            (Bytef*)pfile_in_zip_read_info->read_buffer;
-         pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
-      }
-
-      if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw))
-      {
-         uInt uDoCopy,i ;
-
-         if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
-               (pfile_in_zip_read_info->rest_read_compressed == 0))
-            return (iRead==0) ? UNZ_EOF : iRead;
-
-         if (pfile_in_zip_read_info->stream.avail_out <
-               pfile_in_zip_read_info->stream.avail_in)
-            uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
-         else
-            uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
-
-         for (i=0;i<uDoCopy;i++)
-            *(pfile_in_zip_read_info->stream.next_out+i) =
-               *(pfile_in_zip_read_info->stream.next_in+i);
-
-         pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uDoCopy;
-
-         pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
-               pfile_in_zip_read_info->stream.next_out,
-               uDoCopy);
-         pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;
-         pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
-         pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
-         pfile_in_zip_read_info->stream.next_out += uDoCopy;
-         pfile_in_zip_read_info->stream.next_in += uDoCopy;
-         pfile_in_zip_read_info->stream.total_out += uDoCopy;
-         iRead += uDoCopy;
-      }
-      else if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED)
-      {
-#ifdef HAVE_BZIP2
-         uLong uTotalOutBefore,uTotalOutAfter;
-         const Bytef *bufBefore;
-         uLong uOutThis;
-
-         pfile_in_zip_read_info->bstream.next_in        = (char*)pfile_in_zip_read_info->stream.next_in;
-         pfile_in_zip_read_info->bstream.avail_in       = pfile_in_zip_read_info->stream.avail_in;
-         pfile_in_zip_read_info->bstream.total_in_lo32  = pfile_in_zip_read_info->stream.total_in;
-         pfile_in_zip_read_info->bstream.total_in_hi32  = 0;
-         pfile_in_zip_read_info->bstream.next_out       = (char*)pfile_in_zip_read_info->stream.next_out;
-         pfile_in_zip_read_info->bstream.avail_out      = pfile_in_zip_read_info->stream.avail_out;
-         pfile_in_zip_read_info->bstream.total_out_lo32 = pfile_in_zip_read_info->stream.total_out;
-         pfile_in_zip_read_info->bstream.total_out_hi32 = 0;
-
-         uTotalOutBefore = pfile_in_zip_read_info->bstream.total_out_lo32;
-         bufBefore = (const Bytef *)pfile_in_zip_read_info->bstream.next_out;
-
-         err=BZ2_bzDecompress(&pfile_in_zip_read_info->bstream);
-
-         uTotalOutAfter = pfile_in_zip_read_info->bstream.total_out_lo32;
-         uOutThis = uTotalOutAfter-uTotalOutBefore;
-
-         pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;
-
-         pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis));
-         pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis;
-         iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
-
-         pfile_in_zip_read_info->stream.next_in   = (Bytef*)pfile_in_zip_read_info->bstream.next_in;
-         pfile_in_zip_read_info->stream.avail_in  = pfile_in_zip_read_info->bstream.avail_in;
-         pfile_in_zip_read_info->stream.total_in  = pfile_in_zip_read_info->bstream.total_in_lo32;
-         pfile_in_zip_read_info->stream.next_out  = (Bytef*)pfile_in_zip_read_info->bstream.next_out;
-         pfile_in_zip_read_info->stream.avail_out = pfile_in_zip_read_info->bstream.avail_out;
-         pfile_in_zip_read_info->stream.total_out = pfile_in_zip_read_info->bstream.total_out_lo32;
-
-         if (err==BZ_STREAM_END)
-            return (iRead==0) ? UNZ_EOF : iRead;
-         if (err!=BZ_OK)
-            break;
-#endif
-      } // end Z_BZIP2ED
-      else
-      {
-         ZPOS64_T uTotalOutBefore,uTotalOutAfter;
-         const Bytef *bufBefore;
-         ZPOS64_T uOutThis;
-         int flush=Z_SYNC_FLUSH;
-
-         uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
-         bufBefore = pfile_in_zip_read_info->stream.next_out;
-
-         /*
-            if ((pfile_in_zip_read_info->rest_read_uncompressed ==
-            pfile_in_zip_read_info->stream.avail_out) &&
-            (pfile_in_zip_read_info->rest_read_compressed == 0))
-            flush = Z_FINISH;
-            */
-         err=inflate(&pfile_in_zip_read_info->stream,flush);
-
-         if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL))
-            err = Z_DATA_ERROR;
-
-         uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
-         uOutThis = uTotalOutAfter-uTotalOutBefore;
-
-         pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;
-
-         pfile_in_zip_read_info->crc32 =
-            crc32(pfile_in_zip_read_info->crc32,bufBefore,
-                  (uInt)(uOutThis));
-
-         pfile_in_zip_read_info->rest_read_uncompressed -=
-            uOutThis;
-
-         iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
-
-         if (err==Z_STREAM_END)
-            return (iRead==0) ? UNZ_EOF : iRead;
-         if (err!=Z_OK)
-            break;
-      }
-   }
-
-   if (err==Z_OK)
-      return iRead;
-   return err;
-}
-
-
-/*
-   Give the current position in uncompressed data
-   */
-extern z_off_t ZEXPORT unztell (unzFile file)
-{
-   unz64_s* s;
-   file_in_zip64_read_info_s* pfile_in_zip_read_info;
-   if (file==NULL)
-      return UNZ_PARAMERROR;
-   s=(unz64_s*)file;
-   pfile_in_zip_read_info=s->pfile_in_zip_read;
-
-   if (pfile_in_zip_read_info==NULL)
-      return UNZ_PARAMERROR;
-
-   return (z_off_t)pfile_in_zip_read_info->stream.total_out;
-}
-
-extern ZPOS64_T ZEXPORT unztell64 (unzFile file)
-{
-
-   unz64_s* s;
-   file_in_zip64_read_info_s* pfile_in_zip_read_info;
-   if (file==NULL)
-      return (ZPOS64_T)-1;
-   s=(unz64_s*)file;
-   pfile_in_zip_read_info=s->pfile_in_zip_read;
-
-   if (pfile_in_zip_read_info==NULL)
-      return (ZPOS64_T)-1;
-
-   return pfile_in_zip_read_info->total_out_64;
-}
-
-
-/*
-   return 1 if the end of file was reached, 0 elsewhere
-   */
-extern int ZEXPORT unzeof (unzFile file)
-{
-   unz64_s* s;
-   file_in_zip64_read_info_s* pfile_in_zip_read_info;
-   if (file==NULL)
-      return UNZ_PARAMERROR;
-   s=(unz64_s*)file;
-   pfile_in_zip_read_info=s->pfile_in_zip_read;
-
-   if (pfile_in_zip_read_info==NULL)
-      return UNZ_PARAMERROR;
-
-   if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
-      return 1;
-   else
-      return 0;
-}
-
-
-
-/*
-   Read extra field from the current file (opened by unzOpenCurrentFile)
-   This is the local-header version of the extra field (sometimes, there is
-   more info in the local-header version than in the central-header)
-
-   if buf==NULL, it return the size of the local extra field that can be read
-
-   if buf!=NULL, len is the size of the buffer, the extra header is copied in
-   buf.
-   the return value is the number of bytes copied in buf, or (if <0)
-   the error code
-   */
-extern int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned len)
-{
-   unz64_s* s;
-   file_in_zip64_read_info_s* pfile_in_zip_read_info;
-   uInt read_now;
-   ZPOS64_T size_to_read;
-
-   if (file==NULL)
-      return UNZ_PARAMERROR;
-   s=(unz64_s*)file;
-   pfile_in_zip_read_info=s->pfile_in_zip_read;
-
-   if (pfile_in_zip_read_info==NULL)
-      return UNZ_PARAMERROR;
-
-   size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
-         pfile_in_zip_read_info->pos_local_extrafield);
-
-   if (buf==NULL)
-      return (int)size_to_read;
-
-   if (len>size_to_read)
-      read_now = (uInt)size_to_read;
-   else
-      read_now = (uInt)len ;
-
-   if (read_now==0)
-      return 0;
-
-   if (ZSEEK64(pfile_in_zip_read_info->z_filefunc,
-            pfile_in_zip_read_info->filestream,
-            pfile_in_zip_read_info->offset_local_extrafield +
-            pfile_in_zip_read_info->pos_local_extrafield,
-            ZLIB_FILEFUNC_SEEK_SET)!=0)
-      return UNZ_ERRNO;
-
-   if (ZREAD64(pfile_in_zip_read_info->z_filefunc,
-            pfile_in_zip_read_info->filestream,
-            buf,read_now)!=read_now)
-      return UNZ_ERRNO;
-
-   return (int)read_now;
-}
-
-/*
-   Close the file in zip opened with unzipOpenCurrentFile
-   Return UNZ_CRCERROR if all the file was read but the CRC is not good
-   */
-extern int ZEXPORT unzCloseCurrentFile (unzFile file)
-{
-   int err=UNZ_OK;
-
-   unz64_s* s;
-   file_in_zip64_read_info_s* pfile_in_zip_read_info;
-   if (file==NULL)
-      return UNZ_PARAMERROR;
-   s=(unz64_s*)file;
-   pfile_in_zip_read_info=s->pfile_in_zip_read;
-
-   if (pfile_in_zip_read_info==NULL)
-      return UNZ_PARAMERROR;
-
-
-   if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) &&
-         (!pfile_in_zip_read_info->raw))
-   {
-      if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
-         err=UNZ_CRCERROR;
-   }
-
-
-   TRYFREE(pfile_in_zip_read_info->read_buffer);
-   pfile_in_zip_read_info->read_buffer = NULL;
-   if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED)
-      inflateEnd(&pfile_in_zip_read_info->stream);
-#ifdef HAVE_BZIP2
-   else if (pfile_in_zip_read_info->stream_initialised == Z_BZIP2ED)
-      BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream);
-#endif
-
-
-   pfile_in_zip_read_info->stream_initialised = 0;
-   TRYFREE(pfile_in_zip_read_info);
-
-   s->pfile_in_zip_read=NULL;
-
-   return err;
-}
-
-
-/*
-   Get the global comment string of the ZipFile, in the szComment buffer.
-   uSizeBuf is the size of the szComment buffer.
-   return the number of byte copied or an error code <0
-   */
-extern int ZEXPORT unzGetGlobalComment (unzFile file, char * szComment, uLong uSizeBuf)
-{
-   unz64_s* s;
-   uLong uReadThis ;
-   if (file==NULL)
-      return (int)UNZ_PARAMERROR;
-   s=(unz64_s*)file;
-
-   uReadThis = uSizeBuf;
-   if (uReadThis>s->gi.size_comment)
-      uReadThis = s->gi.size_comment;
-
-   if (ZSEEK64(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0)
-      return UNZ_ERRNO;
-
-   if (uReadThis>0)
-   {
-      *szComment='\0';
-      if (ZREAD64(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis)
-         return UNZ_ERRNO;
-   }
-
-   if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
-      *(szComment+s->gi.size_comment)='\0';
-   return (int)uReadThis;
-}
-
-/* Additions by RX '2004 */
-extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file)
-{
-   unz64_s* s;
-
-   if (file==NULL)
-      return 0; //UNZ_PARAMERROR;
-   s=(unz64_s*)file;
-   if (!s->current_file_ok)
-      return 0;
-   if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff)
-      if (s->num_file==s->gi.number_entry)
-         return 0;
-   return s->pos_in_central_dir;
-}
-
-extern uLong ZEXPORT unzGetOffset (unzFile file)
-{
-   ZPOS64_T offset64;
-
-   if (file==NULL)
-      return 0; //UNZ_PARAMERROR;
-   offset64 = unzGetOffset64(file);
-   return (uLong)offset64;
-}
-
-extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos)
-{
-   unz64_s* s;
-   int err;
-
-   if (file==NULL)
-      return UNZ_PARAMERROR;
-   s=(unz64_s*)file;
-
-   s->pos_in_central_dir = pos;
-   s->num_file = s->gi.number_entry;      /* hack */
-   err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
-         &s->cur_file_info_internal,
-         NULL,0,NULL,0,NULL,0);
-   s->current_file_ok = (err == UNZ_OK);
-   return err;
-}
-
-extern int ZEXPORT unzSetOffset (unzFile file, uLong pos)
-{
-   return unzSetOffset64(file,pos);
-}
diff --git a/deps/zlib/unzip.h b/deps/zlib/unzip.h
deleted file mode 100644 (file)
index 3183968..0000000
+++ /dev/null
@@ -1,437 +0,0 @@
-/* unzip.h -- IO for uncompress .zip files using zlib
-   Version 1.1, February 14h, 2010
-   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
-
-         Modifications of Unzip for Zip64
-         Copyright (C) 2007-2008 Even Rouault
-
-         Modifications for Zip64 support on both zip and unzip
-         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
-
-         For more info read MiniZip_info.txt
-
-         ---------------------------------------------------------------------------------
-
-        Condition of use and distribution are the same than zlib :
-
-  This software is provided 'as-is', without any express or implied
-  warranty.  In no event will the authors be held liable for any damages
-  arising from the use of this software.
-
-  Permission is granted to anyone to use this software for any purpose,
-  including commercial applications, and to alter it and redistribute it
-  freely, subject to the following restrictions:
-
-  1. The origin of this software must not be misrepresented; you must not
-     claim that you wrote the original software. If you use this software
-     in a product, an acknowledgment in the product documentation would be
-     appreciated but is not required.
-  2. Altered source versions must be plainly marked as such, and must not be
-     misrepresented as being the original software.
-  3. This notice may not be removed or altered from any source distribution.
-
-  ---------------------------------------------------------------------------------
-
-        Changes
-
-        See header of unzip64.c
-
-*/
-
-#ifndef _unz64_H
-#define _unz64_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _ZLIB_H
-#include "zlib.h"
-#endif
-
-#ifndef  _ZLIBIOAPI_H
-#include "ioapi.h"
-#endif
-
-#ifdef HAVE_BZIP2
-#include "bzlib.h"
-#endif
-
-#define Z_BZIP2ED 12
-
-#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
-/* like the STRICT of WIN32, we define a pointer that cannot be converted
-    from (void*) without cast */
-typedef struct TagunzFile__ { int unused; } unzFile__;
-typedef unzFile__ *unzFile;
-#else
-typedef voidp unzFile;
-#endif
-
-
-#define UNZ_OK                          (0)
-#define UNZ_END_OF_LIST_OF_FILE         (-100)
-#define UNZ_ERRNO                       (Z_ERRNO)
-#define UNZ_EOF                         (0)
-#define UNZ_PARAMERROR                  (-102)
-#define UNZ_BADZIPFILE                  (-103)
-#define UNZ_INTERNALERROR               (-104)
-#define UNZ_CRCERROR                    (-105)
-
-/* tm_unz contain date/time info */
-typedef struct tm_unz_s
-{
-    uInt tm_sec;            /* seconds after the minute - [0,59] */
-    uInt tm_min;            /* minutes after the hour - [0,59] */
-    uInt tm_hour;           /* hours since midnight - [0,23] */
-    uInt tm_mday;           /* day of the month - [1,31] */
-    uInt tm_mon;            /* months since January - [0,11] */
-    uInt tm_year;           /* years - [1980..2044] */
-} tm_unz;
-
-/* unz_global_info structure contain global data about the ZIPfile
-   These data comes from the end of central dir */
-typedef struct unz_global_info64_s
-{
-    ZPOS64_T number_entry;         /* total number of entries in
-                                     the central dir on this disk */
-    uLong size_comment;         /* size of the global comment of the zipfile */
-} unz_global_info64;
-
-typedef struct unz_global_info_s
-{
-    uLong number_entry;         /* total number of entries in
-                                     the central dir on this disk */
-    uLong size_comment;         /* size of the global comment of the zipfile */
-} unz_global_info;
-
-/* unz_file_info contain information about a file in the zipfile */
-typedef struct unz_file_info64_s
-{
-    uLong version;              /* version made by                 2 bytes */
-    uLong version_needed;       /* version needed to extract       2 bytes */
-    uLong flag;                 /* general purpose bit flag        2 bytes */
-    uLong compression_method;   /* compression method              2 bytes */
-    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */
-    uLong crc;                  /* crc-32                          4 bytes */
-    ZPOS64_T compressed_size;   /* compressed size                 8 bytes */
-    ZPOS64_T uncompressed_size; /* uncompressed size               8 bytes */
-    uLong size_filename;        /* filename length                 2 bytes */
-    uLong size_file_extra;      /* extra field length              2 bytes */
-    uLong size_file_comment;    /* file comment length             2 bytes */
-
-    uLong disk_num_start;       /* disk number start               2 bytes */
-    uLong internal_fa;          /* internal file attributes        2 bytes */
-    uLong external_fa;          /* external file attributes        4 bytes */
-
-    tm_unz tmu_date;
-} unz_file_info64;
-
-typedef struct unz_file_info_s
-{
-    uLong version;              /* version made by                 2 bytes */
-    uLong version_needed;       /* version needed to extract       2 bytes */
-    uLong flag;                 /* general purpose bit flag        2 bytes */
-    uLong compression_method;   /* compression method              2 bytes */
-    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */
-    uLong crc;                  /* crc-32                          4 bytes */
-    uLong compressed_size;      /* compressed size                 4 bytes */
-    uLong uncompressed_size;    /* uncompressed size               4 bytes */
-    uLong size_filename;        /* filename length                 2 bytes */
-    uLong size_file_extra;      /* extra field length              2 bytes */
-    uLong size_file_comment;    /* file comment length             2 bytes */
-
-    uLong disk_num_start;       /* disk number start               2 bytes */
-    uLong internal_fa;          /* internal file attributes        2 bytes */
-    uLong external_fa;          /* external file attributes        4 bytes */
-
-    tm_unz tmu_date;
-} unz_file_info;
-
-extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
-                                                 const char* fileName2,
-                                                 int iCaseSensitivity));
-/*
-   Compare two filename (fileName1,fileName2).
-   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
-   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
-                                or strcasecmp)
-   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
-    (like 1 on Unix, 2 on Windows)
-*/
-
-
-extern unzFile ZEXPORT unzOpen OF((const char *path));
-extern unzFile ZEXPORT unzOpen64 OF((const void *path));
-/*
-  Open a Zip file. path contain the full pathname (by example,
-     on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
-     "zlib/zlib113.zip".
-     If the zipfile cannot be opened (file don't exist or in not valid), the
-       return value is NULL.
-     Else, the return value is a unzFile Handle, usable with other function
-       of this unzip package.
-     the "64" function take a const void* pointer, because the path is just the
-       value passed to the open64_file_func callback.
-     Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path
-       is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char*
-       does not describe the reality
-*/
-
-
-extern unzFile ZEXPORT unzOpen2 OF((const char *path,
-                                    zlib_filefunc_def* pzlib_filefunc_def));
-/*
-   Open a Zip file, like unzOpen, but provide a set of file low level API
-      for read/write the zip file (see ioapi.h)
-*/
-
-extern unzFile ZEXPORT unzOpen2_64 OF((const void *path,
-                                    zlib_filefunc64_def* pzlib_filefunc_def));
-/*
-   Open a Zip file, like unz64Open, but provide a set of file low level API
-      for read/write the zip file (see ioapi.h)
-*/
-
-extern int ZEXPORT unzClose OF((unzFile file));
-/*
-  Close a ZipFile opened with unzipOpen.
-  If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
-    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
-  return UNZ_OK if there is no problem. */
-
-extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
-                                        unz_global_info *pglobal_info));
-
-extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,
-                                        unz_global_info64 *pglobal_info));
-/*
-  Write info about the ZipFile in the *pglobal_info structure.
-  No preparation of the structure is needed
-  return UNZ_OK if there is no problem. */
-
-
-extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
-                                           char *szComment,
-                                           uLong uSizeBuf));
-/*
-  Get the global comment string of the ZipFile, in the szComment buffer.
-  uSizeBuf is the size of the szComment buffer.
-  return the number of byte copied or an error code <0
-*/
-
-
-/***************************************************************************/
-/* Unzip package allow you browse the directory of the zipfile */
-
-extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
-/*
-  Set the current file of the zipfile to the first file.
-  return UNZ_OK if there is no problem
-*/
-
-extern int ZEXPORT unzGoToNextFile OF((unzFile file));
-/*
-  Set the current file of the zipfile to the next file.
-  return UNZ_OK if there is no problem
-  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
-*/
-
-extern int ZEXPORT unzLocateFile OF((unzFile file,
-                     const char *szFileName,
-                     int iCaseSensitivity));
-/*
-  Try locate the file szFileName in the zipfile.
-  For the iCaseSensitivity signification, see unzStringFileNameCompare
-
-  return value :
-  UNZ_OK if the file is found. It becomes the current file.
-  UNZ_END_OF_LIST_OF_FILE if the file is not found
-*/
-
-
-/* ****************************************** */
-/* Ryan supplied functions */
-/* unz_file_info contain information about a file in the zipfile */
-typedef struct unz_file_pos_s
-{
-    uLong pos_in_zip_directory;   /* offset in zip file directory */
-    uLong num_of_file;            /* # of file */
-} unz_file_pos;
-
-extern int ZEXPORT unzGetFilePos(
-    unzFile file,
-    unz_file_pos* file_pos);
-
-extern int ZEXPORT unzGoToFilePos(
-    unzFile file,
-    unz_file_pos* file_pos);
-
-typedef struct unz64_file_pos_s
-{
-    ZPOS64_T pos_in_zip_directory;   /* offset in zip file directory */
-    ZPOS64_T num_of_file;            /* # of file */
-} unz64_file_pos;
-
-extern int ZEXPORT unzGetFilePos64(
-    unzFile file,
-    unz64_file_pos* file_pos);
-
-extern int ZEXPORT unzGoToFilePos64(
-    unzFile file,
-    const unz64_file_pos* file_pos);
-
-/* ****************************************** */
-
-extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,
-                         unz_file_info64 *pfile_info,
-                         char *szFileName,
-                         uLong fileNameBufferSize,
-                         void *extraField,
-                         uLong extraFieldBufferSize,
-                         char *szComment,
-                         uLong commentBufferSize));
-
-extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
-                         unz_file_info *pfile_info,
-                         char *szFileName,
-                         uLong fileNameBufferSize,
-                         void *extraField,
-                         uLong extraFieldBufferSize,
-                         char *szComment,
-                         uLong commentBufferSize));
-/*
-  Get Info about the current file
-  if pfile_info!=NULL, the *pfile_info structure will contain somes info about
-        the current file
-  if szFileName!=NULL, the filemane string will be copied in szFileName
-            (fileNameBufferSize is the size of the buffer)
-  if extraField!=NULL, the extra field information will be copied in extraField
-            (extraFieldBufferSize is the size of the buffer).
-            This is the Central-header version of the extra field
-  if szComment!=NULL, the comment string of the file will be copied in szComment
-            (commentBufferSize is the size of the buffer)
-*/
-
-
-/** Addition for GDAL : START */
-
-extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
-
-/** Addition for GDAL : END */
-
-
-/***************************************************************************/
-/* for reading the content of the current zipfile, you can open it, read data
-   from it, and close it (you can close it before reading all the file)
-   */
-
-extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
-/*
-  Open for reading data the current file in the zipfile.
-  If there is no error, the return value is UNZ_OK.
-*/
-
-extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
-                                                  const char* password));
-/*
-  Open for reading data the current file in the zipfile.
-  password is a crypting password
-  If there is no error, the return value is UNZ_OK.
-*/
-
-extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
-                                           int* method,
-                                           int* level,
-                                           int raw));
-/*
-  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
-    if raw==1
-  *method will receive method of compression, *level will receive level of
-     compression
-  note : you can set level parameter as NULL (if you did not want known level,
-         but you CANNOT set method parameter as NULL
-*/
-
-extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
-                                           int* method,
-                                           int* level,
-                                           int raw,
-                                           const char* password));
-/*
-  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
-    if raw==1
-  *method will receive method of compression, *level will receive level of
-     compression
-  note : you can set level parameter as NULL (if you did not want known level,
-         but you CANNOT set method parameter as NULL
-*/
-
-
-extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
-/*
-  Close the file in zip opened with unzOpenCurrentFile
-  Return UNZ_CRCERROR if all the file was read but the CRC is not good
-*/
-
-extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
-                      voidp buf,
-                      unsigned len));
-/*
-  Read bytes from the current file (opened by unzOpenCurrentFile)
-  buf contain buffer where data must be copied
-  len the size of buf.
-
-  return the number of byte copied if somes bytes are copied
-  return 0 if the end of file was reached
-  return <0 with error code if there is an error
-    (UNZ_ERRNO for IO error, or zLib error for uncompress error)
-*/
-
-extern z_off_t ZEXPORT unztell OF((unzFile file));
-
-extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
-/*
-  Give the current position in uncompressed data
-*/
-
-extern int ZEXPORT unzeof OF((unzFile file));
-/*
-  return 1 if the end of file was reached, 0 elsewhere
-*/
-
-extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
-                                             voidp buf,
-                                             unsigned len));
-/*
-  Read extra field from the current file (opened by unzOpenCurrentFile)
-  This is the local-header version of the extra field (sometimes, there is
-    more info in the local-header version than in the central-header)
-
-  if buf==NULL, it return the size of the local extra field
-
-  if buf!=NULL, len is the size of the buffer, the extra header is copied in
-    buf.
-  the return value is the number of bytes copied in buf, or (if <0)
-    the error code
-*/
-
-/***************************************************************************/
-
-/* Get the current file offset */
-extern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file);
-extern uLong ZEXPORT unzGetOffset (unzFile file);
-
-/* Set the current file offset */
-extern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos);
-extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _unz64_H */
diff --git a/deps/zlib/zconf.h b/deps/zlib/zconf.h
deleted file mode 100644 (file)
index 9987a77..0000000
+++ /dev/null
@@ -1,511 +0,0 @@
-/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2013 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#ifndef ZCONF_H
-#define ZCONF_H
-
-/*
- * If you *really* need a unique prefix for all types and library functions,
- * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
- * Even better than compiling with -DZ_PREFIX would be to use configure to set
- * this permanently in zconf.h using "./configure --zprefix".
- */
-#ifdef Z_PREFIX     /* may be set to #if 1 by ./configure */
-#  define Z_PREFIX_SET
-
-/* all linked symbols */
-#  define _dist_code            z__dist_code
-#  define _length_code          z__length_code
-#  define _tr_align             z__tr_align
-#  define _tr_flush_bits        z__tr_flush_bits
-#  define _tr_flush_block       z__tr_flush_block
-#  define _tr_init              z__tr_init
-#  define _tr_stored_block      z__tr_stored_block
-#  define _tr_tally             z__tr_tally
-#  define adler32               z_adler32
-#  define adler32_combine       z_adler32_combine
-#  define adler32_combine64     z_adler32_combine64
-#  ifndef Z_SOLO
-#    define compress              z_compress
-#    define compress2             z_compress2
-#    define compressBound         z_compressBound
-#  endif
-#  define crc32                 z_crc32
-#  define crc32_combine         z_crc32_combine
-#  define crc32_combine64       z_crc32_combine64
-#  define deflate               z_deflate
-#  define deflateBound          z_deflateBound
-#  define deflateCopy           z_deflateCopy
-#  define deflateEnd            z_deflateEnd
-#  define deflateInit2_         z_deflateInit2_
-#  define deflateInit_          z_deflateInit_
-#  define deflateParams         z_deflateParams
-#  define deflatePending        z_deflatePending
-#  define deflatePrime          z_deflatePrime
-#  define deflateReset          z_deflateReset
-#  define deflateResetKeep      z_deflateResetKeep
-#  define deflateSetDictionary  z_deflateSetDictionary
-#  define deflateSetHeader      z_deflateSetHeader
-#  define deflateTune           z_deflateTune
-#  define deflate_copyright     z_deflate_copyright
-#  define get_crc_table         z_get_crc_table
-#  ifndef Z_SOLO
-#    define gz_error              z_gz_error
-#    define gz_intmax             z_gz_intmax
-#    define gz_strwinerror        z_gz_strwinerror
-#    define gzbuffer              z_gzbuffer
-#    define gzclearerr            z_gzclearerr
-#    define gzclose               z_gzclose
-#    define gzclose_r             z_gzclose_r
-#    define gzclose_w             z_gzclose_w
-#    define gzdirect              z_gzdirect
-#    define gzdopen               z_gzdopen
-#    define gzeof                 z_gzeof
-#    define gzerror               z_gzerror
-#    define gzflush               z_gzflush
-#    define gzgetc                z_gzgetc
-#    define gzgetc_               z_gzgetc_
-#    define gzgets                z_gzgets
-#    define gzoffset              z_gzoffset
-#    define gzoffset64            z_gzoffset64
-#    define gzopen                z_gzopen
-#    define gzopen64              z_gzopen64
-#    ifdef _WIN32
-#      define gzopen_w              z_gzopen_w
-#    endif
-#    define gzprintf              z_gzprintf
-#    define gzvprintf             z_gzvprintf
-#    define gzputc                z_gzputc
-#    define gzputs                z_gzputs
-#    define gzread                z_gzread
-#    define gzrewind              z_gzrewind
-#    define gzseek                z_gzseek
-#    define gzseek64              z_gzseek64
-#    define gzsetparams           z_gzsetparams
-#    define gztell                z_gztell
-#    define gztell64              z_gztell64
-#    define gzungetc              z_gzungetc
-#    define gzwrite               z_gzwrite
-#  endif
-#  define inflate               z_inflate
-#  define inflateBack           z_inflateBack
-#  define inflateBackEnd        z_inflateBackEnd
-#  define inflateBackInit_      z_inflateBackInit_
-#  define inflateCopy           z_inflateCopy
-#  define inflateEnd            z_inflateEnd
-#  define inflateGetHeader      z_inflateGetHeader
-#  define inflateInit2_         z_inflateInit2_
-#  define inflateInit_          z_inflateInit_
-#  define inflateMark           z_inflateMark
-#  define inflatePrime          z_inflatePrime
-#  define inflateReset          z_inflateReset
-#  define inflateReset2         z_inflateReset2
-#  define inflateSetDictionary  z_inflateSetDictionary
-#  define inflateGetDictionary  z_inflateGetDictionary
-#  define inflateSync           z_inflateSync
-#  define inflateSyncPoint      z_inflateSyncPoint
-#  define inflateUndermine      z_inflateUndermine
-#  define inflateResetKeep      z_inflateResetKeep
-#  define inflate_copyright     z_inflate_copyright
-#  define inflate_fast          z_inflate_fast
-#  define inflate_table         z_inflate_table
-#  ifndef Z_SOLO
-#    define uncompress            z_uncompress
-#  endif
-#  define zError                z_zError
-#  ifndef Z_SOLO
-#    define zcalloc               z_zcalloc
-#    define zcfree                z_zcfree
-#  endif
-#  define zlibCompileFlags      z_zlibCompileFlags
-#  define zlibVersion           z_zlibVersion
-
-/* all zlib typedefs in zlib.h and zconf.h */
-#  define Byte                  z_Byte
-#  define Bytef                 z_Bytef
-#  define alloc_func            z_alloc_func
-#  define charf                 z_charf
-#  define free_func             z_free_func
-#  ifndef Z_SOLO
-#    define gzFile                z_gzFile
-#  endif
-#  define gz_header             z_gz_header
-#  define gz_headerp            z_gz_headerp
-#  define in_func               z_in_func
-#  define intf                  z_intf
-#  define out_func              z_out_func
-#  define uInt                  z_uInt
-#  define uIntf                 z_uIntf
-#  define uLong                 z_uLong
-#  define uLongf                z_uLongf
-#  define voidp                 z_voidp
-#  define voidpc                z_voidpc
-#  define voidpf                z_voidpf
-
-/* all zlib structs in zlib.h and zconf.h */
-#  define gz_header_s           z_gz_header_s
-#  define internal_state        z_internal_state
-
-#endif
-
-#if defined(__MSDOS__) && !defined(MSDOS)
-#  define MSDOS
-#endif
-#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
-#  define OS2
-#endif
-#if defined(_WINDOWS) && !defined(WINDOWS)
-#  define WINDOWS
-#endif
-#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
-#  ifndef WIN32
-#    define WIN32
-#  endif
-#endif
-#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
-#  if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
-#    ifndef SYS16BIT
-#      define SYS16BIT
-#    endif
-#  endif
-#endif
-
-/*
- * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
- * than 64k bytes at a time (needed on systems with 16-bit int).
- */
-#ifdef SYS16BIT
-#  define MAXSEG_64K
-#endif
-#ifdef MSDOS
-#  define UNALIGNED_OK
-#endif
-
-#ifdef __STDC_VERSION__
-#  ifndef STDC
-#    define STDC
-#  endif
-#  if __STDC_VERSION__ >= 199901L
-#    ifndef STDC99
-#      define STDC99
-#    endif
-#  endif
-#endif
-#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
-#  define STDC
-#endif
-#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
-#  define STDC
-#endif
-#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
-#  define STDC
-#endif
-#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
-#  define STDC
-#endif
-
-#if defined(__OS400__) && !defined(STDC)    /* iSeries (formerly AS/400). */
-#  define STDC
-#endif
-
-#ifndef STDC
-#  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
-#    define const       /* note: need a more gentle solution here */
-#  endif
-#endif
-
-#if defined(ZLIB_CONST) && !defined(z_const)
-#  define z_const const
-#else
-#  define z_const
-#endif
-
-/* Some Mac compilers merge all .h files incorrectly: */
-#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
-#  define NO_DUMMY_DECL
-#endif
-
-/* Maximum value for memLevel in deflateInit2 */
-#ifndef MAX_MEM_LEVEL
-#  ifdef MAXSEG_64K
-#    define MAX_MEM_LEVEL 8
-#  else
-#    define MAX_MEM_LEVEL 9
-#  endif
-#endif
-
-/* Maximum value for windowBits in deflateInit2 and inflateInit2.
- * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
- * created by gzip. (Files created by minigzip can still be extracted by
- * gzip.)
- */
-#ifndef MAX_WBITS
-#  define MAX_WBITS   15 /* 32K LZ77 window */
-#endif
-
-/* The memory requirements for deflate are (in bytes):
-            (1 << (windowBits+2)) +  (1 << (memLevel+9))
- that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)
- plus a few kilobytes for small objects. For example, if you want to reduce
- the default memory requirements from 256K to 128K, compile with
-     make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
- Of course this will generally degrade compression (there's no free lunch).
-
-   The memory requirements for inflate are (in bytes) 1 << windowBits
- that is, 32K for windowBits=15 (default value) plus a few kilobytes
- for small objects.
-*/
-
-                        /* Type declarations */
-
-#ifndef OF /* function prototypes */
-#  ifdef STDC
-#    define OF(args)  args
-#  else
-#    define OF(args)  ()
-#  endif
-#endif
-
-#ifndef Z_ARG /* function prototypes for stdarg */
-#  if defined(STDC) || defined(Z_HAVE_STDARG_H)
-#    define Z_ARG(args)  args
-#  else
-#    define Z_ARG(args)  ()
-#  endif
-#endif
-
-/* The following definitions for FAR are needed only for MSDOS mixed
- * model programming (small or medium model with some far allocations).
- * This was tested only with MSC; for other MSDOS compilers you may have
- * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,
- * just define FAR to be empty.
- */
-#ifdef SYS16BIT
-#  if defined(M_I86SM) || defined(M_I86MM)
-     /* MSC small or medium model */
-#    define SMALL_MEDIUM
-#    ifdef _MSC_VER
-#      define FAR _far
-#    else
-#      define FAR far
-#    endif
-#  endif
-#  if (defined(__SMALL__) || defined(__MEDIUM__))
-     /* Turbo C small or medium model */
-#    define SMALL_MEDIUM
-#    ifdef __BORLANDC__
-#      define FAR _far
-#    else
-#      define FAR far
-#    endif
-#  endif
-#endif
-
-#if defined(WINDOWS) || defined(WIN32)
-   /* If building or using zlib as a DLL, define ZLIB_DLL.
-    * This is not mandatory, but it offers a little performance increase.
-    */
-#  ifdef ZLIB_DLL
-#    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
-#      ifdef ZLIB_INTERNAL
-#        define ZEXTERN extern __declspec(dllexport)
-#      else
-#        define ZEXTERN extern __declspec(dllimport)
-#      endif
-#    endif
-#  endif  /* ZLIB_DLL */
-   /* If building or using zlib with the WINAPI/WINAPIV calling convention,
-    * define ZLIB_WINAPI.
-    * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
-    */
-#  ifdef ZLIB_WINAPI
-#    ifdef FAR
-#      undef FAR
-#    endif
-#    include <windows.h>
-     /* No need for _export, use ZLIB.DEF instead. */
-     /* For complete Windows compatibility, use WINAPI, not __stdcall. */
-#    define ZEXPORT WINAPI
-#    ifdef WIN32
-#      define ZEXPORTVA WINAPIV
-#    else
-#      define ZEXPORTVA FAR CDECL
-#    endif
-#  endif
-#endif
-
-#if defined (__BEOS__)
-#  ifdef ZLIB_DLL
-#    ifdef ZLIB_INTERNAL
-#      define ZEXPORT   __declspec(dllexport)
-#      define ZEXPORTVA __declspec(dllexport)
-#    else
-#      define ZEXPORT   __declspec(dllimport)
-#      define ZEXPORTVA __declspec(dllimport)
-#    endif
-#  endif
-#endif
-
-#ifndef ZEXTERN
-#  define ZEXTERN extern
-#endif
-#ifndef ZEXPORT
-#  define ZEXPORT
-#endif
-#ifndef ZEXPORTVA
-#  define ZEXPORTVA
-#endif
-
-#ifndef FAR
-#  define FAR
-#endif
-
-#if !defined(__MACTYPES__)
-typedef unsigned char  Byte;  /* 8 bits */
-#endif
-typedef unsigned int   uInt;  /* 16 bits or more */
-typedef unsigned long  uLong; /* 32 bits or more */
-
-#ifdef SMALL_MEDIUM
-   /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
-#  define Bytef Byte FAR
-#else
-   typedef Byte  FAR Bytef;
-#endif
-typedef char  FAR charf;
-typedef int   FAR intf;
-typedef uInt  FAR uIntf;
-typedef uLong FAR uLongf;
-
-#ifdef STDC
-   typedef void const *voidpc;
-   typedef void FAR   *voidpf;
-   typedef void       *voidp;
-#else
-   typedef Byte const *voidpc;
-   typedef Byte FAR   *voidpf;
-   typedef Byte       *voidp;
-#endif
-
-#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
-#  include <limits.h>
-#  if (UINT_MAX == 0xffffffffUL)
-#    define Z_U4 unsigned
-#  elif (ULONG_MAX == 0xffffffffUL)
-#    define Z_U4 unsigned long
-#  elif (USHRT_MAX == 0xffffffffUL)
-#    define Z_U4 unsigned short
-#  endif
-#endif
-
-#ifdef Z_U4
-   typedef Z_U4 z_crc_t;
-#else
-   typedef unsigned long z_crc_t;
-#endif
-
-#ifdef HAVE_UNISTD_H    /* may be set to #if 1 by ./configure */
-#  define Z_HAVE_UNISTD_H
-#endif
-
-#ifdef HAVE_STDARG_H    /* may be set to #if 1 by ./configure */
-#  define Z_HAVE_STDARG_H
-#endif
-
-#ifdef STDC
-#  ifndef Z_SOLO
-#    include <sys/types.h>      /* for off_t */
-#  endif
-#endif
-
-#if defined(STDC) || defined(Z_HAVE_STDARG_H)
-#  ifndef Z_SOLO
-#    include <stdarg.h>         /* for va_list */
-#  endif
-#endif
-
-#ifdef _WIN32
-#  ifndef Z_SOLO
-#    include <stddef.h>         /* for wchar_t */
-#  endif
-#endif
-
-/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
- * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
- * though the former does not conform to the LFS document), but considering
- * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
- * equivalently requesting no 64-bit operations
- */
-#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
-#  undef _LARGEFILE64_SOURCE
-#endif
-
-#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
-#  define Z_HAVE_UNISTD_H
-#endif
-#ifndef Z_SOLO
-#  if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
-#    include <unistd.h>         /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
-#    ifdef VMS
-#      include <unixio.h>       /* for off_t */
-#    endif
-#    ifndef z_off_t
-#      define z_off_t off_t
-#    endif
-#  endif
-#endif
-
-#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
-#  define Z_LFS64
-#endif
-
-#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
-#  define Z_LARGE64
-#endif
-
-#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
-#  define Z_WANT64
-#endif
-
-#if !defined(SEEK_SET) && !defined(Z_SOLO)
-#  define SEEK_SET        0       /* Seek from beginning of file.  */
-#  define SEEK_CUR        1       /* Seek from current position.  */
-#  define SEEK_END        2       /* Set file pointer to EOF plus "offset" */
-#endif
-
-#ifndef z_off_t
-#  define z_off_t long
-#endif
-
-#if !defined(_WIN32) && defined(Z_LARGE64)
-#  define z_off64_t off64_t
-#else
-#  if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
-#    define z_off64_t __int64
-#  else
-#    define z_off64_t z_off_t
-#  endif
-#endif
-
-/* MVS linker does not support external names larger than 8 bytes */
-#if defined(__MVS__)
-  #pragma map(deflateInit_,"DEIN")
-  #pragma map(deflateInit2_,"DEIN2")
-  #pragma map(deflateEnd,"DEEND")
-  #pragma map(deflateBound,"DEBND")
-  #pragma map(inflateInit_,"ININ")
-  #pragma map(inflateInit2_,"ININ2")
-  #pragma map(inflateEnd,"INEND")
-  #pragma map(inflateSync,"INSY")
-  #pragma map(inflateSetDictionary,"INSEDI")
-  #pragma map(compressBound,"CMBND")
-  #pragma map(inflate_table,"INTABL")
-  #pragma map(inflate_fast,"INFA")
-  #pragma map(inflate_copyright,"INCOPY")
-#endif
-
-#endif /* ZCONF_H */
diff --git a/deps/zlib/zconf.h.in b/deps/zlib/zconf.h.in
deleted file mode 100644 (file)
index 9987a77..0000000
+++ /dev/null
@@ -1,511 +0,0 @@
-/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2013 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#ifndef ZCONF_H
-#define ZCONF_H
-
-/*
- * If you *really* need a unique prefix for all types and library functions,
- * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
- * Even better than compiling with -DZ_PREFIX would be to use configure to set
- * this permanently in zconf.h using "./configure --zprefix".
- */
-#ifdef Z_PREFIX     /* may be set to #if 1 by ./configure */
-#  define Z_PREFIX_SET
-
-/* all linked symbols */
-#  define _dist_code            z__dist_code
-#  define _length_code          z__length_code
-#  define _tr_align             z__tr_align
-#  define _tr_flush_bits        z__tr_flush_bits
-#  define _tr_flush_block       z__tr_flush_block
-#  define _tr_init              z__tr_init
-#  define _tr_stored_block      z__tr_stored_block
-#  define _tr_tally             z__tr_tally
-#  define adler32               z_adler32
-#  define adler32_combine       z_adler32_combine
-#  define adler32_combine64     z_adler32_combine64
-#  ifndef Z_SOLO
-#    define compress              z_compress
-#    define compress2             z_compress2
-#    define compressBound         z_compressBound
-#  endif
-#  define crc32                 z_crc32
-#  define crc32_combine         z_crc32_combine
-#  define crc32_combine64       z_crc32_combine64
-#  define deflate               z_deflate
-#  define deflateBound          z_deflateBound
-#  define deflateCopy           z_deflateCopy
-#  define deflateEnd            z_deflateEnd
-#  define deflateInit2_         z_deflateInit2_
-#  define deflateInit_          z_deflateInit_
-#  define deflateParams         z_deflateParams
-#  define deflatePending        z_deflatePending
-#  define deflatePrime          z_deflatePrime
-#  define deflateReset          z_deflateReset
-#  define deflateResetKeep      z_deflateResetKeep
-#  define deflateSetDictionary  z_deflateSetDictionary
-#  define deflateSetHeader      z_deflateSetHeader
-#  define deflateTune           z_deflateTune
-#  define deflate_copyright     z_deflate_copyright
-#  define get_crc_table         z_get_crc_table
-#  ifndef Z_SOLO
-#    define gz_error              z_gz_error
-#    define gz_intmax             z_gz_intmax
-#    define gz_strwinerror        z_gz_strwinerror
-#    define gzbuffer              z_gzbuffer
-#    define gzclearerr            z_gzclearerr
-#    define gzclose               z_gzclose
-#    define gzclose_r             z_gzclose_r
-#    define gzclose_w             z_gzclose_w
-#    define gzdirect              z_gzdirect
-#    define gzdopen               z_gzdopen
-#    define gzeof                 z_gzeof
-#    define gzerror               z_gzerror
-#    define gzflush               z_gzflush
-#    define gzgetc                z_gzgetc
-#    define gzgetc_               z_gzgetc_
-#    define gzgets                z_gzgets
-#    define gzoffset              z_gzoffset
-#    define gzoffset64            z_gzoffset64
-#    define gzopen                z_gzopen
-#    define gzopen64              z_gzopen64
-#    ifdef _WIN32
-#      define gzopen_w              z_gzopen_w
-#    endif
-#    define gzprintf              z_gzprintf
-#    define gzvprintf             z_gzvprintf
-#    define gzputc                z_gzputc
-#    define gzputs                z_gzputs
-#    define gzread                z_gzread
-#    define gzrewind              z_gzrewind
-#    define gzseek                z_gzseek
-#    define gzseek64              z_gzseek64
-#    define gzsetparams           z_gzsetparams
-#    define gztell                z_gztell
-#    define gztell64              z_gztell64
-#    define gzungetc              z_gzungetc
-#    define gzwrite               z_gzwrite
-#  endif
-#  define inflate               z_inflate
-#  define inflateBack           z_inflateBack
-#  define inflateBackEnd        z_inflateBackEnd
-#  define inflateBackInit_      z_inflateBackInit_
-#  define inflateCopy           z_inflateCopy
-#  define inflateEnd            z_inflateEnd
-#  define inflateGetHeader      z_inflateGetHeader
-#  define inflateInit2_         z_inflateInit2_
-#  define inflateInit_          z_inflateInit_
-#  define inflateMark           z_inflateMark
-#  define inflatePrime          z_inflatePrime
-#  define inflateReset          z_inflateReset
-#  define inflateReset2         z_inflateReset2
-#  define inflateSetDictionary  z_inflateSetDictionary
-#  define inflateGetDictionary  z_inflateGetDictionary
-#  define inflateSync           z_inflateSync
-#  define inflateSyncPoint      z_inflateSyncPoint
-#  define inflateUndermine      z_inflateUndermine
-#  define inflateResetKeep      z_inflateResetKeep
-#  define inflate_copyright     z_inflate_copyright
-#  define inflate_fast          z_inflate_fast
-#  define inflate_table         z_inflate_table
-#  ifndef Z_SOLO
-#    define uncompress            z_uncompress
-#  endif
-#  define zError                z_zError
-#  ifndef Z_SOLO
-#    define zcalloc               z_zcalloc
-#    define zcfree                z_zcfree
-#  endif
-#  define zlibCompileFlags      z_zlibCompileFlags
-#  define zlibVersion           z_zlibVersion
-
-/* all zlib typedefs in zlib.h and zconf.h */
-#  define Byte                  z_Byte
-#  define Bytef                 z_Bytef
-#  define alloc_func            z_alloc_func
-#  define charf                 z_charf
-#  define free_func             z_free_func
-#  ifndef Z_SOLO
-#    define gzFile                z_gzFile
-#  endif
-#  define gz_header             z_gz_header
-#  define gz_headerp            z_gz_headerp
-#  define in_func               z_in_func
-#  define intf                  z_intf
-#  define out_func              z_out_func
-#  define uInt                  z_uInt
-#  define uIntf                 z_uIntf
-#  define uLong                 z_uLong
-#  define uLongf                z_uLongf
-#  define voidp                 z_voidp
-#  define voidpc                z_voidpc
-#  define voidpf                z_voidpf
-
-/* all zlib structs in zlib.h and zconf.h */
-#  define gz_header_s           z_gz_header_s
-#  define internal_state        z_internal_state
-
-#endif
-
-#if defined(__MSDOS__) && !defined(MSDOS)
-#  define MSDOS
-#endif
-#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
-#  define OS2
-#endif
-#if defined(_WINDOWS) && !defined(WINDOWS)
-#  define WINDOWS
-#endif
-#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
-#  ifndef WIN32
-#    define WIN32
-#  endif
-#endif
-#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
-#  if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
-#    ifndef SYS16BIT
-#      define SYS16BIT
-#    endif
-#  endif
-#endif
-
-/*
- * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
- * than 64k bytes at a time (needed on systems with 16-bit int).
- */
-#ifdef SYS16BIT
-#  define MAXSEG_64K
-#endif
-#ifdef MSDOS
-#  define UNALIGNED_OK
-#endif
-
-#ifdef __STDC_VERSION__
-#  ifndef STDC
-#    define STDC
-#  endif
-#  if __STDC_VERSION__ >= 199901L
-#    ifndef STDC99
-#      define STDC99
-#    endif
-#  endif
-#endif
-#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
-#  define STDC
-#endif
-#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
-#  define STDC
-#endif
-#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
-#  define STDC
-#endif
-#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
-#  define STDC
-#endif
-
-#if defined(__OS400__) && !defined(STDC)    /* iSeries (formerly AS/400). */
-#  define STDC
-#endif
-
-#ifndef STDC
-#  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
-#    define const       /* note: need a more gentle solution here */
-#  endif
-#endif
-
-#if defined(ZLIB_CONST) && !defined(z_const)
-#  define z_const const
-#else
-#  define z_const
-#endif
-
-/* Some Mac compilers merge all .h files incorrectly: */
-#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
-#  define NO_DUMMY_DECL
-#endif
-
-/* Maximum value for memLevel in deflateInit2 */
-#ifndef MAX_MEM_LEVEL
-#  ifdef MAXSEG_64K
-#    define MAX_MEM_LEVEL 8
-#  else
-#    define MAX_MEM_LEVEL 9
-#  endif
-#endif
-
-/* Maximum value for windowBits in deflateInit2 and inflateInit2.
- * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
- * created by gzip. (Files created by minigzip can still be extracted by
- * gzip.)
- */
-#ifndef MAX_WBITS
-#  define MAX_WBITS   15 /* 32K LZ77 window */
-#endif
-
-/* The memory requirements for deflate are (in bytes):
-            (1 << (windowBits+2)) +  (1 << (memLevel+9))
- that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)
- plus a few kilobytes for small objects. For example, if you want to reduce
- the default memory requirements from 256K to 128K, compile with
-     make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
- Of course this will generally degrade compression (there's no free lunch).
-
-   The memory requirements for inflate are (in bytes) 1 << windowBits
- that is, 32K for windowBits=15 (default value) plus a few kilobytes
- for small objects.
-*/
-
-                        /* Type declarations */
-
-#ifndef OF /* function prototypes */
-#  ifdef STDC
-#    define OF(args)  args
-#  else
-#    define OF(args)  ()
-#  endif
-#endif
-
-#ifndef Z_ARG /* function prototypes for stdarg */
-#  if defined(STDC) || defined(Z_HAVE_STDARG_H)
-#    define Z_ARG(args)  args
-#  else
-#    define Z_ARG(args)  ()
-#  endif
-#endif
-
-/* The following definitions for FAR are needed only for MSDOS mixed
- * model programming (small or medium model with some far allocations).
- * This was tested only with MSC; for other MSDOS compilers you may have
- * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,
- * just define FAR to be empty.
- */
-#ifdef SYS16BIT
-#  if defined(M_I86SM) || defined(M_I86MM)
-     /* MSC small or medium model */
-#    define SMALL_MEDIUM
-#    ifdef _MSC_VER
-#      define FAR _far
-#    else
-#      define FAR far
-#    endif
-#  endif
-#  if (defined(__SMALL__) || defined(__MEDIUM__))
-     /* Turbo C small or medium model */
-#    define SMALL_MEDIUM
-#    ifdef __BORLANDC__
-#      define FAR _far
-#    else
-#      define FAR far
-#    endif
-#  endif
-#endif
-
-#if defined(WINDOWS) || defined(WIN32)
-   /* If building or using zlib as a DLL, define ZLIB_DLL.
-    * This is not mandatory, but it offers a little performance increase.
-    */
-#  ifdef ZLIB_DLL
-#    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
-#      ifdef ZLIB_INTERNAL
-#        define ZEXTERN extern __declspec(dllexport)
-#      else
-#        define ZEXTERN extern __declspec(dllimport)
-#      endif
-#    endif
-#  endif  /* ZLIB_DLL */
-   /* If building or using zlib with the WINAPI/WINAPIV calling convention,
-    * define ZLIB_WINAPI.
-    * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
-    */
-#  ifdef ZLIB_WINAPI
-#    ifdef FAR
-#      undef FAR
-#    endif
-#    include <windows.h>
-     /* No need for _export, use ZLIB.DEF instead. */
-     /* For complete Windows compatibility, use WINAPI, not __stdcall. */
-#    define ZEXPORT WINAPI
-#    ifdef WIN32
-#      define ZEXPORTVA WINAPIV
-#    else
-#      define ZEXPORTVA FAR CDECL
-#    endif
-#  endif
-#endif
-
-#if defined (__BEOS__)
-#  ifdef ZLIB_DLL
-#    ifdef ZLIB_INTERNAL
-#      define ZEXPORT   __declspec(dllexport)
-#      define ZEXPORTVA __declspec(dllexport)
-#    else
-#      define ZEXPORT   __declspec(dllimport)
-#      define ZEXPORTVA __declspec(dllimport)
-#    endif
-#  endif
-#endif
-
-#ifndef ZEXTERN
-#  define ZEXTERN extern
-#endif
-#ifndef ZEXPORT
-#  define ZEXPORT
-#endif
-#ifndef ZEXPORTVA
-#  define ZEXPORTVA
-#endif
-
-#ifndef FAR
-#  define FAR
-#endif
-
-#if !defined(__MACTYPES__)
-typedef unsigned char  Byte;  /* 8 bits */
-#endif
-typedef unsigned int   uInt;  /* 16 bits or more */
-typedef unsigned long  uLong; /* 32 bits or more */
-
-#ifdef SMALL_MEDIUM
-   /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
-#  define Bytef Byte FAR
-#else
-   typedef Byte  FAR Bytef;
-#endif
-typedef char  FAR charf;
-typedef int   FAR intf;
-typedef uInt  FAR uIntf;
-typedef uLong FAR uLongf;
-
-#ifdef STDC
-   typedef void const *voidpc;
-   typedef void FAR   *voidpf;
-   typedef void       *voidp;
-#else
-   typedef Byte const *voidpc;
-   typedef Byte FAR   *voidpf;
-   typedef Byte       *voidp;
-#endif
-
-#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
-#  include <limits.h>
-#  if (UINT_MAX == 0xffffffffUL)
-#    define Z_U4 unsigned
-#  elif (ULONG_MAX == 0xffffffffUL)
-#    define Z_U4 unsigned long
-#  elif (USHRT_MAX == 0xffffffffUL)
-#    define Z_U4 unsigned short
-#  endif
-#endif
-
-#ifdef Z_U4
-   typedef Z_U4 z_crc_t;
-#else
-   typedef unsigned long z_crc_t;
-#endif
-
-#ifdef HAVE_UNISTD_H    /* may be set to #if 1 by ./configure */
-#  define Z_HAVE_UNISTD_H
-#endif
-
-#ifdef HAVE_STDARG_H    /* may be set to #if 1 by ./configure */
-#  define Z_HAVE_STDARG_H
-#endif
-
-#ifdef STDC
-#  ifndef Z_SOLO
-#    include <sys/types.h>      /* for off_t */
-#  endif
-#endif
-
-#if defined(STDC) || defined(Z_HAVE_STDARG_H)
-#  ifndef Z_SOLO
-#    include <stdarg.h>         /* for va_list */
-#  endif
-#endif
-
-#ifdef _WIN32
-#  ifndef Z_SOLO
-#    include <stddef.h>         /* for wchar_t */
-#  endif
-#endif
-
-/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
- * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
- * though the former does not conform to the LFS document), but considering
- * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
- * equivalently requesting no 64-bit operations
- */
-#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
-#  undef _LARGEFILE64_SOURCE
-#endif
-
-#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
-#  define Z_HAVE_UNISTD_H
-#endif
-#ifndef Z_SOLO
-#  if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
-#    include <unistd.h>         /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
-#    ifdef VMS
-#      include <unixio.h>       /* for off_t */
-#    endif
-#    ifndef z_off_t
-#      define z_off_t off_t
-#    endif
-#  endif
-#endif
-
-#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
-#  define Z_LFS64
-#endif
-
-#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
-#  define Z_LARGE64
-#endif
-
-#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
-#  define Z_WANT64
-#endif
-
-#if !defined(SEEK_SET) && !defined(Z_SOLO)
-#  define SEEK_SET        0       /* Seek from beginning of file.  */
-#  define SEEK_CUR        1       /* Seek from current position.  */
-#  define SEEK_END        2       /* Set file pointer to EOF plus "offset" */
-#endif
-
-#ifndef z_off_t
-#  define z_off_t long
-#endif
-
-#if !defined(_WIN32) && defined(Z_LARGE64)
-#  define z_off64_t off64_t
-#else
-#  if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
-#    define z_off64_t __int64
-#  else
-#    define z_off64_t z_off_t
-#  endif
-#endif
-
-/* MVS linker does not support external names larger than 8 bytes */
-#if defined(__MVS__)
-  #pragma map(deflateInit_,"DEIN")
-  #pragma map(deflateInit2_,"DEIN2")
-  #pragma map(deflateEnd,"DEEND")
-  #pragma map(deflateBound,"DEBND")
-  #pragma map(inflateInit_,"ININ")
-  #pragma map(inflateInit2_,"ININ2")
-  #pragma map(inflateEnd,"INEND")
-  #pragma map(inflateSync,"INSY")
-  #pragma map(inflateSetDictionary,"INSEDI")
-  #pragma map(compressBound,"CMBND")
-  #pragma map(inflate_table,"INTABL")
-  #pragma map(inflate_fast,"INFA")
-  #pragma map(inflate_copyright,"INCOPY")
-#endif
-
-#endif /* ZCONF_H */
diff --git a/deps/zlib/zlib.h b/deps/zlib/zlib.h
deleted file mode 100644 (file)
index aa5935d..0000000
+++ /dev/null
@@ -1,1763 +0,0 @@
-/* zlib.h -- interface of the 'zlib' general purpose compression library
-  version 1.2.8, April 28th, 2013
-
-  Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
-
-  This software is provided 'as-is', without any express or implied
-  warranty.  In no event will the authors be held liable for any damages
-  arising from the use of this software.
-
-  Permission is granted to anyone to use this software for any purpose,
-  including commercial applications, and to alter it and redistribute it
-  freely, subject to the following restrictions:
-
-  1. The origin of this software must not be misrepresented; you must not
-     claim that you wrote the original software. If you use this software
-     in a product, an acknowledgment in the product documentation would be
-     appreciated but is not required.
-  2. Altered source versions must be plainly marked as such, and must not be
-     misrepresented as being the original software.
-  3. This notice may not be removed or altered from any source distribution.
-
-  Jean-loup Gailly        Mark Adler
-  jloup@gzip.org          madler@alumni.caltech.edu
-
-
-  The data format used by the zlib library is described by RFCs (Request for
-  Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
-  (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
-*/
-
-#ifndef ZLIB_H
-#define ZLIB_H
-
-#include "zconf.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define ZLIB_VERSION "1.2.8"
-#define ZLIB_VERNUM 0x1280
-#define ZLIB_VER_MAJOR 1
-#define ZLIB_VER_MINOR 2
-#define ZLIB_VER_REVISION 8
-#define ZLIB_VER_SUBREVISION 0
-
-/*
-    The 'zlib' compression library provides in-memory compression and
-  decompression functions, including integrity checks of the uncompressed data.
-  This version of the library supports only one compression method (deflation)
-  but other algorithms will be added later and will have the same stream
-  interface.
-
-    Compression can be done in a single step if the buffers are large enough,
-  or can be done by repeated calls of the compression function.  In the latter
-  case, the application must provide more input and/or consume the output
-  (providing more output space) before each call.
-
-    The compressed data format used by default by the in-memory functions is
-  the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
-  around a deflate stream, which is itself documented in RFC 1951.
-
-    The library also supports reading and writing files in gzip (.gz) format
-  with an interface similar to that of stdio using the functions that start
-  with "gz".  The gzip format is different from the zlib format.  gzip is a
-  gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
-
-    This library can optionally read and write gzip streams in memory as well.
-
-    The zlib format was designed to be compact and fast for use in memory
-  and on communications channels.  The gzip format was designed for single-
-  file compression on file systems, has a larger header than zlib to maintain
-  directory information, and uses a different, slower check method than zlib.
-
-    The library does not install any signal handler.  The decoder checks
-  the consistency of the compressed data, so the library should never crash
-  even in case of corrupted input.
-*/
-
-typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
-typedef void   (*free_func)  OF((voidpf opaque, voidpf address));
-
-struct internal_state;
-
-typedef struct z_stream_s {
-    z_const Bytef *next_in;     /* next input byte */
-    uInt     avail_in;  /* number of bytes available at next_in */
-    uLong    total_in;  /* total number of input bytes read so far */
-
-    Bytef    *next_out; /* next output byte should be put there */
-    uInt     avail_out; /* remaining free space at next_out */
-    uLong    total_out; /* total number of bytes output so far */
-
-    z_const char *msg;  /* last error message, NULL if no error */
-    void *state; /* not visible by applications */
-
-    alloc_func zalloc;  /* used to allocate the internal state */
-    free_func  zfree;   /* used to free the internal state */
-    voidpf     opaque;  /* private data object passed to zalloc and zfree */
-
-    int     data_type;  /* best guess about the data type: binary or text */
-    uLong   adler;      /* adler32 value of the uncompressed data */
-    uLong   reserved;   /* reserved for future use */
-} z_stream;
-
-typedef z_stream FAR *z_streamp;
-
-/*
-     gzip header information passed to and from zlib routines.  See RFC 1952
-  for more details on the meanings of these fields.
-*/
-typedef struct gz_header_s {
-    int     text;       /* true if compressed data believed to be text */
-    uLong   time;       /* modification time */
-    int     xflags;     /* extra flags (not used when writing a gzip file) */
-    int     os;         /* operating system */
-    Bytef   *extra;     /* pointer to extra field or Z_NULL if none */
-    uInt    extra_len;  /* extra field length (valid if extra != Z_NULL) */
-    uInt    extra_max;  /* space at extra (only when reading header) */
-    Bytef   *name;      /* pointer to zero-terminated file name or Z_NULL */
-    uInt    name_max;   /* space at name (only when reading header) */
-    Bytef   *comment;   /* pointer to zero-terminated comment or Z_NULL */
-    uInt    comm_max;   /* space at comment (only when reading header) */
-    int     hcrc;       /* true if there was or will be a header crc */
-    int     done;       /* true when done reading gzip header (not used
-                           when writing a gzip file) */
-} gz_header;
-
-typedef gz_header FAR *gz_headerp;
-
-/*
-     The application must update next_in and avail_in when avail_in has dropped
-   to zero.  It must update next_out and avail_out when avail_out has dropped
-   to zero.  The application must initialize zalloc, zfree and opaque before
-   calling the init function.  All other fields are set by the compression
-   library and must not be updated by the application.
-
-     The opaque value provided by the application will be passed as the first
-   parameter for calls of zalloc and zfree.  This can be useful for custom
-   memory management.  The compression library attaches no meaning to the
-   opaque value.
-
-     zalloc must return Z_NULL if there is not enough memory for the object.
-   If zlib is used in a multi-threaded application, zalloc and zfree must be
-   thread safe.
-
-     On 16-bit systems, the functions zalloc and zfree must be able to allocate
-   exactly 65536 bytes, but will not be required to allocate more than this if
-   the symbol MAXSEG_64K is defined (see zconf.h).  WARNING: On MSDOS, pointers
-   returned by zalloc for objects of exactly 65536 bytes *must* have their
-   offset normalized to zero.  The default allocation function provided by this
-   library ensures this (see zutil.c).  To reduce memory requirements and avoid
-   any allocation of 64K objects, at the expense of compression ratio, compile
-   the library with -DMAX_WBITS=14 (see zconf.h).
-
-     The fields total_in and total_out can be used for statistics or progress
-   reports.  After compression, total_in holds the total size of the
-   uncompressed data and may be saved for use in the decompressor (particularly
-   if the decompressor wants to decompress everything in a single step).
-*/
-
-                        /* constants */
-
-#define Z_NO_FLUSH      0
-#define Z_PARTIAL_FLUSH 1
-#define Z_SYNC_FLUSH    2
-#define Z_FULL_FLUSH    3
-#define Z_FINISH        4
-#define Z_BLOCK         5
-#define Z_TREES         6
-/* Allowed flush values; see deflate() and inflate() below for details */
-
-#define Z_OK            0
-#define Z_STREAM_END    1
-#define Z_NEED_DICT     2
-#define Z_ERRNO        (-1)
-#define Z_STREAM_ERROR (-2)
-#define Z_DATA_ERROR   (-3)
-#define Z_MEM_ERROR    (-4)
-#define Z_BUF_ERROR    (-5)
-#define Z_VERSION_ERROR (-6)
-/* Return codes for the compression/decompression functions. Negative values
- * are errors, positive values are used for special but normal events.
- */
-
-#define Z_NO_COMPRESSION         0
-#define Z_BEST_SPEED             1
-#define Z_BEST_COMPRESSION       9
-#define Z_DEFAULT_COMPRESSION  (-1)
-/* compression levels */
-
-#define Z_FILTERED            1
-#define Z_HUFFMAN_ONLY        2
-#define Z_RLE                 3
-#define Z_FIXED               4
-#define Z_DEFAULT_STRATEGY    0
-/* compression strategy; see deflateInit2() below for details */
-
-#define Z_BINARY   0
-#define Z_TEXT     1
-#define Z_ASCII    Z_TEXT   /* for compatibility with 1.2.2 and earlier */
-#define Z_UNKNOWN  2
-/* Possible values of the data_type field (though see inflate()) */
-
-#define Z_DEFLATED   8
-/* The deflate compression method (the only one supported in this version) */
-
-#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
-
-#define zlib_version zlibVersion()
-/* for compatibility with versions < 1.0.2 */
-
-
-                        /* basic functions */
-
-ZEXTERN const char * ZEXPORT zlibVersion OF((void));
-/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
-   If the first character differs, the library code actually used is not
-   compatible with the zlib.h header file used by the application.  This check
-   is automatically made by deflateInit and inflateInit.
- */
-
-/*
-ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
-
-     Initializes the internal stream state for compression.  The fields
-   zalloc, zfree and opaque must be initialized before by the caller.  If
-   zalloc and zfree are set to Z_NULL, deflateInit updates them to use default
-   allocation functions.
-
-     The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
-   1 gives best speed, 9 gives best compression, 0 gives no compression at all
-   (the input data is simply copied a block at a time).  Z_DEFAULT_COMPRESSION
-   requests a default compromise between speed and compression (currently
-   equivalent to level 6).
-
-     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
-   memory, Z_STREAM_ERROR if level is not a valid compression level, or
-   Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
-   with the version assumed by the caller (ZLIB_VERSION).  msg is set to null
-   if there is no error message.  deflateInit does not perform any compression:
-   this will be done by deflate().
-*/
-
-
-ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
-/*
-    deflate compresses as much data as possible, and stops when the input
-  buffer becomes empty or the output buffer becomes full.  It may introduce
-  some output latency (reading input without producing any output) except when
-  forced to flush.
-
-    The detailed semantics are as follows.  deflate performs one or both of the
-  following actions:
-
-  - Compress more input starting at next_in and update next_in and avail_in
-    accordingly.  If not all input can be processed (because there is not
-    enough room in the output buffer), next_in and avail_in are updated and
-    processing will resume at this point for the next call of deflate().
-
-  - Provide more output starting at next_out and update next_out and avail_out
-    accordingly.  This action is forced if the parameter flush is non zero.
-    Forcing flush frequently degrades the compression ratio, so this parameter
-    should be set only when necessary (in interactive applications).  Some
-    output may be provided even if flush is not set.
-
-    Before the call of deflate(), the application should ensure that at least
-  one of the actions is possible, by providing more input and/or consuming more
-  output, and updating avail_in or avail_out accordingly; avail_out should
-  never be zero before the call.  The application can consume the compressed
-  output when it wants, for example when the output buffer is full (avail_out
-  == 0), or after each call of deflate().  If deflate returns Z_OK and with
-  zero avail_out, it must be called again after making room in the output
-  buffer because there might be more output pending.
-
-    Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
-  decide how much data to accumulate before producing output, in order to
-  maximize compression.
-
-    If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
-  flushed to the output buffer and the output is aligned on a byte boundary, so
-  that the decompressor can get all input data available so far.  (In
-  particular avail_in is zero after the call if enough output space has been
-  provided before the call.) Flushing may degrade compression for some
-  compression algorithms and so it should be used only when necessary.  This
-  completes the current deflate block and follows it with an empty stored block
-  that is three bits plus filler bits to the next byte, followed by four bytes
-  (00 00 ff ff).
-
-    If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the
-  output buffer, but the output is not aligned to a byte boundary.  All of the
-  input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.
-  This completes the current deflate block and follows it with an empty fixed
-  codes block that is 10 bits long.  This assures that enough bytes are output
-  in order for the decompressor to finish the block before the empty fixed code
-  block.
-
-    If flush is set to Z_BLOCK, a deflate block is completed and emitted, as
-  for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to
-  seven bits of the current block are held to be written as the next byte after
-  the next deflate block is completed.  In this case, the decompressor may not
-  be provided enough bits at this point in order to complete decompression of
-  the data provided so far to the compressor.  It may need to wait for the next
-  block to be emitted.  This is for advanced applications that need to control
-  the emission of deflate blocks.
-
-    If flush is set to Z_FULL_FLUSH, all output is flushed as with
-  Z_SYNC_FLUSH, and the compression state is reset so that decompression can
-  restart from this point if previous compressed data has been damaged or if
-  random access is desired.  Using Z_FULL_FLUSH too often can seriously degrade
-  compression.
-
-    If deflate returns with avail_out == 0, this function must be called again
-  with the same value of the flush parameter and more output space (updated
-  avail_out), until the flush is complete (deflate returns with non-zero
-  avail_out).  In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that
-  avail_out is greater than six to avoid repeated flush markers due to
-  avail_out == 0 on return.
-
-    If the parameter flush is set to Z_FINISH, pending input is processed,
-  pending output is flushed and deflate returns with Z_STREAM_END if there was
-  enough output space; if deflate returns with Z_OK, this function must be
-  called again with Z_FINISH and more output space (updated avail_out) but no
-  more input data, until it returns with Z_STREAM_END or an error.  After
-  deflate has returned Z_STREAM_END, the only possible operations on the stream
-  are deflateReset or deflateEnd.
-
-    Z_FINISH can be used immediately after deflateInit if all the compression
-  is to be done in a single step.  In this case, avail_out must be at least the
-  value returned by deflateBound (see below).  Then deflate is guaranteed to
-  return Z_STREAM_END.  If not enough output space is provided, deflate will
-  not return Z_STREAM_END, and it must be called again as described above.
-
-    deflate() sets strm->adler to the adler32 checksum of all input read
-  so far (that is, total_in bytes).
-
-    deflate() may update strm->data_type if it can make a good guess about
-  the input data type (Z_BINARY or Z_TEXT).  In doubt, the data is considered
-  binary.  This field is only for information purposes and does not affect the
-  compression algorithm in any manner.
-
-    deflate() returns Z_OK if some progress has been made (more input
-  processed or more output produced), Z_STREAM_END if all input has been
-  consumed and all output has been produced (only when flush is set to
-  Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
-  if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible
-  (for example avail_in or avail_out was zero).  Note that Z_BUF_ERROR is not
-  fatal, and deflate() can be called again with more input and more output
-  space to continue compressing.
-*/
-
-
-ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
-/*
-     All dynamically allocated data structures for this stream are freed.
-   This function discards any unprocessed input and does not flush any pending
-   output.
-
-     deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
-   stream state was inconsistent, Z_DATA_ERROR if the stream was freed
-   prematurely (some input or output was discarded).  In the error case, msg
-   may be set but then points to a static string (which must not be
-   deallocated).
-*/
-
-
-/*
-ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
-
-     Initializes the internal stream state for decompression.  The fields
-   next_in, avail_in, zalloc, zfree and opaque must be initialized before by
-   the caller.  If next_in is not Z_NULL and avail_in is large enough (the
-   exact value depends on the compression method), inflateInit determines the
-   compression method from the zlib header and allocates all data structures
-   accordingly; otherwise the allocation will be deferred to the first call of
-   inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to
-   use default allocation functions.
-
-     inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
-   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
-   version assumed by the caller, or Z_STREAM_ERROR if the parameters are
-   invalid, such as a null pointer to the structure.  msg is set to null if
-   there is no error message.  inflateInit does not perform any decompression
-   apart from possibly reading the zlib header if present: actual decompression
-   will be done by inflate().  (So next_in and avail_in may be modified, but
-   next_out and avail_out are unused and unchanged.) The current implementation
-   of inflateInit() does not process any header information -- that is deferred
-   until inflate() is called.
-*/
-
-
-ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
-/*
-    inflate decompresses as much data as possible, and stops when the input
-  buffer becomes empty or the output buffer becomes full.  It may introduce
-  some output latency (reading input without producing any output) except when
-  forced to flush.
-
-  The detailed semantics are as follows.  inflate performs one or both of the
-  following actions:
-
-  - Decompress more input starting at next_in and update next_in and avail_in
-    accordingly.  If not all input can be processed (because there is not
-    enough room in the output buffer), next_in is updated and processing will
-    resume at this point for the next call of inflate().
-
-  - Provide more output starting at next_out and update next_out and avail_out
-    accordingly.  inflate() provides as much output as possible, until there is
-    no more input data or no more space in the output buffer (see below about
-    the flush parameter).
-
-    Before the call of inflate(), the application should ensure that at least
-  one of the actions is possible, by providing more input and/or consuming more
-  output, and updating the next_* and avail_* values accordingly.  The
-  application can consume the uncompressed output when it wants, for example
-  when the output buffer is full (avail_out == 0), or after each call of
-  inflate().  If inflate returns Z_OK and with zero avail_out, it must be
-  called again after making room in the output buffer because there might be
-  more output pending.
-
-    The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,
-  Z_BLOCK, or Z_TREES.  Z_SYNC_FLUSH requests that inflate() flush as much
-  output as possible to the output buffer.  Z_BLOCK requests that inflate()
-  stop if and when it gets to the next deflate block boundary.  When decoding
-  the zlib or gzip format, this will cause inflate() to return immediately
-  after the header and before the first block.  When doing a raw inflate,
-  inflate() will go ahead and process the first block, and will return when it
-  gets to the end of that block, or when it runs out of data.
-
-    The Z_BLOCK option assists in appending to or combining deflate streams.
-  Also to assist in this, on return inflate() will set strm->data_type to the
-  number of unused bits in the last byte taken from strm->next_in, plus 64 if
-  inflate() is currently decoding the last block in the deflate stream, plus
-  128 if inflate() returned immediately after decoding an end-of-block code or
-  decoding the complete header up to just before the first byte of the deflate
-  stream.  The end-of-block will not be indicated until all of the uncompressed
-  data from that block has been written to strm->next_out.  The number of
-  unused bits may in general be greater than seven, except when bit 7 of
-  data_type is set, in which case the number of unused bits will be less than
-  eight.  data_type is set as noted here every time inflate() returns for all
-  flush options, and so can be used to determine the amount of currently
-  consumed input in bits.
-
-    The Z_TREES option behaves as Z_BLOCK does, but it also returns when the
-  end of each deflate block header is reached, before any actual data in that
-  block is decoded.  This allows the caller to determine the length of the
-  deflate block header for later use in random access within a deflate block.
-  256 is added to the value of strm->data_type when inflate() returns
-  immediately after reaching the end of the deflate block header.
-
-    inflate() should normally be called until it returns Z_STREAM_END or an
-  error.  However if all decompression is to be performed in a single step (a
-  single call of inflate), the parameter flush should be set to Z_FINISH.  In
-  this case all pending input is processed and all pending output is flushed;
-  avail_out must be large enough to hold all of the uncompressed data for the
-  operation to complete.  (The size of the uncompressed data may have been
-  saved by the compressor for this purpose.) The use of Z_FINISH is not
-  required to perform an inflation in one step.  However it may be used to
-  inform inflate that a faster approach can be used for the single inflate()
-  call.  Z_FINISH also informs inflate to not maintain a sliding window if the
-  stream completes, which reduces inflate's memory footprint.  If the stream
-  does not complete, either because not all of the stream is provided or not
-  enough output space is provided, then a sliding window will be allocated and
-  inflate() can be called again to continue the operation as if Z_NO_FLUSH had
-  been used.
-
-     In this implementation, inflate() always flushes as much output as
-  possible to the output buffer, and always uses the faster approach on the
-  first call.  So the effects of the flush parameter in this implementation are
-  on the return value of inflate() as noted below, when inflate() returns early
-  when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of
-  memory for a sliding window when Z_FINISH is used.
-
-     If a preset dictionary is needed after this call (see inflateSetDictionary
-  below), inflate sets strm->adler to the Adler-32 checksum of the dictionary
-  chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
-  strm->adler to the Adler-32 checksum of all output produced so far (that is,
-  total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
-  below.  At the end of the stream, inflate() checks that its computed adler32
-  checksum is equal to that saved by the compressor and returns Z_STREAM_END
-  only if the checksum is correct.
-
-    inflate() can decompress and check either zlib-wrapped or gzip-wrapped
-  deflate data.  The header type is detected automatically, if requested when
-  initializing with inflateInit2().  Any information contained in the gzip
-  header is not retained, so applications that need that information should
-  instead use raw inflate, see inflateInit2() below, or inflateBack() and
-  perform their own processing of the gzip header and trailer.  When processing
-  gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output
-  producted so far.  The CRC-32 is checked against the gzip trailer.
-
-    inflate() returns Z_OK if some progress has been made (more input processed
-  or more output produced), Z_STREAM_END if the end of the compressed data has
-  been reached and all uncompressed output has been produced, Z_NEED_DICT if a
-  preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
-  corrupted (input stream not conforming to the zlib format or incorrect check
-  value), Z_STREAM_ERROR if the stream structure was inconsistent (for example
-  next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory,
-  Z_BUF_ERROR if no progress is possible or if there was not enough room in the
-  output buffer when Z_FINISH is used.  Note that Z_BUF_ERROR is not fatal, and
-  inflate() can be called again with more input and more output space to
-  continue decompressing.  If Z_DATA_ERROR is returned, the application may
-  then call inflateSync() to look for a good compression block if a partial
-  recovery of the data is desired.
-*/
-
-
-ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
-/*
-     All dynamically allocated data structures for this stream are freed.
-   This function discards any unprocessed input and does not flush any pending
-   output.
-
-     inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
-   was inconsistent.  In the error case, msg may be set but then points to a
-   static string (which must not be deallocated).
-*/
-
-
-                        /* Advanced functions */
-
-/*
-    The following functions are needed only in some special applications.
-*/
-
-/*
-ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
-                                     int  level,
-                                     int  method,
-                                     int  windowBits,
-                                     int  memLevel,
-                                     int  strategy));
-
-     This is another version of deflateInit with more compression options.  The
-   fields next_in, zalloc, zfree and opaque must be initialized before by the
-   caller.
-
-     The method parameter is the compression method.  It must be Z_DEFLATED in
-   this version of the library.
-
-     The windowBits parameter is the base two logarithm of the window size
-   (the size of the history buffer).  It should be in the range 8..15 for this
-   version of the library.  Larger values of this parameter result in better
-   compression at the expense of memory usage.  The default value is 15 if
-   deflateInit is used instead.
-
-     windowBits can also be -8..-15 for raw deflate.  In this case, -windowBits
-   determines the window size.  deflate() will then generate raw deflate data
-   with no zlib header or trailer, and will not compute an adler32 check value.
-
-     windowBits can also be greater than 15 for optional gzip encoding.  Add
-   16 to windowBits to write a simple gzip header and trailer around the
-   compressed data instead of a zlib wrapper.  The gzip header will have no
-   file name, no extra data, no comment, no modification time (set to zero), no
-   header crc, and the operating system will be set to 255 (unknown).  If a
-   gzip stream is being written, strm->adler is a crc32 instead of an adler32.
-
-     The memLevel parameter specifies how much memory should be allocated
-   for the internal compression state.  memLevel=1 uses minimum memory but is
-   slow and reduces compression ratio; memLevel=9 uses maximum memory for
-   optimal speed.  The default value is 8.  See zconf.h for total memory usage
-   as a function of windowBits and memLevel.
-
-     The strategy parameter is used to tune the compression algorithm.  Use the
-   value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
-   filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
-   string match), or Z_RLE to limit match distances to one (run-length
-   encoding).  Filtered data consists mostly of small values with a somewhat
-   random distribution.  In this case, the compression algorithm is tuned to
-   compress them better.  The effect of Z_FILTERED is to force more Huffman
-   coding and less string matching; it is somewhat intermediate between
-   Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY.  Z_RLE is designed to be almost as
-   fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data.  The
-   strategy parameter only affects the compression ratio but not the
-   correctness of the compressed output even if it is not set appropriately.
-   Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler
-   decoder for special applications.
-
-     deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
-   memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid
-   method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is
-   incompatible with the version assumed by the caller (ZLIB_VERSION).  msg is
-   set to null if there is no error message.  deflateInit2 does not perform any
-   compression: this will be done by deflate().
-*/
-
-ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
-                                             const Bytef *dictionary,
-                                             uInt  dictLength));
-/*
-     Initializes the compression dictionary from the given byte sequence
-   without producing any compressed output.  When using the zlib format, this
-   function must be called immediately after deflateInit, deflateInit2 or
-   deflateReset, and before any call of deflate.  When doing raw deflate, this
-   function must be called either before any call of deflate, or immediately
-   after the completion of a deflate block, i.e. after all input has been
-   consumed and all output has been delivered when using any of the flush
-   options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH.  The
-   compressor and decompressor must use exactly the same dictionary (see
-   inflateSetDictionary).
-
-     The dictionary should consist of strings (byte sequences) that are likely
-   to be encountered later in the data to be compressed, with the most commonly
-   used strings preferably put towards the end of the dictionary.  Using a
-   dictionary is most useful when the data to be compressed is short and can be
-   predicted with good accuracy; the data can then be compressed better than
-   with the default empty dictionary.
-
-     Depending on the size of the compression data structures selected by
-   deflateInit or deflateInit2, a part of the dictionary may in effect be
-   discarded, for example if the dictionary is larger than the window size
-   provided in deflateInit or deflateInit2.  Thus the strings most likely to be
-   useful should be put at the end of the dictionary, not at the front.  In
-   addition, the current implementation of deflate will use at most the window
-   size minus 262 bytes of the provided dictionary.
-
-     Upon return of this function, strm->adler is set to the adler32 value
-   of the dictionary; the decompressor may later use this value to determine
-   which dictionary has been used by the compressor.  (The adler32 value
-   applies to the whole dictionary even if only a subset of the dictionary is
-   actually used by the compressor.) If a raw deflate was requested, then the
-   adler32 value is not computed and strm->adler is not set.
-
-     deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
-   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is
-   inconsistent (for example if deflate has already been called for this stream
-   or if not at a block boundary for raw deflate).  deflateSetDictionary does
-   not perform any compression: this will be done by deflate().
-*/
-
-ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
-                                    z_streamp source));
-/*
-     Sets the destination stream as a complete copy of the source stream.
-
-     This function can be useful when several compression strategies will be
-   tried, for example when there are several ways of pre-processing the input
-   data with a filter.  The streams that will be discarded should then be freed
-   by calling deflateEnd.  Note that deflateCopy duplicates the internal
-   compression state which can be quite large, so this strategy is slow and can
-   consume lots of memory.
-
-     deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
-   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
-   (such as zalloc being Z_NULL).  msg is left unchanged in both source and
-   destination.
-*/
-
-ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
-/*
-     This function is equivalent to deflateEnd followed by deflateInit,
-   but does not free and reallocate all the internal compression state.  The
-   stream will keep the same compression level and any other attributes that
-   may have been set by deflateInit2.
-
-     deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
-   stream state was inconsistent (such as zalloc or state being Z_NULL).
-*/
-
-ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
-                                      int level,
-                                      int strategy));
-/*
-     Dynamically update the compression level and compression strategy.  The
-   interpretation of level and strategy is as in deflateInit2.  This can be
-   used to switch between compression and straight copy of the input data, or
-   to switch to a different kind of input data requiring a different strategy.
-   If the compression level is changed, the input available so far is
-   compressed with the old level (and may be flushed); the new level will take
-   effect only at the next call of deflate().
-
-     Before the call of deflateParams, the stream state must be set as for
-   a call of deflate(), since the currently available input may have to be
-   compressed and flushed.  In particular, strm->avail_out must be non-zero.
-
-     deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
-   stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if
-   strm->avail_out was zero.
-*/
-
-ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
-                                    int good_length,
-                                    int max_lazy,
-                                    int nice_length,
-                                    int max_chain));
-/*
-     Fine tune deflate's internal compression parameters.  This should only be
-   used by someone who understands the algorithm used by zlib's deflate for
-   searching for the best matching string, and even then only by the most
-   fanatic optimizer trying to squeeze out the last compressed bit for their
-   specific input data.  Read the deflate.c source code for the meaning of the
-   max_lazy, good_length, nice_length, and max_chain parameters.
-
-     deflateTune() can be called after deflateInit() or deflateInit2(), and
-   returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
- */
-
-ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
-                                       uLong sourceLen));
-/*
-     deflateBound() returns an upper bound on the compressed size after
-   deflation of sourceLen bytes.  It must be called after deflateInit() or
-   deflateInit2(), and after deflateSetHeader(), if used.  This would be used
-   to allocate an output buffer for deflation in a single pass, and so would be
-   called before deflate().  If that first deflate() call is provided the
-   sourceLen input bytes, an output buffer allocated to the size returned by
-   deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed
-   to return Z_STREAM_END.  Note that it is possible for the compressed size to
-   be larger than the value returned by deflateBound() if flush options other
-   than Z_FINISH or Z_NO_FLUSH are used.
-*/
-
-ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm,
-                                       unsigned *pending,
-                                       int *bits));
-/*
-     deflatePending() returns the number of bytes and bits of output that have
-   been generated, but not yet provided in the available output.  The bytes not
-   provided would be due to the available output space having being consumed.
-   The number of bits of output not provided are between 0 and 7, where they
-   await more bits to join them in order to fill out a full byte.  If pending
-   or bits are Z_NULL, then those values are not set.
-
-     deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source
-   stream state was inconsistent.
- */
-
-ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
-                                     int bits,
-                                     int value));
-/*
-     deflatePrime() inserts bits in the deflate output stream.  The intent
-   is that this function is used to start off the deflate output with the bits
-   leftover from a previous deflate stream when appending to it.  As such, this
-   function can only be used for raw deflate, and must be used before the first
-   deflate() call after a deflateInit2() or deflateReset().  bits must be less
-   than or equal to 16, and that many of the least significant bits of value
-   will be inserted in the output.
-
-     deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough
-   room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the
-   source stream state was inconsistent.
-*/
-
-ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
-                                         gz_headerp head));
-/*
-     deflateSetHeader() provides gzip header information for when a gzip
-   stream is requested by deflateInit2().  deflateSetHeader() may be called
-   after deflateInit2() or deflateReset() and before the first call of
-   deflate().  The text, time, os, extra field, name, and comment information
-   in the provided gz_header structure are written to the gzip header (xflag is
-   ignored -- the extra flags are set according to the compression level).  The
-   caller must assure that, if not Z_NULL, name and comment are terminated with
-   a zero byte, and that if extra is not Z_NULL, that extra_len bytes are
-   available there.  If hcrc is true, a gzip header crc is included.  Note that
-   the current versions of the command-line version of gzip (up through version
-   1.3.x) do not support header crc's, and will report that it is a "multi-part
-   gzip file" and give up.
-
-     If deflateSetHeader is not used, the default gzip header has text false,
-   the time set to zero, and os set to 255, with no extra, name, or comment
-   fields.  The gzip header is returned to the default state by deflateReset().
-
-     deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
-   stream state was inconsistent.
-*/
-
-/*
-ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
-                                     int  windowBits));
-
-     This is another version of inflateInit with an extra parameter.  The
-   fields next_in, avail_in, zalloc, zfree and opaque must be initialized
-   before by the caller.
-
-     The windowBits parameter is the base two logarithm of the maximum window
-   size (the size of the history buffer).  It should be in the range 8..15 for
-   this version of the library.  The default value is 15 if inflateInit is used
-   instead.  windowBits must be greater than or equal to the windowBits value
-   provided to deflateInit2() while compressing, or it must be equal to 15 if
-   deflateInit2() was not used.  If a compressed stream with a larger window
-   size is given as input, inflate() will return with the error code
-   Z_DATA_ERROR instead of trying to allocate a larger window.
-
-     windowBits can also be zero to request that inflate use the window size in
-   the zlib header of the compressed stream.
-
-     windowBits can also be -8..-15 for raw inflate.  In this case, -windowBits
-   determines the window size.  inflate() will then process raw deflate data,
-   not looking for a zlib or gzip header, not generating a check value, and not
-   looking for any check values for comparison at the end of the stream.  This
-   is for use with other formats that use the deflate compressed data format
-   such as zip.  Those formats provide their own check values.  If a custom
-   format is developed using the raw deflate format for compressed data, it is
-   recommended that a check value such as an adler32 or a crc32 be applied to
-   the uncompressed data as is done in the zlib, gzip, and zip formats.  For
-   most applications, the zlib format should be used as is.  Note that comments
-   above on the use in deflateInit2() applies to the magnitude of windowBits.
-
-     windowBits can also be greater than 15 for optional gzip decoding.  Add
-   32 to windowBits to enable zlib and gzip decoding with automatic header
-   detection, or add 16 to decode only the gzip format (the zlib format will
-   return a Z_DATA_ERROR).  If a gzip stream is being decoded, strm->adler is a
-   crc32 instead of an adler32.
-
-     inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
-   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
-   version assumed by the caller, or Z_STREAM_ERROR if the parameters are
-   invalid, such as a null pointer to the structure.  msg is set to null if
-   there is no error message.  inflateInit2 does not perform any decompression
-   apart from possibly reading the zlib header if present: actual decompression
-   will be done by inflate().  (So next_in and avail_in may be modified, but
-   next_out and avail_out are unused and unchanged.) The current implementation
-   of inflateInit2() does not process any header information -- that is
-   deferred until inflate() is called.
-*/
-
-ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
-                                             const Bytef *dictionary,
-                                             uInt  dictLength));
-/*
-     Initializes the decompression dictionary from the given uncompressed byte
-   sequence.  This function must be called immediately after a call of inflate,
-   if that call returned Z_NEED_DICT.  The dictionary chosen by the compressor
-   can be determined from the adler32 value returned by that call of inflate.
-   The compressor and decompressor must use exactly the same dictionary (see
-   deflateSetDictionary).  For raw inflate, this function can be called at any
-   time to set the dictionary.  If the provided dictionary is smaller than the
-   window and there is already data in the window, then the provided dictionary
-   will amend what's there.  The application must insure that the dictionary
-   that was used for compression is provided.
-
-     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
-   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is
-   inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
-   expected one (incorrect adler32 value).  inflateSetDictionary does not
-   perform any decompression: this will be done by subsequent calls of
-   inflate().
-*/
-
-ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm,
-                                             Bytef *dictionary,
-                                             uInt  *dictLength));
-/*
-     Returns the sliding dictionary being maintained by inflate.  dictLength is
-   set to the number of bytes in the dictionary, and that many bytes are copied
-   to dictionary.  dictionary must have enough space, where 32768 bytes is
-   always enough.  If inflateGetDictionary() is called with dictionary equal to
-   Z_NULL, then only the dictionary length is returned, and nothing is copied.
-   Similary, if dictLength is Z_NULL, then it is not set.
-
-     inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
-   stream state is inconsistent.
-*/
-
-ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
-/*
-     Skips invalid compressed data until a possible full flush point (see above
-   for the description of deflate with Z_FULL_FLUSH) can be found, or until all
-   available input is skipped.  No output is provided.
-
-     inflateSync searches for a 00 00 FF FF pattern in the compressed data.
-   All full flush points have this pattern, but not all occurrences of this
-   pattern are full flush points.
-
-     inflateSync returns Z_OK if a possible full flush point has been found,
-   Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point
-   has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.
-   In the success case, the application may save the current current value of
-   total_in which indicates where valid compressed data was found.  In the
-   error case, the application may repeatedly call inflateSync, providing more
-   input each time, until success or end of the input data.
-*/
-
-ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
-                                    z_streamp source));
-/*
-     Sets the destination stream as a complete copy of the source stream.
-
-     This function can be useful when randomly accessing a large stream.  The
-   first pass through the stream can periodically record the inflate state,
-   allowing restarting inflate at those points when randomly accessing the
-   stream.
-
-     inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
-   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
-   (such as zalloc being Z_NULL).  msg is left unchanged in both source and
-   destination.
-*/
-
-ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
-/*
-     This function is equivalent to inflateEnd followed by inflateInit,
-   but does not free and reallocate all the internal decompression state.  The
-   stream will keep attributes that may have been set by inflateInit2.
-
-     inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
-   stream state was inconsistent (such as zalloc or state being Z_NULL).
-*/
-
-ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,
-                                      int windowBits));
-/*
-     This function is the same as inflateReset, but it also permits changing
-   the wrap and window size requests.  The windowBits parameter is interpreted
-   the same as it is for inflateInit2.
-
-     inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source
-   stream state was inconsistent (such as zalloc or state being Z_NULL), or if
-   the windowBits parameter is invalid.
-*/
-
-ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
-                                     int bits,
-                                     int value));
-/*
-     This function inserts bits in the inflate input stream.  The intent is
-   that this function is used to start inflating at a bit position in the
-   middle of a byte.  The provided bits will be used before any bytes are used
-   from next_in.  This function should only be used with raw inflate, and
-   should be used before the first inflate() call after inflateInit2() or
-   inflateReset().  bits must be less than or equal to 16, and that many of the
-   least significant bits of value will be inserted in the input.
-
-     If bits is negative, then the input stream bit buffer is emptied.  Then
-   inflatePrime() can be called again to put bits in the buffer.  This is used
-   to clear out bits leftover after feeding inflate a block description prior
-   to feeding inflate codes.
-
-     inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
-   stream state was inconsistent.
-*/
-
-ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));
-/*
-     This function returns two values, one in the lower 16 bits of the return
-   value, and the other in the remaining upper bits, obtained by shifting the
-   return value down 16 bits.  If the upper value is -1 and the lower value is
-   zero, then inflate() is currently decoding information outside of a block.
-   If the upper value is -1 and the lower value is non-zero, then inflate is in
-   the middle of a stored block, with the lower value equaling the number of
-   bytes from the input remaining to copy.  If the upper value is not -1, then
-   it is the number of bits back from the current bit position in the input of
-   the code (literal or length/distance pair) currently being processed.  In
-   that case the lower value is the number of bytes already emitted for that
-   code.
-
-     A code is being processed if inflate is waiting for more input to complete
-   decoding of the code, or if it has completed decoding but is waiting for
-   more output space to write the literal or match data.
-
-     inflateMark() is used to mark locations in the input data for random
-   access, which may be at bit positions, and to note those cases where the
-   output of a code may span boundaries of random access blocks.  The current
-   location in the input stream can be determined from avail_in and data_type
-   as noted in the description for the Z_BLOCK flush parameter for inflate.
-
-     inflateMark returns the value noted above or -1 << 16 if the provided
-   source stream state was inconsistent.
-*/
-
-ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
-                                         gz_headerp head));
-/*
-     inflateGetHeader() requests that gzip header information be stored in the
-   provided gz_header structure.  inflateGetHeader() may be called after
-   inflateInit2() or inflateReset(), and before the first call of inflate().
-   As inflate() processes the gzip stream, head->done is zero until the header
-   is completed, at which time head->done is set to one.  If a zlib stream is
-   being decoded, then head->done is set to -1 to indicate that there will be
-   no gzip header information forthcoming.  Note that Z_BLOCK or Z_TREES can be
-   used to force inflate() to return immediately after header processing is
-   complete and before any actual data is decompressed.
-
-     The text, time, xflags, and os fields are filled in with the gzip header
-   contents.  hcrc is set to true if there is a header CRC.  (The header CRC
-   was valid if done is set to one.) If extra is not Z_NULL, then extra_max
-   contains the maximum number of bytes to write to extra.  Once done is true,
-   extra_len contains the actual extra field length, and extra contains the
-   extra field, or that field truncated if extra_max is less than extra_len.
-   If name is not Z_NULL, then up to name_max characters are written there,
-   terminated with a zero unless the length is greater than name_max.  If
-   comment is not Z_NULL, then up to comm_max characters are written there,
-   terminated with a zero unless the length is greater than comm_max.  When any
-   of extra, name, or comment are not Z_NULL and the respective field is not
-   present in the header, then that field is set to Z_NULL to signal its
-   absence.  This allows the use of deflateSetHeader() with the returned
-   structure to duplicate the header.  However if those fields are set to
-   allocated memory, then the application will need to save those pointers
-   elsewhere so that they can be eventually freed.
-
-     If inflateGetHeader is not used, then the header information is simply
-   discarded.  The header is always checked for validity, including the header
-   CRC if present.  inflateReset() will reset the process to discard the header
-   information.  The application would need to call inflateGetHeader() again to
-   retrieve the header from the next gzip stream.
-
-     inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
-   stream state was inconsistent.
-*/
-
-/*
-ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
-                                        unsigned char FAR *window));
-
-     Initialize the internal stream state for decompression using inflateBack()
-   calls.  The fields zalloc, zfree and opaque in strm must be initialized
-   before the call.  If zalloc and zfree are Z_NULL, then the default library-
-   derived memory allocation routines are used.  windowBits is the base two
-   logarithm of the window size, in the range 8..15.  window is a caller
-   supplied buffer of that size.  Except for special applications where it is
-   assured that deflate was used with small window sizes, windowBits must be 15
-   and a 32K byte window must be supplied to be able to decompress general
-   deflate streams.
-
-     See inflateBack() for the usage of these routines.
-
-     inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
-   the parameters are invalid, Z_MEM_ERROR if the internal state could not be
-   allocated, or Z_VERSION_ERROR if the version of the library does not match
-   the version of the header file.
-*/
-
-typedef unsigned (*in_func) OF((void FAR *,
-                                z_const unsigned char FAR * FAR *));
-typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
-
-ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
-                                    in_func in, void FAR *in_desc,
-                                    out_func out, void FAR *out_desc));
-/*
-     inflateBack() does a raw inflate with a single call using a call-back
-   interface for input and output.  This is potentially more efficient than
-   inflate() for file i/o applications, in that it avoids copying between the
-   output and the sliding window by simply making the window itself the output
-   buffer.  inflate() can be faster on modern CPUs when used with large
-   buffers.  inflateBack() trusts the application to not change the output
-   buffer passed by the output function, at least until inflateBack() returns.
-
-     inflateBackInit() must be called first to allocate the internal state
-   and to initialize the state with the user-provided window buffer.
-   inflateBack() may then be used multiple times to inflate a complete, raw
-   deflate stream with each call.  inflateBackEnd() is then called to free the
-   allocated state.
-
-     A raw deflate stream is one with no zlib or gzip header or trailer.
-   This routine would normally be used in a utility that reads zip or gzip
-   files and writes out uncompressed files.  The utility would decode the
-   header and process the trailer on its own, hence this routine expects only
-   the raw deflate stream to decompress.  This is different from the normal
-   behavior of inflate(), which expects either a zlib or gzip header and
-   trailer around the deflate stream.
-
-     inflateBack() uses two subroutines supplied by the caller that are then
-   called by inflateBack() for input and output.  inflateBack() calls those
-   routines until it reads a complete deflate stream and writes out all of the
-   uncompressed data, or until it encounters an error.  The function's
-   parameters and return types are defined above in the in_func and out_func
-   typedefs.  inflateBack() will call in(in_desc, &buf) which should return the
-   number of bytes of provided input, and a pointer to that input in buf.  If
-   there is no input available, in() must return zero--buf is ignored in that
-   case--and inflateBack() will return a buffer error.  inflateBack() will call
-   out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].  out()
-   should return zero on success, or non-zero on failure.  If out() returns
-   non-zero, inflateBack() will return with an error.  Neither in() nor out()
-   are permitted to change the contents of the window provided to
-   inflateBackInit(), which is also the buffer that out() uses to write from.
-   The length written by out() will be at most the window size.  Any non-zero
-   amount of input may be provided by in().
-
-     For convenience, inflateBack() can be provided input on the first call by
-   setting strm->next_in and strm->avail_in.  If that input is exhausted, then
-   in() will be called.  Therefore strm->next_in must be initialized before
-   calling inflateBack().  If strm->next_in is Z_NULL, then in() will be called
-   immediately for input.  If strm->next_in is not Z_NULL, then strm->avail_in
-   must also be initialized, and then if strm->avail_in is not zero, input will
-   initially be taken from strm->next_in[0 ..  strm->avail_in - 1].
-
-     The in_desc and out_desc parameters of inflateBack() is passed as the
-   first parameter of in() and out() respectively when they are called.  These
-   descriptors can be optionally used to pass any information that the caller-
-   supplied in() and out() functions need to do their job.
-
-     On return, inflateBack() will set strm->next_in and strm->avail_in to
-   pass back any unused input that was provided by the last in() call.  The
-   return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR
-   if in() or out() returned an error, Z_DATA_ERROR if there was a format error
-   in the deflate stream (in which case strm->msg is set to indicate the nature
-   of the error), or Z_STREAM_ERROR if the stream was not properly initialized.
-   In the case of Z_BUF_ERROR, an input or output error can be distinguished
-   using strm->next_in which will be Z_NULL only if in() returned an error.  If
-   strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning
-   non-zero.  (in() will always be called before out(), so strm->next_in is
-   assured to be defined if out() returns non-zero.) Note that inflateBack()
-   cannot return Z_OK.
-*/
-
-ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));
-/*
-     All memory allocated by inflateBackInit() is freed.
-
-     inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream
-   state was inconsistent.
-*/
-
-ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
-/* Return flags indicating compile-time options.
-
-    Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
-     1.0: size of uInt
-     3.2: size of uLong
-     5.4: size of voidpf (pointer)
-     7.6: size of z_off_t
-
-    Compiler, assembler, and debug options:
-     8: DEBUG
-     9: ASMV or ASMINF -- use ASM code
-     10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
-     11: 0 (reserved)
-
-    One-time table building (smaller code, but not thread-safe if true):
-     12: BUILDFIXED -- build static block decoding tables when needed
-     13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed
-     14,15: 0 (reserved)
-
-    Library content (indicates missing functionality):
-     16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking
-                          deflate code when not needed)
-     17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect
-                    and decode gzip streams (to avoid linking crc code)
-     18-19: 0 (reserved)
-
-    Operation variations (changes in library functionality):
-     20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate
-     21: FASTEST -- deflate algorithm with only one, lowest compression level
-     22,23: 0 (reserved)
-
-    The sprintf variant used by gzprintf (zero is best):
-     24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format
-     25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!
-     26: 0 = returns value, 1 = void -- 1 means inferred string length returned
-
-    Remainder:
-     27-31: 0 (reserved)
- */
-
-#ifndef Z_SOLO
-
-                        /* utility functions */
-
-/*
-     The following utility functions are implemented on top of the basic
-   stream-oriented functions.  To simplify the interface, some default options
-   are assumed (compression level and memory usage, standard memory allocation
-   functions).  The source code of these utility functions can be modified if
-   you need special options.
-*/
-
-ZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,
-                                 const Bytef *source, uLong sourceLen));
-/*
-     Compresses the source buffer into the destination buffer.  sourceLen is
-   the byte length of the source buffer.  Upon entry, destLen is the total size
-   of the destination buffer, which must be at least the value returned by
-   compressBound(sourceLen).  Upon exit, destLen is the actual size of the
-   compressed buffer.
-
-     compress returns Z_OK if success, Z_MEM_ERROR if there was not
-   enough memory, Z_BUF_ERROR if there was not enough room in the output
-   buffer.
-*/
-
-ZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,
-                                  const Bytef *source, uLong sourceLen,
-                                  int level));
-/*
-     Compresses the source buffer into the destination buffer.  The level
-   parameter has the same meaning as in deflateInit.  sourceLen is the byte
-   length of the source buffer.  Upon entry, destLen is the total size of the
-   destination buffer, which must be at least the value returned by
-   compressBound(sourceLen).  Upon exit, destLen is the actual size of the
-   compressed buffer.
-
-     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
-   memory, Z_BUF_ERROR if there was not enough room in the output buffer,
-   Z_STREAM_ERROR if the level parameter is invalid.
-*/
-
-ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
-/*
-     compressBound() returns an upper bound on the compressed size after
-   compress() or compress2() on sourceLen bytes.  It would be used before a
-   compress() or compress2() call to allocate the destination buffer.
-*/
-
-ZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
-                                   const Bytef *source, uLong sourceLen));
-/*
-     Decompresses the source buffer into the destination buffer.  sourceLen is
-   the byte length of the source buffer.  Upon entry, destLen is the total size
-   of the destination buffer, which must be large enough to hold the entire
-   uncompressed data.  (The size of the uncompressed data must have been saved
-   previously by the compressor and transmitted to the decompressor by some
-   mechanism outside the scope of this compression library.) Upon exit, destLen
-   is the actual size of the uncompressed buffer.
-
-     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
-   enough memory, Z_BUF_ERROR if there was not enough room in the output
-   buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.  In
-   the case where there is not enough room, uncompress() will fill the output
-   buffer with the uncompressed data up to that point.
-*/
-
-                        /* gzip file access functions */
-
-/*
-     This library supports reading and writing files in gzip (.gz) format with
-   an interface similar to that of stdio, using the functions that start with
-   "gz".  The gzip format is different from the zlib format.  gzip is a gzip
-   wrapper, documented in RFC 1952, wrapped around a deflate stream.
-*/
-
-typedef struct gzFile_s *gzFile;    /* semi-opaque gzip file descriptor */
-
-/*
-ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
-
-     Opens a gzip (.gz) file for reading or writing.  The mode parameter is as
-   in fopen ("rb" or "wb") but can also include a compression level ("wb9") or
-   a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only
-   compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F'
-   for fixed code compression as in "wb9F".  (See the description of
-   deflateInit2 for more information about the strategy parameter.)  'T' will
-   request transparent writing or appending with no compression and not using
-   the gzip format.
-
-     "a" can be used instead of "w" to request that the gzip stream that will
-   be written be appended to the file.  "+" will result in an error, since
-   reading and writing to the same gzip file is not supported.  The addition of
-   "x" when writing will create the file exclusively, which fails if the file
-   already exists.  On systems that support it, the addition of "e" when
-   reading or writing will set the flag to close the file on an execve() call.
-
-     These functions, as well as gzip, will read and decode a sequence of gzip
-   streams in a file.  The append function of gzopen() can be used to create
-   such a file.  (Also see gzflush() for another way to do this.)  When
-   appending, gzopen does not test whether the file begins with a gzip stream,
-   nor does it look for the end of the gzip streams to begin appending.  gzopen
-   will simply append a gzip stream to the existing file.
-
-     gzopen can be used to read a file which is not in gzip format; in this
-   case gzread will directly read from the file without decompression.  When
-   reading, this will be detected automatically by looking for the magic two-
-   byte gzip header.
-
-     gzopen returns NULL if the file could not be opened, if there was
-   insufficient memory to allocate the gzFile state, or if an invalid mode was
-   specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).
-   errno can be checked to determine if the reason gzopen failed was that the
-   file could not be opened.
-*/
-
-ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
-/*
-     gzdopen associates a gzFile with the file descriptor fd.  File descriptors
-   are obtained from calls like open, dup, creat, pipe or fileno (if the file
-   has been previously opened with fopen).  The mode parameter is as in gzopen.
-
-     The next call of gzclose on the returned gzFile will also close the file
-   descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
-   fd.  If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,
-   mode);.  The duplicated descriptor should be saved to avoid a leak, since
-   gzdopen does not close fd if it fails.  If you are using fileno() to get the
-   file descriptor from a FILE *, then you will have to use dup() to avoid
-   double-close()ing the file descriptor.  Both gzclose() and fclose() will
-   close the associated file descriptor, so they need to have different file
-   descriptors.
-
-     gzdopen returns NULL if there was insufficient memory to allocate the
-   gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not
-   provided, or '+' was provided), or if fd is -1.  The file descriptor is not
-   used until the next gz* read, write, seek, or close operation, so gzdopen
-   will not detect if fd is invalid (unless fd is -1).
-*/
-
-ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
-/*
-     Set the internal buffer size used by this library's functions.  The
-   default buffer size is 8192 bytes.  This function must be called after
-   gzopen() or gzdopen(), and before any other calls that read or write the
-   file.  The buffer memory allocation is always deferred to the first read or
-   write.  Two buffers are allocated, either both of the specified size when
-   writing, or one of the specified size and the other twice that size when
-   reading.  A larger buffer size of, for example, 64K or 128K bytes will
-   noticeably increase the speed of decompression (reading).
-
-     The new buffer size also affects the maximum length for gzprintf().
-
-     gzbuffer() returns 0 on success, or -1 on failure, such as being called
-   too late.
-*/
-
-ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
-/*
-     Dynamically update the compression level or strategy.  See the description
-   of deflateInit2 for the meaning of these parameters.
-
-     gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
-   opened for writing.
-*/
-
-ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
-/*
-     Reads the given number of uncompressed bytes from the compressed file.  If
-   the input file is not in gzip format, gzread copies the given number of
-   bytes into the buffer directly from the file.
-
-     After reaching the end of a gzip stream in the input, gzread will continue
-   to read, looking for another gzip stream.  Any number of gzip streams may be
-   concatenated in the input file, and will all be decompressed by gzread().
-   If something other than a gzip stream is encountered after a gzip stream,
-   that remaining trailing garbage is ignored (and no error is returned).
-
-     gzread can be used to read a gzip file that is being concurrently written.
-   Upon reaching the end of the input, gzread will return with the available
-   data.  If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then
-   gzclearerr can be used to clear the end of file indicator in order to permit
-   gzread to be tried again.  Z_OK indicates that a gzip stream was completed
-   on the last gzread.  Z_BUF_ERROR indicates that the input file ended in the
-   middle of a gzip stream.  Note that gzread does not return -1 in the event
-   of an incomplete gzip stream.  This error is deferred until gzclose(), which
-   will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip
-   stream.  Alternatively, gzerror can be used before gzclose to detect this
-   case.
-
-     gzread returns the number of uncompressed bytes actually read, less than
-   len for end of file, or -1 for error.
-*/
-
-ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
-                                voidpc buf, unsigned len));
-/*
-     Writes the given number of uncompressed bytes into the compressed file.
-   gzwrite returns the number of uncompressed bytes written or 0 in case of
-   error.
-*/
-
-ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));
-/*
-     Converts, formats, and writes the arguments to the compressed file under
-   control of the format string, as in fprintf.  gzprintf returns the number of
-   uncompressed bytes actually written, or 0 in case of error.  The number of
-   uncompressed bytes written is limited to 8191, or one less than the buffer
-   size given to gzbuffer().  The caller should assure that this limit is not
-   exceeded.  If it is exceeded, then gzprintf() will return an error (0) with
-   nothing written.  In this case, there may also be a buffer overflow with
-   unpredictable consequences, which is possible only if zlib was compiled with
-   the insecure functions sprintf() or vsprintf() because the secure snprintf()
-   or vsnprintf() functions were not available.  This can be determined using
-   zlibCompileFlags().
-*/
-
-ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
-/*
-     Writes the given null-terminated string to the compressed file, excluding
-   the terminating null character.
-
-     gzputs returns the number of characters written, or -1 in case of error.
-*/
-
-ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
-/*
-     Reads bytes from the compressed file until len-1 characters are read, or a
-   newline character is read and transferred to buf, or an end-of-file
-   condition is encountered.  If any characters are read or if len == 1, the
-   string is terminated with a null character.  If no characters are read due
-   to an end-of-file or len < 1, then the buffer is left untouched.
-
-     gzgets returns buf which is a null-terminated string, or it returns NULL
-   for end-of-file or in case of error.  If there was an error, the contents at
-   buf are indeterminate.
-*/
-
-ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
-/*
-     Writes c, converted to an unsigned char, into the compressed file.  gzputc
-   returns the value that was written, or -1 in case of error.
-*/
-
-ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
-/*
-     Reads one byte from the compressed file.  gzgetc returns this byte or -1
-   in case of end of file or error.  This is implemented as a macro for speed.
-   As such, it does not do all of the checking the other functions do.  I.e.
-   it does not check to see if file is NULL, nor whether the structure file
-   points to has been clobbered or not.
-*/
-
-ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
-/*
-     Push one character back onto the stream to be read as the first character
-   on the next read.  At least one character of push-back is allowed.
-   gzungetc() returns the character pushed, or -1 on failure.  gzungetc() will
-   fail if c is -1, and may fail if a character has been pushed but not read
-   yet.  If gzungetc is used immediately after gzopen or gzdopen, at least the
-   output buffer size of pushed characters is allowed.  (See gzbuffer above.)
-   The pushed character will be discarded if the stream is repositioned with
-   gzseek() or gzrewind().
-*/
-
-ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
-/*
-     Flushes all pending output into the compressed file.  The parameter flush
-   is as in the deflate() function.  The return value is the zlib error number
-   (see function gzerror below).  gzflush is only permitted when writing.
-
-     If the flush parameter is Z_FINISH, the remaining data is written and the
-   gzip stream is completed in the output.  If gzwrite() is called again, a new
-   gzip stream will be started in the output.  gzread() is able to read such
-   concatented gzip streams.
-
-     gzflush should be called only when strictly necessary because it will
-   degrade compression if called too often.
-*/
-
-/*
-ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
-                                   z_off_t offset, int whence));
-
-     Sets the starting position for the next gzread or gzwrite on the given
-   compressed file.  The offset represents a number of bytes in the
-   uncompressed data stream.  The whence parameter is defined as in lseek(2);
-   the value SEEK_END is not supported.
-
-     If the file is opened for reading, this function is emulated but can be
-   extremely slow.  If the file is opened for writing, only forward seeks are
-   supported; gzseek then compresses a sequence of zeroes up to the new
-   starting position.
-
-     gzseek returns the resulting offset location as measured in bytes from
-   the beginning of the uncompressed stream, or -1 in case of error, in
-   particular if the file is opened for writing and the new starting position
-   would be before the current position.
-*/
-
-ZEXTERN int ZEXPORT    gzrewind OF((gzFile file));
-/*
-     Rewinds the given file. This function is supported only for reading.
-
-     gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
-*/
-
-/*
-ZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));
-
-     Returns the starting position for the next gzread or gzwrite on the given
-   compressed file.  This position represents a number of bytes in the
-   uncompressed data stream, and is zero when starting, even if appending or
-   reading a gzip stream from the middle of a file using gzdopen().
-
-     gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
-*/
-
-/*
-ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));
-
-     Returns the current offset in the file being read or written.  This offset
-   includes the count of bytes that precede the gzip stream, for example when
-   appending or when using gzdopen() for reading.  When reading, the offset
-   does not include as yet unused buffered input.  This information can be used
-   for a progress indicator.  On error, gzoffset() returns -1.
-*/
-
-ZEXTERN int ZEXPORT gzeof OF((gzFile file));
-/*
-     Returns true (1) if the end-of-file indicator has been set while reading,
-   false (0) otherwise.  Note that the end-of-file indicator is set only if the
-   read tried to go past the end of the input, but came up short.  Therefore,
-   just like feof(), gzeof() may return false even if there is no more data to
-   read, in the event that the last read request was for the exact number of
-   bytes remaining in the input file.  This will happen if the input file size
-   is an exact multiple of the buffer size.
-
-     If gzeof() returns true, then the read functions will return no more data,
-   unless the end-of-file indicator is reset by gzclearerr() and the input file
-   has grown since the previous end of file was detected.
-*/
-
-ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
-/*
-     Returns true (1) if file is being copied directly while reading, or false
-   (0) if file is a gzip stream being decompressed.
-
-     If the input file is empty, gzdirect() will return true, since the input
-   does not contain a gzip stream.
-
-     If gzdirect() is used immediately after gzopen() or gzdopen() it will
-   cause buffers to be allocated to allow reading the file to determine if it
-   is a gzip file.  Therefore if gzbuffer() is used, it should be called before
-   gzdirect().
-
-     When writing, gzdirect() returns true (1) if transparent writing was
-   requested ("wT" for the gzopen() mode), or false (0) otherwise.  (Note:
-   gzdirect() is not needed when writing.  Transparent writing must be
-   explicitly requested, so the application already knows the answer.  When
-   linking statically, using gzdirect() will include all of the zlib code for
-   gzip file reading and decompression, which may not be desired.)
-*/
-
-ZEXTERN int ZEXPORT    gzclose OF((gzFile file));
-/*
-     Flushes all pending output if necessary, closes the compressed file and
-   deallocates the (de)compression state.  Note that once file is closed, you
-   cannot call gzerror with file, since its structures have been deallocated.
-   gzclose must not be called more than once on the same file, just as free
-   must not be called more than once on the same allocation.
-
-     gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a
-   file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the
-   last read ended in the middle of a gzip stream, or Z_OK on success.
-*/
-
-ZEXTERN int ZEXPORT gzclose_r OF((gzFile file));
-ZEXTERN int ZEXPORT gzclose_w OF((gzFile file));
-/*
-     Same as gzclose(), but gzclose_r() is only for use when reading, and
-   gzclose_w() is only for use when writing or appending.  The advantage to
-   using these instead of gzclose() is that they avoid linking in zlib
-   compression or decompression code that is not used when only reading or only
-   writing respectively.  If gzclose() is used, then both compression and
-   decompression code will be included the application when linking to a static
-   zlib library.
-*/
-
-ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
-/*
-     Returns the error message for the last error which occurred on the given
-   compressed file.  errnum is set to zlib error number.  If an error occurred
-   in the file system and not in the compression library, errnum is set to
-   Z_ERRNO and the application may consult errno to get the exact error code.
-
-     The application must not modify the returned string.  Future calls to
-   this function may invalidate the previously returned string.  If file is
-   closed, then the string previously returned by gzerror will no longer be
-   available.
-
-     gzerror() should be used to distinguish errors from end-of-file for those
-   functions above that do not distinguish those cases in their return values.
-*/
-
-ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
-/*
-     Clears the error and end-of-file flags for file.  This is analogous to the
-   clearerr() function in stdio.  This is useful for continuing to read a gzip
-   file that is being written concurrently.
-*/
-
-#endif /* !Z_SOLO */
-
-                        /* checksum functions */
-
-/*
-     These functions are not related to compression but are exported
-   anyway because they might be useful in applications using the compression
-   library.
-*/
-
-ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
-/*
-     Update a running Adler-32 checksum with the bytes buf[0..len-1] and
-   return the updated checksum.  If buf is Z_NULL, this function returns the
-   required initial value for the checksum.
-
-     An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
-   much faster.
-
-   Usage example:
-
-     uLong adler = adler32(0L, Z_NULL, 0);
-
-     while (read_buffer(buffer, length) != EOF) {
-       adler = adler32(adler, buffer, length);
-     }
-     if (adler != original_adler) error();
-*/
-
-/*
-ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
-                                          z_off_t len2));
-
-     Combine two Adler-32 checksums into one.  For two sequences of bytes, seq1
-   and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
-   each, adler1 and adler2.  adler32_combine() returns the Adler-32 checksum of
-   seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.  Note
-   that the z_off_t type (like off_t) is a signed integer.  If len2 is
-   negative, the result has no meaning or utility.
-*/
-
-ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));
-/*
-     Update a running CRC-32 with the bytes buf[0..len-1] and return the
-   updated CRC-32.  If buf is Z_NULL, this function returns the required
-   initial value for the crc.  Pre- and post-conditioning (one's complement) is
-   performed within this function so it shouldn't be done by the application.
-
-   Usage example:
-
-     uLong crc = crc32(0L, Z_NULL, 0);
-
-     while (read_buffer(buffer, length) != EOF) {
-       crc = crc32(crc, buffer, length);
-     }
-     if (crc != original_crc) error();
-*/
-
-/*
-ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
-
-     Combine two CRC-32 check values into one.  For two sequences of bytes,
-   seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
-   calculated for each, crc1 and crc2.  crc32_combine() returns the CRC-32
-   check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
-   len2.
-*/
-
-
-                        /* various hacks, don't look :) */
-
-/* deflateInit and inflateInit are macros to allow checking the zlib version
- * and the compiler's view of z_stream:
- */
-ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
-                                     const char *version, int stream_size));
-ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
-                                     const char *version, int stream_size));
-ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,
-                                      int windowBits, int memLevel,
-                                      int strategy, const char *version,
-                                      int stream_size));
-ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,
-                                      const char *version, int stream_size));
-ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
-                                         unsigned char FAR *window,
-                                         const char *version,
-                                         int stream_size));
-#define deflateInit(strm, level) \
-        deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
-#define inflateInit(strm) \
-        inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
-#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
-        deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
-                      (strategy), ZLIB_VERSION, (int)sizeof(z_stream))
-#define inflateInit2(strm, windowBits) \
-        inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
-                      (int)sizeof(z_stream))
-#define inflateBackInit(strm, windowBits, window) \
-        inflateBackInit_((strm), (windowBits), (window), \
-                      ZLIB_VERSION, (int)sizeof(z_stream))
-
-#ifndef Z_SOLO
-
-/* gzgetc() macro and its supporting function and exposed data structure.  Note
- * that the real internal state is much larger than the exposed structure.
- * This abbreviated structure exposes just enough for the gzgetc() macro.  The
- * user should not mess with these exposed elements, since their names or
- * behavior could change in the future, perhaps even capriciously.  They can
- * only be used by the gzgetc() macro.  You have been warned.
- */
-ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));  /* backward compatibility */
-#ifdef Z_PREFIX_SET
-#  undef z_gzgetc
-#  define z_gzgetc(g) \
-          ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
-#else
-#  define gzgetc(g) \
-          ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
-#endif
-
-/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
- * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if
- * both are true, the application gets the *64 functions, and the regular
- * functions are changed to 64 bits) -- in case these are set on systems
- * without large file support, _LFS64_LARGEFILE must also be true
- */
-#ifdef Z_LARGE64
-   ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
-   ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
-   ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
-   ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
-   ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));
-   ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
-#endif
-
-#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
-#  ifdef Z_PREFIX_SET
-#    define z_gzopen z_gzopen64
-#    define z_gzseek z_gzseek64
-#    define z_gztell z_gztell64
-#    define z_gzoffset z_gzoffset64
-#    define z_adler32_combine z_adler32_combine64
-#    define z_crc32_combine z_crc32_combine64
-#  else
-#    define gzopen gzopen64
-#    define gzseek gzseek64
-#    define gztell gztell64
-#    define gzoffset gzoffset64
-#    define adler32_combine adler32_combine64
-#    define crc32_combine crc32_combine64
-#  endif
-#  ifndef Z_LARGE64
-     ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
-     ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));
-     ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));
-     ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));
-     ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
-     ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
-#  endif
-#else
-   ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
-   ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));
-   ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));
-   ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));
-   ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
-   ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
-#endif
-
-#else /* Z_SOLO */
-
-   ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
-   ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
-
-#endif /* !Z_SOLO */
-
-/* hack for buggy compilers */
-#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
-    struct internal_state {int dummy;};
-#endif
-
-/* undocumented functions */
-ZEXTERN const char   * ZEXPORT zError           OF((int));
-ZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp));
-ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table    OF((void));
-ZEXTERN int            ZEXPORT inflateUndermine OF((z_streamp, int));
-ZEXTERN int            ZEXPORT inflateResetKeep OF((z_streamp));
-ZEXTERN int            ZEXPORT deflateResetKeep OF((z_streamp));
-#if defined(_WIN32) && !defined(Z_SOLO)
-ZEXTERN gzFile         ZEXPORT gzopen_w OF((const wchar_t *path,
-                                            const char *mode));
-#endif
-#if defined(STDC) || defined(Z_HAVE_STDARG_H)
-#  ifndef Z_SOLO
-ZEXTERN int            ZEXPORTVA gzvprintf Z_ARG((gzFile file,
-                                                  const char *format,
-                                                  va_list va));
-#  endif
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ZLIB_H */
diff --git a/deps/zlib/zutil.c b/deps/zlib/zutil.c
deleted file mode 100644 (file)
index c9353fe..0000000
+++ /dev/null
@@ -1,305 +0,0 @@
-/* zutil.c -- target dependent utility functions for the compression library
- * Copyright (C) 1995-2005, 2010, 2011, 2012 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#include "zutil.h"
-#ifndef Z_SOLO
-#  include "gzguts.h"
-#endif
-
-char * const z_errmsg[10] = {
-   "need dictionary",     /* Z_NEED_DICT       2  */
-   "stream end",          /* Z_STREAM_END      1  */
-   "",                    /* Z_OK              0  */
-   "file error",          /* Z_ERRNO         (-1) */
-   "stream error",        /* Z_STREAM_ERROR  (-2) */
-   "data error",          /* Z_DATA_ERROR    (-3) */
-   "insufficient memory", /* Z_MEM_ERROR     (-4) */
-   "buffer error",        /* Z_BUF_ERROR     (-5) */
-   "incompatible version",/* Z_VERSION_ERROR (-6) */
-   ""};
-
-
-const char * ZEXPORT zlibVersion(void)
-{
-   return ZLIB_VERSION;
-}
-
-uLong ZEXPORT zlibCompileFlags(void)
-{
-   uLong flags;
-
-   flags = 0;
-   switch ((int)(sizeof(uInt))) {
-      case 2:     break;
-      case 4:     flags += 1;     break;
-      case 8:     flags += 2;     break;
-      default:    flags += 3;
-   }
-   switch ((int)(sizeof(uLong))) {
-      case 2:     break;
-      case 4:     flags += 1 << 2;        break;
-      case 8:     flags += 2 << 2;        break;
-      default:    flags += 3 << 2;
-   }
-   switch ((int)(sizeof(voidpf))) {
-      case 2:     break;
-      case 4:     flags += 1 << 4;        break;
-      case 8:     flags += 2 << 4;        break;
-      default:    flags += 3 << 4;
-   }
-   switch ((int)(sizeof(z_off_t))) {
-      case 2:     break;
-      case 4:     flags += 1 << 6;        break;
-      case 8:     flags += 2 << 6;        break;
-      default:    flags += 3 << 6;
-   }
-#ifdef DEBUG
-   flags += 1 << 8;
-#endif
-#if defined(ASMV) || defined(ASMINF)
-   flags += 1 << 9;
-#endif
-#ifdef ZLIB_WINAPI
-   flags += 1 << 10;
-#endif
-#ifdef BUILDFIXED
-   flags += 1 << 12;
-#endif
-#ifdef DYNAMIC_CRC_TABLE
-   flags += 1 << 13;
-#endif
-#ifdef NO_GZCOMPRESS
-   flags += 1L << 16;
-#endif
-#ifdef NO_GZIP
-   flags += 1L << 17;
-#endif
-#ifdef PKZIP_BUG_WORKAROUND
-   flags += 1L << 20;
-#endif
-#ifdef FASTEST
-   flags += 1L << 21;
-#endif
-#if defined(STDC) || defined(Z_HAVE_STDARG_H)
-#  ifdef NO_vsnprintf
-   flags += 1L << 25;
-#    ifdef HAS_vsprintf_void
-   flags += 1L << 26;
-#    endif
-#  else
-#    ifdef HAS_vsnprintf_void
-   flags += 1L << 26;
-#    endif
-#  endif
-#else
-   flags += 1L << 24;
-#  ifdef NO_snprintf
-   flags += 1L << 25;
-#    ifdef HAS_sprintf_void
-   flags += 1L << 26;
-#    endif
-#  else
-#    ifdef HAS_snprintf_void
-   flags += 1L << 26;
-#    endif
-#  endif
-#endif
-   return flags;
-}
-
-#ifdef DEBUG
-
-#  ifndef verbose
-#    define verbose 0
-#  endif
-int ZLIB_INTERNAL z_verbose = verbose;
-
-void ZLIB_INTERNAL z_error (char *m)
-{
-   fprintf(stderr, "%s\n", m);
-   exit(1);
-}
-#endif
-
-/* exported to allow conversion of error code to string for compress() and
- * uncompress()
- */
-const char * ZEXPORT zError(int err)
-{
-   return ERR_MSG(err);
-}
-
-#if defined(_WIN32_WCE)
-/* The Microsoft C Run-Time Library for Windows CE doesn't have
- * errno.  We define it as a global variable to simplify porting.
- * Its value is always 0 and should not be used.
- */
-int errno = 0;
-#endif
-
-#ifndef HAVE_MEMCPY
-
-void ZLIB_INTERNAL zmemcpy(Bytef *dest, const Bytef *source, uInt len)
-{
-   if (len == 0) return;
-   do {
-      *dest++ = *source++; /* ??? to be unrolled */
-   } while (--len != 0);
-}
-
-int ZLIB_INTERNAL zmemcmp(const Bytef *s1, const Bytef *s2, uInt len)
-{
-   uInt j;
-
-   for (j = 0; j < len; j++) {
-      if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
-   }
-   return 0;
-}
-
-void ZLIB_INTERNAL zmemzero(Bytef *dest, uInt len)
-{
-   if (len == 0) return;
-   do {
-      *dest++ = 0;  /* ??? to be unrolled */
-   } while (--len != 0);
-}
-#endif
-
-#ifndef Z_SOLO
-
-#ifdef SYS16BIT
-
-#ifdef __TURBOC__
-/* Turbo C in 16-bit mode */
-
-#  define MY_ZCALLOC
-
-/* Turbo C malloc() does not allow dynamic allocation of 64K bytes
- * and farmalloc(64K) returns a pointer with an offset of 8, so we
- * must fix the pointer. Warning: the pointer must be put back to its
- * original form in order to free it, use zcfree().
- */
-
-#define MAX_PTR 10
-/* 10*64K = 640K */
-
-local int next_ptr = 0;
-
-typedef struct ptr_table_s {
-   voidpf org_ptr;
-   voidpf new_ptr;
-} ptr_table;
-
-local ptr_table table[MAX_PTR];
-/* This table is used to remember the original form of pointers
- * to large buffers (64K). Such pointers are normalized with a zero offset.
- * Since MSDOS is not a preemptive multitasking OS, this table is not
- * protected from concurrent access. This hack doesn't work anyway on
- * a protected system like OS/2. Use Microsoft C instead.
- */
-
-voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
-{
-   voidpf buf = opaque; /* just to make some compilers happy */
-   ulg bsize = (ulg)items*size;
-
-   /* If we allocate less than 65520 bytes, we assume that farmalloc
-    * will return a usable pointer which doesn't have to be normalized.
-    */
-   if (bsize < 65520L) {
-      buf = farmalloc(bsize);
-      if (*(ush*)&buf != 0) return buf;
-   } else {
-      buf = farmalloc(bsize + 16L);
-   }
-   if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
-   table[next_ptr].org_ptr = buf;
-
-   /* Normalize the pointer to seg:0 */
-   *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
-   *(ush*)&buf = 0;
-   table[next_ptr++].new_ptr = buf;
-   return buf;
-}
-
-void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
-{
-   int n;
-   if (*(ush*)&ptr != 0) { /* object < 64K */
-      farfree(ptr);
-      return;
-   }
-   /* Find the original pointer */
-   for (n = 0; n < next_ptr; n++) {
-      if (ptr != table[n].new_ptr) continue;
-
-      farfree(table[n].org_ptr);
-      while (++n < next_ptr) {
-         table[n-1] = table[n];
-      }
-      next_ptr--;
-      return;
-   }
-   ptr = opaque; /* just to make some compilers happy */
-   Assert(0, "zcfree: ptr not found");
-}
-
-#endif /* __TURBOC__ */
-
-
-#ifdef M_I86
-/* Microsoft C in 16-bit mode */
-
-#  define MY_ZCALLOC
-
-#if (!defined(_MSC_VER) || (_MSC_VER <= 600))
-#  define _halloc  halloc
-#  define _hfree   hfree
-#endif
-
-voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size)
-{
-   if (opaque) opaque = 0; /* to make compiler happy */
-   return _halloc((long)items, size);
-}
-
-void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
-{
-   if (opaque) opaque = 0; /* to make compiler happy */
-   _hfree(ptr);
-}
-
-#endif /* M_I86 */
-
-#endif /* SYS16BIT */
-
-
-#ifndef MY_ZCALLOC /* Any system without a special alloc function */
-
-#ifndef STDC
-extern voidp  malloc OF((uInt size));
-extern voidp  calloc OF((uInt items, uInt size));
-extern void   free   OF((voidpf ptr));
-#endif
-
-voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
-{
-   if (opaque) items += size - size; /* make compiler happy */
-   return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
-      (voidpf)calloc(items, size);
-}
-
-void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
-{
-   free(ptr);
-   if (opaque) return; /* make compiler happy */
-}
-
-#endif /* MY_ZCALLOC */
-
-#endif /* !Z_SOLO */
diff --git a/deps/zlib/zutil.h b/deps/zlib/zutil.h
deleted file mode 100644 (file)
index 5c6929f..0000000
+++ /dev/null
@@ -1,253 +0,0 @@
-/* zutil.h -- internal interface and configuration of the compression library
- * Copyright (C) 1995-2013 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
-   part of the implementation of the compression library and is
-   subject to change. Applications should only use zlib.h.
- */
-
-/* @(#) $Id$ */
-
-#ifndef ZUTIL_H
-#define ZUTIL_H
-
-#ifdef HAVE_HIDDEN
-#  define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
-#else
-#  define ZLIB_INTERNAL
-#endif
-
-#include "zlib.h"
-
-#if defined(STDC) && !defined(Z_SOLO)
-#  if !(defined(_WIN32_WCE) && defined(_MSC_VER))
-#    include <stddef.h>
-#  endif
-#  include <string.h>
-#  include <stdlib.h>
-#endif
-
-#ifdef Z_SOLO
-   typedef long ptrdiff_t;  /* guess -- will be caught if guess is wrong */
-#endif
-
-#ifndef local
-#  define local static
-#endif
-/* compile with -Dlocal if your debugger can't find static symbols */
-
-typedef unsigned char  uch;
-typedef uch FAR uchf;
-typedef unsigned short ush;
-typedef ush FAR ushf;
-typedef unsigned long  ulg;
-
-extern char * const z_errmsg[10]; /* indexed by 2-zlib_error */
-/* (size given to avoid silly warnings with Visual C++) */
-
-#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
-
-#define ERR_RETURN(strm,err) \
-  return (strm->msg = ERR_MSG(err), (err))
-/* To be used only when the state is known to be valid */
-
-        /* common constants */
-
-#ifndef DEF_WBITS
-#  define DEF_WBITS MAX_WBITS
-#endif
-/* default windowBits for decompression. MAX_WBITS is for compression only */
-
-#if MAX_MEM_LEVEL >= 8
-#  define DEF_MEM_LEVEL 8
-#else
-#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL
-#endif
-/* default memLevel */
-
-#define STORED_BLOCK 0
-#define STATIC_TREES 1
-#define DYN_TREES    2
-/* The three kinds of block type */
-
-#define MIN_MATCH  3
-#define MAX_MATCH  258
-/* The minimum and maximum match lengths */
-
-#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
-
-        /* target dependencies */
-
-#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
-#  define OS_CODE  0x00
-#  ifndef Z_SOLO
-#    if defined(__TURBOC__) || defined(__BORLANDC__)
-#      if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
-         /* Allow compilation with ANSI keywords only enabled */
-         void _Cdecl farfree( void *block );
-         void *_Cdecl farmalloc( unsigned long nbytes );
-#      else
-#        include <alloc.h>
-#      endif
-#    else /* MSC or DJGPP */
-#      include <malloc.h>
-#    endif
-#  endif
-#endif
-
-#ifdef AMIGA
-#  define OS_CODE  0x01
-#endif
-
-#if defined(VAXC) || defined(VMS)
-#  define OS_CODE  0x02
-#  define F_OPEN(name, mode) \
-     fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
-#endif
-
-#if defined(ATARI) || defined(atarist)
-#  define OS_CODE  0x05
-#endif
-
-#ifdef OS2
-#  define OS_CODE  0x06
-#  if defined(M_I86) && !defined(Z_SOLO)
-#    include <malloc.h>
-#  endif
-#endif
-
-#if defined(MACOS) || defined(TARGET_OS_MAC)
-#  define OS_CODE  0x07
-#  ifndef Z_SOLO
-#    if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
-#      include <unix.h> /* for fdopen */
-#    else
-#      ifndef fdopen
-#        define fdopen(fd,mode) NULL /* No fdopen() */
-#      endif
-#    endif
-#  endif
-#endif
-
-#ifdef TOPS20
-#  define OS_CODE  0x0a
-#endif
-
-#ifdef WIN32
-#  ifndef __CYGWIN__  /* Cygwin is Unix, not Win32 */
-#    define OS_CODE  0x0b
-#  endif
-#endif
-
-#ifdef __50SERIES /* Prime/PRIMOS */
-#  define OS_CODE  0x0f
-#endif
-
-#if defined(_BEOS_) || defined(RISCOS)
-#  define fdopen(fd,mode) NULL /* No fdopen() */
-#endif
-
-#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
-#  if defined(_WIN32_WCE)
-#    define fdopen(fd,mode) NULL /* No fdopen() */
-#    ifndef _PTRDIFF_T_DEFINED
-       typedef int ptrdiff_t;
-#      define _PTRDIFF_T_DEFINED
-#    endif
-#  else
-#    define fdopen(fd,type)  _fdopen(fd,type)
-#  endif
-#endif
-
-#if defined(__BORLANDC__) && !defined(MSDOS)
-  #pragma warn -8004
-  #pragma warn -8008
-  #pragma warn -8066
-#endif
-
-/* provide prototypes for these when building zlib without LFS */
-#if !defined(_WIN32) && \
-    (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
-    ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
-    ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
-#endif
-
-        /* common defaults */
-
-#ifndef OS_CODE
-#  define OS_CODE  0x03  /* assume Unix */
-#endif
-
-#ifndef F_OPEN
-#  define F_OPEN(name, mode) fopen((name), (mode))
-#endif
-
-         /* functions */
-
-#if defined(pyr) || defined(Z_SOLO)
-#  define NO_MEMCPY
-#endif
-#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
- /* Use our own functions for small and medium model with MSC <= 5.0.
-  * You may have to use the same strategy for Borland C (untested).
-  * The __SC__ check is for Symantec.
-  */
-#  define NO_MEMCPY
-#endif
-#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
-#  define HAVE_MEMCPY
-#endif
-#ifdef HAVE_MEMCPY
-#  ifdef SMALL_MEDIUM /* MSDOS small or medium model */
-#    define zmemcpy _fmemcpy
-#    define zmemcmp _fmemcmp
-#    define zmemzero(dest, len) _fmemset(dest, 0, len)
-#  else
-#    define zmemcpy memcpy
-#    define zmemcmp memcmp
-#    define zmemzero(dest, len) memset(dest, 0, len)
-#  endif
-#else
-   void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
-   int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
-   void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));
-#endif
-
-/* Diagnostic functions */
-#ifdef DEBUG
-#  include <stdio.h>
-   extern int ZLIB_INTERNAL z_verbose;
-   extern void ZLIB_INTERNAL z_error OF((char *m));
-#  define Assert(cond,msg) {if(!(cond)) z_error(msg);}
-#  define Trace(x) {if (z_verbose>=0) fprintf x ;}
-#  define Tracev(x) {if (z_verbose>0) fprintf x ;}
-#  define Tracevv(x) {if (z_verbose>1) fprintf x ;}
-#  define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
-#  define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
-#else
-#  define Assert(cond,msg)
-#  define Trace(x)
-#  define Tracev(x)
-#  define Tracevv(x)
-#  define Tracec(c,x)
-#  define Tracecv(c,x)
-#endif
-
-#ifndef Z_SOLO
-   voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
-                                    unsigned size));
-   void ZLIB_INTERNAL zcfree  OF((voidpf opaque, voidpf ptr));
-#endif
-
-#define ZALLOC(strm, items, size) \
-           (*((strm)->zalloc))((strm)->opaque, (items), (size))
-#define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
-#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
-
-/* Reverse the bytes in a 32-bit value */
-#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
-                    (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
-
-#endif /* ZUTIL_H */