diff --git a/contrib/vmap_extractor_v2/doc/The MoPaQ File Format.txt b/contrib/vmap_extractor_v2/doc/The MoPaQ File Format.txt deleted file mode 100644 index ce8d8f70166..00000000000 --- a/contrib/vmap_extractor_v2/doc/The MoPaQ File Format.txt +++ /dev/null @@ -1,318 +0,0 @@ -THE MOPAQ ARCHIVE FORMAT -v0.9 (Thursday, June 30, 2005) -by Justin Olbrantz(Quantam) - -Distribution and reproduction of this specification are allowed without limitation, as long as it is not altered. Quoting -in other works is freely allowed, as long as the source and author of the quote is stated. - -TABLE OF CONTENTS -1. Introduction to the MoPaQ Format -2. The MoPaQ Format - 2.1 General Archive Layout - 2.2 Archive Header - 2.3 Block Table - 2.4 Hash Table - 2.5 File Data - 2.6 Listfile - 2.7 Extended Attributes - 2.8 Weak (Old) Digital Signature - 2.9 Strong (New) Digital Signature -3. Algorithm Source Code - 3.1 Encryption/Decryption - 3.2 Hashing - 3.3 Conversion of FILETIME and time_t - -1. INTRODUCTION TO THE MOPAQ FORMAT -The MoPaQ (or MPQ) format is an archive file format designed by Mike O'Brien (hence the name Mike O'brien PaCK) at Blizzard -Entertainment. The format has been used in all Blizzard games since (and including) Diablo. It is heavily optimized to be -a read-only game archive format, and excels at this role. - -The Blizzard MoPaQ-reading functions are contained in the Storm module, which my be either statically or dynamically linked. -The Blizzard MoPaQ-writing functions are contained in the MPQAPI module, which is always statically linked. - -2. THE MOPAQ FORMAT -All numbers in the MoPaQ format are in little endian. Data types are listed either as int (integer, the number of bits specified), -byte (8 bits), and char (bytes which contain ASCII characters). All sizes and offsets are in bytes, unless specified otherwise. -Structure members are listed in the following general form: -offset from the beginning of the structure: data type(array size) member name : member description - -2.1 GENERAL ARCHIVE LAYOUT -- Archive Header -- File Data -- File Data - Special Files -- Hash Table -- Block Table -- Strong Digital signature - -This is the usual archive format, and is not absolutely essential. Some archives have been observed placing the hash table -and file table after the archive header, and before the file data. - -2.2 ARCHIVE HEADER -00h: char(4) Magic : Indicates that the file is a MoPaQ archive. Must be ASCII "MPQ" 1Ah. -04h: int32 HeaderSize : Size of the archive header. Should be 32. -08h: int32 ArchiveSize : Size of the whole archive, including the header. Does not include the strong digital signature, if present. -This size is used, among other things, for determining the region to hash in computing the digital signature. -0Ch: int16 Unknown : Unknown -0Eh: int8 SectorSizeShift : Power of two exponent specifying the number of 512-byte disk sectors in each logical sector -in the archive. The size of each logical sector the archive is 512 * 2^SectorSizeShift. Bugs in the Storm library dictate -that this should always be 3 (4096 byte sectors). -10h: int32 HashTableOffset : Offset to the beginning of the hash table, relative to the beginning of the archive. -14h: int32 BlockTableOffset : Offset to the beginning of the block table, relative to the beginning of the archive. -18h: int32 HashTableEntries : Number of entries in the hash table. Must be a power of two, and must be less than 2^16. -1Ch: int32 BlockTableEntries : Number of entries in the block table. - -The archive header is the first structure in the archive, at archive offset 0, but the archive does not need to be at offset -0 of the containing file. The offset of the archive in the file is referred to here as ArchiveOffset. If the archive is not -at the beginning of the file, it must begin at a disk sector boundary (512 bytes). Early versions of Storm require that the -archive be at the end of the containing file (ArchiveOffset + ArchiveSize = file size), but this is not required in newer -versions (due to the strong digital signature not being considered a part of the archive). - -2.3 BLOCK TABLE -The block table contains entries for each region in the archive. Regions may be either files or empty space, which may be -overwritten by new files (typically this space is from deleted file data). The block table is encrypted, using the hash -of "(block table)" as the key. Each entry is structured as follows: - -00h: int32 BlockOffset : Offset of the beginning of the block, relative to the beginning of the archive. Meaningless if the block size is 0. -04h: int32 BlockSize : Size of the block in the archive. -08h: int32 FileSize : Size of the file data stored in the block. Only valid if the block is a file, otherwise meaningless, and should be 0. If the file is compressed, this is the size of the uncompressed file data. -0Ch: int32 Flags : Bit mask of the flags for the block. The following values are conclusively identified: - 80000000h: Block is a file, and follows the file data format; otherwise, block is free space, and may be overwritten. If the block is not a file, all other flags should be cleared. - 01000000h: File is stored as a single unit, rather than split into sectors. - 00020000h: The file's encryption key is adjusted by the block offset and file size (explained in detail in the File Data section). File must be encrypted. - 00010000h: File is encrypted. - 00000200h: File is compressed. Mutually exclusive to file imploded. - 00000100h: File is imploded. Mutually exclusive to file compressed. - -2.4 HASH TABLE -Instead of storing file names, for quick access MoPaQs use a fixed, power of two-size hash table of files in the archive. A file is uniquely identified by its file path, its language, and its platform. The home entry for a file in the hash table is computed as a hash of the file path. In the event of a collision (the home entry is occupied by another file), progressive overflow is used, and the file is placed in the next available hash table entry. Searches for a desired file in the hash table proceed from the home entry for the file until either the file is found, the entire hash table is searched, or an empty hash table entry (FileBlockIndex of FFFFFFFFh) is encountered. The hash table is encrypted using the hash of "(hash table)" as the key. Each entry is structured as follows: - -00h: int32 FilePathHashA : The hash of the file path, using method A. -04h: int32 FilePathHashB : The hash of the file path, using method B. -08h: int16 Language : The language of the file. This is a Windows LANGID data type, and uses the same values. 0 indicates the default language (American English), or that the file is language-neutral. -0Ah: int8 Platform : The platform the file is used for. 0 indicates the default platform. No other values have been observed. -0Ch: int32 FileBlockIndex : If the hash table entry is valid, this is the index into the block table of the file. Otherwise, one of the following two values: - FFFFFFFFh: Hash table entry is empty, and has always been empty. Terminates searches for a given file. - FFFFFFFEh: Hash table entry is empty, but was valid at some point (in other words, the file was deleted). Does not terminate searches for a given file. - -2.5 FILE DATA -00h: int32(SectorsInFile + 1) SectorOffsetTable : Offsets to the start of each sector's data, relative to the beginning of the file data. Not present if this information is calculatable (see details below). -immediately following SectorOffsetTable: SectorData : Data of each sector in the file, packed end to end (see details below). - -Normally, file data is split up into sectors, for simple streaming. All sectors, save for the last, will contain as many bytes of file data as specified in the archive header's SectorSizeShift; the last sector may be smaller than this, depending on the size of the file data. This sector size is the size of the raw file data; if the file is compressed, the compressed sector will be smaller or the same size as the uncompressed sector size. Individual sectors in a compressed file may be stored uncompressed; this occurs if and only if the sector could not be compressed by the algorithm used (if the compressed sector size was greater than or equal to the size of the raw data), and is indicated by the sector's compressed size in SectorOffsetTable being equal to the uncompressed size of the sector (which may be calculated from the FileSize). - -If the sector is compressed (but not imploded), a bit mask byte of the compression algorithm(s) used to compress the sector is appended to the beginning of the compressed sector data. This additional byte counts towards the total size of the sector; if the size of the sector (including this byte) exceeds or matches the uncompressed size of the sector data, the sector will be stored uncompressed, and this byte omitted. Multiple compression algorithms may be used on the same sector; in this case, successive compression occurs in the order the algorithms are listed below, and decompression occurs in the opposite order. For implimentations of all of these algorithms, see StormLib. - 40h: IMA ADPCM mono - 80h: IMA ADPCM stereo - 01h: Huffman encoded - 02h: Deflated (see ZLib) - 08h: Imploded (see PKWare Data Compression Library) - 10h: BZip2 compressed (see BZip2) - -If the file is stored as a single unit (indicated in the file's Flags), there is effectively only a single sector, which -contains the entire file. - -If the file is encrypted, each sector (after compression and appendage of the compression type byte, if applicable) -is encrypted with the file's key. The base key for a file is determined by a hash of the file name stripped of the -directory (i.e. the key for a file named "directory\file" would be computed as the hash of "file"). If this key is -adjusted, as indicated in the file's Flags, the final key is calculated as ((base key + BlockOffset - ArchiveOffset) -XOR FileSize) (StormLib - an open-source implementation of the MoPaQ reading and writing functions, -by Ladislav Zezula - incorrectly uses an AND in place of the XOR). Each sector is encrypted using the key + the -0-based index of the sector in the file. The SectorOffsetTable, if present, is encrypted using the key - 1. - -The SectorOffsetTable is omitted when the sizes and offsets of all sectors in the file are calculatable from the FileSize. -This can happen in several circumstances. If the file is not compressed/imploded, then the size and offset of all sectors -is known, based on the archive's SectorSizeShift. If the file is stored as a single unit compressed/imploded, then the -SectorOffsetTable is omitted, as the single file "sector" corresponds to BlockSize and FileSize, as mentioned previously. -Note that the SectorOffsetTable will always be present if the file is compressed/imploded and the file is not stored as -a single unit, even if there is only a single sector in the file (the size of the file is less than or equal to the -archive's sector size). - -2.6 LISTFILE -The listfile is a very simple extension to the MoPaQ format that contains the file paths of (most) files in the archive. -The languages and platforms of the files are not stored in the listfile. The listfile is contained in the file "(listfile)", -and is simply a non-Unix-style text file with one file path on each line, lines terminated with the bytes 0Dh 0Ah. The file -"(listfile)" may not be listed in the listfile. - -2.7 EXTENDED ATTRIBUTES -The extended attributes are optional file attributes for files in the block table. These attributes were added at times after -the MoPaQ format was already finalized, and it is not necessary for every archive to have all (or any) of the extended attributes. -If an archive contains a given attribute, there will be an instance of that attribute for every block in the block table, although -the attribute will be meaningless if the block is not a file. The order of the attributes for blocks correspond to the order of the -blocks in the block table, and are of the same number. The attributes are stored in parallel arrays in the "(attributes)" file, -in the archive. The attributes corresponding to this file need not be valid (and logically cannot be). Unlike all the other -structures in the MoPaQ format, entries in the extended attributes are NOT guaranteed to be aligned. Also note that in some -archives, malicious zeroing of the attributes has been observed, perhaps with the intent of breaking archive viewers. This -file is structured as follows: - -00h: int32 Version : Specifies the extended attributes format version. For now, must be 100. -04h: int32 AttributesPresent : Bit mask of the extended attributes present in the archive: - 00000001h: File CRC32s. - 00000002h: File timestamps. - 00000004h: File MD5s. -08h: int32(BlockTableEntries) CRC32s : CRC32s of the (uncompressed) file data for each block in the archive. Omitted if the -archive does not have CRC32s. immediately after CRC32s: FILETIME(BlockTableEntries) Timestamps : Timestamps for each block -in the archive. The format is that of the Windows FILETIME structure. Omitted if the archive does not have timestamps. -immediately after Timestamps: MD5(BlockTableEntries) MD5s : MD5s of the (uncompressed) file data for each block in the archive. -Omitted if the archive does not have MD5s. - -2.8 WEAK DIGITAL SIGNATURE -The weak digital signature is a digital signature using Microsoft CryptoAPI. It is an implimentation of the RSASSA-PKCS1-v1_5 -digital signature protocol, using the MD5 hashing algorithm and a 512-bit (weak) RSA key (for more information about this -protocol, see the RSA Labs PKCS1 specification). The public key and exponent are stored in a resource in Storm. The signature -is stored uncompressed, unencrypted in the file "(signature)" in the archive. The archive is hashed from the beginning of the -archive (ArchiveOffset in the containing file) to the end of the archive (the length indicated by ArchiveSize); the signature -file is added to the archive before signing, and the space occupied by the file is considered to be all binary 0s during -signing/verification. This file is structured as follows: - -00h: int32 Unknown : Must be 0. -04h: int32 Unknown : must be 0. -08h: int512 Signature : The digital signature. Like all other numbers in the MoPaQ format, this is stored in little-endian order. - -2.9 STRONG DIGITAL SIGNATURE -The strong digital signature uses a simple proprietary implementation of RSA signing, using the SHA-1 hashing algorithm and -a 2048-bit (strong) RSA key. The default public key and exponent are stored in Storm, but other keys may be used as well. -The strong digital signature is stored immediately after the archive, in the containing file; the entire archive (ArchiveSize -bytes, starting at ArchiveOffset in the containing file) is hashed as a single block. The signature has the following format: - -00h: char(4) Magic : Indicates the presence of a digital signature. Must be "NGIS" ("SIGN" backwards). -04h: int2048 Signature : The digital signature, stored in little-endian format. - -When the Signature field is decrypted with the public key and exponent, and the result stored in little-endian order, it is structured as follows: - -00h: byte Padding : Must be 0Bh. -01h: byte(235) Padding : Must be BBh. -ECh: byte(20) SHA-1 : SHA-1 hash of the archive, in standard SHA-1 format. - -3. ALGORITHM SOURCE CODE -3.1 ENCRYPTION/DECRYPTION -I believe this was derived at some point from code in StormLib. Assumes the long type to be 32 bits, and the machine to be little endian order. - -unsigned long dwCryptTable[0x500]; - -void InitializeCryptTable() -{ - unsigned long seed = 0x00100001; - unsigned long index1 = 0; - unsigned long index2 = 0; - int i; - - for (index1 = 0; index1 < 0x100; index1++) - { - for (index2 = index1, i = 0; i < 5; i++, index2 += 0x100) - { - unsigned long temp1, temp2; - - seed = (seed * 125 + 3) % 0x2AAAAB; - temp1 = (seed & 0xFFFF) << 0x10; - - seed = (seed * 125 + 3) % 0x2AAAAB; - temp2 = (seed & 0xFFFF); - - dwCryptTable[index2] = (temp1 | temp2); - } - } -} - -void EncryptData(void *lpbyBuffer, unsigned long dwLength, unsigned long dwKey) -{ - unsigned long *lpdwBuffer = (unsigned long *)lpbyBuffer; - unsigned long seed = 0xEEEEEEEE; - unsigned long ch; - - assert(lpbyBuffer); - - dwLength /= sizeof(unsigned long); - - while(dwLength-- > 0) - { - seed += dwCryptTable[0x400 + (dwKey & 0xFF)]; - ch = *lpdwBuffer ^ (dwKey + seed); - - dwKey = ((~dwKey << 0x15) + 0x11111111) | (dwKey >> 0x0B); - seed = *lpdwBuffer + seed + (seed << 5) + 3; - - *lpdwBuffer++ = ch; - } -} - -void DecryptData(void *lpbyBuffer, unsigned long dwLength, unsigned long dwKey) -{ - unsigned long *lpdwBuffer = (unsigned long *)lpbyBuffer; - unsigned long seed = 0xEEEEEEEE; - unsigned long ch; - - assert(lpbyBuffer); - - dwLength /= sizeof(unsigned long); - - while(dwLength-- > 0) - { - seed += dwCryptTable[0x400 + (dwKey & 0xFF)]; - ch = *lpdwBuffer ^ (dwKey + seed); - - dwKey = ((~dwKey << 0x15) + 0x11111111) | (dwKey >> 0x0B); - seed = ch + seed + (seed << 5) + 3; - - *lpdwBuffer++ = ch; - } -} - -3.2 HASHING -Based on code from StormLib. - -// Different types of hashes to make with HashString -#define MPQ_HASH_TABLE_OFFSET 0 -#define MPQ_HASH_NAME_A 1 -#define MPQ_HASH_NAME_B 2 -#define MPQ_HASH_FILE_KEY 3 - -unsigned long HashString(const char *lpszString, unsigned long dwHashType) -{ - unsigned long seed1 = 0x7FED7FED; - unsigned long seed2 = 0xEEEEEEEE; - int ch; - - while (*lpszString != 0) - { - ch = toupper(*lpszString++); - - seed1 = dwCryptTable[(dwHashType * 0xFF) + ch] ^ (seed1 + seed2); - seed2 = ch + seed1 + seed2 + (seed2 << 5) + 3; - } - return seed1; -} - -3.3 CONVERSION OF FILETIME AND time_t - -#define EPOCH_OFFSET 116444736000000000ULL // Number of 100 ns units between 01/01/1601 and 01/01/1970 - -bool GetTimeFromFileTime(FILETIME &fileTime, time_t &time) -{ - // The FILETIME represents a 64-bit integer: the number of 100 ns units since January 1, 1601 - unsigned long long nTime = ((unsigned long long)fileTime.dwHighDateTime << 32) + fileTime.dwLowDateTime; - - if (nTime < EPOCH_OFFSET) - return false; - - nTime -= EPOCH_OFFSET; // Convert the time base from 01/01/1601 to 01/01/1970 - nTime /= 10000000ULL; // Convert 100 ns to sec - - time = (time_t)nTime; - - // Test for overflow (FILETIME is 64 bits, time_t is 32 bits) - if ((nTime - (unsigned long long)time) > 0) - return false; - - return true; -} - -void GetFileTimeFromTime(time_t &time, FILETIME &fileTime) -{ - unsigned long long nTime = (unsigned long long)time; - - nTime *= 10000000ULL; - nTime += EPOCH_OFFSET; - - fileTime.dwLowDateTime = (DWORD)nTime; - fileTime.dwHighDateTime = (DWORD)(nTime >> 32); -} diff --git a/contrib/vmap_extractor_v2/doc/The_MoPaQ_File_Format.txt b/contrib/vmap_extractor_v2/doc/The_MoPaQ_File_Format.txt deleted file mode 100644 index 6a21eca5472..00000000000 --- a/contrib/vmap_extractor_v2/doc/The_MoPaQ_File_Format.txt +++ /dev/null @@ -1,421 +0,0 @@ -THE MOPAQ ARCHIVE FORMAT -v1.0 (Friday, September 1, 2006) -by Justin Olbrantz(Quantam) - -Distribution and reproduction of this specification are allowed without limitation, as long as it is not altered. Quotation in other works is freely allowed, as long as the source and author of the quote are stated. - -TABLE OF CONTENTS -1. Introduction to the MoPaQ Format -2. The MoPaQ Format - 2.1 General Archive Layout - 2.2 Archive Header - 2.3 Block Table - 2.4 Extended Block Table - 2.5 Hash Table - 2.6 File Data - 2.7 Listfile - 2.8 Extended Attributes - 2.9 Weak (Old) Digital Signature - 2.10 Strong (New) Digital Signature -3. Algorithm Source Code - 3.1 Encryption/Decryption - 3.2 Hashing and File Key Computation - 3.3 Finding Files - 3.4 Deleting Files - 3.5 Conversion of FILETIME and time_t - 3.6 Forming a 64-bit Large Archive Offset from 32-bit and 16-bit Components -4. Revision History - -1. INTRODUCTION TO THE MOPAQ FORMAT -The MoPaQ (or MPQ) format is an archive file format designed by Mike O'Brien (hence the name Mike O'brien PaCK) at Blizzard Entertainment. The format has been used in all Blizzard games since (and including) Diablo. It is heavily optimized to be a read-only game archive format, and excels at this role. - -The Blizzard MoPaQ-reading functions are contained in the Storm module, which my be either statically or dynamically linked. The Blizzard MoPaQ-writing functions are contained in the MPQAPI module, which is always statically linked. - -StormLib - mentioned several times in this specification - is an open-source MoPaQ reading and writing library written by Ladislav Zezula (no affiliation with Blizzard Entertainment). While it's a bit dated, and does not support all of the newer MoPaQ features, it contains source code to the more exotic compression methods used by MoPaQ, such as the PKWare implode algorithm, MoPaQ's huffman compression algorithm, and the IMA ADPCM compression used by MoPaQ. - -2. THE MOPAQ FORMAT -All numbers in the MoPaQ format are in little endian byte order; signed numbers use the two's complement system. Data types are listed either as int (integer, the number of bits specified), byte (8 bits), or char (bytes which contain ASCII characters). All sizes and offsets are in bytes, unless specified otherwise. Structure members are listed in the following general form: -offset from the beginning of the structure: data type(array size) member name : member description - -2.1 GENERAL ARCHIVE LAYOUT -- Archive Header -- File Data -- File Data - Special Files -- Hash Table -- Block Table -- Extended Block Table -- Strong Digital signature - -This is the usual archive format, but it is not mandatory. Some archives have been observed placing the hash table and file table after the archive header, and before the file data. - -2.2 ARCHIVE HEADER -00h: char(4) Magic : Indicates that the file is a MoPaQ archive. Must be ASCII "MPQ" 1Ah. -04h: int32 HeaderSize : Size of the archive header. -08h: int32 ArchiveSize : Size of the whole archive, including the header. Does not include the strong digital signature, if present. This size is used, among other things, for determining the region to hash in computing the digital signature. This field is deprecated in the Burning Crusade MoPaQ format, and the size of the archive is calculated as the size from the beginning of the archive to the end of the hash table, block table, or extended block table (whichever is largest). -0Ch: int16 FormatVersion : MoPaQ format version. MPQAPI will not open archives where this is negative. Known versions: - 0000h: Original format. HeaderSize should be 20h, and large archives are not supported. - 0001h: Burning Crusade format. Header size should be 2Ch, and large archives are supported. -0Eh: int8 SectorSizeShift : Power of two exponent specifying the number of 512-byte disk sectors in each logical sector in the archive. The size of each logical sector in the archive is 512 * 2^SectorSizeShift. Bugs in the Storm library dictate that this should always be 3 (4096 byte sectors). -10h: int32 HashTableOffset : Offset to the beginning of the hash table, relative to the beginning of the archive. -14h: int32 BlockTableOffset : Offset to the beginning of the block table, relative to the beginning of the archive. -18h: int32 HashTableEntries : Number of entries in the hash table. Must be a power of two, and must be less than 2^16 for the original MoPaQ format, or less than 2^20 for the Burning Crusade format. -1Ch: int32 BlockTableEntries : Number of entries in the block table. -Fields only present in the Burning Crusade format and later: -20h: int64 ExtendedBlockTableOffset : Offset to the beginning of the extended block table, relative to the beginning of the archive. -28h: int16 HashTableOffsetHigh : High 16 bits of the hash table offset for large archives. -2Ah: int16 BlockTableOffsetHigh : High 16 bits of the block table offset for large archives. - -The archive header is the first structure in the archive, at archive offset 0; however, the archive does not need to be at offset 0 of the containing file. The offset of the archive in the file is referred to here as ArchiveOffset. If the archive is not at the beginning of the file, it must begin at a disk sector boundary (512 bytes). Early versions of Storm require that the archive be at the end of the containing file (ArchiveOffset + ArchiveSize = file size), but this is not required in newer versions (due to the strong digital signature not being considered a part of the archive). - -2.3 BLOCK TABLE -The block table contains entries for each region in the archive. Regions may be either files, empty space, which may be overwritten by new files (typically this space is from deleted file data), or unused block table entries. Empty space entries should have BlockOffset and BlockSize nonzero, and FileSize and Flags zero; unused block table entries should have BlockSize, FileSize, and Flags zero. The block table is encrypted, using the hash of "(block table)" as the key. Each entry is structured as follows: - -00h: int32 BlockOffset : Offset of the beginning of the block, relative to the beginning of the archive. -04h: int32 BlockSize : Size of the block in the archive. -08h: int32 FileSize : Size of the file data stored in the block. Only valid if the block is a file; otherwise meaningless, and should be 0. If the file is compressed, this is the size of the uncompressed file data. -0Ch: int32 Flags : Bit mask of the flags for the block. The following values are conclusively identified: - 80000000h: Block is a file, and follows the file data format; otherwise, block is free space or unused. If the block is not a file, all other flags should be cleared, and FileSize should be 0. - 01000000h: File is stored as a single unit, rather than split into sectors. - 00020000h: The file's encryption key is adjusted by the block offset and file size (explained in detail in the File Data section). File must be encrypted. - 00010000h: File is encrypted. - 00000200h: File is compressed. File cannot be imploded. - 00000100h: File is imploded. File cannot be compressed. - -2.4 EXTENDED BLOCK TABLE -The extended block table was added to support archives larger than 4 gigabytes (2^32 bytes). The table contains the upper bits of the archive offsets for each block in the block table. It is simply an array of int16s, which become bits 32-47 of the archive offsets for each block, with bits 48-63 being zero. Individual blocks in the archive are still limited to 4 gigabytes in size. This table is only present in Burning Crusade format archives that exceed 4 gigabytes size. - -As of the Burning Crusade Friends and Family beta, this table is not encrypted. - -2.5 HASH TABLE -Instead of storing file names, for quick access MoPaQs use a fixed, power of two-size hash table of files in the archive. A file is uniquely identified by its file path, its language, and its platform. The home entry for a file in the hash table is computed as a hash of the file path. In the event of a collision (the home entry is occupied by another file), progressive overflow is used, and the file is placed in the next available hash table entry. Searches for a desired file in the hash table proceed from the home entry for the file until either the file is found, the entire hash table is searched, or an empty hash table entry (FileBlockIndex of FFFFFFFFh) is encountered. The hash table is encrypted using the hash of "(hash table)" as the key. Each entry is structured as follows: - -00h: int32 FilePathHashA : The hash of the file path, using method A. -04h: int32 FilePathHashB : The hash of the file path, using method B. -08h: int16 Language : The language of the file. This is a Windows LANGID data type, and uses the same values. 0 indicates the default language (American English), or that the file is language-neutral. -0Ah: int8 Platform : The platform the file is used for. 0 indicates the default platform. No other values have been observed. -0Ch: int32 FileBlockIndex : If the hash table entry is valid, this is the index into the block table of the file. Otherwise, one of the following two values: - FFFFFFFFh: Hash table entry is empty, and has always been empty. Terminates searches for a given file. - FFFFFFFEh: Hash table entry is empty, but was valid at some point (in other words, the file was deleted). Does not terminate searches for a given file. - -2.6 FILE DATA -The data for each file is composed of the following structure: -00h: int32(SectorsInFile + 1) SectorOffsetTable : Offsets to the start of each sector, relative to the beginning of the file data. The last entry contains the file size, making it possible to easily calculate the size of any given sector. This table is not present if this information can be calculated (see details below). -immediately following SectorOffsetTable: SECTOR Sectors(SectorsInFile) : Data of each sector in the file, packed end to end (see details below). - -Normally, file data is split up into sectors, for simple streaming. All sectors, save for the last, will contain as many bytes of file data as specified in the archive header's SectorSizeShift; the last sector may contain less than this, depending on the size of the entire file's data. If the file is compressed or imploded, the sector will be smaller or the same size as the file data it contains. Individual sectors in a compressed or imploded file may be stored uncompressed; this occurs if and only if the file data the sector contains could not be compressed by the algorithm(s) used (if the compressed sector size was greater than or equal to the size of the file data), and is indicated by the sector's size in SectorOffsetTable being equal to the size of the file data in the sector (which may be calculated from the FileSize). - -The format of each sector depends on the kind of sector it is. Uncompressed sectors are simply the the raw file data contained in the sector. Imploded sectors are the raw compressed data following compression with the implode algorithm (these sectors can only be in imploded files). Compressed sectors (only found in compressed - not imploded - files) are compressed with one or more compression algorithms, and have the following structure: -00h: byte CompressionMask : Mask of the compression types applied to this sector. If multiple compression types are used, they are applied in the order listed below, and decompression is performed in the opposite order. This byte counts towards the total sector size, meaning that the sector will be stored uncompressed if the data cannot be compressed by at least two bytes; as well, this byte is encrypted with the sector data, if applicable. The following compression types are defined (for implementations of these algorithms, see StormLib): - 40h: IMA ADPCM mono - 80h: IMA ADPCM stereo - 01h: Huffman encoded - 02h: Deflated (see ZLib) - 08h: Imploded (see PKWare Data Compression Library) - 10h: BZip2 compressed (see BZip2) -01h: byte(SectorSize - 1) SectorData : The compressed data for the sector. - -If the file is stored as a single unit (indicated in the file's Flags), there is effectively only a single sector, which contains the entire file data. - -If the file is encrypted, each sector (after compression/implosion, if applicable) is encrypted with the file's key. The base key for a file is determined by a hash of the file name stripped of the directory (i.e. the key for a file named "directory\file" would be computed as the hash of "file"). If this key is adjusted, as indicated in the file's Flags, the final key is calculated as ((base key + BlockOffset - ArchiveOffset) XOR FileSize) (StormLib incorrectly uses an AND in place of the XOR). Each sector is encrypted using the key + the 0-based index of the sector in the file. The SectorOffsetTable, if present, is encrypted using the key - 1. - -The SectorOffsetTable is omitted when the sizes and offsets of all sectors in the file are calculatable from the FileSize. This can happen in several circumstances. If the file is not compressed/imploded, then the size and offset of all sectors is known, based on the archive's SectorSizeShift. If the file is stored as a single unit compressed/imploded, then the SectorOffsetTable is omitted, as the single file "sector" corresponds to BlockSize and FileSize, as mentioned previously. However, the SectorOffsetTable will be present if the file is compressed/imploded and the file is not stored as a single unit, even if there is only a single sector in the file (the size of the file is less than or equal to the archive's sector size). - -2.7 LISTFILE -The listfile is a very simple extension to the MoPaQ format that contains the file paths of (most) files in the archive. The languages and platforms of the files are not stored in the listfile. The listfile is contained in the file "(listfile)" (default language and platform), and is simply a text file with file paths separated by ';', 0Dh, 0Ah, or some combination of these. The file "(listfile)" may not be listed in the listfile. - -2.8 EXTENDED ATTRIBUTES -The extended attributes are optional file attributes for files in the block table. These attributes were added at times after the MoPaQ format was already finalized, and it is not necessary for every archive to have all (or any) of the extended attributes. If an archive contains a given attribute, there will be an instance of that attribute for every block in the block table, although the attribute will be meaningless if the block is not a file. The order of the attributes for blocks correspond to the order of the blocks in the block table, and are of the same number. The attributes are stored in parallel arrays in the "(attributes)" file (default language and platform), in the archive. The attributes corresponding to this file need not be valid (and logically cannot be). Unlike all the other structures in the MoPaQ format, entries in the extended attributes are NOT guaranteed to be aligned. Also note that in some archives, malicious zeroing of the attributes has been observed, perhaps with the intent of breaking archive viewers. This file is structured as follows: - -00h: int32 Version : Specifies the extended attributes format version. For now, must be 100. -04h: int32 AttributesPresent : Bit mask of the extended attributes present in the archive: - 00000001h: File CRC32s. - 00000002h: File timestamps. - 00000004h: File MD5s. -08h: int32(BlockTableEntries) CRC32s : CRC32s of the (uncompressed) file data for each block in the archive. Omitted if the archive does not have CRC32s. -immediately after CRC32s: FILETIME(BlockTableEntries) Timestamps : Timestamps for each block in the archive. The format is that of the Windows FILETIME structure. Omitted if the archive does not have timestamps. -immediately after Timestamps: MD5(BlockTableEntries) MD5s : MD5s of the (uncompressed) file data for each block in the archive. Omitted if the archive does not have MD5s. - -2.9 WEAK DIGITAL SIGNATURE -The weak digital signature is a digital signature using Microsoft CryptoAPI. It is an implimentation of the RSASSA-PKCS1-v1_5 digital signature protocol, using the MD5 hashing algorithm and a 512-bit (weak) RSA key (for more information about this protocol, see the RSA Labs PKCS1 specification). The public key and exponent are stored in a resource in Storm, the private key is stored in a separate file, whose filename is passed to MPQAPI (the private key is not stored in MPQAPI). The signature is stored uncompressed, unencrypted in the file "(signature)" (default language and platform) in the archive. The archive is hashed from the beginning of the archive (ArchiveOffset in the containing file) to the end of the archive (the length indicated by ArchiveSize, or calculated in the Burning Crusade MoPaQ format); the signature file is added to the archive before signing, and the space occupied by the file is considered to be all binary 0s during signing/verification. This file is structured as follows: - -00h: int32 Unknown : Must be 0. -04h: int32 Unknown : Must be 0. -08h: int512 Signature : The digital signature. Like all other numbers in the MoPaQ format, this is stored in little-endian order. The structure of this, when decrypted, follows the RSASSA-PKCS1-v1_5 specification; this format is rather icky to work with (I wrote a program to verify this signature using nothing but an MD5 function and huge integer functions; it wasn't pleasant), and best left to an encryption library such as Cryto++. - -2.10 STRONG DIGITAL SIGNATURE -The strong digital signature uses a simple proprietary implementation of RSA signing, using the SHA-1 hashing algorithm and a 2048-bit (strong) RSA key. The default public key and exponent are stored in Storm, but other keys may be used as well. The strong digital signature is stored immediately after the archive, in the containing file; the entire archive (ArchiveSize bytes, starting at ArchiveOffset in the containing file) is hashed as a single block. The signature has the following format: - -00h: char(4) Magic : Indicates the presence of a digital signature. Must be "NGIS" ("SIGN" backwards). -04h: int2048 Signature : The digital signature, stored in little-endian format. - -When the Signature field is decrypted with the public key and exponent, and the resulting large integer is stored in little-endian order, it is structured as follows: - -00h: byte Padding : Must be 0Bh. -01h: byte(235) Padding : Must be BBh. -ECh: byte(20) SHA-1 : SHA-1 hash of the archive, in standard SHA-1 byte order. - -3. ALGORITHM SOURCE CODE -All of the sample code here assumes little endian machine byte order, that the short type is 16 bits, that the long type is 32 bits, and that the long long type is 64 bits. Adjustments must be made if these assumptions are not correct on a given platform. All code not credited otherwise was written by myself in the writing of this specification. - -3.1 ENCRYPTION/DECRYPTION -Based on code from StormLib. - -unsigned long dwCryptTable[0x500]; - -// The encryption and hashing functions use a number table in their procedures. This table must be initialized before the functions are called the first time. -void InitializeCryptTable() -{ - unsigned long seed = 0x00100001; - unsigned long index1 = 0; - unsigned long index2 = 0; - int i; - - for (index1 = 0; index1 < 0x100; index1++) - { - for (index2 = index1, i = 0; i < 5; i++, index2 += 0x100) - { - unsigned long temp1, temp2; - - seed = (seed * 125 + 3) % 0x2AAAAB; - temp1 = (seed & 0xFFFF) << 0x10; - - seed = (seed * 125 + 3) % 0x2AAAAB; - temp2 = (seed & 0xFFFF); - - dwCryptTable[index2] = (temp1 | temp2); - } - } -} - -void EncryptData(void *lpbyBuffer, unsigned long dwLength, unsigned long dwKey) -{ - assert(lpbyBuffer); - - unsigned long *lpdwBuffer = (unsigned long *)lpbyBuffer; - unsigned long seed = 0xEEEEEEEE; - unsigned long ch; - - dwLength /= sizeof(unsigned long); - - while(dwLength-- > 0) - { - seed += dwCryptTable[0x400 + (dwKey & 0xFF)]; - ch = *lpdwBuffer ^ (dwKey + seed); - - dwKey = ((~dwKey << 0x15) + 0x11111111) | (dwKey >> 0x0B); - seed = *lpdwBuffer + seed + (seed << 5) + 3; - - *lpdwBuffer++ = ch; - } -} - -void DecryptData(void *lpbyBuffer, unsigned long dwLength, unsigned long dwKey) -{ - assert(lpbyBuffer); - - unsigned long *lpdwBuffer = (unsigned long *)lpbyBuffer; - unsigned long seed = 0xEEEEEEEEL; - unsigned long ch; - - dwLength /= sizeof(unsigned long); - - while(dwLength-- > 0) - { - seed += dwCryptTable[0x400 + (dwKey & 0xFF)]; - ch = *lpdwBuffer ^ (dwKey + seed); - - dwKey = ((~dwKey << 0x15) + 0x11111111L) | (dwKey >> 0x0B); - seed = ch + seed + (seed << 5) + 3; - - *lpdwBuffer++ = ch; - } -} - -3.2 HASHING AND FILE KEY COMPUTATION -These functions may have been derived from StormLib code at some point in the very distant past. It was so long ago that I don't remember for certain. - -// Different types of hashes to make with HashString -#define MPQ_HASH_TABLE_OFFSET 0 -#define MPQ_HASH_NAME_A 1 -#define MPQ_HASH_NAME_B 2 -#define MPQ_HASH_FILE_KEY 3 - -// Based on code from StormLib. -unsigned long HashString(const char *lpszString, unsigned long dwHashType) -{ - assert(lpszString); - assert(dwHashType <= MPQ_HASH_FILE_KEY); - - unsigned long seed1 = 0x7FED7FEDL; - unsigned long seed2 = 0xEEEEEEEEL; - int ch; - - while (*lpszString != 0) - { - ch = toupper(*lpszString++); - - seed1 = dwCryptTable[(dwHashType * 0x100) + ch] ^ (seed1 + seed2); - seed2 = ch + seed1 + seed2 + (seed2 << 5) + 3; - } - return seed1; -} - -#define BLOCK_OFFSET_ADJUSTED_KEY 0x00020000L - -unsigned long ComputeFileKey(const char *lpszFilePath, const BlockTableEntry &blockEntry, unsigned long nArchiveOffset) -{ - assert(lpszFilePath); - - // Find the file name part of the path - const char *lpszFileName = strrchr(lpszFilePath, '\\'); - if (lpszFileName) - lpszFileName++; // Skip the \ - else - lpszFileName = lpszFilePath; - - // Hash the name to get the base key - unsigned long nFileKey = HashString(lpszFileName, MPQ_HASH_FILE_KEY); - - // Offset-adjust the key if necessary - if (blockEntry.Flags & BLOCK_OFFSET_ADJUSTED_KEY) - nFileKey = (nFileKey + blockEntry.BlockOffset) ^ blockEntry.FileSize; - - return nFileKey; -} - -3.3 FINDING FILES - -#define MPQ_HASH_ENTRY_EMPTY 0xFFFFFFFFL -#define MPQ_HASH_ENTRY_DELETED 0xFFFFFFFEL - -bool FindFileInHashTable(const HashTableEntry *lpHashTable, unsigned long nHashTableSize, const char *lpszFilePath, unsigned short nLang, unsigned char nPlatform, unsigned long &iFileHashEntry) -{ - assert(lpHashTable); - assert(nHashTableSize); - assert(lpszFilePath); - - // Find the home entry in the hash table for the file - unsigned long iInitEntry = HashString(lpszFilePath, MPQ_HASH_TABLE_OFFSET) & (nHashTableSize - 1); - - // Is there anything there at all? - if (lpHashTable[iInitEntry].FileBlockIndex == MPQ_HASH_ENTRY_EMPTY) - return false; - - // Compute the hashes to compare the hash table entry against - unsigned long nNameHashA = HashString(lpszFilePath, MPQ_HASH_NAME_A), - nNameHashB = HashString(lpszFilePath, MPQ_HASH_NAME_B), - iCurEntry = iInitEntry; - - // Check each entry in the hash table till a termination point is reached - do - { - if (lpHashTable[iCurEntry].FileBlockIndex != MPQ_HASH_ENTRY_DELETED) - { - if (lpHashTable[iCurEntry].FilePathHashA == nNameHashA - && lpHashTable[iCurEntry].FilePathHashB == nNameHashB - && lpHashTable[iCurEntry].Language == nLang - && lpHashTable[iCurEntry].Platform == nPlatform) - { - iFileHashEntry = iCurEntry; - - return true; - } - } - - iCurEntry = (iCurEntry + 1) & (nHashTableSize - 1); - } while (iCurEntry != iInitEntry && lpHashTable[iCurEntry].FileBlockIndex != MPQ_HASH_ENTRY_EMPTY); - - return false; -} - -3.4 DELETING FILES - -bool DeleteFile(HashTableEntry *lpHashTable, unsigned long nHashTableSize, BlockTableEntry *lpBlockTable, const char *lpszFilePath, unsigned short nLang, unsigned char nPlatform) -{ - assert(lpHashTable); - assert(nHashTableSize); - assert(lpBlockTable); - - // Find the file in the hash table - unsigned long iFileHashEntry; - - if (!FindFileInHashTable(lpHashTable, nHashTableSize, lpszFilePath, nLang, nPlatform, iFileHashEntry)) - return false; - - // Get the block table index before we nuke the hash table entry - unsigned long iFileBlockEntry = lpHashTable[iFileHashEntry].FileBlockIndex; - - // Delete the file's entry in the hash table - memset(&lpHashTable[iFileHashEntry], 0xFF, sizeof(HashTableEntry)); - - // If the next entry is empty, mark this one as empty; otherwise, mark this as deleted. - if (lpHashTable[(iFileHashEntry + 1) & (nHashTableSize - 1)].FileBlockIndex == MPQ_HASH_ENTRY_EMPTY) - lpHashTable[iFileHashEntry].FileBlockIndex = MPQ_HASH_ENTRY_EMPTY; - else - lpHashTable[iFileHashEntry].FileBlockIndex = MPQ_HASH_ENTRY_DELETED; - - // If the block occupies space, mark the block as free space; otherwise, clear the block table entry. - if (lpBlockTable[iFileBlockEntry].BlockSize > 0) - { - lpBlockTable[iFileBlockEntry].FileSize = 0; - lpBlockTable[iFileBlockEntry].Flags = 0; - } - else - memset(&lpBlockTable[iFileBlockEntry], 0, sizeof(BlockTableEntry); - - return true; -} - -3.5 CONVERSION OF FILETIME AND time_t -This code assumes that the base ("zero") date for time_t is 01/01/1970. This is true on Windows, Unix System V systems, and Mac OS X. It is unknown whether this is true on all other platforms. You'll need to research this yourself, if you plan on porting it somewhere else. - -#define EPOCH_OFFSET 116444736000000000ULL // Number of 100 ns units between 01/01/1601 and 01/01/1970 - -bool GetTimeFromFileTime(const FILETIME &fileTime, time_t &time) -{ - // The FILETIME represents a 64-bit integer: the number of 100 ns units since January 1, 1601 - unsigned long long nTime = ((unsigned long long)fileTime.dwHighDateTime << 32) + fileTime.dwLowDateTime; - - if (nTime < EPOCH_OFFSET) - return false; - - nTime -= EPOCH_OFFSET; // Convert the time base from 01/01/1601 to 01/01/1970 - nTime /= 10000000ULL; // Convert 100 ns to sec - - time = (time_t)nTime; - - // Test for overflow (FILETIME is 64 bits, time_t is 32 bits) - if ((nTime - (unsigned long long)time) > 0) - return false; - - return true; -} - -void GetFileTimeFromTime(const time_t &time, FILETIME &fileTime) -{ - unsigned long long nTime = (unsigned long long)time; - - nTime *= 10000000ULL; - nTime += EPOCH_OFFSET; - - fileTime.dwLowDateTime = (DWORD)nTime; - fileTime.dwHighDateTime = (DWORD)(nTime >> 32); -} - -3.6 FORMING A 64-BIT LARGE ARCHIVE OFFSET FROM 32-BIT AND 16-BIT COMPONENTS -unsigned long long MakeLargeArchiveOffset(unsigned long nOffsetLow, unsigned short nOffsetHigh) -{ - return ((unsigned long long)nOffsetHigh << 32) + (unsigned long long)nOffsetLow; -} - -4. REVISION HISTORY -1.0 - - Updated to include most of the changes found in the Burning Crusade Friends and Family beta - -0.91. - - Updated several structure member descriptions - - Listed the full set of characters that can separate list file entries - - Noted that (attributes), (listfile), and (signature) use the default language and platform codes - - Redid part of the file data specs to clarify the format of sectors - - Enhanced descriptions of the different kinds of block table entries - - Added ComputeFileKey, FindFileInHashTable, and DeleteFile source \ No newline at end of file diff --git a/contrib/vmap_extractor_v2/stormdll/StormDll.cpp b/contrib/vmap_extractor_v2/stormdll/StormDll.cpp deleted file mode 100644 index 2031180c7e3..00000000000 --- a/contrib/vmap_extractor_v2/stormdll/StormDll.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/*****************************************************************************/ -/* Storm.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* This is just a dummy module for building import library for Storm.dll */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 11.04.03 1.00 Lad The first version of Storm.cpp */ -/*****************************************************************************/ - -#include - -#define BUILDING_STORM_CPP -#define STORM_ALTERNATE_NAMES -#include "StormDll.h" - -BOOL WINAPI SFILE(OpenArchive)(LPCSTR lpFileName, DWORD dwPriority, DWORD dwFlags, HANDLE *hMPQ) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -BOOL WINAPI SFILE(CloseArchive)(HANDLE hMPQ) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -BOOL WINAPI SFILE(GetArchiveName)(HANDLE hMPQ, LPCSTR lpBuffer, DWORD dwBufferLength) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -BOOL WINAPI SFILE(OpenFile)(LPCSTR lpFileName, HANDLE *hFile) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -BOOL WINAPI SFILE(OpenFileEx)(HANDLE hMPQ, LPCSTR lpFileName, DWORD dwSearchScope, HANDLE *hFile) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -BOOL WINAPI SFILE(CloseFile)(HANDLE hFile) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -DWORD WINAPI SFILE(GetFileSize)(HANDLE hFile, LPDWORD lpFileSizeHigh) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -BOOL WINAPI SFILE(GetFileArchive)(HANDLE hFile, HANDLE *hMPQ) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -BOOL WINAPI SFILE(GetFileName)(HANDLE hFile, LPCSTR lpBuffer, DWORD dwBufferLength) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -DWORD WINAPI SFILE(SetFilePointer)(HANDLE hFile, long lDistanceToMove, PLONG lplDistanceToMoveHigh, DWORD dwMoveMethod) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -BOOL WINAPI SFILE(ReadFile)(HANDLE hFile,LPVOID lpBuffer,DWORD nNumberOfBytesToRead,LPDWORD lpNumberOfBytesRead,LPOVERLAPPED lpOverlapped) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -LCID WINAPI SFILE(SetLocale)(LCID nNewLocale) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -BOOL WINAPI SFILE(GetBasePath)(LPCSTR lpBuffer, DWORD dwBufferLength) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -BOOL WINAPI SFILE(SetBasePath)(LPCSTR lpNewBasePath) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -BOOL WINAPI SFILE(Destroy)() -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -BOOL WINAPI SCOMP(Compress)(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int uCmp, int uCmpType, int nCmpLevel) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - -BOOL WINAPI SCOMP(Decompress)(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} diff --git a/contrib/vmap_extractor_v2/stormdll/StormDll.def b/contrib/vmap_extractor_v2/stormdll/StormDll.def deleted file mode 100644 index 8de88f5db3d..00000000000 --- a/contrib/vmap_extractor_v2/stormdll/StormDll.def +++ /dev/null @@ -1,25 +0,0 @@ -; Storm definition file with alternate Storm.dll names -LIBRARY "Storm" - -EXPORTS - StormCloseArchive @252 ; 0x0FC - StormCloseFile @253 ; 0x0FD - StormDestroy @262 ; 0x106 - StormGetFileArchive @264 ; 0x108 - StormGetFileSize @265 ; 0x109 - StormOpenArchive @266 ; 0x10A - StormOpenFile @267 ; 0x10B - StormOpenFileEx @268 ; 0x10C - StormReadFile @269 ; 0x10D - StormSetBasePath @270 ; 0x10E - StormSetFilePointer @271 ; 0x10F - StormSetLocale @272 ; 0x110 - StormGetBasePath @273 ; 0x111 - StormGetArchiveName @275 ; 0x113 - StormGetFileName @276 ; 0x114 - -; StormSetLastError @465 ; 0x - - StormCompress @551 ; 0x227 - StormDecompress @552 ; 0x228 - \ No newline at end of file diff --git a/contrib/vmap_extractor_v2/stormdll/StormDll.h b/contrib/vmap_extractor_v2/stormdll/StormDll.h deleted file mode 100644 index 6d67820a22f..00000000000 --- a/contrib/vmap_extractor_v2/stormdll/StormDll.h +++ /dev/null @@ -1,67 +0,0 @@ -/*****************************************************************************/ -/* Storm.h Copyright Justin Olbrantz(Quantam) 2000 */ -/*---------------------------------------------------------------------------*/ -/* Storm Interface Library v1.0 for Windows */ -/* */ -/* Author : Justin Olbrantz(Quantam) */ -/* E-mail : omega@dragonfire.net */ -/* WWW : www.campaigncreations.com/starcraft/mpq2k/inside_mopaq/ */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* xx.xx.00 1.00 Qua The first version of Storm.h */ -/* 11.04.03 1.00 Lad Added some functions */ -/*****************************************************************************/ - -// We need the Windows data types for the Storm prototypes -#include - -#ifndef __STORM_H__ -#define __STORM_H__ - -// Somethimes is necessary to change the function names so they -// will not conflict with other MPQ tools. -#ifdef STORM_ALTERNATE_NAMES - #define SFILE(Name) Storm##Name - #define SCOMP(Name) Storm##Name -#else - #define SFILE(Name) SFile##Name - #define SCOMP(Name) SComp##Name -#endif - - -// Just in case anyone is still using C out there -#ifdef __cplusplus -extern "C" { -#endif - -// Storm file function prototypes -BOOL WINAPI SFILE(OpenArchive)(LPCSTR lpFileName, DWORD dwPriority, DWORD dwFlags, HANDLE *hMPQ); -BOOL WINAPI SFILE(CloseArchive)(HANDLE hMPQ); -BOOL WINAPI SFILE(GetArchiveName)(HANDLE hMPQ, LPCSTR lpBuffer, DWORD dwBufferLength); -BOOL WINAPI SFILE(OpenFile)(LPCSTR lpFileName, HANDLE *hFile); -BOOL WINAPI SFILE(OpenFileEx)(HANDLE hMPQ, LPCSTR lpFileName, DWORD dwSearchScope, HANDLE *hFile); -BOOL WINAPI SFILE(CloseFile)(HANDLE hFile); -DWORD WINAPI SFILE(GetFileSize)(HANDLE hFile, LPDWORD lpFileSizeHigh); -BOOL WINAPI SFILE(GetFileArchive)(HANDLE hFile, HANDLE *hMPQ); -BOOL WINAPI SFILE(GetFileName)(HANDLE hFile, LPCSTR lpBuffer, DWORD dwBufferLength); -DWORD WINAPI SFILE(SetFilePointer)(HANDLE hFile, long lDistanceToMove, PLONG lplDistanceToMoveHigh, DWORD dwMoveMethod); -BOOL WINAPI SFILE(ReadFile)(HANDLE hFile,LPVOID lpBuffer,DWORD nNumberOfBytesToRead,LPDWORD lpNumberOfBytesRead,LPOVERLAPPED lpOverlapped); -LCID WINAPI SFILE(SetLocale)(LCID nNewLocale); -BOOL WINAPI SFILE(GetBasePath)(LPCSTR lpBuffer, DWORD dwBufferLength); -BOOL WINAPI SFILE(SetBasePath)(LPCSTR lpNewBasePath); - -// Storm (de)compression functions -BOOL WINAPI SCOMP(Compress) (char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int uCmp, int uCmpType, int nCmpLevel); -BOOL WINAPI SCOMP(Decompress)(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength); - - -#if defined(_MSC_VER) && !defined(BUILDING_STORM_CPP) -#pragma comment(lib, "Storm.lib") // Force linking Storm.lib and thus Storm.dll -#endif - -#ifdef __cplusplus -} -#endif - -#endif // __STORM_H__ diff --git a/contrib/vmap_extractor_v2/stormlib/GfxDecode.cpp b/contrib/vmap_extractor_v2/stormlib/GfxDecode.cpp deleted file mode 100644 index 665e5d38e49..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/GfxDecode.cpp +++ /dev/null @@ -1,697 +0,0 @@ -/*********************************************************************** -* -* Description: GfxDecode -- functions for reading Diablo's GFX files -* Author: Marko Friedemann -* Created at: Son Jan 27 15:20:43 CET 2002 -* Computer: hangloose.flachland-chemnitz.de -* System: Linux 2.4.16 on i686 -* -* Copyright (c) 2002 BMX-Chemnitz.DE All rights reserved. -* -* --------------------------------------------------------------------- -* included are functions for getting: -* - the framecount of .CEL-files -> celGetFrameCount() -* - single frames of .CEL-files -> celGetFrameData() -* - the framecount of .CL2-files -> cl2GetFrameCount() -* - single directions of .CL2-files (all frames) -> cl2GetDirData() -* - single .PCX-files (256 color; v2, v5) -> pcxGetData() -***********************************************************************/ - -#include -#include -#include - -#include "StormLib.h" - -#define TRANS_COL 256 - -using std::cerr; -using std::vector; - -/****** RAMP stuff ***************************************************** - * for a more detailed description/explanation see below - ***********************************************************************/ -// two variations: one/two ramp(s) -static const uint16_t c_2RampSize = 544; // the frame size -static const uint16_t c_1RampSize = 800; // the frame size - -// ramps (both variations) can be either left or right -static const uint16_t c_RampOffsetLeft[17] = { - 0, // __ - 8, // + 8 note that this __-- - 24, // + 16 "drawing" is __-- - 48, // + 24 upside down! __-- this area - 80, // + 32 __-- is always - 120, // + 40 __-- colored - 168, // + 48 __-- - 224, // + 56 __-- lower ramp ends here (+30 == 254) - 288, // + 64 --__ upper ramp might be missing - 348, // + 60 | --__ - 400, // + 52 | --__ this area - 444, // + 44 | --__ is always - 480, // + 36 | --__ colored - 508, // + 28 | either trans- --__ - 528, // + 20 | parent or colored --__ - 540, // + 12 | --__ +2 Pixels = 544 - 542 // + 2 | this last one doesn't exist, it's those^ 2 pixels -}; - -static const uint16_t c_RampOffsetRight[17] = { - 2, // __ before this, there are 2 Pixels - 14, // + 12 --__ 4^2 - 2 - 34, // + 20 --__ 6^2 - 2 - 62, // + 28 this area --__ 8^2 - 2 - 98, // + 36 is always --__ 10^2 - 2 pattern anyone? ;) - 142, // + 44 colored --__ - 194, // + 52 --__ - 254, // + 60 lower ramp ends here --__ (-30 == 224) - 318, // + 64 upper ramp might be missing __-- - 374, // + 56 __-- | - 422, // + 48 this area __-- | note that this - 462, // + 40 is always __-- | "drawing" - 494, // + 32 colored __-- eiter trans- | is upside down! - 518, // + 24 __-- parent or colored | - 534, // + 16 __-- | - 542, // + 8 __-- +2 Startpixels = 544 | - 542 // + 0 this last one doesn't exist, it | would be EOF -}; - -/****** FrameBuffer class ********************************************** - * holds buffers and size information of the actual target image - * purpose: buffer management and avoidance of ugly globals - **********************************************************************/ -class FrameBuf -{ - protected: - vector vecData; - uint8_t *pCurrRow; - uint8_t *pPalette; - uint16_t uRows; - uint16_t *upYSize; - uint16_t *upMaxX; - public: - uint16_t uCols; - uint16_t uXSize; - uint16_t uMaxBlock; - uint16_t uFrameNum; - bool bHasBlocks; - bool bHasRamps; - FrameBuf( - uint8_t *pPal=NULL, uint16_t frame=0, uint16_t xsize=0, - uint16_t *pysize=NULL, uint16_t *pmaxx=NULL, uint16_t maxblock=0) - { - pCurrRow = new uint8_t[4*xsize]; - pPalette = pPal; - uCols = 0; - uRows = 0; - uXSize = xsize; - uFrameNum = frame; - uMaxBlock = maxblock; - upYSize = pysize; - upMaxX = pmaxx; - bHasBlocks= false; - bHasRamps = false; - } - ~FrameBuf() - { - delete[] pCurrRow; - for (vector ::iterator vi=vecData.begin(); vi!=vecData.end(); vi++) - delete[] *vi; - vecData.clear(); - } - void addLine() - { - ++uRows; - uCols = 0; - vecData.push_back(pCurrRow); - pCurrRow = new uint8_t[4*uXSize]; - } - void addPixel(uint16_t uColorNum) - { - if (uColorNum > TRANS_COL) { - cerr << "\n*** there seemed to be an error, illegal color index " << uColorNum; - cerr << "\n +++ at (" << uCols << "," << uRows << "), see for yourself *** \n\n"; - uColorNum = TRANS_COL; // sane setting to avoid segfaults - } - - memcpy(pCurrRow + 4*uCols, pPalette + 4*uColorNum, 4*sizeof(uint8_t)); - if (++uCols == uXSize) - addLine(); - else if ((uColorNum != TRANS_COL) && (upMaxX != NULL) && (uCols > *upMaxX)) - *upMaxX = uCols; - } - // used to return the actual image data - uint8_t *getData() - { - uint16_t i; - vector ::reverse_iterator vri; - // allocate a buffer to hold the actual image size - uint8_t *tmp = new uint8_t[4*uXSize*uRows]; - - // the lines are upside down inside the vector, use reverse iterator - for (i=0, vri=vecData.rbegin(); vri!=vecData.rend(); vri++, i++) - memcpy(tmp+4*uXSize*i, *vri, 4*uXSize*sizeof(uint8_t)); - - *upYSize = uRows; // set height - - if (uCols > 0) { - cerr << "\n*** there seemed to be an error (last line does not match boundary, " << uCols << " pixels left)"; - cerr << "\n +++ this is often caused by specifying an invalid width, see for yourself *** \n\n"; - } - - return tmp; - } -}; - -uint16_t WINAPI celGetFrameCount(uint8_t *pFileBuf) -{ - uint32_t tmp; - memcpy(&tmp, pFileBuf, sizeof(uint32_t)); - return (uint16_t)tmp; -} - -/***** Block Decoder *************************************************** - * one of three possible decoding techniques necessary for .cel - * possible block contents are either colored (in that case the - * appropriate number of pixels are read) or transparent pixels - * there are neither ramps nor plain pixels allowed here - ***********************************************************************/ -uint8_t *celDecodeBlocks(uint8_t *pFileBuf, FrameBuf *pFrame, uint32_t *framestart) -{ - uint32_t uFilePos=framestart[pFrame->uFrameNum]; - uint8_t cRead=0, i=0; - - if (!pFrame->bHasBlocks) // sanity check - return NULL; - - while (uFilePos < framestart[pFrame->uFrameNum+1]) { - cRead = pFileBuf[uFilePos++]; - - if ((uFilePos == framestart[pFrame->uFrameNum]+1)) - // TODO: what is this 0x0A 0x00 stuff all about? - if ((cRead == 0x0A) && (pFileBuf[uFilePos] == 0x00)) { - uFilePos += 9; - cRead = pFileBuf[uFilePos++]; - } - - if (cRead > 0x7F) - // transparent block (complement, 256-val) - for (i=0; i<256-cRead; i++) - pFrame->addPixel(TRANS_COL); - else if (cRead < pFrame->uMaxBlock + 1) - // pixel block (block size pixels to be read!) - for (i=0; iaddPixel(pFileBuf[uFilePos++]); - else - cerr << "\n*** block mode: illegal block (> max_size) ***\n\n"; - } - return pFrame->getData(); -} - -/***** Ramp Decoder **************************************************** - * the second of three possible decoding techniques necessary for .cel - * each block save the first/last is enclosed by two 0x00 pairs - * those blocks affect _TWO_ rows with one being 2 colored pixels shorter - * the first/last "block" affects only one row - ***********************************************************************/ -uint8_t *celDecodeRamps(uint8_t *pFileBuf, FrameBuf *pFrame, uint32_t *framestart, bool bLeft) -{ - uint32_t uFrameLen = framestart[pFrame->uFrameNum+1]-framestart[pFrame->uFrameNum]; - uint32_t uFilePos=0; - uint16_t uBlockLen=0, i=0, j=0; - bool bFirstLonger=false; - - if (!pFrame->bHasRamps) // sanity check - return NULL; - - if (pFrame->uXSize != 32) // only used in that case - return NULL; - - if (!bLeft) { // get first two pixels for right side ramps - pFrame->addPixel(pFileBuf[framestart[pFrame->uFrameNum]]); - pFrame->addPixel(pFileBuf[framestart[pFrame->uFrameNum]+1]); - } - - // do all the ramp blocks - for (i=0; i<(uFrameLen == c_2RampSize ? 15 : 7); i++) { - uBlockLen = (bLeft ? (c_RampOffsetLeft[i+1] - c_RampOffsetLeft[i]) : (c_RampOffsetRight[i+1] - c_RampOffsetRight[i])); - uFilePos = framestart[pFrame->uFrameNum] + (bLeft ? c_RampOffsetLeft[i] : c_RampOffsetRight[i]) + 2; - bFirstLonger = (i>(bLeft ? 7 : 6)); - if (bLeft) { - // OK, first line, starting with transparency - for (j=0; juXSize - uBlockLen/2 + (bFirstLonger ? 0 : 2); j++) - pFrame->addPixel(TRANS_COL); - // fill it up with the pixel block - for (j=0; jaddPixel(pFileBuf[uFilePos++]); - // second line, starting again with transparency - for (j=0; juXSize - uBlockLen/2 + (bFirstLonger ? 2 : 0); j++) - pFrame->addPixel(TRANS_COL); - // fill the second line with the remaining pixels - for (j=0; jaddPixel(pFileBuf[uFilePos++]); - } else { - if (pFrame->uCols != 0) // fill current line with trans (if not empty) - for (j=pFrame->uXSize - pFrame->uCols; j>0; j--) - pFrame->addPixel(TRANS_COL); - // OK, insert the first pixels into a new line - for (j=0; jaddPixel(pFileBuf[uFilePos++]); - // fill the line with transparency - for (j=0; juXSize - uBlockLen/2 + (bFirstLonger ? 0 : 2); j++) - pFrame->addPixel(TRANS_COL); - // start a second line with the remaining pixels - for (j=0; jaddPixel(pFileBuf[uFilePos++]); - } - } - - // now read the last 0x00 pair and fill up - uBlockLen = (uFrameLen == c_2RampSize ? 30 : 2); // one or two ramps? - uFilePos = framestart[pFrame->uFrameNum] + (bLeft ? c_RampOffsetLeft[i] : c_RampOffsetRight[i]) + 2; - // the transparency for the last (single) 0x00 pair - for (j=0; jaddPixel(TRANS_COL); - if (bLeft) { // left side only: the remaining line - for (j=0; juXSize - uBlockLen; j++) - pFrame->addPixel(pFileBuf[uFilePos++]); - } - - // now the rest of the file (plain) - while (uFilePos < framestart[pFrame->uFrameNum+1]) - pFrame->addPixel(pFileBuf[uFilePos++]); - - // the uppermost line is emtpy when 2 ramps are used - if (uFrameLen == c_2RampSize) - for (j=0; juXSize; j++) - pFrame->addPixel(TRANS_COL); - - return pFrame->getData(); -} - -/***** celGetFrameData ************************************************* - * decode .cel data for given frame and xsize - * Args: - * *vpFileBuf the buffer containing the filecontent - * *palette the palette (4 bytes for each of the 257 entries) - * 256 colors are needed + 1 for alpha - * uXSize this information must be given - * uFrameNume the frame to get - * *uYSize the actual value is returned therein - * *uMaxX this can be used (if != NULL) to get the column - * of the rightmost nontransparent pixel (useable - * eg for fonts) - * - * Returns: an array containing 4 Bytes (RGBA) for each pixel - * - * --------------------------------------------------------------- - * Comments: dirty hack, started from scratch @ 2000-10-11 - * cleanly rewritten during incorporation into ladiks StormLib - * status: structured hack ;) - * - * It took me approx. 6 days to understand the format basics (hex viewer) - * For this I had a little help from a dos tool ("ddecode", from - * www.cowlevel.com, binary only, no sources) which, however, gave - * me the general idea what the pictures are actually supposed to look like. - * - * The fine adjustments, however, took quite some time and a little luck. - * After I had written to various people (mickyk and ladik), which could - * not help me, but wished best luck (thanks, btw, it helped ;)), I tried - * some reverse engineering which was not succesful in the end. - * - * I then had incidentally a new idea of what could be going on @ 2002-01-23. - * It just came to my mind that I could retry some actual painting in - * reverse order (had done that before to no avail) and when looking closer - * at it I realized the "ramp" stuff. This really is the trickiest part and - * it took me some eight days to implement it without breaking the other - * parts of the code. Very odd format indeed. - * - * TODO: learn what 0x0A 0x00 means - **********************************************************************/ -uint8_t * WINAPI celGetFrameData(uint8_t *pFileBuf, uint8_t *palette, uint16_t uXSize, uint16_t uFrameNum, uint16_t *uYSize, uint16_t *uMaxX) -{ - FrameBuf *pFrame; - uint32_t *framestart=NULL, frames=0, uFilePos=0; - uint16_t i, tmpWord=0; - uint8_t cRead=0, *data; - - memcpy(&frames, pFileBuf, sizeof(uint32_t)); - uFilePos += sizeof(uint32_t); - - if (pFileBuf == NULL) { - SetLastError(ERROR_INVALID_PARAMETER); - return NULL; - } - - if (palette == NULL) { - SetLastError(ERROR_INVALID_PARAMETER); - return NULL; - } - - if (uFrameNum > frames-1) { - SetLastError(ERROR_INVALID_PARAMETER); - return NULL; - } - - if (uYSize == NULL) { - SetLastError(ERROR_INVALID_PARAMETER); - return NULL; - } - - // in case we want to know the rightmost pixels column (usable eg. for fonts) - if (uMaxX != NULL) - *uMaxX = 0; - - // get the frame offsets - framestart = new uint32_t[frames+1]; - for (i=0; ibHasRamps = (i==(uFrameLen == c_2RampSize ? 16 : 8)); - if (!pFrame->bHasRamps) { // only one can apply - for (i=0; i<(uFrameLen == c_2RampSize ? 16 : 8); i++) { - memcpy(&tmpWord, pFileBuf+framestart[uFrameNum]+c_RampOffsetRight[i], sizeof(uint16_t)); - if (tmpWord != 0) - break; - } - pFrame->bHasRamps = (i==(uFrameLen == c_2RampSize ? 16 : 8)); // bRampsLeft stays false in this case - } - - if (pFrame->bHasRamps) { // decode ramps and be off (if appropriate) - data = celDecodeRamps(pFileBuf, pFrame, framestart, bRampsLeft); - delete pFrame; - delete[] framestart; - return data; - } - } - - /*********** block detection *************************************** - * 0x0A as start byte seems to be sufficient (though I still dunno - * what the trailing 10 bytes mean); in any other case we act as if - * blocks were to be used and check afterwards if the image looks - * OK (that is, the last line has no pixels in it) - ******************************************************************/ - - cRead = pFileBuf[framestart[uFrameNum]]; - if (cRead == 0x0A) // sufficient - pFrame->bHasBlocks = true; - // if width == 32 && framelen == 32*32, assume plain - else if ((uXSize != 32) || (uFrameLen != 32*32)) { // check needed - uFilePos=framestart[uFrameNum]; - i=0; - // rush through the frame - while (uFilePos < framestart[uFrameNum+1]) { - cRead = pFileBuf[uFilePos++]; - - // transparency blocks - while (cRead > 0x7F) { - i += 256-cRead; - i %= uXSize; - if (uFilePos < framestart[uFrameNum+1]) - cRead = pFileBuf[uFilePos++]; - else - cRead = 0; - } - - // colored pixel block - if (uFilePos < framestart[uFrameNum+1]) { - if (cRead < pFrame->uMaxBlock + 1) { - i+=cRead; - i%=uXSize; - uFilePos+=cRead; - } else { - // when the value is out of valid blockrange - i=1; // trigger error (1%uXSize != 0) - break; - } - } - } - if (i%uXSize == 0) // looks as if we got it right - pFrame->bHasBlocks=true; - } - - if (pFrame->bHasBlocks) { // use block decoder if appropriate - data = celDecodeBlocks(pFileBuf, pFrame, framestart); - delete pFrame; - delete[] framestart; - return data; - } - - // plain mode (#3), read each color index and write the pixel - uFilePos=framestart[uFrameNum]; - while (uFilePos < framestart[uFrameNum+1]) - pFrame->addPixel(pFileBuf[uFilePos++]); - - // cleanup, return image data and height - data = pFrame->getData(); - delete pFrame; - delete[] framestart; - return data; -} - -uint16_t WINAPI cl2GetFrameCount(uint8_t *pFileBuf) -{ - uint32_t tmp; - memcpy(&tmp, pFileBuf, sizeof(uint32_t)); - memcpy(&tmp, pFileBuf+tmp, sizeof(uint32_t)); - return (uint16_t)tmp; -} - -/***** cl2GetDirData *************************************************** - * decodes all frames of a .cl2 for given direction and xsize - * Args: - * *pFileBuf the buffer containing the filecontent - * *palette the palette (4 bytes for each of the 257 entries) - * 256 colors are needed + 1 for alpha - * uXSize this information must be given - * uDirNum the direction to get the frames from - * *uYSize the actual height is returned herein - * - * Returns: arrays containing 4 Bytes (RGBA) for each pixel - * where is read at runtime and handed back via *uFrames - * - * --------------------------------------------------------------- - * Comments: dirty hack, started from scratch @ 2000-10-12 - * - * The format basics are similar to .cel, with the main difference - * that the values read have reverse interpretation. In .cel a value - * greater than 0x7F means transparency, while in .cl2 this means - * color and vice-versa. .cl2 has the additional understanding - * of blocks of the same color (0x80 .. 0xBF) where the one color is - * written multiple times. - * - * .cl2 only uses the block scheme, so there is no detection - * necessary in order to get it right. The only thing still unknown - * is that 0x0A 0x00 stuff... - * - * TODO: learn what 0x0A 0x00 means - ***********************************************************************/ -BYTE ** WINAPI cl2GetDirData(BYTE *pFileBuf, BYTE *palette, WORD uXSize, WORD uDirNum, WORD *uYSize) -{ - FrameBuf *pFrame; - uint32_t frames=0, *framestart=NULL, uFilePos=0; - uint16_t i, fc; - uint8_t cRead=0, **data=NULL; - - if (pFileBuf == NULL) { - SetLastError(ERROR_INVALID_PARAMETER); - return NULL; - } - - if (palette == NULL) { - SetLastError(ERROR_INVALID_PARAMETER); - return NULL; - } - - if (uDirNum > 7) { - SetLastError(ERROR_INVALID_PARAMETER); - return NULL; - } - - if (uYSize == NULL) { - SetLastError(ERROR_INVALID_PARAMETER); - return NULL; - } - - // get direction offsets - uint32_t dirstart[8]; - for (i=0; i<8; i++) { - memcpy(&dirstart[i], pFileBuf+uFilePos, sizeof(uint32_t)); - uFilePos += sizeof(uint32_t); - } - - uFilePos = dirstart[uDirNum]; - - memcpy(&frames, pFileBuf+uFilePos, sizeof(uint32_t)); - uFilePos += sizeof(uint32_t); - - data = new uint8_t*[frames]; - - // get frame offsets - framestart = new uint32_t[frames+1]; - for (i=0; iaddPixel(TRANS_COL); - } else if (cRead < 0xC0) { - // read the next byte and write it <0xBF - cRead> times - for (i=0; i<0xBF - cRead; i++) - pFrame->addPixel(pFileBuf[uFilePos]); - ++uFilePos; - } else // cRead > 0xBF - // read a block of the given size and write it - for (i=0; i < 256-cRead; i++) - pFrame->addPixel(pFileBuf[uFilePos++]); - } - - // got the frame data, save it - data[fc] = pFrame->getData(); - delete pFrame; - } - - delete[] framestart; - return data; -} - -/****** pcxGetData ***************************************************** - * decodes pcx files (256 color, as in diablo mpq) - * Args: - * *pFileBuf the buffer containing the filecontent - * uFileSize the size of the file buffer - * uTransColor the palette entry to be transparent - * *uXSize the actual width is returned herein - * *uYSize the actual height is returned herein - * - * Returns: an array containing 4 Bytes (RGBA) for each pixel - * - * --------------------------------------------------------------- - * Comments: format info and pseudocode taken from: - * Klaus Holtorf, "Das Handbuch der Grafikformate" - * ISBN 3-7723-6393-8 - ***********************************************************************/ -BYTE * WINAPI pcxGetData(BYTE *pFileBuf, DWORD uFileSize, BYTE uTransColor, WORD *uXSize, WORD *uYSize) -{ - uint32_t uFilePos=0; - uint32_t uDataRead=0; // potentially big! (logo.pcx: 550 * 216 * 15 = 1,782,000) - uint16_t i=0; - uint8_t *data, *palette; - uint8_t uColorNum=0, uCount=0; - - struct pcx_header_t { - uint8_t id; - uint8_t version; - uint8_t compressed; - uint8_t bpp; - uint16_t x0; - uint16_t y0; - uint16_t x1; - uint16_t y1; - uint16_t xdpi; - uint16_t ydpi; - uint8_t pal[16][3]; - uint8_t reserved; - uint8_t layers; - uint16_t rowbytes; - uint16_t colortype; - uint8_t pad[58]; - } pcxHeader; - - if (pFileBuf == NULL) { - SetLastError(ERROR_INVALID_PARAMETER); - return NULL; - } - - if (uXSize == NULL) { - SetLastError(ERROR_INVALID_PARAMETER); - return NULL; - } - - if (uYSize == NULL) { - SetLastError(ERROR_INVALID_PARAMETER); - return NULL; - } - - // get image information - memcpy(&pcxHeader, pFileBuf, sizeof(struct pcx_header_t)); - *uXSize = (pcxHeader.x1 - pcxHeader.x0 + 1); - *uYSize = (pcxHeader.y1 - pcxHeader.y0 + 1); - - if ((pcxHeader.version != 2) && (pcxHeader.version != 5)) { - cerr << "cannot handle pcx v" << pcxHeader.version << "\n"; - return NULL; - } - - // get palette - palette = new uint8_t[256*4]; - if (pFileBuf[uFileSize - 768 - 1] != 0x0C) { - cerr << "palette error at " << uFileSize - 768 - 1 << "\n"; - return NULL; - } - for (i=0; i<256; i++) { - memcpy(palette+i*4, pFileBuf+uFileSize-768+i*3, 3*sizeof(uint8_t)); - palette[i*4+3] = 0xFF; - } - memset(palette+uTransColor*4, 0, 4*sizeof(uint8_t)); // transparent black - - // start right after the header - uFilePos = sizeof(struct pcx_header_t); - data = new uint8_t[*uXSize * *uYSize * 4]; - while (uDataRead < (uint32_t)(*uXSize * *uYSize)) { - // decompress - uColorNum = pFileBuf[uFilePos++]; - if ((pcxHeader.compressed) && (uColorNum > 0xBF)) { - uCount = (uColorNum & 0x3F); - uColorNum = pFileBuf[uFilePos++]; - } else - uCount = 1; - - // draw count pixels with color val - for (i=0; i 0) - { - dwSeed2 += StormBuffer[0x400 + (dwSeed1 & 0xFF)]; - ch = *pdwTable; - *pdwTable++ = ch ^ (dwSeed1 + dwSeed2); - - dwSeed1 = ((~dwSeed1 << 0x15) + 0x11111111) | (dwSeed1 >> 0x0B); - dwSeed2 = ch + dwSeed2 + (dwSeed2 << 5) + 3; - } -} - -void DecryptHashTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength) -{ - DWORD dwSeed1 = 0x7FED7FED; - DWORD dwSeed2 = 0xEEEEEEEE; - DWORD ch; // One key character - - // Prepare seeds - while(*pbKey != 0) - { - ch = toupper(*pbKey++); - - dwSeed1 = StormBuffer[0x300 + ch] ^ (dwSeed1 + dwSeed2); - dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; - } - - // Decrypt it - dwSeed2 = 0xEEEEEEEE; - while(dwLength-- > 0) - { - dwSeed2 += StormBuffer[0x400 + (dwSeed1 & 0xFF)]; - ch = *pdwTable ^ (dwSeed1 + dwSeed2); - - dwSeed1 = ((~dwSeed1 << 0x15) + 0x11111111) | (dwSeed1 >> 0x0B); - dwSeed2 = ch + dwSeed2 + (dwSeed2 << 5) + 3; - *pdwTable++ = ch; - } -} - -//----------------------------------------------------------------------------- -// Encrypting and decrypting block table - -void EncryptBlockTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength) -{ - DWORD dwSeed1 = 0x7FED7FED; - DWORD dwSeed2 = 0xEEEEEEEE; - DWORD ch; // One key character - - // Prepare seeds - while(*pbKey != 0) - { - ch = toupper(*pbKey++); - - dwSeed1 = StormBuffer[0x300 + ch] ^ (dwSeed1 + dwSeed2); - dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; - } - - // Decrypt it - dwSeed2 = 0xEEEEEEEE; - while(dwLength-- > 0) - { - dwSeed2 += StormBuffer[0x400 + (dwSeed1 & 0xFF)]; - ch = *pdwTable; - *pdwTable++ = ch ^ (dwSeed1 + dwSeed2); - - dwSeed1 = ((~dwSeed1 << 0x15) + 0x11111111) | (dwSeed1 >> 0x0B); - dwSeed2 = ch + dwSeed2 + (dwSeed2 << 5) + 3; - } -} - -void DecryptBlockTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength) -{ - DWORD dwSeed1 = 0x7FED7FED; - DWORD dwSeed2 = 0xEEEEEEEE; - DWORD ch; // One key character - - // Prepare seeds - while(*pbKey != 0) - { - ch = toupper(*pbKey++); - - dwSeed1 = StormBuffer[0x300 + ch] ^ (dwSeed1 + dwSeed2); - dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; - } - - // Encrypt it - dwSeed2 = 0xEEEEEEEE; - while(dwLength-- > 0) - { - dwSeed2 += StormBuffer[0x400 + (dwSeed1 & 0xFF)]; - ch = *pdwTable ^ (dwSeed1 + dwSeed2); - - dwSeed1 = ((~dwSeed1 << 0x15) + 0x11111111) | (dwSeed1 >> 0x0B); - dwSeed2 = ch + dwSeed2 + (dwSeed2 << 5) + 3; - *pdwTable++ = ch; - } -} - -//----------------------------------------------------------------------------- -// Functions tries to get file decryption key. The trick comes from block -// positions which are stored at the begin of each compressed file. We know the -// file size, that means we know number of blocks that means we know the first -// DWORD value in block position. And if we know encrypted and decrypted value, -// we can find the decryption key !!! -// -// hf - MPQ file handle -// block - DWORD array of block positions -// ch - Decrypted value of the first block pos - -DWORD DetectFileSeed(DWORD * block, DWORD decrypted) -{ - DWORD saveSeed1; - DWORD temp = *block ^ decrypted; // temp = seed1 + seed2 - temp -= 0xEEEEEEEE; // temp = seed1 + StormBuffer[0x400 + (seed1 & 0xFF)] - - for(int i = 0; i < 0x100; i++) // Try all 255 possibilities - { - DWORD seed1; - DWORD seed2 = 0xEEEEEEEE; - DWORD ch; - - // Try the first DWORD (We exactly know the value) - seed1 = temp - StormBuffer[0x400 + i]; - seed2 += StormBuffer[0x400 + (seed1 & 0xFF)]; - ch = block[0] ^ (seed1 + seed2); - - if(ch != decrypted) - continue; - - // Add 1 because we are decrypting block positions - saveSeed1 = seed1 + 1; - - // If OK, continue and test the second value. We don't know exactly the value, - // but we know that the second one has lower 16 bits set to zero - // (no compressed block is larger than 0xFFFF bytes) - seed1 = ((~seed1 << 0x15) + 0x11111111) | (seed1 >> 0x0B); - seed2 = ch + seed2 + (seed2 << 5) + 3; - - seed2 += StormBuffer[0x400 + (seed1 & 0xFF)]; - ch = block[1] ^ (seed1 + seed2); - - if((ch & 0xFFFF0000) == 0) - return saveSeed1; - } - return 0; -} - -// Function tries to detect file seed. It expectes at least two uncompressed bytes -DWORD DetectFileSeed2(DWORD * pdwBlock, UINT nDwords, ...) -{ - va_list argList; - DWORD dwDecrypted[0x10]; - DWORD saveSeed1; - DWORD dwTemp; - DWORD i, j; - - // We need at least two DWORDS to detect the seed - if(nDwords < 0x02 || nDwords > 0x10) - return 0; - - va_start(argList, nDwords); - for(i = 0; i < nDwords; i++) - dwDecrypted[i] = va_arg(argList, DWORD); - va_end(argList); - - dwTemp = (*pdwBlock ^ dwDecrypted[0]) - 0xEEEEEEEE; - for(i = 0; i < 0x100; i++) // Try all 255 possibilities - { - DWORD seed1; - DWORD seed2 = 0xEEEEEEEE; - DWORD ch; - - // Try the first DWORD - seed1 = dwTemp - StormBuffer[0x400 + i]; - seed2 += StormBuffer[0x400 + (seed1 & 0xFF)]; - ch = pdwBlock[0] ^ (seed1 + seed2); - - if(ch != dwDecrypted[0]) - continue; - - saveSeed1 = seed1; - - // If OK, continue and test all bytes. - for(j = 1; j < nDwords; j++) - { - seed1 = ((~seed1 << 0x15) + 0x11111111) | (seed1 >> 0x0B); - seed2 = ch + seed2 + (seed2 << 5) + 3; - - seed2 += StormBuffer[0x400 + (seed1 & 0xFF)]; - ch = pdwBlock[j] ^ (seed1 + seed2); - - if(ch == dwDecrypted[j] && j == nDwords - 1) - return saveSeed1; - } - } - return 0; -} - - -//----------------------------------------------------------------------------- -// Encrypting and decrypting MPQ blocks - -void EncryptMPQBlock(DWORD * block, DWORD dwLength, DWORD dwSeed1) -{ - DWORD dwSeed2 = 0xEEEEEEEE; - DWORD ch; - - // Round to DWORDs - dwLength >>= 2; - - while(dwLength-- > 0) - { - dwSeed2 += StormBuffer[0x400 + (dwSeed1 & 0xFF)]; - ch = *block; - *block++ = ch ^ (dwSeed1 + dwSeed2); - - dwSeed1 = ((~dwSeed1 << 0x15) + 0x11111111) | (dwSeed1 >> 0x0B); - dwSeed2 = ch + dwSeed2 + (dwSeed2 << 5) + 3; - } -} - -void DecryptMPQBlock(DWORD * block, DWORD dwLength, DWORD dwSeed1) -{ - DWORD dwSeed2 = 0xEEEEEEEE; - DWORD ch; - - // Round to DWORDs - dwLength >>= 2; - - while(dwLength-- > 0) - { - dwSeed2 += StormBuffer[0x400 + (dwSeed1 & 0xFF)]; - ch = *block ^ (dwSeed1 + dwSeed2); - - dwSeed1 = ((~dwSeed1 << 0x15) + 0x11111111) | (dwSeed1 >> 0x0B); - dwSeed2 = ch + dwSeed2 + (dwSeed2 << 5) + 3; - *block++ = ch; - } -} - - -DWORD DecryptHashIndex(TMPQArchive * ha, const char * szFileName) -{ - BYTE * pbKey = (BYTE *)szFileName; - DWORD dwSeed1 = 0x7FED7FED; - DWORD dwSeed2 = 0xEEEEEEEE; - DWORD ch; - - while(*pbKey != 0) - { - ch = toupper(*pbKey++); - - dwSeed1 = StormBuffer[0x000 + ch] ^ (dwSeed1 + dwSeed2); - dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; - } - return (dwSeed1 & (ha->pHeader->dwHashTableSize - 1)); -} - -DWORD DecryptName1(const char * szFileName) -{ - BYTE * pbKey = (BYTE *)szFileName; - DWORD dwSeed1 = 0x7FED7FED; - DWORD dwSeed2 = 0xEEEEEEEE; - DWORD ch; - - while(*pbKey != 0) - { - ch = toupper(*pbKey++); - - dwSeed1 = StormBuffer[0x100 + ch] ^ (dwSeed1 + dwSeed2); - dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; - } - return dwSeed1; -} - -DWORD DecryptName2(const char * szFileName) -{ - BYTE * pbKey = (BYTE *)szFileName; - DWORD dwSeed1 = 0x7FED7FED; - DWORD dwSeed2 = 0xEEEEEEEE; - int ch; - - while(*pbKey != 0) - { - ch = toupper(*pbKey++); - - dwSeed1 = StormBuffer[0x200 + ch] ^ (dwSeed1 + dwSeed2); - dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; - } - return dwSeed1; -} - -DWORD DecryptFileSeed(const char * szFileName) -{ - BYTE * pbKey = (BYTE *)szFileName; - DWORD dwSeed1 = 0x7FED7FED; // EBX - DWORD dwSeed2 = 0xEEEEEEEE; // ESI - DWORD ch; - - while(*pbKey != 0) - { - ch = toupper(*pbKey++); // ECX - - dwSeed1 = StormBuffer[0x300 + ch] ^ (dwSeed1 + dwSeed2); - dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; - } - return dwSeed1; -} - -TMPQHash * GetHashEntry(TMPQArchive * ha, const char * szFileName) -{ - TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - TMPQHash * pHash0; // File hash entry (start) - TMPQHash * pHash; // File hash entry (current) - DWORD dwIndex = (DWORD)(DWORD_PTR)szFileName; - DWORD dwName1; - DWORD dwName2; - - // If filename is given by index, we have to search all hash entries for the right index. - if(dwIndex <= ha->pHeader->dwBlockTableSize) - { - // Pass all the hash entries and find the - for(pHash = ha->pHashTable; pHash < pHashEnd; pHash++) - { - if(pHash->dwBlockIndex == dwIndex) - return pHash; - } - return NULL; - } - - // Decrypt name and block index - dwIndex = DecryptHashIndex(ha, szFileName); - dwName1 = DecryptName1(szFileName); - dwName2 = DecryptName2(szFileName); - pHash = pHash0 = ha->pHashTable + dwIndex; - - // Look for hash index - while(pHash->dwBlockIndex != HASH_ENTRY_FREE) - { - if(pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2 && pHash->dwBlockIndex != HASH_ENTRY_DELETED) - return pHash; - - // Move to the next hash entry - if(++pHash >= pHashEnd) - pHash = ha->pHashTable; - if(pHash == pHash0) - break; - } - - // File was not found - return NULL; -} - -// Retrieves the locale-specific hash entry -TMPQHash * GetHashEntryEx(TMPQArchive * ha, const char * szFileName, LCID lcLocale) -{ - TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - TMPQHash * pHash0 = NULL; // Language-neutral hash entry - TMPQHash * pHashX = NULL; // Language-speficic - TMPQHash * pHash = GetHashEntry(ha, szFileName); - - if(pHash != NULL) - { - TMPQHash * pHashStart = pHash; - DWORD dwName1 = pHash->dwName1; - DWORD dwName2 = pHash->dwName2; - - while(pHash->dwBlockIndex != HASH_ENTRY_FREE) - { - if(pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2) - { - if(pHash->lcLocale == LANG_NEUTRAL) - pHash0 = pHash; - if(pHash->lcLocale == lcLocale) - pHashX = pHash; - - // If both found, break the loop - if(pHash0 != NULL && pHashX != NULL) - break; - } - - if(++pHash >= pHashEnd) - pHash = ha->pHashTable; - if(pHash == pHashStart) - return NULL; - } - - if(lcLocale != LANG_NEUTRAL && pHashX != NULL) - return pHashX; - if(pHash0 != NULL) - return pHash0; - return NULL; - } - - return pHash; -} - -// Encrypts file name and gets the hash entry -// Returns the hash pointer, which is always within the allocated array -TMPQHash * FindFreeHashEntry(TMPQArchive * ha, const char * szFileName) -{ - TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - TMPQHash * pHash0; // File hash entry (search start) - TMPQHash * pHash; // File hash entry - DWORD dwIndex = DecryptHashIndex(ha, szFileName); - DWORD dwName1 = DecryptName1(szFileName); - DWORD dwName2 = DecryptName2(szFileName); - DWORD dwBlockIndex = 0xFFFFFFFF; - - // Save the starting hash position - pHash = pHash0 = ha->pHashTable + dwIndex; - - // Look for the first free hash entry. Can be also a deleted entry - while(pHash->dwBlockIndex < HASH_ENTRY_DELETED) - { - if(++pHash >= pHashEnd) - pHash = ha->pHashTable; - if(pHash == pHash0) - return NULL; - } - - // Fill the hash entry with the informations about the file name - pHash->dwName1 = dwName1; - pHash->dwName2 = dwName2; - pHash->lcLocale = (USHORT)lcLocale; - pHash->wPlatform = wPlatform; - - // Now we have to find a free block entry - for(dwIndex = 0; dwIndex < ha->pHeader->dwBlockTableSize; dwIndex++) - { - TMPQBlock * pBlock = ha->pBlockTable + dwIndex; - - if((pBlock->dwFlags & MPQ_FILE_EXISTS) == 0) - { - dwBlockIndex = dwIndex; - break; - } - } - - // If no free block entry found, we have to use the index - // at the end of the current block table - if(dwBlockIndex == 0xFFFFFFFF) - dwBlockIndex = ha->pHeader->dwBlockTableSize; - pHash->dwBlockIndex = dwBlockIndex; - return pHash; -} - -//----------------------------------------------------------------------------- -// Checking for valid archive handle and valid file handle - -BOOL IsValidMpqHandle(TMPQArchive * ha) -{ - if(ha == NULL || IsBadReadPtr(ha, sizeof(TMPQArchive))) - return FALSE; - if(ha->pHeader == NULL || IsBadReadPtr(ha->pHeader, sizeof(TMPQHeader))) - return FALSE; - - return (ha->pHeader->dwID == ID_MPQ); -} - -BOOL IsValidFileHandle(TMPQFile * hf) -{ - if(hf == NULL || IsBadReadPtr(hf, sizeof(TMPQFile))) - return FALSE; - - if(hf->hFile != INVALID_HANDLE_VALUE) - return TRUE; - - return IsValidMpqHandle(hf->ha); -} - -// This function writes a local file into the MPQ archive. -// Returns 0 if OK, otherwise error code. -// TODO: Test for archives > 4GB -int AddFileToArchive( - TMPQArchive * ha, - HANDLE hFile, - const char * szArchivedName, - DWORD dwFlags, - DWORD dwQuality, - int nFileType, - BOOL * pbReplaced) -{ - LARGE_INTEGER RelativePos = {0}; - LARGE_INTEGER FilePos = {0}; - LARGE_INTEGER TempPos; - TMPQBlockEx * pBlockEx = NULL; // Entry in the extended block table - TMPQBlock * pBlock = NULL; // Entry in the block table - TMPQHash * pHash = NULL; // Entry in the hash table - DWORD * pdwBlockPos = NULL; // Block position table (compressed files only) - BYTE * pbFileData = NULL; // Uncompressed (source) data - BYTE * pbCompressed = NULL; // Compressed (target) data - BYTE * pbToWrite = NULL; // Data to write to the file - DWORD dwBlockPosLen = 0; // Length of the block table positions - DWORD dwTransferred = 0; // Number of bytes written into archive file - DWORD dwFileSize = 0; // Size of the file to add - DWORD dwSeed1 = 0; // Encryption seed - DWORD nBlocks = 0; // Number of file blocks - DWORD nBlock = 0; // Index of the currently written block - BOOL bReplaced = FALSE; // TRUE if replaced, FALSE if added - int nCmpFirst = nDataCmp; // Compression for the first data block - int nCmpNext = nDataCmp; // Compression for the next data blocks - int nCmp = nDataCmp; // Current compression - int nCmpLevel = -1; // Compression level - int nError = ERROR_SUCCESS; - - // Set the correct compression types - if(dwFlags & MPQ_FILE_COMPRESS_PKWARE) - nCmpFirst = nCmpNext = MPQ_COMPRESSION_PKWARE; - - if(dwFlags & MPQ_FILE_COMPRESS_MULTI) - { - if(nFileType == SFILE_TYPE_DATA) - nCmpFirst = nCmpNext = nDataCmp; - - if(nFileType == SFILE_TYPE_WAVE) - { - nCmpNext = uWaveCmpType[dwQuality]; - nCmpLevel = uWaveCmpLevel[dwQuality]; - } - } - - // Check if the file already exists in the archive - if(nError == ERROR_SUCCESS) - { - if((pHash = GetHashEntryEx(ha, szArchivedName, lcLocale)) != NULL) - { - if(pHash->lcLocale == lcLocale) - { - if((dwFlags & MPQ_FILE_REPLACEEXISTING) == 0) - { - nError = ERROR_ALREADY_EXISTS; - pHash = NULL; - } - else - bReplaced = TRUE; - } - else - pHash = NULL; - } - - if(nError == ERROR_SUCCESS && pHash == NULL) - { - pHash = FindFreeHashEntry(ha, szArchivedName); - if(pHash == NULL) - nError = ERROR_HANDLE_DISK_FULL; - } - } - - // Get the block table entry for the file - if(nError == ERROR_SUCCESS) - { - DWORD dwFileSizeHigh = 0; - - // Get the size of the added file - dwFileSize = GetFileSize(hFile, &dwFileSizeHigh); - if(dwFileSizeHigh != 0) - nError = ERROR_PARAMETER_QUOTA_EXCEEDED; - - // Fix the flags, if the file is too small - if(dwFileSize < 0x04) - dwFlags &= ~(MPQ_FILE_ENCRYPTED | MPQ_FILE_FIXSEED); - if(dwFileSize < 0x20) - dwFlags &= ~MPQ_FILE_COMPRESSED; - - if(pHash->dwBlockIndex == HASH_ENTRY_FREE) - pHash->dwBlockIndex = ha->pHeader->dwBlockTableSize; - - // The block table index cannot be larger than hash table size - if(pHash->dwBlockIndex >= ha->pHeader->dwHashTableSize) - nError = ERROR_HANDLE_DISK_FULL; - } - - // The file will be stored after the end of the last archived file - // (i.e. at old position of archived file - if(nError == ERROR_SUCCESS) - { - TMPQBlock * pBlockEnd = ha->pBlockTable + ha->pHeader->dwBlockTableSize; - const char * szTemp = strrchr(szArchivedName, '\\'); - - // Get the position of the first file - RelativePos.QuadPart = ha->pHeader->dwHeaderSize; - - // Find the position of the last file. It has to be after the last archived file - // (Do not use the dwArchiveSize here, because it may or may not - // include the hash table at the end of the file - pBlockEx = ha->pExtBlockTable; - for(pBlock = ha->pBlockTable; pBlock < pBlockEnd; pBlock++, pBlockEx++) - { - if(pBlock->dwFlags & MPQ_FILE_EXISTS) - { - TempPos.HighPart = pBlockEx->wFilePosHigh; - TempPos.LowPart = pBlock->dwFilePos; - TempPos.QuadPart += pBlock->dwCSize; - - if(TempPos.QuadPart > RelativePos.QuadPart) - RelativePos = TempPos; - } - } - - // When format V1, we cannot exceed 4 GB - if(ha->pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1) - { - TempPos.QuadPart = ha->MpqPos.QuadPart + RelativePos.QuadPart; - TempPos.QuadPart += ha->pHeader->dwHashTableSize * sizeof(TMPQHash); - TempPos.QuadPart += ha->pHeader->dwBlockTableSize * sizeof(TMPQBlock); - TempPos.QuadPart += dwFileSize; - - if(TempPos.HighPart != 0) - nError = ERROR_DISK_FULL; - } - - // Get pointers to both block entries of the file - pBlockEx = ha->pExtBlockTable + pHash->dwBlockIndex; - pBlock = ha->pBlockTable + pHash->dwBlockIndex; - - // Save the file size info - pBlockEx->wFilePosHigh = (USHORT)RelativePos.HighPart; - pBlock->dwFilePos = RelativePos.LowPart; - pBlock->dwFSize = GetFileSize(hFile, NULL); - pBlock->dwFlags = dwFlags | MPQ_FILE_EXISTS; - - // Create seed1 for file encryption - if(szTemp != NULL) - szArchivedName = szTemp + 1; - - if(dwFlags & MPQ_FILE_ENCRYPTED) - { - dwSeed1 = DecryptFileSeed(szArchivedName); - - if(dwFlags & MPQ_FILE_FIXSEED) - dwSeed1 = (dwSeed1 + pBlock->dwFilePos) ^ pBlock->dwFSize; - } - } - - // Allocate buffer for the input data - if(nError == ERROR_SUCCESS) - { - nBlocks = (pBlock->dwFSize / ha->dwBlockSize) + 1; - if(pBlock->dwFSize % ha->dwBlockSize) - nBlocks++; - - pBlock->dwCSize = 0; - if((pbFileData = ALLOCMEM(BYTE, ha->dwBlockSize)) == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - pbToWrite = pbFileData; - } - - // Allocate buffers for the compressed data - if(nError == ERROR_SUCCESS && (dwFlags & MPQ_FILE_COMPRESSED)) - { - pdwBlockPos = ALLOCMEM(DWORD, nBlocks + 1); - pbCompressed = ALLOCMEM(BYTE, ha->dwBlockSize * 2); - if(pdwBlockPos == NULL || pbCompressed == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - pbToWrite = pbCompressed; - } - - // Set the file position to the point where the file will be stored - if(nError == ERROR_SUCCESS) - { - // Set the file pointer to file data position - FilePos.QuadPart = ha->MpqPos.QuadPart + RelativePos.QuadPart; - if(FilePos.QuadPart != ha->FilePointer.QuadPart) - { - SetFilePointer(ha->hFile, FilePos.LowPart, &FilePos.HighPart, FILE_BEGIN); - ha->FilePointer = FilePos; - } - } - - // Write block positions (if the file will be compressed) - if(nError == ERROR_SUCCESS && (dwFlags & MPQ_FILE_COMPRESSED)) - { - dwBlockPosLen = nBlocks * sizeof(DWORD); - if(dwFlags & MPQ_FILE_HAS_EXTRA) - dwBlockPosLen += sizeof(DWORD); - - memset(pdwBlockPos, 0, dwBlockPosLen); - pdwBlockPos[0] = dwBlockPosLen; - - // Write the block positions - BSWAP_ARRAY32_UNSIGNED((DWORD *)pdwBlockPos, nBlocks); - WriteFile(ha->hFile, pdwBlockPos, dwBlockPosLen, &dwTransferred, NULL); - BSWAP_ARRAY32_UNSIGNED((DWORD *)pdwBlockPos, nBlocks); - - if(dwTransferred == dwBlockPosLen) - pBlock->dwCSize += dwBlockPosLen; - else - nError = GetLastError(); - - // Update the current position in the file - ha->HashTablePos.QuadPart = FilePos.QuadPart + dwTransferred; - } - - // Write all file blocks - if(nError == ERROR_SUCCESS) - { - nCmp = nCmpFirst; - - SetFilePointer(hFile, 0, NULL, FILE_BEGIN); - for(nBlock = 0; nBlock < nBlocks-1; nBlock++) - { - DWORD dwInLength = ha->dwBlockSize; - DWORD dwOutLength = ha->dwBlockSize; - - // Load the block from the file - ReadFile(hFile, pbFileData, ha->dwBlockSize, &dwInLength, NULL); - if(dwInLength == 0) - break; - - // Compress the block, if necessary - dwOutLength = dwInLength; - if(pBlock->dwFlags & MPQ_FILE_COMPRESSED) - { - // Should be enough for compression - int nOutLength = ha->dwBlockSize * 2; - int nCmpType = 0; - - if(pBlock->dwFlags & MPQ_FILE_COMPRESS_PKWARE) - Compress_pklib((char *)pbCompressed, &nOutLength, (char *)pbFileData, dwInLength, &nCmpType, 0); - - if(pBlock->dwFlags & MPQ_FILE_COMPRESS_MULTI) - SCompCompress((char *)pbCompressed, &nOutLength, (char *)pbFileData, dwInLength, nCmp, 0, nCmpLevel); - - // The compressed block size must NOT be the same or greater like - // the original block size. If yes, do not compress the block - // and store the data as-is. - if(nOutLength >= (int)dwInLength) - { - memcpy(pbCompressed, pbFileData, dwInLength); - nOutLength = dwInLength; - } - - // Update block positions - dwOutLength = nOutLength; - pdwBlockPos[nBlock+1] = pdwBlockPos[nBlock] + dwOutLength; - nCmp = nCmpNext; - } - - // Encrypt the block, if necessary - if(pBlock->dwFlags & MPQ_FILE_ENCRYPTED) - { - BSWAP_ARRAY32_UNSIGNED((DWORD *)pbToWrite, dwOutLength / sizeof(DWORD)); - EncryptMPQBlock((DWORD *)pbToWrite, dwOutLength, dwSeed1 + nBlock); - BSWAP_ARRAY32_UNSIGNED((DWORD *)pbToWrite, dwOutLength / sizeof(DWORD)); - } - - // Write the block - WriteFile(ha->hFile, pbToWrite, dwOutLength, &dwTransferred, NULL); - if(dwTransferred != dwOutLength) - { - nError = ERROR_DISK_FULL; - break; - } - - // Update the hash table position and the compressed file size - ha->HashTablePos.QuadPart += dwTransferred; - pBlock->dwCSize += dwOutLength; - } - } - - // Now save the block positions - if(nError == ERROR_SUCCESS && (pBlock->dwFlags & MPQ_FILE_COMPRESSED)) - { - if(dwFlags & MPQ_FILE_HAS_EXTRA) - pdwBlockPos[nBlocks] = pdwBlockPos[nBlocks-1]; - - // If file is encrypted, block positions are also encrypted - if(dwFlags & MPQ_FILE_ENCRYPTED) - EncryptMPQBlock(pdwBlockPos, dwBlockPosLen, dwSeed1 - 1); - - // Set the position back to the block table - SetFilePointer(ha->hFile, FilePos.LowPart, &FilePos.HighPart, FILE_BEGIN); - - // Write block positions to the archive - BSWAP_ARRAY32_UNSIGNED((DWORD *)pdwBlockPos, nBlocks); - WriteFile(ha->hFile, pdwBlockPos, dwBlockPosLen, &dwTransferred, NULL); - if(dwTransferred != dwBlockPosLen) - nError = ERROR_DISK_FULL; - - ha->FilePointer.QuadPart = ha->FilePointer.QuadPart + dwTransferred; - } - - // If success, we have to change the settings - // in MPQ header. If failed, we have to clean hash entry - if(nError == ERROR_SUCCESS) - { - ha->pLastFile = NULL; - ha->dwBlockPos = 0; - ha->dwBuffPos = 0; - ha->dwFlags |= MPQ_FLAG_CHANGED; - - // Add new entry to the block table (if needed) - if(pHash->dwBlockIndex >= ha->pHeader->dwBlockTableSize) - ha->pHeader->dwBlockTableSize++; - - // Hash table size in the TMPQArchive is already set at this point - RelativePos.QuadPart = ha->HashTablePos.QuadPart - ha->MpqPos.QuadPart; - ha->pHeader->dwHashTablePos = RelativePos.LowPart; - ha->pHeader->wHashTablePosHigh = (USHORT)RelativePos.HighPart; - - // Update block table pos - RelativePos.QuadPart += (ha->pHeader->dwHashTableSize * sizeof(TMPQHash)); - ha->pHeader->wBlockTablePosHigh = (USHORT)RelativePos.HighPart; - ha->pHeader->dwBlockTablePos = RelativePos.LowPart; - ha->BlockTablePos.QuadPart = RelativePos.QuadPart + ha->MpqPos.QuadPart; - - // If the archive size exceeded 4GB, we have to use extended block table pos - RelativePos.QuadPart += (ha->pHeader->dwBlockTableSize * sizeof(TMPQBlock)); - if(RelativePos.HighPart != 0) - { - ha->pHeader->ExtBlockTablePos = RelativePos; - ha->ExtBlockTablePos.QuadPart = RelativePos.QuadPart + ha->MpqPos.QuadPart; - - RelativePos.QuadPart += (ha->pHeader->dwBlockTableSize * sizeof(TMPQBlockEx)); - } - - // Update archive size (only valid for version V1) - ha->MpqSize = RelativePos; - ha->pHeader->dwArchiveSize = ha->MpqSize.LowPart; - } - else - { - // Clear the hash table entry - if(pHash != NULL) - memset(pHash, 0xFF, sizeof(TMPQHash)); - } - - // Cleanup - if(pbCompressed != NULL) - FREEMEM(pbCompressed); - if(pdwBlockPos != NULL) - FREEMEM(pdwBlockPos); - if(pbFileData != NULL) - FREEMEM(pbFileData); - if(pbReplaced != NULL) - *pbReplaced = bReplaced; - return nError; -} - -int SetDataCompression(int nDataCompression) -{ - nDataCmp = nDataCompression; - return 0; -} - -// This method saves MPQ header, hash table and block table. -// TODO: Test for archives > 4GB -int SaveMPQTables(TMPQArchive * ha) -{ - BYTE * pbBuffer = NULL; - DWORD dwBytes; - DWORD dwWritten; - DWORD dwBuffSize = max(ha->pHeader->dwHashTableSize, ha->pHeader->dwBlockTableSize); - int nError = ERROR_SUCCESS; - - // Allocate buffer for encrypted tables - if(nError == ERROR_SUCCESS) - { - // Allocate temporary buffer for tables encryption - pbBuffer = ALLOCMEM(BYTE, sizeof(TMPQHash) * dwBuffSize); - if(pbBuffer == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Write the MPQ Header - if(nError == ERROR_SUCCESS) - { - DWORD dwHeaderSize = ha->pHeader->dwHeaderSize; - - // Write the MPQ header - SetFilePointer(ha->hFile, ha->MpqPos.LowPart, &ha->MpqPos.HighPart, FILE_BEGIN); - - // Convert to little endian for file save - BSWAP_TMPQHEADER(ha->pHeader); - WriteFile(ha->hFile, ha->pHeader, dwHeaderSize, &dwWritten, NULL); - BSWAP_TMPQHEADER(ha->pHeader); - - if(dwWritten != ha->pHeader->dwHeaderSize) - nError = ERROR_DISK_FULL; - } - - // Write the hash table - if(nError == ERROR_SUCCESS) - { - // Copy the hash table to temporary buffer - dwBytes = ha->pHeader->dwHashTableSize * sizeof(TMPQHash); - memcpy(pbBuffer, ha->pHashTable, dwBytes); - - // Convert to little endian for file save - EncryptHashTable((DWORD *)pbBuffer, (BYTE *)"(hash table)", dwBytes >> 2); - BSWAP_ARRAY32_UNSIGNED((DWORD *)pbBuffer, dwBytes / sizeof(DWORD)); - - // Set the file pointer to the offset of the hash table and write it - SetFilePointer(ha->hFile, ha->HashTablePos.LowPart, (PLONG)&ha->HashTablePos.HighPart, FILE_BEGIN); - WriteFile(ha->hFile, pbBuffer, dwBytes, &dwWritten, NULL); - if(dwWritten != dwBytes) - nError = ERROR_DISK_FULL; - } - - // Write the block table - if(nError == ERROR_SUCCESS) - { - // Copy the block table to temporary buffer - dwBytes = ha->pHeader->dwBlockTableSize * sizeof(TMPQBlock); - memcpy(pbBuffer, ha->pBlockTable, dwBytes); - - // Encrypt the block table and write it to the file - EncryptBlockTable((DWORD *)pbBuffer, (BYTE *)"(block table)", dwBytes >> 2); - - // Convert to little endian for file save - BSWAP_ARRAY32_UNSIGNED((DWORD *)pbBuffer, dwBytes / sizeof(DWORD)); - WriteFile(ha->hFile, pbBuffer, dwBytes, &dwWritten, NULL); - if(dwWritten != dwBytes) - nError = ERROR_DISK_FULL; - } - - // Write the extended block table - if(nError == ERROR_SUCCESS && ha->pHeader->ExtBlockTablePos.QuadPart != 0) - { - // We expect format V2 or newer in this case - assert(ha->pHeader->wFormatVersion >= MPQ_FORMAT_VERSION_2); - - // Copy the block table to temporary buffer - dwBytes = ha->pHeader->dwBlockTableSize * sizeof(TMPQBlockEx); - memcpy(pbBuffer, ha->pExtBlockTable, dwBytes); - - // Convert to little endian for file save - BSWAP_ARRAY16_UNSIGNED((USHORT *)pbBuffer, dwBytes / sizeof(USHORT)); - WriteFile(ha->hFile, pbBuffer, dwBytes, &dwWritten, NULL); - if(dwWritten != dwBytes) - nError = ERROR_DISK_FULL; - } - - - // Set end of file here - if(nError == ERROR_SUCCESS) - { - SetEndOfFile(ha->hFile); - } - - // Cleanup and exit - if(pbBuffer != NULL) - FREEMEM(pbBuffer); - return nError; -} - -// Frees the MPQ archive -// TODO: Test for archives > 4GB -void FreeMPQArchive(TMPQArchive *& ha) -{ - if(ha != NULL) - { - FREEMEM(ha->pbBlockBuffer); - FREEMEM(ha->pBlockTable); - FREEMEM(ha->pExtBlockTable); - FREEMEM(ha->pHashTable); - if(ha->pListFile != NULL) - SListFileFreeListFile(ha); - - if(ha->hFile != INVALID_HANDLE_VALUE) - CloseHandle(ha->hFile); - FREEMEM(ha); - ha = NULL; - } -} diff --git a/contrib/vmap_extractor_v2/stormlib/SCommon.h b/contrib/vmap_extractor_v2/stormlib/SCommon.h deleted file mode 100644 index b53be0ae2a8..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/SCommon.h +++ /dev/null @@ -1,88 +0,0 @@ -/*****************************************************************************/ -/* SCommon.h Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Common functions for encryption/decryption from Storm.dll. Included by */ -/* SFile*** functions, do not include and do not use this file directly */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 24.03.03 1.00 Lad The first version of SFileCommon.h */ -/* 12.06.04 1.00 Lad Renamed to SCommon.h */ -/*****************************************************************************/ - -#ifndef __SCOMMON_H__ -#define __SCOMMON_H__ - -//----------------------------------------------------------------------------- -// StormLib private defines - -#define SFILE_TYPE_DATA 0 // Process the file as data file -#define SFILE_TYPE_WAVE 1 // Process the file as WAVe file - -//----------------------------------------------------------------------------- -// External variables - -extern TMPQArchive * pFirstOpen; -extern LCID lcLocale; - -//----------------------------------------------------------------------------- -// Encryption and decryption functions - -int PrepareStormBuffer(); - -void EncryptHashTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength); -void DecryptHashTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength); -TMPQHash * FindFreeHashEntry(TMPQArchive * ha, const char * szFileName); - -void EncryptBlockTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength); -void DecryptBlockTable(DWORD * pdwTable, BYTE * pbKey, DWORD dwLength); - -DWORD DetectFileSeed(DWORD * block, DWORD decrypted); -DWORD DetectFileSeed2(DWORD * block, UINT nDwords, ...); -void EncryptMPQBlock(DWORD * pdwBlock, DWORD dwLength, DWORD dwSeed1); -void DecryptMPQBlock(DWORD * pdwBlock, DWORD dwLength, DWORD dwSeed1); - -DWORD DecryptHashIndex(TMPQArchive * ha, const char * szFileName); -DWORD DecryptName1 (const char * szFileName); -DWORD DecryptName2 (const char * szFileName); -DWORD DecryptFileSeed (const char * szFileName); - -TMPQHash * GetHashEntry (TMPQArchive * ha, const char * szFileName); -TMPQHash * GetHashEntryEx(TMPQArchive * ha, const char * szFileName, LCID lcLocale); - -//----------------------------------------------------------------------------- -// Compression and decompression functions - -int Compress_pklib (char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int * pCmpType, int nCmpLevel); -int Decompress_pklib(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength); - -//----------------------------------------------------------------------------- -// Checking functions - -BOOL IsValidMpqHandle(TMPQArchive * ha); -BOOL IsValidFileHandle(TMPQFile * hf); - -//----------------------------------------------------------------------------- -// Other functions - -BOOL SFileOpenArchiveEx(const char * szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE * phMPQ, DWORD dwAccessMode = GENERIC_READ); -int AddFileToArchive(TMPQArchive * ha, HANDLE hFile, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality, int nFileType, BOOL * pbReplaced); -int SetDataCompression(int nDataCompression); -int SaveMPQTables(TMPQArchive * ha); -void FreeMPQArchive(TMPQArchive *& ha); - -BOOL CheckWildCard(const char * szString, const char * szWildCard); - -//----------------------------------------------------------------------------- -// Listfile functions - -int SListFileCreateListFile(TMPQArchive * ha); -int SListFileAddNode(TMPQArchive * ha, const char * szAddedFile); -int SListFileRemoveNode(TMPQArchive * ha, const char * szFileName); -int SListFileRenameNode(TMPQArchive * ha, const char * szOldFileName, const char * szNewFileName); -int SListFileFreeListFile(TMPQArchive * ha); - -int SListFileSaveToMpq(TMPQArchive * ha); - -#endif // __SCOMMON_H__ - diff --git a/contrib/vmap_extractor_v2/stormlib/SCompression.cpp b/contrib/vmap_extractor_v2/stormlib/SCompression.cpp deleted file mode 100644 index 612ef2cc262..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/SCompression.cpp +++ /dev/null @@ -1,715 +0,0 @@ -/*****************************************************************************/ -/* SCompression.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* This module serves as a bridge between StormLib code and (de)compression */ -/* functions. All (de)compression calls go (and should only go) through this */ -/* module. No system headers should be included in this module to prevent */ -/* compile-time problems. */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 01.04.03 1.00 Lad The first version of SCompression.cpp */ -/* 19.11.03 1.01 Dan Big endian handling */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "SCommon.h" - -#include - -// Include functions from Pkware Data Compression Library -#include "pklib/pklib.h" - -// Include functions from zlib -#ifndef __SYS_ZLIB -#include "zlib/zlib.h" // Include functions from zlib -#else -#include // If zlib is available on system, use this instead -#endif - -// Include functions from Huffmann compression -#include "huffman/huff.h" - -// Include functions from WAVe compression -#include "wave/wave.h" - -// Include functions from BZip2 compression library -#ifndef __SYS_BZLIB -#include "bzip2/bzlib.h" // Include functions from bzlib -#else -#include // If bzlib is available on system, use this instead -#endif - -//----------------------------------------------------------------------------- -// Local structures - -// Information about the input and output buffers for pklib -typedef struct -{ - char * pInBuff; // Pointer to input data buffer - int nInPos; // Current offset in input data buffer - int nInBytes; // Number of bytes in the input buffer - char * pOutBuff; // Pointer to output data buffer - int nOutPos; // Position in the output buffer - int nMaxOut; // Maximum number of bytes in the output buffer -} TDataInfo; - -// Table of compression functions -typedef int (*COMPRESS)(char *, int *, char *, int, int *, int); -typedef struct -{ - unsigned long dwMask; // Compression mask - COMPRESS Compress; // Compression function -} TCompressTable; - -// Table of decompression functions -typedef int (*DECOMPRESS)(char *, int *, char *, int); -typedef struct -{ - unsigned long dwMask; // Decompression bit - DECOMPRESS Decompress; // Decompression function -} TDecompressTable; - - -/*****************************************************************************/ -/* */ -/* Support functions for Pkware Data Compression Library */ -/* */ -/*****************************************************************************/ - -// Function loads data from the input buffer. Used by Pklib's "implode" -// and "explode" function as user-defined callback -// Returns number of bytes loaded -// -// char * buf - Pointer to a buffer where to store loaded data -// unsigned int * size - Max. number of bytes to read -// void * param - Custom pointer, parameter of implode/explode - -static unsigned int ReadInputData(char * buf, unsigned int * size, void * param) -{ - TDataInfo * pInfo = (TDataInfo *)param; - unsigned int nMaxAvail = (pInfo->nInBytes - pInfo->nInPos); - unsigned int nToRead = *size; - - // Check the case when not enough data available - if(nToRead > nMaxAvail) - nToRead = nMaxAvail; - - // Load data and increment offsets - memcpy(buf, pInfo->pInBuff + pInfo->nInPos, nToRead); - pInfo->nInPos += nToRead; - - return nToRead; -} - -// Function for store output data. Used by Pklib's "implode" and "explode" -// as user-defined callback -// -// char * buf - Pointer to data to be written -// unsigned int * size - Number of bytes to write -// void * param - Custom pointer, parameter of implode/explode - -static void WriteOutputData(char * buf, unsigned int * size, void * param) -{ - TDataInfo * pInfo = (TDataInfo *)param; - unsigned int nMaxWrite = (pInfo->nMaxOut - pInfo->nOutPos); - unsigned int nToWrite = *size; - - // Check the case when not enough space in the output buffer - if(nToWrite > nMaxWrite) - nToWrite = nMaxWrite; - - // Write output data and increments offsets - memcpy(pInfo->pOutBuff + pInfo->nOutPos, buf, nToWrite); - pInfo->nOutPos += nToWrite; -} - -/*****************************************************************************/ -/* */ -/* "80" is IMA ADPCM stereo (de)compression */ -/* "40" is IMA ADPCM mono (de)compression */ -/* */ -/*****************************************************************************/ - -int Compress_wave_mono(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int * pCmpType, int nCmpLevel) -{ - // Prepare the compression level for the next compression - // (After us, the Huffmann compression will be called) - if(0 < nCmpLevel && nCmpLevel <= 2) - { - nCmpLevel = 4; - *pCmpType = 6; - } - else if(nCmpLevel == 3) - { - nCmpLevel = 6; - *pCmpType = 8; - } - else - { - nCmpLevel = 5; - *pCmpType = 7; - } - *pdwOutLength = CompressWave((unsigned char *)pbOutBuffer, *pdwOutLength, (short *)pbInBuffer, dwInLength, 1, nCmpLevel); - return 0; -} - -int Decompress_wave_mono(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength) -{ - *pdwOutLength = DecompressWave((unsigned char *)pbOutBuffer, *pdwOutLength, (unsigned char *)pbInBuffer, dwInLength, 1); - return 1; -} - -int Compress_wave_stereo(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int * pCmpType, int nCmpLevel) -{ - // Prepare the compression type for the next compression - // (After us, the Huffmann compression will be called) - if(0 < nCmpLevel && nCmpLevel <= 2) - { - nCmpLevel = 4; - *pCmpType = 6; - } - else if(nCmpLevel == 3) - { - nCmpLevel = 6; - *pCmpType = 8; - } - else - { - nCmpLevel = 5; - *pCmpType = 7; - } - *pdwOutLength = CompressWave((unsigned char *)pbOutBuffer, *pdwOutLength, (short *)pbInBuffer, dwInLength, 2, nCmpLevel); - return 0; -} - -int Decompress_wave_stereo(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength) -{ - *pdwOutLength = DecompressWave((unsigned char *)pbOutBuffer, *pdwOutLength, (unsigned char *)pbInBuffer, dwInLength, 2); - return 1; -} - -/*****************************************************************************/ -/* */ -/* The "01" (de)compression is the Huffman (de)compression */ -/* */ -/*****************************************************************************/ - -// 1500F4C0 -int Compress_huff(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int * pCmpType, int /* nCmpLevel */) -{ - THuffmannTree ht; // Huffmann tree for compression - TOutputStream os; // Output stream - - // Initialize output stream - os.pbOutBuffer = (unsigned char *)pbOutBuffer; - os.dwOutSize = *pdwOutLength; - os.pbOutPos = (unsigned char *)pbOutBuffer; - os.dwBitBuff = 0; - os.nBits = 0; - - // Initialize the Huffmann tree for compression - ht.InitTree(true); - - *pdwOutLength = ht.DoCompression(&os, (unsigned char *)pbInBuffer, dwInLength, *pCmpType); - - // The following code is not necessary to run, because it has no - // effect on the output data. It only clears the huffmann tree, but when - // the tree is on the stack, who cares ? -// ht.UninitTree(); - return 0; -} - -// 1500F5F0 -int Decompress_huff(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int /* dwInLength */) -{ - THuffmannTree ht; - TInputStream is; - - // Initialize input stream -// is.pbInBuffer = (unsigned char *)pbInBuffer; - is.dwBitBuff = BSWAP_INT32_UNSIGNED(*(unsigned long *)pbInBuffer); - pbInBuffer += sizeof(unsigned long); - is.pbInBuffer = (unsigned char *)pbInBuffer; - is.nBits = 32; - - // Initialize the Huffmann tree for compression - ht.InitTree(false); - *pdwOutLength = ht.DoDecompression((unsigned char *)pbOutBuffer, *pdwOutLength, &is); - - // The following code is not necessary to run, because it has no - // effect on the output data. It only clears the huffmann tree, but when - // the tree is on the stack, who cares ? -// ht.UninitTree(); - return 0; -} - -/*****************************************************************************/ -/* */ -/* The "02" (de)compression is the ZLIB (de)compression */ -/* */ -/*****************************************************************************/ - -int Compress_zlib(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int * /* pCmpType */, int /* nCmpLevel */) -{ - z_stream z; // Stream information for zlib - int nResult; - - // Fill the stream structure for zlib - z.next_in = (Bytef *)pbInBuffer; - z.avail_in = (uInt)dwInLength; - z.total_in = dwInLength; - z.next_out = (Bytef *)pbOutBuffer; - z.avail_out = *pdwOutLength; - z.total_out = 0; - z.zalloc = NULL; - z.zfree = NULL; - - // Initialize the compression structure. Storm.dll uses zlib version 1.1.3 - *pdwOutLength = 0; - if((nResult = deflateInit(&z, Z_DEFAULT_COMPRESSION)) == 0) - { - // Call zlib to compress the data - nResult = deflate(&z, Z_FINISH); - - if(nResult == Z_OK || nResult == Z_STREAM_END) - *pdwOutLength = z.total_out; - - deflateEnd(&z); - } - return nResult; -} - -int Decompress_zlib(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength) -{ - z_stream z; // Stream information for zlib - int nResult; - - // Fill the stream structure for zlib - z.next_in = (Bytef *)pbInBuffer; - z.avail_in = (uInt)dwInLength; - z.total_in = dwInLength; - z.next_out = (Bytef *)pbOutBuffer; - z.avail_out = *pdwOutLength; - z.total_out = 0; - z.zalloc = NULL; - z.zfree = NULL; - - // Initialize the decompression structure. Storm.dll uses zlib version 1.1.3 - if((nResult = inflateInit(&z)) == 0) - { - // Call zlib to decompress the data - nResult = inflate(&z, Z_FINISH); - *pdwOutLength = z.total_out; - inflateEnd(&z); - } - return nResult; -} - -/*****************************************************************************/ -/* */ -/* The "08" (de)compression is the Pkware DCL (de)compression */ -/* */ -/*****************************************************************************/ - -int Compress_pklib(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int * pCmpType, int /* nCmpLevel */) -{ - TDataInfo Info; // Data information - char * work_buf = ALLOCMEM(char, CMP_BUFFER_SIZE);// Pklib's work buffer - unsigned int dict_size; // Dictionary size - unsigned int ctype; // Compression type - - // Fill data information structure - Info.pInBuff = pbInBuffer; - Info.nInPos = 0; - Info.nInBytes = dwInLength; - Info.pOutBuff = pbOutBuffer; - Info.nOutPos = 0; - Info.nMaxOut = *pdwOutLength; - - // Set the compression type and dictionary size - ctype = (*pCmpType == 2) ? CMP_ASCII : CMP_BINARY; - if (dwInLength < 0x600) - dict_size = 0x400; - else if(0x600 <= dwInLength && dwInLength < 0xC00) - dict_size = 0x800; - else - dict_size = 0x1000; - - // Do the compression - implode(ReadInputData, WriteOutputData, work_buf, &Info, &ctype, &dict_size); - *pdwOutLength = Info.nOutPos; - FREEMEM(work_buf); - return 0; -} - -int Decompress_pklib(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength) -{ - TDataInfo Info; // Data information - char * work_buf = ALLOCMEM(char, EXP_BUFFER_SIZE);// Pklib's work buffer - - // Fill data information structure - Info.pInBuff = pbInBuffer; - Info.nInPos = 0; - Info.nInBytes = dwInLength; - Info.pOutBuff = pbOutBuffer; - Info.nOutPos = 0; - Info.nMaxOut = *pdwOutLength; - - // Do the decompression - explode(ReadInputData, WriteOutputData, work_buf, &Info); - - // Fix: If PKLIB is unable to decompress the data, they are uncompressed - if(Info.nOutPos == 0) - { - Info.nOutPos = min(*pdwOutLength, dwInLength); - memcpy(pbOutBuffer, pbInBuffer, Info.nOutPos); - } - - *pdwOutLength = Info.nOutPos; - FREEMEM(work_buf); - return 0; -} - -/*****************************************************************************/ -/* */ -/* The "10" (de)compression is the Bzip2 (de)compression */ -/* */ -/*****************************************************************************/ - -int Compress_bzip2(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int * pCmpType, int nCmpLevel) -{ - bz_stream strm; - int blockSize100k; - int workFactor = 30; - - // Keep compiler happy - nCmpLevel = nCmpLevel; - - // Initialize the BZLIB compression - strm.bzalloc = NULL; - strm.bzfree = NULL; - - // Adjust the block size - blockSize100k = *pCmpType; - if(blockSize100k < 1 || blockSize100k > 9) - blockSize100k = 9; - - // Blizzard uses 9 as blockSize100k, (0 as workFactor) - if(BZ2_bzCompressInit(&strm, blockSize100k, 0, workFactor) == 0) - { - strm.next_in = pbInBuffer; - strm.avail_in = dwInLength; - strm.next_out = pbOutBuffer; - strm.avail_out = *pdwOutLength; - - // Perform the compression - while(BZ2_bzCompress(&strm, (strm.avail_in != 0) ? BZ_RUN : BZ_FINISH) != BZ_STREAM_END); - - // Put the stream into idle state - BZ2_bzCompressEnd(&strm); - *pdwOutLength = strm.total_out_lo32; - } - else - { - *pdwOutLength = 0; - } - - return 0; -} - -int Decompress_bzip2(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength) -{ - bz_stream strm; - - // Initialize the BZLIB decompression - strm.bzalloc = NULL; - strm.bzfree = NULL; - if(BZ2_bzDecompressInit(&strm, 0, 0) == 0) - { - strm.next_in = pbInBuffer; - strm.avail_in = dwInLength; - strm.next_out = pbOutBuffer; - strm.avail_out = *pdwOutLength; - - // Perform the decompression - while(BZ2_bzDecompress(&strm) != BZ_STREAM_END); - - // Put the stream into idle state - BZ2_bzDecompressEnd(&strm); - *pdwOutLength = strm.total_out_lo32; - } - else - { - // Set zero output length - *pdwOutLength = 0; - } - - return 0; -} - -/*****************************************************************************/ -/* */ -/* SCompCompress */ -/* */ -/*****************************************************************************/ - -// This table contains compress functions which can be applied to -// uncompressed blocks. Each bit set means the corresponding -// compression method/function must be applied. -// -// WAVes compression Data compression -// ------------------ ------------------- -// 1st block - 0x08 0x08 (D, HF, W2, SC, D2) -// Rest blocks - 0x81 0x02 (W3) - -static TCompressTable cmp_table[] = -{ - {MPQ_COMPRESSION_WAVE_MONO, Compress_wave_mono}, // IMA ADPCM mono compression - {MPQ_COMPRESSION_WAVE_STEREO, Compress_wave_stereo}, // IMA ADPCM stereo compression - {MPQ_COMPRESSION_HUFFMANN, Compress_huff}, // Huffmann compression - {MPQ_COMPRESSION_ZLIB, Compress_zlib}, // Compression with the "zlib" library - {MPQ_COMPRESSION_PKWARE, Compress_pklib}, // Compression with Pkware DCL - {MPQ_COMPRESSION_BZIP2, Compress_bzip2} // Compression Bzip2 library -}; - -int WINAPI SCompCompress(char * pbCompressed, int * pdwOutLength, char * pbUncompressed, int dwInLength, - int uCompressions, int nCmpType, int nCmpLevel) -{ - char * pbTempBuff = NULL; // Temporary storage for decompressed data - char * pbOutput = pbCompressed; // Current output buffer - char * pbInput; // Current input buffer - int uCompressions2; - int dwCompressCount = 0; - int dwDoneCount = 0; - int dwOutSize = 0; - int dwInSize = dwInLength; - int dwEntries = (sizeof(cmp_table) / sizeof(TCompressTable)); - int nResult = 1; - int i; - - // Check for valid parameters - if(!pdwOutLength || *pdwOutLength < dwInLength || !pbCompressed || !pbUncompressed) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - - // Count the compressions - for(i = 0, uCompressions2 = uCompressions; i < dwEntries; i++) - { - if(uCompressions & cmp_table[i].dwMask) - dwCompressCount++; - - uCompressions2 &= ~cmp_table[i].dwMask; - } - - // If a compression remains, do nothing - if(uCompressions2 != 0) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - - // If more that one compression, allocate intermediate buffer - if(dwCompressCount >= 2) - pbTempBuff = ALLOCMEM(char, *pdwOutLength + 1); - - // Perform the compressions - pbInput = pbUncompressed; - dwInSize = dwInLength; - for(i = 0, uCompressions2 = uCompressions; i < dwEntries; i++) - { - if(uCompressions2 & cmp_table[i].dwMask) - { - // Set the right output buffer - dwCompressCount--; - pbOutput = (dwCompressCount & 1) ? pbTempBuff : pbCompressed; - - // Perform the partial compression - dwOutSize = *pdwOutLength - 1; - - cmp_table[i].Compress(pbOutput + 1, &dwOutSize, pbInput, dwInSize, &nCmpType, nCmpLevel); - if(dwOutSize == 0) - { - SetLastError(ERROR_GEN_FAILURE); - *pdwOutLength = 0; - nResult = 0; - break; - } - - // If the compression failed, copy the block instead - if(dwOutSize >= dwInSize - 1) - { - if(dwDoneCount > 0) - pbOutput++; - - memcpy(pbOutput, pbInput, dwInSize); - pbInput = pbOutput; - uCompressions &= ~cmp_table[i].dwMask; - dwOutSize = dwInSize; - } - else - { - pbInput = pbOutput + 1; - dwInSize = dwOutSize; - dwDoneCount++; - } - } - } - - // Copy the compressed data to the correct output buffer - if(nResult != 0) - { - if(uCompressions && (dwInSize + 1) < *pdwOutLength) - { - if(pbOutput != pbCompressed && pbOutput != pbCompressed + 1) - memcpy(pbCompressed, pbOutput, dwInSize); - *pbCompressed = (char)uCompressions; - *pdwOutLength = dwInSize + 1; - } - else - { - memmove(pbCompressed, pbUncompressed, dwInSize); - *pdwOutLength = dwInSize; - } - } - - // Cleanup and return - if(pbTempBuff != NULL) - FREEMEM(pbTempBuff); - return nResult; -} - -/*****************************************************************************/ -/* */ -/* SCompDecompress */ -/* */ -/*****************************************************************************/ - -// This table contains decompress functions which can be applied to -// uncompressed blocks. The compression mask is stored in the first byte -// of compressed block -static TDecompressTable dcmp_table[] = -{ - {MPQ_COMPRESSION_BZIP2, Decompress_bzip2}, // Decompression with Bzip2 library - {MPQ_COMPRESSION_PKWARE, Decompress_pklib}, // Decompression with Pkware Data Compression Library - {MPQ_COMPRESSION_ZLIB, Decompress_zlib}, // Decompression with the "zlib" library - {MPQ_COMPRESSION_HUFFMANN, Decompress_huff}, // Huffmann decompression - {MPQ_COMPRESSION_WAVE_STEREO, Decompress_wave_stereo}, // IMA ADPCM stereo decompression - {MPQ_COMPRESSION_WAVE_MONO, Decompress_wave_mono} // IMA ADPCM mono decompression -}; - -int WINAPI SCompDecompress(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength) -{ - char * pbTempBuff = NULL; // Temporary storage for decompressed data - char * pbWorkBuff = NULL; // Where to store decompressed data - int dwOutLength = *pdwOutLength; // For storage number of output bytes - unsigned fDecompressions1; // Decompressions applied to the block - unsigned fDecompressions2; // Just another copy of decompressions applied to the block - int dwCount = 0; // Counter for every use - int dwEntries = (sizeof(dcmp_table) / sizeof(TDecompressTable)); - int nResult = 1; - int i; - - // If the input length is the same as output, do nothing. - if(dwInLength == dwOutLength) - { - if(pbInBuffer == pbOutBuffer) - return 1; - - memcpy(pbOutBuffer, pbInBuffer, dwInLength); - *pdwOutLength = dwInLength; - return 1; - } - - // Get applied compression types and decrement data length - fDecompressions1 = fDecompressions2 = (unsigned char)*pbInBuffer++; - dwInLength--; - - // Search decompression table type and get all types of compression - for(i = 0; i < dwEntries; i++) - { - // We have to apply this decompression ? - if(fDecompressions1 & dcmp_table[i].dwMask) - dwCount++; - - // Clear this flag from temporary variable. - fDecompressions2 &= ~dcmp_table[i].dwMask; - } - - // Check if there is some method unhandled - // (E.g. compressed by future versions) - if(fDecompressions2 != 0) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - - // If there is more than only one compression, we have to allocate extra buffer - if(dwCount >= 2) - pbTempBuff = ALLOCMEM(char, dwOutLength); - - // Apply all decompressions - for(i = 0, dwCount = 0; i < dwEntries; i++) - { - // If not used this kind of compression, skip the loop - if(fDecompressions1 & dcmp_table[i].dwMask) - { - // If odd case, use target buffer for output, otherwise use allocated tempbuffer - pbWorkBuff = (dwCount++ & 1) ? pbTempBuff : pbOutBuffer; - dwOutLength = *pdwOutLength; - - // Decompress buffer using corresponding function - dcmp_table[i].Decompress(pbWorkBuff, &dwOutLength, pbInBuffer, dwInLength); - if(dwOutLength == 0) - { - SetLastError(ERROR_GEN_FAILURE); - nResult = 0; - break; - } - - // Move output length to src length for next compression - dwInLength = dwOutLength; - pbInBuffer = pbWorkBuff; - } - } - - // If output buffer is not the same like target buffer, we have to copy data - if(nResult != 0) - { - if(pbWorkBuff != pbOutBuffer) - memcpy(pbOutBuffer, pbInBuffer, dwOutLength); - - } - - // Delete temporary buffer, if necessary - if(pbTempBuff != NULL) - FREEMEM(pbTempBuff); - - *pdwOutLength = dwOutLength; - return nResult; -} - -/*****************************************************************************/ -/* */ -/* SCompSetDataCompression */ -/* */ -/*****************************************************************************/ - -int WINAPI SCompSetDataCompression(int nDataCompression) -{ - int nValidMask = (MPQ_COMPRESSION_ZLIB | MPQ_COMPRESSION_PKWARE | MPQ_COMPRESSION_BZIP2); - - if((nDataCompression & nValidMask) != nDataCompression) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - SetDataCompression(nDataCompression); - return TRUE; -} - - diff --git a/contrib/vmap_extractor_v2/stormlib/SFileCompactArchive.cpp b/contrib/vmap_extractor_v2/stormlib/SFileCompactArchive.cpp deleted file mode 100644 index 9510b15ae1f..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/SFileCompactArchive.cpp +++ /dev/null @@ -1,691 +0,0 @@ -/*****************************************************************************/ -/* SFileCompactArchive.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Archive compacting function */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 14.04.03 1.00 Lad Splitted from SFileCreateArchiveEx.cpp */ -/* 19.11.03 1.01 Dan Big endian handling */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "SCommon.h" - -/*****************************************************************************/ -/* Local structures */ -/*****************************************************************************/ - -/*****************************************************************************/ -/* Local variables */ -/*****************************************************************************/ - -static COMPACTCB CompactCB = NULL; -static void * lpUserData = NULL; - -/*****************************************************************************/ -/* Local functions */ -/*****************************************************************************/ - -// Creates a copy of hash table -static TMPQHash * CopyHashTable(TMPQArchive * ha) -{ - TMPQHash * pHashTableCopy = ALLOCMEM(TMPQHash, ha->pHeader->dwHashTableSize); - - if(pHashTableCopy != NULL) - memcpy(pHashTableCopy, ha->pHashTable, sizeof(TMPQHash) * ha->pHeader->dwHashTableSize); - - return pHashTableCopy; -} - -// TODO: Test for archives > 4GB -static int CheckIfAllFilesKnown(TMPQArchive * ha, const char * szListFile, DWORD * pFileSeeds) -{ - TMPQHash * pHashTableCopy = NULL; // Copy of the hash table - TMPQHash * pHash; - TMPQHash * pHashEnd = NULL; // End of the hash table - DWORD dwFileCount = 0; - int nError = ERROR_SUCCESS; - - // First of all, create a copy of hash table - if(nError == ERROR_SUCCESS) - { - if((pHashTableCopy = CopyHashTable(ha)) == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - pHashEnd = pHashTableCopy + ha->pHeader->dwHashTableSize; - - // Notify the user - if(CompactCB != NULL) - CompactCB(lpUserData, CCB_CHECKING_FILES, 0, ha->pHeader->dwBlockTableSize); - } - - // Now check all the files from the filelist - if(nError == ERROR_SUCCESS) - { - SFILE_FIND_DATA wf; - HANDLE hFind = SFileFindFirstFile((HANDLE)ha, "*", &wf, szListFile); - BOOL bResult = TRUE; - - // Do while some files have been found - while(hFind != NULL && bResult) - { - TMPQHash * pHash = GetHashEntry(ha, wf.cFileName); - - // If the hash table entry has been found, find it's position - // in the hash table copy - if(pHash != NULL) - { - pHash = pHashTableCopy + (pHash - ha->pHashTable); - if(pHash->dwName1 != (DWORD)-1 && pHash->dwName2 != (DWORD)-1) - { - TMPQBlock * pBlock = ha->pBlockTable + pHash->dwBlockIndex; - DWORD dwSeed = 0; - - // Resolve the file seed. Use plain file name for it - if(pBlock->dwFlags & MPQ_FILE_ENCRYPTED) - { - char * szFileName = strrchr(wf.cFileName, '\\'); - - if(szFileName == NULL) - szFileName = wf.cFileName; - else - szFileName++; - - dwSeed = DecryptFileSeed(szFileName); - if(pBlock->dwFlags & MPQ_FILE_FIXSEED) - dwSeed = (dwSeed + pBlock->dwFilePos) ^ pBlock->dwFSize; - } - pFileSeeds[pHash->dwBlockIndex] = dwSeed; - - pHash->dwName1 = 0xFFFFFFFF; - pHash->dwName2 = 0xFFFFFFFF; - pHash->lcLocale = 0xFFFF; - pHash->wPlatform = 0xFFFF; - pHash->dwBlockIndex = 0xFFFFFFFF; - } - } - // Notify the user - if(CompactCB != NULL) - CompactCB(lpUserData, CCB_CHECKING_FILES, ++dwFileCount, ha->pHeader->dwBlockTableSize); - - // Find the next file in the archive - bResult = SFileFindNextFile(hFind, &wf); - } - - if(hFind != NULL) - SFileFindClose(hFind); - } - - // When the filelist checking is complete, parse the hash table copy and find the - if(nError == ERROR_SUCCESS) - { - // Notify the user about checking hash table - dwFileCount = 0; - if(CompactCB != NULL) - CompactCB(lpUserData, CCB_CHECKING_HASH_TABLE, dwFileCount, ha->pHeader->dwBlockTableSize); - - for(pHash = pHashTableCopy; pHash < pHashEnd; pHash++) - { - // If there is an unresolved entry, try to detect its seed. If it fails, - // we cannot complete the work - if(pHash->dwName1 != (DWORD)-1 && pHash->dwName2 != (DWORD)-1) - { - HANDLE hFile = NULL; - DWORD dwFlags = 0; - DWORD dwSeed = 0; - - if(SFileOpenFileEx((HANDLE)ha, (char *)(DWORD_PTR)pHash->dwBlockIndex, 0, &hFile)) - { - TMPQFile * hf = (TMPQFile *)hFile; - dwFlags = hf->pBlock->dwFlags; - dwSeed = hf->dwSeed1; - SFileCloseFile(hFile); - } - - // If the file is encrypted, we have to check - // If we can apply the file decryption seed - if(dwFlags & MPQ_FILE_ENCRYPTED && dwSeed == 0) - { - nError = ERROR_CAN_NOT_COMPLETE; - break; - } - - // Remember the seed - pFileSeeds[pHash->dwBlockIndex] = dwSeed; - - // Notify the user - if(CompactCB != NULL) - CompactCB(lpUserData, CCB_CHECKING_HASH_TABLE, ++dwFileCount, ha->pHeader->dwBlockTableSize); - } - } - } - - // Delete the copy of hash table - if(pHashTableCopy != NULL) - FREEMEM(pHashTableCopy); - return nError; -} - -// Copies all file blocks into another archive. -// TODO: Test for archives > 4GB -static int CopyMpqFileBlocks( - HANDLE hFile, - TMPQArchive * ha, - TMPQBlockEx * pBlockEx, - TMPQBlock * pBlock, - DWORD dwSeed) -{ - LARGE_INTEGER FilePos = {0}; - DWORD * pdwBlockPos2 = NULL; // File block positions to be written to target file - DWORD * pdwBlockPos = NULL; // File block positions (unencrypted) - BYTE * pbBlock = NULL; // Buffer for the file block - DWORD dwTransferred; // Number of bytes transferred - DWORD dwCSize = 0; // Compressed file size - DWORD dwBytes = 0; // Number of bytes - DWORD dwSeed1 = 0; // File seed used for decryption - DWORD dwSeed2 = 0; // File seed used for encryption - DWORD nBlocks = 0; // Number of file blocks - DWORD nBlock = 0; // Currently processed file block - int nError = ERROR_SUCCESS; - - // When file length is zero, do nothing - if(pBlock->dwFSize == 0) - return ERROR_SUCCESS; - - // Calculate number of blocks in the file - if(nError == ERROR_SUCCESS) - { - nBlocks = pBlock->dwFSize / ha->dwBlockSize; - if(pBlock->dwFSize % ha->dwBlockSize) - nBlocks++; - pbBlock = ALLOCMEM(BYTE, ha->dwBlockSize); - if(pbBlock == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Set the position to the begin of the file within archive - if(nError == ERROR_SUCCESS) - { - FilePos.HighPart = pBlockEx->wFilePosHigh; - FilePos.LowPart = pBlock->dwFilePos; - FilePos.QuadPart += ha->MpqPos.QuadPart; - if(SetFilePointer(ha->hFile, FilePos.LowPart, &FilePos.HighPart, FILE_BEGIN) != FilePos.LowPart) - nError = GetLastError(); - } - - // Remember the position in the destination file - if(nError == ERROR_SUCCESS) - { - FilePos.HighPart = 0; - FilePos.LowPart = SetFilePointer(hFile, 0, &FilePos.HighPart, FILE_CURRENT); - } - - // Resolve decryption seeds. The 'dwSeed' parameter is the decryption - // seed for the file. - if(nError == ERROR_SUCCESS && (pBlock->dwFlags & MPQ_FILE_ENCRYPTED)) - { - dwSeed1 = dwSeed; - if(pBlock->dwFlags & MPQ_FILE_FIXSEED) - dwSeed = (dwSeed1 ^ pBlock->dwFSize) - pBlock->dwFilePos; - - dwSeed2 = dwSeed; - if(pBlock->dwFlags & MPQ_FILE_FIXSEED) - dwSeed2 = (dwSeed + (DWORD)(FilePos.QuadPart - ha->MpqPos.QuadPart)) ^ pBlock->dwFSize; - } - - // Load the file positions from the archive and save it to the target file - // (only if the file is compressed) - if(pBlock->dwFlags & MPQ_FILE_COMPRESSED) - { - // Allocate buffers - if(nError == ERROR_SUCCESS) - { - pdwBlockPos = ALLOCMEM(DWORD, nBlocks + 2); - pdwBlockPos2 = ALLOCMEM(DWORD, nBlocks + 2); - - if(pdwBlockPos == NULL || pdwBlockPos2 == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Load the block positions - if(nError == ERROR_SUCCESS) - { - dwBytes = (nBlocks + 1) * sizeof(DWORD); - if(pBlock->dwFlags & MPQ_FILE_HAS_EXTRA) - dwBytes += sizeof(DWORD); - - ReadFile(ha->hFile, pdwBlockPos, dwBytes, &dwTransferred, NULL); - if(dwTransferred != dwBytes) - nError = ERROR_FILE_CORRUPT; - } - - // Re-encrypt the block table positions - if(nError == ERROR_SUCCESS) - { - BSWAP_ARRAY32_UNSIGNED(pdwBlockPos, dwBytes / sizeof(DWORD)); - if(pBlock->dwFlags & MPQ_FILE_ENCRYPTED) - { - DecryptMPQBlock(pdwBlockPos, dwBytes, dwSeed1 - 1); - if(pdwBlockPos[0] != dwBytes) - nError = ERROR_FILE_CORRUPT; - - memcpy(pdwBlockPos2, pdwBlockPos, dwBytes); - EncryptMPQBlock(pdwBlockPos2, dwBytes, dwSeed2 - 1); - } - else - { - memcpy(pdwBlockPos2, pdwBlockPos, dwBytes); - } - BSWAP_ARRAY32_UNSIGNED(pdwBlockPos2, dwBytes / sizeof(DWORD)); - } - - // Write to the target file - if(nError == ERROR_SUCCESS) - { - WriteFile(hFile, pdwBlockPos2, dwBytes, &dwTransferred, NULL); - dwCSize += dwTransferred; - if(dwTransferred != dwBytes) - nError = ERROR_DISK_FULL; - } - } - - // Now we have to copy all file block. We will do it without - // recompression, because re-compression is not necessary in this case - if(nError == ERROR_SUCCESS) - { - for(nBlock = 0; nBlock < nBlocks; nBlock++) - { - // Fix: The last block must not be exactly the size of one block. - dwBytes = ha->dwBlockSize; - if(nBlock == nBlocks - 1) - { - dwBytes = pBlock->dwFSize - (ha->dwBlockSize * (nBlocks - 1)); - } - - if(pBlock->dwFlags & MPQ_FILE_COMPRESSED) - dwBytes = pdwBlockPos[nBlock+1] - pdwBlockPos[nBlock]; - - // Read the file block - ReadFile(ha->hFile, pbBlock, dwBytes, &dwTransferred, NULL); - if(dwTransferred != dwBytes) - { - nError = ERROR_FILE_CORRUPT; - break; - } - - // If necessary, re-encrypt the block - // Note: Recompression is not necessary here. Unlike encryption, - // the compression does not depend on the position of the file in MPQ. - if((pBlock->dwFlags & MPQ_FILE_ENCRYPTED) && dwSeed1 != dwSeed2) - { - BSWAP_ARRAY32_UNSIGNED((DWORD *)pbBlock, dwBytes/sizeof(DWORD)); - DecryptMPQBlock((DWORD *)pbBlock, dwBytes, dwSeed1 + nBlock); - EncryptMPQBlock((DWORD *)pbBlock, dwBytes, dwSeed2 + nBlock); - BSWAP_ARRAY32_UNSIGNED((DWORD *)pbBlock, dwBytes/sizeof(DWORD)); - } - - // Now write the block back to the file - WriteFile(hFile, pbBlock, dwBytes, &dwTransferred, NULL); - dwCSize += dwTransferred; - if(dwTransferred != dwBytes) - { - nError = ERROR_DISK_FULL; - break; - } - } - } - - // Copy the file extras, if any - // These extras does not seem to be encrypted, and their purpose is unknown - if(nError == ERROR_SUCCESS && (pBlock->dwFlags & MPQ_FILE_HAS_EXTRA)) - { - dwBytes = pdwBlockPos[nBlocks + 1] - pdwBlockPos[nBlocks]; - if(dwBytes != 0) - { - ReadFile(ha->hFile, pbBlock, dwBytes, &dwTransferred, NULL); - if(dwTransferred == dwBytes) - { - WriteFile(hFile, pbBlock, dwBytes, &dwTransferred, NULL); - dwCSize += dwTransferred; - if(dwTransferred != dwBytes) - nError = ERROR_DISK_FULL; - } - else - { - nError = ERROR_FILE_CORRUPT; - } - } - } - - // Update file position in the block table - if(nError == ERROR_SUCCESS) - { - // At this point, number of bytes written should be exactly - // the same like the compressed file size. If it isn't, there's something wrong - // (maybe new archive version ?) - assert(dwCSize == pBlock->dwCSize); - - // Update file pos in the block table - FilePos.QuadPart -= ha->MpqPos.QuadPart; - pBlockEx->wFilePosHigh = (USHORT)FilePos.HighPart; - pBlock->dwFilePos = FilePos.LowPart; - } - - // Cleanup and return - if(pdwBlockPos2 != NULL) - FREEMEM(pdwBlockPos2); - if(pdwBlockPos != NULL) - FREEMEM(pdwBlockPos); - if(pbBlock != NULL) - FREEMEM(pbBlock); - return nError; -} - - -static int CopyNonMpqData( - HANDLE hSrcFile, - HANDLE hTrgFile, - LARGE_INTEGER & DataSizeToCopy) -{ - LARGE_INTEGER DataSize = DataSizeToCopy; - DWORD dwTransferred; - DWORD dwToRead; - char DataBuffer[0x1000]; - int nError = ERROR_SUCCESS; - - while(DataSize.QuadPart > 0) - { - // Get the proper size of data - dwToRead = sizeof(DataBuffer); - if(DataSize.HighPart == 0 && DataSize.LowPart < dwToRead) - dwToRead = DataSize.LowPart; - - // Read the source file - ReadFile(hSrcFile, DataBuffer, dwToRead, &dwTransferred, NULL); - if(dwTransferred != dwToRead) - { - nError = ERROR_CAN_NOT_COMPLETE; - break; - } - - // Write to the target file - WriteFile(hTrgFile, DataBuffer, dwToRead, &dwTransferred, NULL); - if(dwTransferred != dwToRead) - { - nError = ERROR_DISK_FULL; - break; - } - - // Decrement the number of data to be copied - DataSize.QuadPart -= dwTransferred; - } - - return ERROR_SUCCESS; -} - -// TODO: Test for archives > 4GB -static int CopyMpqFiles(HANDLE hFile, TMPQArchive * ha, DWORD * pFileSeeds) -{ - TMPQBlockEx * pBlockEx; - TMPQBlock * pBlock; - DWORD dwSeed1; - DWORD dwIndex; - int nError = ERROR_SUCCESS; - - // Walk through all files and write them to the destination MPQ archive - for(dwIndex = 0; dwIndex < ha->pHeader->dwBlockTableSize; dwIndex++) - { - pBlockEx = ha->pExtBlockTable + dwIndex; - pBlock = ha->pBlockTable + dwIndex; - dwSeed1 = pFileSeeds[dwIndex]; - - // Notify the caller about work - if(CompactCB != NULL) - CompactCB(lpUserData, CCB_COMPACTING_FILES, dwIndex, ha->pHeader->dwBlockTableSize); - -// if(dwIndex == 0x1B9) -// DebugBreak(); - - // Copy all the file blocks - // Debug: Break at (dwIndex == 5973) - if(pBlock->dwFlags & MPQ_FILE_EXISTS) - { - nError = CopyMpqFileBlocks(hFile, ha, pBlockEx, pBlock, dwSeed1); - if(nError != ERROR_SUCCESS) - break; - } - } - - // Cleanup and exit - return nError; -} - - -/*****************************************************************************/ -/* Public functions */ -/*****************************************************************************/ - -BOOL WINAPI SFileSetCompactCallback(HANDLE /* hMPQ */, COMPACTCB aCompactCB, void * lpData) -{ - CompactCB = aCompactCB; - lpUserData = lpData; - return TRUE; -} - -//----------------------------------------------------------------------------- -// Archive compacting (incomplete) - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileCompactArchive(HANDLE hMPQ, const char * szListFile, BOOL /* bReserved */) -{ - TMPQArchive * ha = (TMPQArchive *)hMPQ; - HANDLE hFile = INVALID_HANDLE_VALUE; - DWORD * pFileSeeds = NULL; - char szTempFile[MAX_PATH] = ""; - char * szTemp = NULL; - DWORD dwTransferred; - int nError = ERROR_SUCCESS; - - // Test the valid parameters - if(!IsValidMpqHandle(ha)) - nError = ERROR_INVALID_PARAMETER; - - // Create the table with file seeds - if(nError == ERROR_SUCCESS) - { - if((pFileSeeds = ALLOCMEM(DWORD, ha->pHeader->dwBlockTableSize)) != NULL) - memset(pFileSeeds, 0, sizeof(DWORD) * ha->pHeader->dwBlockTableSize); - else - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // First of all, we have to check of we are able to decrypt all files. - // If not, sorry, but the archive cannot be compacted. - if(nError == ERROR_SUCCESS) - nError = CheckIfAllFilesKnown(ha, szListFile, pFileSeeds); - - // Get the temporary file name and create it - if(nError == ERROR_SUCCESS) - { - if(CompactCB != NULL) - CompactCB(lpUserData, CCB_COPYING_NON_MPQ_DATA, 0, 0); - - strcpy(szTempFile, ha->szFileName); - if((szTemp = strrchr(szTempFile, '.')) != NULL) - strcpy(szTemp + 1, "mp_"); - else - strcat(szTempFile, "_"); - - hFile = CreateFile(szTempFile, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, NULL); - if(hFile == INVALID_HANDLE_VALUE) - nError = GetLastError(); - } - - // Write the data before MPQ header (if any) - if(nError == ERROR_SUCCESS && ha->MpqPos.QuadPart > 0) - { - SetFilePointer(ha->hFile, 0, NULL, FILE_BEGIN); - if(ha->pShunt != NULL) - nError = CopyNonMpqData(ha->hFile, hFile, ha->ShuntPos); - else - nError = CopyNonMpqData(ha->hFile, hFile, ha->MpqPos); - } - - // Write the MPQ shunt (if any) - if(nError == ERROR_SUCCESS && ha->pShunt != NULL) - { - BSWAP_TMPQSHUNT(ha->pShunt); - WriteFile(hFile, ha->pShunt, sizeof(TMPQShunt), &dwTransferred, NULL); - BSWAP_TMPQSHUNT(ha->pShunt); - - if(dwTransferred != sizeof(TMPQShunt)) - nError = ERROR_DISK_FULL; - } - - // Write the data between MPQ shunt and the MPQ header (if any) - if(nError == ERROR_SUCCESS && ha->pShunt != NULL) - { - LARGE_INTEGER BytesToCopy; - - BytesToCopy.QuadPart = ha->MpqPos.QuadPart - (ha->ShuntPos.QuadPart + sizeof(TMPQShunt)); - nError = CopyNonMpqData(ha->hFile, hFile, BytesToCopy); - } - - // Write the MPQ header - if(nError == ERROR_SUCCESS) - { - BSWAP_TMPQHEADER(ha->pHeader); - WriteFile(hFile, ha->pHeader, ha->pHeader->dwHeaderSize, &dwTransferred, NULL); - BSWAP_TMPQHEADER(ha->pHeader); - if(dwTransferred != ha->pHeader->dwHeaderSize) - nError = ERROR_DISK_FULL; - } - - // Write the data between the header and between the first file - // For this, we have to determine where the first file begins - if(nError == ERROR_SUCCESS) - { - LARGE_INTEGER FirstFilePos; - LARGE_INTEGER TempPos; - TMPQBlockEx * pBlockEx = ha->pExtBlockTable; - TMPQBlock * pBlockEnd = ha->pBlockTable + ha->pHeader->dwBlockTableSize; - TMPQBlock * pBlock = ha->pBlockTable; - - // Maximum file position - FirstFilePos.HighPart = 0x7FFFFFFF; - FirstFilePos.LowPart = 0xFFFFFFFF; - - // Find the block with the least position in the MPQ - while(pBlock < pBlockEnd) - { - TempPos.HighPart = pBlockEx->wFilePosHigh; - TempPos.LowPart = pBlock->dwFilePos; - if(TempPos.QuadPart < FirstFilePos.QuadPart) - FirstFilePos = TempPos; - - pBlockEx++; - pBlock++; - } - - // Set the position in the source file right after the file header - TempPos.QuadPart = ha->MpqPos.QuadPart + ha->pHeader->dwHeaderSize; - SetFilePointer(ha->hFile, TempPos.LowPart, &TempPos.HighPart, FILE_BEGIN); - - // Get the number of bytes to copy - FirstFilePos.QuadPart -= ha->pHeader->dwHeaderSize; - nError = CopyNonMpqData(ha->hFile, hFile, FirstFilePos); - } - - // Now write all file blocks. - if(nError == ERROR_SUCCESS) - nError = CopyMpqFiles(hFile, ha, pFileSeeds); - - // Now we need to update the tables positions - // (but only if the tables are at the end of the file) - if(nError == ERROR_SUCCESS) - { - LARGE_INTEGER RelativePos; - LARGE_INTEGER FilePos = {0}; - - // Set the hash table position - FilePos.LowPart = SetFilePointer(hFile, 0, &FilePos.HighPart, FILE_CURRENT); - RelativePos.QuadPart = FilePos.QuadPart - ha->MpqPos.QuadPart; - ha->pHeader->wHashTablePosHigh = (USHORT)RelativePos.HighPart; - ha->pHeader->dwHashTablePos = RelativePos.LowPart; - ha->HashTablePos = FilePos; - - // Set the block table position - RelativePos.QuadPart += ha->pHeader->dwHashTableSize * sizeof(TMPQHash); - FilePos.QuadPart += ha->pHeader->dwHashTableSize * sizeof(TMPQHash); - ha->pHeader->wBlockTablePosHigh = (USHORT)RelativePos.HighPart; - ha->pHeader->dwBlockTablePos = RelativePos.LowPart; - ha->BlockTablePos = FilePos; - - // Set the extended block table position - RelativePos.QuadPart += ha->pHeader->dwBlockTableSize * sizeof(TMPQBlock); - FilePos.QuadPart += ha->pHeader->dwBlockTableSize * sizeof(TMPQBlock); - if(ha->ExtBlockTablePos.QuadPart != 0) - { - ha->pHeader->ExtBlockTablePos = RelativePos; - ha->ExtBlockTablePos = FilePos; - - RelativePos.QuadPart += ha->pHeader->dwBlockTableSize * sizeof(TMPQBlockEx); - FilePos.QuadPart += ha->pHeader->dwBlockTableSize * sizeof(TMPQBlockEx); - } - - // Set the archive size - ha->pHeader->dwArchiveSize = RelativePos.LowPart; - ha->MpqSize = RelativePos; - } - - // If succeeded, update the tables in the file - if(nError == ERROR_SUCCESS) - { - CloseHandle(ha->hFile); - ha->FilePointer.QuadPart = 0; - ha->hFile = hFile; - hFile = INVALID_HANDLE_VALUE; - nError = SaveMPQTables(ha); - } - - // If all succeeded, switch the archives - if(nError == ERROR_SUCCESS) - { - if(CompactCB != NULL) - CompactCB(lpUserData, CCB_CLOSING_ARCHIVE, 0, 0); - - if(!DeleteFile(ha->szFileName) || // Delete the old archive - !CloseHandle(ha->hFile) || // Close the new archive - !MoveFile(szTempFile, ha->szFileName)) // Rename the temporary archive - nError = GetLastError(); - } - - // Now open the freshly renamed archive file - if(nError == ERROR_SUCCESS) - { - ha->hFile = CreateFile(ha->szFileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - if(ha->hFile == INVALID_HANDLE_VALUE) - nError = GetLastError(); - } - - // Invalidate the positions of the archive - if(nError == ERROR_SUCCESS) - { - ha->FilePointer.QuadPart = 0; - ha->pLastFile = NULL; - ha->dwBlockPos = 0; - ha->dwBuffPos = 0; - } - - // Cleanup and return - if(hFile != INVALID_HANDLE_VALUE) - CloseHandle(hFile); - if(pFileSeeds != NULL) - FREEMEM(pFileSeeds); - if(nError != ERROR_SUCCESS) - SetLastError(nError); - DeleteFile(szTempFile); - CompactCB = NULL; - return (nError == ERROR_SUCCESS); -} diff --git a/contrib/vmap_extractor_v2/stormlib/SFileCreateArchiveEx.cpp b/contrib/vmap_extractor_v2/stormlib/SFileCreateArchiveEx.cpp deleted file mode 100644 index 2410920fc93..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/SFileCreateArchiveEx.cpp +++ /dev/null @@ -1,530 +0,0 @@ -/*****************************************************************************/ -/* SFileCreateArchiveEx.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* MPQ Editing functions */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 24.03.03 1.00 Lad Splitted from SFileOpenArchive.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "SCommon.h" - -//----------------------------------------------------------------------------- -// Defines - -#define DEFAULT_BLOCK_SIZE 3 // Default size of the block - -//----------------------------------------------------------------------------- -// Local tables - -static DWORD PowersOfTwo[] = -{ - 0x0000002, 0x0000004, 0x0000008, - 0x0000010, 0x0000020, 0x0000040, 0x0000080, - 0x0000100, 0x0000200, 0x0000400, 0x0000800, - 0x0001000, 0x0002000, 0x0004000, 0x0008000, - 0x0010000, 0x0020000, 0x0040000, 0x0080000, - 0x0000000 -}; - -/*****************************************************************************/ -/* Public functions */ -/*****************************************************************************/ - -//----------------------------------------------------------------------------- -// Opens or creates a (new) MPQ archive. -// -// szMpqName - Name of the archive to be created. -// -// dwCreationDisposition: -// -// Value Archive exists Archive doesn't exist -// ---------- --------------------- --------------------- -// CREATE_NEW Fails Creates new archive -// CREATE_ALWAYS Overwrites existing Creates new archive -// OPEN_EXISTING Opens the archive Fails -// OPEN_ALWAYS Opens the archive Creates new archive -// -// The above mentioned values can be combined with the following flags: -// -// MPQ_CREATE_ARCHIVE_V1 - Creates MPQ archive version 1 -// MPQ_CREATE_ARCHIVE_V2 - Creates MPQ archive version 2 -// -// dwHashTableSize - Size of the hash table (only if creating a new archive). -// Must be between 2^4 (= 16) and 2^18 (= 262 144) -// -// phMpq - Receives handle to the archive -// - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileCreateArchiveEx(const char * szMpqName, DWORD dwCreationDisposition, DWORD dwHashTableSize, HANDLE * phMPQ) -{ - LARGE_INTEGER MpqPos = {0}; // Position of MPQ header in the file - TMPQArchive * ha = NULL; // MPQ archive handle - HANDLE hFile = INVALID_HANDLE_VALUE; // File handle - DWORD dwTransferred = 0; // Number of bytes written into the archive - USHORT wFormatVersion; - BOOL bFileExists = FALSE; - int nIndex = 0; - int nError = ERROR_SUCCESS; - - // Pre-initialize the result value - if(phMPQ != NULL) - *phMPQ = NULL; - - // Check the parameters, if they are valid - if(szMpqName == NULL || *szMpqName == 0 || phMPQ == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - // Check the value of dwCreationDisposition against file existence - bFileExists = (GetFileAttributes(szMpqName) != 0xFFFFFFFF); - - // Extract format version from the "dwCreationDisposition" - wFormatVersion = (USHORT)(dwCreationDisposition >> 0x10); - dwCreationDisposition &= 0x0000FFFF; - - // If the file exists and open required, do it. - if(bFileExists && (dwCreationDisposition == OPEN_EXISTING || dwCreationDisposition == OPEN_ALWAYS)) - { - // Try to open the archive normal way. If it fails, it means that - // the file exist, but it is not a MPQ archive. - if(SFileOpenArchiveEx(szMpqName, 0, 0, phMPQ, GENERIC_READ | GENERIC_WRITE)) - return TRUE; - } - - // Two error cases - if(dwCreationDisposition == CREATE_NEW && bFileExists) - { - SetLastError(ERROR_ALREADY_EXISTS); - return FALSE; - } - if(dwCreationDisposition == OPEN_EXISTING && bFileExists == FALSE) - { - SetLastError(ERROR_FILE_NOT_FOUND); - return FALSE; - } - - // At this point, we have to create the archive. If the file exists, - // we will convert it to MPQ archive. - // Check the value of hash table size. It has to be a power of two - // and must be between HASH_TABLE_SIZE_MIN and HASH_TABLE_SIZE_MAX - if(dwHashTableSize < HASH_TABLE_SIZE_MIN) - dwHashTableSize = HASH_TABLE_SIZE_MIN; - if(dwHashTableSize > HASH_TABLE_SIZE_MAX) - dwHashTableSize = HASH_TABLE_SIZE_MAX; - - // Round the hash table size up to the nearest power of two - for(nIndex = 0; PowersOfTwo[nIndex] != 0; nIndex++) - { - if(dwHashTableSize <= PowersOfTwo[nIndex]) - { - dwHashTableSize = PowersOfTwo[nIndex]; - break; - } - } - - // Prepare the buffer for decryption engine - if(nError == ERROR_SUCCESS) - nError = PrepareStormBuffer(); - - // Get the position where the MPQ header will begin. - if(nError == ERROR_SUCCESS) - { - hFile = CreateFile(szMpqName, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ, - NULL, - dwCreationDisposition, - 0, - NULL); - if(hFile == INVALID_HANDLE_VALUE) - nError = GetLastError(); - } - - // Retrieve the file size and round it up to 0x200 bytes - if(nError == ERROR_SUCCESS) - { - MpqPos.LowPart = GetFileSize(hFile, (LPDWORD)&MpqPos.HighPart); - MpqPos.QuadPart += 0x1FF; - MpqPos.LowPart &= 0xFFFFFE00; - - if(wFormatVersion == MPQ_FORMAT_VERSION_1 && MpqPos.HighPart != 0) - nError = ERROR_DISK_FULL; - if(wFormatVersion == MPQ_FORMAT_VERSION_2 && MpqPos.HighPart > 0x0000FFFF) - nError = ERROR_DISK_FULL; - } - - // Move to the end of the file (i.e. begin of the MPQ) - if(nError == ERROR_SUCCESS) - { - if(SetFilePointer(hFile, MpqPos.LowPart, &MpqPos.HighPart, FILE_BEGIN) == 0xFFFFFFFF) - nError = GetLastError(); - } - - // Set the new end of the file to the MPQ header position - if(nError == ERROR_SUCCESS) - { - if(!SetEndOfFile(hFile)) - nError = GetLastError(); - } - - // Create the archive handle - if(nError == ERROR_SUCCESS) - { - if((ha = ALLOCMEM(TMPQArchive, 1)) == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Fill the MPQ archive handle structure and create the header, - // block buffer, hash table and block table - if(nError == ERROR_SUCCESS) - { - memset(ha, 0, sizeof(TMPQArchive)); - strcpy(ha->szFileName, szMpqName); - ha->hFile = hFile; - ha->dwBlockSize = 0x200 << DEFAULT_BLOCK_SIZE; - ha->MpqPos = MpqPos; - ha->FilePointer = MpqPos; - ha->pHeader = &ha->Header; - ha->pHashTable = ALLOCMEM(TMPQHash, dwHashTableSize); - ha->pBlockTable = ALLOCMEM(TMPQBlock, dwHashTableSize); - ha->pExtBlockTable = ALLOCMEM(TMPQBlockEx, dwHashTableSize); - ha->pbBlockBuffer = ALLOCMEM(BYTE, ha->dwBlockSize); - ha->pListFile = NULL; - ha->dwFlags |= MPQ_FLAG_CHANGED; - - if(!ha->pHashTable || !ha->pBlockTable || !ha->pExtBlockTable || !ha->pbBlockBuffer) - nError = GetLastError(); - hFile = INVALID_HANDLE_VALUE; - } - - // Fill the MPQ header and all buffers - if(nError == ERROR_SUCCESS) - { - LARGE_INTEGER TempPos; - TMPQHeader2 * pHeader = ha->pHeader; - DWORD dwHeaderSize = (wFormatVersion == MPQ_FORMAT_VERSION_2) ? sizeof(TMPQHeader2) : sizeof(TMPQHeader); - - memset(pHeader, 0, sizeof(TMPQHeader2)); - pHeader->dwID = ID_MPQ; - pHeader->dwHeaderSize = dwHeaderSize; - pHeader->dwArchiveSize = pHeader->dwHeaderSize + dwHashTableSize * sizeof(TMPQHash); - pHeader->wFormatVersion = wFormatVersion; - pHeader->wBlockSize = 3; // 0x1000 bytes per block - pHeader->dwHashTableSize = dwHashTableSize; - - // Set proper hash table positions - ha->HashTablePos.QuadPart = ha->MpqPos.QuadPart + pHeader->dwHeaderSize; - ha->pHeader->dwHashTablePos = pHeader->dwHeaderSize; - ha->pHeader->wHashTablePosHigh = 0; - - // Set proper block table positions - ha->BlockTablePos.QuadPart = ha->HashTablePos.QuadPart + - (ha->pHeader->dwHashTableSize * sizeof(TMPQHash)); - TempPos.QuadPart = ha->BlockTablePos.QuadPart - ha->MpqPos.QuadPart; - ha->pHeader->dwBlockTablePos = TempPos.LowPart; - ha->pHeader->wBlockTablePosHigh = (USHORT)TempPos.HighPart; - - // For now, we set extended block table positioon top zero unless we add enough - // files to cause the archive size exceed 4 GB - ha->ExtBlockTablePos.QuadPart = 0; - - // Clear all tables - memset(ha->pBlockTable, 0, sizeof(TMPQBlock) * dwHashTableSize); - memset(ha->pExtBlockTable, 0, sizeof(TMPQBlockEx) * dwHashTableSize); - memset(ha->pHashTable, 0xFF, sizeof(TMPQHash) * dwHashTableSize); - } - - // Write the MPQ header to the file - if(nError == ERROR_SUCCESS) - { - DWORD dwHeaderSize = ha->pHeader->dwHeaderSize; - - BSWAP_TMPQHEADER(ha->pHeader); - WriteFile(ha->hFile, ha->pHeader, dwHeaderSize, &dwTransferred, NULL); - BSWAP_TMPQHEADER(ha->pHeader); - - if(dwTransferred != ha->pHeader->dwHeaderSize) - nError = ERROR_DISK_FULL; - - ha->FilePointer.QuadPart = ha->MpqPos.QuadPart + dwTransferred; - ha->MpqSize.QuadPart += dwTransferred; - } - - // Create the internal listfile - if(nError == ERROR_SUCCESS) - nError = SListFileCreateListFile(ha); - - // Try to add the internal listfile - if(nError == ERROR_SUCCESS) - SFileAddListFile((HANDLE)ha, NULL); - - // Cleanup : If an error, delete all buffers and return - if(nError != ERROR_SUCCESS) - { - FreeMPQArchive(ha); - if(hFile != INVALID_HANDLE_VALUE) - CloseHandle(hFile); - SetLastError(nError); - } - - // Return the values - *phMPQ = (HANDLE)ha; - return (nError == ERROR_SUCCESS); -} - -//----------------------------------------------------------------------------- -// Changes locale ID of a file - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileSetFileLocale(HANDLE hFile, LCID lcNewLocale) -{ - TMPQFile * hf = (TMPQFile *)hFile; - - // Invalid handle => do nothing - if(IsValidFileHandle(hf) == FALSE || IsValidMpqHandle(hf->ha) == FALSE) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - // If the file has not been open for writing, do nothing. - if(hf->ha->pListFile == NULL) - return ERROR_ACCESS_DENIED; - - hf->pHash->lcLocale = (USHORT)lcNewLocale; - hf->ha->dwFlags |= MPQ_FLAG_CHANGED; - return TRUE; -} - -//----------------------------------------------------------------------------- -// Adds a file into the archive - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileAddFileEx(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality, int nFileType) -{ - TMPQArchive * ha = (TMPQArchive *)hMPQ; - HANDLE hFile = INVALID_HANDLE_VALUE; - BOOL bReplaced = FALSE; // TRUE if replacing file in the archive - int nError = ERROR_SUCCESS; - - if(nError == ERROR_SUCCESS) - { - // Check valid parameters - if(IsValidMpqHandle(ha) == FALSE || szFileName == NULL || *szFileName == 0 || szArchivedName == NULL || *szArchivedName == 0) - nError = ERROR_INVALID_PARAMETER; - - // Check the values of dwFlags - if((dwFlags & MPQ_FILE_COMPRESS_PKWARE) && (dwFlags & MPQ_FILE_COMPRESS_MULTI)) - nError = ERROR_INVALID_PARAMETER; - } - - // If anyone is trying to add listfile, and the archive already has a listfile, - // deny the operation, but return success. - if(nError == ERROR_SUCCESS) - { - if(ha->pListFile != NULL && !_stricmp(szFileName, LISTFILE_NAME)) - return ERROR_SUCCESS; - } - - // Open added file - if(nError == ERROR_SUCCESS) - { - hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, NULL); - if(hFile == INVALID_HANDLE_VALUE) - nError = GetLastError(); - } - - if(nError == ERROR_SUCCESS) - nError = AddFileToArchive(ha, hFile, szArchivedName, dwFlags, dwQuality, nFileType, &bReplaced); - - // Add the file into listfile also - if(nError == ERROR_SUCCESS && bReplaced == FALSE) - nError = SListFileAddNode(ha, szArchivedName); - - // Cleanup and exit - if(hFile != INVALID_HANDLE_VALUE) - CloseHandle(hFile); - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (nError == ERROR_SUCCESS); -} - -// Adds a data file into the archive -// TODO: Test for archives > 4GB -BOOL WINAPI SFileAddFile(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags) -{ - return SFileAddFileEx(hMPQ, szFileName, szArchivedName, dwFlags, 0, SFILE_TYPE_DATA); -} - -// Adds a WAVE file into the archive -// TODO: Test for archives > 4GB -BOOL WINAPI SFileAddWave(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality) -{ - return SFileAddFileEx(hMPQ, szFileName, szArchivedName, dwFlags, dwQuality, SFILE_TYPE_WAVE); -} - -//----------------------------------------------------------------------------- -// BOOL SFileRemoveFile(HANDLE hMPQ, char * szFileName) -// -// This function removes a file from the archive. The file content -// remains there, only the entries in the hash table and in the block -// table are updated. - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileRemoveFile(HANDLE hMPQ, const char * szFileName, DWORD dwSearchScope) -{ - TMPQArchive * ha = (TMPQArchive *)hMPQ; - TMPQBlockEx * pBlockEx = NULL; // Block entry of deleted file - TMPQBlock * pBlock = NULL; // Block entry of deleted file - TMPQHash * pHash = NULL; // Hash entry of deleted file - DWORD dwBlockIndex = 0; - int nError = ERROR_SUCCESS; - - // Check the parameters - if(nError == ERROR_SUCCESS) - { - if(IsValidMpqHandle(ha) == FALSE) - nError = ERROR_INVALID_PARAMETER; - if(dwSearchScope != SFILE_OPEN_BY_INDEX && *szFileName == 0) - nError = ERROR_INVALID_PARAMETER; - } - - // Do not allow to remove listfile - if(nError == ERROR_SUCCESS) - { - if(dwSearchScope != SFILE_OPEN_BY_INDEX && !_stricmp(szFileName, LISTFILE_NAME)) - nError = ERROR_ACCESS_DENIED; - } - - // Get hash entry belonging to this file - if(nError == ERROR_SUCCESS) - { - if((pHash = GetHashEntryEx(ha, (char *)szFileName, lcLocale)) == NULL) - nError = ERROR_FILE_NOT_FOUND; - } - - // If index was not found, or is greater than number of files, exit. - if(nError == ERROR_SUCCESS) - { - if((dwBlockIndex = pHash->dwBlockIndex) > ha->pHeader->dwBlockTableSize) - nError = ERROR_FILE_NOT_FOUND; - } - - // Get block and test if the file is not already deleted - if(nError == ERROR_SUCCESS) - { - pBlockEx = ha->pExtBlockTable + dwBlockIndex; - pBlock = ha->pBlockTable + dwBlockIndex; - if((pBlock->dwFlags & MPQ_FILE_EXISTS) == 0) - nError = ERROR_FILE_NOT_FOUND; - } - - // Now invalidate the block entry and the hash entry. Do not make any - // relocations and file copying, use SFileCompactArchive for it. - if(nError == ERROR_SUCCESS) - { - pBlockEx->wFilePosHigh = 0; - pBlock->dwFilePos = 0; - pBlock->dwFSize = 0; - pBlock->dwCSize = 0; - pBlock->dwFlags = 0; - pHash->dwName1 = 0xFFFFFFFF; - pHash->dwName2 = 0xFFFFFFFF; - pHash->lcLocale = 0xFFFF; - pHash->wPlatform = 0xFFFF; - pHash->dwBlockIndex = HASH_ENTRY_DELETED; - - // Update MPQ archive - ha->dwFlags |= MPQ_FLAG_CHANGED; - } - - // Remove the file from the list file - if(nError == ERROR_SUCCESS && lcLocale == LANG_NEUTRAL) - nError = SListFileRemoveNode(ha, szFileName); - - // Resolve error and exit - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (nError == ERROR_SUCCESS); -} - -// Renames the file within the archive. -// TODO: Test for archives > 4GB -BOOL WINAPI SFileRenameFile(HANDLE hMPQ, const char * szFileName, const char * szNewFileName) -{ - TMPQArchive * ha = (TMPQArchive *)hMPQ; - TMPQHash * pOldHash = NULL; // Hash entry for the original file - TMPQHash * pNewHash = NULL; // Hash entry for the renamed file - DWORD dwBlockIndex = 0; - int nError = ERROR_SUCCESS; - - // Test the valid parameters - if(nError == ERROR_SUCCESS) - { - if(hMPQ == NULL || szNewFileName == NULL || *szNewFileName == 0) - nError = ERROR_INVALID_PARAMETER; - if(szFileName == NULL || *szFileName == 0) - nError = ERROR_INVALID_PARAMETER; - } - - // Do not allow to rename listfile - if(nError == ERROR_SUCCESS) - { - if(!_stricmp(szFileName, LISTFILE_NAME)) - nError = ERROR_ACCESS_DENIED; - } - - // Test if the file already exists in the archive - if(nError == ERROR_SUCCESS) - { - if((pNewHash = GetHashEntryEx(ha, szNewFileName, lcLocale)) != NULL) - nError = ERROR_ALREADY_EXISTS; - } - - // Get the hash table entry for the original file - if(nError == ERROR_SUCCESS) - { - if((pOldHash = GetHashEntryEx(ha, szFileName, lcLocale)) == NULL) - nError = ERROR_FILE_NOT_FOUND; - } - - // Get the hash table entry for the renamed file - if(nError == ERROR_SUCCESS) - { - // Save block table index and remove the hash table entry - dwBlockIndex = pOldHash->dwBlockIndex; - pOldHash->dwName1 = 0xFFFFFFFF; - pOldHash->dwName2 = 0xFFFFFFFF; - pOldHash->lcLocale = 0xFFFF; - pOldHash->wPlatform = 0xFFFF; - pOldHash->dwBlockIndex = HASH_ENTRY_DELETED; - - if((pNewHash = FindFreeHashEntry(ha, szNewFileName)) == NULL) - nError = ERROR_CAN_NOT_COMPLETE; - } - - // Save the block index and clear the hash entry - if(nError == ERROR_SUCCESS) - { - // Copy the block table index - pNewHash->dwBlockIndex = dwBlockIndex; - ha->dwFlags |= MPQ_FLAG_CHANGED; - } - - // Rename the file in the list file - if(nError == ERROR_SUCCESS) - nError = SListFileRenameNode(ha, szFileName, szNewFileName); - - // Resolve error and return - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (nError == ERROR_SUCCESS); -} - diff --git a/contrib/vmap_extractor_v2/stormlib/SFileExtractFile.cpp b/contrib/vmap_extractor_v2/stormlib/SFileExtractFile.cpp deleted file mode 100644 index 7f16cde0171..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/SFileExtractFile.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/*****************************************************************************/ -/* SFileExtractFile.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Simple extracting utility */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 20.06.03 1.00 Lad The first version of SFileExtractFile.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "SCommon.h" - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileExtractFile(HANDLE hMpq, const char * szToExtract, const char * szExtracted) -{ - HANDLE hLocalFile = INVALID_HANDLE_VALUE; - HANDLE hMpqFile = NULL; - int nError = ERROR_SUCCESS; - - // Create the local file - if(nError == ERROR_SUCCESS) - { - hLocalFile = CreateFile(szExtracted, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, NULL); - if(hLocalFile == INVALID_HANDLE_VALUE) - nError = GetLastError(); - } - - // Open the MPQ file - if(nError == ERROR_SUCCESS) - { - if(!SFileOpenFileEx(hMpq, szToExtract, 0, &hMpqFile)) - nError = GetLastError(); - } - - // Copy the file's content - if(nError == ERROR_SUCCESS) - { - char szBuffer[0x1000]; - DWORD dwTransferred = 1; - - while(dwTransferred > 0) - { - SFileReadFile(hMpqFile, szBuffer, sizeof(szBuffer), &dwTransferred, NULL); - if(dwTransferred == 0) - break; - - WriteFile(hLocalFile, szBuffer, dwTransferred, &dwTransferred, NULL); - if(dwTransferred == 0) - break; - } - } - - // Close the files - if(hMpqFile != NULL) - SFileCloseFile(hMpqFile); - if(hLocalFile != INVALID_HANDLE_VALUE) - CloseHandle(hLocalFile); - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (BOOL)(nError == ERROR_SUCCESS); -} diff --git a/contrib/vmap_extractor_v2/stormlib/SFileFindFile.cpp b/contrib/vmap_extractor_v2/stormlib/SFileFindFile.cpp deleted file mode 100644 index 41dbeba900c..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/SFileFindFile.cpp +++ /dev/null @@ -1,291 +0,0 @@ -/*****************************************************************************/ -/* SFileFindFile.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* A module for file searching within MPQs */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 25.03.03 1.00 Lad The first version of SFileFindFile.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "SCommon.h" - -//----------------------------------------------------------------------------- -// Defines - -#define LISTFILE_CACHE_SIZE 0x1000 - -//----------------------------------------------------------------------------- -// Local functions - -static BOOL IsValidSearchHandle(TMPQSearch * hs) -{ - if(hs == NULL || IsBadReadPtr(hs, sizeof(TMPQSearch))) - return FALSE; - - if(!IsValidMpqHandle(hs->ha)) - return FALSE; - - return TRUE; -} - -// This function compares a string with a wildcard search string. -// returns TRUE, when the string matches with the wildcard. -BOOL CheckWildCard(const char * szString, const char * szWildCard) -{ - char * szTemp; // Temporary helper pointer - int nResult = 0; // For memcmp return values - int nMustNotMatch = 0; // Number of following chars int szString, - // which must not match with szWildCard - int nMustMatch = 0; // Number of the following characters, - // which must match - - // When the string is empty, it does not match with every wildcard - if(*szString == 0) - return FALSE; - - // When the mask is empty, it matches to every wildcard - if(szWildCard == NULL || *szWildCard == 0) - return FALSE; - - // Do normal test - for(;;) - { - switch(*szWildCard) - { - case '*': // Means "every number of characters" - // Skip all asterisks - while(*szWildCard == '*') - szWildCard++; - - // When no more characters in wildcard, it means that the strings match - if(*szWildCard == 0) - return TRUE; - - // The next N characters must not agree - nMustNotMatch |= 0x70000000; - break; - - case '?': // Means "One or no character" - while(*szWildCard == '?') - { - nMustNotMatch++; - szWildCard++; - } - break; - - default: - // If the two characters match - if(toupper(*szString) == toupper(*szWildCard)) - { - // When end of string, they agree - if(*szString == 0) - return TRUE; - - nMustNotMatch = 0; - szWildCard++; - szString++; - break; - } - - // If the next character must match, the string does not match - if(nMustNotMatch == 0) - return FALSE; - - // Count the characters which must match after characters - // that must not match - szTemp = (char *)szWildCard; - nMustMatch = 0; - while(*szTemp != 0 && *szTemp != '*' && *szTemp != '?') - { - nMustMatch++; - szTemp++; - } - - // Now skip characters from szString up to number of chars - // that must not match - nResult = -1; - while(nMustNotMatch > 0 && *szString != 0) - { - if((nResult = _strnicmp(szString, szWildCard, nMustMatch)) == 0) - break; - - szString++; - nMustNotMatch--; - } - - // Make one more comparison - if(nMustNotMatch == 0) - nResult = _strnicmp(szString, szWildCard, nMustMatch); - - // If a match has been found, continue the search - if(nResult == 0) - { - nMustNotMatch = 0; - szWildCard += nMustMatch; - szString += nMustMatch; - break; - } - return FALSE; - } - } -} - -// Performs one MPQ search -// TODO: Test for archives > 4GB -static int DoMPQSearch(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileData) -{ - TMPQArchive * ha = hs->ha; - TFileNode * pNode; - TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - TMPQHash * pHash = ha->pHashTable + hs->dwNextIndex; - - // Do until some file found or no more files - while(pHash < pHashEnd) - { - pNode = ha->pListFile[hs->dwNextIndex++]; - - // If this entry is free, do nothing - if(pHash->dwBlockIndex < HASH_ENTRY_FREE && (DWORD_PTR)pNode < HASH_ENTRY_FREE) - { - // Check the file name. - if(CheckWildCard(pNode->szFileName, hs->szSearchMask)) - { - TMPQBlock * pBlock = ha->pBlockTable + pHash->dwBlockIndex; - - lpFindFileData->lcLocale = pHash->lcLocale; - lpFindFileData->dwFileSize = pBlock->dwFSize; - lpFindFileData->dwFileFlags = pBlock->dwFlags; - lpFindFileData->dwBlockIndex = pHash->dwBlockIndex; - lpFindFileData->dwCompSize = pBlock->dwCSize; - - // Fill the file name and plain file name - strcpy(lpFindFileData->cFileName, pNode->szFileName); - lpFindFileData->szPlainName = strrchr(lpFindFileData->cFileName, '\\'); - if(lpFindFileData->szPlainName == NULL) - lpFindFileData->szPlainName = lpFindFileData->cFileName; - else - lpFindFileData->szPlainName++; - - // Fill the next entry - return ERROR_SUCCESS; - } - } - - pHash++; - } - - // No more files found, return error - return ERROR_NO_MORE_FILES; -} - -// TODO: Test for archives > 4GB -static void FreeMPQSearch(TMPQSearch *& hs) -{ - if(hs != NULL) - { - FREEMEM(hs); - hs = NULL; - } -} - -//----------------------------------------------------------------------------- -// Public functions - -// TODO: Test for archives > 4GB -HANDLE WINAPI SFileFindFirstFile(HANDLE hMPQ, const char * szMask, SFILE_FIND_DATA * lpFindFileData, const char * szListFile) -{ - TMPQArchive * ha = (TMPQArchive *)hMPQ; - TMPQSearch * hs = NULL; // Search object handle - size_t nSize = 0; - int nError = ERROR_SUCCESS; - - // Check for the valid parameters - if(nError == ERROR_SUCCESS) - { - if(!IsValidMpqHandle(ha)) - nError = ERROR_INVALID_PARAMETER; - - if(szMask == NULL || lpFindFileData == NULL) - nError = ERROR_INVALID_PARAMETER; - - if(szListFile == NULL && !IsValidMpqHandle(ha)) - nError = ERROR_INVALID_PARAMETER; - } - - // Include the listfile into the MPQ's internal listfile - // Note that if the listfile name is NULL, do nothing because the - // internal listfile is always included. - if(nError == ERROR_SUCCESS && szListFile != NULL) - nError = SFileAddListFile((HANDLE)ha, szListFile); - - // Allocate the structure for MPQ search - if(nError == ERROR_SUCCESS) - { - nSize = sizeof(TMPQSearch) + strlen(szMask) + 1; - if((hs = (TMPQSearch *)ALLOCMEM(char, nSize)) == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Perform the first search - if(nError == ERROR_SUCCESS) - { - memset(hs, 0, sizeof(TMPQSearch)); - hs->ha = ha; - hs->dwNextIndex = 0; - strcpy(hs->szSearchMask, szMask); - nError = DoMPQSearch(hs, lpFindFileData); - } - - // Cleanup - if(nError != ERROR_SUCCESS) - { - FreeMPQSearch(hs); - SetLastError(nError); - } - - // Return the result value - return (HANDLE)hs; -} - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData) -{ - TMPQSearch * hs = (TMPQSearch *)hFind; - int nError = ERROR_SUCCESS; - - // Check the parameters - if(nError == ERROR_SUCCESS) - { - if(!IsValidSearchHandle(hs) || lpFindFileData == NULL) - nError = ERROR_INVALID_PARAMETER; - } - - if(nError == ERROR_SUCCESS) - nError = DoMPQSearch(hs, lpFindFileData); - - if(nError != ERROR_SUCCESS) - { - SetLastError(nError); - return FALSE; - } - return TRUE; -} - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileFindClose(HANDLE hFind) -{ - TMPQSearch * hs = (TMPQSearch *)hFind; - - // Check the parameters - if(!IsValidSearchHandle(hs)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - FreeMPQSearch(hs); - return TRUE; -} diff --git a/contrib/vmap_extractor_v2/stormlib/SFileOpenArchive.cpp b/contrib/vmap_extractor_v2/stormlib/SFileOpenArchive.cpp deleted file mode 100644 index cadb4e023a2..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/SFileOpenArchive.cpp +++ /dev/null @@ -1,497 +0,0 @@ -/*****************************************************************************/ -/* SFileOpenArchive.cpp Copyright Ladislav Zezula 1999 */ -/* */ -/* Author : Ladislav Zezula */ -/* E-mail : ladik@zezula.net */ -/* WWW : www.zezula.net */ -/*---------------------------------------------------------------------------*/ -/* Archive functions of Storm.dll */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* xx.xx.xx 1.00 Lad The first version of SFileOpenArchive.cpp */ -/* 19.11.03 1.01 Dan Big endian handling */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "SCommon.h" - -/*****************************************************************************/ -/* Local functions */ -/*****************************************************************************/ - -static BOOL IsAviFile(TMPQHeader * pHeader) -{ - DWORD * AviHdr = (DWORD *)pHeader; - - // Test for 'RIFF', 'AVI ' or 'LIST' - return (AviHdr[0] == 'FFIR' && AviHdr[2] == ' IVA' && AviHdr[3] == 'TSIL'); -} - -// This function gets the right positions of the hash table and the block table. -// TODO: Test for archives > 4GB -static int RelocateMpqTablePositions(TMPQArchive * ha) -{ - TMPQHeader2 * pHeader = ha->pHeader; - LARGE_INTEGER FileSize; - LARGE_INTEGER TempSize; - - // Get the size of the file - FileSize.LowPart = GetFileSize(ha->hFile, (LPDWORD)&FileSize.HighPart); - - // Set the proper hash table position - ha->HashTablePos.HighPart = pHeader->wHashTablePosHigh; - ha->HashTablePos.LowPart = pHeader->dwHashTablePos; - ha->HashTablePos.QuadPart += ha->MpqPos.QuadPart; - if(ha->HashTablePos.QuadPart > FileSize.QuadPart) - return ERROR_BAD_FORMAT; - - // Set the proper block table position - ha->BlockTablePos.HighPart = pHeader->wBlockTablePosHigh; - ha->BlockTablePos.LowPart = pHeader->dwBlockTablePos; - ha->BlockTablePos.QuadPart += ha->MpqPos.QuadPart; - if(ha->BlockTablePos.QuadPart > FileSize.QuadPart) - return ERROR_BAD_FORMAT; - - // Set the proper position of the extended block table - if(pHeader->ExtBlockTablePos.QuadPart != 0) - { - ha->ExtBlockTablePos = pHeader->ExtBlockTablePos; - ha->ExtBlockTablePos.QuadPart += ha->MpqPos.QuadPart; - if(ha->ExtBlockTablePos.QuadPart > FileSize.QuadPart) - return ERROR_BAD_FORMAT; - } - - // Size of MPQ archive is computed as the biggest of - // (EndOfBlockTable, EndOfHashTable, EndOfExtBlockTable) - TempSize.QuadPart = ha->HashTablePos.QuadPart + (pHeader->dwHashTableSize * sizeof(TMPQHash)); - if(TempSize.QuadPart > ha->MpqSize.QuadPart) - ha->MpqSize = TempSize; - TempSize.QuadPart = ha->BlockTablePos.QuadPart + (pHeader->dwBlockTableSize * sizeof(TMPQBlock)); - if(TempSize.QuadPart > ha->MpqSize.QuadPart) - ha->MpqSize = TempSize; - TempSize.QuadPart = ha->ExtBlockTablePos.QuadPart + (pHeader->dwBlockTableSize * sizeof(TMPQBlockEx)); - if(TempSize.QuadPart > ha->MpqSize.QuadPart) - ha->MpqSize = TempSize; - - // MPQ size does not include the bytes before MPQ header - ha->MpqSize.QuadPart -= ha->MpqPos.QuadPart; - return ERROR_SUCCESS; -} - - -/*****************************************************************************/ -/* Public functions */ -/*****************************************************************************/ - -//----------------------------------------------------------------------------- -// SFileGetLocale and SFileSetLocale -// Set the locale for all neewly opened archives and files - -LCID WINAPI SFileGetLocale() -{ - return lcLocale; -} - -LCID WINAPI SFileSetLocale(LCID lcNewLocale) -{ - lcLocale = lcNewLocale; - return lcLocale; -} - -//----------------------------------------------------------------------------- -// SFileOpenArchiveEx (not a public function !!!) -// -// szFileName - MPQ archive file name to open -// dwPriority - When SFileOpenFileEx called, this contains the search priority for searched archives -// dwFlags - If contains MPQ_OPEN_NO_LISTFILE, then the internal list file will not be used. -// phMPQ - Pointer to store open archive handle - -BOOL SFileOpenArchiveEx( - const char * szMpqName, - DWORD dwPriority, - DWORD dwFlags, - HANDLE * phMPQ, - DWORD dwAccessMode) -{ - LARGE_INTEGER TempPos; - TMPQArchive * ha = NULL; // Archive handle - HANDLE hFile = INVALID_HANDLE_VALUE;// Opened archive file handle - DWORD dwMaxBlockIndex = 0; // Maximum value of block entry - DWORD dwBlockTableSize = 0; // Block table size. - DWORD dwTransferred; // Number of bytes read - DWORD dwBytes = 0; // Number of bytes to read - int nError = ERROR_SUCCESS; - - // Check the right parameters - if(nError == ERROR_SUCCESS) - { - if(szMpqName == NULL || *szMpqName == 0 || phMPQ == NULL) - nError = ERROR_INVALID_PARAMETER; - } - - // Ensure that StormBuffer is allocated - if(nError == ERROR_SUCCESS) - nError = PrepareStormBuffer(); - - // Open the MPQ archive file - if(nError == ERROR_SUCCESS) - { - hFile = CreateFile(szMpqName, dwAccessMode, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - if(hFile == INVALID_HANDLE_VALUE) - nError = GetLastError(); - } - - // Allocate the MPQhandle - if(nError == ERROR_SUCCESS) - { - if((ha = ALLOCMEM(TMPQArchive, 1)) == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Initialize handle structure and allocate structure for MPQ header - if(nError == ERROR_SUCCESS) - { - memset(ha, 0, sizeof(TMPQArchive)); - strncpy(ha->szFileName, szMpqName, strlen(szMpqName)); - ha->hFile = hFile; - ha->dwPriority = dwPriority; - ha->pHeader = &ha->Header; - ha->pListFile = NULL; - hFile = INVALID_HANDLE_VALUE; - } - - // Find the offset of MPQ header within the file - if(nError == ERROR_SUCCESS) - { - LARGE_INTEGER SearchPos = {0}; - LARGE_INTEGER MpqPos = {0}; - DWORD dwHeaderID; - - for(;;) - { - // Invalidate the MPQ ID and read the eventual header - SetFilePointer(ha->hFile, MpqPos.LowPart, &MpqPos.HighPart, FILE_BEGIN); - ReadFile(ha->hFile, ha->pHeader, sizeof(TMPQHeader2), &dwTransferred, NULL); - dwHeaderID = BSWAP_INT32_UNSIGNED(ha->pHeader->dwID); - - // Special check : Some MPQs are actually AVI files, only with - // changed extension. - if(MpqPos.QuadPart == 0 && IsAviFile(ha->pHeader)) - { - nError = ERROR_AVI_FILE; - break; - } - - // If different number of bytes read, break the loop - if(dwTransferred != sizeof(TMPQHeader2)) - { - nError = ERROR_BAD_FORMAT; - break; - } - - // If there is the MPQ shunt signature, process it - if(dwHeaderID == ID_MPQ_SHUNT && ha->pShunt == NULL) - { - // Fill the shunt header - ha->ShuntPos = MpqPos; - ha->pShunt = &ha->Shunt; - memcpy(ha->pShunt, ha->pHeader, sizeof(TMPQShunt)); - BSWAP_TMPQSHUNT(ha->pShunt); - - // Set the MPQ pos and repeat the search - MpqPos.QuadPart = SearchPos.QuadPart + ha->pShunt->dwHeaderPos; - continue; - } - - // There must be MPQ header signature - if(dwHeaderID == ID_MPQ) - { - BSWAP_TMPQHEADER(ha->pHeader); - - // Save the position where the MPQ header has been found - ha->MpqPos = MpqPos; - - // If valid signature has been found, break the loop - if(ha->pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1) - { - // W3M Map Protectors set some garbage value into the "dwHeaderSize" - // field of MPQ header. This value is apparently ignored by Storm.dll - if(ha->pHeader->dwHeaderSize != sizeof(TMPQHeader) && - ha->pHeader->dwHeaderSize != sizeof(TMPQHeader2)) - { - ha->dwFlags |= MPQ_FLAG_PROTECTED; - ha->pHeader->dwHeaderSize = sizeof(TMPQHeader); - } - - if(ha->pHeader->dwHashTablePos < ha->pHeader->dwArchiveSize && - ha->pHeader->dwBlockTablePos < ha->pHeader->dwArchiveSize) - { - break; - } - } - - if(ha->pHeader->wFormatVersion == MPQ_FORMAT_VERSION_2) - { - break; - } - - nError = ERROR_NOT_SUPPORTED; - break; - } - - // If a MPQ shunt already has been found, - // and no MPQ header was at potision pointed by the shunt, - // then the archive is corrupt - if(ha->pShunt != NULL) - { - nError = ERROR_BAD_FORMAT; - break; - } - - // Move to the next possible offset - SearchPos.QuadPart += 0x200; - MpqPos = SearchPos; - } - } - - // Relocate tables position - if(nError == ERROR_SUCCESS) - { - // Clear the fields not supported in older formats - if(ha->pHeader->wFormatVersion < MPQ_FORMAT_VERSION_2) - { - ha->pHeader->ExtBlockTablePos.QuadPart = 0; - ha->pHeader->wBlockTablePosHigh = 0; - ha->pHeader->wHashTablePosHigh = 0; - } - - ha->dwBlockSize = (0x200 << ha->pHeader->wBlockSize); - nError = RelocateMpqTablePositions(ha); - } - - // Allocate buffers - if(nError == ERROR_SUCCESS) - { - // - // Note that the block table should be as large as the hash table - // (For later file additions). - // - // I have found a MPQ which has the block table larger than - // the hash table. We should avoid buffer overruns caused by that. - // - dwBlockTableSize = max(ha->pHeader->dwHashTableSize, ha->pHeader->dwBlockTableSize); - - ha->pHashTable = ALLOCMEM(TMPQHash, ha->pHeader->dwHashTableSize); - ha->pBlockTable = ALLOCMEM(TMPQBlock, dwBlockTableSize); - ha->pExtBlockTable = ALLOCMEM(TMPQBlockEx, dwBlockTableSize); - ha->pbBlockBuffer = ALLOCMEM(BYTE, ha->dwBlockSize); - - if(!ha->pHashTable || !ha->pBlockTable || !ha->pExtBlockTable || !ha->pbBlockBuffer) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Read the hash table into memory - if(nError == ERROR_SUCCESS) - { - dwBytes = ha->pHeader->dwHashTableSize * sizeof(TMPQHash); - SetFilePointer(ha->hFile, ha->HashTablePos.LowPart, &ha->HashTablePos.HighPart, FILE_BEGIN); - ReadFile(ha->hFile, ha->pHashTable, dwBytes, &dwTransferred, NULL); - - if(dwTransferred != dwBytes) - nError = ERROR_FILE_CORRUPT; - } - - // Decrypt hash table and check if it is correctly decrypted - if(nError == ERROR_SUCCESS) - { - TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - TMPQHash * pHash; - - // We have to convert the hash table from LittleEndian - BSWAP_ARRAY32_UNSIGNED((DWORD *)ha->pHashTable, (dwBytes / sizeof(DWORD))); - DecryptHashTable((DWORD *)ha->pHashTable, (BYTE *)"(hash table)", (ha->pHeader->dwHashTableSize * 4)); - - // Check hash table if is correctly decrypted - for(pHash = ha->pHashTable; pHash < pHashEnd; pHash++) - { - // Note: Some MPQs from World of Warcraft have wPlatform set to 0x0100. - - // If not free or deleted hash entry, check for valid values - if(pHash->dwBlockIndex < HASH_ENTRY_DELETED) - { - // The block index should not be larger than size of the block table - if(pHash->dwBlockIndex > ha->pHeader->dwBlockTableSize) - { - nError = ERROR_BAD_FORMAT; - break; - } - - // Remember the highest block table entry - if(pHash->dwBlockIndex > dwMaxBlockIndex) - dwMaxBlockIndex = pHash->dwBlockIndex; - } - } - } - - // Now, read the block table - if(nError == ERROR_SUCCESS) - { - memset(ha->pBlockTable, 0, dwBlockTableSize * sizeof(TMPQBlock)); - - dwBytes = ha->pHeader->dwBlockTableSize * sizeof(TMPQBlock); - SetFilePointer(ha->hFile, ha->BlockTablePos.LowPart, &ha->BlockTablePos.HighPart, FILE_BEGIN); - ReadFile(ha->hFile, ha->pBlockTable, dwBytes, &dwTransferred, NULL); - - // We have to convert every DWORD in ha->block from LittleEndian - BSWAP_ARRAY32_UNSIGNED((DWORD *)ha->pBlockTable, dwBytes / sizeof(DWORD)); - - if(dwTransferred != dwBytes) - nError = ERROR_FILE_CORRUPT; - } - - // Decrypt block table. - // Some MPQs don't have Decrypted block table, e.g. cracked Diablo version - // We have to check if block table is really encrypted - if(nError == ERROR_SUCCESS) - { - TMPQBlock * pBlockEnd = ha->pBlockTable + ha->pHeader->dwBlockTableSize; - TMPQBlock * pBlock = ha->pBlockTable; - BOOL bBlockTableEncrypted = FALSE; - - // Verify all blocks entries in the table - // The loop usually stops at the first entry - while(pBlock < pBlockEnd) - { - // The lower 8 bits of the MPQ flags are always zero. - // Note that this may change in next MPQ versions - if(pBlock->dwFlags & 0x000000FF) - { - bBlockTableEncrypted = TRUE; - break; - } - - // Move to the next block table entry - pBlock++; - } - - if(bBlockTableEncrypted) - { - DecryptBlockTable((DWORD *)ha->pBlockTable, - (BYTE *)"(block table)", - (ha->pHeader->dwBlockTableSize * 4)); - } - } - - // Now, read the extended block table. - // For V1 archives, we still will maintain the extended block table - // (it will be filled with zeros) - // TODO: Test with >4GB - if(nError == ERROR_SUCCESS) - { - memset(ha->pExtBlockTable, 0, dwBlockTableSize * sizeof(TMPQBlockEx)); - - if(ha->pHeader->ExtBlockTablePos.QuadPart != 0) - { - dwBytes = ha->pHeader->dwBlockTableSize * sizeof(TMPQBlockEx); - SetFilePointer(ha->hFile, - ha->ExtBlockTablePos.LowPart, - &ha->ExtBlockTablePos.HighPart, - FILE_BEGIN); - ReadFile(ha->hFile, ha->pExtBlockTable, dwBytes, &dwTransferred, NULL); - - // We have to convert every DWORD in ha->block from LittleEndian - BSWAP_ARRAY16_UNSIGNED((USHORT *)ha->pExtBlockTable, dwBytes / sizeof(USHORT)); - - // The extended block table is not encrypted (so far) - if(dwTransferred != dwBytes) - nError = ERROR_FILE_CORRUPT; - } - } - - // Verify the both block tables (If the MPQ file is not protected) - if(nError == ERROR_SUCCESS && (ha->dwFlags & MPQ_FLAG_PROTECTED) == 0) - { - TMPQBlockEx * pBlockEx = ha->pExtBlockTable; - TMPQBlock * pBlockEnd = ha->pBlockTable + dwMaxBlockIndex + 1; - TMPQBlock * pBlock = ha->pBlockTable; - - // If the MPQ file is not protected, - // we will check if all sizes in the block table is correct. - // Note that we will not relocate the block table (change from previous versions) - for(; pBlock < pBlockEnd; pBlock++, pBlockEx++) - { - if(pBlock->dwFlags & MPQ_FILE_EXISTS) - { - // Get the 64-bit file position - TempPos.HighPart = pBlockEx->wFilePosHigh; - TempPos.LowPart = pBlock->dwFilePos; - - if(TempPos.QuadPart > ha->MpqSize.QuadPart || pBlock->dwCSize > ha->MpqSize.QuadPart) - { - nError = ERROR_BAD_FORMAT; - break; - } - } - } - } - - // If the user didn't specified otherwise, - // include the internal listfile to the TMPQArchive structure - if((dwFlags & MPQ_OPEN_NO_LISTFILE) == 0) - { - if(nError == ERROR_SUCCESS) - SListFileCreateListFile(ha); - - // Add the internal listfile - if(nError == ERROR_SUCCESS) - SFileAddListFile((HANDLE)ha, NULL); - } - - // Cleanup and exit - if(nError != ERROR_SUCCESS) - { - FreeMPQArchive(ha); - if(hFile != INVALID_HANDLE_VALUE) - CloseHandle(hFile); - SetLastError(nError); - } - else - { - if(pFirstOpen == NULL) - pFirstOpen = ha; - } - *phMPQ = ha; - return (nError == ERROR_SUCCESS); -} - -BOOL WINAPI SFileOpenArchive(const char * szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE * phMPQ) -{ - return SFileOpenArchiveEx(szMpqName, dwPriority, dwFlags, phMPQ, GENERIC_READ); -} - -//----------------------------------------------------------------------------- -// BOOL SFileCloseArchive(HANDLE hMPQ); -// - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileCloseArchive(HANDLE hMPQ) -{ - TMPQArchive * ha = (TMPQArchive *)hMPQ; - - if(!IsValidMpqHandle(ha)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - if(ha->dwFlags & MPQ_FLAG_CHANGED) - { - SListFileSaveToMpq(ha); - SaveMPQTables(ha); - } - FreeMPQArchive(ha); - return TRUE; -} - diff --git a/contrib/vmap_extractor_v2/stormlib/SFileOpenFileEx.cpp b/contrib/vmap_extractor_v2/stormlib/SFileOpenFileEx.cpp deleted file mode 100644 index dae312144eb..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/SFileOpenFileEx.cpp +++ /dev/null @@ -1,403 +0,0 @@ -/*****************************************************************************/ -/* SFileOpenFileEx.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Description : */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* xx.xx.99 1.00 Lad The first version of SFileOpenFileEx.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "SCommon.h" - -/*****************************************************************************/ -/* Local functions */ -/*****************************************************************************/ - -// TODO: Test for archives > 4GB -static BOOL OpenLocalFile(const char * szFileName, HANDLE * phFile) -{ - TMPQFile * hf = NULL; - HANDLE hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL); - - if(hFile != INVALID_HANDLE_VALUE) - { - // Allocate and initialize file handle - size_t nHandleSize = sizeof(TMPQFile) + strlen(szFileName); - if((hf = (TMPQFile *)ALLOCMEM(char, nHandleSize)) != NULL) - { - memset(hf, 0, nHandleSize); - strcpy(hf->szFileName, szFileName); - hf->hFile = hFile; - *phFile = hf; - return TRUE; - } - else - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - } - *phFile = NULL; - return FALSE; -} - -// TODO: Test for archives > 4GB -static void FreeMPQFile(TMPQFile *& hf) -{ - if(hf != NULL) - { - if(hf->hFile != INVALID_HANDLE_VALUE) - CloseHandle(hf->hFile); - if(hf->pdwBlockPos != NULL) - FREEMEM(hf->pdwBlockPos); - if(hf->pbFileBuffer != NULL) - FREEMEM(hf->pbFileBuffer); - FREEMEM(hf); - hf = NULL; - } -} - -/*****************************************************************************/ -/* Public functions */ -/*****************************************************************************/ - -//----------------------------------------------------------------------------- -// SFileEnumLocales enums all locale versions within MPQ. -// Functions fills all available language identifiers on a file into the buffer -// pointed by plcLocales. There must be enough entries to copy the localed, -// otherwise the function returns ERROR_INSUFFICIENT_BUFFER. - -// TODO: Test for archives > 4GB -int WINAPI SFileEnumLocales( - HANDLE hMPQ, - const char * szFileName, - LCID * plcLocales, - DWORD * pdwMaxLocales, - DWORD dwSearchScope) -{ - TMPQArchive * ha = (TMPQArchive *)hMPQ; - TMPQHash * pHash = NULL; - TMPQHash * pHashEnd = NULL; - DWORD dwLocales = 0; - int nError = ERROR_SUCCESS; - - // Test the parameters - if(nError == ERROR_SUCCESS) - { - if(!IsValidMpqHandle(ha) || pdwMaxLocales == NULL) - nError = ERROR_INVALID_PARAMETER; - if(dwSearchScope == SFILE_OPEN_BY_INDEX && (DWORD_PTR)szFileName > ha->pHeader->dwBlockTableSize) - nError = ERROR_INVALID_PARAMETER; - if(dwSearchScope != SFILE_OPEN_BY_INDEX && *szFileName == 0) - nError = ERROR_INVALID_PARAMETER; - } - - // Retrieve the hash entry for the required file - if(nError == ERROR_SUCCESS) - { - pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - - if(dwSearchScope == SFILE_OPEN_BY_INDEX) - { - for(pHash = ha->pHashTable; pHash < pHashEnd; pHash++) - { - if(pHash->dwBlockIndex == (DWORD_PTR)szFileName) - break; - } - if(pHash == pHashEnd) - pHash = NULL; - } - else - pHash = GetHashEntry(ha, szFileName); - } - - // If the file was not found, sorry - if(nError == ERROR_SUCCESS) - { - if(pHash == NULL) - nError = ERROR_FILE_NOT_FOUND; - } - - // Count the entries which correspond to the same file name - if(nError == ERROR_SUCCESS) - { - TMPQHash * pSaveHash = pHash; - DWORD dwName1 = pHash->dwName1; - DWORD dwName2 = pHash->dwName2; - - // For nameless access, return 1 locale always - if(dwSearchScope == SFILE_OPEN_BY_INDEX) - dwLocales++; - else - { - while(pHash < pHashEnd && pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2) - { - dwLocales++; - pHash++; - } - } - - pHash = pSaveHash; - } - - // Test if there is enough space to copy the locales - if(nError == ERROR_SUCCESS) - { - DWORD dwMaxLocales = *pdwMaxLocales; - - *pdwMaxLocales = dwLocales; - if(dwMaxLocales < dwLocales) - nError = ERROR_INSUFFICIENT_BUFFER; - } - - // Fill all the locales - if(nError == ERROR_SUCCESS) - { - for(DWORD i = 0; i < dwLocales; i++, pHash++) - *plcLocales++ = (LCID)pHash->lcLocale; - } - return nError; -} - -//----------------------------------------------------------------------------- -// SFileHasFile -// -// hMPQ - Handle of opened MPQ archive -// szFileName - Name of file to look for - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileHasFile(HANDLE hMPQ, char * szFileName) -{ - TMPQArchive * ha = (TMPQArchive *)hMPQ; - int nError = ERROR_SUCCESS; - - if(nError == ERROR_SUCCESS) - { - if(ha == NULL) - nError = ERROR_INVALID_PARAMETER; - if(*szFileName == 0) - nError = ERROR_INVALID_PARAMETER; - } - - // Prepare the file opening - if(nError == ERROR_SUCCESS) - { - if(GetHashEntryEx(ha, szFileName, lcLocale) == NULL) - { - nError = ERROR_FILE_NOT_FOUND; - } - } - - // Cleanup - if(nError != ERROR_SUCCESS) - { - SetLastError(nError); - } - - return (nError == ERROR_SUCCESS); -} - - -//----------------------------------------------------------------------------- -// SFileOpenFileEx -// -// hMPQ - Handle of opened MPQ archive -// szFileName - Name of file to open -// dwSearchScope - Where to search -// phFile - Pointer to store opened file handle - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileOpenFileEx(HANDLE hMPQ, const char * szFileName, DWORD dwSearchScope, HANDLE * phFile) -{ - LARGE_INTEGER FilePos; - TMPQArchive * ha = (TMPQArchive *)hMPQ; - TMPQFile * hf = NULL; - TMPQHash * pHash = NULL; // Hash table index - TMPQBlock * pBlock = NULL; // File block - TMPQBlockEx * pBlockEx = NULL; - DWORD dwHashIndex = 0; // Hash table index - DWORD dwBlockIndex = (DWORD)-1; // Found table index - size_t nHandleSize = 0; // Memory space necessary to allocate TMPQHandle - int nError = ERROR_SUCCESS; - -#ifdef _DEBUG - // Due to increasing numbers of files in MPQs, I had to change the behavior - // of opening by file index. Now, the SFILE_OPEN_BY_INDEX value of dwSearchScope - // must be entered. This check will allow to find code places that are incompatible - // with the new behavior. - if(dwSearchScope != SFILE_OPEN_BY_INDEX && szFileName != NULL) - { - assert((DWORD_PTR)szFileName > 0x10000); - } -#endif - - if(nError == ERROR_SUCCESS) - { - if(ha == NULL && dwSearchScope == SFILE_OPEN_FROM_MPQ) - nError = ERROR_INVALID_PARAMETER; - if(phFile == NULL) - nError = ERROR_INVALID_PARAMETER; - if(dwSearchScope == SFILE_OPEN_BY_INDEX && (DWORD_PTR)szFileName > ha->pHeader->dwBlockTableSize) - nError = ERROR_INVALID_PARAMETER; - if(dwSearchScope != SFILE_OPEN_BY_INDEX && (szFileName == NULL || *szFileName == 0)) - nError = ERROR_INVALID_PARAMETER; - } - - // Prepare the file opening - if(nError == ERROR_SUCCESS) - { - // When the file is given by number, ... - if(dwSearchScope == SFILE_OPEN_BY_INDEX) - { - TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - - // Set handle size to be sizeof(TMPQFile) + length of FileXXXXXXXX.xxx - nHandleSize = sizeof(TMPQFile) + 20; - for(pHash = ha->pHashTable; pHash < pHashEnd; pHash++) - { - if((DWORD_PTR)szFileName == pHash->dwBlockIndex) - { - dwHashIndex = (DWORD)(pHash - ha->pHashTable); - dwBlockIndex = pHash->dwBlockIndex; - break; - } - } - } - else - { - // If we have to open a disk file - if(dwSearchScope == SFILE_OPEN_LOCAL_FILE) - return OpenLocalFile(szFileName, phFile); - - nHandleSize = sizeof(TMPQFile) + strlen(szFileName); - if((pHash = GetHashEntryEx(ha, szFileName, lcLocale)) != NULL) - { - dwHashIndex = (DWORD)(pHash - ha->pHashTable); - dwBlockIndex = pHash->dwBlockIndex; - } - } - } - - // Get block index from file name and test it - if(nError == ERROR_SUCCESS) - { - // If index was not found, or is greater than number of files, exit. - if(dwBlockIndex == (DWORD)-1 || dwBlockIndex > ha->pHeader->dwBlockTableSize) - nError = ERROR_FILE_NOT_FOUND; - } - - // Get block and test if the file was not already deleted. - if(nError == ERROR_SUCCESS) - { - // Get both block tables and file position - pBlockEx = ha->pExtBlockTable + dwBlockIndex; - pBlock = ha->pBlockTable + dwBlockIndex; - FilePos.HighPart = pBlockEx->wFilePosHigh; - FilePos.LowPart = pBlock->dwFilePos; - - if(FilePos.QuadPart > ha->MpqSize.QuadPart || - pBlock->dwCSize > ha->MpqSize.QuadPart) - nError = ERROR_FILE_CORRUPT; - if((pBlock->dwFlags & MPQ_FILE_EXISTS) == 0) - nError = ERROR_FILE_NOT_FOUND; - if(pBlock->dwFlags & ~MPQ_FILE_VALID_FLAGS) - nError = ERROR_NOT_SUPPORTED; - } - - // Allocate file handle - if(nError == ERROR_SUCCESS) - { - if((hf = (TMPQFile *)ALLOCMEM(char, nHandleSize)) == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Initialize file handle - if(nError == ERROR_SUCCESS) - { - memset(hf, 0, nHandleSize); - hf->hFile = INVALID_HANDLE_VALUE; - hf->ha = ha; - hf->pBlockEx = pBlockEx; - hf->pBlock = pBlock; - hf->nBlocks = (hf->pBlock->dwFSize + ha->dwBlockSize - 1) / ha->dwBlockSize; - hf->pHash = pHash; - - hf->MpqFilePos.HighPart = pBlockEx->wFilePosHigh; - hf->MpqFilePos.LowPart = pBlock->dwFilePos; - hf->MpqFilePos.QuadPart += ha->MpqPos.QuadPart; - - hf->dwHashIndex = dwHashIndex; - hf->dwFileIndex = dwBlockIndex; - - // Allocate buffers for decompression. - if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESSED) - { - // Allocate buffer for block positions. At the begin of file are stored - // DWORDs holding positions of each block relative from begin of file in the archive - // As for newer MPQs, there may be one additional entry in the block table - // (if the MPQ_FILE_HAS_EXTRA flag is set). - // Allocate the buffer to include this DWORD as well - - if((hf->pdwBlockPos = ALLOCMEM(DWORD, hf->nBlocks + 2)) == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Decrypt file seed. Cannot be used if the file is given by index - if(dwSearchScope != SFILE_OPEN_BY_INDEX) - { - if(hf->pBlock->dwFlags & MPQ_FILE_ENCRYPTED) - { - const char * szTemp = strrchr(szFileName, '\\'); - - strcpy(hf->szFileName, szFileName); - if(szTemp != NULL) - szFileName = szTemp + 1; - hf->dwSeed1 = DecryptFileSeed((char *)szFileName); - - if(hf->pBlock->dwFlags & MPQ_FILE_FIXSEED) - { - hf->dwSeed1 = (hf->dwSeed1 + hf->pBlock->dwFilePos) ^ hf->pBlock->dwFSize; - } - } - } - else - { - // If the file is encrypted and not compressed, we cannot detect the file seed - if(SFileGetFileName(hf, hf->szFileName) == FALSE) - nError = GetLastError(); - } - } - - // Cleanup - if(nError != ERROR_SUCCESS) - { - FreeMPQFile(hf); - SetLastError(nError); - } - - *phFile = hf; - return (nError == ERROR_SUCCESS); -} - -//----------------------------------------------------------------------------- -// BOOL SFileCloseFile(HANDLE hFile); - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileCloseFile(HANDLE hFile) -{ - TMPQFile * hf = (TMPQFile *)hFile; - - if(!IsValidFileHandle(hf)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - // Set the last accessed file in the archive - if(hf->ha != NULL) - hf->ha->pLastFile = NULL; - - // Free the structure - FreeMPQFile(hf); - return TRUE; -} diff --git a/contrib/vmap_extractor_v2/stormlib/SFileReadFile.cpp b/contrib/vmap_extractor_v2/stormlib/SFileReadFile.cpp deleted file mode 100644 index 27fd1e0f085..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/SFileReadFile.cpp +++ /dev/null @@ -1,826 +0,0 @@ -/*****************************************************************************/ -/* SFileReadFile.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Description : */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* xx.xx.99 1.00 Lad The first version of SFileReadFile.cpp */ -/* 24.03.99 1.00 Lad Added the SFileGetFileInfo function */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "SCommon.h" - -//----------------------------------------------------------------------------- -// Defines - -#define ID_WAVE 0x46464952 // Signature of WAVes for name breaking -#define ID_EXE 0x00005A4D // Signature of executable files - -//----------------------------------------------------------------------------- -// Local structures - -struct TID2Ext -{ - DWORD dwID; - char * szExt; -}; - -//----------------------------------------------------------------------------- -// ReadMPQBlock -// -// hf - MPQ File handle. -// dwBlockPos - Position of block in the file (relative to file begin) -// buffer - Pointer to target buffer to store blocks. -// dwBlockSize - Number of bytes to read. Must be multiplier of block size. -// -// Returns number of bytes read. - -// TODO: Test for archives > 4GB -static DWORD WINAPI ReadMPQBlocks(TMPQFile * hf, DWORD dwBlockPos, BYTE * buffer, DWORD blockBytes) -{ - LARGE_INTEGER FilePos; - TMPQArchive * ha = hf->ha; // Archive handle - BYTE * tempBuffer = NULL; // Buffer for reading compressed data from the file - DWORD dwFilePos = dwBlockPos; // Reading position from the file - DWORD dwToRead; // Number of bytes to read - DWORD blockNum; // Block number (needed for decrypt) - DWORD dwBytesRead = 0; // Total number of bytes read - DWORD bytesRemain = 0; // Number of data bytes remaining up to the end of the file - DWORD nBlocks; // Number of blocks to load - DWORD i; - - // Test parameters. Block position and block size must be block-aligned, block size nonzero - if((dwBlockPos & (ha->dwBlockSize - 1)) || blockBytes == 0) - return 0; - - // Check the end of file - if((dwBlockPos + blockBytes) > hf->pBlock->dwFSize) - blockBytes = hf->pBlock->dwFSize - dwBlockPos; - - bytesRemain = hf->pBlock->dwFSize - dwBlockPos; - blockNum = dwBlockPos / ha->dwBlockSize; - nBlocks = blockBytes / ha->dwBlockSize; - if(blockBytes % ha->dwBlockSize) - nBlocks++; - - // If file has variable block positions, we have to load them - if((hf->pBlock->dwFlags & MPQ_FILE_COMPRESSED) && hf->bBlockPosLoaded == FALSE) - { - // Move file pointer to the begin of the file in the MPQ - if(hf->MpqFilePos.QuadPart != ha->FilePointer.QuadPart) - { - SetFilePointer(ha->hFile, hf->MpqFilePos.LowPart, &hf->MpqFilePos.HighPart, FILE_BEGIN); - } - - // Read block positions from begin of file. - dwToRead = (hf->nBlocks+1) * sizeof(DWORD); - if(hf->pBlock->dwFlags & MPQ_FILE_HAS_EXTRA) - dwToRead += sizeof(DWORD); - - // Read the block pos table and convert the buffer to little endian - ReadFile(ha->hFile, hf->pdwBlockPos, dwToRead, &dwBytesRead, NULL); - BSWAP_ARRAY32_UNSIGNED(hf->pdwBlockPos, (hf->nBlocks+1)); - - // - // If the archive if protected some way, perform additional check - // Sometimes, the file appears not to be encrypted, but it is. - // - // Note: In WoW 1.10+, there's a new flag. With this flag present, - // there's one additional entry in the block table. - // - - if(hf->pdwBlockPos[0] != dwBytesRead) - hf->pBlock->dwFlags |= MPQ_FILE_ENCRYPTED; - - // Decrypt loaded block positions if necessary - if(hf->pBlock->dwFlags & MPQ_FILE_ENCRYPTED) - { - // If we don't know the file seed, try to find it. - if(hf->dwSeed1 == 0) - hf->dwSeed1 = DetectFileSeed(hf->pdwBlockPos, dwBytesRead); - - // If we don't know the file seed, sorry but we cannot extract the file. - if(hf->dwSeed1 == 0) - return 0; - - // Decrypt block positions - DecryptMPQBlock(hf->pdwBlockPos, dwBytesRead, hf->dwSeed1 - 1); - - // Check if the block positions are correctly decrypted - // I don't know why, but sometimes it will result invalid block positions on some files - if(hf->pdwBlockPos[0] != dwBytesRead) - { - // Try once again to detect file seed and decrypt the blocks - // TODO: Test with >4GB - SetFilePointer(ha->hFile, hf->MpqFilePos.LowPart, &hf->MpqFilePos.HighPart, FILE_BEGIN); - ReadFile(ha->hFile, hf->pdwBlockPos, dwToRead, &dwBytesRead, NULL); - - BSWAP_ARRAY32_UNSIGNED(hf->pdwBlockPos, (hf->nBlocks+1)); - hf->dwSeed1 = DetectFileSeed(hf->pdwBlockPos, dwBytesRead); - DecryptMPQBlock(hf->pdwBlockPos, dwBytesRead, hf->dwSeed1 - 1); - - // Check if the block positions are correctly decrypted - if(hf->pdwBlockPos[0] != dwBytesRead) - return 0; - } - } - - // Update hf's variables - ha->FilePointer.QuadPart = hf->MpqFilePos.QuadPart + dwBytesRead; - hf->bBlockPosLoaded = TRUE; - } - - // Get file position and number of bytes to read - dwFilePos = dwBlockPos; - dwToRead = blockBytes; - if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESSED) - { - dwFilePos = hf->pdwBlockPos[blockNum]; - dwToRead = hf->pdwBlockPos[blockNum + nBlocks] - dwFilePos; - } - FilePos.QuadPart = hf->MpqFilePos.QuadPart + dwFilePos; - - // Get work buffer for store read data - tempBuffer = buffer; - if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESSED) - { - if((tempBuffer = ALLOCMEM(BYTE, dwToRead)) == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - } - - // Set file pointer, if necessary - if(ha->FilePointer.QuadPart != FilePos.QuadPart) - { - SetFilePointer(ha->hFile, FilePos.LowPart, &FilePos.HighPart, FILE_BEGIN); - } - - // 15018F87 : Read all requested blocks - ReadFile(ha->hFile, tempBuffer, dwToRead, &dwBytesRead, NULL); - ha->FilePointer.QuadPart = FilePos.QuadPart + dwBytesRead; - - // Block processing part. - DWORD blockStart = 0; // Index of block start in work buffer - DWORD blockSize = min(blockBytes, ha->dwBlockSize); - DWORD index = blockNum; // Current block index - - dwBytesRead = 0; // Clear read byte counter - - // Walk through all blocks - for(i = 0; i < nBlocks; i++, index++) - { - BYTE * inputBuffer = tempBuffer + blockStart; - int outLength = ha->dwBlockSize; - - if(bytesRemain < (DWORD)outLength) - outLength = bytesRemain; - - // Get current block length - if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESSED) - blockSize = hf->pdwBlockPos[index+1] - hf->pdwBlockPos[index]; - - // If block is encrypted, we have to decrypt it. - if(hf->pBlock->dwFlags & MPQ_FILE_ENCRYPTED) - { - BSWAP_ARRAY32_UNSIGNED((DWORD *)inputBuffer, blockSize / sizeof(DWORD)); - - // If we don't know the seed, try to decode it as WAVE file - if(hf->dwSeed1 == 0) - hf->dwSeed1 = DetectFileSeed2((DWORD *)inputBuffer, 3, ID_WAVE, hf->pBlock->dwFSize - 8, 0x45564157); - - // Let's try MSVC's standard EXE or header - if(hf->dwSeed1 == 0) - hf->dwSeed1 = DetectFileSeed2((DWORD *)inputBuffer, 2, 0x00905A4D, 0x00000003); - - if(hf->dwSeed1 == 0) - return 0; - - DecryptMPQBlock((DWORD *)inputBuffer, blockSize, hf->dwSeed1 + index); - BSWAP_ARRAY32_UNSIGNED((DWORD *)inputBuffer, blockSize / sizeof(DWORD)); - } - - // If the block is really compressed, decompress it. - // WARNING : Some block may not be compressed, it can be determined only - // by comparing uncompressed and compressed size !!! - if(blockSize < (DWORD)outLength) - { - // Is the file compressed with PKWARE Data Compression Library ? - if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESS_PKWARE) - Decompress_pklib((char *)buffer, &outLength, (char *)inputBuffer, (int)blockSize); - - // Is it a file compressed by Blizzard's multiple compression ? - // Note that Storm.dll v 1.0.9 distributed with Warcraft III - // passes the full path name of the opened archive as the new last parameter - if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESS_MULTI) - SCompDecompress((char *)buffer, &outLength, (char *)inputBuffer, (int)blockSize); - dwBytesRead += outLength; - buffer += outLength; - } - else - { - if(buffer != inputBuffer) - memcpy(buffer, inputBuffer, blockSize); - - dwBytesRead += blockSize; - buffer += blockSize; - } - blockStart += blockSize; - bytesRemain -= outLength; - } - - // Delete input buffer, if necessary - if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESSED) - FREEMEM(tempBuffer); - - return dwBytesRead; -} - -// When this function is called, it is already ensured that the parameters are valid -// (e.g. the "dwToRead + dwFilePos" is not greater than the file size) -// TODO: Test for archives > 4GB -static DWORD WINAPI ReadMPQFileSingleUnit(TMPQFile * hf, DWORD dwFilePos, BYTE * pbBuffer, DWORD dwToRead) -{ - TMPQArchive * ha = hf->ha; - DWORD dwBytesRead = 0; - - if(ha->FilePointer.QuadPart != hf->MpqFilePos.QuadPart) - { - SetFilePointer(ha->hFile, hf->MpqFilePos.LowPart, &hf->MpqFilePos.HighPart, FILE_BEGIN); - ha->FilePointer = hf->MpqFilePos; - } - - // If the file is really compressed, decompress it. - // Otherwise, read the data as-is to the caller. - if(hf->pBlock->dwCSize < hf->pBlock->dwFSize) - { - if(hf->pbFileBuffer == NULL) - { - BYTE * inputBuffer = NULL; - int outputBufferSize = (int)hf->pBlock->dwFSize; - int inputBufferSize = (int)hf->pBlock->dwCSize; - - hf->pbFileBuffer = ALLOCMEM(BYTE, outputBufferSize); - inputBuffer = ALLOCMEM(BYTE, inputBufferSize); - if(inputBuffer != NULL && hf->pbFileBuffer != NULL) - { - // Read the compressed file data - ReadFile(ha->hFile, inputBuffer, inputBufferSize, &dwBytesRead, NULL); - - // Is the file compressed with PKWARE Data Compression Library ? - if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESS_PKWARE) - Decompress_pklib((char *)hf->pbFileBuffer, &outputBufferSize, (char *)inputBuffer, (int)inputBufferSize); - - // Is it a file compressed by Blizzard's multiple compression ? - // Note that Storm.dll v 1.0.9 distributed with Warcraft III - // passes the full path name of the opened archive as the new last parameter - if(hf->pBlock->dwFlags & MPQ_FILE_COMPRESS_MULTI) - SCompDecompress((char *)hf->pbFileBuffer, &outputBufferSize, (char *)inputBuffer, (int)inputBufferSize); - } - - // Free the temporary buffer - if(inputBuffer != NULL) - FREEMEM(inputBuffer); - } - - // Copy the file data, if any there - if(hf->pbFileBuffer != NULL) - { - memcpy(pbBuffer, hf->pbFileBuffer + dwFilePos, dwToRead); - dwBytesRead += dwToRead; - } - } - else - { - // Read the uncompressed file data - ReadFile(ha->hFile, pbBuffer, dwToRead, &dwBytesRead, NULL); - dwBytesRead = (int)dwBytesRead; - } - - return (DWORD)dwBytesRead; -} - - -//----------------------------------------------------------------------------- -// ReadMPQFile - -// TODO: Test for archives > 4GB -static DWORD WINAPI ReadMPQFile(TMPQFile * hf, DWORD dwFilePos, BYTE * pbBuffer, DWORD dwToRead) -{ - TMPQArchive * ha = hf->ha; - TMPQBlock * pBlock = hf->pBlock; // Pointer to file block - DWORD dwBytesRead = 0; // Number of bytes read from the file - DWORD dwBlockPos; // Position in the file aligned to the whole blocks - DWORD dwLoaded; - - // File position is greater or equal to file size ? - if(dwFilePos >= pBlock->dwFSize) - return dwBytesRead; - - // If too few bytes in the file remaining, cut them - if((pBlock->dwFSize - dwFilePos) < dwToRead) - dwToRead = (pBlock->dwFSize - dwFilePos); - - // If the file is stored as single unit, handle it separately - if(pBlock->dwFlags & MPQ_FILE_SINGLE_UNIT) - return ReadMPQFileSingleUnit(hf, dwFilePos, pbBuffer, dwToRead); - - // Block position in the file - dwBlockPos = dwFilePos & ~(ha->dwBlockSize - 1); // Position in the block - - // Load the first block, if incomplete. It may be loaded in the cache buffer. - // We have to check if this block is loaded. If not, load it. - if((dwFilePos % ha->dwBlockSize) != 0) - { - // Number of bytes remaining in the buffer - DWORD dwToCopy; - DWORD dwLoaded = ha->dwBlockSize; - - // Check if data are loaded in the cache - if(hf != ha->pLastFile || dwBlockPos != ha->dwBlockPos) - { - // Load one MPQ block into archive buffer - dwLoaded = ReadMPQBlocks(hf, dwBlockPos, ha->pbBlockBuffer, ha->dwBlockSize); - if(dwLoaded == 0) - return (DWORD)-1; - - // Save lastly accessed file and block position for later use - ha->pLastFile = hf; - ha->dwBlockPos = dwBlockPos; - ha->dwBuffPos = dwFilePos % ha->dwBlockSize; - } - dwToCopy = dwLoaded - ha->dwBuffPos; - if(dwToCopy > dwToRead) - dwToCopy = dwToRead; - - // Copy data from block buffer into target buffer - memcpy(pbBuffer, ha->pbBlockBuffer + ha->dwBuffPos, dwToCopy); - - // Update pointers - dwToRead -= dwToCopy; - dwBytesRead += dwToCopy; - pbBuffer += dwToCopy; - dwBlockPos += ha->dwBlockSize; - ha->dwBuffPos += dwToCopy; - - // If all, return. - if(dwToRead == 0) - return dwBytesRead; - } - - // Load the whole ("middle") blocks only if there are more or equal one block - if(dwToRead > ha->dwBlockSize) - { - DWORD dwBlockBytes = dwToRead & ~(ha->dwBlockSize - 1); - - dwLoaded = ReadMPQBlocks(hf, dwBlockPos, pbBuffer, dwBlockBytes); - if(dwLoaded == 0) - return (DWORD)-1; - - // Update pointers - dwToRead -= dwLoaded; - dwBytesRead += dwLoaded; - pbBuffer += dwLoaded; - dwBlockPos += dwLoaded; - - // If all, return. - if(dwToRead == 0) - return dwBytesRead; - } - - // Load the terminating block - if(dwToRead > 0) - { - DWORD dwToCopy = ha->dwBlockSize; - - // Check if data are loaded in the cache - if(hf != ha->pLastFile || dwBlockPos != ha->dwBlockPos) - { - // Load one MPQ block into archive buffer - dwToCopy = ReadMPQBlocks(hf, dwBlockPos, ha->pbBlockBuffer, ha->dwBlockSize); - if(dwToCopy == 0) - return (DWORD)-1; - - // Save lastly accessed file and block position for later use - ha->pLastFile = hf; - ha->dwBlockPos = dwBlockPos; - } - ha->dwBuffPos = 0; - - // Check number of bytes read - if(dwToCopy > dwToRead) - dwToCopy = dwToRead; - - memcpy(pbBuffer, ha->pbBlockBuffer, dwToCopy); - dwBytesRead += dwToCopy; - ha->dwBuffPos = dwToCopy; - } - - // Return what we've read - return dwBytesRead; -} - -//----------------------------------------------------------------------------- -// SFileReadFile - -// TODO: Test for archives > 4GB -BOOL WINAPI SFileReadFile(HANDLE hFile, VOID * lpBuffer, DWORD dwToRead, DWORD * pdwRead, LPOVERLAPPED lpOverlapped) -{ - TMPQFile * hf = (TMPQFile *)hFile; - DWORD dwBytes = 0; // Number of bytes (for everything) - int nError = ERROR_SUCCESS; - - // Zero the number of bytes read - if(pdwRead != NULL) - *pdwRead = 0; - - // Check valid parameters - if(nError == ERROR_SUCCESS) - { - if(hf == NULL || lpBuffer == NULL) - nError = ERROR_INVALID_PARAMETER; - } - - // If direct access to the file, use Win32 for reading - if(nError == ERROR_SUCCESS && hf->hFile != INVALID_HANDLE_VALUE) - { - DWORD dwTransferred; - - ReadFile(hf->hFile, lpBuffer, dwToRead, &dwTransferred, lpOverlapped); - if(dwTransferred < dwToRead) - { - SetLastError(ERROR_HANDLE_EOF); - return FALSE; - } - - if(pdwRead != NULL) - *pdwRead = dwTransferred; - return TRUE; - } - - // Read all the bytes available in the buffer (If any) - if(nError == ERROR_SUCCESS) - { - if(dwToRead > 0) - { - dwBytes = ReadMPQFile(hf, hf->dwFilePos, (BYTE *)lpBuffer, dwToRead); - if(dwBytes == (DWORD)-1) - { - SetLastError(ERROR_CAN_NOT_COMPLETE); - return FALSE; - } - hf->ha->pLastFile = hf; - hf->dwFilePos += dwBytes; - } - if(pdwRead != NULL) - *pdwRead = dwBytes; - } - - // Check number of bytes read. If not OK, return FALSE. - if(dwBytes < dwToRead) - { - SetLastError(ERROR_HANDLE_EOF); - return FALSE; - } - return TRUE; -} - -//----------------------------------------------------------------------------- -// SFileGetFilePos -// -// Returns position of archive file in the archive (relative to begin of file) - -// TODO: Test for archives > 4GB -DWORD WINAPI SFileGetFilePos(HANDLE hFile, DWORD * pdwFilePosHigh) -{ - TMPQFile * hf = (TMPQFile *)hFile; - - if(pdwFilePosHigh != NULL) - *pdwFilePosHigh = 0; - - if(hf == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return (DWORD)-1; - } - - // If opened as plain file, ... - if(hf->hFile != INVALID_HANDLE_VALUE) - return 0; - - // If opened from archive, return file size - if(pdwFilePosHigh != NULL) - *pdwFilePosHigh = hf->MpqFilePos.HighPart; - return hf->MpqFilePos.LowPart; -} - -//----------------------------------------------------------------------------- -// SFileGetFileSize - -// TODO: Test for archives > 4GB -DWORD WINAPI SFileGetFileSize(HANDLE hFile, DWORD * pdwFileSizeHigh) -{ - TMPQFile * hf = (TMPQFile *)hFile; - - if(pdwFileSizeHigh != NULL) - *pdwFileSizeHigh = 0; - - if(hf == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return (DWORD)-1; - } - - // If opened as plain file, ... - if(hf->hFile != INVALID_HANDLE_VALUE) - return GetFileSize(hf->hFile, pdwFileSizeHigh); - - // If opened from archive, return file size - return hf->pBlock->dwFSize; -} - -// TODO: Test for archives > 4GB -DWORD WINAPI SFileSetFilePointer(HANDLE hFile, LONG lFilePos, LONG * pdwFilePosHigh, DWORD dwMethod) -{ - TMPQArchive * ha; - TMPQFile * hf = (TMPQFile *)hFile; - - if(hf == NULL || (pdwFilePosHigh != NULL && *pdwFilePosHigh != 0)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return (DWORD)-1; - } - - // If opened as plain file, call Win32 API - if(hf->hFile != INVALID_HANDLE_VALUE) - return SetFilePointer(hf->hFile, lFilePos, pdwFilePosHigh, dwMethod); - ha = hf->ha; - - switch(dwMethod) - { - case FILE_BEGIN: - // Cannot set pointer before begin of file - if(-lFilePos > (LONG)hf->dwFilePos) - hf->dwFilePos = 0; - else - hf->dwFilePos = lFilePos; - break; - - case FILE_CURRENT: - // Cannot set pointer before begin of file - if(-lFilePos > (LONG)hf->dwFilePos) - hf->dwFilePos = 0; - else - hf->dwFilePos += lFilePos; - break; - - case FILE_END: - // Cannot set file position before begin of file - if(-lFilePos >= (LONG)hf->pBlock->dwFSize) - hf->dwFilePos = 0; - else - hf->dwFilePos = hf->pBlock->dwFSize + lFilePos; - break; - - default: - return ERROR_INVALID_PARAMETER; - } - - if(hf == ha->pLastFile && (hf->dwFilePos & ~(ha->dwBlockSize - 1)) == ha->dwBlockPos) - ha->dwBuffPos = hf->dwFilePos & (ha->dwBlockSize - 1); - else - { - ha->pLastFile = NULL; - ha->dwBuffPos = 0; - } - - return hf->dwFilePos; -} - -//----------------------------------------------------------------------------- -// Tries to retrieve the file name - -static TID2Ext id2ext[] = -{ - {0x1A51504D, "mpq"}, // MPQ archive header ID ('MPQ\x1A') - {0x46464952, "wav"}, // WAVE header 'RIFF' - {0x324B4D53, "smk"}, // Old "Smacker Video" files 'SMK2' - {0x694B4942, "bik"}, // Bink video files (new) - {0x0801050A, "pcx"}, // PCX images used in Diablo I - {0x544E4F46, "fnt"}, // Font files used in Diablo II - {0x6D74683C, "html"}, // HTML ' 4GB -BOOL WINAPI SFileGetFileName(HANDLE hFile, char * szFileName) -{ - TMPQFile * hf = (TMPQFile *)hFile; // MPQ File handle - char * szExt = "xxx"; // Default extension - DWORD dwFirstBytes[2]; // The first 4 bytes of the file - DWORD dwFilePos; // Saved file position - int nError = ERROR_SUCCESS; - int i; - - // Pre-zero the output buffer - if(szFileName != NULL) - *szFileName = 0; - - // Check valid parameters - if(nError == ERROR_SUCCESS) - { - if(hf == NULL || szFileName == NULL) - nError = ERROR_INVALID_PARAMETER; - } - - // If the file name is already filled, return it. - if(nError == ERROR_SUCCESS && *hf->szFileName != 0) - { - if(szFileName != hf->szFileName) - strcpy(szFileName, hf->szFileName); - return TRUE; - } - - if(nError == ERROR_SUCCESS) - { - if(hf->dwFileIndex == (DWORD)-1) - nError = ERROR_CAN_NOT_COMPLETE; - } - - // Read the first 8 bytes from the file - if(nError == ERROR_SUCCESS) - { - dwFirstBytes[0] = dwFirstBytes[1] = 0; - dwFilePos = SFileSetFilePointer(hf, 0, NULL, FILE_CURRENT); - if(!SFileReadFile(hFile, &dwFirstBytes, sizeof(dwFirstBytes), NULL)) - nError = GetLastError(); - BSWAP_ARRAY32_UNSIGNED(dwFirstBytes, sizeof(dwFirstBytes) / sizeof(DWORD)); - SFileSetFilePointer(hf, dwFilePos, NULL, FILE_BEGIN); - } - - if(nError == ERROR_SUCCESS) - { - if((dwFirstBytes[0] & 0x0000FFFF) == ID_EXE) - szExt = "exe"; - else if(dwFirstBytes[0] == 0x00000006 && dwFirstBytes[1] == 0x00000001) - szExt = "dc6"; - else - { - for(i = 0; id2ext[i].szExt != NULL; i++) - { - if(id2ext[i].dwID == dwFirstBytes[0]) - { - szExt = id2ext[i].szExt; - break; - } - } - } - - // Create the file name - sprintf(hf->szFileName, "File%08lu.%s", hf->dwFileIndex, szExt); - if(szFileName != hf->szFileName) - strcpy(szFileName, hf->szFileName); - } - return (nError == ERROR_SUCCESS); -} - -//----------------------------------------------------------------------------- -// Retrieves an information about an archive or about a file within the archive -// -// hMpqOrFile - Handle to an MPQ archive or to a file -// dwInfoType - Information to obtain - -// TODO: Test for archives > 4GB -DWORD_PTR WINAPI SFileGetFileInfo(HANDLE hMpqOrFile, DWORD dwInfoType) -{ - TMPQArchive * ha = (TMPQArchive *)hMpqOrFile; - TMPQFile * hf = (TMPQFile *)hMpqOrFile; - TMPQBlock * pBlockEnd; - TMPQBlock * pBlock; - DWORD dwFileCount = 0; - DWORD dwSeed; - - switch(dwInfoType) - { - case SFILE_INFO_ARCHIVE_SIZE: - if(IsValidMpqHandle(ha)) - return ha->pHeader->dwArchiveSize; - break; - - case SFILE_INFO_HASH_TABLE_SIZE: // Size of the hash table - if(IsValidMpqHandle(ha)) - return ha->pHeader->dwHashTableSize; - break; - - case SFILE_INFO_BLOCK_TABLE_SIZE: // Size of the hash table - if(IsValidMpqHandle(ha)) - return ha->pHeader->dwBlockTableSize; - break; - - case SFILE_INFO_BLOCK_SIZE: - if(IsValidMpqHandle(ha)) - return ha->dwBlockSize; - break; - - case SFILE_INFO_HASH_TABLE: - if(IsValidMpqHandle(ha)) - return (DWORD_PTR)ha->pHashTable; - break; - - case SFILE_INFO_BLOCK_TABLE: - if(IsValidMpqHandle(ha)) - return (DWORD_PTR)ha->pBlockTable; - break; - - case SFILE_INFO_NUM_FILES: - if(IsValidMpqHandle(ha)) - { - pBlockEnd = ha->pBlockTable + ha->pHeader->dwBlockTableSize; - for(pBlock = ha->pBlockTable; pBlock < pBlockEnd; pBlock++) - { - if(pBlock->dwFlags & MPQ_FILE_EXISTS) - dwFileCount++; - } - return dwFileCount; - } - break; - - case SFILE_INFO_HASH_INDEX: - if(IsValidFileHandle(hf)) - return hf->dwHashIndex; - break; - - case SFILE_INFO_CODENAME1: - if(IsValidFileHandle(hf)) - return hf->pHash->dwName1; - break; - - case SFILE_INFO_CODENAME2: - if(IsValidFileHandle(hf)) - return hf->pHash->dwName2; - break; - - case SFILE_INFO_LOCALEID: - if(IsValidFileHandle(hf)) - return hf->pHash->lcLocale; - break; - - case SFILE_INFO_BLOCKINDEX: - if(IsValidFileHandle(hf)) - return hf->dwFileIndex; - break; - - case SFILE_INFO_FILE_SIZE: - if(IsValidFileHandle(hf)) - return hf->pBlock->dwFSize; - break; - - case SFILE_INFO_COMPRESSED_SIZE: - if(IsValidFileHandle(hf)) - return hf->pBlock->dwCSize; - break; - - case SFILE_INFO_FLAGS: - if(IsValidFileHandle(hf)) - return hf->pBlock->dwFlags; - break; - - case SFILE_INFO_POSITION: - if(IsValidFileHandle(hf)) - return hf->pBlock->dwFilePos; - break; - - case SFILE_INFO_SEED: - if(IsValidFileHandle(hf)) - return hf->dwSeed1; - break; - - case SFILE_INFO_SEED_UNFIXED: - if(IsValidFileHandle(hf)) - { - dwSeed = hf->dwSeed1; - if(hf->pBlock->dwFlags & MPQ_FILE_FIXSEED) - dwSeed = (dwSeed ^ hf->pBlock->dwFSize) - (DWORD)(hf->MpqFilePos.QuadPart - hf->ha->MpqPos.QuadPart); - return dwSeed; - } - break; - } - - // Unknown parameter or invalid handle - SetLastError(ERROR_INVALID_PARAMETER); - return 0xFFFFFFFF; -} diff --git a/contrib/vmap_extractor_v2/stormlib/SListFile.cpp b/contrib/vmap_extractor_v2/stormlib/SListFile.cpp deleted file mode 100644 index c3723d17dcd..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/SListFile.cpp +++ /dev/null @@ -1,561 +0,0 @@ -/*****************************************************************************/ -/* SListFile.cpp Copyright (c) Ladislav Zezula 2004 */ -/*---------------------------------------------------------------------------*/ -/* Description: */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 12.06.04 1.00 Lad The first version of SListFile.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "SCommon.h" -#include - -//----------------------------------------------------------------------------- -// Listfile entry structure - -#define LISTFILE_CACHE_SIZE 0x1000 // Size of one cache element -#define NO_MORE_CHARACTERS 256 -#define HASH_TABLE_SIZE 31 // Initial hash table size (should be a prime number) - -// TODO: Check on x64 !!! -#define LISTFILE_ENTRY_DELETED (DWORD_PTR)(-2) -#define LISTFILE_ENTRY_FREE (DWORD_PTR)(-1) - -struct TListFileCache -{ - HANDLE hFile; // Stormlib file handle - char * szMask; // File mask - DWORD dwFileSize; // Total size of the cached file - DWORD dwBuffSize; // File of the cache - DWORD dwFilePos; // Position of the cache in the file - BYTE * pBegin; // The begin of the listfile cache - BYTE * pPos; - BYTE * pEnd; // The last character in the file cache - - BYTE Buffer[1]; // Listfile cache itself -}; - -//----------------------------------------------------------------------------- -// Local functions (cache) - -// Reloads the cache. Returns number of characters -// that has been loaded into the cache. -static int ReloadCache(TListFileCache * pCache) -{ - // Check if there is enough characters in the cache - // If not, we have to reload the next block - if(pCache->pPos >= pCache->pEnd) - { - // If the cache is already at the end, do nothing more - if((pCache->dwFilePos + pCache->dwBuffSize) >= pCache->dwFileSize) - return 0; - - pCache->dwFilePos += pCache->dwBuffSize; - SFileReadFile(pCache->hFile, pCache->Buffer, pCache->dwBuffSize, &pCache->dwBuffSize, NULL); - if(pCache->dwBuffSize == 0) - return 0; - - // Set the buffer pointers - pCache->pBegin = - pCache->pPos = &pCache->Buffer[0]; - pCache->pEnd = pCache->pBegin + pCache->dwBuffSize; - } - - return pCache->dwBuffSize; -} - -static size_t ReadLine(TListFileCache * pCache, char * szLine, int nMaxChars) -{ - char * szLineBegin = szLine; - char * szLineEnd = szLine + nMaxChars - 1; - -__BeginLoading: - - // Skip newlines, spaces, tabs and another non-printable stuff - while(pCache->pPos < pCache->pEnd && *pCache->pPos <= 0x20) - pCache->pPos++; - - // Copy the remaining characters - while(pCache->pPos < pCache->pEnd && szLine < szLineEnd) - { - // If we have found a newline, stop loading - if(*pCache->pPos == 0x0D || *pCache->pPos == 0x0A) - break; - - *szLine++ = *pCache->pPos++; - } - - // If we now need to reload the cache, do it - if(pCache->pPos == pCache->pEnd) - { - if(ReloadCache(pCache) > 0) - goto __BeginLoading; - } - - *szLine = 0; - return (szLine - szLineBegin); -} - -//----------------------------------------------------------------------------- -// Local functions (listfile nodes) - -// This function creates the name for the listfile. -// the file will be created under unique name in the temporary directory -static void GetListFileName(TMPQArchive * /* ha */, char * szListFile) -{ - char szTemp[MAX_PATH]; - - // Create temporary file name int TEMP directory - GetTempPath(sizeof(szTemp)-1, szTemp); - GetTempFileName(szTemp, LISTFILE_NAME, 0, szListFile); -} - -// Creates new listfile. The listfile is an array of TListFileNode -// structures. The size of the array is the same like the hash table size, -// the ordering is the same too (listfile item index is the same like -// the index in the MPQ hash table) - -int SListFileCreateListFile(TMPQArchive * ha) -{ - DWORD dwItems = ha->pHeader->dwHashTableSize; - - // The listfile should be NULL now - assert(ha->pListFile == NULL); - - ha->pListFile = ALLOCMEM(TFileNode *, dwItems); - if(ha->pListFile == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - memset(ha->pListFile, 0xFF, dwItems * sizeof(TFileNode *)); - return ERROR_SUCCESS; -} - -// Adds a filename into the listfile. If the file name is already there, -// does nothing. -int SListFileAddNode(TMPQArchive * ha, const char * szFileName) -{ - TFileNode * pNode = NULL; - TMPQHash * pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - TMPQHash * pHash0 = GetHashEntry(ha, szFileName); - TMPQHash * pHash = pHash0; - DWORD dwHashIndex = 0; - size_t nLength; // File name lentgth - DWORD dwName1; - DWORD dwName2; - - // If the file does not exist within the MPQ, do nothing - if(pHash == NULL) - return ERROR_SUCCESS; - - // If the listfile entry already exists, do nothing - dwHashIndex = (DWORD)(pHash - ha->pHashTable); - dwName1 = pHash->dwName1; - dwName2 = pHash->dwName2; - if((DWORD_PTR)ha->pListFile[dwHashIndex] <= LISTFILE_ENTRY_DELETED) - return ERROR_SUCCESS; - - // Create the listfile node and insert it into the listfile table - nLength = strlen(szFileName); - pNode = (TFileNode *)ALLOCMEM(char, sizeof(TFileNode) + nLength); - pNode->dwRefCount = 0; - pNode->nLength = nLength; - strcpy(pNode->szFileName, szFileName); - - // Fill the nodes for all language versions - while(pHash->dwBlockIndex < LISTFILE_ENTRY_DELETED) - { - if(pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2) - { - pNode->dwRefCount++; - ha->pListFile[pHash - ha->pHashTable] = pNode; - } - - if(++pHash >= pHashEnd) - pHash = ha->pHashTable; - if(pHash == pHash0) - break; - } - - return ERROR_SUCCESS; -} - -// Removes a filename from the listfile. -// If the name is not there, does nothing -int SListFileRemoveNode(TMPQArchive * ha, const char * szFileName) -{ - TFileNode * pNode = NULL; - TMPQHash * pHash = GetHashEntry(ha, szFileName); - size_t nHashIndex = 0; - - if(pHash != NULL) - { - nHashIndex = pHash - ha->pHashTable; - pNode = ha->pListFile[nHashIndex]; - ha->pListFile[nHashIndex] = (TFileNode *)LISTFILE_ENTRY_DELETED; - - // If the reference count has reached zero, do nothing - if(--pNode->dwRefCount == 0) - FREEMEM(pNode); - } - return ERROR_SUCCESS; -} - - -// Renames a node. We will not deal with the renaming, we'll simply -// remove the old node and insert the new one. -// TODO: Test for archives > 4GB -int SListFileRenameNode(TMPQArchive * ha, const char * szOldFileName, const char * szNewFileName) -{ - SListFileRemoveNode(ha, szOldFileName); - return SListFileAddNode(ha, szNewFileName); -} - -// TODO: Test for archives > 4GB -int SListFileFreeListFile(TMPQArchive * ha) -{ - if(ha->pListFile != NULL) - { - for(DWORD i = 0; i < ha->pHeader->dwHashTableSize; i++) - { - TFileNode * pNode = ha->pListFile[i]; - - if((DWORD_PTR)pNode < LISTFILE_ENTRY_FREE) - { - if(--pNode->dwRefCount == 0) - { - FREEMEM(pNode); - ha->pListFile[i] = (TFileNode *)LISTFILE_ENTRY_FREE; - } - } - } - - FREEMEM(ha->pListFile); - ha->pListFile = NULL; - } - - return ERROR_SUCCESS; -} - -// Saves the whole listfile into the MPQ. -// TODO: Test for archives > 4GB -int SListFileSaveToMpq(TMPQArchive * ha) -{ - TFileNode * pNode = NULL; - TMPQHash * pHashEnd = NULL; - TMPQHash * pHash0 = NULL; - TMPQHash * pHash = NULL; - HANDLE hFile = INVALID_HANDLE_VALUE; - char szListFile[MAX_PATH]; - char szBuffer[MAX_PATH+4]; - DWORD dwTransferred; - size_t nLength = 0; - DWORD dwName1 = 0; - DWORD dwName2 = 0; - LCID lcSave = lcLocale; - int nError = ERROR_SUCCESS; - - // If no listfile, do nothing - if(ha->pListFile == NULL) - return ERROR_SUCCESS; - - // Create the local listfile - if(nError == ERROR_SUCCESS) - { - GetListFileName(ha, szListFile); - hFile = CreateFile(szListFile, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL); - if(hFile == INVALID_HANDLE_VALUE) - nError = GetLastError(); - } - - // Find the hash entry corresponding to listfile - pHashEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - pHash0 = pHash = GetHashEntry(ha, 0); - if(pHash == NULL) - pHash0 = pHash = ha->pHashTable; - - // Save the file - if(nError == ERROR_SUCCESS) - { - for(;;) - { - if(pHash->dwName1 != dwName1 && pHash->dwName2 != dwName2 && pHash->dwBlockIndex < LISTFILE_ENTRY_DELETED) - { - dwName1 = pHash->dwName1; - dwName2 = pHash->dwName2; - pNode = ha->pListFile[pHash - ha->pHashTable]; - - if((DWORD_PTR)pNode < LISTFILE_ENTRY_DELETED) - { - memcpy(szBuffer, pNode->szFileName, pNode->nLength); - szBuffer[pNode->nLength + 0] = 0x0D; - szBuffer[pNode->nLength + 1] = 0x0A; - WriteFile(hFile, szBuffer, (DWORD)(pNode->nLength + 2), &dwTransferred, NULL); - } - } - - if(++pHash >= pHashEnd) - pHash = ha->pHashTable; - if(pHash == pHash0) - break; - } - - // Write the listfile name (if not already there) - if(GetHashEntry(ha, LISTFILE_NAME) == NULL) - { - nLength = strlen(LISTFILE_NAME); - memcpy(szBuffer, LISTFILE_NAME, nLength); - szBuffer[nLength + 0] = 0x0D; - szBuffer[nLength + 1] = 0x0A; - WriteFile(hFile, szBuffer, (DWORD)(nLength + 2), &dwTransferred, NULL); - } - - // Add the listfile into the archive. - SFileSetLocale(LANG_NEUTRAL); - nError = AddFileToArchive(ha, hFile, LISTFILE_NAME, MPQ_FILE_COMPRESS_PKWARE | MPQ_FILE_ENCRYPTED | MPQ_FILE_REPLACEEXISTING, 0, SFILE_TYPE_DATA, NULL); - } - - // Close the temporary file. This will delete it too. - if(hFile != INVALID_HANDLE_VALUE) - CloseHandle(hFile); - - lcLocale = lcSave; - return nError; -} - -//----------------------------------------------------------------------------- -// File functions - -// Adds a listfile into the MPQ archive. -// Note that the function does not remove the -// TODO: Test for archives > 4GB -int WINAPI SFileAddListFile(HANDLE hMpq, const char * szListFile) -{ - TListFileCache * pCache = NULL; - TMPQArchive * ha = (TMPQArchive *)hMpq; - HANDLE hListFile = NULL; - char szFileName[MAX_PATH + 1]; - DWORD dwSearchScope = SFILE_OPEN_LOCAL_FILE; - DWORD dwCacheSize = 0; - DWORD dwFileSize = 0; - size_t nLength = 0; - int nError = ERROR_SUCCESS; - - // If the szListFile is NULL, it means we have to open internal listfile - if(szListFile == NULL) - { - szListFile = LISTFILE_NAME; - dwSearchScope = SFILE_OPEN_FROM_MPQ; - } - - // Open the local/internal listfile - if(nError == ERROR_SUCCESS) - { - if(!SFileOpenFileEx((HANDLE)ha, szListFile, dwSearchScope, &hListFile)) - nError = GetLastError(); - } - - if(nError == ERROR_SUCCESS) - { - dwCacheSize = - dwFileSize = SFileGetFileSize(hListFile, NULL); - - // Try to allocate memory for the complete file. If it fails, - // load the part of the file - pCache = (TListFileCache *)ALLOCMEM(char, (sizeof(TListFileCache) + dwCacheSize)); - if(pCache == NULL) - { - dwCacheSize = LISTFILE_CACHE_SIZE; - pCache = (TListFileCache *)ALLOCMEM(char, sizeof(TListFileCache) + dwCacheSize); - } - - if(pCache == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - if(nError == ERROR_SUCCESS) - { - // Initialize the file cache - memset(pCache, 0, sizeof(TListFileCache)); - pCache->hFile = hListFile; - pCache->dwFileSize = dwFileSize; - pCache->dwBuffSize = dwCacheSize; - pCache->dwFilePos = 0; - - // Fill the cache - SFileReadFile(hListFile, pCache->Buffer, pCache->dwBuffSize, &pCache->dwBuffSize, NULL); - - // Initialize the pointers - pCache->pBegin = - pCache->pPos = &pCache->Buffer[0]; - pCache->pEnd = pCache->pBegin + pCache->dwBuffSize; - - // Load the node tree - while((nLength = ReadLine(pCache, szFileName, sizeof(szFileName) - 1)) > 0) - SListFileAddNode(ha, szFileName); - - // Add well-known names - // Sometimes, they are not in listfile, but they exist in the archive - SListFileAddNode(ha, LISTFILE_NAME); - SListFileAddNode(ha, SIGNATURE_NAME); - SListFileAddNode(ha, ATTRIBUTES_NAME); - } - - // Cleanup & exit - if(pCache != NULL) - SListFileFindClose((HANDLE)pCache); - return nError; -} - -//----------------------------------------------------------------------------- -// Passing through the listfile - -// TODO: Test for archives > 4GB -HANDLE SListFileFindFirstFile(HANDLE hMpq, const char * szListFile, const char * szMask, SFILE_FIND_DATA * lpFindFileData) -{ - TListFileCache * pCache = NULL; - TMPQArchive * ha = (TMPQArchive *)hMpq; - HANDLE hListFile = NULL; - DWORD dwSearchScope = SFILE_OPEN_LOCAL_FILE; - DWORD dwCacheSize = 0; - DWORD dwFileSize = 0; - size_t nLength = 0; - int nError = ERROR_SUCCESS; - - // Initialize the structure with zeros - memset(lpFindFileData, 0, sizeof(SFILE_FIND_DATA)); - - // If the szListFile is NULL, it means we have to open internal listfile - if(szListFile == NULL) - { - szListFile = LISTFILE_NAME; - dwSearchScope = SFILE_OPEN_FROM_MPQ; - } - - // Open the local/internal listfile - if(nError == ERROR_SUCCESS) - { - if(!SFileOpenFileEx((HANDLE)ha, szListFile, dwSearchScope, &hListFile)) - nError = GetLastError(); - } - - if(nError == ERROR_SUCCESS) - { - dwCacheSize = - dwFileSize = SFileGetFileSize(hListFile, NULL); - - // Try to allocate memory for the complete file. If it fails, - // load the part of the file - pCache = (TListFileCache *)ALLOCMEM(char, sizeof(TListFileCache) + dwCacheSize); - if(pCache == NULL) - { - dwCacheSize = LISTFILE_CACHE_SIZE; - pCache = (TListFileCache *)ALLOCMEM(char, sizeof(TListFileCache) + dwCacheSize); - } - - if(pCache == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - if(nError == ERROR_SUCCESS) - { - // Initialize the file cache - memset(pCache, 0, sizeof(TListFileCache)); - pCache->hFile = hListFile; - pCache->dwFileSize = dwFileSize; - pCache->dwBuffSize = dwCacheSize; - pCache->dwFilePos = 0; - if(szMask != NULL) - { - pCache->szMask = ALLOCMEM(char, strlen(szMask) + 1); - strcpy(pCache->szMask, szMask); - } - - // Fill the cache - SFileReadFile(hListFile, pCache->Buffer, pCache->dwBuffSize, &pCache->dwBuffSize, NULL); - - // Initialize the pointers - pCache->pBegin = - pCache->pPos = &pCache->Buffer[0]; - pCache->pEnd = pCache->pBegin + pCache->dwBuffSize; - - for(;;) - { - // Read the (next) line - nLength = ReadLine(pCache, lpFindFileData->cFileName, sizeof(lpFindFileData->cFileName)); - if(nLength == 0) - { - nError = ERROR_NO_MORE_FILES; - break; - } - - // If some mask entered, check it - if(CheckWildCard(lpFindFileData->cFileName, pCache->szMask)) - break; - } - } - - // Cleanup & exit - if(nError != ERROR_SUCCESS) - { - memset(lpFindFileData, 0, sizeof(SFILE_FIND_DATA)); - SListFileFindClose((HANDLE)pCache); - pCache = NULL; - - SetLastError(nError); - } - return (HANDLE)pCache; -} - -// TODO: Test for archives > 4GB -BOOL SListFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData) -{ - TListFileCache * pCache = (TListFileCache *)hFind; - size_t nLength; - BOOL bResult = FALSE; - int nError = ERROR_SUCCESS; - - for(;;) - { - // Read the (next) line - nLength = ReadLine(pCache, lpFindFileData->cFileName, sizeof(lpFindFileData->cFileName)); - if(nLength == 0) - { - nError = ERROR_NO_MORE_FILES; - break; - } - - // If some mask entered, check it - if(CheckWildCard(lpFindFileData->cFileName, pCache->szMask)) - { - bResult = TRUE; - break; - } - } - - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return bResult; -} - -// TODO: Test for archives > 4GB -BOOL SListFileFindClose(HANDLE hFind) -{ - TListFileCache * pCache = (TListFileCache *)hFind; - - if(pCache != NULL) - { - if(pCache->hFile != NULL) - SFileCloseFile(pCache->hFile); - if(pCache->szMask != NULL) - FREEMEM(pCache->szMask); - - FREEMEM(pCache); - return TRUE; - } - - return FALSE; -} - diff --git a/contrib/vmap_extractor_v2/stormlib/StormDll.h b/contrib/vmap_extractor_v2/stormlib/StormDll.h deleted file mode 100644 index 6d67820a22f..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/StormDll.h +++ /dev/null @@ -1,67 +0,0 @@ -/*****************************************************************************/ -/* Storm.h Copyright Justin Olbrantz(Quantam) 2000 */ -/*---------------------------------------------------------------------------*/ -/* Storm Interface Library v1.0 for Windows */ -/* */ -/* Author : Justin Olbrantz(Quantam) */ -/* E-mail : omega@dragonfire.net */ -/* WWW : www.campaigncreations.com/starcraft/mpq2k/inside_mopaq/ */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* xx.xx.00 1.00 Qua The first version of Storm.h */ -/* 11.04.03 1.00 Lad Added some functions */ -/*****************************************************************************/ - -// We need the Windows data types for the Storm prototypes -#include - -#ifndef __STORM_H__ -#define __STORM_H__ - -// Somethimes is necessary to change the function names so they -// will not conflict with other MPQ tools. -#ifdef STORM_ALTERNATE_NAMES - #define SFILE(Name) Storm##Name - #define SCOMP(Name) Storm##Name -#else - #define SFILE(Name) SFile##Name - #define SCOMP(Name) SComp##Name -#endif - - -// Just in case anyone is still using C out there -#ifdef __cplusplus -extern "C" { -#endif - -// Storm file function prototypes -BOOL WINAPI SFILE(OpenArchive)(LPCSTR lpFileName, DWORD dwPriority, DWORD dwFlags, HANDLE *hMPQ); -BOOL WINAPI SFILE(CloseArchive)(HANDLE hMPQ); -BOOL WINAPI SFILE(GetArchiveName)(HANDLE hMPQ, LPCSTR lpBuffer, DWORD dwBufferLength); -BOOL WINAPI SFILE(OpenFile)(LPCSTR lpFileName, HANDLE *hFile); -BOOL WINAPI SFILE(OpenFileEx)(HANDLE hMPQ, LPCSTR lpFileName, DWORD dwSearchScope, HANDLE *hFile); -BOOL WINAPI SFILE(CloseFile)(HANDLE hFile); -DWORD WINAPI SFILE(GetFileSize)(HANDLE hFile, LPDWORD lpFileSizeHigh); -BOOL WINAPI SFILE(GetFileArchive)(HANDLE hFile, HANDLE *hMPQ); -BOOL WINAPI SFILE(GetFileName)(HANDLE hFile, LPCSTR lpBuffer, DWORD dwBufferLength); -DWORD WINAPI SFILE(SetFilePointer)(HANDLE hFile, long lDistanceToMove, PLONG lplDistanceToMoveHigh, DWORD dwMoveMethod); -BOOL WINAPI SFILE(ReadFile)(HANDLE hFile,LPVOID lpBuffer,DWORD nNumberOfBytesToRead,LPDWORD lpNumberOfBytesRead,LPOVERLAPPED lpOverlapped); -LCID WINAPI SFILE(SetLocale)(LCID nNewLocale); -BOOL WINAPI SFILE(GetBasePath)(LPCSTR lpBuffer, DWORD dwBufferLength); -BOOL WINAPI SFILE(SetBasePath)(LPCSTR lpNewBasePath); - -// Storm (de)compression functions -BOOL WINAPI SCOMP(Compress) (char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int uCmp, int uCmpType, int nCmpLevel); -BOOL WINAPI SCOMP(Decompress)(char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength); - - -#if defined(_MSC_VER) && !defined(BUILDING_STORM_CPP) -#pragma comment(lib, "Storm.lib") // Force linking Storm.lib and thus Storm.dll -#endif - -#ifdef __cplusplus -} -#endif - -#endif // __STORM_H__ diff --git a/contrib/vmap_extractor_v2/stormlib/StormLib.h b/contrib/vmap_extractor_v2/stormlib/StormLib.h deleted file mode 100644 index eeb8daa6468..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/StormLib.h +++ /dev/null @@ -1,579 +0,0 @@ -/*****************************************************************************/ -/* StormLib.h Copyright (c) Ladislav Zezula 1999-2005 */ -/*---------------------------------------------------------------------------*/ -/* StormLib library v 5.00 */ -/* */ -/* Author : Ladislav Zezula */ -/* E-mail : ladik@zezula.net */ -/* WWW : http://www.zezula.net */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* xx.xx.99 1.00 Lad Created */ -/* 24.03.03 2.50 Lad Version 2.50 */ -/* 02.04.03 3.00 Lad Version 3.00 with compression */ -/* 11.04.03 3.01 Lad Renamed to StormLib.h for compatibility with */ -/* original headers for Storm.dll */ -/* 10.05.03 3.02 Lad Added Pkware DCL compression */ -/* 26.05.03 4.00 Lad Completed all compressions */ -/* 18.06.03 4.01 Lad Added SFileSetFileLocale */ -/* Added SFileExtractFile */ -/* 26.07.03 4.02 Lad Implemented nameless rename and delete */ -/* 26.07.03 4.03 Lad Added support for protected MPQs */ -/* 28.08.03 4.10 Lad Fixed bugs that caused StormLib incorrectly work */ -/* with Diablo I savegames and with files having full */ -/* hash table */ -/* 08.12.03 4.11 DCH Fixed bug in reading file block larger than 0x1000 */ -/* on certain files. */ -/* Fixed bug in AddFile with MPQ_FILE_REPLACE_EXISTING */ -/* (Thanx Daniel Chiamarello, dchiamarello@madvawes.com)*/ -/* 21.12.03 4.50 Lad Completed port for Mac */ -/* Fixed bug in compacting (if fsize is mul of 0x1000) */ -/* Fixed bug in SCompCompress */ -/* 27.05.04 4.51 Lad Changed memory management from new/delete to our */ -/* own macros */ -/* 22.06.04 4.60 Lad Optimized search. Support for multiple listfiles. */ -/* 30.09.04 4.61 Lad Fixed some bugs (Aaargh !!!) */ -/* Correctly works if HashTableSize > BlockTableSize */ -/* 29.12.04 4.70 Lad Fixed compatibility problem with MPQs from WoW */ -/* 14.07.05 5.00 Lad Added the BZLIB compression support */ -/* Added suport of files stored as single unit */ -/* 17.04.06 5.01 Lad Converted to MS Visual Studio 8.0 */ -/* Fixed issue with protected Warcraft 3 protected maps */ -/* 15.05.06 5.02 Lad Fixed issue with WoW 1.10+ */ -/* 07.09.06 5.10 Lad Fixed processing files longer than 2GB */ -/* 22.11.06 6.00 Lad Support for MPQ archives V2 */ -/*****************************************************************************/ - -#ifndef __STORMLIB_H_ -#define __STORMLIB_H_ - -#include "StormPort.h" - -//----------------------------------------------------------------------------- -// Use the apropriate library -// -// The library type is encoded in the library name as the following -// StormLibXYZ.lib -// -// X - D for Debug version, R for Release version -// Y - A for ANSI version, U for Unicode version (Unicode version does not exist yet) -// Z - S for static C library, D for multithreaded DLL C-library -// - -#if defined(_MSC_VER) && !defined (__STORMLIB_SELF__) - #ifdef _DEBUG // DEBUG VERSIONS - #ifdef _DLL - #pragma comment(lib, "StormLibDAD.lib") // Debug Ansi Dynamic version - #else - #pragma comment(lib, "StormLibDAS.lib") // Debug Ansi Static version - #endif - #else // RELEASE VERSIONS - #ifdef _DLL - #pragma comment(lib, "StormLibRAD.lib") // Release Ansi Dynamic version - #else - #pragma comment(lib, "StormLibRAS.lib") // Release Ansi Static version - #endif - #endif -#endif - -//----------------------------------------------------------------------------- -// Defines - -#define ID_MPQ 0x1A51504D // MPQ archive header ID ('MPQ\x1A') -#define ID_MPQ_SHUNT 0x1B51504D // MPQ shunt entry ('MPQ\x1B') - -#define ERROR_AVI_FILE 10000 // No MPQ file, but AVI file. - -// Values for SFileCreateArchiveEx -#define HASH_TABLE_SIZE_MIN 0x00002 -#define HASH_TABLE_SIZE_MAX 0x40000 - -#define HASH_ENTRY_DELETED 0xFFFFFFFE // Block index for deleted hash entry -#define HASH_ENTRY_FREE 0xFFFFFFFF // Block index for free hash entry - -// Values for SFileOpenArchive -#define SFILE_OPEN_HARD_DISK_FILE 2 // Open the archive on HDD -#define SFILE_OPEN_CDROM_FILE 3 // Open the archive only if it is on CDROM - -// Values for SFileOpenFile -#define SFILE_OPEN_FROM_MPQ 0 // Open the file from the MPQ archive -#define SFILE_OPEN_BY_INDEX 1 // The 'szFileName' parameter is actually the file index -#define SFILE_OPEN_LOCAL_FILE (DWORD)-1 // Open the file from the MPQ archive - -// Flags for TMPQArchive::dwFlags -#define MPQ_FLAG_CHANGED 0x00000001 // If set, the MPQ has been changed -#define MPQ_FLAG_PROTECTED 0x00000002 // Set on protected MPQs (like W3M maps) - -// Flags for SFileAddFile -#define MPQ_FILE_COMPRESS_PKWARE 0x00000100 // Compression made by PKWARE Data Compression Library -#define MPQ_FILE_COMPRESS_MULTI 0x00000200 // Multiple compressions -#define MPQ_FILE_COMPRESSED 0x0000FF00 // File is compressed -#define MPQ_FILE_ENCRYPTED 0x00010000 // Indicates whether file is encrypted -#define MPQ_FILE_FIXSEED 0x00020000 // File decrypt seed has to be fixed -#define MPQ_FILE_SINGLE_UNIT 0x01000000 // File is stored as a single unit, rather than split into sectors (Thx, Quantam) -#define MPQ_FILE_DUMMY_FILE 0x02000000 // The file is only 1 byte long and its name is a hash -#define MPQ_FILE_HAS_EXTRA 0x04000000 // The file has extra data appended after regular data. - // Must be with compressed files only -#define MPQ_FILE_EXISTS 0x80000000 // Set if file exists, reset when the file was deleted -#define MPQ_FILE_REPLACEEXISTING 0x80000000 // Replace when the file exist (SFileAddFile) - -#define MPQ_FILE_VALID_FLAGS (MPQ_FILE_COMPRESS_PKWARE | \ - MPQ_FILE_COMPRESS_MULTI | \ - MPQ_FILE_ENCRYPTED | \ - MPQ_FILE_FIXSEED | \ - MPQ_FILE_SINGLE_UNIT | \ - MPQ_FILE_DUMMY_FILE | \ - MPQ_FILE_HAS_EXTRA | \ - MPQ_FILE_EXISTS) - -// Compression types for multilpe compressions -#define MPQ_COMPRESSION_HUFFMANN 0x01 // Huffmann compression (used on WAVE files only) -#define MPQ_COMPRESSION_ZLIB 0x02 // ZLIB compression -#define MPQ_COMPRESSION_PKWARE 0x08 // PKWARE DCL compression -#define MPQ_COMPRESSION_BZIP2 0x10 // BZIP2 compression -#define MPQ_COMPRESSION_WAVE_MONO 0x40 // -#define MPQ_COMPRESSION_WAVE_STEREO 0x80 // - - -// Constants for SFileAddWave -#define MPQ_WAVE_QUALITY_HIGH 0 // Best quality, the worst compression -#define MPQ_WAVE_QUALITY_MEDIUM 1 // Medium quality, medium compression -#define MPQ_WAVE_QUALITY_LOW 2 // Low quality, the best compression - -// Constants for SFileGetFileInfo -#define SFILE_INFO_ARCHIVE_SIZE 1 // MPQ size (value from header) -#define SFILE_INFO_HASH_TABLE_SIZE 2 // Size of hash table, in entries -#define SFILE_INFO_BLOCK_TABLE_SIZE 3 // Number of entries in the block table -#define SFILE_INFO_BLOCK_SIZE 4 // Size of file block (in bytes) -#define SFILE_INFO_HASH_TABLE 5 // Pointer to Hash table (TMPQHash *) -#define SFILE_INFO_BLOCK_TABLE 6 // Pointer to Block Table (TMPQBlock *) -#define SFILE_INFO_NUM_FILES 7 // Real number of files within archive -//------ -#define SFILE_INFO_HASH_INDEX 8 // Hash index of file in MPQ -#define SFILE_INFO_CODENAME1 9 // The first codename of the file -#define SFILE_INFO_CODENAME2 10 // The second codename of the file -#define SFILE_INFO_LOCALEID 11 // Locale ID of file in MPQ -#define SFILE_INFO_BLOCKINDEX 12 // Index to Block Table -#define SFILE_INFO_FILE_SIZE 13 // Original file size -#define SFILE_INFO_COMPRESSED_SIZE 14 // Compressed file size -#define SFILE_INFO_FLAGS 15 // File flags -#define SFILE_INFO_POSITION 16 // File position within archive -#define SFILE_INFO_SEED 17 // File decryption seed -#define SFILE_INFO_SEED_UNFIXED 18 // Decryption seed not fixed to file pos and size - -// Values for compact callback -#define CCB_CHECKING_FILES 1 // Checking archive (dwParam1 = current, dwParam2 = total) -#define CCB_CHECKING_HASH_TABLE 2 // Checking hash table (dwParam1 = current, dwParam2 = total) -#define CCB_COPYING_NON_MPQ_DATA 3 // Copying non-MPQ data: No params used -#define CCB_COMPACTING_FILES 4 // Compacting archive (dwParam1 = current, dwParam2 = total) -#define CCB_CLOSING_ARCHIVE 5 // Closing archive: No params used - -#define LISTFILE_NAME "(listfile)" // Name of internal listfile -#define SIGNATURE_NAME "(signature)" // Name of internal signature -#define ATTRIBUTES_NAME "(attributes)" // Name of internal attributes file - -#define STORMLIB_VERSION (0x0600) // Current version of StormLib - -#define MPQ_FORMAT_VERSION_1 0 // Up to The Burning Crusade -#define MPQ_FORMAT_VERSION_2 1 // The Burning Crusade and newer, - -// Flags for SFileOpenArchiveEx -#define MPQ_OPEN_NO_LISTFILE 0x00000001 // Don't add the internal listfile - -// supports archives with size > 4 GB -// Additional flags for SFileCreateArchiveEx -#define MPQ_CREATE_ARCHIVE_V1 0x00000000 // Creates archive with size up to 4GB -#define MPQ_CREATE_ARCHIVE_V2 0x00010000 // Creates archive larger than 4 GB - -//----------------------------------------------------------------------------- -// Structures - -#if (defined(WIN32) || defined(WIN64)) -#include -#else -#pragma pack(1) -#endif - -struct TMPQFile; - -struct TMPQShunt -{ - // The ID_MPQ_SHUNT ('MPQ\x1B') signature - DWORD dwID; - - DWORD dwUnknown; - - // Position of the MPQ header, relative to the begin of the shunt - DWORD dwHeaderPos; -}; - - -// MPQ file header -struct TMPQHeader -{ - // The ID_MPQ ('MPQ\x1A') signature - DWORD dwID; - - // Size of the archive header - DWORD dwHeaderSize; - - // Size of MPQ archive - // This field is deprecated in the Burning Crusade MoPaQ format, and the size of the archive - // is calculated as the size from the beginning of the archive to the end of the hash table, - // block table, or extended block table (whichever is largest). - DWORD dwArchiveSize; - - // 0 = Original format - // 1 = Extended format (The Burning Crusade and newer) - USHORT wFormatVersion; - - // Power of two exponent specifying the number of 512-byte disk sectors in each logical sector - // in the archive. The size of each logical sector in the archive is 512 * 2^SectorSizeShift. - // Bugs in the Storm library dictate that this should always be 3 (4096 byte sectors). - USHORT wBlockSize; - - // Offset to the beginning of the hash table, relative to the beginning of the archive. - DWORD dwHashTablePos; - - // Offset to the beginning of the block table, relative to the beginning of the archive. - DWORD dwBlockTablePos; - - // Number of entries in the hash table. Must be a power of two, and must be less than 2^16 for - // the original MoPaQ format, or less than 2^20 for the Burning Crusade format. - DWORD dwHashTableSize; - - // Number of entries in the block table - DWORD dwBlockTableSize; -}; - - -// Extended MPQ file header. Valid only if wFormatVersion is 1 or higher -struct TMPQHeader2 : public TMPQHeader -{ - // Offset to the beginning of the extended block table, relative to the beginning of the archive. - LARGE_INTEGER ExtBlockTablePos; - - // High 16 bits of the hash table offset for large archives. - USHORT wHashTablePosHigh; - - // High 16 bits of the block table offset for large archives. - USHORT wBlockTablePosHigh; -}; - - -// Hash entry. All files in the archive are searched by their hashes. -struct TMPQHash -{ - // The hash of the file path, using method A. - DWORD dwName1; - - // The hash of the file path, using method B. - DWORD dwName2; - -#ifdef PLATFORM_LITTLE_ENDIAN - - // The language of the file. This is a Windows LANGID data type, and uses the same values. - // 0 indicates the default language (American English), or that the file is language-neutral. - USHORT lcLocale; - - // The platform the file is used for. 0 indicates the default platform. - // No other values have been observed. - USHORT wPlatform; - -#else - - USHORT wPlatform; - USHORT lcLocale; - -#endif - - // If the hash table entry is valid, this is the index into the block table of the file. - // Otherwise, one of the following two values: - // - FFFFFFFFh: Hash table entry is empty, and has always been empty. - // Terminates searches for a given file. - // - FFFFFFFEh: Hash table entry is empty, but was valid at some point (a deleted file). - // Does not terminate searches for a given file. - DWORD dwBlockIndex; -}; - - -// File description block contains informations about the file -struct TMPQBlock -{ - // Offset of the beginning of the block, relative to the beginning of the archive. - DWORD dwFilePos; - - // Compressed file size - DWORD dwCSize; - - // Only valid if the block is a file; otherwise meaningless, and should be 0. - // If the file is compressed, this is the size of the uncompressed file data. - DWORD dwFSize; - - // Flags for the file. See MPQ_FILE_XXXX constants - DWORD dwFlags; -}; - - -// The extended block table was added to support archives larger than 4 gigabytes (2^32 bytes). -// The table contains the upper bits of the archive offsets for each block in the block table. -// It is simply an array of int16s, which become bits 32-47 of the archive offsets for each block, -// with bits 48-63 being zero. Individual blocks in the archive are still limited to 4 gigabytes -// in size. This table is only present in Burning Crusade format archives that exceed 4 gigabytes size. -struct TMPQBlockEx -{ - USHORT wFilePosHigh; -}; - - -struct TFileNode -{ - DWORD dwRefCount; // Number of references - // There can be more files that have the same name. - // (e.g. multiple language files). We don't want to - // have an entry for each of them, so the entries will be referenced. - // When a number of node references reaches zero, - // the node will be deleted - - size_t nLength; // File name length - char szFileName[1]; // File name, variable length -}; - -#if (defined(WIN32) || defined(WIN64)) -#include -#else -#pragma options align=reset -#endif - -// Archive handle structure. Note that it does not agree with Storm.dll's structure. -struct TMPQArchive -{ -// TMPQArchive * pNext; // Next archive (used by Storm.dll only) -// TMPQArchive * pPrev; // Previous archive (used by Storm.dll only) - char szFileName[MAX_PATH]; // Opened archive file name - HANDLE hFile; // File handle - DWORD dwPriority; // Priority of the archive - LARGE_INTEGER ShuntPos; // Position of MPQShunt (only valid if a shunt is present) - LARGE_INTEGER MpqPos; // MPQ position in the file, relative to the begin of the file - LARGE_INTEGER MpqSize; // Size of MPQ archive - LARGE_INTEGER HashTablePos; // Offset of the hast table in the MPQ, relative to the begin of the file - LARGE_INTEGER BlockTablePos; // Offset of the hast table in the MPQ, relative to the begin - LARGE_INTEGER ExtBlockTablePos; // Offset of the extended block table, relative to the begin - LARGE_INTEGER FilePointer; // Current position in the file (relative to begin of the file) - - TMPQFile * pLastFile; // Recently read file - DWORD dwBlockPos; // Position of loaded block in the file - DWORD dwBlockSize; // Size of file block - BYTE * pbBlockBuffer; // Buffer (cache) for file block - DWORD dwBuffPos; // Position in block buffer - TMPQShunt * pShunt; // MPQ shunt (NULL if not present in the file) - TMPQHeader2 * pHeader; // MPQ file header - TMPQHash * pHashTable; // Hash table - TMPQBlock * pBlockTable; // Block table - TMPQBlockEx * pExtBlockTable; // Extended block table - - TMPQShunt Shunt; // MPQ shunt. Valid only when ID_MPQ_SHUNT has been found - TMPQHeader2 Header; // MPQ header - - // Non-Storm.dll members - TFileNode ** pListFile; // File name array -// HANDLE hListFile; // Handle to temporary listfile (when open with write access) - DWORD dwFlags; // See MPQ_FLAG_XXXXX -// BOOL bChanged; // TRUE if the archive was changed since open. -// BOOL bProtected; // TRUE if the archive is protected by somehow -}; - - -// File handle structure. Note that it does not agree with Storm.dll structures -struct TMPQFile -{ - HANDLE hFile; // File handle - TMPQArchive * ha; // Archive handle - TMPQHash * pHash; // Hash table entry - TMPQBlockEx * pBlockEx; // Pointer to extended file block entry - TMPQBlock * pBlock; // File block pointer - DWORD dwSeed1; // Seed used for file decrypt - DWORD dwFilePos; // Current file position - LARGE_INTEGER MpqFilePos; // Position of the file data in MPQ archive - // (relative to file begin) - - DWORD * pdwBlockPos; // Position of each file block (only for compressed files) - DWORD nBlocks; // Number of blocks in the file (incl. the last noncomplete one) - BOOL bBlockPosLoaded; // TRUE if block positions loaded - BYTE * pbFileBuffer; // Decompressed file (for single unit files, size is the uncompressed file size) - - DWORD dwHashIndex; // Index to Hash table - DWORD dwFileIndex; // Index to Block table - char szFileName[1]; // File name (variable length) -}; - - -// Used by searching in MPQ archives -struct TMPQSearch -{ - TMPQArchive * ha; // Handle to MPQ, where the search runs - DWORD dwNextIndex; // The next searched hash index - DWORD dwName1; // Lastly found Name1 - DWORD dwName2; // Lastly found Name2 - char szSearchMask[1]; // Search mask (variable length) -}; - - -struct SFILE_FIND_DATA -{ - char cFileName[MAX_PATH]; // Full name of the found file - char * szPlainName; // Pointer to file part - LCID lcLocale; // Locale version - DWORD dwFileSize; // File size in bytes - DWORD dwFileFlags; // File flags (compressed or encrypted) - DWORD dwBlockIndex; // Block index for the file - DWORD dwCompSize; // Compressed file size -}; - -//----------------------------------------------------------------------------- -// Memory management -// -// We use our own macros for allocating/freeing memory. If you want -// to redefine them, please keep the following rules -// -// - The memory allocation must return NULL if not enough memory -// (i.e not to throw exception) -// - It is not necessary to fill the allocated block with zeros -// - Memory freeing function must not test the pointer to NULL. -// - - -__inline void * DebugMalloc(char * szFile, int nLine, int nSize) -{ - void * ptr = malloc(nSize + 100); - char * plain; - - plain = strrchr(szFile, '\\'); - if(plain == NULL) - plain = strrchr(szFile, '/'); - if(plain == NULL) - plain = szFile; - -#if _MSC_VER > 0x1300 - sprintf_s((char *)ptr, nSize+100, "%s(%u)", plain, nLine); -#else - sprintf((char *)ptr, "%s(%u)", plain, nLine); -#endif - - return (char *)ptr + 100; -} - - -__inline void DebugFree(void * ptr) -{ - free((char *)ptr - 100); -} - - -#ifndef ALLOCMEM - #define ALLOCMEM(type, nitems) (type *)malloc((nitems) * sizeof(type)) - #define FREEMEM(ptr) free(ptr) -#endif - -//#define ALLOCMEM(type, nitems) (type *)DebugMalloc(__FILE__, __LINE__, (nitems) * sizeof(type)) -//#define FREEMEM(ptr) DebugFree(ptr) - -//----------------------------------------------------------------------------- -// Functions in StormLib - compatible with Storm.dll - -// Typedefs for functions exported by Storm.dll -typedef LCID (WINAPI * SFILESETLOCALE)(LCID); -typedef BOOL (WINAPI * SFILEOPENARCHIVE)(const char *, DWORD, DWORD, HANDLE *); -typedef BOOL (WINAPI * SFILECLOSEARCHIVE)(HANDLE); -typedef BOOL (WINAPI * SFILEOPENFILEEX)(HANDLE, const char *, DWORD, HANDLE *); -typedef BOOL (WINAPI * SFILECLOSEFILE)(HANDLE); -typedef DWORD (WINAPI * SFILEGETFILESIZE)(HANDLE, DWORD *); -typedef DWORD (WINAPI * SFILESETFILEPOINTER)(HANDLE, LONG, LONG *, DWORD); -typedef BOOL (WINAPI * SFILEREADFILE)(HANDLE, VOID *, DWORD, DWORD *, LPOVERLAPPED); - -// Archive opening/closing -LCID WINAPI SFileSetLocale(LCID lcNewLocale); -LCID WINAPI SFileGetLocale(); -BOOL WINAPI SFileOpenArchive(const char * szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE * phMPQ); -BOOL WINAPI SFileCloseArchive(HANDLE hMPQ); - -// File opening/closing -BOOL WINAPI SFileOpenFileEx(HANDLE hMPQ, const char * szFileName, DWORD dwSearchScope, HANDLE * phFile); -BOOL WINAPI SFileCloseFile(HANDLE hFile); - -// File I/O -DWORD WINAPI SFileGetFilePos(HANDLE hFile, DWORD * pdwFilePosHigh = NULL); -DWORD WINAPI SFileGetFileSize(HANDLE hFile, DWORD * pdwFileSizeHigh = NULL); -DWORD WINAPI SFileSetFilePointer(HANDLE hFile, LONG lFilePos, LONG * pdwFilePosHigh, DWORD dwMethod); -BOOL WINAPI SFileReadFile(HANDLE hFile, VOID * lpBuffer, DWORD dwToRead, DWORD * pdwRead = NULL, LPOVERLAPPED lpOverlapped = NULL); - -BOOL WINAPI SFileExtractFile(HANDLE hMpq, const char * szToExtract, const char * szExtracted); - -// Adds another listfile into MPQ. The currently added listfile(s) remain, -// so you can use this API to combining more listfiles. -// Note that this function is internally called by SFileFindFirstFile -int WINAPI SFileAddListFile(HANDLE hMpq, const char * szListFile); - -//----------------------------------------------------------------------------- -// Functions in StormLib - not implemented in Storm.dll - -// Archive creating and editing -BOOL WINAPI SFileCreateArchiveEx(const char * szMpqName, DWORD dwCreationDisposition, DWORD dwHashTableSize, HANDLE * phMPQ); -BOOL WINAPI SFileAddFile(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags); -BOOL WINAPI SFileAddWave(HANDLE hMPQ, const char * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality); -BOOL WINAPI SFileRemoveFile(HANDLE hMPQ, const char * szFileName, DWORD dwSearchScope = SFILE_OPEN_BY_INDEX); -BOOL WINAPI SFileRenameFile(HANDLE hMPQ, const char * szOldFileName, const char * szNewFileName); -BOOL WINAPI SFileSetFileLocale(HANDLE hFile, LCID lcNewLocale); - -// Retrieving info about the file -BOOL WINAPI SFileHasFile(HANDLE hMPQ, char * szFileName); -BOOL WINAPI SFileGetFileName(HANDLE hFile, char * szFileName); -DWORD_PTR WINAPI SFileGetFileInfo(HANDLE hMpqOrFile, DWORD dwInfoType); - -// File search -// Note that the SFileFindFirstFileEx has been removed. Use SListFileFindFirst/Next -HANDLE WINAPI SFileFindFirstFile(HANDLE hMPQ, const char * szMask, SFILE_FIND_DATA * lpFindFileData, const char * szListFile); -BOOL WINAPI SFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData); -BOOL WINAPI SFileFindClose(HANDLE hFind); - -// Listfile search -HANDLE SListFileFindFirstFile(HANDLE hMpq, const char * szListFile, const char * szMask, SFILE_FIND_DATA * lpFindFileData); -BOOL SListFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData); -BOOL SListFileFindClose(HANDLE hFind); - -// Archive compacting -typedef void (WINAPI * COMPACTCB)(void * lpUserData, DWORD dwWorkType, DWORD dwParam1, DWORD dwParam2); -BOOL WINAPI SFileSetCompactCallback(HANDLE hMPQ, COMPACTCB CompactCB, void * lpData); -BOOL WINAPI SFileCompactArchive(HANDLE hMPQ, const char * szListFile = NULL, BOOL bReserved = 0); - -// Locale support -int WINAPI SFileEnumLocales(HANDLE hMPQ, const char * szFileName, LCID * plcLocales, DWORD * pdwMaxLocales, DWORD dwSearchScope = SFILE_OPEN_BY_INDEX); - -// (De)compression -int WINAPI SCompCompress (char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength, int uCompressions, int nCmpType, int nCmpLevel); -int WINAPI SCompDecompress (char * pbOutBuffer, int * pdwOutLength, char * pbInBuffer, int dwInLength); - -// Sets the default data compression for files added to MPQ, -// if MPQ_FILE_COMPRESS_MULTI has been specified in call to SFileAddFile -int WINAPI SCompSetDataCompression(int nDataCompression); - -//----------------------------------------------------------------------------- -// Functions from Storm.dll. They use slightly different names for keeping -// possibility to use them together with StormLib (StormXXX instead of SFileXXX) - -#ifdef __LINK_STORM_DLL__ - #define STORM_ALTERNATE_NAMES // Force Storm.h to use alternate fnc names - #include "StormDll.h" -#endif // __LINK_STORM_DLL__ - -//----------------------------------------------------------------------------- -// GFX decode functions. See GfxDecode.cpp for details and description - -USHORT WINAPI celGetFrameCount(BYTE * fileBuf); -BYTE * WINAPI celGetFrameData(BYTE *fileBuf, BYTE *palette, USHORT xsize, USHORT frame, USHORT *ysize, USHORT *maxX=NULL); -USHORT WINAPI cl2GetFrameCount(BYTE *fileBuf); -BYTE ** WINAPI cl2GetDirData(BYTE *fileBuf, BYTE *palette, USHORT xsize, USHORT dir, USHORT *ysize); -BYTE * WINAPI pcxGetData(BYTE *filebuf, DWORD filesize, BYTE transcol, USHORT *xsize, USHORT *ysize); - -#endif // __STORMLIB_H_ diff --git a/contrib/vmap_extractor_v2/stormlib/StormPort.h b/contrib/vmap_extractor_v2/stormlib/StormPort.h deleted file mode 100644 index 6254f84e725..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/StormPort.h +++ /dev/null @@ -1,278 +0,0 @@ -/*****************************************************************************/ -/* StormPort.h Copyright (c) Marko Friedemann 2001 */ -/*---------------------------------------------------------------------------*/ -/* Portability module for the StormLib library. Contains a wrapper symbols */ -/* to make the compilation under Linux work */ -/* */ -/* Author: Marko Friedemann */ -/* Created at: Mon Jan 29 18:26:01 CEST 2001 */ -/* Computer: whiplash.flachland-chemnitz.de */ -/* System: Linux 2.4.0 on i686 */ -/* */ -/* Author: Sam Wilkins */ -/* System: Mac OS X and port to big endian processor */ -/* */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 29.01.01 1.00 Mar Created */ -/* 24.03.03 1.01 Lad Some cosmetic changes */ -/* 12.11.03 1.02 Dan Macintosh compatibility */ -/* 24.07.04 1.03 Sam Mac OS X compatibility */ -/* 22.11.06 1.04 Sam Mac OS X compatibility (for StormLib 6.0) */ -/* 31.12.06 1.05 XPinguin Full GNU/Linux compatibility */ -/*****************************************************************************/ - -#ifndef __STORMPORT_H__ -#define __STORMPORT_H__ - -// Defines for Windows -#if !defined(PLATFORM_DEFINED) && (defined(WIN32) || defined(WIN64)) - - // In MSVC 8.0, there are some functions declared as deprecated. - #if _MSC_VER >= 1400 - #define _CRT_SECURE_NO_DEPRECATE - #define _CRT_NON_CONFORMING_SWPRINTFS - #endif - - #include - #include - #include - #define PLATFORM_LITTLE_ENDIAN 1 - - #ifdef WIN64 - #define PLATFORM_64BIT - #else - #define PLATFORM_32BIT - #endif - - #define PLATFORM_DEFINED // The platform is known now - -#endif - -// Defines for Mac Carbon -#if !defined(PLATFORM_DEFINED) && defined(__APPLE__) // Mac Carbon API - - // Macintosh using Carbon - #include // Mac OS X - #define _stricmp strcasecmp // Case insensitive strcmp has a different name on this platform. - #define _strnicmp strncasecmp - - typedef void * LPCSTR; - typedef unsigned long * LPDWORD; - typedef long * PLONG; - typedef void * LPVOID; - typedef unsigned int UINT; - - #define PKEXPORT - #define __SYS_ZLIB - #define __SYS_BZLIB - #define LANG_NEUTRAL 0 - - #if defined(__BIG_ENDIAN__) - #define PLATFORM_LITTLE_ENDIAN 0 - #else - #define PLATFORM_LITTLE_ENDIAN 1 // Apple is now making Macs with Intel CPUs - #endif - #define PLATFORM_DEFINED // The platform is known now - -#endif - -// Assumption: we are not on Windows nor Macintosh, so this must be linux *grin* -// Ladik : Why the hell Linux does not use some OS-dependent #define ? -#if !defined(PLATFORM_DEFINED) - - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - - #define PLATFORM_LITTLE_ENDIAN 1 - #define PLATFORM_DEFINED - #define LANG_NEUTRAL 0 - -#endif /* not __powerc */ - - -#if !defined(WIN32) && !defined(WIN64) - - // Typedefs for ANSI C - typedef unsigned char BYTE; - typedef short SHORT; - typedef unsigned short WORD; - typedef unsigned short USHORT; - typedef long LONG; - typedef unsigned long DWORD; - typedef unsigned long DWORD_PTR; - typedef long LONG_PTR; - typedef long long LONGLONG; -#ifndef __OBJC__ - #define BOOL bool -#endif - typedef void * HANDLE; - typedef void * LPOVERLAPPED; // Unsupported on Linux - typedef char TCHAR; - typedef unsigned long LCID; - - typedef void * LPCSTR; - typedef unsigned long * LPDWORD; - typedef long * PLONG; - typedef void * LPVOID; - typedef unsigned int UINT; - - typedef struct _FILETIME - { - DWORD dwLowDateTime; - DWORD dwHighDateTime; - } - FILETIME, *PFILETIME; - - typedef union _LARGE_INTEGER - { - #if PLATFORM_LITTLE_ENDIAN - struct - { - DWORD LowPart; - LONG HighPart; - }; - #else - struct - { - LONG HighPart; - DWORD LowPart; - }; - #endif - LONGLONG QuadPart; - } - LARGE_INTEGER, *PLARGE_INTEGER; - - // Some Windows-specific defines - #ifndef MAX_PATH - #define MAX_PATH 1024 - #endif - - #ifndef TRUE - #define TRUE true - #endif - - #ifndef FALSE - #define FALSE false - #endif - - #define VOID void - #define WINAPI - - #define FILE_BEGIN SEEK_SET - #define FILE_CURRENT SEEK_CUR - #define FILE_END SEEK_END - - #define CREATE_NEW 1 - #define CREATE_ALWAYS 2 - #define OPEN_EXISTING 3 - #define OPEN_ALWAYS 4 - - #define FILE_SHARE_READ 0x00000001L - #define GENERIC_WRITE 0x40000000 - #define GENERIC_READ 0x80000000 - - #define FILE_FLAG_DELETE_ON_CLOSE 1 // Sam: Added these two defines so it would compile. - #define FILE_FLAG_SEQUENTIAL_SCAN 2 - - #define ERROR_SUCCESS 0 - #define ERROR_INVALID_FUNCTION 1 - #define ERROR_FILE_NOT_FOUND 2 - #define ERROR_ACCESS_DENIED 5 - #define ERROR_NOT_ENOUGH_MEMORY 8 - #define ERROR_BAD_FORMAT 11 - #define ERROR_NO_MORE_FILES 18 - #define ERROR_GEN_FAILURE 31 - #define ERROR_HANDLE_EOF 38 - #define ERROR_HANDLE_DISK_FULL 39 - #define ERROR_NOT_SUPPORTED 50 - #define ERROR_INVALID_PARAMETER 87 - #define ERROR_DISK_FULL 112 - #define ERROR_CALL_NOT_IMPLEMENTED 120 - #define ERROR_ALREADY_EXISTS 183 - #define ERROR_CAN_NOT_COMPLETE 1003 - #define ERROR_PARAMETER_QUOTA_EXCEEDED 1283 - #define ERROR_FILE_CORRUPT 1392 - #define ERROR_INSUFFICIENT_BUFFER 4999 - - #define INVALID_HANDLE_VALUE ((HANDLE) -1) - - #ifndef min - #define min(a, b) ((a < b) ? a : b) - #endif - - #ifndef max - #define max(a, b) ((a > b) ? a : b) - #endif - - #define _stricmp strcasecmp - #define _strnicmp strncasecmp - - extern int globalerr; - - void SetLastError(int err); - int GetLastError(); - char *ErrString(int err); - - // Emulation of functions for file I/O available in Win32 - HANDLE CreateFile(const char * lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, void * lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile); - BOOL CloseHandle(HANDLE hObject); - - DWORD GetFileSize(HANDLE hFile, DWORD * lpFileSizeHigh); - DWORD SetFilePointer(HANDLE, LONG lDistanceToMove, LONG * lpDistanceToMoveHigh, DWORD dwMoveMethod); - BOOL SetEndOfFile(HANDLE hFile); - - BOOL ReadFile(HANDLE hFile, void * lpBuffer, DWORD nNumberOfBytesToRead, DWORD * lpNumberOfBytesRead, void * lpOverLapped); - BOOL WriteFile(HANDLE hFile, const void * lpBuffer, DWORD nNumberOfBytesToWrite, DWORD * lpNumberOfBytesWritten, void * lpOverLapped); - - BOOL IsBadReadPtr(const void * ptr, int size); - DWORD GetFileAttributes(const char * szileName); - - BOOL DeleteFile(const char * lpFileName); - BOOL MoveFile(const char * lpFromFileName, const char * lpToFileName); - void GetTempPath(DWORD szTempLength, char * szTemp); - void GetTempFileName(const char * lpTempFolderPath, const char * lpFileName, DWORD something, char * szLFName); - - #define strnicmp strncasecmp - -#endif // !WIN32 - -#if PLATFORM_LITTLE_ENDIAN - #define BSWAP_INT16_UNSIGNED(a) (a) - #define BSWAP_INT16_SIGNED(a) (a) - #define BSWAP_INT32_UNSIGNED(a) (a) - #define BSWAP_INT32_SIGNED(a) (a) - #define BSWAP_ARRAY16_UNSIGNED(a,b) {} - #define BSWAP_ARRAY32_UNSIGNED(a,b) {} - #define BSWAP_TMPQSHUNT(a) {} - #define BSWAP_TMPQHEADER(a) {} -#else - extern unsigned short SwapUShort(unsigned short); - extern unsigned long SwapULong(unsigned long); - extern short SwapShort(unsigned short); - extern long SwapLong(unsigned long); - extern void ConvertUnsignedLongBuffer(unsigned long *buffer, unsigned long nbLongs); - extern void ConvertUnsignedShortBuffer(unsigned short *buffer, unsigned long nbShorts); - extern void ConvertTMPQShunt(void *shunt); - extern void ConvertTMPQHeader(void *header); - #define BSWAP_INT16_UNSIGNED(a) SwapUShort((a)) - #define BSWAP_INT32_UNSIGNED(a) SwapULong((a)) - #define BSWAP_INT16_SIGNED(a) SwapShort((a)) - #define BSWAP_INT32_SIGNED(a) SwapLong((a)) - #define BSWAP_ARRAY16_UNSIGNED(a,b) ConvertUnsignedShortBuffer((a),(b)) - #define BSWAP_ARRAY32_UNSIGNED(a,b) ConvertUnsignedLongBuffer((a),(b)) - #define BSWAP_TMPQSHUNT(a) ConvertTMPQShunt((a)) - #define BSWAP_TMPQHEADER(a) ConvertTMPQHeader((a)) -#endif - -#endif // __STORMPORT_H__ diff --git a/contrib/vmap_extractor_v2/stormlib/StormPortLinux.cpp b/contrib/vmap_extractor_v2/stormlib/StormPortLinux.cpp deleted file mode 100644 index afbbd985a7f..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/StormPortLinux.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/******************************************************************** -* -* Description: implementation for StormLib - linux port -* intended to be used in GLdiablo -* -* ----> StormLib was originally developed for Windows by -* Ladislav Zezula (www.zezula.net), and he did -* a _great_ job! Thanks Ladislav! -* -* this is currently a quick and dirty hack to get it working -* don't expect beauty and/or miracles :) -* -* these are function wraps to execute Windows API calls -* as native Macintosh file calls (open/close/read/write/...) -* -* continue you work: added some wrapping functions for GNU/Linux by XPinguin -* -* Author: Marko Friedemann -* Created at: Mon Jan 29 19:01:37 CEST 2001 -* Computer: whiplash.flachland-chemnitz.de -* System: Linux 2.4.0 on i686 -* -* Copyright (c) 2001 BMX-Chemnitz.DE All rights reserved. -* -********************************************************************/ - -#ifndef _WIN32 -#include "StormPort.h" - -int globalerr; - -void SetLastError(int err) -{ - globalerr = err; -} - -int GetLastError() -{ - return(globalerr); -} - -char *ErrString(int err) -{ - switch (err) { - case ERROR_INVALID_FUNCTION: - return "function not implemented"; - case ERROR_FILE_NOT_FOUND: - return "file not found"; - case ERROR_ACCESS_DENIED: - return "access denied"; - case ERROR_NOT_ENOUGH_MEMORY: - return "not enough memory"; - case ERROR_BAD_FORMAT: - return "bad format"; - case ERROR_NO_MORE_FILES: - return "no more files"; - case ERROR_HANDLE_EOF: - return "access beyound EOF"; - case ERROR_HANDLE_DISK_FULL: - return "no space left on device"; - case ERROR_INVALID_PARAMETER: - return "invalid parameter"; - case ERROR_DISK_FULL: - return "no space left on device"; - case ERROR_ALREADY_EXISTS: - return "file exists"; - case ERROR_CAN_NOT_COMPLETE: - return "operation cannot be completed"; - default: - return "unknown error"; - } -} - -HANDLE CreateFile(const char *sFileName, DWORD ulMode, DWORD ulSharing, void *pSecAttrib, DWORD ulCreation, DWORD ulFlags, HANDLE hFile) -{ - switch (ulCreation) { - case OPEN_EXISTING: - return (HANDLE)open(sFileName, O_RDONLY | O_LARGEFILE); - case OPEN_ALWAYS: - return (HANDLE)open(sFileName, O_RDWR | O_CREAT); - case CREATE_NEW: - return (HANDLE)open(sFileName, O_RDWR | O_CREAT | O_TRUNC); - default: - return INVALID_HANDLE_VALUE; - } -} - -BOOL CloseHandle(HANDLE hFile) -{ - return (close((int)hFile) == 0); -} - -DWORD GetFileSize(HANDLE hFile, DWORD *ulOffSetHigh) -{ - if ((hFile == NULL) || (hFile == INVALID_HANDLE_VALUE)) - return 0xffffffff; - - struct stat fileinfo; - fstat((int)hFile, &fileinfo); - - return fileinfo.st_size; -} - -DWORD SetFilePointer(HANDLE hFile, LONG lOffSetLow, LONG *pOffSetHigh, DWORD ulMethod) -{ - return lseek64((int)hFile, (off64_t)(*pOffSetHigh) << 32 | (DWORD)lOffSetLow, ulMethod); -} - -BOOL SetEndOfFile(HANDLE hFile) -{ - return (ftruncate((int)hFile, lseek((int)hFile, 0, SEEK_CUR)) == 0); -} - -BOOL ReadFile(HANDLE hFile, void *pBuffer, DWORD ulLen, DWORD *ulRead, void *pOverLapped) -{ - ssize_t count; - if ((count = read((int)hFile, pBuffer, ulLen)) == -1) { - *ulRead = 0; - return false; - } - *ulRead = count; - return true; -} - -BOOL WriteFile(HANDLE hFile, const void *pBuffer, DWORD ulLen, DWORD *ulWritten, void *pOverLapped) -{ - ssize_t count; - if ((count = write((int)hFile, pBuffer, ulLen)) == -1) { - *ulWritten = 0; - return false; - } - *ulWritten = count; - return true; -} - -// Check if a memory block is accessible for reading -BOOL IsBadReadPtr(const void * ptr, int size) -{ - return FALSE; -} - -// Returns attributes of a file -DWORD GetFileAttributes(const char * szFileName) -{ - return 0; -} - -void GetTempPath(DWORD szTempLength, char * szTemp) -{ - strncpy(szTemp, P_tmpdir, szTempLength); -} - -void GetTempFileName(const char * lpTempFolderPath, const char * lpFileName, DWORD something, char * szLFName) -{ - strcpy(szLFName, tempnam(lpTempFolderPath, lpFileName)); -} - -BOOL DeleteFile(const char *lpFileName) -{ - return (BOOL)remove(lpFileName); -} - -BOOL MoveFile(const char *lpExistingFileName, const char *lpNewFileName) -{ - return rename(lpExistingFileName, lpNewFileName); -} - -#endif diff --git a/contrib/vmap_extractor_v2/stormlib/StormPortMac.cpp b/contrib/vmap_extractor_v2/stormlib/StormPortMac.cpp deleted file mode 100644 index 2477333ae02..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/StormPortMac.cpp +++ /dev/null @@ -1,762 +0,0 @@ -/******************************************************************** -* -* Description: implementation for StormLib - Macintosh port -* -* these are function wraps to execute Windows API calls -* as native Macintosh file calls (open/close/read/write/...) -* requires Mac OS X -* -* Derived from Marko Friedemann -* StormPort.cpp for Linux -* -* Author: Daniel Chiaramello -* -* Carbonized by: Sam Wilkins -* -********************************************************************/ - -#ifndef _WIN32 -#include "StormPort.h" -#include "StormLib.h" - -// FUNCTIONS EXTRACTED FROM MOREFILE PACKAGE!!! -// FEEL FREE TO REMOVE THEM AND TO ADD THE ORIGINAL ONES! - -/***************************************************************************** -* BEGIN OF MOREFILES COPY-PASTE -*****************************************************************************/ - -#ifdef __USEPRAGMAINTERNAL - #ifdef __MWERKS__ - #pragma internal on - #endif -#endif - -union TLongAnd4Bytes -{ - unsigned char bytes[4]; - unsigned long uvalue; - signed long svalue; -}; - - -static OSErr FSGetFullPath(const FSRef *ref, UInt8 *fullPath, UInt32 fullPathLength) -{ - OSErr result; - - result = FSRefMakePath(ref, fullPath, fullPathLength); - - return result; -} - -static OSErr FSLocationFromFullPath(const void *fullPath, FSRef *ref) -{ - OSErr result; - - result = FSPathMakeRef((UInt8 *)fullPath, ref, NULL); // Create an FSRef from the path - return result; -} - -/*****************************************************************************/ - -/*****************************************************************************/ - -static OSErr FSCreateCompat(const FSRef *parentRef, OSType creator, OSType fileType, const UniChar *fileName, - UniCharCount nameLength, FSRef *ref) -{ - FSCatalogInfo theCatInfo; - OSErr theErr; - ((FileInfo *)&theCatInfo.finderInfo)->fileCreator = creator; - ((FileInfo *)&theCatInfo.finderInfo)->fileType = fileType; - ((FileInfo *)&theCatInfo.finderInfo)->finderFlags = 0; - SetPt(&((FileInfo *)&theCatInfo.finderInfo)->location, 0, 0); - ((FileInfo *)&theCatInfo.finderInfo)->reservedField = 0; - - theErr = FSCreateFileUnicode(parentRef, nameLength, fileName, kFSCatInfoFinderInfo, &theCatInfo, ref, NULL); - return theErr; -} - - -/*****************************************************************************/ - -static OSErr FSOpenDFCompat(FSRef *ref, char permission, short *refNum) -{ - HFSUniStr255 forkName; - OSErr theErr; - Boolean isFolder, wasChanged; - - theErr = FSResolveAliasFile(ref, TRUE, &isFolder, &wasChanged); - if (theErr != noErr) - return theErr; - - FSGetDataForkName(&forkName); - theErr = FSOpenFork(ref, forkName.length, forkName.unicode, permission, refNum); - return theErr; -} - -/***************************************************************************** -* END OF MOREFILES COPY-PASTE -*****************************************************************************/ - -#pragma mark - - -int globalerr; - -/******************************************************************** -* SwapLong -********************************************************************/ - -unsigned long SwapULong(unsigned long data) -{ - // Apple provided function - uint32_t result; - - __asm__("lwbrx %0,0,%1" : "=r" (result) : "r" (&data), "m" (data)); - return result; - -/* - TLongAnd4Bytes Work; - unsigned char * value_as_4bytes = (unsigned char *)&value; - - Work.bytes[0] = value_as_4bytes[3]; - Work.bytes[1] = value_as_4bytes[2]; - Work.bytes[2] = value_as_4bytes[1]; - Work.bytes[3] = value_as_4bytes[0]; - - return Work.uvalue; -*/ -} - -long SwapLong(unsigned long data) -{ - // Apple provided function - uint32_t result; - - __asm__("lwbrx %0,0,%1" : "=r" (result) : "r" (&data), "m" (data)); - return (long)result; - -/* - TLongAnd4Bytes Work; - unsigned char * value_as_4bytes = (unsigned char *)&value; - - Work.bytes[0] = value_as_4bytes[3]; - Work.bytes[1] = value_as_4bytes[2]; - Work.bytes[2] = value_as_4bytes[1]; - Work.bytes[3] = value_as_4bytes[0]; - - return Work.svalue; -*/ -} - -/******************************************************************** -* SwapShort -********************************************************************/ -unsigned short SwapUShort(unsigned short data) -{ - // Apple provided function - uint16_t result; - __asm__("lhbrx %0,0,%1" : "=r" (result) : "r" (&data), "m" (data)); - return result; -} - -short SwapShort(unsigned short data) -{ - // Apple provided function - uint16_t result; - __asm__("lhbrx %0,0,%1" : "=r" (result) : "r" (&data), "m" (data)); - return (short)result; -} - -/******************************************************************** -* ConvertUnsignedLongBuffer -********************************************************************/ -void ConvertUnsignedLongBuffer(unsigned long *buffer, unsigned long nbLongs) -{ - while (nbLongs-- > 0) - { - *buffer = SwapLong(*buffer); - buffer++; - } -} - -/******************************************************************** -* ConvertUnsignedShortBuffer -********************************************************************/ -void ConvertUnsignedShortBuffer(unsigned short *buffer, unsigned long nbShorts) -{ - while (nbShorts-- > 0) - { - *buffer = SwapShort(*buffer); - buffer++; - } -} - -/******************************************************************** -* ConvertTMPQShunt -********************************************************************/ -void ConvertTMPQShunt(void *shunt) -{ - TMPQShunt * theShunt = (TMPQShunt *)shunt; - - theShunt->dwID = SwapULong(theShunt->dwID); - theShunt->dwUnknown = SwapULong(theShunt->dwUnknown); - theShunt->dwHeaderPos = SwapULong(theShunt->dwHeaderPos); -} - -/******************************************************************** -* ConvertTMPQHeader -********************************************************************/ -void ConvertTMPQHeader(void *header) -{ - TMPQHeader2 * theHeader = (TMPQHeader2 *)header; - - theHeader->dwID = SwapULong(theHeader->dwID); - theHeader->dwHeaderSize = SwapULong(theHeader->dwHeaderSize); - theHeader->dwArchiveSize = SwapULong(theHeader->dwArchiveSize); - theHeader->wFormatVersion = SwapUShort(theHeader->wFormatVersion); - theHeader->wBlockSize = SwapUShort(theHeader->wBlockSize); - theHeader->dwHashTablePos = SwapULong(theHeader->dwHashTablePos); - theHeader->dwBlockTablePos = SwapULong(theHeader->dwBlockTablePos); - theHeader->dwHashTableSize = SwapULong(theHeader->dwHashTableSize); - theHeader->dwBlockTableSize = SwapULong(theHeader->dwBlockTableSize); - - if(theHeader->wFormatVersion >= MPQ_FORMAT_VERSION_2) - { - DWORD dwTemp = theHeader->ExtBlockTablePos.LowPart; - theHeader->ExtBlockTablePos.LowPart = theHeader->ExtBlockTablePos.HighPart; - theHeader->ExtBlockTablePos.HighPart = dwTemp; - theHeader->ExtBlockTablePos.LowPart = SwapULong(theHeader->ExtBlockTablePos.LowPart); - theHeader->ExtBlockTablePos.HighPart = SwapULong(theHeader->ExtBlockTablePos.HighPart); - theHeader->wHashTablePosHigh = SwapUShort(theHeader->wHashTablePosHigh); - theHeader->wBlockTablePosHigh = SwapUShort(theHeader->wBlockTablePosHigh); - } -} - -/******************************************************************** -* ConvertTMPQHash -********************************************************************/ -void ConvertHashTable(void *hashtable, DWORD nHashEntries) -{ - TMPQHash * theHash = (TMPQHash *)hashtable; - USHORT lcLocale; - - for(DWORD i = 0; i < nHashEntries; i++, theHash++) - { - lcLocale = theHash->lcLocale; - theHash->lcLocale = theHash->wPlatform; - theHash->wPlatform = lcLocale; - } -} - -#pragma mark - - -/******************************************************************** -* SetLastError -********************************************************************/ -void SetLastError(int err) -{ - globalerr = err; -} - -/******************************************************************** -* GetLastError -********************************************************************/ -int GetLastError() -{ - return globalerr; -} - -/******************************************************************** -* ErrString -********************************************************************/ -char *ErrString(int err) -{ - switch (err) - { - case ERROR_INVALID_FUNCTION: - return "function not implemented"; - case ERROR_FILE_NOT_FOUND: - return "file not found"; - case ERROR_ACCESS_DENIED: - return "access denied"; - case ERROR_NOT_ENOUGH_MEMORY: - return "not enough memory"; - case ERROR_BAD_FORMAT: - return "bad format"; - case ERROR_NO_MORE_FILES: - return "no more files"; - case ERROR_HANDLE_EOF: - return "access beyound EOF"; - case ERROR_HANDLE_DISK_FULL: - return "no space left on device"; - case ERROR_INVALID_PARAMETER: - return "invalid parameter"; - case ERROR_DISK_FULL: - return "no space left on device"; - case ERROR_ALREADY_EXISTS: - return "file exists"; - case ERROR_CAN_NOT_COMPLETE: - return "operation cannot be completed"; - case ERROR_INSUFFICIENT_BUFFER: - return "insufficient buffer"; - default: - return "unknown error"; - } -} - -#pragma mark - - -/******************************************************************** -* GetTempPath - returns a '/' or ':'-terminated path -* szTempLength: length for path -* szTemp: file path -********************************************************************/ -void GetTempPath(DWORD szTempLength, char * szTemp) // I think I'll change this to use FSRefs. -{ - FSRef theFSRef; - OSErr theErr = FSFindFolder(kOnAppropriateDisk, kTemporaryFolderType, kCreateFolder, &theFSRef); - if (theErr == noErr) - { - theErr = FSGetFullPath(&theFSRef, (UInt8 *)szTemp, MAX_PATH); - if (theErr != noErr) - szTemp[0] = '\0'; - } - else - szTemp[0] = '\0'; - strcat(szTemp, "/"); - - SetLastError(theErr); -} - -/******************************************************************** -* GetTempFileName -* lpTempFolderPath: the temporary folder path, terminated by "/" -* lpFileName: a file name base -* something: unknown -* szLFName: the final path, built from the path, the file name and a random pattern -********************************************************************/ -void GetTempFileName(const char * lpTempFolderPath, const char * lpFileName, DWORD something, char * szLFName) -{ -#pragma unused (something) - char tmp[2] = "A"; - - while (true) - { - HANDLE fHandle; - - strcpy(szLFName, lpTempFolderPath); - strcat(szLFName, lpFileName); - strcat(szLFName, tmp); - - if ((fHandle = CreateFile(szLFName, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE) - // OK we found it! - break; - CloseHandle(fHandle); - tmp[0]++; - } -} - -/******************************************************************** -* DeleteFile -* lpFileName: file path -********************************************************************/ -BOOL DeleteFile(const char * lpFileName) -{ - OSErr theErr; - FSRef theFileRef; - - theErr = FSLocationFromFullPath(lpFileName, &theFileRef); - if (theErr != noErr) - { - SetLastError(theErr); - return FALSE; - } - - theErr = FSDeleteObject(&theFileRef); - - SetLastError(theErr); - - return theErr == noErr; -} - -/******************************************************************** -* MoveFile -* lpFromFileName: old file path -* lpToFileName: new file path -********************************************************************/ -BOOL MoveFile(const char * lpFromFileName, const char * lpToFileName) -{ - OSErr theErr; - FSRef fromFileRef; - FSRef toFileRef; - FSRef parentFolderRef; - - // Get the path to the old file - theErr = FSLocationFromFullPath(lpFromFileName, &fromFileRef); - if (theErr != noErr) - { - SetLastError(theErr); - return false; - } - - // Get the path to the new folder for the file - char folderName[strlen(lpToFileName)]; - CFStringRef folderPathCFString = CFStringCreateWithCString(NULL, lpToFileName, kCFStringEncodingUTF8); - CFURLRef fileURL = CFURLCreateWithFileSystemPath(NULL, folderPathCFString, kCFURLPOSIXPathStyle, FALSE); - CFURLRef folderURL = CFURLCreateCopyDeletingLastPathComponent(NULL, fileURL); - CFURLGetFileSystemRepresentation(folderURL, TRUE, (UInt8 *)folderName, strlen(lpToFileName)); - theErr = FSLocationFromFullPath(folderName, &parentFolderRef); - CFRelease(fileURL); - CFRelease(folderURL); - CFRelease(folderPathCFString); - - // Move the old file - theErr = FSMoveObject(&fromFileRef, &parentFolderRef, &toFileRef); - if (theErr != noErr) - { - SetLastError(theErr); - return false; - } - - // Get a CFString for the new file name - CFStringRef newFileNameCFString = CFStringCreateWithCString(NULL, lpToFileName, kCFStringEncodingUTF8); - fileURL = CFURLCreateWithFileSystemPath(NULL, newFileNameCFString, kCFURLPOSIXPathStyle, FALSE); - CFRelease(newFileNameCFString); - newFileNameCFString = CFURLCopyLastPathComponent(fileURL); - CFRelease(fileURL); - - // Convert CFString to Unicode and rename the file - UniChar unicodeFileName[256]; - CFStringGetCharacters(newFileNameCFString, CFRangeMake(0, CFStringGetLength(newFileNameCFString)), - unicodeFileName); - theErr = FSRenameUnicode(&toFileRef, CFStringGetLength(newFileNameCFString), unicodeFileName, - kTextEncodingUnknown, NULL); - if (theErr != noErr) - { - SetLastError(theErr); - CFRelease(newFileNameCFString); - return false; - } - - CFRelease(newFileNameCFString); - - SetLastError(theErr); - return true; -} - -/******************************************************************** -* CreateFile -* ulMode: GENERIC_READ | GENERIC_WRITE -* ulSharing: FILE_SHARE_READ -* pSecAttrib: NULL -* ulCreation: OPEN_EXISTING, OPEN_ALWAYS, CREATE_NEW -* ulFlags: 0 -* hFile: NULL -********************************************************************/ -HANDLE CreateFile( const char *sFileName, /* file name */ - DWORD ulMode, /* access mode */ - DWORD ulSharing, /* share mode */ - void *pSecAttrib, /* SD */ - DWORD ulCreation, /* how to create */ - DWORD ulFlags, /* file attributes */ - HANDLE hFile ) /* handle to template file */ -{ -#pragma unused (ulSharing, pSecAttrib, ulFlags, hFile) - - OSErr theErr; - FSRef theFileRef; - FSRef theParentRef; - short fileRef; - char permission; - static OSType gCreator; - static OSType gType; - - theErr = FSLocationFromFullPath(sFileName, &theFileRef); - if (theErr == fnfErr) - { // Create the FSRef for the parent directory. - memset(&theFileRef, 0, sizeof(FSRef)); - UInt8 folderName[MAX_PATH]; - CFStringRef folderPathCFString = CFStringCreateWithCString(NULL, sFileName, kCFStringEncodingUTF8); - CFURLRef fileURL = CFURLCreateWithFileSystemPath(NULL, folderPathCFString, kCFURLPOSIXPathStyle, FALSE); - CFURLRef folderURL = CFURLCreateCopyDeletingLastPathComponent(NULL, fileURL); - CFURLGetFileSystemRepresentation(folderURL, TRUE, folderName, MAX_PATH); - theErr = FSLocationFromFullPath(folderName, &theParentRef); - CFRelease(fileURL); - CFRelease(folderURL); - CFRelease(folderPathCFString); - } - if (theErr != noErr) - { - SetLastError(theErr); - if (ulCreation == OPEN_EXISTING || theErr != fnfErr) - return INVALID_HANDLE_VALUE; - } - - if (ulCreation != OPEN_EXISTING) - { /* We create the file */ - UniChar unicodeFileName[256]; - CFStringRef filePathCFString = CFStringCreateWithCString(NULL, sFileName, kCFStringEncodingUTF8); - CFURLRef fileURL = CFURLCreateWithFileSystemPath(NULL, filePathCFString, kCFURLPOSIXPathStyle, FALSE); - CFStringRef fileNameCFString = CFURLCopyLastPathComponent(fileURL); - CFStringGetCharacters(fileNameCFString, CFRangeMake(0, CFStringGetLength(fileNameCFString)), - unicodeFileName); - theErr = FSCreateCompat(&theParentRef, gCreator, gType, unicodeFileName, - CFStringGetLength(fileNameCFString), &theFileRef); - CFRelease(fileNameCFString); - CFRelease(filePathCFString); - CFRelease(fileURL); - if (theErr != noErr) - { - SetLastError(theErr); - return INVALID_HANDLE_VALUE; - } - } - - if (ulMode == GENERIC_READ) - permission = fsRdPerm; - else - { - if (ulMode == GENERIC_WRITE) - permission = fsWrPerm; - else - permission = fsRdWrPerm; - } - theErr = FSOpenDFCompat(&theFileRef, permission, &fileRef); - - SetLastError(theErr); - - if (theErr == noErr) - return (HANDLE)(int)fileRef; - else - return INVALID_HANDLE_VALUE; -} - -/******************************************************************** -* CloseHandle -********************************************************************/ -BOOL CloseHandle( HANDLE hFile ) /* handle to object */ -{ - OSErr theErr; - - if ((hFile == NULL) || (hFile == INVALID_HANDLE_VALUE)) - return FALSE; - - theErr = FSCloseFork((short)(int)hFile); - - SetLastError(theErr); - - return theErr != noErr; -} - -/******************************************************************** -* GetFileSize -********************************************************************/ -DWORD GetFileSize( HANDLE hFile, /* handle to file */ - DWORD *ulOffSetHigh ) /* high-order word of file size */ -{ - SInt64 fileLength; - OSErr theErr; - - if ((hFile == NULL) || (hFile == INVALID_HANDLE_VALUE)) - { - SetLastError(theErr); - return -1u; - } - - theErr = FSGetForkSize((short)(int)hFile, &fileLength); - if (theErr != noErr) - { - SetLastError(theErr); - return -1u; - } - - if (ulOffSetHigh != NULL) - *ulOffSetHigh = fileLength >> 32; - - SetLastError(theErr); - - return fileLength; -} - -/******************************************************************** -* SetFilePointer -* pOffSetHigh: NULL -* ulMethod: FILE_BEGIN, FILE_CURRENT -********************************************************************/ -DWORD SetFilePointer( HANDLE hFile, /* handle to file */ - LONG lOffSetLow, /* bytes to move pointer */ - LONG *pOffSetHigh, /* bytes to move pointer */ - DWORD ulMethod ) /* starting point */ -{ - OSErr theErr; - - if (ulMethod == FILE_CURRENT) - { - SInt64 bytesToMove; - - if (pOffSetHigh != NULL) - bytesToMove = ((SInt64)*pOffSetHigh << 32) + lOffSetLow; - else - bytesToMove = lOffSetLow; - - SInt64 newPos; - - theErr = FSSetForkPosition((short)(int)hFile, fsFromMark, bytesToMove); - if (theErr != noErr) - { - SetLastError(theErr); - return -1u; - } - - theErr = FSGetForkPosition((short)(int)hFile, &newPos); - if (theErr != noErr) - { - SetLastError(theErr); - return -1u; - } - - if (pOffSetHigh != NULL) - *pOffSetHigh = newPos >> 32; - - SetLastError(theErr); - return newPos; - } - else if (ulMethod == FILE_BEGIN) - { - SInt64 bytesToMove; - - if (pOffSetHigh != NULL) - bytesToMove = ((SInt64)*pOffSetHigh << 32) + lOffSetLow; - else - bytesToMove = lOffSetLow; - - theErr = FSSetForkPosition((short)(int)hFile, fsFromStart, bytesToMove); - if (theErr != noErr) - { - SetLastError(theErr); - return -1u; - } - - SetLastError(theErr); - return lOffSetLow; - } - else - { - SInt64 bytesToMove; - - if (pOffSetHigh != NULL) - bytesToMove = ((SInt64)*pOffSetHigh << 32) + lOffSetLow; - else - bytesToMove = lOffSetLow; - - SInt64 newPos; - - theErr = FSSetForkPosition((short)(int)hFile, fsFromLEOF, bytesToMove); - if (theErr != noErr) - { - SetLastError(theErr); - return -1u; - } - - theErr = FSGetForkPosition((short)(int)hFile, &newPos); - if (theErr != noErr) - { - SetLastError(theErr); - return -1u; - } - - if (pOffSetHigh != NULL) - *pOffSetHigh = newPos >> 32; - - SetLastError(theErr); - return newPos; - } -} - -/******************************************************************** -* SetEndOfFile -********************************************************************/ -BOOL SetEndOfFile( HANDLE hFile ) /* handle to file */ -{ - OSErr theErr; - - theErr = FSSetForkSize((short)(int)hFile, fsAtMark, 0); - - SetLastError(theErr); - - return theErr == noErr; -} - -/******************************************************************** -* ReadFile -* pOverLapped: NULL -********************************************************************/ -BOOL ReadFile( HANDLE hFile, /* handle to file */ - void *pBuffer, /* data buffer */ - DWORD ulLen, /* number of bytes to read */ - DWORD *ulRead, /* number of bytes read */ - void *pOverLapped ) /* overlapped buffer */ -{ -#pragma unused (pOverLapped) - - ByteCount nbCharsRead; - OSErr theErr; - - nbCharsRead = ulLen; - theErr = FSReadFork((short)(int)hFile, fsAtMark, 0, nbCharsRead, pBuffer, &nbCharsRead); - *ulRead = nbCharsRead; - - SetLastError(theErr); - - return theErr == noErr; -} - -/******************************************************************** -* WriteFile -* pOverLapped: NULL -********************************************************************/ -BOOL WriteFile( HANDLE hFile, /* handle to file */ - const void *pBuffer, /* data buffer */ - DWORD ulLen, /* number of bytes to write */ - DWORD *ulWritten, /* number of bytes written */ - void *pOverLapped ) /* overlapped buffer */ -{ -#pragma unused (pOverLapped) - - ByteCount nbCharsToWrite; - OSErr theErr; - - nbCharsToWrite = ulLen; - theErr = FSWriteFork((short)(int)hFile, fsAtMark, 0, nbCharsToWrite, pBuffer, &nbCharsToWrite); - *ulWritten = nbCharsToWrite; - - SetLastError(theErr); - - return theErr == noErr; -} - -// Check if a memory block is accessible for reading. It's probably too -// hard to check on Mac, so sorry, we'll just have to crash -BOOL IsBadReadPtr(const void * ptr, int size) -{ -#pragma unused (ptr, size) - - return FALSE; -} - -// Returns attributes of a file. Actually, it doesn't, it just checks if -// the file exists, since that's all StormLib uses it for -DWORD GetFileAttributes(const char * szFileName) -{ - FSRef theRef; - OSErr theErr; - - theErr = FSLocationFromFullPath(szFileName, &theRef); - - if (theErr != noErr) - return -1u; - else - return 0; -} - -#endif diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/CHANGES b/contrib/vmap_extractor_v2/stormlib/bzip2/CHANGES deleted file mode 100644 index e31b03a0118..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/CHANGES +++ /dev/null @@ -1,275 +0,0 @@ - - -0.9.0 -~~~~~ -First version. - - -0.9.0a -~~~~~~ -Removed 'ranlib' from Makefile, since most modern Unix-es -don't need it, or even know about it. - - -0.9.0b -~~~~~~ -Fixed a problem with error reporting in bzip2.c. This does not effect -the library in any way. Problem is: versions 0.9.0 and 0.9.0a (of the -program proper) compress and decompress correctly, but give misleading -error messages (internal panics) when an I/O error occurs, instead of -reporting the problem correctly. This shouldn't give any data loss -(as far as I can see), but is confusing. - -Made the inline declarations disappear for non-GCC compilers. - - -0.9.0c -~~~~~~ -Fixed some problems in the library pertaining to some boundary cases. -This makes the library behave more correctly in those situations. The -fixes apply only to features (calls and parameters) not used by -bzip2.c, so the non-fixedness of them in previous versions has no -effect on reliability of bzip2.c. - -In bzlib.c: - * made zero-length BZ_FLUSH work correctly in bzCompress(). - * fixed bzWrite/bzRead to ignore zero-length requests. - * fixed bzread to correctly handle read requests after EOF. - * wrong parameter order in call to bzDecompressInit in - bzBuffToBuffDecompress. Fixed. - -In compress.c: - * changed setting of nGroups in sendMTFValues() so as to - do a bit better on small files. This _does_ effect - bzip2.c. - - -0.9.5a -~~~~~~ -Major change: add a fallback sorting algorithm (blocksort.c) -to give reasonable behaviour even for very repetitive inputs. -Nuked --repetitive-best and --repetitive-fast since they are -no longer useful. - -Minor changes: mostly a whole bunch of small changes/ -bugfixes in the driver (bzip2.c). Changes pertaining to the -user interface are: - - allow decompression of symlink'd files to stdout - decompress/test files even without .bz2 extension - give more accurate error messages for I/O errors - when compressing/decompressing to stdout, don't catch control-C - read flags from BZIP2 and BZIP environment variables - decline to break hard links to a file unless forced with -f - allow -c flag even with no filenames - preserve file ownerships as far as possible - make -s -1 give the expected block size (100k) - add a flag -q --quiet to suppress nonessential warnings - stop decoding flags after --, so files beginning in - can be handled - resolved inconsistent naming: bzcat or bz2cat ? - bzip2 --help now returns 0 - -Programming-level changes are: - - fixed syntax error in GET_LL4 for Borland C++ 5.02 - let bzBuffToBuffDecompress return BZ_DATA_ERROR{_MAGIC} - fix overshoot of mode-string end in bzopen_or_bzdopen - wrapped bzlib.h in #ifdef __cplusplus ... extern "C" { ... } - close file handles under all error conditions - added minor mods so it compiles with DJGPP out of the box - fixed Makefile so it doesn't give problems with BSD make - fix uninitialised memory reads in dlltest.c - -0.9.5b -~~~~~~ -Open stdin/stdout in binary mode for DJGPP. - -0.9.5c -~~~~~~ -Changed BZ_N_OVERSHOOT to be ... + 2 instead of ... + 1. The + 1 -version could cause the sorted order to be wrong in some extremely -obscure cases. Also changed setting of quadrant in blocksort.c. - -0.9.5d -~~~~~~ -The only functional change is to make bzlibVersion() in the library -return the correct string. This has no effect whatsoever on the -functioning of the bzip2 program or library. Added a couple of casts -so the library compiles without warnings at level 3 in MS Visual -Studio 6.0. Included a Y2K statement in the file Y2K_INFO. All other -changes are minor documentation changes. - -1.0 -~~~ -Several minor bugfixes and enhancements: - -* Large file support. The library uses 64-bit counters to - count the volume of data passing through it. bzip2.c - is now compiled with -D_FILE_OFFSET_BITS=64 to get large - file support from the C library. -v correctly prints out - file sizes greater than 4 gigabytes. All these changes have - been made without assuming a 64-bit platform or a C compiler - which supports 64-bit ints, so, except for the C library - aspect, they are fully portable. - -* Decompression robustness. The library/program should be - robust to any corruption of compressed data, detecting and - handling _all_ corruption, instead of merely relying on - the CRCs. What this means is that the program should - never crash, given corrupted data, and the library should - always return BZ_DATA_ERROR. - -* Fixed an obscure race-condition bug only ever observed on - Solaris, in which, if you were very unlucky and issued - control-C at exactly the wrong time, both input and output - files would be deleted. - -* Don't run out of file handles on test/decompression when - large numbers of files have invalid magic numbers. - -* Avoid library namespace pollution. Prefix all exported - symbols with BZ2_. - -* Minor sorting enhancements from my DCC2000 paper. - -* Advance the version number to 1.0, so as to counteract the - (false-in-this-case) impression some people have that programs - with version numbers less than 1.0 are in some way, experimental, - pre-release versions. - -* Create an initial Makefile-libbz2_so to build a shared library. - Yes, I know I should really use libtool et al ... - -* Make the program exit with 2 instead of 0 when decompression - fails due to a bad magic number (ie, an invalid bzip2 header). - Also exit with 1 (as the manual claims :-) whenever a diagnostic - message would have been printed AND the corresponding operation - is aborted, for example - bzip2: Output file xx already exists. - When a diagnostic message is printed but the operation is not - aborted, for example - bzip2: Can't guess original name for wurble -- using wurble.out - then the exit value 0 is returned, unless some other problem is - also detected. - - I think it corresponds more closely to what the manual claims now. - - -1.0.1 -~~~~~ -* Modified dlltest.c so it uses the new BZ2_ naming scheme. -* Modified makefile-msc to fix minor build probs on Win2k. -* Updated README.COMPILATION.PROBLEMS. - -There are no functionality changes or bug fixes relative to version -1.0.0. This is just a documentation update + a fix for minor Win32 -build problems. For almost everyone, upgrading from 1.0.0 to 1.0.1 is -utterly pointless. Don't bother. - - -1.0.2 -~~~~~ -A bug fix release, addressing various minor issues which have appeared -in the 18 or so months since 1.0.1 was released. Most of the fixes -are to do with file-handling or documentation bugs. To the best of my -knowledge, there have been no data-loss-causing bugs reported in the -compression/decompression engine of 1.0.0 or 1.0.1. - -Note that this release does not improve the rather crude build system -for Unix platforms. The general plan here is to autoconfiscate/ -libtoolise 1.0.2 soon after release, and release the result as 1.1.0 -or perhaps 1.2.0. That, however, is still just a plan at this point. - -Here are the changes in 1.0.2. Bug-reporters and/or patch-senders in -parentheses. - -* Fix an infinite segfault loop in 1.0.1 when a directory is - encountered in -f (force) mode. - (Trond Eivind Glomsrod, Nicholas Nethercote, Volker Schmidt) - -* Avoid double fclose() of output file on certain I/O error paths. - (Solar Designer) - -* Don't fail with internal error 1007 when fed a long stream (> 48MB) - of byte 251. Also print useful message suggesting that 1007s may be - caused by bad memory. - (noticed by Juan Pedro Vallejo, fixed by me) - -* Fix uninitialised variable silly bug in demo prog dlltest.c. - (Jorj Bauer) - -* Remove 512-MB limitation on recovered file size for bzip2recover - on selected platforms which support 64-bit ints. At the moment - all GCC supported platforms, and Win32. - (me, Alson van der Meulen) - -* Hard-code header byte values, to give correct operation on platforms - using EBCDIC as their native character set (IBM's OS/390). - (Leland Lucius) - -* Copy file access times correctly. - (Marty Leisner) - -* Add distclean and check targets to Makefile. - (Michael Carmack) - -* Parameterise use of ar and ranlib in Makefile. Also add $(LDFLAGS). - (Rich Ireland, Bo Thorsen) - -* Pass -p (create parent dirs as needed) to mkdir during make install. - (Jeremy Fusco) - -* Dereference symlinks when copying file permissions in -f mode. - (Volker Schmidt) - -* Majorly simplify implementation of uInt64_qrm10. - (Bo Lindbergh) - -* Check the input file still exists before deleting the output one, - when aborting in cleanUpAndFail(). - (Joerg Prante, Robert Linden, Matthias Krings) - -Also a bunch of patches courtesy of Philippe Troin, the Debian maintainer -of bzip2: - -* Wrapper scripts (with manpages): bzdiff, bzgrep, bzmore. - -* Spelling changes and minor enhancements in bzip2.1. - -* Avoid race condition between creating the output file and setting its - interim permissions safely, by using fopen_output_safely(). - No changes to bzip2recover since there is no issue with file - permissions there. - -* do not print senseless report with -v when compressing an empty - file. - -* bzcat -f works on non-bzip2 files. - -* do not try to escape shell meta-characters on unix (the shell takes - care of these). - -* added --fast and --best aliases for -1 -9 for gzip compatibility. - - -1.0.3 (15 Feb 05) -~~~~~~~~~~~~~~~~~ -Fixes some minor bugs since the last version, 1.0.2. - -* Further robustification against corrupted compressed data. - There are currently no known bitstreams which can cause the - decompressor to crash, loop or access memory which does not - belong to it. If you are using bzip2 or the library to - decompress bitstreams from untrusted sources, an upgrade - to 1.0.3 is recommended. - -* The documentation has been converted to XML, from which html - and pdf can be derived. - -* Various minor bugs in the documentation have been fixed. - -* Fixes for various compilation warnings with newer versions of - gcc, and on 64-bit platforms. - -* The BZ_NO_STDIO cpp symbol was not properly observed in 1.0.2. - This has been fixed. diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/LICENSE b/contrib/vmap_extractor_v2/stormlib/bzip2/LICENSE deleted file mode 100644 index e60845b4dcc..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/LICENSE +++ /dev/null @@ -1,40 +0,0 @@ - -This program, "bzip2", the associated library "libbzip2", and all -documentation, are copyright (C) 1996-2005 Julian R Seward. All -rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - -2. 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. - -3. Altered source versions must be plainly marked as such, and must - not be misrepresented as being the original software. - -4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written - permission. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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. - -Julian Seward, Cambridge, UK. -jseward@acm.org -bzip2/libbzip2 version 1.0.3 of 15 February 2005 - diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/Makefile-libbz2_so b/contrib/vmap_extractor_v2/stormlib/bzip2/Makefile-libbz2_so deleted file mode 100644 index 458c5a135e7..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/Makefile-libbz2_so +++ /dev/null @@ -1,44 +0,0 @@ - -# This Makefile builds a shared version of the library, -# libbz2.so.1.0.3, with soname libbz2.so.1.0, -# at least on x86-Linux (RedHat 7.2), -# with gcc-2.96 20000731 (Red Hat Linux 7.1 2.96-98). -# Please see the README file for some -# important info about building the library like this. - -SHELL=/bin/sh -CC=gcc -BIGFILES=-D_FILE_OFFSET_BITS=64 -CFLAGS=-fpic -fPIC -Wall -Winline -O -g - -OBJS= blocksort.o \ - huffman.o \ - crctable.o \ - randtable.o \ - compress.o \ - decompress.o \ - bzlib.o - -all: $(OBJS) - $(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.3 $(OBJS) - $(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.3 - rm -f libbz2.so.1.0 - ln -s libbz2.so.1.0.3 libbz2.so.1.0 - -clean: - rm -f $(OBJS) bzip2.o libbz2.so.1.0.3 libbz2.so.1.0 bzip2-shared - -blocksort.o: blocksort.c - $(CC) $(CFLAGS) -c blocksort.c -huffman.o: huffman.c - $(CC) $(CFLAGS) -c huffman.c -crctable.o: crctable.c - $(CC) $(CFLAGS) -c crctable.c -randtable.o: randtable.c - $(CC) $(CFLAGS) -c randtable.c -compress.o: compress.c - $(CC) $(CFLAGS) -c compress.c -decompress.o: decompress.c - $(CC) $(CFLAGS) -c decompress.c -bzlib.o: bzlib.c - $(CC) $(CFLAGS) -c bzlib.c diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/README b/contrib/vmap_extractor_v2/stormlib/bzip2/README deleted file mode 100644 index 1aff4487e8c..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/README +++ /dev/null @@ -1,185 +0,0 @@ - -This is the README for bzip2, a block-sorting file compressor, version -1.0.3. This version is fully compatible with the previous public -releases, versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1 and 1.0.2. - -bzip2-1.0.3 is distributed under a BSD-style license. For details, -see the file LICENSE. - -Complete documentation is available in Postscript form (manual.ps), -PDF (manual.pdf) or html (manual.html). A plain-text version of the -manual page is available as bzip2.txt. A statement about Y2K issues -is now included in the file Y2K_INFO. - - -HOW TO BUILD -- UNIX - -Type `make'. This builds the library libbz2.a and then the -programs bzip2 and bzip2recover. Six self-tests are run. -If the self-tests complete ok, carry on to installation: - -To install in /usr/bin, /usr/lib, /usr/man and /usr/include, type - make install -To install somewhere else, eg, /xxx/yyy/{bin,lib,man,include}, type - make install PREFIX=/xxx/yyy -If you are (justifiably) paranoid and want to see what 'make install' -is going to do, you can first do - make -n install or - make -n install PREFIX=/xxx/yyy respectively. -The -n instructs make to show the commands it would execute, but -not actually execute them. - - -HOW TO BUILD -- UNIX, shared library libbz2.so. - -Do 'make -f Makefile-libbz2_so'. This Makefile seems to work for -Linux-ELF (RedHat 7.2 on an x86 box), with gcc. I make no claims -that it works for any other platform, though I suspect it probably -will work for most platforms employing both ELF and gcc. - -bzip2-shared, a client of the shared library, is also built, but not -self-tested. So I suggest you also build using the normal Makefile, -since that conducts a self-test. A second reason to prefer the -version statically linked to the library is that, on x86 platforms, -building shared objects makes a valuable register (%ebx) unavailable -to gcc, resulting in a slowdown of 10%-20%, at least for bzip2. - -Important note for people upgrading .so's from 0.9.0/0.9.5 to version -1.0.X. All the functions in the library have been renamed, from (eg) -bzCompress to BZ2_bzCompress, to avoid namespace pollution. -Unfortunately this means that the libbz2.so created by -Makefile-libbz2_so will not work with any program which used an older -version of the library. Sorry. I do encourage library clients to -make the effort to upgrade to use version 1.0, since it is both faster -and more robust than previous versions. - - -HOW TO BUILD -- Windows 95, NT, DOS, Mac, etc. - -It's difficult for me to support compilation on all these platforms. -My approach is to collect binaries for these platforms, and put them -on the master web page (http://sources.redhat.com/bzip2). Look there. -However (FWIW), bzip2-1.0.X is very standard ANSI C and should compile -unmodified with MS Visual C. If you have difficulties building, you -might want to read README.COMPILATION.PROBLEMS. - -At least using MS Visual C++ 6, you can build from the unmodified -sources by issuing, in a command shell: - nmake -f makefile.msc -(you may need to first run the MSVC-provided script VCVARS32.BAT - so as to set up paths to the MSVC tools correctly). - - -VALIDATION - -Correct operation, in the sense that a compressed file can always be -decompressed to reproduce the original, is obviously of paramount -importance. To validate bzip2, I used a modified version of Mark -Nelson's churn program. Churn is an automated test driver which -recursively traverses a directory structure, using bzip2 to compress -and then decompress each file it encounters, and checking that the -decompressed data is the same as the original. - - - -Please read and be aware of the following: - -WARNING: - - This program (attempts to) compress data by performing several - non-trivial transformations on it. Unless you are 100% familiar - with *all* the algorithms contained herein, and with the - consequences of modifying them, you should NOT meddle with the - compression or decompression machinery. Incorrect changes can and - very likely *will* lead to disastrous loss of data. - - -DISCLAIMER: - - I TAKE NO RESPONSIBILITY FOR ANY LOSS OF DATA ARISING FROM THE - USE OF THIS PROGRAM, HOWSOEVER CAUSED. - - Every compression of a file implies an assumption that the - compressed file can be decompressed to reproduce the original. - Great efforts in design, coding and testing have been made to - ensure that this program works correctly. However, the complexity - of the algorithms, and, in particular, the presence of various - special cases in the code which occur with very low but non-zero - probability make it impossible to rule out the possibility of bugs - remaining in the program. DO NOT COMPRESS ANY DATA WITH THIS - PROGRAM UNLESS YOU ARE PREPARED TO ACCEPT THE POSSIBILITY, HOWEVER - SMALL, THAT THE DATA WILL NOT BE RECOVERABLE. - - That is not to say this program is inherently unreliable. Indeed, - I very much hope the opposite is true. bzip2 has been carefully - constructed and extensively tested. - - -PATENTS: - - To the best of my knowledge, bzip2 does not use any patented - algorithms. However, I do not have the resources to carry out - a patent search. Therefore I cannot give any guarantee of the - above statement. - -End of legalities. - - -WHAT'S NEW IN 0.9.0 (as compared to 0.1pl2) ? - - * Approx 10% faster compression, 30% faster decompression - * -t (test mode) is a lot quicker - * Can decompress concatenated compressed files - * Programming interface, so programs can directly read/write .bz2 files - * Less restrictive (BSD-style) licensing - * Flag handling more compatible with GNU gzip - * Much more documentation, i.e., a proper user manual - * Hopefully, improved portability (at least of the library) - -WHAT'S NEW IN 0.9.5 ? - - * Compression speed is much less sensitive to the input - data than in previous versions. Specifically, the very - slow performance caused by repetitive data is fixed. - * Many small improvements in file and flag handling. - * A Y2K statement. - -WHAT'S NEW IN 1.0.0 ? - - See the CHANGES file. - -WHAT'S NEW IN 1.0.2 ? - - See the CHANGES file. - -WHAT'S NEW IN 1.0.3 ? - - See the CHANGES file. - - -I hope you find bzip2 useful. Feel free to contact me at - jseward@bzip.org -if you have any suggestions or queries. Many people mailed me with -comments, suggestions and patches after the releases of bzip-0.15, -bzip-0.21, and bzip2 versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1 and -1.0.2, and the changes in bzip2 are largely a result of this feedback. -I thank you for your comments. - -At least for the time being, bzip2's "home" is (or can be reached via) -http://www.bzip.org - -Julian Seward -jseward@bzip.org - -Cambridge, UK. - -18 July 1996 (version 0.15) -25 August 1996 (version 0.21) - 7 August 1997 (bzip2, version 0.1) -29 August 1997 (bzip2, version 0.1pl2) -23 August 1998 (bzip2, version 0.9.0) - 8 June 1999 (bzip2, version 0.9.5) - 4 Sept 1999 (bzip2, version 0.9.5d) - 5 May 2000 (bzip2, version 1.0pre8) -30 December 2001 (bzip2, version 1.0.2pre1) -15 February 2005 (bzip2, version 1.0.3) diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/README.COMPILATION.PROBLEMS b/contrib/vmap_extractor_v2/stormlib/bzip2/README.COMPILATION.PROBLEMS deleted file mode 100644 index f1bc396b765..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/README.COMPILATION.PROBLEMS +++ /dev/null @@ -1,39 +0,0 @@ - -bzip2-1.0.3 should compile without problems on the vast majority of -platforms. Using the supplied Makefile, I've built and tested it -myself for x86-linux and x86_64-linux. With makefile.msc, Visual C++ -6.0 and nmake, you can build a native Win32 version too. Large file -support seems to work correctly on at least alpha-tru64unix and -x86-cygwin32 (on Windows 2000). - -When I say "large file" I mean a file of size 2,147,483,648 (2^31) -bytes or above. Many older OSs can't handle files above this size, -but many newer ones can. Large files are pretty huge -- most files -you'll encounter are not Large Files. - -Earlier versions of bzip2 (0.1, 0.9.0, 0.9.5) compiled on a wide -variety of platforms without difficulty, and I hope this version will -continue in that tradition. However, in order to support large files, -I've had to include the define -D_FILE_OFFSET_BITS=64 in the Makefile. -This can cause problems. - -The technique of adding -D_FILE_OFFSET_BITS=64 to get large file -support is, as far as I know, the Recommended Way to get correct large -file support. For more details, see the Large File Support -Specification, published by the Large File Summit, at - http://ftp.sas.com/standards/large.file - -As a general comment, if you get compilation errors which you think -are related to large file support, try removing the above define from -the Makefile, ie, delete the line - BIGFILES=-D_FILE_OFFSET_BITS=64 -from the Makefile, and do 'make clean ; make'. This will give you a -version of bzip2 without large file support, which, for most -applications, is probably not a problem. - -Alternatively, try some of the platform-specific hints listed below. - -You can use the spewG.c program to generate huge files to test bzip2's -large file support, if you are feeling paranoid. Be aware though that -any compilation problems which affect bzip2 will also affect spewG.c, -alas. diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/README.XML.STUFF b/contrib/vmap_extractor_v2/stormlib/bzip2/README.XML.STUFF deleted file mode 100644 index 0ff209f4466..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/README.XML.STUFF +++ /dev/null @@ -1,31 +0,0 @@ -The script xmlproc.sh takes an xml file as input, -and processes it to create .pdf, .html or .ps output. -It uses format.pl, a perl script to format
 blocks nicely,
- and add CDATA tags so writers do not have to use eg. < 
-
-The file "entities.xml" must be edited to reflect current
-version, year, etc.
-
-
-Usage:
-
-  xmlproc.sh -v manual.xml
-  Validates an xml file to ensure no dtd-compliance errors
-
-  xmlproc.sh -html manual.xml
-  Output: manual.html
-
-  xmlproc.sh -pdf manual.xml
-  Output: manual.pdf
-
-  xmlproc.sh -ps manual.xml
-  Output: manual.ps
-
-
-Notum bene: 
-- pdfxmltex barfs if given a filename with an underscore in it
-
-- xmltex won't work yet - there's a bug in passivetex
-    which we are all waiting for Sebastian to fix.
-  So we are going the xml -> pdf -> ps route for the time being,
-    using pdfxmltex.
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/Y2K_INFO b/contrib/vmap_extractor_v2/stormlib/bzip2/Y2K_INFO
deleted file mode 100644
index 55fd56a2edb..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/Y2K_INFO
+++ /dev/null
@@ -1,34 +0,0 @@
-
-Y2K status of bzip2 and libbzip2, versions 0.1, 0.9.0 and 0.9.5
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Informally speaking:
-   bzip2 is a compression program built on top of libbzip2, 
-   a library which does the real work of compression and 
-   decompression.  As far as I am aware, libbzip2 does not have 
-   any date-related code at all.
-
-   bzip2 itself copies dates from source to destination files 
-   when compressing or decompressing, using the 'stat' and 'utime' 
-   UNIX system calls.  It doesn't examine, manipulate or store the 
-   dates in any way.  So as far as I can see, there shouldn't be any 
-   problem with bzip2 providing 'stat' and 'utime' work correctly 
-   on your system.
-
-   On non-unix platforms (those for which BZ_UNIX in bzip2.c is
-   not set to 1), bzip2 doesn't even do the date copying.
-
-   Overall, informally speaking, I don't think bzip2 or libbzip2 
-   have a Y2K problem.
-
-Formally speaking:
-   I am not prepared to offer you any assurance whatsoever 
-   regarding Y2K issues in my software.  You alone assume the 
-   entire risk of using the software.  The disclaimer of liability 
-   in the LICENSE file in the bzip2 source distribution continues 
-   to apply on this issue as with every other issue pertaining 
-   to the software.
-
-Julian Seward
-Cambridge, UK
-25 August 1999
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/blocksort.c b/contrib/vmap_extractor_v2/stormlib/bzip2/blocksort.c
deleted file mode 100644
index 906124b97e6..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/blocksort.c
+++ /dev/null
@@ -1,1141 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Block sorting machinery                               ---*/
-/*---                                           blocksort.c ---*/
-/*-------------------------------------------------------------*/
-
-/*--
-  This file is a part of bzip2 and/or libbzip2, a program and
-  library for lossless, block-sorting data compression.
-
-  Copyright (C) 1996-2005 Julian R Seward.  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-  2. 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.
-
-  3. Altered source versions must be plainly marked as such, and must
-     not be misrepresented as being the original software.
-
-  4. The name of the author may not be used to endorse or promote
-     products derived from this software without specific prior written
-     permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
-
-  Julian Seward, Cambridge, UK.
-  jseward@bzip.org
-  bzip2/libbzip2 version 1.0 of 21 March 2000
-
-  This program is based on (at least) the work of:
-     Mike Burrows
-     David Wheeler
-     Peter Fenwick
-     Alistair Moffat
-     Radford Neal
-     Ian H. Witten
-     Robert Sedgewick
-     Jon L. Bentley
-
-  For more information on these sources, see the manual.
-
-  To get some idea how the block sorting algorithms in this file
-  work, read my paper
-     On the Performance of BWT Sorting Algorithms
-  in Proceedings of the IEEE Data Compression Conference 2000,
-  Snowbird, Utah, USA, 27-30 March 2000.  The main sort in this
-  file implements the algorithm called  cache  in the paper.
---*/
-
-
-#include "bzlib_private.h"
-
-/*---------------------------------------------*/
-/*--- Fallback O(N log(N)^2) sorting        ---*/
-/*--- algorithm, for repetitive blocks      ---*/
-/*---------------------------------------------*/
-
-/*---------------------------------------------*/
-static 
-__inline__
-void fallbackSimpleSort ( UInt32* fmap, 
-                          UInt32* eclass, 
-                          Int32   lo, 
-                          Int32   hi )
-{
-   Int32 i, j, tmp;
-   UInt32 ec_tmp;
-
-   if (lo == hi) return;
-
-   if (hi - lo > 3) {
-      for ( i = hi-4; i >= lo; i-- ) {
-         tmp = fmap[i];
-         ec_tmp = eclass[tmp];
-         for ( j = i+4; j <= hi && ec_tmp > eclass[fmap[j]]; j += 4 )
-            fmap[j-4] = fmap[j];
-         fmap[j-4] = tmp;
-      }
-   }
-
-   for ( i = hi-1; i >= lo; i-- ) {
-      tmp = fmap[i];
-      ec_tmp = eclass[tmp];
-      for ( j = i+1; j <= hi && ec_tmp > eclass[fmap[j]]; j++ )
-         fmap[j-1] = fmap[j];
-      fmap[j-1] = tmp;
-   }
-}
-
-
-/*---------------------------------------------*/
-#define fswap(zz1, zz2) \
-   { Int32 zztmp = zz1; zz1 = zz2; zz2 = zztmp; }
-
-#define fvswap(zzp1, zzp2, zzn)       \
-{                                     \
-   Int32 yyp1 = (zzp1);               \
-   Int32 yyp2 = (zzp2);               \
-   Int32 yyn  = (zzn);                \
-   while (yyn > 0) {                  \
-      fswap(fmap[yyp1], fmap[yyp2]);  \
-      yyp1++; yyp2++; yyn--;          \
-   }                                  \
-}
-
-
-#define fmin(a,b) ((a) < (b)) ? (a) : (b)
-
-#define fpush(lz,hz) { stackLo[sp] = lz; \
-                       stackHi[sp] = hz; \
-                       sp++; }
-
-#define fpop(lz,hz) { sp--;              \
-                      lz = stackLo[sp];  \
-                      hz = stackHi[sp]; }
-
-#define FALLBACK_QSORT_SMALL_THRESH 10
-#define FALLBACK_QSORT_STACK_SIZE   100
-
-
-static
-void fallbackQSort3 ( UInt32* fmap, 
-                      UInt32* eclass,
-                      Int32   loSt, 
-                      Int32   hiSt )
-{
-   Int32 unLo, unHi, ltLo, gtHi, n, m;
-   Int32 sp, lo, hi;
-   UInt32 med, r, r3;
-   Int32 stackLo[FALLBACK_QSORT_STACK_SIZE];
-   Int32 stackHi[FALLBACK_QSORT_STACK_SIZE];
-
-   r = 0;
-
-   sp = 0;
-   fpush ( loSt, hiSt );
-
-   while (sp > 0) {
-
-      AssertH ( sp < FALLBACK_QSORT_STACK_SIZE, 1004 );
-
-      fpop ( lo, hi );
-      if (hi - lo < FALLBACK_QSORT_SMALL_THRESH) {
-         fallbackSimpleSort ( fmap, eclass, lo, hi );
-         continue;
-      }
-
-      /* Random partitioning.  Median of 3 sometimes fails to
-         avoid bad cases.  Median of 9 seems to help but 
-         looks rather expensive.  This too seems to work but
-         is cheaper.  Guidance for the magic constants 
-         7621 and 32768 is taken from Sedgewick's algorithms
-         book, chapter 35.
-      */
-      r = ((r * 7621) + 1) % 32768;
-      r3 = r % 3;
-      if (r3 == 0) med = eclass[fmap[lo]]; else
-      if (r3 == 1) med = eclass[fmap[(lo+hi)>>1]]; else
-                   med = eclass[fmap[hi]];
-
-      unLo = ltLo = lo;
-      unHi = gtHi = hi;
-
-      while (1) {
-         while (1) {
-            if (unLo > unHi) break;
-            n = (Int32)eclass[fmap[unLo]] - (Int32)med;
-            if (n == 0) { 
-               fswap(fmap[unLo], fmap[ltLo]); 
-               ltLo++; unLo++; 
-               continue; 
-            };
-            if (n > 0) break;
-            unLo++;
-         }
-         while (1) {
-            if (unLo > unHi) break;
-            n = (Int32)eclass[fmap[unHi]] - (Int32)med;
-            if (n == 0) { 
-               fswap(fmap[unHi], fmap[gtHi]); 
-               gtHi--; unHi--; 
-               continue; 
-            };
-            if (n < 0) break;
-            unHi--;
-         }
-         if (unLo > unHi) break;
-         fswap(fmap[unLo], fmap[unHi]); unLo++; unHi--;
-      }
-
-      AssertD ( unHi == unLo-1, "fallbackQSort3(2)" );
-
-      if (gtHi < ltLo) continue;
-
-      n = fmin(ltLo-lo, unLo-ltLo); fvswap(lo, unLo-n, n);
-      m = fmin(hi-gtHi, gtHi-unHi); fvswap(unLo, hi-m+1, m);
-
-      n = lo + unLo - ltLo - 1;
-      m = hi - (gtHi - unHi) + 1;
-
-      if (n - lo > hi - m) {
-         fpush ( lo, n );
-         fpush ( m, hi );
-      } else {
-         fpush ( m, hi );
-         fpush ( lo, n );
-      }
-   }
-}
-
-#undef fmin
-#undef fpush
-#undef fpop
-#undef fswap
-#undef fvswap
-#undef FALLBACK_QSORT_SMALL_THRESH
-#undef FALLBACK_QSORT_STACK_SIZE
-
-
-/*---------------------------------------------*/
-/* Pre:
-      nblock > 0
-      eclass exists for [0 .. nblock-1]
-      ((UChar*)eclass) [0 .. nblock-1] holds block
-      ptr exists for [0 .. nblock-1]
-
-   Post:
-      ((UChar*)eclass) [0 .. nblock-1] holds block
-      All other areas of eclass destroyed
-      fmap [0 .. nblock-1] holds sorted order
-      bhtab [ 0 .. 2+(nblock/32) ] destroyed
-*/
-
-#define       SET_BH(zz)  bhtab[(zz) >> 5] |= (1 << ((zz) & 31))
-#define     CLEAR_BH(zz)  bhtab[(zz) >> 5] &= ~(1 << ((zz) & 31))
-#define     ISSET_BH(zz)  (bhtab[(zz) >> 5] & (1 << ((zz) & 31)))
-#define      WORD_BH(zz)  bhtab[(zz) >> 5]
-#define UNALIGNED_BH(zz)  ((zz) & 0x01f)
-
-static
-void fallbackSort ( UInt32* fmap, 
-                    UInt32* eclass, 
-                    UInt32* bhtab,
-                    Int32   nblock,
-                    Int32   verb )
-{
-   Int32 ftab[257];
-   Int32 ftabCopy[256];
-   Int32 H, i, j, k, l, r, cc, cc1;
-   Int32 nNotDone;
-   Int32 nBhtab;
-   UChar* eclass8 = (UChar*)eclass;
-
-   /*--
-      Initial 1-char radix sort to generate
-      initial fmap and initial BH bits.
-   --*/
-   if (verb >= 4)
-      VPrintf0 ( "        bucket sorting ...\n" );
-   for (i = 0; i < 257;    i++) ftab[i] = 0;
-   for (i = 0; i < nblock; i++) ftab[eclass8[i]]++;
-   for (i = 0; i < 256;    i++) ftabCopy[i] = ftab[i];
-   for (i = 1; i < 257;    i++) ftab[i] += ftab[i-1];
-
-   for (i = 0; i < nblock; i++) {
-      j = eclass8[i];
-      k = ftab[j] - 1;
-      ftab[j] = k;
-      fmap[k] = i;
-   }
-
-   nBhtab = 2 + (nblock / 32);
-   for (i = 0; i < nBhtab; i++) bhtab[i] = 0;
-   for (i = 0; i < 256; i++) SET_BH(ftab[i]);
-
-   /*--
-      Inductively refine the buckets.  Kind-of an
-      "exponential radix sort" (!), inspired by the
-      Manber-Myers suffix array construction algorithm.
-   --*/
-
-   /*-- set sentinel bits for block-end detection --*/
-   for (i = 0; i < 32; i++) { 
-      SET_BH(nblock + 2*i);
-      CLEAR_BH(nblock + 2*i + 1);
-   }
-
-   /*-- the log(N) loop --*/
-   H = 1;
-   while (1) {
-
-      if (verb >= 4) 
-         VPrintf1 ( "        depth %6d has ", H );
-
-      j = 0;
-      for (i = 0; i < nblock; i++) {
-         if (ISSET_BH(i)) j = i;
-         k = fmap[i] - H; if (k < 0) k += nblock;
-         eclass[k] = j;
-      }
-
-      nNotDone = 0;
-      r = -1;
-      while (1) {
-
-         /*-- find the next non-singleton bucket --*/
-         k = r + 1;
-         while (ISSET_BH(k) && UNALIGNED_BH(k)) k++;
-         if (ISSET_BH(k)) {
-            while (WORD_BH(k) == 0xffffffff) k += 32;
-            while (ISSET_BH(k)) k++;
-         }
-         l = k - 1;
-         if (l >= nblock) break;
-         while (!ISSET_BH(k) && UNALIGNED_BH(k)) k++;
-         if (!ISSET_BH(k)) {
-            while (WORD_BH(k) == 0x00000000) k += 32;
-            while (!ISSET_BH(k)) k++;
-         }
-         r = k - 1;
-         if (r >= nblock) break;
-
-         /*-- now [l, r] bracket current bucket --*/
-         if (r > l) {
-            nNotDone += (r - l + 1);
-            fallbackQSort3 ( fmap, eclass, l, r );
-
-            /*-- scan bucket and generate header bits-- */
-            cc = -1;
-            for (i = l; i <= r; i++) {
-               cc1 = eclass[fmap[i]];
-               if (cc != cc1) { SET_BH(i); cc = cc1; };
-            }
-         }
-      }
-
-      if (verb >= 4) 
-         VPrintf1 ( "%6d unresolved strings\n", nNotDone );
-
-      H *= 2;
-      if (H > nblock || nNotDone == 0) break;
-   }
-
-   /*-- 
-      Reconstruct the original block in
-      eclass8 [0 .. nblock-1], since the
-      previous phase destroyed it.
-   --*/
-   if (verb >= 4)
-      VPrintf0 ( "        reconstructing block ...\n" );
-   j = 0;
-   for (i = 0; i < nblock; i++) {
-      while (ftabCopy[j] == 0) j++;
-      ftabCopy[j]--;
-      eclass8[fmap[i]] = (UChar)j;
-   }
-   AssertH ( j < 256, 1005 );
-}
-
-#undef       SET_BH
-#undef     CLEAR_BH
-#undef     ISSET_BH
-#undef      WORD_BH
-#undef UNALIGNED_BH
-
-
-/*---------------------------------------------*/
-/*--- The main, O(N^2 log(N)) sorting       ---*/
-/*--- algorithm.  Faster for "normal"       ---*/
-/*--- non-repetitive blocks.                ---*/
-/*---------------------------------------------*/
-
-/*---------------------------------------------*/
-static
-__inline__
-Bool mainGtU ( UInt32  i1, 
-               UInt32  i2,
-               UChar*  block, 
-               UInt16* quadrant,
-               UInt32  nblock,
-               Int32*  budget )
-{
-   Int32  k;
-   UChar  c1, c2;
-   UInt16 s1, s2;
-
-   AssertD ( i1 != i2, "mainGtU" );
-   /* 1 */
-   c1 = block[i1]; c2 = block[i2];
-   if (c1 != c2) return (c1 > c2);
-   i1++; i2++;
-   /* 2 */
-   c1 = block[i1]; c2 = block[i2];
-   if (c1 != c2) return (c1 > c2);
-   i1++; i2++;
-   /* 3 */
-   c1 = block[i1]; c2 = block[i2];
-   if (c1 != c2) return (c1 > c2);
-   i1++; i2++;
-   /* 4 */
-   c1 = block[i1]; c2 = block[i2];
-   if (c1 != c2) return (c1 > c2);
-   i1++; i2++;
-   /* 5 */
-   c1 = block[i1]; c2 = block[i2];
-   if (c1 != c2) return (c1 > c2);
-   i1++; i2++;
-   /* 6 */
-   c1 = block[i1]; c2 = block[i2];
-   if (c1 != c2) return (c1 > c2);
-   i1++; i2++;
-   /* 7 */
-   c1 = block[i1]; c2 = block[i2];
-   if (c1 != c2) return (c1 > c2);
-   i1++; i2++;
-   /* 8 */
-   c1 = block[i1]; c2 = block[i2];
-   if (c1 != c2) return (c1 > c2);
-   i1++; i2++;
-   /* 9 */
-   c1 = block[i1]; c2 = block[i2];
-   if (c1 != c2) return (c1 > c2);
-   i1++; i2++;
-   /* 10 */
-   c1 = block[i1]; c2 = block[i2];
-   if (c1 != c2) return (c1 > c2);
-   i1++; i2++;
-   /* 11 */
-   c1 = block[i1]; c2 = block[i2];
-   if (c1 != c2) return (c1 > c2);
-   i1++; i2++;
-   /* 12 */
-   c1 = block[i1]; c2 = block[i2];
-   if (c1 != c2) return (c1 > c2);
-   i1++; i2++;
-
-   k = nblock + 8;
-
-   do {
-      /* 1 */
-      c1 = block[i1]; c2 = block[i2];
-      if (c1 != c2) return (c1 > c2);
-      s1 = quadrant[i1]; s2 = quadrant[i2];
-      if (s1 != s2) return (s1 > s2);
-      i1++; i2++;
-      /* 2 */
-      c1 = block[i1]; c2 = block[i2];
-      if (c1 != c2) return (c1 > c2);
-      s1 = quadrant[i1]; s2 = quadrant[i2];
-      if (s1 != s2) return (s1 > s2);
-      i1++; i2++;
-      /* 3 */
-      c1 = block[i1]; c2 = block[i2];
-      if (c1 != c2) return (c1 > c2);
-      s1 = quadrant[i1]; s2 = quadrant[i2];
-      if (s1 != s2) return (s1 > s2);
-      i1++; i2++;
-      /* 4 */
-      c1 = block[i1]; c2 = block[i2];
-      if (c1 != c2) return (c1 > c2);
-      s1 = quadrant[i1]; s2 = quadrant[i2];
-      if (s1 != s2) return (s1 > s2);
-      i1++; i2++;
-      /* 5 */
-      c1 = block[i1]; c2 = block[i2];
-      if (c1 != c2) return (c1 > c2);
-      s1 = quadrant[i1]; s2 = quadrant[i2];
-      if (s1 != s2) return (s1 > s2);
-      i1++; i2++;
-      /* 6 */
-      c1 = block[i1]; c2 = block[i2];
-      if (c1 != c2) return (c1 > c2);
-      s1 = quadrant[i1]; s2 = quadrant[i2];
-      if (s1 != s2) return (s1 > s2);
-      i1++; i2++;
-      /* 7 */
-      c1 = block[i1]; c2 = block[i2];
-      if (c1 != c2) return (c1 > c2);
-      s1 = quadrant[i1]; s2 = quadrant[i2];
-      if (s1 != s2) return (s1 > s2);
-      i1++; i2++;
-      /* 8 */
-      c1 = block[i1]; c2 = block[i2];
-      if (c1 != c2) return (c1 > c2);
-      s1 = quadrant[i1]; s2 = quadrant[i2];
-      if (s1 != s2) return (s1 > s2);
-      i1++; i2++;
-
-      if (i1 >= nblock) i1 -= nblock;
-      if (i2 >= nblock) i2 -= nblock;
-
-      k -= 8;
-      (*budget)--;
-   }
-      while (k >= 0);
-
-   return False;
-}
-
-
-/*---------------------------------------------*/
-/*--
-   Knuth's increments seem to work better
-   than Incerpi-Sedgewick here.  Possibly
-   because the number of elems to sort is
-   usually small, typically <= 20.
---*/
-static
-Int32 incs[14] = { 1, 4, 13, 40, 121, 364, 1093, 3280,
-                   9841, 29524, 88573, 265720,
-                   797161, 2391484 };
-
-static
-void mainSimpleSort ( UInt32* ptr,
-                      UChar*  block,
-                      UInt16* quadrant,
-                      Int32   nblock,
-                      Int32   lo, 
-                      Int32   hi, 
-                      Int32   d,
-                      Int32*  budget )
-{
-   Int32 i, j, h, bigN, hp;
-   UInt32 v;
-
-   bigN = hi - lo + 1;
-   if (bigN < 2) return;
-
-   hp = 0;
-   while (incs[hp] < bigN) hp++;
-   hp--;
-
-   for (; hp >= 0; hp--) {
-      h = incs[hp];
-
-      i = lo + h;
-      while (True) {
-
-         /*-- copy 1 --*/
-         if (i > hi) break;
-         v = ptr[i];
-         j = i;
-         while ( mainGtU ( 
-                    ptr[j-h]+d, v+d, block, quadrant, nblock, budget 
-                 ) ) {
-            ptr[j] = ptr[j-h];
-            j = j - h;
-            if (j <= (lo + h - 1)) break;
-         }
-         ptr[j] = v;
-         i++;
-
-         /*-- copy 2 --*/
-         if (i > hi) break;
-         v = ptr[i];
-         j = i;
-         while ( mainGtU ( 
-                    ptr[j-h]+d, v+d, block, quadrant, nblock, budget 
-                 ) ) {
-            ptr[j] = ptr[j-h];
-            j = j - h;
-            if (j <= (lo + h - 1)) break;
-         }
-         ptr[j] = v;
-         i++;
-
-         /*-- copy 3 --*/
-         if (i > hi) break;
-         v = ptr[i];
-         j = i;
-         while ( mainGtU ( 
-                    ptr[j-h]+d, v+d, block, quadrant, nblock, budget 
-                 ) ) {
-            ptr[j] = ptr[j-h];
-            j = j - h;
-            if (j <= (lo + h - 1)) break;
-         }
-         ptr[j] = v;
-         i++;
-
-         if (*budget < 0) return;
-      }
-   }
-}
-
-
-/*---------------------------------------------*/
-/*--
-   The following is an implementation of
-   an elegant 3-way quicksort for strings,
-   described in a paper "Fast Algorithms for
-   Sorting and Searching Strings", by Robert
-   Sedgewick and Jon L. Bentley.
---*/
-
-#define mswap(zz1, zz2) \
-   { Int32 zztmp = zz1; zz1 = zz2; zz2 = zztmp; }
-
-#define mvswap(zzp1, zzp2, zzn)       \
-{                                     \
-   Int32 yyp1 = (zzp1);               \
-   Int32 yyp2 = (zzp2);               \
-   Int32 yyn  = (zzn);                \
-   while (yyn > 0) {                  \
-      mswap(ptr[yyp1], ptr[yyp2]);    \
-      yyp1++; yyp2++; yyn--;          \
-   }                                  \
-}
-
-static 
-__inline__
-UChar mmed3 ( UChar a, UChar b, UChar c )
-{
-   UChar t;
-   if (a > b) { t = a; a = b; b = t; };
-   if (b > c) { 
-      b = c;
-      if (a > b) b = a;
-   }
-   return b;
-}
-
-#define mmin(a,b) ((a) < (b)) ? (a) : (b)
-
-#define mpush(lz,hz,dz) { stackLo[sp] = lz; \
-                          stackHi[sp] = hz; \
-                          stackD [sp] = dz; \
-                          sp++; }
-
-#define mpop(lz,hz,dz) { sp--;             \
-                         lz = stackLo[sp]; \
-                         hz = stackHi[sp]; \
-                         dz = stackD [sp]; }
-
-
-#define mnextsize(az) (nextHi[az]-nextLo[az])
-
-#define mnextswap(az,bz)                                        \
-   { Int32 tz;                                                  \
-     tz = nextLo[az]; nextLo[az] = nextLo[bz]; nextLo[bz] = tz; \
-     tz = nextHi[az]; nextHi[az] = nextHi[bz]; nextHi[bz] = tz; \
-     tz = nextD [az]; nextD [az] = nextD [bz]; nextD [bz] = tz; }
-
-
-#define MAIN_QSORT_SMALL_THRESH 20
-#define MAIN_QSORT_DEPTH_THRESH (BZ_N_RADIX + BZ_N_QSORT)
-#define MAIN_QSORT_STACK_SIZE 100
-
-static
-void mainQSort3 ( UInt32* ptr,
-                  UChar*  block,
-                  UInt16* quadrant,
-                  Int32   nblock,
-                  Int32   loSt, 
-                  Int32   hiSt, 
-                  Int32   dSt,
-                  Int32*  budget )
-{
-   Int32 unLo, unHi, ltLo, gtHi, n, m, med;
-   Int32 sp, lo, hi, d;
-
-   Int32 stackLo[MAIN_QSORT_STACK_SIZE];
-   Int32 stackHi[MAIN_QSORT_STACK_SIZE];
-   Int32 stackD [MAIN_QSORT_STACK_SIZE];
-
-   Int32 nextLo[3];
-   Int32 nextHi[3];
-   Int32 nextD [3];
-
-   sp = 0;
-   mpush ( loSt, hiSt, dSt );
-
-   while (sp > 0) {
-
-      AssertH ( sp < MAIN_QSORT_STACK_SIZE, 1001 );
-
-      mpop ( lo, hi, d );
-      if (hi - lo < MAIN_QSORT_SMALL_THRESH || 
-          d > MAIN_QSORT_DEPTH_THRESH) {
-         mainSimpleSort ( ptr, block, quadrant, nblock, lo, hi, d, budget );
-         if (*budget < 0) return;
-         continue;
-      }
-
-      med = (Int32) 
-            mmed3 ( block[ptr[ lo         ]+d],
-                    block[ptr[ hi         ]+d],
-                    block[ptr[ (lo+hi)>>1 ]+d] );
-
-      unLo = ltLo = lo;
-      unHi = gtHi = hi;
-
-      while (True) {
-         while (True) {
-            if (unLo > unHi) break;
-            n = ((Int32)block[ptr[unLo]+d]) - med;
-            if (n == 0) { 
-               mswap(ptr[unLo], ptr[ltLo]); 
-               ltLo++; unLo++; continue; 
-            };
-            if (n >  0) break;
-            unLo++;
-         }
-         while (True) {
-            if (unLo > unHi) break;
-            n = ((Int32)block[ptr[unHi]+d]) - med;
-            if (n == 0) { 
-               mswap(ptr[unHi], ptr[gtHi]); 
-               gtHi--; unHi--; continue; 
-            };
-            if (n <  0) break;
-            unHi--;
-         }
-         if (unLo > unHi) break;
-         mswap(ptr[unLo], ptr[unHi]); unLo++; unHi--;
-      }
-
-      AssertD ( unHi == unLo-1, "mainQSort3(2)" );
-
-      if (gtHi < ltLo) {
-         mpush(lo, hi, d+1 );
-         continue;
-      }
-
-      n = mmin(ltLo-lo, unLo-ltLo); mvswap(lo, unLo-n, n);
-      m = mmin(hi-gtHi, gtHi-unHi); mvswap(unLo, hi-m+1, m);
-
-      n = lo + unLo - ltLo - 1;
-      m = hi - (gtHi - unHi) + 1;
-
-      nextLo[0] = lo;  nextHi[0] = n;   nextD[0] = d;
-      nextLo[1] = m;   nextHi[1] = hi;  nextD[1] = d;
-      nextLo[2] = n+1; nextHi[2] = m-1; nextD[2] = d+1;
-
-      if (mnextsize(0) < mnextsize(1)) mnextswap(0,1);
-      if (mnextsize(1) < mnextsize(2)) mnextswap(1,2);
-      if (mnextsize(0) < mnextsize(1)) mnextswap(0,1);
-
-      AssertD (mnextsize(0) >= mnextsize(1), "mainQSort3(8)" );
-      AssertD (mnextsize(1) >= mnextsize(2), "mainQSort3(9)" );
-
-      mpush (nextLo[0], nextHi[0], nextD[0]);
-      mpush (nextLo[1], nextHi[1], nextD[1]);
-      mpush (nextLo[2], nextHi[2], nextD[2]);
-   }
-}
-
-#undef mswap
-#undef mvswap
-#undef mpush
-#undef mpop
-#undef mmin
-#undef mnextsize
-#undef mnextswap
-#undef MAIN_QSORT_SMALL_THRESH
-#undef MAIN_QSORT_DEPTH_THRESH
-#undef MAIN_QSORT_STACK_SIZE
-
-
-/*---------------------------------------------*/
-/* Pre:
-      nblock > N_OVERSHOOT
-      block32 exists for [0 .. nblock-1 +N_OVERSHOOT]
-      ((UChar*)block32) [0 .. nblock-1] holds block
-      ptr exists for [0 .. nblock-1]
-
-   Post:
-      ((UChar*)block32) [0 .. nblock-1] holds block
-      All other areas of block32 destroyed
-      ftab [0 .. 65536 ] destroyed
-      ptr [0 .. nblock-1] holds sorted order
-      if (*budget < 0), sorting was abandoned
-*/
-
-#define BIGFREQ(b) (ftab[((b)+1) << 8] - ftab[(b) << 8])
-#define SETMASK (1 << 21)
-#define CLEARMASK (~(SETMASK))
-
-static
-void mainSort ( UInt32* ptr, 
-                UChar*  block,
-                UInt16* quadrant, 
-                UInt32* ftab,
-                Int32   nblock,
-                Int32   verb,
-                Int32*  budget )
-{
-   Int32  i, j, k, ss, sb;
-   Int32  runningOrder[256];
-   Bool   bigDone[256];
-   Int32  copyStart[256];
-   Int32  copyEnd  [256];
-   UChar  c1;
-   Int32  numQSorted;
-   UInt16 s;
-   if (verb >= 4) VPrintf0 ( "        main sort initialise ...\n" );
-
-   /*-- set up the 2-byte frequency table --*/
-   for (i = 65536; i >= 0; i--) ftab[i] = 0;
-
-   j = block[0] << 8;
-   i = nblock-1;
-   for (; i >= 3; i -= 4) {
-      quadrant[i] = 0;
-      j = (j >> 8) | ( ((UInt16)block[i]) << 8);
-      ftab[j]++;
-      quadrant[i-1] = 0;
-      j = (j >> 8) | ( ((UInt16)block[i-1]) << 8);
-      ftab[j]++;
-      quadrant[i-2] = 0;
-      j = (j >> 8) | ( ((UInt16)block[i-2]) << 8);
-      ftab[j]++;
-      quadrant[i-3] = 0;
-      j = (j >> 8) | ( ((UInt16)block[i-3]) << 8);
-      ftab[j]++;
-   }
-   for (; i >= 0; i--) {
-      quadrant[i] = 0;
-      j = (j >> 8) | ( ((UInt16)block[i]) << 8);
-      ftab[j]++;
-   }
-
-   /*-- (emphasises close relationship of block & quadrant) --*/
-   for (i = 0; i < BZ_N_OVERSHOOT; i++) {
-      block   [nblock+i] = block[i];
-      quadrant[nblock+i] = 0;
-   }
-
-   if (verb >= 4) VPrintf0 ( "        bucket sorting ...\n" );
-
-   /*-- Complete the initial radix sort --*/
-   for (i = 1; i <= 65536; i++) ftab[i] += ftab[i-1];
-
-   s = block[0] << 8;
-   i = nblock-1;
-   for (; i >= 3; i -= 4) {
-      s = (s >> 8) | (block[i] << 8);
-      j = ftab[s] -1;
-      ftab[s] = j;
-      ptr[j] = i;
-      s = (s >> 8) | (block[i-1] << 8);
-      j = ftab[s] -1;
-      ftab[s] = j;
-      ptr[j] = i-1;
-      s = (s >> 8) | (block[i-2] << 8);
-      j = ftab[s] -1;
-      ftab[s] = j;
-      ptr[j] = i-2;
-      s = (s >> 8) | (block[i-3] << 8);
-      j = ftab[s] -1;
-      ftab[s] = j;
-      ptr[j] = i-3;
-   }
-   for (; i >= 0; i--) {
-      s = (s >> 8) | (block[i] << 8);
-      j = ftab[s] -1;
-      ftab[s] = j;
-      ptr[j] = i;
-   }
-
-   /*--
-      Now ftab contains the first loc of every small bucket.
-      Calculate the running order, from smallest to largest
-      big bucket.
-   --*/
-   for (i = 0; i <= 255; i++) {
-      bigDone     [i] = False;
-      runningOrder[i] = i;
-   }
-
-   {
-      Int32 vv;
-      Int32 h = 1;
-      do h = 3 * h + 1; while (h <= 256);
-      do {
-         h = h / 3;
-         for (i = h; i <= 255; i++) {
-            vv = runningOrder[i];
-            j = i;
-            while ( BIGFREQ(runningOrder[j-h]) > BIGFREQ(vv) ) {
-               runningOrder[j] = runningOrder[j-h];
-               j = j - h;
-               if (j <= (h - 1)) goto zero;
-            }
-            zero:
-            runningOrder[j] = vv;
-         }
-      } while (h != 1);
-   }
-
-   /*--
-      The main sorting loop.
-   --*/
-
-   numQSorted = 0;
-
-   for (i = 0; i <= 255; i++) {
-
-      /*--
-         Process big buckets, starting with the least full.
-         Basically this is a 3-step process in which we call
-         mainQSort3 to sort the small buckets [ss, j], but
-         also make a big effort to avoid the calls if we can.
-      --*/
-      ss = runningOrder[i];
-
-      /*--
-         Step 1:
-         Complete the big bucket [ss] by quicksorting
-         any unsorted small buckets [ss, j], for j != ss.  
-         Hopefully previous pointer-scanning phases have already
-         completed many of the small buckets [ss, j], so
-         we don't have to sort them at all.
-      --*/
-      for (j = 0; j <= 255; j++) {
-         if (j != ss) {
-            sb = (ss << 8) + j;
-            if ( ! (ftab[sb] & SETMASK) ) {
-               Int32 lo = ftab[sb]   & CLEARMASK;
-               Int32 hi = (ftab[sb+1] & CLEARMASK) - 1;
-               if (hi > lo) {
-                  if (verb >= 4)
-                     VPrintf4 ( "        qsort [0x%x, 0x%x]   "
-                                "done %d   this %d\n",
-                                ss, j, numQSorted, hi - lo + 1 );
-                  mainQSort3 ( 
-                     ptr, block, quadrant, nblock, 
-                     lo, hi, BZ_N_RADIX, budget 
-                  );   
-                  numQSorted += (hi - lo + 1);
-                  if (*budget < 0) return;
-               }
-            }
-            ftab[sb] |= SETMASK;
-         }
-      }
-
-      AssertH ( !bigDone[ss], 1006 );
-
-      /*--
-         Step 2:
-         Now scan this big bucket [ss] so as to synthesise the
-         sorted order for small buckets [t, ss] for all t,
-         including, magically, the bucket [ss,ss] too.
-         This will avoid doing Real Work in subsequent Step 1's.
-      --*/
-      {
-         for (j = 0; j <= 255; j++) {
-            copyStart[j] =  ftab[(j << 8) + ss]     & CLEARMASK;
-            copyEnd  [j] = (ftab[(j << 8) + ss + 1] & CLEARMASK) - 1;
-         }
-         for (j = ftab[ss << 8] & CLEARMASK; j < copyStart[ss]; j++) {
-            k = ptr[j]-1; if (k < 0) k += nblock;
-            c1 = block[k];
-            if (!bigDone[c1])
-               ptr[ copyStart[c1]++ ] = k;
-         }
-         for (j = (ftab[(ss+1) << 8] & CLEARMASK) - 1; j > copyEnd[ss]; j--) {
-            k = ptr[j]-1; if (k < 0) k += nblock;
-            c1 = block[k];
-            if (!bigDone[c1]) 
-               ptr[ copyEnd[c1]-- ] = k;
-         }
-      }
-
-      AssertH ( (copyStart[ss]-1 == copyEnd[ss])
-                || 
-                /* Extremely rare case missing in bzip2-1.0.0 and 1.0.1.
-                   Necessity for this case is demonstrated by compressing 
-                   a sequence of approximately 48.5 million of character 
-                   251; 1.0.0/1.0.1 will then die here. */
-                (copyStart[ss] == 0 && copyEnd[ss] == nblock-1),
-                1007 )
-
-      for (j = 0; j <= 255; j++) ftab[(j << 8) + ss] |= SETMASK;
-
-      /*--
-         Step 3:
-         The [ss] big bucket is now done.  Record this fact,
-         and update the quadrant descriptors.  Remember to
-         update quadrants in the overshoot area too, if
-         necessary.  The "if (i < 255)" test merely skips
-         this updating for the last bucket processed, since
-         updating for the last bucket is pointless.
-
-         The quadrant array provides a way to incrementally
-         cache sort orderings, as they appear, so as to 
-         make subsequent comparisons in fullGtU() complete
-         faster.  For repetitive blocks this makes a big
-         difference (but not big enough to be able to avoid
-         the fallback sorting mechanism, exponential radix sort).
-
-         The precise meaning is: at all times:
-
-            for 0 <= i < nblock and 0 <= j <= nblock
-
-            if block[i] != block[j], 
-
-               then the relative values of quadrant[i] and 
-                    quadrant[j] are meaningless.
-
-               else {
-                  if quadrant[i] < quadrant[j]
-                     then the string starting at i lexicographically
-                     precedes the string starting at j
-
-                  else if quadrant[i] > quadrant[j]
-                     then the string starting at j lexicographically
-                     precedes the string starting at i
-
-                  else
-                     the relative ordering of the strings starting
-                     at i and j has not yet been determined.
-               }
-      --*/
-      bigDone[ss] = True;
-
-      if (i < 255) {
-         Int32 bbStart  = ftab[ss << 8] & CLEARMASK;
-         Int32 bbSize   = (ftab[(ss+1) << 8] & CLEARMASK) - bbStart;
-         Int32 shifts   = 0;
-
-         while ((bbSize >> shifts) > 65534) shifts++;
-
-         for (j = bbSize-1; j >= 0; j--) {
-            Int32 a2update     = ptr[bbStart + j];
-            UInt16 qVal        = (UInt16)(j >> shifts);
-            quadrant[a2update] = qVal;
-            if (a2update < BZ_N_OVERSHOOT)
-               quadrant[a2update + nblock] = qVal;
-         }
-         AssertH ( ((bbSize-1) >> shifts) <= 65535, 1002 );
-      }
-
-   }
-
-   if (verb >= 4)
-      VPrintf3 ( "        %d pointers, %d sorted, %d scanned\n",
-                 nblock, numQSorted, nblock - numQSorted );
-}
-
-#undef BIGFREQ
-#undef SETMASK
-#undef CLEARMASK
-
-
-/*---------------------------------------------*/
-/* Pre:
-      nblock > 0
-      arr2 exists for [0 .. nblock-1 +N_OVERSHOOT]
-      ((UChar*)arr2)  [0 .. nblock-1] holds block
-      arr1 exists for [0 .. nblock-1]
-
-   Post:
-      ((UChar*)arr2) [0 .. nblock-1] holds block
-      All other areas of block destroyed
-      ftab [ 0 .. 65536 ] destroyed
-      arr1 [0 .. nblock-1] holds sorted order
-*/
-void BZ2_blockSort ( EState* s )
-{
-   UInt32* ptr    = s->ptr; 
-   UChar*  block  = s->block;
-   UInt32* ftab   = s->ftab;
-   Int32   nblock = s->nblock;
-   Int32   verb   = s->verbosity;
-   Int32   wfact  = s->workFactor;
-   UInt16* quadrant;
-   Int32   budget;
-   Int32   budgetInit;
-   Int32   i;
-
-   if (nblock < 10000) {
-      fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb );
-   } else {
-      /* Calculate the location for quadrant, remembering to get
-         the alignment right.  Assumes that &(block[0]) is at least
-         2-byte aligned -- this should be ok since block is really
-         the first section of arr2.
-      */
-      i = nblock+BZ_N_OVERSHOOT;
-      if (i & 1) i++;
-      quadrant = (UInt16*)(&(block[i]));
-
-      /* (wfact-1) / 3 puts the default-factor-30
-         transition point at very roughly the same place as 
-         with v0.1 and v0.9.0.  
-         Not that it particularly matters any more, since the
-         resulting compressed stream is now the same regardless
-         of whether or not we use the main sort or fallback sort.
-      */
-      if (wfact < 1  ) wfact = 1;
-      if (wfact > 100) wfact = 100;
-      budgetInit = nblock * ((wfact-1) / 3);
-      budget = budgetInit;
-
-      mainSort ( ptr, block, quadrant, ftab, nblock, verb, &budget );
-      if (verb >= 3) 
-         VPrintf3 ( "      %d work, %d block, ratio %5.2f\n",
-                    budgetInit - budget,
-                    nblock, 
-                    (float)(budgetInit - budget) /
-                    (float)(nblock==0 ? 1 : nblock) ); 
-      if (budget < 0) {
-         if (verb >= 2) 
-            VPrintf0 ( "    too repetitive; using fallback"
-                       " sorting algorithm\n" );
-         fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb );
-      }
-   }
-
-   s->origPtr = -1;
-   for (i = 0; i < s->nblock; i++)
-      if (ptr[i] == 0)
-         { s->origPtr = i; break; };
-
-   AssertH( s->origPtr != -1, 1003 );
-}
-
-
-/*-------------------------------------------------------------*/
-/*--- end                                       blocksort.c ---*/
-/*-------------------------------------------------------------*/
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bz-common.xsl b/contrib/vmap_extractor_v2/stormlib/bzip2/bz-common.xsl
deleted file mode 100644
index 66fcd6fe0b6..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bz-common.xsl
+++ /dev/null
@@ -1,39 +0,0 @@
- 
-
-
-
- 
-
-
-
- 
- 
-   
-    
-      
-     
-  
-
-
-
-
-set       toc,title
-book      toc,title,figure,table,example,equation
-chapter   toc,title
-section   toc
-sect1     toc
-sect2     toc
-sect3     toc
-sect4     nop
-sect5     nop
-qandaset  toc
-qandadiv  nop
-appendix  toc,title
-article/appendix  nop
-article   toc,title
-preface   toc,title
-reference toc,title
-
-
-
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bz-fo.xsl b/contrib/vmap_extractor_v2/stormlib/bzip2/bz-fo.xsl
deleted file mode 100644
index 7f2a7674f04..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bz-fo.xsl
+++ /dev/null
@@ -1,257 +0,0 @@
- 
-
-
-
-
-
-
-
-
-
-
-
-
-      
-     
-   
-
-
-
-
- 
-
-
-
-
-
-
-  
-
-
-
-
-  blue
-
-
-
-
-  
-    
-  
-
-
-
-  
-    
-  
-
-
-
-
-  
-  
-  
-    
-      
-    
-  
-  
-    
-      
-        
-          
-          
-          
-        
-      
-    
-    
-          
-    
-  
-  
-    
-      
-        
-      
-    
-    
-      
-        
-      
-    
-  
-
-
-
-
-  
-  
-  
-    
-      
-        
-      
-    
-    
-          
-    
-  
-  
-    
-      
-        
-      
-    
-    
-      
-        
-      
-    
-  
-
-
-
-
-
-  
-    
-  
-    
-  
-  
-    
-      
-    
-  
-
-
-
-
-
-  
-  
-  
-  
-    
-      0pt
-    
-  
-  
-    
-      
-      
-      
-        
-          
-            baseline
-             
-               
-            
-          
-          
-            baseline
-            
-              
-                
-                
-                
-                
-              
-            
-          
-        
-      
-    
-  
-  
-  
-    
-      
-    
-    
-      
-    
-    
-      
-    
-  
-
-
-
-
-
-  
-  
-  
-  
-    
-      0pt
-    
-  
-  
-    
-      
-        
-        
-        
-      
-      
-      
-      
-        
-          
-            baseline
-            
-               
-            
-          
-          
-            baseline
-            
-              
-                
-                
-                
-                
-              
-            
-          
-        
-      
-    
-  
-  
-  
-    
-      
-    
-    
-      
-    
-    
-      
-    
-  
-
-
-
-
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bz-html.xsl b/contrib/vmap_extractor_v2/stormlib/bzip2/bz-html.xsl
deleted file mode 100644
index 1785fffbc95..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bz-html.xsl
+++ /dev/null
@@ -1,20 +0,0 @@
- 
- ]>
-
-
-
-
-
-
-
-
-
-
-  
-  
-
-
-
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzdiff b/contrib/vmap_extractor_v2/stormlib/bzip2/bzdiff
deleted file mode 100644
index 3c2eb859fca..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzdiff
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/bin/sh
-# sh is buggy on RS/6000 AIX 3.2. Replace above line with #!/bin/ksh
-
-# Bzcmp/diff wrapped for bzip2, 
-# adapted from zdiff by Philippe Troin  for Debian GNU/Linux.
-
-# Bzcmp and bzdiff are used to invoke the cmp or the  diff  pro-
-# gram  on compressed files.  All options specified are passed
-# directly to cmp or diff.  If only 1 file is specified,  then
-# the  files  compared  are file1 and an uncompressed file1.gz.
-# If two files are specified, then they are  uncompressed  (if
-# necessary) and fed to cmp or diff.  The exit status from cmp
-# or diff is preserved.
-
-PATH="/usr/bin:$PATH"; export PATH
-prog=`echo $0 | sed 's|.*/||'`
-case "$prog" in
-  *cmp) comp=${CMP-cmp}   ;;
-  *)    comp=${DIFF-diff} ;;
-esac
-
-OPTIONS=
-FILES=
-for ARG
-do
-    case "$ARG" in
-    -*)	OPTIONS="$OPTIONS $ARG";;
-     *)	if test -f "$ARG"; then
-            FILES="$FILES $ARG"
-        else
-            echo "${prog}: $ARG not found or not a regular file"
-	    exit 1
-        fi ;;
-    esac
-done
-if test -z "$FILES"; then
-	echo "Usage: $prog [${comp}_options] file [file]"
-	exit 1
-fi
-tmp=`tempfile -d /tmp -p bz` || {
-      echo 'cannot create a temporary file' >&2
-      exit 1
-}
-set $FILES
-if test $# -eq 1; then
-	FILE=`echo "$1" | sed 's/.bz2$//'`
-	bzip2 -cd "$FILE.bz2" | $comp $OPTIONS - "$FILE"
-	STAT="$?"
-
-elif test $# -eq 2; then
-	case "$1" in
-        *.bz2)
-                case "$2" in
-	        *.bz2)
-			F=`echo "$2" | sed 's|.*/||;s|.bz2$||'`
-                        bzip2 -cdfq "$2" > $tmp
-                        bzip2 -cdfq "$1" | $comp $OPTIONS - $tmp
-                        STAT="$?"
-			/bin/rm -f $tmp;;
-
-                *)      bzip2 -cdfq "$1" | $comp $OPTIONS - "$2"
-                        STAT="$?";;
-                esac;;
-        *)      case "$2" in
-	        *.bz2)
-                        bzip2 -cdfq "$2" | $comp $OPTIONS "$1" -
-                        STAT="$?";;
-                *)      $comp $OPTIONS "$1" "$2"
-                        STAT="$?";;
-                esac;;
-	esac
-        exit "$STAT"
-else
-	echo "Usage: $prog [${comp}_options] file [file]"
-	exit 1
-fi
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzdiff.1 b/contrib/vmap_extractor_v2/stormlib/bzip2/bzdiff.1
deleted file mode 100644
index adb7a8e724e..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzdiff.1
+++ /dev/null
@@ -1,47 +0,0 @@
-\"Shamelessly copied from zmore.1 by Philippe Troin 
-\"for Debian GNU/Linux
-.TH BZDIFF 1
-.SH NAME
-bzcmp, bzdiff \- compare bzip2 compressed files
-.SH SYNOPSIS
-.B bzcmp
-[ cmp_options ] file1
-[ file2 ]
-.br
-.B bzdiff
-[ diff_options ] file1
-[ file2 ]
-.SH DESCRIPTION
-.I  Bzcmp
-and 
-.I bzdiff
-are used to invoke the
-.I cmp
-or the
-.I diff
-program on bzip2 compressed files.  All options specified are passed
-directly to
-.I cmp
-or
-.IR diff "."
-If only 1 file is specified, then the files compared are
-.I file1
-and an uncompressed
-.IR file1 ".bz2."
-If two files are specified, then they are uncompressed if necessary and fed to
-.I cmp
-or
-.IR diff "."
-The exit status from 
-.I cmp
-or
-.I diff
-is preserved.
-.SH "SEE ALSO"
-cmp(1), diff(1), bzmore(1), bzless(1), bzgrep(1), bzip2(1)
-.SH BUGS
-Messages from the
-.I cmp
-or
-.I diff
-programs refer to temporary filenames instead of those specified.
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzgrep b/contrib/vmap_extractor_v2/stormlib/bzip2/bzgrep
deleted file mode 100644
index dbfc00e8dbe..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzgrep
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/bin/sh
-
-# Bzgrep wrapped for bzip2, 
-# adapted from zgrep by Philippe Troin  for Debian GNU/Linux.
-## zgrep notice:
-## zgrep -- a wrapper around a grep program that decompresses files as needed
-## Adapted from a version sent by Charles Levert 
-
-PATH="/usr/bin:$PATH"; export PATH
-
-prog=`echo $0 | sed 's|.*/||'`
-case "$prog" in
-	*egrep)	grep=${EGREP-egrep}	;;
-	*fgrep)	grep=${FGREP-fgrep}	;;
-	*)	grep=${GREP-grep}	;;
-esac
-pat=""
-while test $# -ne 0; do
-  case "$1" in
-  -e | -f) opt="$opt $1"; shift; pat="$1"
-           if test "$grep" = grep; then  # grep is buggy with -e on SVR4
-             grep=egrep
-           fi;;
-  -A | -B) opt="$opt $1 $2"; shift;;
-  -*)	   opt="$opt $1";;
-   *)      if test -z "$pat"; then
-	     pat="$1"
-	   else
-	     break;
-           fi;;
-  esac
-  shift
-done
-
-if test -z "$pat"; then
-  echo "grep through bzip2 files"
-  echo "usage: $prog [grep_options] pattern [files]"
-  exit 1
-fi
-
-list=0
-silent=0
-op=`echo "$opt" | sed -e 's/ //g' -e 's/-//g'`
-case "$op" in
-  *l*) list=1
-esac
-case "$op" in
-  *h*) silent=1
-esac
-
-if test $# -eq 0; then
-  bzip2 -cdfq | $grep $opt "$pat"
-  exit $?
-fi
-
-res=0
-for i do
-  if test -f "$i"; then :; else if test -f "$i.bz2"; then i="$i.bz2"; fi; fi
-  if test $list -eq 1; then
-    bzip2 -cdfq "$i" | $grep $opt "$pat" 2>&1 > /dev/null && echo $i
-    r=$?
-  elif test $# -eq 1 -o $silent -eq 1; then
-    bzip2 -cdfq "$i" | $grep $opt "$pat"
-    r=$?
-  else
-    bzip2 -cdfq "$i" | $grep $opt "$pat" | sed "s|^|${i}:|"
-    r=$?
-  fi
-  test "$r" -ne 0 && res="$r"
-done
-exit $res
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzgrep.1 b/contrib/vmap_extractor_v2/stormlib/bzip2/bzgrep.1
deleted file mode 100644
index 930af8c7fcb..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzgrep.1
+++ /dev/null
@@ -1,56 +0,0 @@
-\"Shamelessly copied from zmore.1 by Philippe Troin 
-\"for Debian GNU/Linux
-.TH BZGREP 1
-.SH NAME
-bzgrep, bzfgrep, bzegrep \- search possibly bzip2 compressed files for a regular expression
-.SH SYNOPSIS
-.B bzgrep
-[ grep_options ]
-.BI  [\ -e\ ] " pattern"
-.IR filename ".\|.\|."
-.br
-.B bzegrep
-[ egrep_options ]
-.BI  [\ -e\ ] " pattern"
-.IR filename ".\|.\|."
-.br
-.B bzfgrep
-[ fgrep_options ]
-.BI  [\ -e\ ] " pattern"
-.IR filename ".\|.\|."
-.SH DESCRIPTION
-.IR  Bzgrep
-is used to invoke the
-.I grep
-on bzip2-compressed files. All options specified are passed directly to
-.I grep.
-If no file is specified, then the standard input is decompressed
-if necessary and fed to grep.
-Otherwise the given files are uncompressed if necessary and fed to
-.I grep.
-.PP
-If
-.I bzgrep
-is invoked as
-.I bzegrep
-or
-.I bzfgrep
-then
-.I egrep
-or
-.I fgrep
-is used instead of
-.I grep.
-If the GREP environment variable is set,
-.I bzgrep
-uses it as the
-.I grep
-program to be invoked. For example:
-
-    for sh:  GREP=fgrep  bzgrep string files
-    for csh: (setenv GREP fgrep; bzgrep string files)
-.SH AUTHOR
-Charles Levert (charles@comm.polymtl.ca). Adapted to bzip2 by Philippe
-Troin  for Debian GNU/Linux.
-.SH "SEE ALSO"
-grep(1), egrep(1), fgrep(1), bzdiff(1), bzmore(1), bzless(1), bzip2(1)
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzip.css b/contrib/vmap_extractor_v2/stormlib/bzip2/bzip.css
deleted file mode 100644
index 43193d8db0b..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzip.css
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Colours:
-#74240f  dark brown      h1, h2, h3, h4
-#336699  medium blue     links
-#339999  turquoise       link hover colour
-#202020  almost black    general text
-#761596  purple          md5sum text
-#626262  dark gray       pre border
-#eeeeee  very light gray pre background
-#f2f2f9  very light blue nav table background
-#3366cc  medium blue     nav table border
-*/
-
-a, a:link, a:visited, a:active { color: #336699; }
-a:hover { color: #339999; }
-
-body { font: 80%/126% sans-serif; }
-h1, h2, h3, h4 { color: #74240f; }
-
-dt { color: #336699; font-weight: bold }
-dd { 
- margin-left: 1.5em; 
- padding-bottom: 0.8em;
-}
-
-/* -- ruler -- */
-div.hr_blue { 
-  height:  3px; 
-  background:#ffffff url("/images/hr_blue.png") repeat-x; }
-div.hr_blue hr { display:none; }
-
-/* release styles */
-#release p { margin-top: 0.4em; }
-#release .md5sum { color: #761596; }
-
-
-/* ------ styles for docs|manuals|howto ------ */
-/* -- lists -- */
-ul  { 
- margin:     0px 4px 16px 16px;
- padding:    0px;
- list-style: url("/images/li-blue.png"); 
-}
-ul li { 
- margin-bottom: 10px;
-}
-ul ul	{ 
- list-style-type:  none; 
- list-style-image: none; 
- margin-left:      0px; 
-}
-
-/* header / footer nav tables */
-table.nav {
- border:     solid 1px #3366cc;
- background: #f2f2f9;
- background-color: #f2f2f9;
- margin-bottom: 0.5em;
-}
-/* don't have underlined links in chunked nav menus */
-table.nav a { text-decoration: none; }
-table.nav a:hover { text-decoration: underline; }
-table.nav td { font-size: 85%; }
-
-code, tt, pre { font-size: 120%; }
-code, tt { color: #761596; }
-
-div.literallayout, pre.programlisting, pre.screen {
- color:      #000000;
- padding:    0.5em;
- background: #eeeeee;
- border:     1px solid #626262;
- background-color: #eeeeee;
- margin: 4px 0px 4px 0px; 
-}
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2.1 b/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2.1
deleted file mode 100644
index d2c06615683..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2.1
+++ /dev/null
@@ -1,454 +0,0 @@
-.PU
-.TH bzip2 1
-.SH NAME
-bzip2, bunzip2 \- a block-sorting file compressor, v1.0.3
-.br
-bzcat \- decompresses files to stdout
-.br
-bzip2recover \- recovers data from damaged bzip2 files
-
-.SH SYNOPSIS
-.ll +8
-.B bzip2
-.RB [ " \-cdfkqstvzVL123456789 " ]
-[
-.I "filenames \&..."
-]
-.ll -8
-.br
-.B bunzip2
-.RB [ " \-fkvsVL " ]
-[ 
-.I "filenames \&..."
-]
-.br
-.B bzcat
-.RB [ " \-s " ]
-[ 
-.I "filenames \&..."
-]
-.br
-.B bzip2recover
-.I "filename"
-
-.SH DESCRIPTION
-.I bzip2
-compresses files using the Burrows-Wheeler block sorting
-text compression algorithm, and Huffman coding.  Compression is
-generally considerably better than that achieved by more conventional
-LZ77/LZ78-based compressors, and approaches the performance of the PPM
-family of statistical compressors.
-
-The command-line options are deliberately very similar to 
-those of 
-.I GNU gzip, 
-but they are not identical.
-
-.I bzip2
-expects a list of file names to accompany the
-command-line flags.  Each file is replaced by a compressed version of
-itself, with the name "original_name.bz2".  
-Each compressed file
-has the same modification date, permissions, and, when possible,
-ownership as the corresponding original, so that these properties can
-be correctly restored at decompression time.  File name handling is
-naive in the sense that there is no mechanism for preserving original
-file names, permissions, ownerships or dates in filesystems which lack
-these concepts, or have serious file name length restrictions, such as
-MS-DOS.
-
-.I bzip2
-and
-.I bunzip2
-will by default not overwrite existing
-files.  If you want this to happen, specify the \-f flag.
-
-If no file names are specified,
-.I bzip2
-compresses from standard
-input to standard output.  In this case,
-.I bzip2
-will decline to
-write compressed output to a terminal, as this would be entirely
-incomprehensible and therefore pointless.
-
-.I bunzip2
-(or
-.I bzip2 \-d) 
-decompresses all
-specified files.  Files which were not created by 
-.I bzip2
-will be detected and ignored, and a warning issued.  
-.I bzip2
-attempts to guess the filename for the decompressed file 
-from that of the compressed file as follows:
-
-       filename.bz2    becomes   filename
-       filename.bz     becomes   filename
-       filename.tbz2   becomes   filename.tar
-       filename.tbz    becomes   filename.tar
-       anyothername    becomes   anyothername.out
-
-If the file does not end in one of the recognised endings, 
-.I .bz2, 
-.I .bz, 
-.I .tbz2
-or
-.I .tbz, 
-.I bzip2 
-complains that it cannot
-guess the name of the original file, and uses the original name
-with
-.I .out
-appended.
-
-As with compression, supplying no
-filenames causes decompression from 
-standard input to standard output.
-
-.I bunzip2 
-will correctly decompress a file which is the
-concatenation of two or more compressed files.  The result is the
-concatenation of the corresponding uncompressed files.  Integrity
-testing (\-t) 
-of concatenated 
-compressed files is also supported.
-
-You can also compress or decompress files to the standard output by
-giving the \-c flag.  Multiple files may be compressed and
-decompressed like this.  The resulting outputs are fed sequentially to
-stdout.  Compression of multiple files 
-in this manner generates a stream
-containing multiple compressed file representations.  Such a stream
-can be decompressed correctly only by
-.I bzip2 
-version 0.9.0 or
-later.  Earlier versions of
-.I bzip2
-will stop after decompressing
-the first file in the stream.
-
-.I bzcat
-(or
-.I bzip2 -dc) 
-decompresses all specified files to
-the standard output.
-
-.I bzip2
-will read arguments from the environment variables
-.I BZIP2
-and
-.I BZIP,
-in that order, and will process them
-before any arguments read from the command line.  This gives a 
-convenient way to supply default arguments.
-
-Compression is always performed, even if the compressed 
-file is slightly
-larger than the original.  Files of less than about one hundred bytes
-tend to get larger, since the compression mechanism has a constant
-overhead in the region of 50 bytes.  Random data (including the output
-of most file compressors) is coded at about 8.05 bits per byte, giving
-an expansion of around 0.5%.
-
-As a self-check for your protection, 
-.I 
-bzip2
-uses 32-bit CRCs to
-make sure that the decompressed version of a file is identical to the
-original.  This guards against corruption of the compressed data, and
-against undetected bugs in
-.I bzip2
-(hopefully very unlikely).  The
-chances of data corruption going undetected is microscopic, about one
-chance in four billion for each file processed.  Be aware, though, that
-the check occurs upon decompression, so it can only tell you that
-something is wrong.  It can't help you 
-recover the original uncompressed
-data.  You can use 
-.I bzip2recover
-to try to recover data from
-damaged files.
-
-Return values: 0 for a normal exit, 1 for environmental problems (file
-not found, invalid flags, I/O errors, &c), 2 to indicate a corrupt
-compressed file, 3 for an internal consistency error (eg, bug) which
-caused
-.I bzip2
-to panic.
-
-.SH OPTIONS
-.TP
-.B \-c --stdout
-Compress or decompress to standard output.
-.TP
-.B \-d --decompress
-Force decompression.  
-.I bzip2, 
-.I bunzip2 
-and
-.I bzcat 
-are
-really the same program, and the decision about what actions to take is
-done on the basis of which name is used.  This flag overrides that
-mechanism, and forces 
-.I bzip2
-to decompress.
-.TP
-.B \-z --compress
-The complement to \-d: forces compression, regardless of the
-invocation name.
-.TP
-.B \-t --test
-Check integrity of the specified file(s), but don't decompress them.
-This really performs a trial decompression and throws away the result.
-.TP
-.B \-f --force
-Force overwrite of output files.  Normally,
-.I bzip2 
-will not overwrite
-existing output files.  Also forces 
-.I bzip2 
-to break hard links
-to files, which it otherwise wouldn't do.
-
-bzip2 normally declines to decompress files which don't have the
-correct magic header bytes.  If forced (-f), however, it will pass
-such files through unmodified.  This is how GNU gzip behaves.
-.TP
-.B \-k --keep
-Keep (don't delete) input files during compression
-or decompression.
-.TP
-.B \-s --small
-Reduce memory usage, for compression, decompression and testing.  Files
-are decompressed and tested using a modified algorithm which only
-requires 2.5 bytes per block byte.  This means any file can be
-decompressed in 2300k of memory, albeit at about half the normal speed.
-
-During compression, \-s selects a block size of 200k, which limits
-memory use to around the same figure, at the expense of your compression
-ratio.  In short, if your machine is low on memory (8 megabytes or
-less), use \-s for everything.  See MEMORY MANAGEMENT below.
-.TP
-.B \-q --quiet
-Suppress non-essential warning messages.  Messages pertaining to
-I/O errors and other critical events will not be suppressed.
-.TP
-.B \-v --verbose
-Verbose mode -- show the compression ratio for each file processed.
-Further \-v's increase the verbosity level, spewing out lots of
-information which is primarily of interest for diagnostic purposes.
-.TP
-.B \-L --license -V --version
-Display the software version, license terms and conditions.
-.TP
-.B \-1 (or \-\-fast) to \-9 (or \-\-best)
-Set the block size to 100 k, 200 k ..  900 k when compressing.  Has no
-effect when decompressing.  See MEMORY MANAGEMENT below.
-The \-\-fast and \-\-best aliases are primarily for GNU gzip 
-compatibility.  In particular, \-\-fast doesn't make things
-significantly faster.  
-And \-\-best merely selects the default behaviour.
-.TP
-.B \--
-Treats all subsequent arguments as file names, even if they start
-with a dash.  This is so you can handle files with names beginning
-with a dash, for example: bzip2 \-- \-myfilename.
-.TP
-.B \--repetitive-fast --repetitive-best
-These flags are redundant in versions 0.9.5 and above.  They provided
-some coarse control over the behaviour of the sorting algorithm in
-earlier versions, which was sometimes useful.  0.9.5 and above have an
-improved algorithm which renders these flags irrelevant.
-
-.SH MEMORY MANAGEMENT
-.I bzip2 
-compresses large files in blocks.  The block size affects
-both the compression ratio achieved, and the amount of memory needed for
-compression and decompression.  The flags \-1 through \-9
-specify the block size to be 100,000 bytes through 900,000 bytes (the
-default) respectively.  At decompression time, the block size used for
-compression is read from the header of the compressed file, and
-.I bunzip2
-then allocates itself just enough memory to decompress
-the file.  Since block sizes are stored in compressed files, it follows
-that the flags \-1 to \-9 are irrelevant to and so ignored
-during decompression.
-
-Compression and decompression requirements, 
-in bytes, can be estimated as:
-
-       Compression:   400k + ( 8 x block size )
-
-       Decompression: 100k + ( 4 x block size ), or
-                      100k + ( 2.5 x block size )
-
-Larger block sizes give rapidly diminishing marginal returns.  Most of
-the compression comes from the first two or three hundred k of block
-size, a fact worth bearing in mind when using
-.I bzip2
-on small machines.
-It is also important to appreciate that the decompression memory
-requirement is set at compression time by the choice of block size.
-
-For files compressed with the default 900k block size,
-.I bunzip2
-will require about 3700 kbytes to decompress.  To support decompression
-of any file on a 4 megabyte machine, 
-.I bunzip2
-has an option to
-decompress using approximately half this amount of memory, about 2300
-kbytes.  Decompression speed is also halved, so you should use this
-option only where necessary.  The relevant flag is -s.
-
-In general, try and use the largest block size memory constraints allow,
-since that maximises the compression achieved.  Compression and
-decompression speed are virtually unaffected by block size.
-
-Another significant point applies to files which fit in a single block
--- that means most files you'd encounter using a large block size.  The
-amount of real memory touched is proportional to the size of the file,
-since the file is smaller than a block.  For example, compressing a file
-20,000 bytes long with the flag -9 will cause the compressor to
-allocate around 7600k of memory, but only touch 400k + 20000 * 8 = 560
-kbytes of it.  Similarly, the decompressor will allocate 3700k but only
-touch 100k + 20000 * 4 = 180 kbytes.
-
-Here is a table which summarises the maximum memory usage for different
-block sizes.  Also recorded is the total compressed size for 14 files of
-the Calgary Text Compression Corpus totalling 3,141,622 bytes.  This
-column gives some feel for how compression varies with block size.
-These figures tend to understate the advantage of larger block sizes for
-larger files, since the Corpus is dominated by smaller files.
-
-           Compress   Decompress   Decompress   Corpus
-    Flag     usage      usage       -s usage     Size
-
-     -1      1200k       500k         350k      914704
-     -2      2000k       900k         600k      877703
-     -3      2800k      1300k         850k      860338
-     -4      3600k      1700k        1100k      846899
-     -5      4400k      2100k        1350k      845160
-     -6      5200k      2500k        1600k      838626
-     -7      6100k      2900k        1850k      834096
-     -8      6800k      3300k        2100k      828642
-     -9      7600k      3700k        2350k      828642
-
-.SH RECOVERING DATA FROM DAMAGED FILES
-.I bzip2
-compresses files in blocks, usually 900kbytes long.  Each
-block is handled independently.  If a media or transmission error causes
-a multi-block .bz2
-file to become damaged, it may be possible to
-recover data from the undamaged blocks in the file.
-
-The compressed representation of each block is delimited by a 48-bit
-pattern, which makes it possible to find the block boundaries with
-reasonable certainty.  Each block also carries its own 32-bit CRC, so
-damaged blocks can be distinguished from undamaged ones.
-
-.I bzip2recover
-is a simple program whose purpose is to search for
-blocks in .bz2 files, and write each block out into its own .bz2 
-file.  You can then use
-.I bzip2 
-\-t
-to test the
-integrity of the resulting files, and decompress those which are
-undamaged.
-
-.I bzip2recover
-takes a single argument, the name of the damaged file, 
-and writes a number of files "rec00001file.bz2",
-"rec00002file.bz2", etc, containing the  extracted  blocks.
-The  output  filenames  are  designed  so  that the use of
-wildcards in subsequent processing -- for example,  
-"bzip2 -dc  rec*file.bz2 > recovered_data" -- processes the files in
-the correct order.
-
-.I bzip2recover
-should be of most use dealing with large .bz2
-files,  as  these will contain many blocks.  It is clearly
-futile to use it on damaged single-block  files,  since  a
-damaged  block  cannot  be recovered.  If you wish to minimise 
-any potential data loss through media  or  transmission errors, 
-you might consider compressing with a smaller
-block size.
-
-.SH PERFORMANCE NOTES
-The sorting phase of compression gathers together similar strings in the
-file.  Because of this, files containing very long runs of repeated
-symbols, like "aabaabaabaab ..."  (repeated several hundred times) may
-compress more slowly than normal.  Versions 0.9.5 and above fare much
-better than previous versions in this respect.  The ratio between
-worst-case and average-case compression time is in the region of 10:1.
-For previous versions, this figure was more like 100:1.  You can use the
-\-vvvv option to monitor progress in great detail, if you want.
-
-Decompression speed is unaffected by these phenomena.
-
-.I bzip2
-usually allocates several megabytes of memory to operate
-in, and then charges all over it in a fairly random fashion.  This means
-that performance, both for compressing and decompressing, is largely
-determined by the speed at which your machine can service cache misses.
-Because of this, small changes to the code to reduce the miss rate have
-been observed to give disproportionately large performance improvements.
-I imagine 
-.I bzip2
-will perform best on machines with very large caches.
-
-.SH CAVEATS
-I/O error messages are not as helpful as they could be.
-.I bzip2
-tries hard to detect I/O errors and exit cleanly, but the details of
-what the problem is sometimes seem rather misleading.
-
-This manual page pertains to version 1.0.3 of
-.I bzip2.  
-Compressed data created by this version is entirely forwards and
-backwards compatible with the previous public releases, versions
-0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1 and 1.0.2, but with the following
-exception: 0.9.0 and above can correctly decompress multiple
-concatenated compressed files.  0.1pl2 cannot do this; it will stop
-after decompressing just the first file in the stream.
-
-.I bzip2recover
-versions prior to 1.0.2 used 32-bit integers to represent
-bit positions in compressed files, so they could not handle compressed
-files more than 512 megabytes long.  Versions 1.0.2 and above use
-64-bit ints on some platforms which support them (GNU supported
-targets, and Windows).  To establish whether or not bzip2recover was
-built with such a limitation, run it without arguments.  In any event
-you can build yourself an unlimited version if you can recompile it
-with MaybeUInt64 set to be an unsigned 64-bit integer.
-
-
-
-.SH AUTHOR
-Julian Seward, jsewardbzip.org.
-
-http://www.bzip.org
-
-The ideas embodied in
-.I bzip2
-are due to (at least) the following
-people: Michael Burrows and David Wheeler (for the block sorting
-transformation), David Wheeler (again, for the Huffman coder), Peter
-Fenwick (for the structured coding model in the original
-.I bzip,
-and many refinements), and Alistair Moffat, Radford Neal and Ian Witten
-(for the arithmetic coder in the original
-.I bzip).  
-I am much
-indebted for their help, support and advice.  See the manual in the
-source distribution for pointers to sources of documentation.  Christian
-von Roques encouraged me to look for faster sorting algorithms, so as to
-speed up compression.  Bela Lubkin encouraged me to improve the
-worst-case compression performance.  
-Donna Robinson XMLised the documentation.
-The bz* scripts are derived from those of GNU gzip.
-Many people sent patches, helped
-with portability problems, lent machines, gave advice and were generally
-helpful.
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2.1.preformatted b/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2.1.preformatted
deleted file mode 100644
index 129ca835c9c..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2.1.preformatted
+++ /dev/null
@@ -1,399 +0,0 @@
-bzip2(1)                                                 bzip2(1)
-
-
-
-NNAAMMEE
-       bzip2, bunzip2 − a blockâ€sorting file compressor, v1.0.3
-       bzcat − decompresses files to stdout
-       bzip2recover − recovers data from damaged bzip2 files
-
-
-SSYYNNOOPPSSIISS
-       bbzziipp22 [ −−ccddffkkqqssttvvzzVVLL112233445566778899 ] [ _f_i_l_e_n_a_m_e_s _._._.  ]
-       bbuunnzziipp22 [ −−ffkkvvssVVLL ] [ _f_i_l_e_n_a_m_e_s _._._.  ]
-       bbzzccaatt [ −−ss ] [ _f_i_l_e_n_a_m_e_s _._._.  ]
-       bbzziipp22rreeccoovveerr _f_i_l_e_n_a_m_e
-
-
-DDEESSCCRRIIPPTTIIOONN
-       _b_z_i_p_2  compresses  files  using  the Burrowsâ€Wheeler block
-       sorting text compression algorithm,  and  Huffman  coding.
-       Compression  is  generally  considerably  better than that
-       achieved by more conventional LZ77/LZ78â€based compressors,
-       and  approaches  the performance of the PPM family of sta­
-       tistical compressors.
-
-       The commandâ€line options are deliberately very similar  to
-       those of _G_N_U _g_z_i_p_, but they are not identical.
-
-       _b_z_i_p_2  expects  a list of file names to accompany the com­
-       mandâ€line flags.  Each file is replaced  by  a  compressed
-       version  of  itself,  with  the  name "original_name.bz2".
-       Each compressed file has the same modification date,  per­
-       missions, and, when possible, ownership as the correspond­
-       ing original, so that these properties  can  be  correctly
-       restored  at  decompression  time.   File name handling is
-       naive in the sense that there is no mechanism for preserv­
-       ing  original file names, permissions, ownerships or dates
-       in filesystems which lack these concepts, or have  serious
-       file name length restrictions, such as MSâ€DOS.
-
-       _b_z_i_p_2  and  _b_u_n_z_i_p_2 will by default not overwrite existing
-       files.  If you want this to happen, specify the −f flag.
-
-       If no file names  are  specified,  _b_z_i_p_2  compresses  from
-       standard  input  to  standard output.  In this case, _b_z_i_p_2
-       will decline to write compressed output to a terminal,  as
-       this  would  be  entirely  incomprehensible  and therefore
-       pointless.
-
-       _b_u_n_z_i_p_2 (or _b_z_i_p_2 _−_d_) decompresses  all  specified  files.
-       Files which were not created by _b_z_i_p_2 will be detected and
-       ignored, and a warning issued.  _b_z_i_p_2  attempts  to  guess
-       the  filename  for  the decompressed file from that of the
-       compressed file as follows:
-
-              filename.bz2    becomes   filename
-              filename.bz     becomes   filename
-              filename.tbz2   becomes   filename.tar
-              filename.tbz    becomes   filename.tar
-              anyothername    becomes   anyothername.out
-
-       If the file does not end in one of the recognised endings,
-       _._b_z_2_,  _._b_z_,  _._t_b_z_2 or _._t_b_z_, _b_z_i_p_2 complains that it cannot
-       guess the name of the original file, and uses the original
-       name with _._o_u_t appended.
-
-       As  with compression, supplying no filenames causes decom­
-       pression from standard input to standard output.
-
-       _b_u_n_z_i_p_2 will correctly decompress a file which is the con­
-       catenation of two or more compressed files.  The result is
-       the concatenation of the corresponding uncompressed files.
-       Integrity testing (−t) of concatenated compressed files is
-       also supported.
-
-       You can also compress or decompress files to the  standard
-       output  by giving the −c flag.  Multiple files may be com­
-       pressed and decompressed like this.  The resulting outputs
-       are  fed  sequentially to stdout.  Compression of multiple
-       files in this manner generates a stream containing  multi­
-       ple compressed file representations.  Such a stream can be
-       decompressed correctly only  by  _b_z_i_p_2  version  0.9.0  or
-       later.   Earlier  versions of _b_z_i_p_2 will stop after decom­
-       pressing the first file in the stream.
-
-       _b_z_c_a_t (or _b_z_i_p_2 _â€_d_c_) decompresses all specified  files  to
-       the standard output.
-
-       _b_z_i_p_2  will  read arguments from the environment variables
-       _B_Z_I_P_2 and _B_Z_I_P_, in  that  order,  and  will  process  them
-       before  any  arguments  read  from the command line.  This
-       gives a convenient way to supply default arguments.
-
-       Compression is always performed, even  if  the  compressed
-       file  is slightly larger than the original.  Files of less
-       than about one hundred bytes tend to get larger, since the
-       compression  mechanism  has  a  constant  overhead  in the
-       region of 50 bytes.  Random data (including the output  of
-       most  file  compressors)  is  coded at about 8.05 bits per
-       byte, giving an expansion of around 0.5%.
-
-       As a selfâ€check for your  protection,  _b_z_i_p_2  uses  32â€bit
-       CRCs  to make sure that the decompressed version of a file
-       is identical to the original.  This guards against corrup­
-       tion  of  the compressed data, and against undetected bugs
-       in _b_z_i_p_2 (hopefully very unlikely).  The chances  of  data
-       corruption  going  undetected  is  microscopic,  about one
-       chance in four billion for each file processed.  Be aware,
-       though,  that  the  check occurs upon decompression, so it
-       can only tell you that something is wrong.  It can’t  help
-       you  recover  the original uncompressed data.  You can use
-       _b_z_i_p_2_r_e_c_o_v_e_r to try to recover data from damaged files.
-
-       Return values: 0 for a normal exit,  1  for  environmental
-       problems  (file not found, invalid flags, I/O errors, &c),
-       2 to indicate a corrupt compressed file, 3 for an internal
-       consistency error (eg, bug) which caused _b_z_i_p_2 to panic.
-
-
-OOPPTTIIOONNSS
-       −−cc â€â€â€â€ssttddoouutt
-              Compress or decompress to standard output.
-
-       −−dd â€â€â€â€ddeeccoommpprreessss
-              Force  decompression.  _b_z_i_p_2_, _b_u_n_z_i_p_2 and _b_z_c_a_t are
-              really the same program,  and  the  decision  about
-              what  actions to take is done on the basis of which
-              name is used.  This flag overrides that  mechanism,
-              and forces _b_z_i_p_2 to decompress.
-
-       −−zz â€â€â€â€ccoommpprreessss
-              The   complement   to   −d:   forces   compression,
-              regardless of the invocation name.
-
-       −−tt â€â€â€â€tteesstt
-              Check integrity of the specified file(s), but don’t
-              decompress  them.   This  really  performs  a trial
-              decompression and throws away the result.
-
-       −−ff â€â€â€â€ffoorrccee
-              Force overwrite of output files.   Normally,  _b_z_i_p_2
-              will  not  overwrite  existing  output files.  Also
-              forces _b_z_i_p_2 to break hard links to files, which it
-              otherwise wouldn’t do.
-
-              bzip2  normally  declines to decompress files which
-              don’t have the  correct  magic  header  bytes.   If
-              forced  (â€f),  however,  it  will  pass  such files
-              through unmodified.  This is how GNU gzip  behaves.
-
-       −−kk â€â€â€â€kkeeeepp
-              Keep  (don’t delete) input files during compression
-              or decompression.
-
-       −−ss â€â€â€â€ssmmaallll
-              Reduce memory usage, for compression, decompression
-              and  testing.   Files  are  decompressed and tested
-              using a modified algorithm which only requires  2.5
-              bytes  per  block byte.  This means any file can be
-              decompressed in 2300k of memory,  albeit  at  about
-              half the normal speed.
-
-              During  compression,  −s  selects  a  block size of
-              200k, which limits memory use to  around  the  same
-              figure,  at  the expense of your compression ratio.
-              In short, if your  machine  is  low  on  memory  (8
-              megabytes  or  less),  use  −s for everything.  See
-              MEMORY MANAGEMENT below.
-
-       −−qq â€â€â€â€qquuiieett
-              Suppress nonâ€essential warning messages.   Messages
-              pertaining  to I/O errors and other critical events
-              will not be suppressed.
-
-       −−vv â€â€â€â€vveerrbboossee
-              Verbose mode â€â€ show the compression ratio for each
-              file  processed.   Further  −v’s  increase the ver­
-              bosity level, spewing out lots of information which
-              is primarily of interest for diagnostic purposes.
-
-       −−LL â€â€â€â€lliicceennssee â€â€VV â€â€â€â€vveerrssiioonn
-              Display  the  software  version,  license terms and
-              conditions.
-
-       −−11 ((oorr −−−−ffaasstt)) ttoo −−99 ((oorr −−−−bbeesstt))
-              Set the block size to 100 k, 200 k ..  900  k  when
-              compressing.   Has  no  effect  when decompressing.
-              See MEMORY MANAGEMENT below.  The −−fast and −−best
-              aliases  are  primarily for GNU gzip compatibility.
-              In particular, −−fast doesn’t make things  signifi­
-              cantly  faster.   And  −−best  merely  selects  the
-              default behaviour.
-
-       −−     Treats all subsequent arguments as file names, even
-              if they start with a dash.  This is so you can han­
-              dle files with names beginning  with  a  dash,  for
-              example: bzip2 −†−myfilename.
-
-       −−â€â€rreeppeettiittiivveeâ€â€ffaasstt â€â€â€â€rreeppeettiittiivveeâ€â€bbeesstt
-              These  flags  are  redundant  in versions 0.9.5 and
-              above.  They provided some coarse control over  the
-              behaviour  of the sorting algorithm in earlier ver­
-              sions, which was sometimes useful.  0.9.5 and above
-              have  an  improved  algorithm  which  renders these
-              flags irrelevant.
-
-
-MMEEMMOORRYY MMAANNAAGGEEMMEENNTT
-       _b_z_i_p_2 compresses large files in blocks.   The  block  size
-       affects  both  the  compression  ratio  achieved,  and the
-       amount of memory needed for compression and decompression.
-       The  flags  −1  through  −9  specify  the block size to be
-       100,000 bytes through 900,000 bytes (the default)  respec­
-       tively.   At  decompression  time, the block size used for
-       compression is read from  the  header  of  the  compressed
-       file, and _b_u_n_z_i_p_2 then allocates itself just enough memory
-       to decompress the file.  Since block sizes are  stored  in
-       compressed  files,  it follows that the flags −1 to −9 are
-       irrelevant to and so ignored during decompression.
-
-       Compression and decompression requirements, in bytes,  can
-       be estimated as:
-
-              Compression:   400k + ( 8 x block size )
-
-              Decompression: 100k + ( 4 x block size ), or
-                             100k + ( 2.5 x block size )
-
-       Larger  block  sizes  give  rapidly  diminishing  marginal
-       returns.  Most of the compression comes from the first two
-       or  three hundred k of block size, a fact worth bearing in
-       mind when using _b_z_i_p_2  on  small  machines.   It  is  also
-       important  to  appreciate  that  the  decompression memory
-       requirement is set at compression time by  the  choice  of
-       block size.
-
-       For  files  compressed  with  the default 900k block size,
-       _b_u_n_z_i_p_2 will require about 3700 kbytes to decompress.   To
-       support decompression of any file on a 4 megabyte machine,
-       _b_u_n_z_i_p_2 has an option to  decompress  using  approximately
-       half this amount of memory, about 2300 kbytes.  Decompres­
-       sion speed is also halved, so you should use  this  option
-       only where necessary.  The relevant flag is â€s.
-
-       In general, try and use the largest block size memory con­
-       straints  allow,  since  that  maximises  the  compression
-       achieved.   Compression and decompression speed are virtu­
-       ally unaffected by block size.
-
-       Another significant point applies to files which fit in  a
-       single  block  â€â€  that  means  most files you’d encounter
-       using a large block  size.   The  amount  of  real  memory
-       touched is proportional to the size of the file, since the
-       file is smaller than a block.  For example, compressing  a
-       file  20,000  bytes  long  with the flag â€9 will cause the
-       compressor to allocate around 7600k of  memory,  but  only
-       touch 400k + 20000 * 8 = 560 kbytes of it.  Similarly, the
-       decompressor will allocate 3700k but  only  touch  100k  +
-       20000 * 4 = 180 kbytes.
-
-       Here  is a table which summarises the maximum memory usage
-       for different block sizes.  Also  recorded  is  the  total
-       compressed  size for 14 files of the Calgary Text Compres­
-       sion Corpus totalling 3,141,622 bytes.  This column  gives
-       some  feel  for  how  compression  varies with block size.
-       These figures tend to understate the advantage  of  larger
-       block  sizes  for  larger files, since the Corpus is domi­
-       nated by smaller files.
-
-                  Compress   Decompress   Decompress   Corpus
-           Flag     usage      usage       â€s usage     Size
-
-            â€1      1200k       500k         350k      914704
-            â€2      2000k       900k         600k      877703
-            â€3      2800k      1300k         850k      860338
-            â€4      3600k      1700k        1100k      846899
-            â€5      4400k      2100k        1350k      845160
-            â€6      5200k      2500k        1600k      838626
-            â€7      6100k      2900k        1850k      834096
-            â€8      6800k      3300k        2100k      828642
-            â€9      7600k      3700k        2350k      828642
-
-
-RREECCOOVVEERRIINNGG DDAATTAA FFRROOMM DDAAMMAAGGEEDD FFIILLEESS
-       _b_z_i_p_2 compresses files in blocks, usually 900kbytes  long.
-       Each block is handled independently.  If a media or trans­
-       mission error causes a multiâ€block  .bz2  file  to  become
-       damaged,  it  may  be  possible  to  recover data from the
-       undamaged blocks in the file.
-
-       The compressed representation of each block  is  delimited
-       by  a  48â€bit pattern, which makes it possible to find the
-       block boundaries with reasonable  certainty.   Each  block
-       also  carries its own 32â€bit CRC, so damaged blocks can be
-       distinguished from undamaged ones.
-
-       _b_z_i_p_2_r_e_c_o_v_e_r is a  simple  program  whose  purpose  is  to
-       search  for blocks in .bz2 files, and write each block out
-       into its own .bz2 file.  You can then use _b_z_i_p_2 −t to test
-       the integrity of the resulting files, and decompress those
-       which are undamaged.
-
-       _b_z_i_p_2_r_e_c_o_v_e_r takes a single argument, the name of the dam­
-       aged    file,    and    writes    a    number   of   files
-       "rec00001file.bz2",  "rec00002file.bz2",  etc,  containing
-       the   extracted   blocks.   The   output   filenames   are
-       designed  so  that the use of wildcards in subsequent pro­
-       cessing  â€â€ for example, "bzip2 â€dc  rec*file.bz2 > recov­
-       ered_data" â€â€ processes the files in the correct order.
-
-       _b_z_i_p_2_r_e_c_o_v_e_r should be of most use dealing with large .bz2
-       files,  as  these will contain many blocks.  It is clearly
-       futile to use it on damaged singleâ€block  files,  since  a
-       damaged  block  cannot  be recovered.  If you wish to min­
-       imise any potential data loss through media  or  transmis­
-       sion errors, you might consider compressing with a smaller
-       block size.
-
-
-PPEERRFFOORRMMAANNCCEE NNOOTTEESS
-       The sorting phase of compression gathers together  similar
-       strings  in  the  file.  Because of this, files containing
-       very long runs of  repeated  symbols,  like  "aabaabaabaab
-       ..."   (repeated  several hundred times) may compress more
-       slowly than normal.  Versions 0.9.5 and  above  fare  much
-       better  than previous versions in this respect.  The ratio
-       between worstâ€case and averageâ€case compression time is in
-       the  region  of  10:1.  For previous versions, this figure
-       was more like 100:1.  You can use the −vvvv option to mon­
-       itor progress in great detail, if you want.
-
-       Decompression speed is unaffected by these phenomena.
-
-       _b_z_i_p_2  usually  allocates  several  megabytes of memory to
-       operate in, and then charges all over it in a fairly  ran­
-       dom  fashion.   This means that performance, both for com­
-       pressing and decompressing, is largely determined  by  the
-       speed  at  which  your  machine  can service cache misses.
-       Because of this, small changes to the code to  reduce  the
-       miss  rate  have  been observed to give disproportionately
-       large performance improvements.  I imagine _b_z_i_p_2 will per­
-       form best on machines with very large caches.
-
-
-CCAAVVEEAATTSS
-       I/O  error  messages  are not as helpful as they could be.
-       _b_z_i_p_2 tries hard to detect I/O errors  and  exit  cleanly,
-       but  the  details  of  what  the problem is sometimes seem
-       rather misleading.
-
-       This manual page pertains to version 1.0.3 of _b_z_i_p_2_.  Com­
-       pressed  data created by this version is entirely forwards
-       and  backwards  compatible  with   the   previous   public
-       releases,  versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1 and
-       1.0.2, but with the following exception: 0.9.0  and  above
-       can  correctly decompress multiple concatenated compressed
-       files.  0.1pl2 cannot do this; it will stop  after  decom­
-       pressing just the first file in the stream.
-
-       _b_z_i_p_2_r_e_c_o_v_e_r  versions prior to 1.0.2 used 32â€bit integers
-       to represent bit positions in compressed  files,  so  they
-       could  not handle compressed files more than 512 megabytes
-       long.  Versions 1.0.2 and above use 64â€bit  ints  on  some
-       platforms  which  support them (GNU supported targets, and
-       Windows).  To establish whether or  not  bzip2recover  was
-       built  with  such  a limitation, run it without arguments.
-       In any event you can build yourself an  unlimited  version
-       if  you  can  recompile  it  with MaybeUInt64 set to be an
-       unsigned 64â€bit integer.
-
-
-
-
-AAUUTTHHOORR
-       Julian Seward, jsewardbzip.org.
-
-       http://www.bzip.org
-
-       The ideas embodied in _b_z_i_p_2 are due to (at least) the fol­
-       lowing  people: Michael Burrows and David Wheeler (for the
-       block sorting transformation), David Wheeler  (again,  for
-       the Huffman coder), Peter Fenwick (for the structured cod­
-       ing model in the original _b_z_i_p_, and many refinements), and
-       Alistair  Moffat,  Radford  Neal  and  Ian Witten (for the
-       arithmetic  coder  in  the  original  _b_z_i_p_)_.   I  am  much
-       indebted for their help, support and advice.  See the man­
-       ual in the source distribution for pointers to sources  of
-       documentation.  Christian von Roques encouraged me to look
-       for faster sorting algorithms, so as to speed up  compres­
-       sion.  Bela Lubkin encouraged me to improve the worstâ€case
-       compression performance.  Donna Robinson XMLised the docu­
-       mentation.   The bz* scripts are derived from those of GNU
-       gzip.  Many people sent patches, helped  with  portability
-       problems,  lent  machines,  gave advice and were generally
-       helpful.
-
-
-
-                                                         bzip2(1)
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2.c b/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2.c
deleted file mode 100644
index 79f87a51986..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2.c
+++ /dev/null
@@ -1,2107 +0,0 @@
-
-/*-----------------------------------------------------------*/
-/*--- A block-sorting, lossless compressor        bzip2.c ---*/
-/*-----------------------------------------------------------*/
-
-/*--
-  This file is a part of bzip2 and/or libbzip2, a program and
-  library for lossless, block-sorting data compression.
-
-  Copyright (C) 1996-2005 Julian R Seward.  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-  2. 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.
-
-  3. Altered source versions must be plainly marked as such, and must
-     not be misrepresented as being the original software.
-
-  4. The name of the author may not be used to endorse or promote 
-     products derived from this software without specific prior written 
-     permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
-
-  Julian Seward, Cambridge, UK.
-  jseward@bzip.org
-  bzip2/libbzip2 version 1.0 of 21 March 2000
-
-  This program is based on (at least) the work of:
-     Mike Burrows
-     David Wheeler
-     Peter Fenwick
-     Alistair Moffat
-     Radford Neal
-     Ian H. Witten
-     Robert Sedgewick
-     Jon L. Bentley
-
-  For more information on these sources, see the manual.
---*/
-
-
-/*----------------------------------------------------*/
-/*--- IMPORTANT                                    ---*/
-/*----------------------------------------------------*/
-
-/*--
-   WARNING:
-      This program and library (attempts to) compress data by 
-      performing several non-trivial transformations on it.  
-      Unless you are 100% familiar with *all* the algorithms 
-      contained herein, and with the consequences of modifying them, 
-      you should NOT meddle with the compression or decompression 
-      machinery.  Incorrect changes can and very likely *will* 
-      lead to disasterous loss of data.
-
-   DISCLAIMER:
-      I TAKE NO RESPONSIBILITY FOR ANY LOSS OF DATA ARISING FROM THE
-      USE OF THIS PROGRAM, HOWSOEVER CAUSED.
-
-      Every compression of a file implies an assumption that the
-      compressed file can be decompressed to reproduce the original.
-      Great efforts in design, coding and testing have been made to
-      ensure that this program works correctly.  However, the
-      complexity of the algorithms, and, in particular, the presence
-      of various special cases in the code which occur with very low
-      but non-zero probability make it impossible to rule out the
-      possibility of bugs remaining in the program.  DO NOT COMPRESS
-      ANY DATA WITH THIS PROGRAM AND/OR LIBRARY UNLESS YOU ARE PREPARED 
-      TO ACCEPT THE POSSIBILITY, HOWEVER SMALL, THAT THE DATA WILL 
-      NOT BE RECOVERABLE.
-
-      That is not to say this program is inherently unreliable.
-      Indeed, I very much hope the opposite is true.  bzip2/libbzip2
-      has been carefully constructed and extensively tested.
-
-   PATENTS:
-      To the best of my knowledge, bzip2/libbzip2 does not use any 
-      patented algorithms.  However, I do not have the resources 
-      available to carry out a full patent search.  Therefore I cannot 
-      give any guarantee of the above statement.
---*/
-
-
-
-/*----------------------------------------------------*/
-/*--- and now for something much more pleasant :-) ---*/
-/*----------------------------------------------------*/
-
-/*---------------------------------------------*/
-/*--
-  Place a 1 beside your platform, and 0 elsewhere.
---*/
-
-/*--
-  Generic 32-bit Unix.
-  Also works on 64-bit Unix boxes.
-  This is the default.
---*/
-#define BZ_UNIX      1
-
-/*--
-  Win32, as seen by Jacob Navia's excellent
-  port of (Chris Fraser & David Hanson)'s excellent
-  lcc compiler.  Or with MS Visual C.
-  This is selected automatically if compiled by a compiler which
-  defines _WIN32, not including the Cygwin GCC.
---*/
-#define BZ_LCCWIN32  0
-
-#if defined(_WIN32) && !defined(__CYGWIN__)
-#undef  BZ_LCCWIN32
-#define BZ_LCCWIN32 1
-#undef  BZ_UNIX
-#define BZ_UNIX 0
-#endif
-
-
-/*---------------------------------------------*/
-/*--
-  Some stuff for all platforms.
---*/
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include "bzlib.h"
-
-#define ERROR_IF_EOF(i)       { if ((i) == EOF)  ioError(); }
-#define ERROR_IF_NOT_ZERO(i)  { if ((i) != 0)    ioError(); }
-#define ERROR_IF_MINUS_ONE(i) { if ((i) == (-1)) ioError(); }
-
-
-/*---------------------------------------------*/
-/*--
-   Platform-specific stuff.
---*/
-
-#if BZ_UNIX
-#   include 
-#   include 
-#   include 
-#   include 
-#   include 
-#   include 
-
-#   define PATH_SEP    '/'
-#   define MY_LSTAT    lstat
-#   define MY_STAT     stat
-#   define MY_S_ISREG  S_ISREG
-#   define MY_S_ISDIR  S_ISDIR
-
-#   define APPEND_FILESPEC(root, name) \
-      root=snocString((root), (name))
-
-#   define APPEND_FLAG(root, name) \
-      root=snocString((root), (name))
-
-#   define SET_BINARY_MODE(fd) /**/
-
-#   ifdef __GNUC__
-#      define NORETURN __attribute__ ((noreturn))
-#   else
-#      define NORETURN /**/
-#   endif
-
-#   ifdef __DJGPP__
-#     include 
-#     include 
-#     undef MY_LSTAT
-#     undef MY_STAT
-#     define MY_LSTAT stat
-#     define MY_STAT stat
-#     undef SET_BINARY_MODE
-#     define SET_BINARY_MODE(fd)                        \
-        do {                                            \
-           int retVal = setmode ( fileno ( fd ),        \
-                                  O_BINARY );           \
-           ERROR_IF_MINUS_ONE ( retVal );               \
-        } while ( 0 )
-#   endif
-
-#   ifdef __CYGWIN__
-#     include 
-#     include 
-#     undef SET_BINARY_MODE
-#     define SET_BINARY_MODE(fd)                        \
-        do {                                            \
-           int retVal = setmode ( fileno ( fd ),        \
-                                  O_BINARY );           \
-           ERROR_IF_MINUS_ONE ( retVal );               \
-        } while ( 0 )
-#   endif
-#endif /* BZ_UNIX */
-
-
-
-#if BZ_LCCWIN32
-#   include 
-#   include 
-#   include 
-
-#   define NORETURN       /**/
-#   define PATH_SEP       '\\'
-#   define MY_LSTAT       _stat
-#   define MY_STAT        _stat
-#   define MY_S_ISREG(x)  ((x) & _S_IFREG)
-#   define MY_S_ISDIR(x)  ((x) & _S_IFDIR)
-
-#   define APPEND_FLAG(root, name) \
-      root=snocString((root), (name))
-
-#   define APPEND_FILESPEC(root, name)                \
-      root = snocString ((root), (name))
-
-#   define SET_BINARY_MODE(fd)                        \
-      do {                                            \
-         int retVal = setmode ( fileno ( fd ),        \
-                                O_BINARY );           \
-         ERROR_IF_MINUS_ONE ( retVal );               \
-      } while ( 0 )
-
-#endif /* BZ_LCCWIN32 */
-
-
-/*---------------------------------------------*/
-/*--
-  Some more stuff for all platforms :-)
---*/
-
-typedef char            Char;
-typedef unsigned char   Bool;
-typedef unsigned char   UChar;
-typedef int             Int32;
-typedef unsigned int    UInt32;
-typedef short           Int16;
-typedef unsigned short  UInt16;
-                                       
-#define True  ((Bool)1)
-#define False ((Bool)0)
-
-/*--
-  IntNative is your platform's `native' int size.
-  Only here to avoid probs with 64-bit platforms.
---*/
-typedef int IntNative;
-
-
-/*---------------------------------------------------*/
-/*--- Misc (file handling) data decls             ---*/
-/*---------------------------------------------------*/
-
-Int32   verbosity;
-Bool    keepInputFiles, smallMode, deleteOutputOnInterrupt;
-Bool    forceOverwrite, testFailsExist, unzFailsExist, noisy;
-Int32   numFileNames, numFilesProcessed, blockSize100k;
-Int32   exitValue;
-
-/*-- source modes; F==file, I==stdin, O==stdout --*/
-#define SM_I2O           1
-#define SM_F2O           2
-#define SM_F2F           3
-
-/*-- operation modes --*/
-#define OM_Z             1
-#define OM_UNZ           2
-#define OM_TEST          3
-
-Int32   opMode;
-Int32   srcMode;
-
-#define FILE_NAME_LEN 1034
-
-Int32   longestFileName;
-Char    inName [FILE_NAME_LEN];
-Char    outName[FILE_NAME_LEN];
-Char    tmpName[FILE_NAME_LEN];
-Char    *progName;
-Char    progNameReally[FILE_NAME_LEN];
-FILE    *outputHandleJustInCase;
-Int32   workFactor;
-
-static void    panic                 ( Char* )   NORETURN;
-static void    ioError               ( void )    NORETURN;
-static void    outOfMemory           ( void )    NORETURN;
-static void    configError           ( void )    NORETURN;
-static void    crcError              ( void )    NORETURN;
-static void    cleanUpAndFail        ( Int32 )   NORETURN;
-static void    compressedStreamEOF   ( void )    NORETURN;
-
-static void    copyFileName ( Char*, Char* );
-static void*   myMalloc     ( Int32 );
-
-
-
-/*---------------------------------------------------*/
-/*--- An implementation of 64-bit ints.  Sigh.    ---*/
-/*--- Roll on widespread deployment of ANSI C9X ! ---*/
-/*---------------------------------------------------*/
-
-typedef
-   struct { UChar b[8]; } 
-   UInt64;
-
-
-static
-void uInt64_from_UInt32s ( UInt64* n, UInt32 lo32, UInt32 hi32 )
-{
-   n->b[7] = (UChar)((hi32 >> 24) & 0xFF);
-   n->b[6] = (UChar)((hi32 >> 16) & 0xFF);
-   n->b[5] = (UChar)((hi32 >> 8)  & 0xFF);
-   n->b[4] = (UChar) (hi32        & 0xFF);
-   n->b[3] = (UChar)((lo32 >> 24) & 0xFF);
-   n->b[2] = (UChar)((lo32 >> 16) & 0xFF);
-   n->b[1] = (UChar)((lo32 >> 8)  & 0xFF);
-   n->b[0] = (UChar) (lo32        & 0xFF);
-}
-
-
-static
-double uInt64_to_double ( UInt64* n )
-{
-   Int32  i;
-   double base = 1.0;
-   double sum  = 0.0;
-   for (i = 0; i < 8; i++) {
-      sum  += base * (double)(n->b[i]);
-      base *= 256.0;
-   }
-   return sum;
-}
-
-
-static
-Bool uInt64_isZero ( UInt64* n )
-{
-   Int32 i;
-   for (i = 0; i < 8; i++)
-      if (n->b[i] != 0) return 0;
-   return 1;
-}
-
-
-/* Divide *n by 10, and return the remainder.  */
-static 
-Int32 uInt64_qrm10 ( UInt64* n )
-{
-   UInt32 rem, tmp;
-   Int32  i;
-   rem = 0;
-   for (i = 7; i >= 0; i--) {
-      tmp = rem * 256 + n->b[i];
-      n->b[i] = tmp / 10;
-      rem = tmp % 10;
-   }
-   return rem;
-}
-
-
-/* ... and the Whole Entire Point of all this UInt64 stuff is
-   so that we can supply the following function.
-*/
-static
-void uInt64_toAscii ( char* outbuf, UInt64* n )
-{
-   Int32  i, q;
-   UChar  buf[32];
-   Int32  nBuf   = 0;
-   UInt64 n_copy = *n;
-   do {
-      q = uInt64_qrm10 ( &n_copy );
-      buf[nBuf] = q + '0';
-      nBuf++;
-   } while (!uInt64_isZero(&n_copy));
-   outbuf[nBuf] = 0;
-   for (i = 0; i < nBuf; i++) 
-      outbuf[i] = buf[nBuf-i-1];
-}
-
-
-/*---------------------------------------------------*/
-/*--- Processing of complete files and streams    ---*/
-/*---------------------------------------------------*/
-
-/*---------------------------------------------*/
-static 
-Bool myfeof ( FILE* f )
-{
-   Int32 c = fgetc ( f );
-   if (c == EOF) return True;
-   ungetc ( c, f );
-   return False;
-}
-
-
-/*---------------------------------------------*/
-static 
-void compressStream ( FILE *stream, FILE *zStream )
-{
-   BZFILE* bzf = NULL;
-   UChar   ibuf[5000];
-   Int32   nIbuf;
-   UInt32  nbytes_in_lo32, nbytes_in_hi32;
-   UInt32  nbytes_out_lo32, nbytes_out_hi32;
-   Int32   bzerr, bzerr_dummy, ret;
-
-   SET_BINARY_MODE(stream);
-   SET_BINARY_MODE(zStream);
-
-   if (ferror(stream)) goto errhandler_io;
-   if (ferror(zStream)) goto errhandler_io;
-
-   bzf = BZ2_bzWriteOpen ( &bzerr, zStream, 
-                           blockSize100k, verbosity, workFactor );   
-   if (bzerr != BZ_OK) goto errhandler;
-
-   if (verbosity >= 2) fprintf ( stderr, "\n" );
-
-   while (True) {
-
-      if (myfeof(stream)) break;
-      nIbuf = fread ( ibuf, sizeof(UChar), 5000, stream );
-      if (ferror(stream)) goto errhandler_io;
-      if (nIbuf > 0) BZ2_bzWrite ( &bzerr, bzf, (void*)ibuf, nIbuf );
-      if (bzerr != BZ_OK) goto errhandler;
-
-   }
-
-   BZ2_bzWriteClose64 ( &bzerr, bzf, 0, 
-                        &nbytes_in_lo32, &nbytes_in_hi32,
-                        &nbytes_out_lo32, &nbytes_out_hi32 );
-   if (bzerr != BZ_OK) goto errhandler;
-
-   if (ferror(zStream)) goto errhandler_io;
-   ret = fflush ( zStream );
-   if (ret == EOF) goto errhandler_io;
-   if (zStream != stdout) {
-      ret = fclose ( zStream );
-      outputHandleJustInCase = NULL;
-      if (ret == EOF) goto errhandler_io;
-   }
-   outputHandleJustInCase = NULL;
-   if (ferror(stream)) goto errhandler_io;
-   ret = fclose ( stream );
-   if (ret == EOF) goto errhandler_io;
-
-   if (verbosity >= 1) {
-      if (nbytes_in_lo32 == 0 && nbytes_in_hi32 == 0) {
-	 fprintf ( stderr, " no data compressed.\n");
-      } else {
-	 Char   buf_nin[32], buf_nout[32];
-	 UInt64 nbytes_in,   nbytes_out;
-	 double nbytes_in_d, nbytes_out_d;
-	 uInt64_from_UInt32s ( &nbytes_in, 
-			       nbytes_in_lo32, nbytes_in_hi32 );
-	 uInt64_from_UInt32s ( &nbytes_out, 
-			       nbytes_out_lo32, nbytes_out_hi32 );
-	 nbytes_in_d  = uInt64_to_double ( &nbytes_in );
-	 nbytes_out_d = uInt64_to_double ( &nbytes_out );
-	 uInt64_toAscii ( buf_nin, &nbytes_in );
-	 uInt64_toAscii ( buf_nout, &nbytes_out );
-	 fprintf ( stderr, "%6.3f:1, %6.3f bits/byte, "
-		   "%5.2f%% saved, %s in, %s out.\n",
-		   nbytes_in_d / nbytes_out_d,
-		   (8.0 * nbytes_out_d) / nbytes_in_d,
-		   100.0 * (1.0 - nbytes_out_d / nbytes_in_d),
-		   buf_nin,
-		   buf_nout
-		 );
-      }
-   }
-
-   return;
-
-   errhandler:
-   BZ2_bzWriteClose64 ( &bzerr_dummy, bzf, 1, 
-                        &nbytes_in_lo32, &nbytes_in_hi32,
-                        &nbytes_out_lo32, &nbytes_out_hi32 );
-   switch (bzerr) {
-      case BZ_CONFIG_ERROR:
-         configError(); break;
-      case BZ_MEM_ERROR:
-         outOfMemory (); break;
-      case BZ_IO_ERROR:
-         errhandler_io:
-         ioError(); break;
-      default:
-         panic ( "compress:unexpected error" );
-   }
-
-   panic ( "compress:end" );
-   /*notreached*/
-}
-
-
-
-/*---------------------------------------------*/
-static 
-Bool uncompressStream ( FILE *zStream, FILE *stream )
-{
-   BZFILE* bzf = NULL;
-   Int32   bzerr, bzerr_dummy, ret, nread, streamNo, i;
-   UChar   obuf[5000];
-   UChar   unused[BZ_MAX_UNUSED];
-   Int32   nUnused;
-   void*   unusedTmpV;
-   UChar*  unusedTmp;
-
-   nUnused = 0;
-   streamNo = 0;
-
-   SET_BINARY_MODE(stream);
-   SET_BINARY_MODE(zStream);
-
-   if (ferror(stream)) goto errhandler_io;
-   if (ferror(zStream)) goto errhandler_io;
-
-   while (True) {
-
-      bzf = BZ2_bzReadOpen ( 
-               &bzerr, zStream, verbosity, 
-               (int)smallMode, unused, nUnused
-            );
-      if (bzf == NULL || bzerr != BZ_OK) goto errhandler;
-      streamNo++;
-
-      while (bzerr == BZ_OK) {
-         nread = BZ2_bzRead ( &bzerr, bzf, obuf, 5000 );
-         if (bzerr == BZ_DATA_ERROR_MAGIC) goto trycat;
-         if ((bzerr == BZ_OK || bzerr == BZ_STREAM_END) && nread > 0)
-            fwrite ( obuf, sizeof(UChar), nread, stream );
-         if (ferror(stream)) goto errhandler_io;
-      }
-      if (bzerr != BZ_STREAM_END) goto errhandler;
-
-      BZ2_bzReadGetUnused ( &bzerr, bzf, &unusedTmpV, &nUnused );
-      if (bzerr != BZ_OK) panic ( "decompress:bzReadGetUnused" );
-
-      unusedTmp = (UChar*)unusedTmpV;
-      for (i = 0; i < nUnused; i++) unused[i] = unusedTmp[i];
-
-      BZ2_bzReadClose ( &bzerr, bzf );
-      if (bzerr != BZ_OK) panic ( "decompress:bzReadGetUnused" );
-
-      if (nUnused == 0 && myfeof(zStream)) break;
-   }
-
-   closeok:
-   if (ferror(zStream)) goto errhandler_io;
-   ret = fclose ( zStream );
-   if (ret == EOF) goto errhandler_io;
-
-   if (ferror(stream)) goto errhandler_io;
-   ret = fflush ( stream );
-   if (ret != 0) goto errhandler_io;
-   if (stream != stdout) {
-      ret = fclose ( stream );
-      outputHandleJustInCase = NULL;
-      if (ret == EOF) goto errhandler_io;
-   }
-   outputHandleJustInCase = NULL;
-   if (verbosity >= 2) fprintf ( stderr, "\n    " );
-   return True;
-
-   trycat: 
-   if (forceOverwrite) {
-      rewind(zStream);
-      while (True) {
-      	 if (myfeof(zStream)) break;
-      	 nread = fread ( obuf, sizeof(UChar), 5000, zStream );
-      	 if (ferror(zStream)) goto errhandler_io;
-      	 if (nread > 0) fwrite ( obuf, sizeof(UChar), nread, stream );
-      	 if (ferror(stream)) goto errhandler_io;
-      }
-      goto closeok;
-   }
-  
-   errhandler:
-   BZ2_bzReadClose ( &bzerr_dummy, bzf );
-   switch (bzerr) {
-      case BZ_CONFIG_ERROR:
-         configError(); break;
-      case BZ_IO_ERROR:
-         errhandler_io:
-         ioError(); break;
-      case BZ_DATA_ERROR:
-         crcError();
-      case BZ_MEM_ERROR:
-         outOfMemory();
-      case BZ_UNEXPECTED_EOF:
-         compressedStreamEOF();
-      case BZ_DATA_ERROR_MAGIC:
-         if (zStream != stdin) fclose(zStream);
-         if (stream != stdout) fclose(stream);
-         if (streamNo == 1) {
-            return False;
-         } else {
-            if (noisy)
-            fprintf ( stderr, 
-                      "\n%s: %s: trailing garbage after EOF ignored\n",
-                      progName, inName );
-            return True;       
-         }
-      default:
-         panic ( "decompress:unexpected error" );
-   }
-
-   panic ( "decompress:end" );
-   return True; /*notreached*/
-}
-
-
-/*---------------------------------------------*/
-static 
-Bool testStream ( FILE *zStream )
-{
-   BZFILE* bzf = NULL;
-   Int32   bzerr, bzerr_dummy, ret, nread, streamNo, i;
-   UChar   obuf[5000];
-   UChar   unused[BZ_MAX_UNUSED];
-   Int32   nUnused;
-   void*   unusedTmpV;
-   UChar*  unusedTmp;
-
-   nUnused = 0;
-   streamNo = 0;
-
-   SET_BINARY_MODE(zStream);
-   if (ferror(zStream)) goto errhandler_io;
-
-   while (True) {
-
-      bzf = BZ2_bzReadOpen ( 
-               &bzerr, zStream, verbosity, 
-               (int)smallMode, unused, nUnused
-            );
-      if (bzf == NULL || bzerr != BZ_OK) goto errhandler;
-      streamNo++;
-
-      while (bzerr == BZ_OK) {
-         nread = BZ2_bzRead ( &bzerr, bzf, obuf, 5000 );
-         if (bzerr == BZ_DATA_ERROR_MAGIC) goto errhandler;
-      }
-      if (bzerr != BZ_STREAM_END) goto errhandler;
-
-      BZ2_bzReadGetUnused ( &bzerr, bzf, &unusedTmpV, &nUnused );
-      if (bzerr != BZ_OK) panic ( "test:bzReadGetUnused" );
-
-      unusedTmp = (UChar*)unusedTmpV;
-      for (i = 0; i < nUnused; i++) unused[i] = unusedTmp[i];
-
-      BZ2_bzReadClose ( &bzerr, bzf );
-      if (bzerr != BZ_OK) panic ( "test:bzReadGetUnused" );
-      if (nUnused == 0 && myfeof(zStream)) break;
-
-   }
-
-   if (ferror(zStream)) goto errhandler_io;
-   ret = fclose ( zStream );
-   if (ret == EOF) goto errhandler_io;
-
-   if (verbosity >= 2) fprintf ( stderr, "\n    " );
-   return True;
-
-   errhandler:
-   BZ2_bzReadClose ( &bzerr_dummy, bzf );
-   if (verbosity == 0) 
-      fprintf ( stderr, "%s: %s: ", progName, inName );
-   switch (bzerr) {
-      case BZ_CONFIG_ERROR:
-         configError(); break;
-      case BZ_IO_ERROR:
-         errhandler_io:
-         ioError(); break;
-      case BZ_DATA_ERROR:
-         fprintf ( stderr,
-                   "data integrity (CRC) error in data\n" );
-         return False;
-      case BZ_MEM_ERROR:
-         outOfMemory();
-      case BZ_UNEXPECTED_EOF:
-         fprintf ( stderr,
-                   "file ends unexpectedly\n" );
-         return False;
-      case BZ_DATA_ERROR_MAGIC:
-         if (zStream != stdin) fclose(zStream);
-         if (streamNo == 1) {
-          fprintf ( stderr, 
-                    "bad magic number (file not created by bzip2)\n" );
-            return False;
-         } else {
-            if (noisy)
-            fprintf ( stderr, 
-                      "trailing garbage after EOF ignored\n" );
-            return True;       
-         }
-      default:
-         panic ( "test:unexpected error" );
-   }
-
-   panic ( "test:end" );
-   return True; /*notreached*/
-}
-
-
-/*---------------------------------------------------*/
-/*--- Error [non-] handling grunge                ---*/
-/*---------------------------------------------------*/
-
-/*---------------------------------------------*/
-static
-void setExit ( Int32 v )
-{
-   if (v > exitValue) exitValue = v;
-}
-
-
-/*---------------------------------------------*/
-static 
-void cadvise ( void )
-{
-   if (noisy)
-   fprintf (
-      stderr,
-      "\nIt is possible that the compressed file(s) have become corrupted.\n"
-        "You can use the -tvv option to test integrity of such files.\n\n"
-        "You can use the `bzip2recover' program to attempt to recover\n"
-        "data from undamaged sections of corrupted files.\n\n"
-    );
-}
-
-
-/*---------------------------------------------*/
-static 
-void showFileNames ( void )
-{
-   if (noisy)
-   fprintf (
-      stderr,
-      "\tInput file = %s, output file = %s\n",
-      inName, outName 
-   );
-}
-
-
-/*---------------------------------------------*/
-static 
-void cleanUpAndFail ( Int32 ec )
-{
-   IntNative      retVal;
-   struct MY_STAT statBuf;
-
-   if ( srcMode == SM_F2F 
-        && opMode != OM_TEST
-        && deleteOutputOnInterrupt ) {
-
-      /* Check whether input file still exists.  Delete output file
-         only if input exists to avoid loss of data.  Joerg Prante, 5
-         January 2002.  (JRS 06-Jan-2002: other changes in 1.0.2 mean
-         this is less likely to happen.  But to be ultra-paranoid, we
-         do the check anyway.)  */
-      retVal = MY_STAT ( inName, &statBuf );
-      if (retVal == 0) {
-         if (noisy)
-            fprintf ( stderr, 
-                      "%s: Deleting output file %s, if it exists.\n",
-                      progName, outName );
-         if (outputHandleJustInCase != NULL)
-            fclose ( outputHandleJustInCase );
-         retVal = remove ( outName );
-         if (retVal != 0)
-            fprintf ( stderr,
-                      "%s: WARNING: deletion of output file "
-                      "(apparently) failed.\n",
-                      progName );
-      } else {
-         fprintf ( stderr,
-                   "%s: WARNING: deletion of output file suppressed\n",
-                    progName );
-         fprintf ( stderr,
-                   "%s:    since input file no longer exists.  Output file\n",
-                   progName );
-         fprintf ( stderr,
-                   "%s:    `%s' may be incomplete.\n",
-                   progName, outName );
-         fprintf ( stderr, 
-                   "%s:    I suggest doing an integrity test (bzip2 -tv)"
-                   " of it.\n",
-                   progName );
-      }
-   }
-
-   if (noisy && numFileNames > 0 && numFilesProcessed < numFileNames) {
-      fprintf ( stderr, 
-                "%s: WARNING: some files have not been processed:\n"
-                "%s:    %d specified on command line, %d not processed yet.\n\n",
-                progName, progName,
-                numFileNames, numFileNames - numFilesProcessed );
-   }
-   setExit(ec);
-   exit(exitValue);
-}
-
-
-/*---------------------------------------------*/
-static 
-void panic ( Char* s )
-{
-   fprintf ( stderr,
-             "\n%s: PANIC -- internal consistency error:\n"
-             "\t%s\n"
-             "\tThis is a BUG.  Please report it to me at:\n"
-             "\tjseward@bzip.org\n",
-             progName, s );
-   showFileNames();
-   cleanUpAndFail( 3 );
-}
-
-
-/*---------------------------------------------*/
-static 
-void crcError ( void )
-{
-   fprintf ( stderr,
-             "\n%s: Data integrity error when decompressing.\n",
-             progName );
-   showFileNames();
-   cadvise();
-   cleanUpAndFail( 2 );
-}
-
-
-/*---------------------------------------------*/
-static 
-void compressedStreamEOF ( void )
-{
-  if (noisy) {
-    fprintf ( stderr,
-	      "\n%s: Compressed file ends unexpectedly;\n\t"
-	      "perhaps it is corrupted?  *Possible* reason follows.\n",
-	      progName );
-    perror ( progName );
-    showFileNames();
-    cadvise();
-  }
-  cleanUpAndFail( 2 );
-}
-
-
-/*---------------------------------------------*/
-static 
-void ioError ( void )
-{
-   fprintf ( stderr,
-             "\n%s: I/O or other error, bailing out.  "
-             "Possible reason follows.\n",
-             progName );
-   perror ( progName );
-   showFileNames();
-   cleanUpAndFail( 1 );
-}
-
-
-/*---------------------------------------------*/
-static 
-void mySignalCatcher ( IntNative n )
-{
-   fprintf ( stderr,
-             "\n%s: Control-C or similar caught, quitting.\n",
-             progName );
-   cleanUpAndFail(1);
-}
-
-
-/*---------------------------------------------*/
-static 
-void mySIGSEGVorSIGBUScatcher ( IntNative n )
-{
-   if (opMode == OM_Z)
-      fprintf ( 
-      stderr,
-      "\n%s: Caught a SIGSEGV or SIGBUS whilst compressing.\n"
-      "\n"
-      "   Possible causes are (most likely first):\n"
-      "   (1) This computer has unreliable memory or cache hardware\n"
-      "       (a surprisingly common problem; try a different machine.)\n"
-      "   (2) A bug in the compiler used to create this executable\n"
-      "       (unlikely, if you didn't compile bzip2 yourself.)\n"
-      "   (3) A real bug in bzip2 -- I hope this should never be the case.\n"
-      "   The user's manual, Section 4.3, has more info on (1) and (2).\n"
-      "   \n"
-      "   If you suspect this is a bug in bzip2, or are unsure about (1)\n"
-      "   or (2), feel free to report it to me at: jseward@bzip.org.\n"
-      "   Section 4.3 of the user's manual describes the info a useful\n"
-      "   bug report should have.  If the manual is available on your\n"
-      "   system, please try and read it before mailing me.  If you don't\n"
-      "   have the manual or can't be bothered to read it, mail me anyway.\n"
-      "\n",
-      progName );
-      else
-      fprintf ( 
-      stderr,
-      "\n%s: Caught a SIGSEGV or SIGBUS whilst decompressing.\n"
-      "\n"
-      "   Possible causes are (most likely first):\n"
-      "   (1) The compressed data is corrupted, and bzip2's usual checks\n"
-      "       failed to detect this.  Try bzip2 -tvv my_file.bz2.\n"
-      "   (2) This computer has unreliable memory or cache hardware\n"
-      "       (a surprisingly common problem; try a different machine.)\n"
-      "   (3) A bug in the compiler used to create this executable\n"
-      "       (unlikely, if you didn't compile bzip2 yourself.)\n"
-      "   (4) A real bug in bzip2 -- I hope this should never be the case.\n"
-      "   The user's manual, Section 4.3, has more info on (2) and (3).\n"
-      "   \n"
-      "   If you suspect this is a bug in bzip2, or are unsure about (2)\n"
-      "   or (3), feel free to report it to me at: jseward@bzip.org.\n"
-      "   Section 4.3 of the user's manual describes the info a useful\n"
-      "   bug report should have.  If the manual is available on your\n"
-      "   system, please try and read it before mailing me.  If you don't\n"
-      "   have the manual or can't be bothered to read it, mail me anyway.\n"
-      "\n",
-      progName );
-
-   showFileNames();
-   if (opMode == OM_Z)
-      cleanUpAndFail( 3 ); else
-      { cadvise(); cleanUpAndFail( 2 ); }
-}
-
-
-/*---------------------------------------------*/
-static 
-void outOfMemory ( void )
-{
-   fprintf ( stderr,
-             "\n%s: couldn't allocate enough memory\n",
-             progName );
-   showFileNames();
-   cleanUpAndFail(1);
-}
-
-
-/*---------------------------------------------*/
-static 
-void configError ( void )
-{
-   fprintf ( stderr,
-             "bzip2: I'm not configured correctly for this platform!\n"
-             "\tI require Int32, Int16 and Char to have sizes\n"
-             "\tof 4, 2 and 1 bytes to run properly, and they don't.\n"
-             "\tProbably you can fix this by defining them correctly,\n"
-             "\tand recompiling.  Bye!\n" );
-   setExit(3);
-   exit(exitValue);
-}
-
-
-/*---------------------------------------------------*/
-/*--- The main driver machinery                   ---*/
-/*---------------------------------------------------*/
-
-/* All rather crufty.  The main problem is that input files
-   are stat()d multiple times before use.  This should be
-   cleaned up. 
-*/
-
-/*---------------------------------------------*/
-static 
-void pad ( Char *s )
-{
-   Int32 i;
-   if ( (Int32)strlen(s) >= longestFileName ) return;
-   for (i = 1; i <= longestFileName - (Int32)strlen(s); i++)
-      fprintf ( stderr, " " );
-}
-
-
-/*---------------------------------------------*/
-static 
-void copyFileName ( Char* to, Char* from ) 
-{
-   if ( strlen(from) > FILE_NAME_LEN-10 )  {
-      fprintf (
-         stderr,
-         "bzip2: file name\n`%s'\n"
-         "is suspiciously (more than %d chars) long.\n"
-         "Try using a reasonable file name instead.  Sorry! :-)\n",
-         from, FILE_NAME_LEN-10
-      );
-      setExit(1);
-      exit(exitValue);
-   }
-
-  strncpy(to,from,FILE_NAME_LEN-10);
-  to[FILE_NAME_LEN-10]='\0';
-}
-
-
-/*---------------------------------------------*/
-static 
-Bool fileExists ( Char* name )
-{
-   FILE *tmp   = fopen ( name, "rb" );
-   Bool exists = (tmp != NULL);
-   if (tmp != NULL) fclose ( tmp );
-   return exists;
-}
-
-
-/*---------------------------------------------*/
-/* Open an output file safely with O_EXCL and good permissions.
-   This avoids a race condition in versions < 1.0.2, in which
-   the file was first opened and then had its interim permissions
-   set safely.  We instead use open() to create the file with
-   the interim permissions required. (--- --- rw-).
-
-   For non-Unix platforms, if we are not worrying about
-   security issues, simple this simply behaves like fopen.
-*/
-FILE* fopen_output_safely ( Char* name, const char* mode )
-{
-#  if BZ_UNIX
-   FILE*     fp;
-   IntNative fh;
-   fh = open(name, O_WRONLY|O_CREAT|O_EXCL, S_IWUSR|S_IRUSR);
-   if (fh == -1) return NULL;
-   fp = fdopen(fh, mode);
-   if (fp == NULL) close(fh);
-   return fp;
-#  else
-   return fopen(name, mode);
-#  endif
-}
-
-
-/*---------------------------------------------*/
-/*--
-  if in doubt, return True
---*/
-static 
-Bool notAStandardFile ( Char* name )
-{
-   IntNative      i;
-   struct MY_STAT statBuf;
-
-   i = MY_LSTAT ( name, &statBuf );
-   if (i != 0) return True;
-   if (MY_S_ISREG(statBuf.st_mode)) return False;
-   return True;
-}
-
-
-/*---------------------------------------------*/
-/*--
-  rac 11/21/98 see if file has hard links to it
---*/
-static 
-Int32 countHardLinks ( Char* name )
-{  
-   IntNative      i;
-   struct MY_STAT statBuf;
-
-   i = MY_LSTAT ( name, &statBuf );
-   if (i != 0) return 0;
-   return (statBuf.st_nlink - 1);
-}
-
-
-/*---------------------------------------------*/
-/* Copy modification date, access date, permissions and owner from the
-   source to destination file.  We have to copy this meta-info off
-   into fileMetaInfo before starting to compress / decompress it,
-   because doing it afterwards means we get the wrong access time.
-
-   To complicate matters, in compress() and decompress() below, the
-   sequence of tests preceding the call to saveInputFileMetaInfo()
-   involves calling fileExists(), which in turn establishes its result
-   by attempting to fopen() the file, and if successful, immediately
-   fclose()ing it again.  So we have to assume that the fopen() call
-   does not cause the access time field to be updated.
-
-   Reading of the man page for stat() (man 2 stat) on RedHat 7.2 seems
-   to imply that merely doing open() will not affect the access time.
-   Therefore we merely need to hope that the C library only does
-   open() as a result of fopen(), and not any kind of read()-ahead
-   cleverness.
-
-   It sounds pretty fragile to me.  Whether this carries across
-   robustly to arbitrary Unix-like platforms (or even works robustly
-   on this one, RedHat 7.2) is unknown to me.  Nevertheless ...  
-*/
-#if BZ_UNIX
-static 
-struct MY_STAT fileMetaInfo;
-#endif
-
-static 
-void saveInputFileMetaInfo ( Char *srcName )
-{
-#  if BZ_UNIX
-   IntNative retVal;
-   /* Note use of stat here, not lstat. */
-   retVal = MY_STAT( srcName, &fileMetaInfo );
-   ERROR_IF_NOT_ZERO ( retVal );
-#  endif
-}
-
-
-static 
-void applySavedMetaInfoToOutputFile ( Char *dstName )
-{
-#  if BZ_UNIX
-   IntNative      retVal;
-   struct utimbuf uTimBuf;
-
-   uTimBuf.actime = fileMetaInfo.st_atime;
-   uTimBuf.modtime = fileMetaInfo.st_mtime;
-
-   retVal = chmod ( dstName, fileMetaInfo.st_mode );
-   ERROR_IF_NOT_ZERO ( retVal );
-
-   retVal = utime ( dstName, &uTimBuf );
-   ERROR_IF_NOT_ZERO ( retVal );
-
-   retVal = chown ( dstName, fileMetaInfo.st_uid, fileMetaInfo.st_gid );
-   /* chown() will in many cases return with EPERM, which can
-      be safely ignored.
-   */
-#  endif
-}
-
-
-/*---------------------------------------------*/
-static 
-Bool containsDubiousChars ( Char* name )
-{
-#  if BZ_UNIX
-   /* On unix, files can contain any characters and the file expansion
-    * is performed by the shell.
-    */
-   return False;
-#  else /* ! BZ_UNIX */
-   /* On non-unix (Win* platforms), wildcard characters are not allowed in 
-    * filenames.
-    */
-   for (; *name != '\0'; name++)
-      if (*name == '?' || *name == '*') return True;
-   return False;
-#  endif /* BZ_UNIX */
-}
-
-
-/*---------------------------------------------*/
-#define BZ_N_SUFFIX_PAIRS 4
-
-Char* zSuffix[BZ_N_SUFFIX_PAIRS] 
-   = { ".bz2", ".bz", ".tbz2", ".tbz" };
-Char* unzSuffix[BZ_N_SUFFIX_PAIRS] 
-   = { "", "", ".tar", ".tar" };
-
-static 
-Bool hasSuffix ( Char* s, Char* suffix )
-{
-   Int32 ns = strlen(s);
-   Int32 nx = strlen(suffix);
-   if (ns < nx) return False;
-   if (strcmp(s + ns - nx, suffix) == 0) return True;
-   return False;
-}
-
-static 
-Bool mapSuffix ( Char* name, 
-                 Char* oldSuffix, Char* newSuffix )
-{
-   if (!hasSuffix(name,oldSuffix)) return False;
-   name[strlen(name)-strlen(oldSuffix)] = 0;
-   strcat ( name, newSuffix );
-   return True;
-}
-
-
-/*---------------------------------------------*/
-static 
-void compress ( Char *name )
-{
-   FILE  *inStr;
-   FILE  *outStr;
-   Int32 n, i;
-   struct MY_STAT statBuf;
-
-   deleteOutputOnInterrupt = False;
-
-   if (name == NULL && srcMode != SM_I2O)
-      panic ( "compress: bad modes\n" );
-
-   switch (srcMode) {
-      case SM_I2O: 
-         copyFileName ( inName, "(stdin)" );
-         copyFileName ( outName, "(stdout)" ); 
-         break;
-      case SM_F2F: 
-         copyFileName ( inName, name );
-         copyFileName ( outName, name );
-         strcat ( outName, ".bz2" ); 
-         break;
-      case SM_F2O: 
-         copyFileName ( inName, name );
-         copyFileName ( outName, "(stdout)" ); 
-         break;
-   }
-
-   if ( srcMode != SM_I2O && containsDubiousChars ( inName ) ) {
-      if (noisy)
-      fprintf ( stderr, "%s: There are no files matching `%s'.\n",
-                progName, inName );
-      setExit(1);
-      return;
-   }
-   if ( srcMode != SM_I2O && !fileExists ( inName ) ) {
-      fprintf ( stderr, "%s: Can't open input file %s: %s.\n",
-                progName, inName, strerror(errno) );
-      setExit(1);
-      return;
-   }
-   for (i = 0; i < BZ_N_SUFFIX_PAIRS; i++) {
-      if (hasSuffix(inName, zSuffix[i])) {
-         if (noisy)
-         fprintf ( stderr, 
-                   "%s: Input file %s already has %s suffix.\n",
-                   progName, inName, zSuffix[i] );
-         setExit(1);
-         return;
-      }
-   }
-   if ( srcMode == SM_F2F || srcMode == SM_F2O ) {
-      MY_STAT(inName, &statBuf);
-      if ( MY_S_ISDIR(statBuf.st_mode) ) {
-         fprintf( stderr,
-                  "%s: Input file %s is a directory.\n",
-                  progName,inName);
-         setExit(1);
-         return;
-      }
-   }
-   if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( inName )) {
-      if (noisy)
-      fprintf ( stderr, "%s: Input file %s is not a normal file.\n",
-                progName, inName );
-      setExit(1);
-      return;
-   }
-   if ( srcMode == SM_F2F && fileExists ( outName ) ) {
-      if (forceOverwrite) {
-	 remove(outName);
-      } else {
-	 fprintf ( stderr, "%s: Output file %s already exists.\n",
-		   progName, outName );
-	 setExit(1);
-	 return;
-      }
-   }
-   if ( srcMode == SM_F2F && !forceOverwrite &&
-        (n=countHardLinks ( inName )) > 0) {
-      fprintf ( stderr, "%s: Input file %s has %d other link%s.\n",
-                progName, inName, n, n > 1 ? "s" : "" );
-      setExit(1);
-      return;
-   }
-
-   if ( srcMode == SM_F2F ) {
-      /* Save the file's meta-info before we open it.  Doing it later
-         means we mess up the access times. */
-      saveInputFileMetaInfo ( inName );
-   }
-
-   switch ( srcMode ) {
-
-      case SM_I2O:
-         inStr = stdin;
-         outStr = stdout;
-         if ( isatty ( fileno ( stdout ) ) ) {
-            fprintf ( stderr,
-                      "%s: I won't write compressed data to a terminal.\n",
-                      progName );
-            fprintf ( stderr, "%s: For help, type: `%s --help'.\n",
-                              progName, progName );
-            setExit(1);
-            return;
-         };
-         break;
-
-      case SM_F2O:
-         inStr = fopen ( inName, "rb" );
-         outStr = stdout;
-         if ( isatty ( fileno ( stdout ) ) ) {
-            fprintf ( stderr,
-                      "%s: I won't write compressed data to a terminal.\n",
-                      progName );
-            fprintf ( stderr, "%s: For help, type: `%s --help'.\n",
-                              progName, progName );
-            if ( inStr != NULL ) fclose ( inStr );
-            setExit(1);
-            return;
-         };
-         if ( inStr == NULL ) {
-            fprintf ( stderr, "%s: Can't open input file %s: %s.\n",
-                      progName, inName, strerror(errno) );
-            setExit(1);
-            return;
-         };
-         break;
-
-      case SM_F2F:
-         inStr = fopen ( inName, "rb" );
-         outStr = fopen_output_safely ( outName, "wb" );
-         if ( outStr == NULL) {
-            fprintf ( stderr, "%s: Can't create output file %s: %s.\n",
-                      progName, outName, strerror(errno) );
-            if ( inStr != NULL ) fclose ( inStr );
-            setExit(1);
-            return;
-         }
-         if ( inStr == NULL ) {
-            fprintf ( stderr, "%s: Can't open input file %s: %s.\n",
-                      progName, inName, strerror(errno) );
-            if ( outStr != NULL ) fclose ( outStr );
-            setExit(1);
-            return;
-         };
-         break;
-
-      default:
-         panic ( "compress: bad srcMode" );
-         break;
-   }
-
-   if (verbosity >= 1) {
-      fprintf ( stderr,  "  %s: ", inName );
-      pad ( inName );
-      fflush ( stderr );
-   }
-
-   /*--- Now the input and output handles are sane.  Do the Biz. ---*/
-   outputHandleJustInCase = outStr;
-   deleteOutputOnInterrupt = True;
-   compressStream ( inStr, outStr );
-   outputHandleJustInCase = NULL;
-
-   /*--- If there was an I/O error, we won't get here. ---*/
-   if ( srcMode == SM_F2F ) {
-      applySavedMetaInfoToOutputFile ( outName );
-      deleteOutputOnInterrupt = False;
-      if ( !keepInputFiles ) {
-         IntNative retVal = remove ( inName );
-         ERROR_IF_NOT_ZERO ( retVal );
-      }
-   }
-
-   deleteOutputOnInterrupt = False;
-}
-
-
-/*---------------------------------------------*/
-static 
-void uncompress ( Char *name )
-{
-   FILE  *inStr;
-   FILE  *outStr;
-   Int32 n, i;
-   Bool  magicNumberOK;
-   Bool  cantGuess;
-   struct MY_STAT statBuf;
-
-   deleteOutputOnInterrupt = False;
-
-   if (name == NULL && srcMode != SM_I2O)
-      panic ( "uncompress: bad modes\n" );
-
-   cantGuess = False;
-   switch (srcMode) {
-      case SM_I2O: 
-         copyFileName ( inName, "(stdin)" );
-         copyFileName ( outName, "(stdout)" ); 
-         break;
-      case SM_F2F: 
-         copyFileName ( inName, name );
-         copyFileName ( outName, name );
-         for (i = 0; i < BZ_N_SUFFIX_PAIRS; i++)
-            if (mapSuffix(outName,zSuffix[i],unzSuffix[i]))
-               goto zzz; 
-         cantGuess = True;
-         strcat ( outName, ".out" );
-         break;
-      case SM_F2O: 
-         copyFileName ( inName, name );
-         copyFileName ( outName, "(stdout)" ); 
-         break;
-   }
-
-   zzz:
-   if ( srcMode != SM_I2O && containsDubiousChars ( inName ) ) {
-      if (noisy)
-      fprintf ( stderr, "%s: There are no files matching `%s'.\n",
-                progName, inName );
-      setExit(1);
-      return;
-   }
-   if ( srcMode != SM_I2O && !fileExists ( inName ) ) {
-      fprintf ( stderr, "%s: Can't open input file %s: %s.\n",
-                progName, inName, strerror(errno) );
-      setExit(1);
-      return;
-   }
-   if ( srcMode == SM_F2F || srcMode == SM_F2O ) {
-      MY_STAT(inName, &statBuf);
-      if ( MY_S_ISDIR(statBuf.st_mode) ) {
-         fprintf( stderr,
-                  "%s: Input file %s is a directory.\n",
-                  progName,inName);
-         setExit(1);
-         return;
-      }
-   }
-   if ( srcMode == SM_F2F && !forceOverwrite && notAStandardFile ( inName )) {
-      if (noisy)
-      fprintf ( stderr, "%s: Input file %s is not a normal file.\n",
-                progName, inName );
-      setExit(1);
-      return;
-   }
-   if ( /* srcMode == SM_F2F implied && */ cantGuess ) {
-      if (noisy)
-      fprintf ( stderr, 
-                "%s: Can't guess original name for %s -- using %s\n",
-                progName, inName, outName );
-      /* just a warning, no return */
-   }   
-   if ( srcMode == SM_F2F && fileExists ( outName ) ) {
-      if (forceOverwrite) {
-	remove(outName);
-      } else {
-        fprintf ( stderr, "%s: Output file %s already exists.\n",
-                  progName, outName );
-        setExit(1);
-        return;
-      }
-   }
-   if ( srcMode == SM_F2F && !forceOverwrite &&
-        (n=countHardLinks ( inName ) ) > 0) {
-      fprintf ( stderr, "%s: Input file %s has %d other link%s.\n",
-                progName, inName, n, n > 1 ? "s" : "" );
-      setExit(1);
-      return;
-   }
-
-   if ( srcMode == SM_F2F ) {
-      /* Save the file's meta-info before we open it.  Doing it later
-         means we mess up the access times. */
-      saveInputFileMetaInfo ( inName );
-   }
-
-   switch ( srcMode ) {
-
-      case SM_I2O:
-         inStr = stdin;
-         outStr = stdout;
-         if ( isatty ( fileno ( stdin ) ) ) {
-            fprintf ( stderr,
-                      "%s: I won't read compressed data from a terminal.\n",
-                      progName );
-            fprintf ( stderr, "%s: For help, type: `%s --help'.\n",
-                              progName, progName );
-            setExit(1);
-            return;
-         };
-         break;
-
-      case SM_F2O:
-         inStr = fopen ( inName, "rb" );
-         outStr = stdout;
-         if ( inStr == NULL ) {
-            fprintf ( stderr, "%s: Can't open input file %s:%s.\n",
-                      progName, inName, strerror(errno) );
-            if ( inStr != NULL ) fclose ( inStr );
-            setExit(1);
-            return;
-         };
-         break;
-
-      case SM_F2F:
-         inStr = fopen ( inName, "rb" );
-         outStr = fopen_output_safely ( outName, "wb" );
-         if ( outStr == NULL) {
-            fprintf ( stderr, "%s: Can't create output file %s: %s.\n",
-                      progName, outName, strerror(errno) );
-            if ( inStr != NULL ) fclose ( inStr );
-            setExit(1);
-            return;
-         }
-         if ( inStr == NULL ) {
-            fprintf ( stderr, "%s: Can't open input file %s: %s.\n",
-                      progName, inName, strerror(errno) );
-            if ( outStr != NULL ) fclose ( outStr );
-            setExit(1);
-            return;
-         };
-         break;
-
-      default:
-         panic ( "uncompress: bad srcMode" );
-         break;
-   }
-
-   if (verbosity >= 1) {
-      fprintf ( stderr, "  %s: ", inName );
-      pad ( inName );
-      fflush ( stderr );
-   }
-
-   /*--- Now the input and output handles are sane.  Do the Biz. ---*/
-   outputHandleJustInCase = outStr;
-   deleteOutputOnInterrupt = True;
-   magicNumberOK = uncompressStream ( inStr, outStr );
-   outputHandleJustInCase = NULL;
-
-   /*--- If there was an I/O error, we won't get here. ---*/
-   if ( magicNumberOK ) {
-      if ( srcMode == SM_F2F ) {
-         applySavedMetaInfoToOutputFile ( outName );
-         deleteOutputOnInterrupt = False;
-         if ( !keepInputFiles ) {
-            IntNative retVal = remove ( inName );
-            ERROR_IF_NOT_ZERO ( retVal );
-         }
-      }
-   } else {
-      unzFailsExist = True;
-      deleteOutputOnInterrupt = False;
-      if ( srcMode == SM_F2F ) {
-         IntNative retVal = remove ( outName );
-         ERROR_IF_NOT_ZERO ( retVal );
-      }
-   }
-   deleteOutputOnInterrupt = False;
-
-   if ( magicNumberOK ) {
-      if (verbosity >= 1)
-         fprintf ( stderr, "done\n" );
-   } else {
-      setExit(2);
-      if (verbosity >= 1)
-         fprintf ( stderr, "not a bzip2 file.\n" ); else
-         fprintf ( stderr,
-                   "%s: %s is not a bzip2 file.\n",
-                   progName, inName );
-   }
-
-}
-
-
-/*---------------------------------------------*/
-static 
-void testf ( Char *name )
-{
-   FILE *inStr;
-   Bool allOK;
-   struct MY_STAT statBuf;
-
-   deleteOutputOnInterrupt = False;
-
-   if (name == NULL && srcMode != SM_I2O)
-      panic ( "testf: bad modes\n" );
-
-   copyFileName ( outName, "(none)" );
-   switch (srcMode) {
-      case SM_I2O: copyFileName ( inName, "(stdin)" ); break;
-      case SM_F2F: copyFileName ( inName, name ); break;
-      case SM_F2O: copyFileName ( inName, name ); break;
-   }
-
-   if ( srcMode != SM_I2O && containsDubiousChars ( inName ) ) {
-      if (noisy)
-      fprintf ( stderr, "%s: There are no files matching `%s'.\n",
-                progName, inName );
-      setExit(1);
-      return;
-   }
-   if ( srcMode != SM_I2O && !fileExists ( inName ) ) {
-      fprintf ( stderr, "%s: Can't open input %s: %s.\n",
-                progName, inName, strerror(errno) );
-      setExit(1);
-      return;
-   }
-   if ( srcMode != SM_I2O ) {
-      MY_STAT(inName, &statBuf);
-      if ( MY_S_ISDIR(statBuf.st_mode) ) {
-         fprintf( stderr,
-                  "%s: Input file %s is a directory.\n",
-                  progName,inName);
-         setExit(1);
-         return;
-      }
-   }
-
-   switch ( srcMode ) {
-
-      case SM_I2O:
-         if ( isatty ( fileno ( stdin ) ) ) {
-            fprintf ( stderr,
-                      "%s: I won't read compressed data from a terminal.\n",
-                      progName );
-            fprintf ( stderr, "%s: For help, type: `%s --help'.\n",
-                              progName, progName );
-            setExit(1);
-            return;
-         };
-         inStr = stdin;
-         break;
-
-      case SM_F2O: case SM_F2F:
-         inStr = fopen ( inName, "rb" );
-         if ( inStr == NULL ) {
-            fprintf ( stderr, "%s: Can't open input file %s:%s.\n",
-                      progName, inName, strerror(errno) );
-            setExit(1);
-            return;
-         };
-         break;
-
-      default:
-         panic ( "testf: bad srcMode" );
-         break;
-   }
-
-   if (verbosity >= 1) {
-      fprintf ( stderr, "  %s: ", inName );
-      pad ( inName );
-      fflush ( stderr );
-   }
-
-   /*--- Now the input handle is sane.  Do the Biz. ---*/
-   outputHandleJustInCase = NULL;
-   allOK = testStream ( inStr );
-
-   if (allOK && verbosity >= 1) fprintf ( stderr, "ok\n" );
-   if (!allOK) testFailsExist = True;
-}
-
-
-/*---------------------------------------------*/
-static 
-void license ( void )
-{
-   fprintf ( stderr,
-
-    "bzip2, a block-sorting file compressor.  "
-    "Version %s.\n"
-    "   \n"
-    "   Copyright (C) 1996-2005 by Julian Seward.\n"
-    "   \n"
-    "   This program is free software; you can redistribute it and/or modify\n"
-    "   it under the terms set out in the LICENSE file, which is included\n"
-    "   in the bzip2-1.0 source distribution.\n"
-    "   \n"
-    "   This program is distributed in the hope that it will be useful,\n"
-    "   but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
-    "   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
-    "   LICENSE file for more details.\n"
-    "   \n",
-    BZ2_bzlibVersion()
-   );
-}
-
-
-/*---------------------------------------------*/
-static 
-void usage ( Char *fullProgName )
-{
-   fprintf (
-      stderr,
-      "bzip2, a block-sorting file compressor.  "
-      "Version %s.\n"
-      "\n   usage: %s [flags and input files in any order]\n"
-      "\n"
-      "   -h --help           print this message\n"
-      "   -d --decompress     force decompression\n"
-      "   -z --compress       force compression\n"
-      "   -k --keep           keep (don't delete) input files\n"
-      "   -f --force          overwrite existing output files\n"
-      "   -t --test           test compressed file integrity\n"
-      "   -c --stdout         output to standard out\n"
-      "   -q --quiet          suppress noncritical error messages\n"
-      "   -v --verbose        be verbose (a 2nd -v gives more)\n"
-      "   -L --license        display software version & license\n"
-      "   -V --version        display software version & license\n"
-      "   -s --small          use less memory (at most 2500k)\n"
-      "   -1 .. -9            set block size to 100k .. 900k\n"
-      "   --fast              alias for -1\n"
-      "   --best              alias for -9\n"
-      "\n"
-      "   If invoked as `bzip2', default action is to compress.\n"
-      "              as `bunzip2',  default action is to decompress.\n"
-      "              as `bzcat', default action is to decompress to stdout.\n"
-      "\n"
-      "   If no file names are given, bzip2 compresses or decompresses\n"
-      "   from standard input to standard output.  You can combine\n"
-      "   short flags, so `-v -4' means the same as -v4 or -4v, &c.\n"
-#     if BZ_UNIX
-      "\n"
-#     endif
-      ,
-
-      BZ2_bzlibVersion(),
-      fullProgName
-   );
-}
-
-
-/*---------------------------------------------*/
-static 
-void redundant ( Char* flag )
-{
-   fprintf ( 
-      stderr, 
-      "%s: %s is redundant in versions 0.9.5 and above\n",
-      progName, flag );
-}
-
-
-/*---------------------------------------------*/
-/*--
-  All the garbage from here to main() is purely to
-  implement a linked list of command-line arguments,
-  into which main() copies argv[1 .. argc-1].
-
-  The purpose of this exercise is to facilitate 
-  the expansion of wildcard characters * and ? in 
-  filenames for OSs which don't know how to do it
-  themselves, like MSDOS, Windows 95 and NT.
-
-  The actual Dirty Work is done by the platform-
-  specific macro APPEND_FILESPEC.
---*/
-
-typedef
-   struct zzzz {
-      Char        *name;
-      struct zzzz *link;
-   }
-   Cell;
-
-
-/*---------------------------------------------*/
-static 
-void *myMalloc ( Int32 n )
-{
-   void* p;
-
-   p = malloc ( (size_t)n );
-   if (p == NULL) outOfMemory ();
-   return p;
-}
-
-
-/*---------------------------------------------*/
-static 
-Cell *mkCell ( void )
-{
-   Cell *c;
-
-   c = (Cell*) myMalloc ( sizeof ( Cell ) );
-   c->name = NULL;
-   c->link = NULL;
-   return c;
-}
-
-
-/*---------------------------------------------*/
-static 
-Cell *snocString ( Cell *root, Char *name )
-{
-   if (root == NULL) {
-      Cell *tmp = mkCell();
-      tmp->name = (Char*) myMalloc ( 5 + strlen(name) );
-      strcpy ( tmp->name, name );
-      return tmp;
-   } else {
-      Cell *tmp = root;
-      while (tmp->link != NULL) tmp = tmp->link;
-      tmp->link = snocString ( tmp->link, name );
-      return root;
-   }
-}
-
-
-/*---------------------------------------------*/
-static 
-void addFlagsFromEnvVar ( Cell** argList, Char* varName ) 
-{
-   Int32 i, j, k;
-   Char *envbase, *p;
-
-   envbase = getenv(varName);
-   if (envbase != NULL) {
-      p = envbase;
-      i = 0;
-      while (True) {
-         if (p[i] == 0) break;
-         p += i;
-         i = 0;
-         while (isspace((Int32)(p[0]))) p++;
-         while (p[i] != 0 && !isspace((Int32)(p[i]))) i++;
-         if (i > 0) {
-            k = i; if (k > FILE_NAME_LEN-10) k = FILE_NAME_LEN-10;
-            for (j = 0; j < k; j++) tmpName[j] = p[j];
-            tmpName[k] = 0;
-            APPEND_FLAG(*argList, tmpName);
-         }
-      }
-   }
-}
-
-
-/*---------------------------------------------*/
-#define ISFLAG(s) (strcmp(aa->name, (s))==0)
-
-IntNative main ( IntNative argc, Char *argv[] )
-{
-   Int32  i, j;
-   Char   *tmp;
-   Cell   *argList;
-   Cell   *aa;
-   Bool   decode;
-
-   /*-- Be really really really paranoid :-) --*/
-   if (sizeof(Int32) != 4 || sizeof(UInt32) != 4  ||
-       sizeof(Int16) != 2 || sizeof(UInt16) != 2  ||
-       sizeof(Char)  != 1 || sizeof(UChar)  != 1)
-      configError();
-
-   /*-- Initialise --*/
-   outputHandleJustInCase  = NULL;
-   smallMode               = False;
-   keepInputFiles          = False;
-   forceOverwrite          = False;
-   noisy                   = True;
-   verbosity               = 0;
-   blockSize100k           = 9;
-   testFailsExist          = False;
-   unzFailsExist           = False;
-   numFileNames            = 0;
-   numFilesProcessed       = 0;
-   workFactor              = 30;
-   deleteOutputOnInterrupt = False;
-   exitValue               = 0;
-   i = j = 0; /* avoid bogus warning from egcs-1.1.X */
-
-   /*-- Set up signal handlers for mem access errors --*/
-   signal (SIGSEGV, mySIGSEGVorSIGBUScatcher);
-#  if BZ_UNIX
-#  ifndef __DJGPP__
-   signal (SIGBUS,  mySIGSEGVorSIGBUScatcher);
-#  endif
-#  endif
-
-   copyFileName ( inName,  "(none)" );
-   copyFileName ( outName, "(none)" );
-
-   copyFileName ( progNameReally, argv[0] );
-   progName = &progNameReally[0];
-   for (tmp = &progNameReally[0]; *tmp != '\0'; tmp++)
-      if (*tmp == PATH_SEP) progName = tmp + 1;
-
-
-   /*-- Copy flags from env var BZIP2, and 
-        expand filename wildcards in arg list.
-   --*/
-   argList = NULL;
-   addFlagsFromEnvVar ( &argList,  "BZIP2" );
-   addFlagsFromEnvVar ( &argList,  "BZIP" );
-   for (i = 1; i <= argc-1; i++)
-      APPEND_FILESPEC(argList, argv[i]);
-
-
-   /*-- Find the length of the longest filename --*/
-   longestFileName = 7;
-   numFileNames    = 0;
-   decode          = True;
-   for (aa = argList; aa != NULL; aa = aa->link) {
-      if (ISFLAG("--")) { decode = False; continue; }
-      if (aa->name[0] == '-' && decode) continue;
-      numFileNames++;
-      if (longestFileName < (Int32)strlen(aa->name) )
-         longestFileName = (Int32)strlen(aa->name);
-   }
-
-
-   /*-- Determine source modes; flag handling may change this too. --*/
-   if (numFileNames == 0)
-      srcMode = SM_I2O; else srcMode = SM_F2F;
-
-
-   /*-- Determine what to do (compress/uncompress/test/cat). --*/
-   /*-- Note that subsequent flag handling may change this. --*/
-   opMode = OM_Z;
-
-   if ( (strstr ( progName, "unzip" ) != 0) ||
-        (strstr ( progName, "UNZIP" ) != 0) )
-      opMode = OM_UNZ;
-
-   if ( (strstr ( progName, "z2cat" ) != 0) ||
-        (strstr ( progName, "Z2CAT" ) != 0) ||
-        (strstr ( progName, "zcat" ) != 0)  ||
-        (strstr ( progName, "ZCAT" ) != 0) )  {
-      opMode = OM_UNZ;
-      srcMode = (numFileNames == 0) ? SM_I2O : SM_F2O;
-   }
-
-
-   /*-- Look at the flags. --*/
-   for (aa = argList; aa != NULL; aa = aa->link) {
-      if (ISFLAG("--")) break;
-      if (aa->name[0] == '-' && aa->name[1] != '-') {
-         for (j = 1; aa->name[j] != '\0'; j++) {
-            switch (aa->name[j]) {
-               case 'c': srcMode          = SM_F2O; break;
-               case 'd': opMode           = OM_UNZ; break;
-               case 'z': opMode           = OM_Z; break;
-               case 'f': forceOverwrite   = True; break;
-               case 't': opMode           = OM_TEST; break;
-               case 'k': keepInputFiles   = True; break;
-               case 's': smallMode        = True; break;
-               case 'q': noisy            = False; break;
-               case '1': blockSize100k    = 1; break;
-               case '2': blockSize100k    = 2; break;
-               case '3': blockSize100k    = 3; break;
-               case '4': blockSize100k    = 4; break;
-               case '5': blockSize100k    = 5; break;
-               case '6': blockSize100k    = 6; break;
-               case '7': blockSize100k    = 7; break;
-               case '8': blockSize100k    = 8; break;
-               case '9': blockSize100k    = 9; break;
-               case 'V':
-               case 'L': license();            break;
-               case 'v': verbosity++; break;
-               case 'h': usage ( progName );
-                         exit ( 0 );
-                         break;
-               default:  fprintf ( stderr, "%s: Bad flag `%s'\n",
-                                   progName, aa->name );
-                         usage ( progName );
-                         exit ( 1 );
-                         break;
-            }
-         }
-      }
-   }
-   
-   /*-- And again ... --*/
-   for (aa = argList; aa != NULL; aa = aa->link) {
-      if (ISFLAG("--")) break;
-      if (ISFLAG("--stdout"))            srcMode          = SM_F2O;  else
-      if (ISFLAG("--decompress"))        opMode           = OM_UNZ;  else
-      if (ISFLAG("--compress"))          opMode           = OM_Z;    else
-      if (ISFLAG("--force"))             forceOverwrite   = True;    else
-      if (ISFLAG("--test"))              opMode           = OM_TEST; else
-      if (ISFLAG("--keep"))              keepInputFiles   = True;    else
-      if (ISFLAG("--small"))             smallMode        = True;    else
-      if (ISFLAG("--quiet"))             noisy            = False;   else
-      if (ISFLAG("--version"))           license();                  else
-      if (ISFLAG("--license"))           license();                  else
-      if (ISFLAG("--exponential"))       workFactor = 1;             else 
-      if (ISFLAG("--repetitive-best"))   redundant(aa->name);        else
-      if (ISFLAG("--repetitive-fast"))   redundant(aa->name);        else
-      if (ISFLAG("--fast"))              blockSize100k = 1;          else
-      if (ISFLAG("--best"))              blockSize100k = 9;          else
-      if (ISFLAG("--verbose"))           verbosity++;                else
-      if (ISFLAG("--help"))              { usage ( progName ); exit ( 0 ); }
-         else
-         if (strncmp ( aa->name, "--", 2) == 0) {
-            fprintf ( stderr, "%s: Bad flag `%s'\n", progName, aa->name );
-            usage ( progName );
-            exit ( 1 );
-         }
-   }
-
-   if (verbosity > 4) verbosity = 4;
-   if (opMode == OM_Z && smallMode && blockSize100k > 2) 
-      blockSize100k = 2;
-
-   if (opMode == OM_TEST && srcMode == SM_F2O) {
-      fprintf ( stderr, "%s: -c and -t cannot be used together.\n",
-                progName );
-      exit ( 1 );
-   }
-
-   if (srcMode == SM_F2O && numFileNames == 0)
-      srcMode = SM_I2O;
-
-   if (opMode != OM_Z) blockSize100k = 0;
-
-   if (srcMode == SM_F2F) {
-      signal (SIGINT,  mySignalCatcher);
-      signal (SIGTERM, mySignalCatcher);
-#     if BZ_UNIX
-      signal (SIGHUP,  mySignalCatcher);
-#     endif
-   }
-
-   if (opMode == OM_Z) {
-     if (srcMode == SM_I2O) {
-        compress ( NULL );
-     } else {
-        decode = True;
-        for (aa = argList; aa != NULL; aa = aa->link) {
-           if (ISFLAG("--")) { decode = False; continue; }
-           if (aa->name[0] == '-' && decode) continue;
-           numFilesProcessed++;
-           compress ( aa->name );
-        }
-     }
-   } 
-   else
-
-   if (opMode == OM_UNZ) {
-      unzFailsExist = False;
-      if (srcMode == SM_I2O) {
-         uncompress ( NULL );
-      } else {
-         decode = True;
-         for (aa = argList; aa != NULL; aa = aa->link) {
-            if (ISFLAG("--")) { decode = False; continue; }
-            if (aa->name[0] == '-' && decode) continue;
-            numFilesProcessed++;
-            uncompress ( aa->name );
-         }      
-      }
-      if (unzFailsExist) { 
-         setExit(2); 
-         exit(exitValue);
-      }
-   } 
-
-   else {
-      testFailsExist = False;
-      if (srcMode == SM_I2O) {
-         testf ( NULL );
-      } else {
-         decode = True;
-         for (aa = argList; aa != NULL; aa = aa->link) {
-	    if (ISFLAG("--")) { decode = False; continue; }
-            if (aa->name[0] == '-' && decode) continue;
-            numFilesProcessed++;
-            testf ( aa->name );
-	 }
-      }
-      if (testFailsExist && noisy) {
-         fprintf ( stderr,
-           "\n"
-           "You can use the `bzip2recover' program to attempt to recover\n"
-           "data from undamaged sections of corrupted files.\n\n"
-         );
-         setExit(2);
-         exit(exitValue);
-      }
-   }
-
-   /* Free the argument list memory to mollify leak detectors 
-      (eg) Purify, Checker.  Serves no other useful purpose.
-   */
-   aa = argList;
-   while (aa != NULL) {
-      Cell* aa2 = aa->link;
-      if (aa->name != NULL) free(aa->name);
-      free(aa);
-      aa = aa2;
-   }
-
-   return exitValue;
-}
-
-
-/*-----------------------------------------------------------*/
-/*--- end                                         bzip2.c ---*/
-/*-----------------------------------------------------------*/
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2.txt b/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2.txt
deleted file mode 100644
index bf895b6cb8a..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2.txt
+++ /dev/null
@@ -1,391 +0,0 @@
-
-NAME
-       bzip2, bunzip2 - a block-sorting file compressor, v1.0.3
-       bzcat - decompresses files to stdout
-       bzip2recover - recovers data from damaged bzip2 files
-
-
-SYNOPSIS
-       bzip2 [ -cdfkqstvzVL123456789 ] [ filenames ...  ]
-       bunzip2 [ -fkvsVL ] [ filenames ...  ]
-       bzcat [ -s ] [ filenames ...  ]
-       bzip2recover filename
-
-
-DESCRIPTION
-       bzip2  compresses  files  using  the Burrows-Wheeler block
-       sorting text compression algorithm,  and  Huffman  coding.
-       Compression  is  generally  considerably  better than that
-       achieved by more conventional LZ77/LZ78-based compressors,
-       and  approaches  the performance of the PPM family of sta-
-       tistical compressors.
-
-       The command-line options are deliberately very similar  to
-       those of GNU gzip, but they are not identical.
-
-       bzip2  expects  a list of file names to accompany the com-
-       mand-line flags.  Each file is replaced  by  a  compressed
-       version  of  itself,  with  the  name "original_name.bz2".
-       Each compressed file has the same modification date,  per-
-       missions, and, when possible, ownership as the correspond-
-       ing original, so that these properties  can  be  correctly
-       restored  at  decompression  time.   File name handling is
-       naive in the sense that there is no mechanism for preserv-
-       ing  original file names, permissions, ownerships or dates
-       in filesystems which lack these concepts, or have  serious
-       file name length restrictions, such as MS-DOS.
-
-       bzip2  and  bunzip2 will by default not overwrite existing
-       files.  If you want this to happen, specify the -f flag.
-
-       If no file names  are  specified,  bzip2  compresses  from
-       standard  input  to  standard output.  In this case, bzip2
-       will decline to write compressed output to a terminal,  as
-       this  would  be  entirely  incomprehensible  and therefore
-       pointless.
-
-       bunzip2 (or bzip2 -d) decompresses  all  specified  files.
-       Files which were not created by bzip2 will be detected and
-       ignored, and a warning issued.  bzip2  attempts  to  guess
-       the  filename  for  the decompressed file from that of the
-       compressed file as follows:
-
-              filename.bz2    becomes   filename
-              filename.bz     becomes   filename
-              filename.tbz2   becomes   filename.tar
-              filename.tbz    becomes   filename.tar
-              anyothername    becomes   anyothername.out
-
-       If the file does not end in one of the recognised endings,
-       .bz2,  .bz,  .tbz2 or .tbz, bzip2 complains that it cannot
-       guess the name of the original file, and uses the original
-       name with .out appended.
-
-       As  with compression, supplying no filenames causes decom-
-       pression from standard input to standard output.
-
-       bunzip2 will correctly decompress a file which is the con-
-       catenation of two or more compressed files.  The result is
-       the concatenation of the corresponding uncompressed files.
-       Integrity testing (-t) of concatenated compressed files is
-       also supported.
-
-       You can also compress or decompress files to the  standard
-       output  by giving the -c flag.  Multiple files may be com-
-       pressed and decompressed like this.  The resulting outputs
-       are  fed  sequentially to stdout.  Compression of multiple
-       files in this manner generates a stream containing  multi-
-       ple compressed file representations.  Such a stream can be
-       decompressed correctly only  by  bzip2  version  0.9.0  or
-       later.   Earlier  versions of bzip2 will stop after decom-
-       pressing the first file in the stream.
-
-       bzcat (or bzip2 -dc) decompresses all specified  files  to
-       the standard output.
-
-       bzip2  will  read arguments from the environment variables
-       BZIP2 and BZIP, in  that  order,  and  will  process  them
-       before  any  arguments  read  from the command line.  This
-       gives a convenient way to supply default arguments.
-
-       Compression is always performed, even  if  the  compressed
-       file  is slightly larger than the original.  Files of less
-       than about one hundred bytes tend to get larger, since the
-       compression  mechanism  has  a  constant  overhead  in the
-       region of 50 bytes.  Random data (including the output  of
-       most  file  compressors)  is  coded at about 8.05 bits per
-       byte, giving an expansion of around 0.5%.
-
-       As a self-check for your  protection,  bzip2  uses  32-bit
-       CRCs  to make sure that the decompressed version of a file
-       is identical to the original.  This guards against corrup-
-       tion  of  the compressed data, and against undetected bugs
-       in bzip2 (hopefully very unlikely).  The chances  of  data
-       corruption  going  undetected  is  microscopic,  about one
-       chance in four billion for each file processed.  Be aware,
-       though,  that  the  check occurs upon decompression, so it
-       can only tell you that something is wrong.  It can't  help
-       you  recover  the original uncompressed data.  You can use
-       bzip2recover to try to recover data from damaged files.
-
-       Return values: 0 for a normal exit,  1  for  environmental
-       problems  (file not found, invalid flags, I/O errors, &c),
-       2 to indicate a corrupt compressed file, 3 for an internal
-       consistency error (eg, bug) which caused bzip2 to panic.
-
-
-OPTIONS
-       -c --stdout
-              Compress or decompress to standard output.
-
-       -d --decompress
-              Force  decompression.  bzip2, bunzip2 and bzcat are
-              really the same program,  and  the  decision  about
-              what  actions to take is done on the basis of which
-              name is used.  This flag overrides that  mechanism,
-              and forces bzip2 to decompress.
-
-       -z --compress
-              The   complement   to   -d:   forces   compression,
-              regardless of the invocation name.
-
-       -t --test
-              Check integrity of the specified file(s), but don't
-              decompress  them.   This  really  performs  a trial
-              decompression and throws away the result.
-
-       -f --force
-              Force overwrite of output files.   Normally,  bzip2
-              will  not  overwrite  existing  output files.  Also
-              forces bzip2 to break hard links to files, which it
-              otherwise wouldn't do.
-
-              bzip2  normally  declines to decompress files which
-              don't have the  correct  magic  header  bytes.   If
-              forced  (-f),  however,  it  will  pass  such files
-              through unmodified.  This is how GNU gzip  behaves.
-
-       -k --keep
-              Keep  (don't delete) input files during compression
-              or decompression.
-
-       -s --small
-              Reduce memory usage, for compression, decompression
-              and  testing.   Files  are  decompressed and tested
-              using a modified algorithm which only requires  2.5
-              bytes  per  block byte.  This means any file can be
-              decompressed in 2300k of memory,  albeit  at  about
-              half the normal speed.
-
-              During  compression,  -s  selects  a  block size of
-              200k, which limits memory use to  around  the  same
-              figure,  at  the expense of your compression ratio.
-              In short, if your  machine  is  low  on  memory  (8
-              megabytes  or  less),  use  -s for everything.  See
-              MEMORY MANAGEMENT below.
-
-       -q --quiet
-              Suppress non-essential warning messages.   Messages
-              pertaining  to I/O errors and other critical events
-              will not be suppressed.
-
-       -v --verbose
-              Verbose mode -- show the compression ratio for each
-              file  processed.   Further  -v's  increase the ver-
-              bosity level, spewing out lots of information which
-              is primarily of interest for diagnostic purposes.
-
-       -L --license -V --version
-              Display  the  software  version,  license terms and
-              conditions.
-
-       -1 (or --fast) to -9 (or --best)
-              Set the block size to 100 k, 200 k ..  900  k  when
-              compressing.   Has  no  effect  when decompressing.
-              See MEMORY MANAGEMENT below.  The --fast and --best
-              aliases  are  primarily for GNU gzip compatibility.
-              In particular, --fast doesn't make things  signifi-
-              cantly  faster.   And  --best  merely  selects  the
-              default behaviour.
-
-       --     Treats all subsequent arguments as file names, even
-              if they start with a dash.  This is so you can han-
-              dle files with names beginning  with  a  dash,  for
-              example: bzip2 -- -myfilename.
-
-       --repetitive-fast --repetitive-best
-              These  flags  are  redundant  in versions 0.9.5 and
-              above.  They provided some coarse control over  the
-              behaviour  of the sorting algorithm in earlier ver-
-              sions, which was sometimes useful.  0.9.5 and above
-              have  an  improved  algorithm  which  renders these
-              flags irrelevant.
-
-
-MEMORY MANAGEMENT
-       bzip2 compresses large files in blocks.   The  block  size
-       affects  both  the  compression  ratio  achieved,  and the
-       amount of memory needed for compression and decompression.
-       The  flags  -1  through  -9  specify  the block size to be
-       100,000 bytes through 900,000 bytes (the default)  respec-
-       tively.   At  decompression  time, the block size used for
-       compression is read from  the  header  of  the  compressed
-       file, and bunzip2 then allocates itself just enough memory
-       to decompress the file.  Since block sizes are  stored  in
-       compressed  files,  it follows that the flags -1 to -9 are
-       irrelevant to and so ignored during decompression.
-
-       Compression and decompression requirements, in bytes,  can
-       be estimated as:
-
-              Compression:   400k + ( 8 x block size )
-
-              Decompression: 100k + ( 4 x block size ), or
-                             100k + ( 2.5 x block size )
-
-       Larger  block  sizes  give  rapidly  diminishing  marginal
-       returns.  Most of the compression comes from the first two
-       or  three hundred k of block size, a fact worth bearing in
-       mind when using bzip2  on  small  machines.   It  is  also
-       important  to  appreciate  that  the  decompression memory
-       requirement is set at compression time by  the  choice  of
-       block size.
-
-       For  files  compressed  with  the default 900k block size,
-       bunzip2 will require about 3700 kbytes to decompress.   To
-       support decompression of any file on a 4 megabyte machine,
-       bunzip2 has an option to  decompress  using  approximately
-       half this amount of memory, about 2300 kbytes.  Decompres-
-       sion speed is also halved, so you should use  this  option
-       only where necessary.  The relevant flag is -s.
-
-       In general, try and use the largest block size memory con-
-       straints  allow,  since  that  maximises  the  compression
-       achieved.   Compression and decompression speed are virtu-
-       ally unaffected by block size.
-
-       Another significant point applies to files which fit in  a
-       single  block  --  that  means  most files you'd encounter
-       using a large block  size.   The  amount  of  real  memory
-       touched is proportional to the size of the file, since the
-       file is smaller than a block.  For example, compressing  a
-       file  20,000  bytes  long  with the flag -9 will cause the
-       compressor to allocate around 7600k of  memory,  but  only
-       touch 400k + 20000 * 8 = 560 kbytes of it.  Similarly, the
-       decompressor will allocate 3700k but  only  touch  100k  +
-       20000 * 4 = 180 kbytes.
-
-       Here  is a table which summarises the maximum memory usage
-       for different block sizes.  Also  recorded  is  the  total
-       compressed  size for 14 files of the Calgary Text Compres-
-       sion Corpus totalling 3,141,622 bytes.  This column  gives
-       some  feel  for  how  compression  varies with block size.
-       These figures tend to understate the advantage  of  larger
-       block  sizes  for  larger files, since the Corpus is domi-
-       nated by smaller files.
-
-                  Compress   Decompress   Decompress   Corpus
-           Flag     usage      usage       -s usage     Size
-
-            -1      1200k       500k         350k      914704
-            -2      2000k       900k         600k      877703
-            -3      2800k      1300k         850k      860338
-            -4      3600k      1700k        1100k      846899
-            -5      4400k      2100k        1350k      845160
-            -6      5200k      2500k        1600k      838626
-            -7      6100k      2900k        1850k      834096
-            -8      6800k      3300k        2100k      828642
-            -9      7600k      3700k        2350k      828642
-
-
-RECOVERING DATA FROM DAMAGED FILES
-       bzip2 compresses files in blocks, usually 900kbytes  long.
-       Each block is handled independently.  If a media or trans-
-       mission error causes a multi-block  .bz2  file  to  become
-       damaged,  it  may  be  possible  to  recover data from the
-       undamaged blocks in the file.
-
-       The compressed representation of each block  is  delimited
-       by  a  48-bit pattern, which makes it possible to find the
-       block boundaries with reasonable  certainty.   Each  block
-       also  carries its own 32-bit CRC, so damaged blocks can be
-       distinguished from undamaged ones.
-
-       bzip2recover is a  simple  program  whose  purpose  is  to
-       search  for blocks in .bz2 files, and write each block out
-       into its own .bz2 file.  You can then use bzip2 -t to test
-       the integrity of the resulting files, and decompress those
-       which are undamaged.
-
-       bzip2recover takes a single argument, the name of the dam-
-       aged    file,    and    writes    a    number   of   files
-       "rec00001file.bz2",  "rec00002file.bz2",  etc,  containing
-       the   extracted   blocks.   The   output   filenames   are
-       designed  so  that the use of wildcards in subsequent pro-
-       cessing  -- for example, "bzip2 -dc  rec*file.bz2 > recov-
-       ered_data" -- processes the files in the correct order.
-
-       bzip2recover should be of most use dealing with large .bz2
-       files,  as  these will contain many blocks.  It is clearly
-       futile to use it on damaged single-block  files,  since  a
-       damaged  block  cannot  be recovered.  If you wish to min-
-       imise any potential data loss through media  or  transmis-
-       sion errors, you might consider compressing with a smaller
-       block size.
-
-
-PERFORMANCE NOTES
-       The sorting phase of compression gathers together  similar
-       strings  in  the  file.  Because of this, files containing
-       very long runs of  repeated  symbols,  like  "aabaabaabaab
-       ..."   (repeated  several hundred times) may compress more
-       slowly than normal.  Versions 0.9.5 and  above  fare  much
-       better  than previous versions in this respect.  The ratio
-       between worst-case and average-case compression time is in
-       the  region  of  10:1.  For previous versions, this figure
-       was more like 100:1.  You can use the -vvvv option to mon-
-       itor progress in great detail, if you want.
-
-       Decompression speed is unaffected by these phenomena.
-
-       bzip2  usually  allocates  several  megabytes of memory to
-       operate in, and then charges all over it in a fairly  ran-
-       dom  fashion.   This means that performance, both for com-
-       pressing and decompressing, is largely determined  by  the
-       speed  at  which  your  machine  can service cache misses.
-       Because of this, small changes to the code to  reduce  the
-       miss  rate  have  been observed to give disproportionately
-       large performance improvements.  I imagine bzip2 will per-
-       form best on machines with very large caches.
-
-
-CAVEATS
-       I/O  error  messages  are not as helpful as they could be.
-       bzip2 tries hard to detect I/O errors  and  exit  cleanly,
-       but  the  details  of  what  the problem is sometimes seem
-       rather misleading.
-
-       This manual page pertains to version 1.0.3 of bzip2.  Com-
-       pressed  data created by this version is entirely forwards
-       and  backwards  compatible  with   the   previous   public
-       releases,  versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1 and
-       1.0.2, but with the following exception: 0.9.0  and  above
-       can  correctly decompress multiple concatenated compressed
-       files.  0.1pl2 cannot do this; it will stop  after  decom-
-       pressing just the first file in the stream.
-
-       bzip2recover  versions prior to 1.0.2 used 32-bit integers
-       to represent bit positions in compressed  files,  so  they
-       could  not handle compressed files more than 512 megabytes
-       long.  Versions 1.0.2 and above use 64-bit  ints  on  some
-       platforms  which  support them (GNU supported targets, and
-       Windows).  To establish whether or  not  bzip2recover  was
-       built  with  such  a limitation, run it without arguments.
-       In any event you can build yourself an  unlimited  version
-       if  you  can  recompile  it  with MaybeUInt64 set to be an
-       unsigned 64-bit integer.
-
-
-AUTHOR
-       Julian Seward, jsewardbzip.org.
-
-       http://www.bzip.org
-
-       The ideas embodied in bzip2 are due to (at least) the fol-
-       lowing  people: Michael Burrows and David Wheeler (for the
-       block sorting transformation), David Wheeler  (again,  for
-       the Huffman coder), Peter Fenwick (for the structured cod-
-       ing model in the original bzip, and many refinements), and
-       Alistair  Moffat,  Radford  Neal  and  Ian Witten (for the
-       arithmetic  coder  in  the  original  bzip).   I  am  much
-       indebted for their help, support and advice.  See the man-
-       ual in the source distribution for pointers to sources  of
-       documentation.  Christian von Roques encouraged me to look
-       for faster sorting algorithms, so as to speed up  compres-
-       sion.  Bela Lubkin encouraged me to improve the worst-case
-       compression performance.  Donna Robinson XMLised the docu-
-       mentation.   The bz* scripts are derived from those of GNU
-       gzip.  Many people sent patches, helped  with  portability
-       problems,  lent  machines,  gave advice and were generally
-       helpful.
-
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2recover.c b/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2recover.c
deleted file mode 100644
index 5cd405dd4cb..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzip2recover.c
+++ /dev/null
@@ -1,546 +0,0 @@
-
-/*-----------------------------------------------------------*/
-/*--- Block recoverer program for bzip2                   ---*/
-/*---                                      bzip2recover.c ---*/
-/*-----------------------------------------------------------*/
-
-/*--
-  This program is bzip2recover, a program to attempt data 
-  salvage from damaged files created by the accompanying
-  bzip2-1.0.3 program.
-
-  Copyright (C) 1996-2005 Julian R Seward.  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-  2. 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.
-
-  3. Altered source versions must be plainly marked as such, and must
-     not be misrepresented as being the original software.
-
-  4. The name of the author may not be used to endorse or promote 
-     products derived from this software without specific prior written 
-     permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
-
-  Julian Seward, Cambridge, UK.
-  jseward@bzip.org
-  bzip2/libbzip2 version 1.0.3 of 15 February 2005
---*/
-
-/*--
-  This program is a complete hack and should be rewritten
-  properly.  It isn't very complicated.
---*/
-
-#include 
-#include 
-#include 
-#include 
-
-
-/* This program records bit locations in the file to be recovered.
-   That means that if 64-bit ints are not supported, we will not
-   be able to recover .bz2 files over 512MB (2^32 bits) long.
-   On GNU supported platforms, we take advantage of the 64-bit
-   int support to circumvent this problem.  Ditto MSVC.
-
-   This change occurred in version 1.0.2; all prior versions have
-   the 512MB limitation.
-*/
-#ifdef __GNUC__
-   typedef  unsigned long long int  MaybeUInt64;
-#  define MaybeUInt64_FMT "%Lu"
-#else
-#ifdef _MSC_VER
-   typedef  unsigned __int64  MaybeUInt64;
-#  define MaybeUInt64_FMT "%I64u"
-#else
-   typedef  unsigned int   MaybeUInt64;
-#  define MaybeUInt64_FMT "%u"
-#endif
-#endif
-
-typedef  unsigned int   UInt32;
-typedef  int            Int32;
-typedef  unsigned char  UChar;
-typedef  char           Char;
-typedef  unsigned char  Bool;
-#define True    ((Bool)1)
-#define False   ((Bool)0)
-
-
-#define BZ_MAX_FILENAME 2000
-
-Char inFileName[BZ_MAX_FILENAME];
-Char outFileName[BZ_MAX_FILENAME];
-Char progName[BZ_MAX_FILENAME];
-
-MaybeUInt64 bytesOut = 0;
-MaybeUInt64 bytesIn  = 0;
-
-
-/*---------------------------------------------------*/
-/*--- Header bytes                                ---*/
-/*---------------------------------------------------*/
-
-#define BZ_HDR_B 0x42                         /* 'B' */
-#define BZ_HDR_Z 0x5a                         /* 'Z' */
-#define BZ_HDR_h 0x68                         /* 'h' */
-#define BZ_HDR_0 0x30                         /* '0' */
- 
-
-/*---------------------------------------------------*/
-/*--- I/O errors                                  ---*/
-/*---------------------------------------------------*/
-
-/*---------------------------------------------*/
-void readError ( void )
-{
-   fprintf ( stderr,
-             "%s: I/O error reading `%s', possible reason follows.\n",
-            progName, inFileName );
-   perror ( progName );
-   fprintf ( stderr, "%s: warning: output file(s) may be incomplete.\n",
-             progName );
-   exit ( 1 );
-}
-
-
-/*---------------------------------------------*/
-void writeError ( void )
-{
-   fprintf ( stderr,
-             "%s: I/O error reading `%s', possible reason follows.\n",
-            progName, inFileName );
-   perror ( progName );
-   fprintf ( stderr, "%s: warning: output file(s) may be incomplete.\n",
-             progName );
-   exit ( 1 );
-}
-
-
-/*---------------------------------------------*/
-void mallocFail ( Int32 n )
-{
-   fprintf ( stderr,
-             "%s: malloc failed on request for %d bytes.\n",
-            progName, n );
-   fprintf ( stderr, "%s: warning: output file(s) may be incomplete.\n",
-             progName );
-   exit ( 1 );
-}
-
-
-/*---------------------------------------------*/
-void tooManyBlocks ( Int32 max_handled_blocks )
-{
-   fprintf ( stderr,
-             "%s: `%s' appears to contain more than %d blocks\n",
-            progName, inFileName, max_handled_blocks );
-   fprintf ( stderr,
-             "%s: and cannot be handled.  To fix, increase\n",
-             progName );
-   fprintf ( stderr, 
-             "%s: BZ_MAX_HANDLED_BLOCKS in bzip2recover.c, and recompile.\n",
-             progName );
-   exit ( 1 );
-}
-
-
-
-/*---------------------------------------------------*/
-/*--- Bit stream I/O                              ---*/
-/*---------------------------------------------------*/
-
-typedef
-   struct {
-      FILE*  handle;
-      Int32  buffer;
-      Int32  buffLive;
-      Char   mode;
-   }
-   BitStream;
-
-
-/*---------------------------------------------*/
-BitStream* bsOpenReadStream ( FILE* stream )
-{
-   BitStream *bs = malloc ( sizeof(BitStream) );
-   if (bs == NULL) mallocFail ( sizeof(BitStream) );
-   bs->handle = stream;
-   bs->buffer = 0;
-   bs->buffLive = 0;
-   bs->mode = 'r';
-   return bs;
-}
-
-
-/*---------------------------------------------*/
-BitStream* bsOpenWriteStream ( FILE* stream )
-{
-   BitStream *bs = malloc ( sizeof(BitStream) );
-   if (bs == NULL) mallocFail ( sizeof(BitStream) );
-   bs->handle = stream;
-   bs->buffer = 0;
-   bs->buffLive = 0;
-   bs->mode = 'w';
-   return bs;
-}
-
-
-/*---------------------------------------------*/
-void bsPutBit ( BitStream* bs, Int32 bit )
-{
-   if (bs->buffLive == 8) {
-      Int32 retVal = putc ( (UChar) bs->buffer, bs->handle );
-      if (retVal == EOF) writeError();
-      bytesOut++;
-      bs->buffLive = 1;
-      bs->buffer = bit & 0x1;
-   } else {
-      bs->buffer = ( (bs->buffer << 1) | (bit & 0x1) );
-      bs->buffLive++;
-   };
-}
-
-
-/*---------------------------------------------*/
-/*--
-   Returns 0 or 1, or 2 to indicate EOF.
---*/
-Int32 bsGetBit ( BitStream* bs )
-{
-   if (bs->buffLive > 0) {
-      bs->buffLive --;
-      return ( ((bs->buffer) >> (bs->buffLive)) & 0x1 );
-   } else {
-      Int32 retVal = getc ( bs->handle );
-      if ( retVal == EOF ) {
-         if (errno != 0) readError();
-         return 2;
-      }
-      bs->buffLive = 7;
-      bs->buffer = retVal;
-      return ( ((bs->buffer) >> 7) & 0x1 );
-   }
-}
-
-
-/*---------------------------------------------*/
-void bsClose ( BitStream* bs )
-{
-   Int32 retVal;
-
-   if ( bs->mode == 'w' ) {
-      while ( bs->buffLive < 8 ) {
-         bs->buffLive++;
-         bs->buffer <<= 1;
-      };
-      retVal = putc ( (UChar) (bs->buffer), bs->handle );
-      if (retVal == EOF) writeError();
-      bytesOut++;
-      retVal = fflush ( bs->handle );
-      if (retVal == EOF) writeError();
-   }
-   retVal = fclose ( bs->handle );
-   if (retVal == EOF) {
-      if (bs->mode == 'w') writeError(); else readError();
-   }
-   free ( bs );
-}
-
-
-/*---------------------------------------------*/
-void bsPutUChar ( BitStream* bs, UChar c )
-{
-   Int32 i;
-   for (i = 7; i >= 0; i--)
-      bsPutBit ( bs, (((UInt32) c) >> i) & 0x1 );
-}
-
-
-/*---------------------------------------------*/
-void bsPutUInt32 ( BitStream* bs, UInt32 c )
-{
-   Int32 i;
-
-   for (i = 31; i >= 0; i--)
-      bsPutBit ( bs, (c >> i) & 0x1 );
-}
-
-
-/*---------------------------------------------*/
-Bool endsInBz2 ( Char* name )
-{
-   Int32 n = strlen ( name );
-   if (n <= 4) return False;
-   return
-      (name[n-4] == '.' &&
-       name[n-3] == 'b' &&
-       name[n-2] == 'z' &&
-       name[n-1] == '2');
-}
-
-
-/*---------------------------------------------------*/
-/*---                                             ---*/
-/*---------------------------------------------------*/
-
-/* This logic isn't really right when it comes to Cygwin. */
-#ifdef _WIN32
-#  define  BZ_SPLIT_SYM  '\\'  /* path splitter on Windows platform */
-#else
-#  define  BZ_SPLIT_SYM  '/'   /* path splitter on Unix platform */
-#endif
-
-#define BLOCK_HEADER_HI  0x00003141UL
-#define BLOCK_HEADER_LO  0x59265359UL
-
-#define BLOCK_ENDMARK_HI 0x00001772UL
-#define BLOCK_ENDMARK_LO 0x45385090UL
-
-/* Increase if necessary.  However, a .bz2 file with > 50000 blocks
-   would have an uncompressed size of at least 40GB, so the chances
-   are low you'll need to up this.
-*/
-#define BZ_MAX_HANDLED_BLOCKS 50000
-
-MaybeUInt64 bStart [BZ_MAX_HANDLED_BLOCKS];
-MaybeUInt64 bEnd   [BZ_MAX_HANDLED_BLOCKS];
-MaybeUInt64 rbStart[BZ_MAX_HANDLED_BLOCKS];
-MaybeUInt64 rbEnd  [BZ_MAX_HANDLED_BLOCKS];
-
-Int32 main ( Int32 argc, Char** argv )
-{
-   FILE*       inFile;
-   FILE*       outFile;
-   BitStream*  bsIn, *bsWr;
-   Int32       b, wrBlock, currBlock, rbCtr;
-   MaybeUInt64 bitsRead;
-
-   UInt32      buffHi, buffLo, blockCRC;
-   Char*       p;
-
-   strcpy ( progName, argv[0] );
-   inFileName[0] = outFileName[0] = 0;
-
-   fprintf ( stderr, 
-             "bzip2recover 1.0.3: extracts blocks from damaged .bz2 files.\n" );
-
-   if (argc != 2) {
-      fprintf ( stderr, "%s: usage is `%s damaged_file_name'.\n",
-                        progName, progName );
-      switch (sizeof(MaybeUInt64)) {
-         case 8:
-            fprintf(stderr, 
-                    "\trestrictions on size of recovered file: None\n");
-            break;
-         case 4:
-            fprintf(stderr, 
-                    "\trestrictions on size of recovered file: 512 MB\n");
-            fprintf(stderr, 
-                    "\tto circumvent, recompile with MaybeUInt64 as an\n"
-                    "\tunsigned 64-bit int.\n");
-            break;
-         default:
-            fprintf(stderr, 
-                    "\tsizeof(MaybeUInt64) is not 4 or 8 -- "
-                    "configuration error.\n");
-            break;
-      }
-      exit(1);
-   }
-
-   if (strlen(argv[1]) >= BZ_MAX_FILENAME-20) {
-      fprintf ( stderr, 
-                "%s: supplied filename is suspiciously (>= %d chars) long.  Bye!\n",
-                progName, (int)strlen(argv[1]) );
-      exit(1);
-   }
-
-   strcpy ( inFileName, argv[1] );
-
-   inFile = fopen ( inFileName, "rb" );
-   if (inFile == NULL) {
-      fprintf ( stderr, "%s: can't read `%s'\n", progName, inFileName );
-      exit(1);
-   }
-
-   bsIn = bsOpenReadStream ( inFile );
-   fprintf ( stderr, "%s: searching for block boundaries ...\n", progName );
-
-   bitsRead = 0;
-   buffHi = buffLo = 0;
-   currBlock = 0;
-   bStart[currBlock] = 0;
-
-   rbCtr = 0;
-
-   while (True) {
-      b = bsGetBit ( bsIn );
-      bitsRead++;
-      if (b == 2) {
-         if (bitsRead >= bStart[currBlock] &&
-            (bitsRead - bStart[currBlock]) >= 40) {
-            bEnd[currBlock] = bitsRead-1;
-            if (currBlock > 0)
-               fprintf ( stderr, "   block %d runs from " MaybeUInt64_FMT 
-                                 " to " MaybeUInt64_FMT " (incomplete)\n",
-                         currBlock,  bStart[currBlock], bEnd[currBlock] );
-         } else
-            currBlock--;
-         break;
-      }
-      buffHi = (buffHi << 1) | (buffLo >> 31);
-      buffLo = (buffLo << 1) | (b & 1);
-      if ( ( (buffHi & 0x0000ffff) == BLOCK_HEADER_HI 
-             && buffLo == BLOCK_HEADER_LO)
-           || 
-           ( (buffHi & 0x0000ffff) == BLOCK_ENDMARK_HI 
-             && buffLo == BLOCK_ENDMARK_LO)
-         ) {
-         if (bitsRead > 49) {
-            bEnd[currBlock] = bitsRead-49;
-         } else {
-            bEnd[currBlock] = 0;
-         }
-         if (currBlock > 0 &&
-	     (bEnd[currBlock] - bStart[currBlock]) >= 130) {
-            fprintf ( stderr, "   block %d runs from " MaybeUInt64_FMT 
-                              " to " MaybeUInt64_FMT "\n",
-                      rbCtr+1,  bStart[currBlock], bEnd[currBlock] );
-            rbStart[rbCtr] = bStart[currBlock];
-            rbEnd[rbCtr] = bEnd[currBlock];
-            rbCtr++;
-         }
-         if (currBlock >= BZ_MAX_HANDLED_BLOCKS)
-            tooManyBlocks(BZ_MAX_HANDLED_BLOCKS);
-         currBlock++;
-
-         bStart[currBlock] = bitsRead;
-      }
-   }
-
-   bsClose ( bsIn );
-
-   /*-- identified blocks run from 1 to rbCtr inclusive. --*/
-
-   if (rbCtr < 1) {
-      fprintf ( stderr,
-                "%s: sorry, I couldn't find any block boundaries.\n",
-                progName );
-      exit(1);
-   };
-
-   fprintf ( stderr, "%s: splitting into blocks\n", progName );
-
-   inFile = fopen ( inFileName, "rb" );
-   if (inFile == NULL) {
-      fprintf ( stderr, "%s: can't open `%s'\n", progName, inFileName );
-      exit(1);
-   }
-   bsIn = bsOpenReadStream ( inFile );
-
-   /*-- placate gcc's dataflow analyser --*/
-   blockCRC = 0; bsWr = 0;
-
-   bitsRead = 0;
-   outFile = NULL;
-   wrBlock = 0;
-   while (True) {
-      b = bsGetBit(bsIn);
-      if (b == 2) break;
-      buffHi = (buffHi << 1) | (buffLo >> 31);
-      buffLo = (buffLo << 1) | (b & 1);
-      if (bitsRead == 47+rbStart[wrBlock]) 
-         blockCRC = (buffHi << 16) | (buffLo >> 16);
-
-      if (outFile != NULL && bitsRead >= rbStart[wrBlock]
-                          && bitsRead <= rbEnd[wrBlock]) {
-         bsPutBit ( bsWr, b );
-      }
-
-      bitsRead++;
-
-      if (bitsRead == rbEnd[wrBlock]+1) {
-         if (outFile != NULL) {
-            bsPutUChar ( bsWr, 0x17 ); bsPutUChar ( bsWr, 0x72 );
-            bsPutUChar ( bsWr, 0x45 ); bsPutUChar ( bsWr, 0x38 );
-            bsPutUChar ( bsWr, 0x50 ); bsPutUChar ( bsWr, 0x90 );
-            bsPutUInt32 ( bsWr, blockCRC );
-            bsClose ( bsWr );
-         }
-         if (wrBlock >= rbCtr) break;
-         wrBlock++;
-      } else
-      if (bitsRead == rbStart[wrBlock]) {
-         /* Create the output file name, correctly handling leading paths. 
-            (31.10.2001 by Sergey E. Kusikov) */
-         Char* split;
-         Int32 ofs, k;
-         for (k = 0; k < BZ_MAX_FILENAME; k++) 
-            outFileName[k] = 0;
-         strcpy (outFileName, inFileName);
-         split = strrchr (outFileName, BZ_SPLIT_SYM);
-         if (split == NULL) {
-            split = outFileName;
-         } else {
-            ++split;
-	 }
-	 /* Now split points to the start of the basename. */
-         ofs  = split - outFileName;
-         sprintf (split, "rec%5d", wrBlock+1);
-         for (p = split; *p != 0; p++) if (*p == ' ') *p = '0';
-         strcat (outFileName, inFileName + ofs);
-
-         if ( !endsInBz2(outFileName)) strcat ( outFileName, ".bz2" );
-
-         fprintf ( stderr, "   writing block %d to `%s' ...\n",
-                           wrBlock+1, outFileName );
-
-         outFile = fopen ( outFileName, "wb" );
-         if (outFile == NULL) {
-            fprintf ( stderr, "%s: can't write `%s'\n",
-                      progName, outFileName );
-            exit(1);
-         }
-         bsWr = bsOpenWriteStream ( outFile );
-         bsPutUChar ( bsWr, BZ_HDR_B );    
-         bsPutUChar ( bsWr, BZ_HDR_Z );    
-         bsPutUChar ( bsWr, BZ_HDR_h );    
-         bsPutUChar ( bsWr, BZ_HDR_0 + 9 );
-         bsPutUChar ( bsWr, 0x31 ); bsPutUChar ( bsWr, 0x41 );
-         bsPutUChar ( bsWr, 0x59 ); bsPutUChar ( bsWr, 0x26 );
-         bsPutUChar ( bsWr, 0x53 ); bsPutUChar ( bsWr, 0x59 );
-      }
-   }
-
-   fprintf ( stderr, "%s: finished\n", progName );
-   return 0;
-}
-
-
-
-/*-----------------------------------------------------------*/
-/*--- end                                  bzip2recover.c ---*/
-/*-----------------------------------------------------------*/
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.c b/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.c
deleted file mode 100644
index 3d405f9322a..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.c
+++ /dev/null
@@ -1,1617 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Library top-level functions.                          ---*/
-/*---                                               bzlib.c ---*/
-/*-------------------------------------------------------------*/
-
-/*--
-  This file is a part of bzip2 and/or libbzip2, a program and
-  library for lossless, block-sorting data compression.
-
-  Copyright (C) 1996-2005 Julian R Seward.  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-  2. 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.
-
-  3. Altered source versions must be plainly marked as such, and must
-     not be misrepresented as being the original software.
-
-  4. The name of the author may not be used to endorse or promote 
-     products derived from this software without specific prior written 
-     permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
-
-  Julian Seward, Cambridge, UK.
-  jseward@bzip.org
-  bzip2/libbzip2 version 1.0 of 21 March 2000
-
-  This program is based on (at least) the work of:
-     Mike Burrows
-     David Wheeler
-     Peter Fenwick
-     Alistair Moffat
-     Radford Neal
-     Ian H. Witten
-     Robert Sedgewick
-     Jon L. Bentley
-
-  For more information on these sources, see the manual.
---*/
-
-/*--
-   CHANGES
-   ~~~~~~~
-   0.9.0 -- original version.
-
-   0.9.0a/b -- no changes in this file.
-
-   0.9.0c
-      * made zero-length BZ_FLUSH work correctly in bzCompress().
-      * fixed bzWrite/bzRead to ignore zero-length requests.
-      * fixed bzread to correctly handle read requests after EOF.
-      * wrong parameter order in call to bzDecompressInit in
-        bzBuffToBuffDecompress.  Fixed.
---*/
-
-#define _CRT_SECURE_NO_DEPRECATE
-#include "bzlib_private.h"
-
-
-/*---------------------------------------------------*/
-/*--- Compression stuff                           ---*/
-/*---------------------------------------------------*/
-
-
-/*---------------------------------------------------*/
-#ifndef BZ_NO_STDIO
-void BZ2_bz__AssertH__fail ( int errcode )
-{
-   fprintf(stderr, 
-      "\n\nbzip2/libbzip2: internal error number %d.\n"
-      "This is a bug in bzip2/libbzip2, %s.\n"
-      "Please report it to me at: jseward@bzip.org.  If this happened\n"
-      "when you were using some program which uses libbzip2 as a\n"
-      "component, you should also report this bug to the author(s)\n"
-      "of that program.  Please make an effort to report this bug;\n"
-      "timely and accurate bug reports eventually lead to higher\n"
-      "quality software.  Thanks.  Julian Seward, 15 February 2005.\n\n",
-      errcode,
-      BZ2_bzlibVersion()
-   );
-
-   if (errcode == 1007) {
-   fprintf(stderr,
-      "\n*** A special note about internal error number 1007 ***\n"
-      "\n"
-      "Experience suggests that a common cause of i.e. 1007\n"
-      "is unreliable memory or other hardware.  The 1007 assertion\n"
-      "just happens to cross-check the results of huge numbers of\n"
-      "memory reads/writes, and so acts (unintendedly) as a stress\n"
-      "test of your memory system.\n"
-      "\n"
-      "I suggest the following: try compressing the file again,\n"
-      "possibly monitoring progress in detail with the -vv flag.\n"
-      "\n"
-      "* If the error cannot be reproduced, and/or happens at different\n"
-      "  points in compression, you may have a flaky memory system.\n"
-      "  Try a memory-test program.  I have used Memtest86\n"
-      "  (www.memtest86.com).  At the time of writing it is free (GPLd).\n"
-      "  Memtest86 tests memory much more thorougly than your BIOSs\n"
-      "  power-on test, and may find failures that the BIOS doesn't.\n"
-      "\n"
-      "* If the error can be repeatably reproduced, this is a bug in\n"
-      "  bzip2, and I would very much like to hear about it.  Please\n"
-      "  let me know, and, ideally, save a copy of the file causing the\n"
-      "  problem -- without which I will be unable to investigate it.\n"
-      "\n"
-   );
-   }
-
-   exit(3);
-}
-#endif
-
-
-/*---------------------------------------------------*/
-static
-int bz_config_ok ( void )
-{
-   if (sizeof(int)   != 4) return 0;
-   if (sizeof(short) != 2) return 0;
-   if (sizeof(char)  != 1) return 0;
-   return 1;
-}
-
-
-/*---------------------------------------------------*/
-static
-void* default_bzalloc ( void* opaque, Int32 items, Int32 size )
-{
-   void* v = malloc ( items * size );
-   return v;
-}
-
-static
-void default_bzfree ( void* opaque, void* addr )
-{
-   if (addr != NULL) free ( addr );
-}
-
-
-/*---------------------------------------------------*/
-static
-void prepare_new_block ( EState* s )
-{
-   Int32 i;
-   s->nblock = 0;
-   s->numZ = 0;
-   s->state_out_pos = 0;
-   BZ_INITIALISE_CRC ( s->blockCRC );
-   for (i = 0; i < 256; i++) s->inUse[i] = False;
-   s->blockNo++;
-}
-
-
-/*---------------------------------------------------*/
-static
-void init_RL ( EState* s )
-{
-   s->state_in_ch  = 256;
-   s->state_in_len = 0;
-}
-
-
-static
-Bool isempty_RL ( EState* s )
-{
-   if (s->state_in_ch < 256 && s->state_in_len > 0)
-      return False; else
-      return True;
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzCompressInit) 
-                    ( bz_stream* strm, 
-                     int        blockSize100k,
-                     int        verbosity,
-                     int        workFactor )
-{
-   Int32   n;
-   EState* s;
-
-   if (!bz_config_ok()) return BZ_CONFIG_ERROR;
-
-   if (strm == NULL || 
-       blockSize100k < 1 || blockSize100k > 9 ||
-       workFactor < 0 || workFactor > 250)
-     return BZ_PARAM_ERROR;
-
-   if (workFactor == 0) workFactor = 30;
-   if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
-   if (strm->bzfree == NULL) strm->bzfree = default_bzfree;
-
-   s = BZALLOC( sizeof(EState) );
-   if (s == NULL) return BZ_MEM_ERROR;
-   s->strm = strm;
-
-   s->arr1 = NULL;
-   s->arr2 = NULL;
-   s->ftab = NULL;
-
-   n       = 100000 * blockSize100k;
-   s->arr1 = BZALLOC( n                  * sizeof(UInt32) );
-   s->arr2 = BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) );
-   s->ftab = BZALLOC( 65537              * sizeof(UInt32) );
-
-   if (s->arr1 == NULL || s->arr2 == NULL || s->ftab == NULL) {
-      if (s->arr1 != NULL) BZFREE(s->arr1);
-      if (s->arr2 != NULL) BZFREE(s->arr2);
-      if (s->ftab != NULL) BZFREE(s->ftab);
-      if (s       != NULL) BZFREE(s);
-      return BZ_MEM_ERROR;
-   }
-
-   s->blockNo           = 0;
-   s->state             = BZ_S_INPUT;
-   s->mode              = BZ_M_RUNNING;
-   s->combinedCRC       = 0;
-   s->blockSize100k     = blockSize100k;
-   s->nblockMAX         = 100000 * blockSize100k - 19;
-   s->verbosity         = verbosity;
-   s->workFactor        = workFactor;
-
-   s->block             = (UChar*)s->arr2;
-   s->mtfv              = (UInt16*)s->arr1;
-   s->zbits             = NULL;
-   s->ptr               = (UInt32*)s->arr1;
-
-   strm->state          = s;
-   strm->total_in_lo32  = 0;
-   strm->total_in_hi32  = 0;
-   strm->total_out_lo32 = 0;
-   strm->total_out_hi32 = 0;
-   init_RL ( s );
-   prepare_new_block ( s );
-   return BZ_OK;
-}
-
-
-/*---------------------------------------------------*/
-static
-void add_pair_to_block ( EState* s )
-{
-   Int32 i;
-   UChar ch = (UChar)(s->state_in_ch);
-   for (i = 0; i < s->state_in_len; i++) {
-      BZ_UPDATE_CRC( s->blockCRC, ch );
-   }
-   s->inUse[s->state_in_ch] = True;
-   switch (s->state_in_len) {
-      case 1:
-         s->block[s->nblock] = (UChar)ch; s->nblock++;
-         break;
-      case 2:
-         s->block[s->nblock] = (UChar)ch; s->nblock++;
-         s->block[s->nblock] = (UChar)ch; s->nblock++;
-         break;
-      case 3:
-         s->block[s->nblock] = (UChar)ch; s->nblock++;
-         s->block[s->nblock] = (UChar)ch; s->nblock++;
-         s->block[s->nblock] = (UChar)ch; s->nblock++;
-         break;
-      default:
-         s->inUse[s->state_in_len-4] = True;
-         s->block[s->nblock] = (UChar)ch; s->nblock++;
-         s->block[s->nblock] = (UChar)ch; s->nblock++;
-         s->block[s->nblock] = (UChar)ch; s->nblock++;
-         s->block[s->nblock] = (UChar)ch; s->nblock++;
-         s->block[s->nblock] = ((UChar)(s->state_in_len-4));
-         s->nblock++;
-         break;
-   }
-}
-
-
-/*---------------------------------------------------*/
-static
-void flush_RL ( EState* s )
-{
-   if (s->state_in_ch < 256) add_pair_to_block ( s );
-   init_RL ( s );
-}
-
-
-/*---------------------------------------------------*/
-#define ADD_CHAR_TO_BLOCK(zs,zchh0)               \
-{                                                 \
-   UInt32 zchh = (UInt32)(zchh0);                 \
-   /*-- fast track the common case --*/           \
-   if (zchh != zs->state_in_ch &&                 \
-       zs->state_in_len == 1) {                   \
-      UChar ch = (UChar)(zs->state_in_ch);        \
-      BZ_UPDATE_CRC( zs->blockCRC, ch );          \
-      zs->inUse[zs->state_in_ch] = True;          \
-      zs->block[zs->nblock] = (UChar)ch;          \
-      zs->nblock++;                               \
-      zs->state_in_ch = zchh;                     \
-   }                                              \
-   else                                           \
-   /*-- general, uncommon cases --*/              \
-   if (zchh != zs->state_in_ch ||                 \
-      zs->state_in_len == 255) {                  \
-      if (zs->state_in_ch < 256)                  \
-         add_pair_to_block ( zs );                \
-      zs->state_in_ch = zchh;                     \
-      zs->state_in_len = 1;                       \
-   } else {                                       \
-      zs->state_in_len++;                         \
-   }                                              \
-}
-
-
-/*---------------------------------------------------*/
-static
-Bool copy_input_until_stop ( EState* s )
-{
-   Bool progress_in = False;
-
-   if (s->mode == BZ_M_RUNNING) {
-
-      /*-- fast track the common case --*/
-      while (True) {
-         /*-- block full? --*/
-         if (s->nblock >= s->nblockMAX) break;
-         /*-- no input? --*/
-         if (s->strm->avail_in == 0) break;
-         progress_in = True;
-         ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); 
-         s->strm->next_in++;
-         s->strm->avail_in--;
-         s->strm->total_in_lo32++;
-         if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++;
-      }
-
-   } else {
-
-      /*-- general, uncommon case --*/
-      while (True) {
-         /*-- block full? --*/
-         if (s->nblock >= s->nblockMAX) break;
-         /*-- no input? --*/
-         if (s->strm->avail_in == 0) break;
-         /*-- flush/finish end? --*/
-         if (s->avail_in_expect == 0) break;
-         progress_in = True;
-         ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); 
-         s->strm->next_in++;
-         s->strm->avail_in--;
-         s->strm->total_in_lo32++;
-         if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++;
-         s->avail_in_expect--;
-      }
-   }
-   return progress_in;
-}
-
-
-/*---------------------------------------------------*/
-static
-Bool copy_output_until_stop ( EState* s )
-{
-   Bool progress_out = False;
-
-   while (True) {
-
-      /*-- no output space? --*/
-      if (s->strm->avail_out == 0) break;
-
-      /*-- block done? --*/
-      if (s->state_out_pos >= s->numZ) break;
-
-      progress_out = True;
-      *(s->strm->next_out) = s->zbits[s->state_out_pos];
-      s->state_out_pos++;
-      s->strm->avail_out--;
-      s->strm->next_out++;
-      s->strm->total_out_lo32++;
-      if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
-   }
-
-   return progress_out;
-}
-
-
-/*---------------------------------------------------*/
-static
-Bool handle_compress ( bz_stream* strm )
-{
-   Bool progress_in  = False;
-   Bool progress_out = False;
-   EState* s = strm->state;
-   
-   while (True) {
-
-      if (s->state == BZ_S_OUTPUT) {
-         progress_out |= copy_output_until_stop ( s );
-         if (s->state_out_pos < s->numZ) break;
-         if (s->mode == BZ_M_FINISHING && 
-             s->avail_in_expect == 0 &&
-             isempty_RL(s)) break;
-         prepare_new_block ( s );
-         s->state = BZ_S_INPUT;
-         if (s->mode == BZ_M_FLUSHING && 
-             s->avail_in_expect == 0 &&
-             isempty_RL(s)) break;
-      }
-
-      if (s->state == BZ_S_INPUT) {
-         progress_in |= copy_input_until_stop ( s );
-         if (s->mode != BZ_M_RUNNING && s->avail_in_expect == 0) {
-            flush_RL ( s );
-            BZ2_compressBlock ( s, (Bool)(s->mode == BZ_M_FINISHING) );
-            s->state = BZ_S_OUTPUT;
-         }
-         else
-         if (s->nblock >= s->nblockMAX) {
-            BZ2_compressBlock ( s, False );
-            s->state = BZ_S_OUTPUT;
-         }
-         else
-         if (s->strm->avail_in == 0) {
-            break;
-         }
-      }
-
-   }
-
-   return progress_in || progress_out;
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
-{
-   Bool progress;
-   EState* s;
-   if (strm == NULL) return BZ_PARAM_ERROR;
-   s = strm->state;
-   if (s == NULL) return BZ_PARAM_ERROR;
-   if (s->strm != strm) return BZ_PARAM_ERROR;
-
-   preswitch:
-   switch (s->mode) {
-
-      case BZ_M_IDLE:
-         return BZ_SEQUENCE_ERROR;
-
-      case BZ_M_RUNNING:
-         if (action == BZ_RUN) {
-            progress = handle_compress ( strm );
-            return progress ? BZ_RUN_OK : BZ_PARAM_ERROR;
-         } 
-         else
-         if (action == BZ_FLUSH) {
-            s->avail_in_expect = strm->avail_in;
-            s->mode = BZ_M_FLUSHING;
-            goto preswitch;
-         }
-         else
-         if (action == BZ_FINISH) {
-            s->avail_in_expect = strm->avail_in;
-            s->mode = BZ_M_FINISHING;
-            goto preswitch;
-         }
-         else 
-            return BZ_PARAM_ERROR;
-
-      case BZ_M_FLUSHING:
-         if (action != BZ_FLUSH) return BZ_SEQUENCE_ERROR;
-         if (s->avail_in_expect != s->strm->avail_in) 
-            return BZ_SEQUENCE_ERROR;
-         progress = handle_compress ( strm );
-         if (s->avail_in_expect > 0 || !isempty_RL(s) ||
-             s->state_out_pos < s->numZ) return BZ_FLUSH_OK;
-         s->mode = BZ_M_RUNNING;
-         return BZ_RUN_OK;
-
-      case BZ_M_FINISHING:
-         if (action != BZ_FINISH) return BZ_SEQUENCE_ERROR;
-         if (s->avail_in_expect != s->strm->avail_in) 
-            return BZ_SEQUENCE_ERROR;
-         progress = handle_compress ( strm );
-         if (!progress) return BZ_SEQUENCE_ERROR;
-         if (s->avail_in_expect > 0 || !isempty_RL(s) ||
-             s->state_out_pos < s->numZ) return BZ_FINISH_OK;
-         s->mode = BZ_M_IDLE;
-         return BZ_STREAM_END;
-   }
-   return BZ_OK; /*--not reached--*/
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzCompressEnd)  ( bz_stream *strm )
-{
-   EState* s;
-   if (strm == NULL) return BZ_PARAM_ERROR;
-   s = strm->state;
-   if (s == NULL) return BZ_PARAM_ERROR;
-   if (s->strm != strm) return BZ_PARAM_ERROR;
-
-   if (s->arr1 != NULL) BZFREE(s->arr1);
-   if (s->arr2 != NULL) BZFREE(s->arr2);
-   if (s->ftab != NULL) BZFREE(s->ftab);
-   BZFREE(strm->state);
-
-   strm->state = NULL;   
-
-   return BZ_OK;
-}
-
-
-/*---------------------------------------------------*/
-/*--- Decompression stuff                         ---*/
-/*---------------------------------------------------*/
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzDecompressInit) 
-                     ( bz_stream* strm, 
-                       int        verbosity,
-                       int        small )
-{
-   DState* s;
-
-   if (!bz_config_ok()) return BZ_CONFIG_ERROR;
-
-   if (strm == NULL) return BZ_PARAM_ERROR;
-   if (small != 0 && small != 1) return BZ_PARAM_ERROR;
-   if (verbosity < 0 || verbosity > 4) return BZ_PARAM_ERROR;
-
-   if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
-   if (strm->bzfree == NULL) strm->bzfree = default_bzfree;
-
-   s = BZALLOC( sizeof(DState) );
-   if (s == NULL) return BZ_MEM_ERROR;
-   s->strm                  = strm;
-   strm->state              = s;
-   s->state                 = BZ_X_MAGIC_1;
-   s->bsLive                = 0;
-   s->bsBuff                = 0;
-   s->calculatedCombinedCRC = 0;
-   strm->total_in_lo32      = 0;
-   strm->total_in_hi32      = 0;
-   strm->total_out_lo32     = 0;
-   strm->total_out_hi32     = 0;
-   s->smallDecompress       = (Bool)small;
-   s->ll4                   = NULL;
-   s->ll16                  = NULL;
-   s->tt                    = NULL;
-   s->currBlockNo           = 0;
-   s->verbosity             = verbosity;
-
-   return BZ_OK;
-}
-
-
-/*---------------------------------------------------*/
-/* Return  True iff data corruption is discovered.
-   Returns False if there is no problem.
-*/
-static
-Bool unRLE_obuf_to_output_FAST ( DState* s )
-{
-   UChar k1;
-
-   if (s->blockRandomised) {
-
-      while (True) {
-         /* try to finish existing run */
-         while (True) {
-            if (s->strm->avail_out == 0) return False;
-            if (s->state_out_len == 0) break;
-            *( (UChar*)(s->strm->next_out) ) = s->state_out_ch;
-            BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch );
-            s->state_out_len--;
-            s->strm->next_out++;
-            s->strm->avail_out--;
-            s->strm->total_out_lo32++;
-            if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
-         }
-
-         /* can a new run be started? */
-         if (s->nblock_used == s->save_nblock+1) return False;
-               
-         /* Only caused by corrupt data stream? */
-         if (s->nblock_used > s->save_nblock+1)
-            return True;
-   
-         s->state_out_len = 1;
-         s->state_out_ch = s->k0;
-         BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; 
-         k1 ^= BZ_RAND_MASK; s->nblock_used++;
-         if (s->nblock_used == s->save_nblock+1) continue;
-         if (k1 != s->k0) { s->k0 = k1; continue; };
-   
-         s->state_out_len = 2;
-         BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; 
-         k1 ^= BZ_RAND_MASK; s->nblock_used++;
-         if (s->nblock_used == s->save_nblock+1) continue;
-         if (k1 != s->k0) { s->k0 = k1; continue; };
-   
-         s->state_out_len = 3;
-         BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; 
-         k1 ^= BZ_RAND_MASK; s->nblock_used++;
-         if (s->nblock_used == s->save_nblock+1) continue;
-         if (k1 != s->k0) { s->k0 = k1; continue; };
-   
-         BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; 
-         k1 ^= BZ_RAND_MASK; s->nblock_used++;
-         s->state_out_len = ((Int32)k1) + 4;
-         BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK; 
-         s->k0 ^= BZ_RAND_MASK; s->nblock_used++;
-      }
-
-   } else {
-
-      /* restore */
-      UInt32        c_calculatedBlockCRC = s->calculatedBlockCRC;
-      UChar         c_state_out_ch       = s->state_out_ch;
-      Int32         c_state_out_len      = s->state_out_len;
-      Int32         c_nblock_used        = s->nblock_used;
-      Int32         c_k0                 = s->k0;
-      UInt32*       c_tt                 = s->tt;
-      UInt32        c_tPos               = s->tPos;
-      char*         cs_next_out          = s->strm->next_out;
-      unsigned int  cs_avail_out         = s->strm->avail_out;
-      /* end restore */
-
-      UInt32       avail_out_INIT = cs_avail_out;
-      Int32        s_save_nblockPP = s->save_nblock+1;
-      unsigned int total_out_lo32_old;
-
-      while (True) {
-
-         /* try to finish existing run */
-         if (c_state_out_len > 0) {
-            while (True) {
-               if (cs_avail_out == 0) goto return_notr;
-               if (c_state_out_len == 1) break;
-               *( (UChar*)(cs_next_out) ) = c_state_out_ch;
-               BZ_UPDATE_CRC ( c_calculatedBlockCRC, c_state_out_ch );
-               c_state_out_len--;
-               cs_next_out++;
-               cs_avail_out--;
-            }
-            s_state_out_len_eq_one:
-            {
-               if (cs_avail_out == 0) { 
-                  c_state_out_len = 1; goto return_notr;
-               };
-               *( (UChar*)(cs_next_out) ) = c_state_out_ch;
-               BZ_UPDATE_CRC ( c_calculatedBlockCRC, c_state_out_ch );
-               cs_next_out++;
-               cs_avail_out--;
-            }
-         }   
-         /* Only caused by corrupt data stream? */
-         if (c_nblock_used > s_save_nblockPP)
-            return True;
-
-         /* can a new run be started? */
-         if (c_nblock_used == s_save_nblockPP) {
-            c_state_out_len = 0; goto return_notr;
-         };   
-         c_state_out_ch = c_k0;
-         BZ_GET_FAST_C(k1); c_nblock_used++;
-         if (k1 != c_k0) { 
-            c_k0 = k1; goto s_state_out_len_eq_one; 
-         };
-         if (c_nblock_used == s_save_nblockPP) 
-            goto s_state_out_len_eq_one;
-   
-         c_state_out_len = 2;
-         BZ_GET_FAST_C(k1); c_nblock_used++;
-         if (c_nblock_used == s_save_nblockPP) continue;
-         if (k1 != c_k0) { c_k0 = k1; continue; };
-   
-         c_state_out_len = 3;
-         BZ_GET_FAST_C(k1); c_nblock_used++;
-         if (c_nblock_used == s_save_nblockPP) continue;
-         if (k1 != c_k0) { c_k0 = k1; continue; };
-   
-         BZ_GET_FAST_C(k1); c_nblock_used++;
-         c_state_out_len = ((Int32)k1) + 4;
-         BZ_GET_FAST_C(c_k0); c_nblock_used++;
-      }
-
-      return_notr:
-      total_out_lo32_old = s->strm->total_out_lo32;
-      s->strm->total_out_lo32 += (avail_out_INIT - cs_avail_out);
-      if (s->strm->total_out_lo32 < total_out_lo32_old)
-         s->strm->total_out_hi32++;
-
-      /* save */
-      s->calculatedBlockCRC = c_calculatedBlockCRC;
-      s->state_out_ch       = c_state_out_ch;
-      s->state_out_len      = c_state_out_len;
-      s->nblock_used        = c_nblock_used;
-      s->k0                 = c_k0;
-      s->tt                 = c_tt;
-      s->tPos               = c_tPos;
-      s->strm->next_out     = cs_next_out;
-      s->strm->avail_out    = cs_avail_out;
-      /* end save */
-   }
-   return False;
-}
-
-
-
-/*---------------------------------------------------*/
-__inline__ Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab )
-{
-   Int32 nb, na, mid;
-   nb = 0;
-   na = 256;
-   do {
-      mid = (nb + na) >> 1;
-      if (indx >= cftab[mid]) nb = mid; else na = mid;
-   }
-   while (na - nb != 1);
-   return nb;
-}
-
-
-/*---------------------------------------------------*/
-/* Return  True iff data corruption is discovered.
-   Returns False if there is no problem.
-*/
-static
-Bool unRLE_obuf_to_output_SMALL ( DState* s )
-{
-   UChar k1;
-
-   if (s->blockRandomised) {
-
-      while (True) {
-         /* try to finish existing run */
-         while (True) {
-            if (s->strm->avail_out == 0) return False;
-            if (s->state_out_len == 0) break;
-            *( (UChar*)(s->strm->next_out) ) = s->state_out_ch;
-            BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch );
-            s->state_out_len--;
-            s->strm->next_out++;
-            s->strm->avail_out--;
-            s->strm->total_out_lo32++;
-            if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
-         }
-   
-         /* can a new run be started? */
-         if (s->nblock_used == s->save_nblock+1) return False;
-
-         /* Only caused by corrupt data stream? */
-         if (s->nblock_used > s->save_nblock+1)
-            return True;
-   
-         s->state_out_len = 1;
-         s->state_out_ch = s->k0;
-         BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; 
-         k1 ^= BZ_RAND_MASK; s->nblock_used++;
-         if (s->nblock_used == s->save_nblock+1) continue;
-         if (k1 != s->k0) { s->k0 = k1; continue; };
-   
-         s->state_out_len = 2;
-         BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; 
-         k1 ^= BZ_RAND_MASK; s->nblock_used++;
-         if (s->nblock_used == s->save_nblock+1) continue;
-         if (k1 != s->k0) { s->k0 = k1; continue; };
-   
-         s->state_out_len = 3;
-         BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; 
-         k1 ^= BZ_RAND_MASK; s->nblock_used++;
-         if (s->nblock_used == s->save_nblock+1) continue;
-         if (k1 != s->k0) { s->k0 = k1; continue; };
-   
-         BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; 
-         k1 ^= BZ_RAND_MASK; s->nblock_used++;
-         s->state_out_len = ((Int32)k1) + 4;
-         BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK; 
-         s->k0 ^= BZ_RAND_MASK; s->nblock_used++;
-      }
-
-   } else {
-
-      while (True) {
-         /* try to finish existing run */
-         while (True) {
-            if (s->strm->avail_out == 0) return False;
-            if (s->state_out_len == 0) break;
-            *( (UChar*)(s->strm->next_out) ) = s->state_out_ch;
-            BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch );
-            s->state_out_len--;
-            s->strm->next_out++;
-            s->strm->avail_out--;
-            s->strm->total_out_lo32++;
-            if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
-         }
-   
-         /* can a new run be started? */
-         if (s->nblock_used == s->save_nblock+1) return False;
-
-         /* Only caused by corrupt data stream? */
-         if (s->nblock_used > s->save_nblock+1)
-            return True;
-   
-         s->state_out_len = 1;
-         s->state_out_ch = s->k0;
-         BZ_GET_SMALL(k1); s->nblock_used++;
-         if (s->nblock_used == s->save_nblock+1) continue;
-         if (k1 != s->k0) { s->k0 = k1; continue; };
-   
-         s->state_out_len = 2;
-         BZ_GET_SMALL(k1); s->nblock_used++;
-         if (s->nblock_used == s->save_nblock+1) continue;
-         if (k1 != s->k0) { s->k0 = k1; continue; };
-   
-         s->state_out_len = 3;
-         BZ_GET_SMALL(k1); s->nblock_used++;
-         if (s->nblock_used == s->save_nblock+1) continue;
-         if (k1 != s->k0) { s->k0 = k1; continue; };
-   
-         BZ_GET_SMALL(k1); s->nblock_used++;
-         s->state_out_len = ((Int32)k1) + 4;
-         BZ_GET_SMALL(s->k0); s->nblock_used++;
-      }
-
-   }
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzDecompress) ( bz_stream *strm )
-{
-   Bool    corrupt;
-   DState* s;
-   if (strm == NULL) return BZ_PARAM_ERROR;
-   s = strm->state;
-   if (s == NULL) return BZ_PARAM_ERROR;
-   if (s->strm != strm) return BZ_PARAM_ERROR;
-
-   while (True) {
-      if (s->state == BZ_X_IDLE) return BZ_SEQUENCE_ERROR;
-      if (s->state == BZ_X_OUTPUT) {
-         if (s->smallDecompress)
-            corrupt = unRLE_obuf_to_output_SMALL ( s ); else
-            corrupt = unRLE_obuf_to_output_FAST  ( s );
-         if (corrupt) return BZ_DATA_ERROR;
-         if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) {
-            BZ_FINALISE_CRC ( s->calculatedBlockCRC );
-            if (s->verbosity >= 3) 
-               VPrintf2 ( " {0x%08x, 0x%08x}", s->storedBlockCRC, 
-                          s->calculatedBlockCRC );
-            if (s->verbosity >= 2) VPrintf0 ( "]" );
-            if (s->calculatedBlockCRC != s->storedBlockCRC)
-               return BZ_DATA_ERROR;
-            s->calculatedCombinedCRC 
-               = (s->calculatedCombinedCRC << 1) | 
-                    (s->calculatedCombinedCRC >> 31);
-            s->calculatedCombinedCRC ^= s->calculatedBlockCRC;
-            s->state = BZ_X_BLKHDR_1;
-         } else {
-            return BZ_OK;
-         }
-      }
-      if (s->state >= BZ_X_MAGIC_1) {
-         Int32 r = BZ2_decompress ( s );
-         if (r == BZ_STREAM_END) {
-            if (s->verbosity >= 3)
-               VPrintf2 ( "\n    combined CRCs: stored = 0x%08x, computed = 0x%08x", 
-                          s->storedCombinedCRC, s->calculatedCombinedCRC );
-            if (s->calculatedCombinedCRC != s->storedCombinedCRC)
-               return BZ_DATA_ERROR;
-            return r;
-         }
-         if (s->state != BZ_X_OUTPUT) return r;
-      }
-   }
-
-   AssertH ( 0, 6001 );
-
-   return 0;  /*NOTREACHED*/
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzDecompressEnd)  ( bz_stream *strm )
-{
-   DState* s;
-   if (strm == NULL) return BZ_PARAM_ERROR;
-   s = strm->state;
-   if (s == NULL) return BZ_PARAM_ERROR;
-   if (s->strm != strm) return BZ_PARAM_ERROR;
-
-   if (s->tt   != NULL) BZFREE(s->tt);
-   if (s->ll16 != NULL) BZFREE(s->ll16);
-   if (s->ll4  != NULL) BZFREE(s->ll4);
-
-   BZFREE(strm->state);
-   strm->state = NULL;
-
-   return BZ_OK;
-}
-
-
-#ifndef BZ_NO_STDIO
-/*---------------------------------------------------*/
-/*--- File I/O stuff                              ---*/
-/*---------------------------------------------------*/
-
-#define BZ_SETERR(eee)                    \
-{                                         \
-   if (bzerror != NULL) *bzerror = eee;   \
-   if (bzf != NULL) bzf->lastErr = eee;   \
-}
-
-typedef 
-   struct {
-      FILE*     handle;
-      Char      buf[BZ_MAX_UNUSED];
-      Int32     bufN;
-      Bool      writing;
-      bz_stream strm;
-      Int32     lastErr;
-      Bool      initialisedOk;
-   }
-   bzFile;
-
-
-/*---------------------------------------------*/
-static Bool myfeof ( FILE* f )
-{
-   Int32 c = fgetc ( f );
-   if (c == EOF) return True;
-   ungetc ( c, f );
-   return False;
-}
-
-
-/*---------------------------------------------------*/
-BZFILE* BZ_API(BZ2_bzWriteOpen) 
-                    ( int*  bzerror,      
-                      FILE* f, 
-                      int   blockSize100k, 
-                      int   verbosity,
-                      int   workFactor )
-{
-   Int32   ret;
-   bzFile* bzf = NULL;
-
-   BZ_SETERR(BZ_OK);
-
-   if (f == NULL ||
-       (blockSize100k < 1 || blockSize100k > 9) ||
-       (workFactor < 0 || workFactor > 250) ||
-       (verbosity < 0 || verbosity > 4))
-      { BZ_SETERR(BZ_PARAM_ERROR); return NULL; };
-
-   if (ferror(f))
-      { BZ_SETERR(BZ_IO_ERROR); return NULL; };
-
-   bzf = malloc ( sizeof(bzFile) );
-   if (bzf == NULL)
-      { BZ_SETERR(BZ_MEM_ERROR); return NULL; };
-
-   BZ_SETERR(BZ_OK);
-   bzf->initialisedOk = False;
-   bzf->bufN          = 0;
-   bzf->handle        = f;
-   bzf->writing       = True;
-   bzf->strm.bzalloc  = NULL;
-   bzf->strm.bzfree   = NULL;
-   bzf->strm.opaque   = NULL;
-
-   if (workFactor == 0) workFactor = 30;
-   ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k, 
-                              verbosity, workFactor );
-   if (ret != BZ_OK)
-      { BZ_SETERR(ret); free(bzf); return NULL; };
-
-   bzf->strm.avail_in = 0;
-   bzf->initialisedOk = True;
-   return bzf;   
-}
-
-
-
-/*---------------------------------------------------*/
-void BZ_API(BZ2_bzWrite)
-             ( int*    bzerror, 
-               BZFILE* b, 
-               void*   buf, 
-               int     len )
-{
-   Int32 n, n2, ret;
-   bzFile* bzf = (bzFile*)b;
-
-   BZ_SETERR(BZ_OK);
-   if (bzf == NULL || buf == NULL || len < 0)
-      { BZ_SETERR(BZ_PARAM_ERROR); return; };
-   if (!(bzf->writing))
-      { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
-   if (ferror(bzf->handle))
-      { BZ_SETERR(BZ_IO_ERROR); return; };
-
-   if (len == 0)
-      { BZ_SETERR(BZ_OK); return; };
-
-   bzf->strm.avail_in = len;
-   bzf->strm.next_in  = buf;
-
-   while (True) {
-      bzf->strm.avail_out = BZ_MAX_UNUSED;
-      bzf->strm.next_out = bzf->buf;
-      ret = BZ2_bzCompress ( &(bzf->strm), BZ_RUN );
-      if (ret != BZ_RUN_OK)
-         { BZ_SETERR(ret); return; };
-
-      if (bzf->strm.avail_out < BZ_MAX_UNUSED) {
-         n = BZ_MAX_UNUSED - bzf->strm.avail_out;
-         n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), 
-                       n, bzf->handle );
-         if (n != n2 || ferror(bzf->handle))
-            { BZ_SETERR(BZ_IO_ERROR); return; };
-      }
-
-      if (bzf->strm.avail_in == 0)
-         { BZ_SETERR(BZ_OK); return; };
-   }
-}
-
-
-/*---------------------------------------------------*/
-void BZ_API(BZ2_bzWriteClose)
-                  ( int*          bzerror, 
-                    BZFILE*       b, 
-                    int           abandon,
-                    unsigned int* nbytes_in,
-                    unsigned int* nbytes_out )
-{
-   BZ2_bzWriteClose64 ( bzerror, b, abandon, 
-                        nbytes_in, NULL, nbytes_out, NULL );
-}
-
-
-void BZ_API(BZ2_bzWriteClose64)
-                  ( int*          bzerror, 
-                    BZFILE*       b, 
-                    int           abandon,
-                    unsigned int* nbytes_in_lo32,
-                    unsigned int* nbytes_in_hi32,
-                    unsigned int* nbytes_out_lo32,
-                    unsigned int* nbytes_out_hi32 )
-{
-   Int32   n, n2, ret;
-   bzFile* bzf = (bzFile*)b;
-
-   if (bzf == NULL)
-      { BZ_SETERR(BZ_OK); return; };
-   if (!(bzf->writing))
-      { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
-   if (ferror(bzf->handle))
-      { BZ_SETERR(BZ_IO_ERROR); return; };
-
-   if (nbytes_in_lo32 != NULL) *nbytes_in_lo32 = 0;
-   if (nbytes_in_hi32 != NULL) *nbytes_in_hi32 = 0;
-   if (nbytes_out_lo32 != NULL) *nbytes_out_lo32 = 0;
-   if (nbytes_out_hi32 != NULL) *nbytes_out_hi32 = 0;
-
-   if ((!abandon) && bzf->lastErr == BZ_OK) {
-      while (True) {
-         bzf->strm.avail_out = BZ_MAX_UNUSED;
-         bzf->strm.next_out = bzf->buf;
-         ret = BZ2_bzCompress ( &(bzf->strm), BZ_FINISH );
-         if (ret != BZ_FINISH_OK && ret != BZ_STREAM_END)
-            { BZ_SETERR(ret); return; };
-
-         if (bzf->strm.avail_out < BZ_MAX_UNUSED) {
-            n = BZ_MAX_UNUSED - bzf->strm.avail_out;
-            n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), 
-                          n, bzf->handle );
-            if (n != n2 || ferror(bzf->handle))
-               { BZ_SETERR(BZ_IO_ERROR); return; };
-         }
-
-         if (ret == BZ_STREAM_END) break;
-      }
-   }
-
-   if ( !abandon && !ferror ( bzf->handle ) ) {
-      fflush ( bzf->handle );
-      if (ferror(bzf->handle))
-         { BZ_SETERR(BZ_IO_ERROR); return; };
-   }
-
-   if (nbytes_in_lo32 != NULL)
-      *nbytes_in_lo32 = bzf->strm.total_in_lo32;
-   if (nbytes_in_hi32 != NULL)
-      *nbytes_in_hi32 = bzf->strm.total_in_hi32;
-   if (nbytes_out_lo32 != NULL)
-      *nbytes_out_lo32 = bzf->strm.total_out_lo32;
-   if (nbytes_out_hi32 != NULL)
-      *nbytes_out_hi32 = bzf->strm.total_out_hi32;
-
-   BZ_SETERR(BZ_OK);
-   BZ2_bzCompressEnd ( &(bzf->strm) );
-   free ( bzf );
-}
-
-
-/*---------------------------------------------------*/
-BZFILE* BZ_API(BZ2_bzReadOpen) 
-                   ( int*  bzerror, 
-                     FILE* f, 
-                     int   verbosity,
-                     int   small,
-                     void* unused,
-                     int   nUnused )
-{
-   bzFile* bzf = NULL;
-   int     ret;
-
-   BZ_SETERR(BZ_OK);
-
-   if (f == NULL || 
-       (small != 0 && small != 1) ||
-       (verbosity < 0 || verbosity > 4) ||
-       (unused == NULL && nUnused != 0) ||
-       (unused != NULL && (nUnused < 0 || nUnused > BZ_MAX_UNUSED)))
-      { BZ_SETERR(BZ_PARAM_ERROR); return NULL; };
-
-   if (ferror(f))
-      { BZ_SETERR(BZ_IO_ERROR); return NULL; };
-
-   bzf = malloc ( sizeof(bzFile) );
-   if (bzf == NULL) 
-      { BZ_SETERR(BZ_MEM_ERROR); return NULL; };
-
-   BZ_SETERR(BZ_OK);
-
-   bzf->initialisedOk = False;
-   bzf->handle        = f;
-   bzf->bufN          = 0;
-   bzf->writing       = False;
-   bzf->strm.bzalloc  = NULL;
-   bzf->strm.bzfree   = NULL;
-   bzf->strm.opaque   = NULL;
-   
-   while (nUnused > 0) {
-      bzf->buf[bzf->bufN] = *((UChar*)(unused)); bzf->bufN++;
-      unused = ((void*)( 1 + ((UChar*)(unused))  ));
-      nUnused--;
-   }
-
-   ret = BZ2_bzDecompressInit ( &(bzf->strm), verbosity, small );
-   if (ret != BZ_OK)
-      { BZ_SETERR(ret); free(bzf); return NULL; };
-
-   bzf->strm.avail_in = bzf->bufN;
-   bzf->strm.next_in  = bzf->buf;
-
-   bzf->initialisedOk = True;
-   return bzf;   
-}
-
-
-/*---------------------------------------------------*/
-void BZ_API(BZ2_bzReadClose) ( int *bzerror, BZFILE *b )
-{
-   bzFile* bzf = (bzFile*)b;
-
-   BZ_SETERR(BZ_OK);
-   if (bzf == NULL)
-      { BZ_SETERR(BZ_OK); return; };
-
-   if (bzf->writing)
-      { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
-
-   if (bzf->initialisedOk)
-      (void)BZ2_bzDecompressEnd ( &(bzf->strm) );
-   free ( bzf );
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzRead) 
-           ( int*    bzerror, 
-             BZFILE* b, 
-             void*   buf, 
-             int     len )
-{
-   Int32   n, ret;
-   bzFile* bzf = (bzFile*)b;
-
-   BZ_SETERR(BZ_OK);
-
-   if (bzf == NULL || buf == NULL || len < 0)
-      { BZ_SETERR(BZ_PARAM_ERROR); return 0; };
-
-   if (bzf->writing)
-      { BZ_SETERR(BZ_SEQUENCE_ERROR); return 0; };
-
-   if (len == 0)
-      { BZ_SETERR(BZ_OK); return 0; };
-
-   bzf->strm.avail_out = len;
-   bzf->strm.next_out = buf;
-
-   while (True) {
-
-      if (ferror(bzf->handle)) 
-         { BZ_SETERR(BZ_IO_ERROR); return 0; };
-
-      if (bzf->strm.avail_in == 0 && !myfeof(bzf->handle)) {
-         n = fread ( bzf->buf, sizeof(UChar), 
-                     BZ_MAX_UNUSED, bzf->handle );
-         if (ferror(bzf->handle))
-            { BZ_SETERR(BZ_IO_ERROR); return 0; };
-         bzf->bufN = n;
-         bzf->strm.avail_in = bzf->bufN;
-         bzf->strm.next_in = bzf->buf;
-      }
-
-      ret = BZ2_bzDecompress ( &(bzf->strm) );
-
-      if (ret != BZ_OK && ret != BZ_STREAM_END)
-         { BZ_SETERR(ret); return 0; };
-
-      if (ret == BZ_OK && myfeof(bzf->handle) && 
-          bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0)
-         { BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; };
-
-      if (ret == BZ_STREAM_END)
-         { BZ_SETERR(BZ_STREAM_END);
-           return len - bzf->strm.avail_out; };
-      if (bzf->strm.avail_out == 0)
-         { BZ_SETERR(BZ_OK); return len; };
-      
-   }
-
-   return 0; /*not reached*/
-}
-
-
-/*---------------------------------------------------*/
-void BZ_API(BZ2_bzReadGetUnused) 
-                     ( int*    bzerror, 
-                       BZFILE* b, 
-                       void**  unused, 
-                       int*    nUnused )
-{
-   bzFile* bzf = (bzFile*)b;
-   if (bzf == NULL)
-      { BZ_SETERR(BZ_PARAM_ERROR); return; };
-   if (bzf->lastErr != BZ_STREAM_END)
-      { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
-   if (unused == NULL || nUnused == NULL)
-      { BZ_SETERR(BZ_PARAM_ERROR); return; };
-
-   BZ_SETERR(BZ_OK);
-   *nUnused = bzf->strm.avail_in;
-   *unused = bzf->strm.next_in;
-}
-#endif
-
-
-/*---------------------------------------------------*/
-/*--- Misc convenience stuff                      ---*/
-/*---------------------------------------------------*/
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzBuffToBuffCompress) 
-                         ( char*         dest, 
-                           unsigned int* destLen,
-                           char*         source, 
-                           unsigned int  sourceLen,
-                           int           blockSize100k, 
-                           int           verbosity, 
-                           int           workFactor )
-{
-   bz_stream strm;
-   int ret;
-
-   if (dest == NULL || destLen == NULL || 
-       source == NULL ||
-       blockSize100k < 1 || blockSize100k > 9 ||
-       verbosity < 0 || verbosity > 4 ||
-       workFactor < 0 || workFactor > 250) 
-      return BZ_PARAM_ERROR;
-
-   if (workFactor == 0) workFactor = 30;
-   strm.bzalloc = NULL;
-   strm.bzfree = NULL;
-   strm.opaque = NULL;
-   ret = BZ2_bzCompressInit ( &strm, blockSize100k, 
-                              verbosity, workFactor );
-   if (ret != BZ_OK) return ret;
-
-   strm.next_in = source;
-   strm.next_out = dest;
-   strm.avail_in = sourceLen;
-   strm.avail_out = *destLen;
-
-   ret = BZ2_bzCompress ( &strm, BZ_FINISH );
-   if (ret == BZ_FINISH_OK) goto output_overflow;
-   if (ret != BZ_STREAM_END) goto errhandler;
-
-   /* normal termination */
-   *destLen -= strm.avail_out;   
-   BZ2_bzCompressEnd ( &strm );
-   return BZ_OK;
-
-   output_overflow:
-   BZ2_bzCompressEnd ( &strm );
-   return BZ_OUTBUFF_FULL;
-
-   errhandler:
-   BZ2_bzCompressEnd ( &strm );
-   return ret;
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzBuffToBuffDecompress) 
-                           ( char*         dest, 
-                             unsigned int* destLen,
-                             char*         source, 
-                             unsigned int  sourceLen,
-                             int           small,
-                             int           verbosity )
-{
-   bz_stream strm;
-   int ret;
-
-   if (dest == NULL || destLen == NULL || 
-       source == NULL ||
-       (small != 0 && small != 1) ||
-       verbosity < 0 || verbosity > 4) 
-          return BZ_PARAM_ERROR;
-
-   strm.bzalloc = NULL;
-   strm.bzfree = NULL;
-   strm.opaque = NULL;
-   ret = BZ2_bzDecompressInit ( &strm, verbosity, small );
-   if (ret != BZ_OK) return ret;
-
-   strm.next_in = source;
-   strm.next_out = dest;
-   strm.avail_in = sourceLen;
-   strm.avail_out = *destLen;
-
-   ret = BZ2_bzDecompress ( &strm );
-   if (ret == BZ_OK) goto output_overflow_or_eof;
-   if (ret != BZ_STREAM_END) goto errhandler;
-
-   /* normal termination */
-   *destLen -= strm.avail_out;
-   BZ2_bzDecompressEnd ( &strm );
-   return BZ_OK;
-
-   output_overflow_or_eof:
-   if (strm.avail_out > 0) {
-      BZ2_bzDecompressEnd ( &strm );
-      return BZ_UNEXPECTED_EOF;
-   } else {
-      BZ2_bzDecompressEnd ( &strm );
-      return BZ_OUTBUFF_FULL;
-   };      
-
-   errhandler:
-   BZ2_bzDecompressEnd ( &strm );
-   return ret; 
-}
-
-
-/*---------------------------------------------------*/
-/*--
-   Code contributed by Yoshioka Tsuneo
-   (QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp),
-   to support better zlib compatibility.
-   This code is not _officially_ part of libbzip2 (yet);
-   I haven't tested it, documented it, or considered the
-   threading-safeness of it.
-   If this code breaks, please contact both Yoshioka and me.
---*/
-/*---------------------------------------------------*/
-
-/*---------------------------------------------------*/
-/*--
-   return version like "0.9.0c".
---*/
-const char * BZ_API(BZ2_bzlibVersion)(void)
-{
-   return BZ_VERSION;
-}
-
-
-#ifndef BZ_NO_STDIO
-/*---------------------------------------------------*/
-
-#if defined(_WIN32) || defined(OS2) || defined(MSDOS)
-#   include 
-#   include 
-#   define SET_BINARY_MODE(file) _setmode(_fileno(file),O_BINARY)
-#else
-#   define SET_BINARY_MODE(file)
-#endif
-static
-BZFILE * bzopen_or_bzdopen
-               ( const char *path,   /* no use when bzdopen */
-                 int fd,             /* no use when bzdopen */
-                 const char *mode,
-                 int open_mode)      /* bzopen: 0, bzdopen:1 */
-{
-   int    bzerr;
-   char   unused[BZ_MAX_UNUSED];
-   int    blockSize100k = 9;
-   int    writing       = 0;
-   char   mode2[10]     = "";
-   FILE   *fp           = NULL;
-   BZFILE *bzfp         = NULL;
-   int    verbosity     = 0;
-   int    workFactor    = 30;
-   int    smallMode     = 0;
-   int    nUnused       = 0; 
-
-   if (mode == NULL) return NULL;
-   while (*mode) {
-      switch (*mode) {
-      case 'r':
-         writing = 0; break;
-      case 'w':
-         writing = 1; break;
-      case 's':
-         smallMode = 1; break;
-      default:
-         if (isdigit((int)(*mode))) {
-            blockSize100k = *mode-BZ_HDR_0;
-         }
-      }
-      mode++;
-   }
-   strcat(mode2, writing ? "w" : "r" );
-   strcat(mode2,"b");   /* binary mode */
-
-   if (open_mode==0) {
-      if (path==NULL || strcmp(path,"")==0) {
-        fp = (writing ? stdout : stdin);
-        SET_BINARY_MODE(fp);
-      } else {
-        fp = fopen(path,mode2);
-      }
-   } else {
-#ifdef BZ_STRICT_ANSI
-      fp = NULL;
-#else
-      fp = _fdopen(fd,mode2);
-#endif
-   }
-   if (fp == NULL) return NULL;
-
-   if (writing) {
-      /* Guard against total chaos and anarchy -- JRS */
-      if (blockSize100k < 1) blockSize100k = 1;
-      if (blockSize100k > 9) blockSize100k = 9; 
-      bzfp = BZ2_bzWriteOpen(&bzerr,fp,blockSize100k,
-                             verbosity,workFactor);
-   } else {
-      bzfp = BZ2_bzReadOpen(&bzerr,fp,verbosity,smallMode,
-                            unused,nUnused);
-   }
-   if (bzfp == NULL) {
-      if (fp != stdin && fp != stdout) fclose(fp);
-      return NULL;
-   }
-   return bzfp;
-}
-
-
-/*---------------------------------------------------*/
-/*--
-   open file for read or write.
-      ex) bzopen("file","w9")
-      case path="" or NULL => use stdin or stdout.
---*/
-BZFILE * BZ_API(BZ2_bzopen)
-               ( const char *path,
-                 const char *mode )
-{
-   return bzopen_or_bzdopen(path,-1,mode,/*bzopen*/0);
-}
-
-
-/*---------------------------------------------------*/
-BZFILE * BZ_API(BZ2_bzdopen)
-               ( int fd,
-                 const char *mode )
-{
-   return bzopen_or_bzdopen(NULL,fd,mode,/*bzdopen*/1);
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzread) (BZFILE* b, void* buf, int len )
-{
-   int bzerr, nread;
-   if (((bzFile*)b)->lastErr == BZ_STREAM_END) return 0;
-   nread = BZ2_bzRead(&bzerr,b,buf,len);
-   if (bzerr == BZ_OK || bzerr == BZ_STREAM_END) {
-      return nread;
-   } else {
-      return -1;
-   }
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzwrite) (BZFILE* b, void* buf, int len )
-{
-   int bzerr;
-
-   BZ2_bzWrite(&bzerr,b,buf,len);
-   if(bzerr == BZ_OK){
-      return len;
-   }else{
-      return -1;
-   }
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzflush) (BZFILE *b)
-{
-   /* do nothing now... */
-   return 0;
-}
-
-
-/*---------------------------------------------------*/
-void BZ_API(BZ2_bzclose) (BZFILE* b)
-{
-   int bzerr;
-   FILE *fp = ((bzFile *)b)->handle;
-   
-   if (b==NULL) {return;}
-   if(((bzFile*)b)->writing){
-      BZ2_bzWriteClose(&bzerr,b,0,NULL,NULL);
-      if(bzerr != BZ_OK){
-         BZ2_bzWriteClose(NULL,b,1,NULL,NULL);
-      }
-   }else{
-      BZ2_bzReadClose(&bzerr,b);
-   }
-   if(fp!=stdin && fp!=stdout){
-      fclose(fp);
-   }
-}
-
-
-/*---------------------------------------------------*/
-/*--
-   return last error code 
---*/
-static char *bzerrorstrings[] = {
-       "OK"
-      ,"SEQUENCE_ERROR"
-      ,"PARAM_ERROR"
-      ,"MEM_ERROR"
-      ,"DATA_ERROR"
-      ,"DATA_ERROR_MAGIC"
-      ,"IO_ERROR"
-      ,"UNEXPECTED_EOF"
-      ,"OUTBUFF_FULL"
-      ,"CONFIG_ERROR"
-      ,"???"   /* for future */
-      ,"???"   /* for future */
-      ,"???"   /* for future */
-      ,"???"   /* for future */
-      ,"???"   /* for future */
-      ,"???"   /* for future */
-};
-
-
-const char * BZ_API(BZ2_bzerror) (BZFILE *b, int *errnum)
-{
-   int err = ((bzFile *)b)->lastErr;
-
-   if(err>0) err = 0;
-   *errnum = err;
-   return bzerrorstrings[err*-1];
-}
-#endif
-
-
-/*-------------------------------------------------------------*/
-/*--- end                                           bzlib.c ---*/
-/*-------------------------------------------------------------*/
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.h b/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.h
deleted file mode 100644
index 323724394a2..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib.h
+++ /dev/null
@@ -1,323 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Public header file for the library.                   ---*/
-/*---                                               bzlib.h ---*/
-/*-------------------------------------------------------------*/
-
-/*--
-  This file is a part of bzip2 and/or libbzip2, a program and
-  library for lossless, block-sorting data compression.
-
-  Copyright (C) 1996-2005 Julian R Seward.  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-  2. 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.
-
-  3. Altered source versions must be plainly marked as such, and must
-     not be misrepresented as being the original software.
-
-  4. The name of the author may not be used to endorse or promote 
-     products derived from this software without specific prior written 
-     permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
-
-  Julian Seward, Cambridge, UK.
-  jseward@bzip.org
-  bzip2/libbzip2 version 1.0 of 21 March 2000
-
-  This program is based on (at least) the work of:
-     Mike Burrows
-     David Wheeler
-     Peter Fenwick
-     Alistair Moffat
-     Radford Neal
-     Ian H. Witten
-     Robert Sedgewick
-     Jon L. Bentley
-
-  For more information on these sources, see the manual.
---*/
-
-
-#ifndef _BZLIB_H
-#define _BZLIB_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define BZ_RUN               0
-#define BZ_FLUSH             1
-#define BZ_FINISH            2
-
-#define BZ_OK                0
-#define BZ_RUN_OK            1
-#define BZ_FLUSH_OK          2
-#define BZ_FINISH_OK         3
-#define BZ_STREAM_END        4
-#define BZ_SEQUENCE_ERROR    (-1)
-#define BZ_PARAM_ERROR       (-2)
-#define BZ_MEM_ERROR         (-3)
-#define BZ_DATA_ERROR        (-4)
-#define BZ_DATA_ERROR_MAGIC  (-5)
-#define BZ_IO_ERROR          (-6)
-#define BZ_UNEXPECTED_EOF    (-7)
-#define BZ_OUTBUFF_FULL      (-8)
-#define BZ_CONFIG_ERROR      (-9)
-
-typedef 
-   struct {
-      char *next_in;
-      unsigned int avail_in;
-      unsigned int total_in_lo32;
-      unsigned int total_in_hi32;
-
-      char *next_out;
-      unsigned int avail_out;
-      unsigned int total_out_lo32;
-      unsigned int total_out_hi32;
-
-      void *state;
-
-      void *(*bzalloc)(void *,int,int);
-      void (*bzfree)(void *,void *);
-      void *opaque;
-   } 
-   bz_stream;
-
-
-#ifndef BZ_IMPORT
-#define BZ_EXPORT
-#endif
-
-#ifndef BZ_NO_STDIO
-/* Need a definitition for FILE */
-#include 
-#endif
-
-#ifdef _WIN32
-#   include 
-#   ifdef small
-      /* windows.h define small to char */
-#      undef small
-#   endif
-#   ifdef BZ_EXPORT
-#   define BZ_API(func) WINAPI func
-#   define BZ_EXTERN extern
-#   else
-   /* import windows dll dynamically */
-#   define BZ_API(func) (WINAPI * func)
-#   define BZ_EXTERN
-#   endif
-#else
-#   define BZ_API(func) func
-#   define BZ_EXTERN extern
-#endif
-
-
-/*-- Core (low-level) library functions --*/
-
-BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( 
-      bz_stream* strm, 
-      int        blockSize100k, 
-      int        verbosity, 
-      int        workFactor 
-   );
-
-BZ_EXTERN int BZ_API(BZ2_bzCompress) ( 
-      bz_stream* strm, 
-      int action 
-   );
-
-BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( 
-      bz_stream* strm 
-   );
-
-BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( 
-      bz_stream *strm, 
-      int       verbosity, 
-      int       small
-   );
-
-BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( 
-      bz_stream* strm 
-   );
-
-BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( 
-      bz_stream *strm 
-   );
-
-
-
-/*-- High(er) level library functions --*/
-
-#ifndef BZ_NO_STDIO
-#define BZ_MAX_UNUSED 5000
-
-typedef void BZFILE;
-
-BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( 
-      int*  bzerror,   
-      FILE* f, 
-      int   verbosity, 
-      int   small,
-      void* unused,    
-      int   nUnused 
-   );
-
-BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( 
-      int*    bzerror, 
-      BZFILE* b 
-   );
-
-BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( 
-      int*    bzerror, 
-      BZFILE* b, 
-      void**  unused,  
-      int*    nUnused 
-   );
-
-BZ_EXTERN int BZ_API(BZ2_bzRead) ( 
-      int*    bzerror, 
-      BZFILE* b, 
-      void*   buf, 
-      int     len 
-   );
-
-BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( 
-      int*  bzerror,      
-      FILE* f, 
-      int   blockSize100k, 
-      int   verbosity, 
-      int   workFactor 
-   );
-
-BZ_EXTERN void BZ_API(BZ2_bzWrite) ( 
-      int*    bzerror, 
-      BZFILE* b, 
-      void*   buf, 
-      int     len 
-   );
-
-BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( 
-      int*          bzerror, 
-      BZFILE*       b, 
-      int           abandon, 
-      unsigned int* nbytes_in, 
-      unsigned int* nbytes_out 
-   );
-
-BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( 
-      int*          bzerror, 
-      BZFILE*       b, 
-      int           abandon, 
-      unsigned int* nbytes_in_lo32, 
-      unsigned int* nbytes_in_hi32, 
-      unsigned int* nbytes_out_lo32, 
-      unsigned int* nbytes_out_hi32
-   );
-#endif
-
-
-/*-- Utility functions --*/
-
-BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( 
-      char*         dest, 
-      unsigned int* destLen,
-      char*         source, 
-      unsigned int  sourceLen,
-      int           blockSize100k, 
-      int           verbosity, 
-      int           workFactor 
-   );
-
-BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( 
-      char*         dest, 
-      unsigned int* destLen,
-      char*         source, 
-      unsigned int  sourceLen,
-      int           small, 
-      int           verbosity 
-   );
-
-
-/*--
-   Code contributed by Yoshioka Tsuneo
-   (QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp),
-   to support better zlib compatibility.
-   This code is not _officially_ part of libbzip2 (yet);
-   I haven't tested it, documented it, or considered the
-   threading-safeness of it.
-   If this code breaks, please contact both Yoshioka and me.
---*/
-
-BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
-      void
-   );
-
-#ifndef BZ_NO_STDIO
-BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
-      const char *path,
-      const char *mode
-   );
-
-BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
-      int        fd,
-      const char *mode
-   );
-         
-BZ_EXTERN int BZ_API(BZ2_bzread) (
-      BZFILE* b, 
-      void* buf, 
-      int len 
-   );
-
-BZ_EXTERN int BZ_API(BZ2_bzwrite) (
-      BZFILE* b, 
-      void*   buf, 
-      int     len 
-   );
-
-BZ_EXTERN int BZ_API(BZ2_bzflush) (
-      BZFILE* b
-   );
-
-BZ_EXTERN void BZ_API(BZ2_bzclose) (
-      BZFILE* b
-   );
-
-BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
-      BZFILE *b, 
-      int    *errnum
-   );
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-/*-------------------------------------------------------------*/
-/*--- end                                           bzlib.h ---*/
-/*-------------------------------------------------------------*/
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib_private.h b/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib_private.h
deleted file mode 100644
index ca76fe62b3b..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzlib_private.h
+++ /dev/null
@@ -1,537 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Private header file for the library.                  ---*/
-/*---                                       bzlib_private.h ---*/
-/*-------------------------------------------------------------*/
-
-/*--
-  This file is a part of bzip2 and/or libbzip2, a program and
-  library for lossless, block-sorting data compression.
-
-  Copyright (C) 1996-2005 Julian R Seward.  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-  2. 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.
-
-  3. Altered source versions must be plainly marked as such, and must
-     not be misrepresented as being the original software.
-
-  4. The name of the author may not be used to endorse or promote 
-     products derived from this software without specific prior written 
-     permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
-
-  Julian Seward, Cambridge, UK.
-  jseward@bzip.org
-  bzip2/libbzip2 version 1.0 of 21 March 2000
-
-  This program is based on (at least) the work of:
-     Mike Burrows
-     David Wheeler
-     Peter Fenwick
-     Alistair Moffat
-     Radford Neal
-     Ian H. Witten
-     Robert Sedgewick
-     Jon L. Bentley
-
-  For more information on these sources, see the manual.
---*/
-
-
-#ifndef _BZLIB_PRIVATE_H
-#define _BZLIB_PRIVATE_H
-
-#include 
-
-#ifndef BZ_NO_STDIO
-#include 
-#include 
-#include 
-#endif
-
-#include "bzlib.h"
-
-
-
-/*-- General stuff. --*/
-
-#define BZ_VERSION  "1.0.3, 15-Feb-2005"
-
-typedef char            Char;
-typedef unsigned char   Bool;
-typedef unsigned char   UChar;
-typedef int             Int32;
-typedef unsigned int    UInt32;
-typedef short           Int16;
-typedef unsigned short  UInt16;
-
-#define True  ((Bool)1)
-#define False ((Bool)0)
-
-#ifndef __GNUC__
-#define __inline__  /* */
-#endif 
-
-#ifndef BZ_NO_STDIO
-extern void BZ2_bz__AssertH__fail ( int errcode );
-#define AssertH(cond,errcode) \
-   { if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); }
-#if BZ_DEBUG
-#define AssertD(cond,msg) \
-   { if (!(cond)) {       \
-      fprintf ( stderr,   \
-        "\n\nlibbzip2(debug build): internal error\n\t%s\n", msg );\
-      exit(1); \
-   }}
-#else
-#define AssertD(cond,msg) /* */
-#endif
-#define VPrintf0(zf) \
-   fprintf(stderr,zf)
-#define VPrintf1(zf,za1) \
-   fprintf(stderr,zf,za1)
-#define VPrintf2(zf,za1,za2) \
-   fprintf(stderr,zf,za1,za2)
-#define VPrintf3(zf,za1,za2,za3) \
-   fprintf(stderr,zf,za1,za2,za3)
-#define VPrintf4(zf,za1,za2,za3,za4) \
-   fprintf(stderr,zf,za1,za2,za3,za4)
-#define VPrintf5(zf,za1,za2,za3,za4,za5) \
-   fprintf(stderr,zf,za1,za2,za3,za4,za5)
-#else
-extern void bz_internal_error ( int errcode );
-#define AssertH(cond,errcode) \
-   { if (!(cond)) bz_internal_error ( errcode ); }
-#define AssertD(cond,msg) /* */
-#define VPrintf0(zf) /* */
-#define VPrintf1(zf,za1) /* */
-#define VPrintf2(zf,za1,za2) /* */
-#define VPrintf3(zf,za1,za2,za3) /* */
-#define VPrintf4(zf,za1,za2,za3,za4) /* */
-#define VPrintf5(zf,za1,za2,za3,za4,za5) /* */
-#endif
-
-
-#define BZALLOC(nnn) (strm->bzalloc)(strm->opaque,(nnn),1)
-#define BZFREE(ppp)  (strm->bzfree)(strm->opaque,(ppp))
-
-
-/*-- Header bytes. --*/
-
-#define BZ_HDR_B 0x42   /* 'B' */
-#define BZ_HDR_Z 0x5a   /* 'Z' */
-#define BZ_HDR_h 0x68   /* 'h' */
-#define BZ_HDR_0 0x30   /* '0' */
-  
-/*-- Constants for the back end. --*/
-
-#define BZ_MAX_ALPHA_SIZE 258
-#define BZ_MAX_CODE_LEN    23
-
-#define BZ_RUNA 0
-#define BZ_RUNB 1
-
-#define BZ_N_GROUPS 6
-#define BZ_G_SIZE   50
-#define BZ_N_ITERS  4
-
-#define BZ_MAX_SELECTORS (2 + (900000 / BZ_G_SIZE))
-
-
-
-/*-- Stuff for randomising repetitive blocks. --*/
-
-extern Int32 BZ2_rNums[512];
-
-#define BZ_RAND_DECLS                          \
-   Int32 rNToGo;                               \
-   Int32 rTPos                                 \
-
-#define BZ_RAND_INIT_MASK                      \
-   s->rNToGo = 0;                              \
-   s->rTPos  = 0                               \
-
-#define BZ_RAND_MASK ((s->rNToGo == 1) ? 1 : 0)
-
-#define BZ_RAND_UPD_MASK                       \
-   if (s->rNToGo == 0) {                       \
-      s->rNToGo = BZ2_rNums[s->rTPos];         \
-      s->rTPos++;                              \
-      if (s->rTPos == 512) s->rTPos = 0;       \
-   }                                           \
-   s->rNToGo--;
-
-
-
-/*-- Stuff for doing CRCs. --*/
-
-extern UInt32 BZ2_crc32Table[256];
-
-#define BZ_INITIALISE_CRC(crcVar)              \
-{                                              \
-   crcVar = 0xffffffffL;                       \
-}
-
-#define BZ_FINALISE_CRC(crcVar)                \
-{                                              \
-   crcVar = ~(crcVar);                         \
-}
-
-#define BZ_UPDATE_CRC(crcVar,cha)              \
-{                                              \
-   crcVar = (crcVar << 8) ^                    \
-            BZ2_crc32Table[(crcVar >> 24) ^    \
-                           ((UChar)cha)];      \
-}
-
-
-
-/*-- States and modes for compression. --*/
-
-#define BZ_M_IDLE      1
-#define BZ_M_RUNNING   2
-#define BZ_M_FLUSHING  3
-#define BZ_M_FINISHING 4
-
-#define BZ_S_OUTPUT    1
-#define BZ_S_INPUT     2
-
-#define BZ_N_RADIX 2
-#define BZ_N_QSORT 12
-#define BZ_N_SHELL 18
-#define BZ_N_OVERSHOOT (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2)
-
-
-
-
-/*-- Structure holding all the compression-side stuff. --*/
-
-typedef
-   struct {
-      /* pointer back to the struct bz_stream */
-      bz_stream* strm;
-
-      /* mode this stream is in, and whether inputting */
-      /* or outputting data */
-      Int32    mode;
-      Int32    state;
-
-      /* remembers avail_in when flush/finish requested */
-      UInt32   avail_in_expect;
-
-      /* for doing the block sorting */
-      UInt32*  arr1;
-      UInt32*  arr2;
-      UInt32*  ftab;
-      Int32    origPtr;
-
-      /* aliases for arr1 and arr2 */
-      UInt32*  ptr;
-      UChar*   block;
-      UInt16*  mtfv;
-      UChar*   zbits;
-
-      /* for deciding when to use the fallback sorting algorithm */
-      Int32    workFactor;
-
-      /* run-length-encoding of the input */
-      UInt32   state_in_ch;
-      Int32    state_in_len;
-      BZ_RAND_DECLS;
-
-      /* input and output limits and current posns */
-      Int32    nblock;
-      Int32    nblockMAX;
-      Int32    numZ;
-      Int32    state_out_pos;
-
-      /* map of bytes used in block */
-      Int32    nInUse;
-      Bool     inUse[256];
-      UChar    unseqToSeq[256];
-
-      /* the buffer for bit stream creation */
-      UInt32   bsBuff;
-      Int32    bsLive;
-
-      /* block and combined CRCs */
-      UInt32   blockCRC;
-      UInt32   combinedCRC;
-
-      /* misc administratium */
-      Int32    verbosity;
-      Int32    blockNo;
-      Int32    blockSize100k;
-
-      /* stuff for coding the MTF values */
-      Int32    nMTF;
-      Int32    mtfFreq    [BZ_MAX_ALPHA_SIZE];
-      UChar    selector   [BZ_MAX_SELECTORS];
-      UChar    selectorMtf[BZ_MAX_SELECTORS];
-
-      UChar    len     [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
-      Int32    code    [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
-      Int32    rfreq   [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
-      /* second dimension: only 3 needed; 4 makes index calculations faster */
-      UInt32   len_pack[BZ_MAX_ALPHA_SIZE][4];
-
-   }
-   EState;
-
-
-
-/*-- externs for compression. --*/
-
-extern void 
-BZ2_blockSort ( EState* );
-
-extern void 
-BZ2_compressBlock ( EState*, Bool );
-
-extern void 
-BZ2_bsInitWrite ( EState* );
-
-extern void 
-BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 );
-
-extern void 
-BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 );
-
-
-
-/*-- states for decompression. --*/
-
-#define BZ_X_IDLE        1
-#define BZ_X_OUTPUT      2
-
-#define BZ_X_MAGIC_1     10
-#define BZ_X_MAGIC_2     11
-#define BZ_X_MAGIC_3     12
-#define BZ_X_MAGIC_4     13
-#define BZ_X_BLKHDR_1    14
-#define BZ_X_BLKHDR_2    15
-#define BZ_X_BLKHDR_3    16
-#define BZ_X_BLKHDR_4    17
-#define BZ_X_BLKHDR_5    18
-#define BZ_X_BLKHDR_6    19
-#define BZ_X_BCRC_1      20
-#define BZ_X_BCRC_2      21
-#define BZ_X_BCRC_3      22
-#define BZ_X_BCRC_4      23
-#define BZ_X_RANDBIT     24
-#define BZ_X_ORIGPTR_1   25
-#define BZ_X_ORIGPTR_2   26
-#define BZ_X_ORIGPTR_3   27
-#define BZ_X_MAPPING_1   28
-#define BZ_X_MAPPING_2   29
-#define BZ_X_SELECTOR_1  30
-#define BZ_X_SELECTOR_2  31
-#define BZ_X_SELECTOR_3  32
-#define BZ_X_CODING_1    33
-#define BZ_X_CODING_2    34
-#define BZ_X_CODING_3    35
-#define BZ_X_MTF_1       36
-#define BZ_X_MTF_2       37
-#define BZ_X_MTF_3       38
-#define BZ_X_MTF_4       39
-#define BZ_X_MTF_5       40
-#define BZ_X_MTF_6       41
-#define BZ_X_ENDHDR_2    42
-#define BZ_X_ENDHDR_3    43
-#define BZ_X_ENDHDR_4    44
-#define BZ_X_ENDHDR_5    45
-#define BZ_X_ENDHDR_6    46
-#define BZ_X_CCRC_1      47
-#define BZ_X_CCRC_2      48
-#define BZ_X_CCRC_3      49
-#define BZ_X_CCRC_4      50
-
-
-
-/*-- Constants for the fast MTF decoder. --*/
-
-#define MTFA_SIZE 4096
-#define MTFL_SIZE 16
-
-
-
-/*-- Structure holding all the decompression-side stuff. --*/
-
-typedef
-   struct {
-      /* pointer back to the struct bz_stream */
-      bz_stream* strm;
-
-      /* state indicator for this stream */
-      Int32    state;
-
-      /* for doing the final run-length decoding */
-      UChar    state_out_ch;
-      Int32    state_out_len;
-      Bool     blockRandomised;
-      BZ_RAND_DECLS;
-
-      /* the buffer for bit stream reading */
-      UInt32   bsBuff;
-      Int32    bsLive;
-
-      /* misc administratium */
-      Int32    blockSize100k;
-      Bool     smallDecompress;
-      Int32    currBlockNo;
-      Int32    verbosity;
-
-      /* for undoing the Burrows-Wheeler transform */
-      Int32    origPtr;
-      UInt32   tPos;
-      Int32    k0;
-      Int32    unzftab[256];
-      Int32    nblock_used;
-      Int32    cftab[257];
-      Int32    cftabCopy[257];
-
-      /* for undoing the Burrows-Wheeler transform (FAST) */
-      UInt32   *tt;
-
-      /* for undoing the Burrows-Wheeler transform (SMALL) */
-      UInt16   *ll16;
-      UChar    *ll4;
-
-      /* stored and calculated CRCs */
-      UInt32   storedBlockCRC;
-      UInt32   storedCombinedCRC;
-      UInt32   calculatedBlockCRC;
-      UInt32   calculatedCombinedCRC;
-
-      /* map of bytes used in block */
-      Int32    nInUse;
-      Bool     inUse[256];
-      Bool     inUse16[16];
-      UChar    seqToUnseq[256];
-
-      /* for decoding the MTF values */
-      UChar    mtfa   [MTFA_SIZE];
-      Int32    mtfbase[256 / MTFL_SIZE];
-      UChar    selector   [BZ_MAX_SELECTORS];
-      UChar    selectorMtf[BZ_MAX_SELECTORS];
-      UChar    len  [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
-
-      Int32    limit  [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
-      Int32    base   [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
-      Int32    perm   [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
-      Int32    minLens[BZ_N_GROUPS];
-
-      /* save area for scalars in the main decompress code */
-      Int32    save_i;
-      Int32    save_j;
-      Int32    save_t;
-      Int32    save_alphaSize;
-      Int32    save_nGroups;
-      Int32    save_nSelectors;
-      Int32    save_EOB;
-      Int32    save_groupNo;
-      Int32    save_groupPos;
-      Int32    save_nextSym;
-      Int32    save_nblockMAX;
-      Int32    save_nblock;
-      Int32    save_es;
-      Int32    save_N;
-      Int32    save_curr;
-      Int32    save_zt;
-      Int32    save_zn; 
-      Int32    save_zvec;
-      Int32    save_zj;
-      Int32    save_gSel;
-      Int32    save_gMinlen;
-      Int32*   save_gLimit;
-      Int32*   save_gBase;
-      Int32*   save_gPerm;
-
-   }
-   DState;
-
-
-
-/*-- Macros for decompression. --*/
-
-#define BZ_GET_FAST(cccc)                     \
-    s->tPos = s->tt[s->tPos];                 \
-    cccc = (UChar)(s->tPos & 0xff);           \
-    s->tPos >>= 8;
-
-#define BZ_GET_FAST_C(cccc)                   \
-    c_tPos = c_tt[c_tPos];                    \
-    cccc = (UChar)(c_tPos & 0xff);            \
-    c_tPos >>= 8;
-
-#define SET_LL4(i,n)                                          \
-   { if (((i) & 0x1) == 0)                                    \
-        s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0xf0) | (n); else    \
-        s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0x0f) | ((n) << 4);  \
-   }
-
-#define GET_LL4(i)                             \
-   ((((UInt32)(s->ll4[(i) >> 1])) >> (((i) << 2) & 0x4)) & 0xF)
-
-#define SET_LL(i,n)                          \
-   { s->ll16[i] = (UInt16)(n & 0x0000ffff);  \
-     SET_LL4(i, n >> 16);                    \
-   }
-
-#define GET_LL(i) \
-   (((UInt32)s->ll16[i]) | (GET_LL4(i) << 16))
-
-#define BZ_GET_SMALL(cccc)                            \
-      cccc = BZ2_indexIntoF ( s->tPos, s->cftab );    \
-      s->tPos = GET_LL(s->tPos);
-
-
-/*-- externs for decompression. --*/
-
-extern Int32 
-BZ2_indexIntoF ( Int32, Int32* );
-
-extern Int32 
-BZ2_decompress ( DState* );
-
-extern void 
-BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*,
-                           Int32,  Int32, Int32 );
-
-
-#endif
-
-
-/*-- BZ_NO_STDIO seems to make NULL disappear on some platforms. --*/
-
-#ifdef BZ_NO_STDIO
-#ifndef NULL
-#define NULL 0
-#endif
-#endif
-
-
-/*-------------------------------------------------------------*/
-/*--- end                                   bzlib_private.h ---*/
-/*-------------------------------------------------------------*/
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzmore b/contrib/vmap_extractor_v2/stormlib/bzip2/bzmore
deleted file mode 100644
index d3140434049..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzmore
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/bin/sh
-
-# Bzmore wrapped for bzip2, 
-# adapted from zmore by Philippe Troin  for Debian GNU/Linux.
-
-PATH="/usr/bin:$PATH"; export PATH
-
-prog=`echo $0 | sed 's|.*/||'`
-case "$prog" in
-	*less)	more=less	;;
-	*)	more=more       ;;
-esac
-
-if test "`echo -n a`" = "-n a"; then
-  # looks like a SysV system:
-  n1=''; n2='\c'
-else
-  n1='-n'; n2=''
-fi
-oldtty=`stty -g 2>/dev/null`
-if stty -cbreak 2>/dev/null; then
-  cb='cbreak'; ncb='-cbreak'
-else
-  # 'stty min 1' resets eof to ^a on both SunOS and SysV!
-  cb='min 1 -icanon'; ncb='icanon eof ^d'
-fi
-if test $? -eq 0 -a -n "$oldtty"; then
-   trap 'stty $oldtty 2>/dev/null; exit' 0 2 3 5 10 13 15
-else
-   trap 'stty $ncb echo 2>/dev/null; exit' 0 2 3 5 10 13 15
-fi
-
-if test $# = 0; then
-    if test -t 0; then
-	echo usage: $prog files...
-    else
-	bzip2 -cdfq | eval $more
-    fi
-else
-    FIRST=1
-    for FILE
-    do
-	if test $FIRST -eq 0; then
-		echo $n1 "--More--(Next file: $FILE)$n2"
-		stty $cb -echo 2>/dev/null
-		ANS=`dd bs=1 count=1 2>/dev/null` 
-		stty $ncb echo 2>/dev/null
-		echo " "
-		if test "$ANS" = 'e' -o "$ANS" = 'q'; then
-			exit
-		fi
-	fi
-	if test "$ANS" != 's'; then
-		echo "------> $FILE <------"
-		bzip2 -cdfq "$FILE" | eval $more
-	fi
-	if test -t; then
-		FIRST=0
-	fi
-    done
-fi
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/bzmore.1 b/contrib/vmap_extractor_v2/stormlib/bzip2/bzmore.1
deleted file mode 100644
index b437d3b031f..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/bzmore.1
+++ /dev/null
@@ -1,152 +0,0 @@
-.\"Shamelessly copied from zmore.1 by Philippe Troin 
-.\"for Debian GNU/Linux
-.TH BZMORE 1
-.SH NAME
-bzmore, bzless \- file perusal filter for crt viewing of bzip2 compressed text
-.SH SYNOPSIS
-.B bzmore
-[ name ...  ]
-.br
-.B bzless
-[ name ...  ]
-.SH NOTE
-In the following description,
-.I bzless
-and
-.I less
-can be used interchangeably with
-.I bzmore
-and
-.I more.
-.SH DESCRIPTION
-.I  Bzmore
-is a filter which allows examination of compressed or plain text files
-one screenful at a time on a soft-copy terminal.
-.I bzmore
-works on files compressed with
-.I bzip2
-and also on uncompressed files.
-If a file does not exist,
-.I bzmore
-looks for a file of the same name with the addition of a .bz2 suffix.
-.PP
-.I Bzmore
-normally pauses after each screenful, printing --More--
-at the bottom of the screen.
-If the user then types a carriage return, one more line is displayed.
-If the user hits a space,
-another screenful is displayed.  Other possibilities are enumerated later.
-.PP
-.I Bzmore
-looks in the file
-.I /etc/termcap
-to determine terminal characteristics,
-and to determine the default window size.
-On a terminal capable of displaying 24 lines,
-the default window size is 22 lines.
-Other sequences which may be typed when
-.I bzmore
-pauses, and their effects, are as follows (\fIi\fP is an optional integer
-argument, defaulting to 1) :
-.PP
-.IP \fIi\|\fP
-display
-.I i
-more lines, (or another screenful if no argument is given)
-.PP
-.IP ^D
-display 11 more lines (a ``scroll'').
-If
-.I i
-is given, then the scroll size is set to \fIi\|\fP.
-.PP
-.IP d
-same as ^D (control-D)
-.PP
-.IP \fIi\|\fPz
-same as typing a space except that \fIi\|\fP, if present, becomes the new
-window size.  Note that the window size reverts back to the default at the
-end of the current file.
-.PP
-.IP \fIi\|\fPs
-skip \fIi\|\fP lines and print a screenful of lines
-.PP
-.IP \fIi\|\fPf
-skip \fIi\fP screenfuls and print a screenful of lines
-.PP
-.IP "q or Q"
-quit reading the current file; go on to the next (if any)
-.PP
-.IP "e or q"
-When the prompt --More--(Next file: 
-.IR file )
-is printed, this command causes bzmore to exit.
-.PP
-.IP s
-When the prompt --More--(Next file: 
-.IR file )
-is printed, this command causes bzmore to skip the next file and continue.
-.PP 
-.IP =
-Display the current line number.
-.PP
-.IP \fIi\|\fP/expr
-search for the \fIi\|\fP-th occurrence of the regular expression \fIexpr.\fP
-If the pattern is not found,
-.I bzmore
-goes on to the next file (if any).
-Otherwise, a screenful is displayed, starting two lines before the place
-where the expression was found.
-The user's erase and kill characters may be used to edit the regular
-expression.
-Erasing back past the first column cancels the search command.
-.PP
-.IP \fIi\|\fPn
-search for the \fIi\|\fP-th occurrence of the last regular expression entered.
-.PP
-.IP !command
-invoke a shell with \fIcommand\|\fP. 
-The character `!' in "command" are replaced with the
-previous shell command.  The sequence "\\!" is replaced by "!".
-.PP
-.IP ":q or :Q"
-quit reading the current file; go on to the next (if any)
-(same as q or Q).
-.PP
-.IP .
-(dot) repeat the previous command.
-.PP
-The commands take effect immediately, i.e., it is not necessary to
-type a carriage return.
-Up to the time when the command character itself is given,
-the user may hit the line kill character to cancel the numerical
-argument being formed.
-In addition, the user may hit the erase character to redisplay the
---More-- message.
-.PP
-At any time when output is being sent to the terminal, the user can
-hit the quit key (normally control\-\\).
-.I Bzmore
-will stop sending output, and will display the usual --More--
-prompt.
-The user may then enter one of the above commands in the normal manner.
-Unfortunately, some output is lost when this is done, due to the
-fact that any characters waiting in the terminal's output queue
-are flushed when the quit signal occurs.
-.PP
-The terminal is set to
-.I noecho
-mode by this program so that the output can be continuous.
-What you type will thus not show on your terminal, except for the / and !
-commands.
-.PP
-If the standard output is not a teletype, then
-.I bzmore
-acts just like
-.I bzcat,
-except that a header is printed before each file.
-.SH FILES
-.DT
-/etc/termcap		Terminal data base
-.SH "SEE ALSO"
-more(1), less(1), bzip2(1), bzdiff(1), bzgrep(1)
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/compress.c b/contrib/vmap_extractor_v2/stormlib/bzip2/compress.c
deleted file mode 100644
index 156056fb376..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/compress.c
+++ /dev/null
@@ -1,715 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Compression machinery (not incl block sorting)        ---*/
-/*---                                            compress.c ---*/
-/*-------------------------------------------------------------*/
-
-/*--
-  This file is a part of bzip2 and/or libbzip2, a program and
-  library for lossless, block-sorting data compression.
-
-  Copyright (C) 1996-2005 Julian R Seward.  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-  2. 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.
-
-  3. Altered source versions must be plainly marked as such, and must
-     not be misrepresented as being the original software.
-
-  4. The name of the author may not be used to endorse or promote 
-     products derived from this software without specific prior written 
-     permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
-
-  Julian Seward, Cambridge, UK.
-  jseward@bzip.org
-  bzip2/libbzip2 version 1.0 of 21 March 2000
-
-  This program is based on (at least) the work of:
-     Mike Burrows
-     David Wheeler
-     Peter Fenwick
-     Alistair Moffat
-     Radford Neal
-     Ian H. Witten
-     Robert Sedgewick
-     Jon L. Bentley
-
-  For more information on these sources, see the manual.
---*/
-
-/*--
-   CHANGES
-   ~~~~~~~
-   0.9.0 -- original version.
-
-   0.9.0a/b -- no changes in this file.
-
-   0.9.0c
-      * changed setting of nGroups in sendMTFValues() so as to 
-        do a bit better on small files
---*/
-
-#include "bzlib_private.h"
-
-
-/*---------------------------------------------------*/
-/*--- Bit stream I/O                              ---*/
-/*---------------------------------------------------*/
-
-/*---------------------------------------------------*/
-void BZ2_bsInitWrite ( EState* s )
-{
-   s->bsLive = 0;
-   s->bsBuff = 0;
-}
-
-
-/*---------------------------------------------------*/
-static
-void bsFinishWrite ( EState* s )
-{
-   while (s->bsLive > 0) {
-      s->zbits[s->numZ] = (UChar)(s->bsBuff >> 24);
-      s->numZ++;
-      s->bsBuff <<= 8;
-      s->bsLive -= 8;
-   }
-}
-
-
-/*---------------------------------------------------*/
-#define bsNEEDW(nz)                           \
-{                                             \
-   while (s->bsLive >= 8) {                   \
-      s->zbits[s->numZ]                       \
-         = (UChar)(s->bsBuff >> 24);          \
-      s->numZ++;                              \
-      s->bsBuff <<= 8;                        \
-      s->bsLive -= 8;                         \
-   }                                          \
-}
-
-
-/*---------------------------------------------------*/
-static
-__inline__
-void bsW ( EState* s, Int32 n, UInt32 v )
-{
-   bsNEEDW ( n );
-   s->bsBuff |= (v << (32 - s->bsLive - n));
-   s->bsLive += n;
-}
-
-
-/*---------------------------------------------------*/
-static
-void bsPutUInt32 ( EState* s, UInt32 u )
-{
-   bsW ( s, 8, (u >> 24) & 0xffL );
-   bsW ( s, 8, (u >> 16) & 0xffL );
-   bsW ( s, 8, (u >>  8) & 0xffL );
-   bsW ( s, 8,  u        & 0xffL );
-}
-
-
-/*---------------------------------------------------*/
-static
-void bsPutUChar ( EState* s, UChar c )
-{
-   bsW( s, 8, (UInt32)c );
-}
-
-
-/*---------------------------------------------------*/
-/*--- The back end proper                         ---*/
-/*---------------------------------------------------*/
-
-/*---------------------------------------------------*/
-static
-void makeMaps_e ( EState* s )
-{
-   Int32 i;
-   s->nInUse = 0;
-   for (i = 0; i < 256; i++)
-      if (s->inUse[i]) {
-         s->unseqToSeq[i] = s->nInUse;
-         s->nInUse++;
-      }
-}
-
-
-/*---------------------------------------------------*/
-static
-void generateMTFValues ( EState* s )
-{
-   UChar   yy[256];
-   Int32   i, j;
-   Int32   zPend;
-   Int32   wr;
-   Int32   EOB;
-
-   /* 
-      After sorting (eg, here),
-         s->arr1 [ 0 .. s->nblock-1 ] holds sorted order,
-         and
-         ((UChar*)s->arr2) [ 0 .. s->nblock-1 ] 
-         holds the original block data.
-
-      The first thing to do is generate the MTF values,
-      and put them in
-         ((UInt16*)s->arr1) [ 0 .. s->nblock-1 ].
-      Because there are strictly fewer or equal MTF values
-      than block values, ptr values in this area are overwritten
-      with MTF values only when they are no longer needed.
-
-      The final compressed bitstream is generated into the
-      area starting at
-         (UChar*) (&((UChar*)s->arr2)[s->nblock])
-
-      These storage aliases are set up in bzCompressInit(),
-      except for the last one, which is arranged in 
-      compressBlock().
-   */
-   UInt32* ptr   = s->ptr;
-   UChar* block  = s->block;
-   UInt16* mtfv  = s->mtfv;
-
-   makeMaps_e ( s );
-   EOB = s->nInUse+1;
-
-   for (i = 0; i <= EOB; i++) s->mtfFreq[i] = 0;
-
-   wr = 0;
-   zPend = 0;
-   for (i = 0; i < s->nInUse; i++) yy[i] = (UChar) i;
-
-   for (i = 0; i < s->nblock; i++) {
-      UChar ll_i;
-      AssertD ( wr <= i, "generateMTFValues(1)" );
-      j = ptr[i]-1; if (j < 0) j += s->nblock;
-      ll_i = s->unseqToSeq[block[j]];
-      AssertD ( ll_i < s->nInUse, "generateMTFValues(2a)" );
-
-      if (yy[0] == ll_i) { 
-         zPend++;
-      } else {
-
-         if (zPend > 0) {
-            zPend--;
-            while (True) {
-               if (zPend & 1) {
-                  mtfv[wr] = BZ_RUNB; wr++; 
-                  s->mtfFreq[BZ_RUNB]++; 
-               } else {
-                  mtfv[wr] = BZ_RUNA; wr++; 
-                  s->mtfFreq[BZ_RUNA]++; 
-               }
-               if (zPend < 2) break;
-               zPend = (zPend - 2) / 2;
-            };
-            zPend = 0;
-         }
-         {
-            register UChar  rtmp;
-            register UChar* ryy_j;
-            register UChar  rll_i;
-            rtmp  = yy[1];
-            yy[1] = yy[0];
-            ryy_j = &(yy[1]);
-            rll_i = ll_i;
-            while ( rll_i != rtmp ) {
-               register UChar rtmp2;
-               ryy_j++;
-               rtmp2  = rtmp;
-               rtmp   = *ryy_j;
-               *ryy_j = rtmp2;
-            };
-            yy[0] = rtmp;
-            j = ryy_j - &(yy[0]);
-            mtfv[wr] = j+1; wr++; s->mtfFreq[j+1]++;
-         }
-
-      }
-   }
-
-   if (zPend > 0) {
-      zPend--;
-      while (True) {
-         if (zPend & 1) {
-            mtfv[wr] = BZ_RUNB; wr++; 
-            s->mtfFreq[BZ_RUNB]++; 
-         } else {
-            mtfv[wr] = BZ_RUNA; wr++; 
-            s->mtfFreq[BZ_RUNA]++; 
-         }
-         if (zPend < 2) break;
-         zPend = (zPend - 2) / 2;
-      };
-      zPend = 0;
-   }
-
-   mtfv[wr] = EOB; wr++; s->mtfFreq[EOB]++;
-
-   s->nMTF = wr;
-}
-
-
-/*---------------------------------------------------*/
-#define BZ_LESSER_ICOST  0
-#define BZ_GREATER_ICOST 15
-
-static
-void sendMTFValues ( EState* s )
-{
-   Int32 v, t, i, j, gs, ge, totc, bt, bc, iter;
-   Int32 nSelectors, alphaSize, minLen, maxLen, selCtr;
-   Int32 nGroups, nBytes;
-
-   /*--
-   UChar  len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
-   is a global since the decoder also needs it.
-
-   Int32  code[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
-   Int32  rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
-   are also globals only used in this proc.
-   Made global to keep stack frame size small.
-   --*/
-
-
-   UInt16 cost[BZ_N_GROUPS];
-   Int32  fave[BZ_N_GROUPS];
-
-   UInt16* mtfv = s->mtfv;
-
-   if (s->verbosity >= 3)
-      VPrintf3( "      %d in block, %d after MTF & 1-2 coding, "
-                "%d+2 syms in use\n", 
-                s->nblock, s->nMTF, s->nInUse );
-
-   alphaSize = s->nInUse+2;
-   for (t = 0; t < BZ_N_GROUPS; t++)
-      for (v = 0; v < alphaSize; v++)
-         s->len[t][v] = BZ_GREATER_ICOST;
-
-   /*--- Decide how many coding tables to use ---*/
-   AssertH ( s->nMTF > 0, 3001 );
-   if (s->nMTF < 200)  nGroups = 2; else
-   if (s->nMTF < 600)  nGroups = 3; else
-   if (s->nMTF < 1200) nGroups = 4; else
-   if (s->nMTF < 2400) nGroups = 5; else
-                       nGroups = 6;
-
-   /*--- Generate an initial set of coding tables ---*/
-   { 
-      Int32 nPart, remF, tFreq, aFreq;
-
-      nPart = nGroups;
-      remF  = s->nMTF;
-      gs = 0;
-      while (nPart > 0) {
-         tFreq = remF / nPart;
-         ge = gs-1;
-         aFreq = 0;
-         while (aFreq < tFreq && ge < alphaSize-1) {
-            ge++;
-            aFreq += s->mtfFreq[ge];
-         }
-
-         if (ge > gs 
-             && nPart != nGroups && nPart != 1 
-             && ((nGroups-nPart) % 2 == 1)) {
-            aFreq -= s->mtfFreq[ge];
-            ge--;
-         }
-
-         if (s->verbosity >= 3)
-            VPrintf5( "      initial group %d, [%d .. %d], "
-                      "has %d syms (%4.1f%%)\n",
-                      nPart, gs, ge, aFreq, 
-                      (100.0 * (float)aFreq) / (float)(s->nMTF) );
- 
-         for (v = 0; v < alphaSize; v++)
-            if (v >= gs && v <= ge) 
-               s->len[nPart-1][v] = BZ_LESSER_ICOST; else
-               s->len[nPart-1][v] = BZ_GREATER_ICOST;
- 
-         nPart--;
-         gs = ge+1;
-         remF -= aFreq;
-      }
-   }
-
-   /*--- 
-      Iterate up to BZ_N_ITERS times to improve the tables.
-   ---*/
-   for (iter = 0; iter < BZ_N_ITERS; iter++) {
-
-      for (t = 0; t < nGroups; t++) fave[t] = 0;
-
-      for (t = 0; t < nGroups; t++)
-         for (v = 0; v < alphaSize; v++)
-            s->rfreq[t][v] = 0;
-
-      /*---
-        Set up an auxiliary length table which is used to fast-track
-        the common case (nGroups == 6).
-      ---*/
-      if (nGroups == 6) {
-         for (v = 0; v < alphaSize; v++) {
-            s->len_pack[v][0] = (s->len[1][v] << 16) | s->len[0][v];
-            s->len_pack[v][1] = (s->len[3][v] << 16) | s->len[2][v];
-            s->len_pack[v][2] = (s->len[5][v] << 16) | s->len[4][v];
-         }
-      }
-
-      nSelectors = 0;
-      totc = 0;
-      gs = 0;
-      while (True) {
-
-         /*--- Set group start & end marks. --*/
-         if (gs >= s->nMTF) break;
-         ge = gs + BZ_G_SIZE - 1; 
-         if (ge >= s->nMTF) ge = s->nMTF-1;
-
-         /*-- 
-            Calculate the cost of this group as coded
-            by each of the coding tables.
-         --*/
-         for (t = 0; t < nGroups; t++) cost[t] = 0;
-
-         if (nGroups == 6 && 50 == ge-gs+1) {
-            /*--- fast track the common case ---*/
-            register UInt32 cost01, cost23, cost45;
-            register UInt16 icv;
-            cost01 = cost23 = cost45 = 0;
-
-#           define BZ_ITER(nn)                \
-               icv = mtfv[gs+(nn)];           \
-               cost01 += s->len_pack[icv][0]; \
-               cost23 += s->len_pack[icv][1]; \
-               cost45 += s->len_pack[icv][2]; \
-
-            BZ_ITER(0);  BZ_ITER(1);  BZ_ITER(2);  BZ_ITER(3);  BZ_ITER(4);
-            BZ_ITER(5);  BZ_ITER(6);  BZ_ITER(7);  BZ_ITER(8);  BZ_ITER(9);
-            BZ_ITER(10); BZ_ITER(11); BZ_ITER(12); BZ_ITER(13); BZ_ITER(14);
-            BZ_ITER(15); BZ_ITER(16); BZ_ITER(17); BZ_ITER(18); BZ_ITER(19);
-            BZ_ITER(20); BZ_ITER(21); BZ_ITER(22); BZ_ITER(23); BZ_ITER(24);
-            BZ_ITER(25); BZ_ITER(26); BZ_ITER(27); BZ_ITER(28); BZ_ITER(29);
-            BZ_ITER(30); BZ_ITER(31); BZ_ITER(32); BZ_ITER(33); BZ_ITER(34);
-            BZ_ITER(35); BZ_ITER(36); BZ_ITER(37); BZ_ITER(38); BZ_ITER(39);
-            BZ_ITER(40); BZ_ITER(41); BZ_ITER(42); BZ_ITER(43); BZ_ITER(44);
-            BZ_ITER(45); BZ_ITER(46); BZ_ITER(47); BZ_ITER(48); BZ_ITER(49);
-
-#           undef BZ_ITER
-
-            cost[0] = cost01 & 0xffff; cost[1] = cost01 >> 16;
-            cost[2] = cost23 & 0xffff; cost[3] = cost23 >> 16;
-            cost[4] = cost45 & 0xffff; cost[5] = cost45 >> 16;
-
-         } else {
-            /*--- slow version which correctly handles all situations ---*/
-            for (i = gs; i <= ge; i++) {
-               UInt16 icv = mtfv[i];
-               for (t = 0; t < nGroups; t++) cost[t] += s->len[t][icv];
-            }
-         }
-
-         /*--
-            Find the coding table which is best for this group,
-            and record its identity in the selector table.
-         --*/
-         bc = 999999999; bt = -1;
-         for (t = 0; t < nGroups; t++)
-            if (cost[t] < bc) { bc = cost[t]; bt = t; };
-         totc += bc;
-         fave[bt]++;
-         s->selector[nSelectors] = bt;
-         nSelectors++;
-
-         /*-- 
-            Increment the symbol frequencies for the selected table.
-          --*/
-         if (nGroups == 6 && 50 == ge-gs+1) {
-            /*--- fast track the common case ---*/
-
-#           define BZ_ITUR(nn) s->rfreq[bt][ mtfv[gs+(nn)] ]++
-
-            BZ_ITUR(0);  BZ_ITUR(1);  BZ_ITUR(2);  BZ_ITUR(3);  BZ_ITUR(4);
-            BZ_ITUR(5);  BZ_ITUR(6);  BZ_ITUR(7);  BZ_ITUR(8);  BZ_ITUR(9);
-            BZ_ITUR(10); BZ_ITUR(11); BZ_ITUR(12); BZ_ITUR(13); BZ_ITUR(14);
-            BZ_ITUR(15); BZ_ITUR(16); BZ_ITUR(17); BZ_ITUR(18); BZ_ITUR(19);
-            BZ_ITUR(20); BZ_ITUR(21); BZ_ITUR(22); BZ_ITUR(23); BZ_ITUR(24);
-            BZ_ITUR(25); BZ_ITUR(26); BZ_ITUR(27); BZ_ITUR(28); BZ_ITUR(29);
-            BZ_ITUR(30); BZ_ITUR(31); BZ_ITUR(32); BZ_ITUR(33); BZ_ITUR(34);
-            BZ_ITUR(35); BZ_ITUR(36); BZ_ITUR(37); BZ_ITUR(38); BZ_ITUR(39);
-            BZ_ITUR(40); BZ_ITUR(41); BZ_ITUR(42); BZ_ITUR(43); BZ_ITUR(44);
-            BZ_ITUR(45); BZ_ITUR(46); BZ_ITUR(47); BZ_ITUR(48); BZ_ITUR(49);
-
-#           undef BZ_ITUR
-
-         } else {
-            /*--- slow version which correctly handles all situations ---*/
-            for (i = gs; i <= ge; i++)
-               s->rfreq[bt][ mtfv[i] ]++;
-         }
-
-         gs = ge+1;
-      }
-      if (s->verbosity >= 3) {
-         VPrintf2 ( "      pass %d: size is %d, grp uses are ", 
-                   iter+1, totc/8 );
-         for (t = 0; t < nGroups; t++)
-            VPrintf1 ( "%d ", fave[t] );
-         VPrintf0 ( "\n" );
-      }
-
-      /*--
-        Recompute the tables based on the accumulated frequencies.
-      --*/
-      /* maxLen was changed from 20 to 17 in bzip2-1.0.3.  See 
-         comment in huffman.c for details. */
-      for (t = 0; t < nGroups; t++)
-         BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]), 
-                                 alphaSize, 17 /*20*/ );
-   }
-
-
-   AssertH( nGroups < 8, 3002 );
-   AssertH( nSelectors < 32768 &&
-            nSelectors <= (2 + (900000 / BZ_G_SIZE)),
-            3003 );
-
-
-   /*--- Compute MTF values for the selectors. ---*/
-   {
-      UChar pos[BZ_N_GROUPS], ll_i, tmp2, tmp;
-      for (i = 0; i < nGroups; i++) pos[i] = i;
-      for (i = 0; i < nSelectors; i++) {
-         ll_i = s->selector[i];
-         j = 0;
-         tmp = pos[j];
-         while ( ll_i != tmp ) {
-            j++;
-            tmp2 = tmp;
-            tmp = pos[j];
-            pos[j] = tmp2;
-         };
-         pos[0] = tmp;
-         s->selectorMtf[i] = j;
-      }
-   };
-
-   /*--- Assign actual codes for the tables. --*/
-   for (t = 0; t < nGroups; t++) {
-      minLen = 32;
-      maxLen = 0;
-      for (i = 0; i < alphaSize; i++) {
-         if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
-         if (s->len[t][i] < minLen) minLen = s->len[t][i];
-      }
-      AssertH ( !(maxLen > 17 /*20*/ ), 3004 );
-      AssertH ( !(minLen < 1),  3005 );
-      BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]), 
-                          minLen, maxLen, alphaSize );
-   }
-
-   /*--- Transmit the mapping table. ---*/
-   { 
-      Bool inUse16[16];
-      for (i = 0; i < 16; i++) {
-          inUse16[i] = False;
-          for (j = 0; j < 16; j++)
-             if (s->inUse[i * 16 + j]) inUse16[i] = True;
-      }
-     
-      nBytes = s->numZ;
-      for (i = 0; i < 16; i++)
-         if (inUse16[i]) bsW(s,1,1); else bsW(s,1,0);
-
-      for (i = 0; i < 16; i++)
-         if (inUse16[i])
-            for (j = 0; j < 16; j++) {
-               if (s->inUse[i * 16 + j]) bsW(s,1,1); else bsW(s,1,0);
-            }
-
-      if (s->verbosity >= 3) 
-         VPrintf1( "      bytes: mapping %d, ", s->numZ-nBytes );
-   }
-
-   /*--- Now the selectors. ---*/
-   nBytes = s->numZ;
-   bsW ( s, 3, nGroups );
-   bsW ( s, 15, nSelectors );
-   for (i = 0; i < nSelectors; i++) { 
-      for (j = 0; j < s->selectorMtf[i]; j++) bsW(s,1,1);
-      bsW(s,1,0);
-   }
-   if (s->verbosity >= 3)
-      VPrintf1( "selectors %d, ", s->numZ-nBytes );
-
-   /*--- Now the coding tables. ---*/
-   nBytes = s->numZ;
-
-   for (t = 0; t < nGroups; t++) {
-      Int32 curr = s->len[t][0];
-      bsW ( s, 5, curr );
-      for (i = 0; i < alphaSize; i++) {
-         while (curr < s->len[t][i]) { bsW(s,2,2); curr++; /* 10 */ };
-         while (curr > s->len[t][i]) { bsW(s,2,3); curr--; /* 11 */ };
-         bsW ( s, 1, 0 );
-      }
-   }
-
-   if (s->verbosity >= 3)
-      VPrintf1 ( "code lengths %d, ", s->numZ-nBytes );
-
-   /*--- And finally, the block data proper ---*/
-   nBytes = s->numZ;
-   selCtr = 0;
-   gs = 0;
-   while (True) {
-      if (gs >= s->nMTF) break;
-      ge = gs + BZ_G_SIZE - 1; 
-      if (ge >= s->nMTF) ge = s->nMTF-1;
-      AssertH ( s->selector[selCtr] < nGroups, 3006 );
-
-      if (nGroups == 6 && 50 == ge-gs+1) {
-            /*--- fast track the common case ---*/
-            UInt16 mtfv_i;
-            UChar* s_len_sel_selCtr 
-               = &(s->len[s->selector[selCtr]][0]);
-            Int32* s_code_sel_selCtr
-               = &(s->code[s->selector[selCtr]][0]);
-
-#           define BZ_ITAH(nn)                      \
-               mtfv_i = mtfv[gs+(nn)];              \
-               bsW ( s,                             \
-                     s_len_sel_selCtr[mtfv_i],      \
-                     s_code_sel_selCtr[mtfv_i] )
-
-            BZ_ITAH(0);  BZ_ITAH(1);  BZ_ITAH(2);  BZ_ITAH(3);  BZ_ITAH(4);
-            BZ_ITAH(5);  BZ_ITAH(6);  BZ_ITAH(7);  BZ_ITAH(8);  BZ_ITAH(9);
-            BZ_ITAH(10); BZ_ITAH(11); BZ_ITAH(12); BZ_ITAH(13); BZ_ITAH(14);
-            BZ_ITAH(15); BZ_ITAH(16); BZ_ITAH(17); BZ_ITAH(18); BZ_ITAH(19);
-            BZ_ITAH(20); BZ_ITAH(21); BZ_ITAH(22); BZ_ITAH(23); BZ_ITAH(24);
-            BZ_ITAH(25); BZ_ITAH(26); BZ_ITAH(27); BZ_ITAH(28); BZ_ITAH(29);
-            BZ_ITAH(30); BZ_ITAH(31); BZ_ITAH(32); BZ_ITAH(33); BZ_ITAH(34);
-            BZ_ITAH(35); BZ_ITAH(36); BZ_ITAH(37); BZ_ITAH(38); BZ_ITAH(39);
-            BZ_ITAH(40); BZ_ITAH(41); BZ_ITAH(42); BZ_ITAH(43); BZ_ITAH(44);
-            BZ_ITAH(45); BZ_ITAH(46); BZ_ITAH(47); BZ_ITAH(48); BZ_ITAH(49);
-
-#           undef BZ_ITAH
-
-      } else {
-         /*--- slow version which correctly handles all situations ---*/
-         for (i = gs; i <= ge; i++) {
-            bsW ( s,
-                  s->len  [s->selector[selCtr]] [mtfv[i]],
-                  s->code [s->selector[selCtr]] [mtfv[i]] );
-         }
-      }
-
-      gs = ge+1;
-      selCtr++;
-   }
-   AssertH( selCtr == nSelectors, 3007 );
-
-   if (s->verbosity >= 3)
-      VPrintf1( "codes %d\n", s->numZ-nBytes );
-}
-
-
-/*---------------------------------------------------*/
-void BZ2_compressBlock ( EState* s, Bool is_last_block )
-{
-   if (s->nblock > 0) {
-
-      BZ_FINALISE_CRC ( s->blockCRC );
-      s->combinedCRC = (s->combinedCRC << 1) | (s->combinedCRC >> 31);
-      s->combinedCRC ^= s->blockCRC;
-      if (s->blockNo > 1) s->numZ = 0;
-
-      if (s->verbosity >= 2)
-         VPrintf4( "    block %d: crc = 0x%08x, "
-                   "combined CRC = 0x%08x, size = %d\n",
-                   s->blockNo, s->blockCRC, s->combinedCRC, s->nblock );
-
-      BZ2_blockSort ( s );
-   }
-
-   s->zbits = (UChar*) (&((UChar*)s->arr2)[s->nblock]);
-
-   /*-- If this is the first block, create the stream header. --*/
-   if (s->blockNo == 1) {
-      BZ2_bsInitWrite ( s );
-      bsPutUChar ( s, BZ_HDR_B );
-      bsPutUChar ( s, BZ_HDR_Z );
-      bsPutUChar ( s, BZ_HDR_h );
-      bsPutUChar ( s, (UChar)(BZ_HDR_0 + s->blockSize100k) );
-   }
-
-   if (s->nblock > 0) {
-
-      bsPutUChar ( s, 0x31 ); bsPutUChar ( s, 0x41 );
-      bsPutUChar ( s, 0x59 ); bsPutUChar ( s, 0x26 );
-      bsPutUChar ( s, 0x53 ); bsPutUChar ( s, 0x59 );
-
-      /*-- Now the block's CRC, so it is in a known place. --*/
-      bsPutUInt32 ( s, s->blockCRC );
-
-      /*-- 
-         Now a single bit indicating (non-)randomisation. 
-         As of version 0.9.5, we use a better sorting algorithm
-         which makes randomisation unnecessary.  So always set
-         the randomised bit to 'no'.  Of course, the decoder
-         still needs to be able to handle randomised blocks
-         so as to maintain backwards compatibility with
-         older versions of bzip2.
-      --*/
-      bsW(s,1,0);
-
-      bsW ( s, 24, s->origPtr );
-      generateMTFValues ( s );
-      sendMTFValues ( s );
-   }
-
-
-   /*-- If this is the last block, add the stream trailer. --*/
-   if (is_last_block) {
-
-      bsPutUChar ( s, 0x17 ); bsPutUChar ( s, 0x72 );
-      bsPutUChar ( s, 0x45 ); bsPutUChar ( s, 0x38 );
-      bsPutUChar ( s, 0x50 ); bsPutUChar ( s, 0x90 );
-      bsPutUInt32 ( s, s->combinedCRC );
-      if (s->verbosity >= 2)
-         VPrintf1( "    final combined CRC = 0x%08x\n   ", s->combinedCRC );
-      bsFinishWrite ( s );
-   }
-}
-
-
-/*-------------------------------------------------------------*/
-/*--- end                                        compress.c ---*/
-/*-------------------------------------------------------------*/
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/crctable.c b/contrib/vmap_extractor_v2/stormlib/bzip2/crctable.c
deleted file mode 100644
index b6dadfc62f2..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/crctable.c
+++ /dev/null
@@ -1,144 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Table for doing CRCs                                  ---*/
-/*---                                            crctable.c ---*/
-/*-------------------------------------------------------------*/
-
-/*--
-  This file is a part of bzip2 and/or libbzip2, a program and
-  library for lossless, block-sorting data compression.
-
-  Copyright (C) 1996-2005 Julian R Seward.  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-  2. 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.
-
-  3. Altered source versions must be plainly marked as such, and must
-     not be misrepresented as being the original software.
-
-  4. The name of the author may not be used to endorse or promote 
-     products derived from this software without specific prior written 
-     permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
-
-  Julian Seward, Cambridge, UK.
-  jseward@bzip.org
-  bzip2/libbzip2 version 1.0 of 21 March 2000
-
-  This program is based on (at least) the work of:
-     Mike Burrows
-     David Wheeler
-     Peter Fenwick
-     Alistair Moffat
-     Radford Neal
-     Ian H. Witten
-     Robert Sedgewick
-     Jon L. Bentley
-
-  For more information on these sources, see the manual.
---*/
-
-
-#include "bzlib_private.h"
-
-/*--
-  I think this is an implementation of the AUTODIN-II,
-  Ethernet & FDDI 32-bit CRC standard.  Vaguely derived
-  from code by Rob Warnock, in Section 51 of the
-  comp.compression FAQ.
---*/
-
-UInt32 BZ2_crc32Table[256] = {
-
-   /*-- Ugly, innit? --*/
-
-   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
-};
-
-
-/*-------------------------------------------------------------*/
-/*--- end                                        crctable.c ---*/
-/*-------------------------------------------------------------*/
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/decompress.c b/contrib/vmap_extractor_v2/stormlib/bzip2/decompress.c
deleted file mode 100644
index 81c3d2cc3f4..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/decompress.c
+++ /dev/null
@@ -1,666 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Decompression machinery                               ---*/
-/*---                                          decompress.c ---*/
-/*-------------------------------------------------------------*/
-
-/*--
-  This file is a part of bzip2 and/or libbzip2, a program and
-  library for lossless, block-sorting data compression.
-
-  Copyright (C) 1996-2005 Julian R Seward.  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-  2. 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.
-
-  3. Altered source versions must be plainly marked as such, and must
-     not be misrepresented as being the original software.
-
-  4. The name of the author may not be used to endorse or promote 
-     products derived from this software without specific prior written 
-     permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
-
-  Julian Seward, Cambridge, UK.
-  jseward@bzip.org
-  bzip2/libbzip2 version 1.0 of 21 March 2000
-
-  This program is based on (at least) the work of:
-     Mike Burrows
-     David Wheeler
-     Peter Fenwick
-     Alistair Moffat
-     Radford Neal
-     Ian H. Witten
-     Robert Sedgewick
-     Jon L. Bentley
-
-  For more information on these sources, see the manual.
---*/
-
-
-#include "bzlib_private.h"
-
-
-/*---------------------------------------------------*/
-static
-void makeMaps_d ( DState* s )
-{
-   Int32 i;
-   s->nInUse = 0;
-   for (i = 0; i < 256; i++)
-      if (s->inUse[i]) {
-         s->seqToUnseq[s->nInUse] = i;
-         s->nInUse++;
-      }
-}
-
-
-/*---------------------------------------------------*/
-#define RETURN(rrr)                               \
-   { retVal = rrr; goto save_state_and_return; };
-
-#define GET_BITS(lll,vvv,nnn)                     \
-   case lll: s->state = lll;                      \
-   while (True) {                                 \
-      if (s->bsLive >= nnn) {                     \
-         UInt32 v;                                \
-         v = (s->bsBuff >>                        \
-             (s->bsLive-nnn)) & ((1 << nnn)-1);   \
-         s->bsLive -= nnn;                        \
-         vvv = v;                                 \
-         break;                                   \
-      }                                           \
-      if (s->strm->avail_in == 0) RETURN(BZ_OK);  \
-      s->bsBuff                                   \
-         = (s->bsBuff << 8) |                     \
-           ((UInt32)                              \
-              (*((UChar*)(s->strm->next_in))));   \
-      s->bsLive += 8;                             \
-      s->strm->next_in++;                         \
-      s->strm->avail_in--;                        \
-      s->strm->total_in_lo32++;                   \
-      if (s->strm->total_in_lo32 == 0)            \
-         s->strm->total_in_hi32++;                \
-   }
-
-#define GET_UCHAR(lll,uuu)                        \
-   GET_BITS(lll,uuu,8)
-
-#define GET_BIT(lll,uuu)                          \
-   GET_BITS(lll,uuu,1)
-
-/*---------------------------------------------------*/
-#define GET_MTF_VAL(label1,label2,lval)           \
-{                                                 \
-   if (groupPos == 0) {                           \
-      groupNo++;                                  \
-      if (groupNo >= nSelectors)                  \
-         RETURN(BZ_DATA_ERROR);                   \
-      groupPos = BZ_G_SIZE;                       \
-      gSel = s->selector[groupNo];                \
-      gMinlen = s->minLens[gSel];                 \
-      gLimit = &(s->limit[gSel][0]);              \
-      gPerm = &(s->perm[gSel][0]);                \
-      gBase = &(s->base[gSel][0]);                \
-   }                                              \
-   groupPos--;                                    \
-   zn = gMinlen;                                  \
-   GET_BITS(label1, zvec, zn);                    \
-   while (1) {                                    \
-      if (zn > 20 /* the longest code */)         \
-         RETURN(BZ_DATA_ERROR);                   \
-      if (zvec <= gLimit[zn]) break;              \
-      zn++;                                       \
-      GET_BIT(label2, zj);                        \
-      zvec = (zvec << 1) | zj;                    \
-   };                                             \
-   if (zvec - gBase[zn] < 0                       \
-       || zvec - gBase[zn] >= BZ_MAX_ALPHA_SIZE)  \
-      RETURN(BZ_DATA_ERROR);                      \
-   lval = gPerm[zvec - gBase[zn]];                \
-}
-
-
-/*---------------------------------------------------*/
-Int32 BZ2_decompress ( DState* s )
-{
-   UChar      uc;
-   Int32      retVal;
-   Int32      minLen, maxLen;
-   bz_stream* strm = s->strm;
-
-   /* stuff that needs to be saved/restored */
-   Int32  i;
-   Int32  j;
-   Int32  t;
-   Int32  alphaSize;
-   Int32  nGroups;
-   Int32  nSelectors;
-   Int32  EOB;
-   Int32  groupNo;
-   Int32  groupPos;
-   Int32  nextSym;
-   Int32  nblockMAX;
-   Int32  nblock;
-   Int32  es;
-   Int32  N;
-   Int32  curr;
-   Int32  zt;
-   Int32  zn; 
-   Int32  zvec;
-   Int32  zj;
-   Int32  gSel;
-   Int32  gMinlen;
-   Int32* gLimit;
-   Int32* gBase;
-   Int32* gPerm;
-
-   if (s->state == BZ_X_MAGIC_1) {
-      /*initialise the save area*/
-      s->save_i           = 0;
-      s->save_j           = 0;
-      s->save_t           = 0;
-      s->save_alphaSize   = 0;
-      s->save_nGroups     = 0;
-      s->save_nSelectors  = 0;
-      s->save_EOB         = 0;
-      s->save_groupNo     = 0;
-      s->save_groupPos    = 0;
-      s->save_nextSym     = 0;
-      s->save_nblockMAX   = 0;
-      s->save_nblock      = 0;
-      s->save_es          = 0;
-      s->save_N           = 0;
-      s->save_curr        = 0;
-      s->save_zt          = 0;
-      s->save_zn          = 0;
-      s->save_zvec        = 0;
-      s->save_zj          = 0;
-      s->save_gSel        = 0;
-      s->save_gMinlen     = 0;
-      s->save_gLimit      = NULL;
-      s->save_gBase       = NULL;
-      s->save_gPerm       = NULL;
-   }
-
-   /*restore from the save area*/
-   i           = s->save_i;
-   j           = s->save_j;
-   t           = s->save_t;
-   alphaSize   = s->save_alphaSize;
-   nGroups     = s->save_nGroups;
-   nSelectors  = s->save_nSelectors;
-   EOB         = s->save_EOB;
-   groupNo     = s->save_groupNo;
-   groupPos    = s->save_groupPos;
-   nextSym     = s->save_nextSym;
-   nblockMAX   = s->save_nblockMAX;
-   nblock      = s->save_nblock;
-   es          = s->save_es;
-   N           = s->save_N;
-   curr        = s->save_curr;
-   zt          = s->save_zt;
-   zn          = s->save_zn; 
-   zvec        = s->save_zvec;
-   zj          = s->save_zj;
-   gSel        = s->save_gSel;
-   gMinlen     = s->save_gMinlen;
-   gLimit      = s->save_gLimit;
-   gBase       = s->save_gBase;
-   gPerm       = s->save_gPerm;
-
-   retVal = BZ_OK;
-
-   switch (s->state) {
-
-      GET_UCHAR(BZ_X_MAGIC_1, uc);
-      if (uc != BZ_HDR_B) RETURN(BZ_DATA_ERROR_MAGIC);
-
-      GET_UCHAR(BZ_X_MAGIC_2, uc);
-      if (uc != BZ_HDR_Z) RETURN(BZ_DATA_ERROR_MAGIC);
-
-      GET_UCHAR(BZ_X_MAGIC_3, uc)
-      if (uc != BZ_HDR_h) RETURN(BZ_DATA_ERROR_MAGIC);
-
-      GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8)
-      if (s->blockSize100k < (BZ_HDR_0 + 1) || 
-          s->blockSize100k > (BZ_HDR_0 + 9)) RETURN(BZ_DATA_ERROR_MAGIC);
-      s->blockSize100k -= BZ_HDR_0;
-
-      if (s->smallDecompress) {
-         s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) );
-         s->ll4  = BZALLOC( 
-                      ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar) 
-                   );
-         if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR);
-      } else {
-         s->tt  = BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) );
-         if (s->tt == NULL) RETURN(BZ_MEM_ERROR);
-      }
-
-      GET_UCHAR(BZ_X_BLKHDR_1, uc);
-
-      if (uc == 0x17) goto endhdr_2;
-      if (uc != 0x31) RETURN(BZ_DATA_ERROR);
-      GET_UCHAR(BZ_X_BLKHDR_2, uc);
-      if (uc != 0x41) RETURN(BZ_DATA_ERROR);
-      GET_UCHAR(BZ_X_BLKHDR_3, uc);
-      if (uc != 0x59) RETURN(BZ_DATA_ERROR);
-      GET_UCHAR(BZ_X_BLKHDR_4, uc);
-      if (uc != 0x26) RETURN(BZ_DATA_ERROR);
-      GET_UCHAR(BZ_X_BLKHDR_5, uc);
-      if (uc != 0x53) RETURN(BZ_DATA_ERROR);
-      GET_UCHAR(BZ_X_BLKHDR_6, uc);
-      if (uc != 0x59) RETURN(BZ_DATA_ERROR);
-
-      s->currBlockNo++;
-      if (s->verbosity >= 2)
-         VPrintf1 ( "\n    [%d: huff+mtf ", s->currBlockNo );
- 
-      s->storedBlockCRC = 0;
-      GET_UCHAR(BZ_X_BCRC_1, uc);
-      s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
-      GET_UCHAR(BZ_X_BCRC_2, uc);
-      s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
-      GET_UCHAR(BZ_X_BCRC_3, uc);
-      s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
-      GET_UCHAR(BZ_X_BCRC_4, uc);
-      s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
-
-      GET_BITS(BZ_X_RANDBIT, s->blockRandomised, 1);
-
-      s->origPtr = 0;
-      GET_UCHAR(BZ_X_ORIGPTR_1, uc);
-      s->origPtr = (s->origPtr << 8) | ((Int32)uc);
-      GET_UCHAR(BZ_X_ORIGPTR_2, uc);
-      s->origPtr = (s->origPtr << 8) | ((Int32)uc);
-      GET_UCHAR(BZ_X_ORIGPTR_3, uc);
-      s->origPtr = (s->origPtr << 8) | ((Int32)uc);
-
-      if (s->origPtr < 0)
-         RETURN(BZ_DATA_ERROR);
-      if (s->origPtr > 10 + 100000*s->blockSize100k) 
-         RETURN(BZ_DATA_ERROR);
-
-      /*--- Receive the mapping table ---*/
-      for (i = 0; i < 16; i++) {
-         GET_BIT(BZ_X_MAPPING_1, uc);
-         if (uc == 1) 
-            s->inUse16[i] = True; else 
-            s->inUse16[i] = False;
-      }
-
-      for (i = 0; i < 256; i++) s->inUse[i] = False;
-
-      for (i = 0; i < 16; i++)
-         if (s->inUse16[i])
-            for (j = 0; j < 16; j++) {
-               GET_BIT(BZ_X_MAPPING_2, uc);
-               if (uc == 1) s->inUse[i * 16 + j] = True;
-            }
-      makeMaps_d ( s );
-      if (s->nInUse == 0) RETURN(BZ_DATA_ERROR);
-      alphaSize = s->nInUse+2;
-
-      /*--- Now the selectors ---*/
-      GET_BITS(BZ_X_SELECTOR_1, nGroups, 3);
-      if (nGroups < 2 || nGroups > 6) RETURN(BZ_DATA_ERROR);
-      GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15);
-      if (nSelectors < 1) RETURN(BZ_DATA_ERROR);
-      for (i = 0; i < nSelectors; i++) {
-         j = 0;
-         while (True) {
-            GET_BIT(BZ_X_SELECTOR_3, uc);
-            if (uc == 0) break;
-            j++;
-            if (j >= nGroups) RETURN(BZ_DATA_ERROR);
-         }
-         s->selectorMtf[i] = j;
-      }
-
-      /*--- Undo the MTF values for the selectors. ---*/
-      {
-         UChar pos[BZ_N_GROUPS], tmp, v;
-         for (v = 0; v < nGroups; v++) pos[v] = v;
-   
-         for (i = 0; i < nSelectors; i++) {
-            v = s->selectorMtf[i];
-            tmp = pos[v];
-            while (v > 0) { pos[v] = pos[v-1]; v--; }
-            pos[0] = tmp;
-            s->selector[i] = tmp;
-         }
-      }
-
-      /*--- Now the coding tables ---*/
-      for (t = 0; t < nGroups; t++) {
-         GET_BITS(BZ_X_CODING_1, curr, 5);
-         for (i = 0; i < alphaSize; i++) {
-            while (True) {
-               if (curr < 1 || curr > 20) RETURN(BZ_DATA_ERROR);
-               GET_BIT(BZ_X_CODING_2, uc);
-               if (uc == 0) break;
-               GET_BIT(BZ_X_CODING_3, uc);
-               if (uc == 0) curr++; else curr--;
-            }
-            s->len[t][i] = curr;
-         }
-      }
-
-      /*--- Create the Huffman decoding tables ---*/
-      for (t = 0; t < nGroups; t++) {
-         minLen = 32;
-         maxLen = 0;
-         for (i = 0; i < alphaSize; i++) {
-            if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
-            if (s->len[t][i] < minLen) minLen = s->len[t][i];
-         }
-         BZ2_hbCreateDecodeTables ( 
-            &(s->limit[t][0]), 
-            &(s->base[t][0]), 
-            &(s->perm[t][0]), 
-            &(s->len[t][0]),
-            minLen, maxLen, alphaSize
-         );
-         s->minLens[t] = minLen;
-      }
-
-      /*--- Now the MTF values ---*/
-
-      EOB      = s->nInUse+1;
-      nblockMAX = 100000 * s->blockSize100k;
-      groupNo  = -1;
-      groupPos = 0;
-
-      for (i = 0; i <= 255; i++) s->unzftab[i] = 0;
-
-      /*-- MTF init --*/
-      {
-         Int32 ii, jj, kk;
-         kk = MTFA_SIZE-1;
-         for (ii = 256 / MTFL_SIZE - 1; ii >= 0; ii--) {
-            for (jj = MTFL_SIZE-1; jj >= 0; jj--) {
-               s->mtfa[kk] = (UChar)(ii * MTFL_SIZE + jj);
-               kk--;
-            }
-            s->mtfbase[ii] = kk + 1;
-         }
-      }
-      /*-- end MTF init --*/
-
-      nblock = 0;
-      GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym);
-
-      while (True) {
-
-         if (nextSym == EOB) break;
-
-         if (nextSym == BZ_RUNA || nextSym == BZ_RUNB) {
-
-            es = -1;
-            N = 1;
-            do {
-               if (nextSym == BZ_RUNA) es = es + (0+1) * N; else
-               if (nextSym == BZ_RUNB) es = es + (1+1) * N;
-               N = N * 2;
-               GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym);
-            }
-               while (nextSym == BZ_RUNA || nextSym == BZ_RUNB);
-
-            es++;
-            uc = s->seqToUnseq[ s->mtfa[s->mtfbase[0]] ];
-            s->unzftab[uc] += es;
-
-            if (s->smallDecompress)
-               while (es > 0) {
-                  if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
-                  s->ll16[nblock] = (UInt16)uc;
-                  nblock++;
-                  es--;
-               }
-            else
-               while (es > 0) {
-                  if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
-                  s->tt[nblock] = (UInt32)uc;
-                  nblock++;
-                  es--;
-               };
-
-            continue;
-
-         } else {
-
-            if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
-
-            /*-- uc = MTF ( nextSym-1 ) --*/
-            {
-               Int32 ii, jj, kk, pp, lno, off;
-               UInt32 nn;
-               nn = (UInt32)(nextSym - 1);
-
-               if (nn < MTFL_SIZE) {
-                  /* avoid general-case expense */
-                  pp = s->mtfbase[0];
-                  uc = s->mtfa[pp+nn];
-                  while (nn > 3) {
-                     Int32 z = pp+nn;
-                     s->mtfa[(z)  ] = s->mtfa[(z)-1];
-                     s->mtfa[(z)-1] = s->mtfa[(z)-2];
-                     s->mtfa[(z)-2] = s->mtfa[(z)-3];
-                     s->mtfa[(z)-3] = s->mtfa[(z)-4];
-                     nn -= 4;
-                  }
-                  while (nn > 0) { 
-                     s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--; 
-                  };
-                  s->mtfa[pp] = uc;
-               } else { 
-                  /* general case */
-                  lno = nn / MTFL_SIZE;
-                  off = nn % MTFL_SIZE;
-                  pp = s->mtfbase[lno] + off;
-                  uc = s->mtfa[pp];
-                  while (pp > s->mtfbase[lno]) { 
-                     s->mtfa[pp] = s->mtfa[pp-1]; pp--; 
-                  };
-                  s->mtfbase[lno]++;
-                  while (lno > 0) {
-                     s->mtfbase[lno]--;
-                     s->mtfa[s->mtfbase[lno]] 
-                        = s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1];
-                     lno--;
-                  }
-                  s->mtfbase[0]--;
-                  s->mtfa[s->mtfbase[0]] = uc;
-                  if (s->mtfbase[0] == 0) {
-                     kk = MTFA_SIZE-1;
-                     for (ii = 256 / MTFL_SIZE-1; ii >= 0; ii--) {
-                        for (jj = MTFL_SIZE-1; jj >= 0; jj--) {
-                           s->mtfa[kk] = s->mtfa[s->mtfbase[ii] + jj];
-                           kk--;
-                        }
-                        s->mtfbase[ii] = kk + 1;
-                     }
-                  }
-               }
-            }
-            /*-- end uc = MTF ( nextSym-1 ) --*/
-
-            s->unzftab[s->seqToUnseq[uc]]++;
-            if (s->smallDecompress)
-               s->ll16[nblock] = (UInt16)(s->seqToUnseq[uc]); else
-               s->tt[nblock]   = (UInt32)(s->seqToUnseq[uc]);
-            nblock++;
-
-            GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym);
-            continue;
-         }
-      }
-
-      /* Now we know what nblock is, we can do a better sanity
-         check on s->origPtr.
-      */
-      if (s->origPtr < 0 || s->origPtr >= nblock)
-         RETURN(BZ_DATA_ERROR);
-
-      /*-- Set up cftab to facilitate generation of T^(-1) --*/
-      s->cftab[0] = 0;
-      for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1];
-      for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1];
-      for (i = 0; i <= 256; i++) {
-         if (s->cftab[i] < 0 || s->cftab[i] > nblock) {
-            /* s->cftab[i] can legitimately be == nblock */
-            RETURN(BZ_DATA_ERROR);
-         }
-      }
-
-      s->state_out_len = 0;
-      s->state_out_ch  = 0;
-      BZ_INITIALISE_CRC ( s->calculatedBlockCRC );
-      s->state = BZ_X_OUTPUT;
-      if (s->verbosity >= 2) VPrintf0 ( "rt+rld" );
-
-      if (s->smallDecompress) {
-
-         /*-- Make a copy of cftab, used in generation of T --*/
-         for (i = 0; i <= 256; i++) s->cftabCopy[i] = s->cftab[i];
-
-         /*-- compute the T vector --*/
-         for (i = 0; i < nblock; i++) {
-            uc = (UChar)(s->ll16[i]);
-            SET_LL(i, s->cftabCopy[uc]);
-            s->cftabCopy[uc]++;
-         }
-
-         /*-- Compute T^(-1) by pointer reversal on T --*/
-         i = s->origPtr;
-         j = GET_LL(i);
-         do {
-            Int32 tmp = GET_LL(j);
-            SET_LL(j, i);
-            i = j;
-            j = tmp;
-         }
-            while (i != s->origPtr);
-
-         s->tPos = s->origPtr;
-         s->nblock_used = 0;
-         if (s->blockRandomised) {
-            BZ_RAND_INIT_MASK;
-            BZ_GET_SMALL(s->k0); s->nblock_used++;
-            BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; 
-         } else {
-            BZ_GET_SMALL(s->k0); s->nblock_used++;
-         }
-
-      } else {
-
-         /*-- compute the T^(-1) vector --*/
-         for (i = 0; i < nblock; i++) {
-            uc = (UChar)(s->tt[i] & 0xff);
-            s->tt[s->cftab[uc]] |= (i << 8);
-            s->cftab[uc]++;
-         }
-
-         s->tPos = s->tt[s->origPtr] >> 8;
-         s->nblock_used = 0;
-         if (s->blockRandomised) {
-            BZ_RAND_INIT_MASK;
-            BZ_GET_FAST(s->k0); s->nblock_used++;
-            BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; 
-         } else {
-            BZ_GET_FAST(s->k0); s->nblock_used++;
-         }
-
-      }
-
-      RETURN(BZ_OK);
-
-
-
-    endhdr_2:
-
-      GET_UCHAR(BZ_X_ENDHDR_2, uc);
-      if (uc != 0x72) RETURN(BZ_DATA_ERROR);
-      GET_UCHAR(BZ_X_ENDHDR_3, uc);
-      if (uc != 0x45) RETURN(BZ_DATA_ERROR);
-      GET_UCHAR(BZ_X_ENDHDR_4, uc);
-      if (uc != 0x38) RETURN(BZ_DATA_ERROR);
-      GET_UCHAR(BZ_X_ENDHDR_5, uc);
-      if (uc != 0x50) RETURN(BZ_DATA_ERROR);
-      GET_UCHAR(BZ_X_ENDHDR_6, uc);
-      if (uc != 0x90) RETURN(BZ_DATA_ERROR);
-
-      s->storedCombinedCRC = 0;
-      GET_UCHAR(BZ_X_CCRC_1, uc);
-      s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
-      GET_UCHAR(BZ_X_CCRC_2, uc);
-      s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
-      GET_UCHAR(BZ_X_CCRC_3, uc);
-      s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
-      GET_UCHAR(BZ_X_CCRC_4, uc);
-      s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
-
-      s->state = BZ_X_IDLE;
-      RETURN(BZ_STREAM_END);
-
-      default: AssertH ( False, 4001 );
-   }
-
-   AssertH ( False, 4002 );
-
-   save_state_and_return:
-
-   s->save_i           = i;
-   s->save_j           = j;
-   s->save_t           = t;
-   s->save_alphaSize   = alphaSize;
-   s->save_nGroups     = nGroups;
-   s->save_nSelectors  = nSelectors;
-   s->save_EOB         = EOB;
-   s->save_groupNo     = groupNo;
-   s->save_groupPos    = groupPos;
-   s->save_nextSym     = nextSym;
-   s->save_nblockMAX   = nblockMAX;
-   s->save_nblock      = nblock;
-   s->save_es          = es;
-   s->save_N           = N;
-   s->save_curr        = curr;
-   s->save_zt          = zt;
-   s->save_zn          = zn;
-   s->save_zvec        = zvec;
-   s->save_zj          = zj;
-   s->save_gSel        = gSel;
-   s->save_gMinlen     = gMinlen;
-   s->save_gLimit      = gLimit;
-   s->save_gBase       = gBase;
-   s->save_gPerm       = gPerm;
-
-   return retVal;   
-}
-
-
-/*-------------------------------------------------------------*/
-/*--- end                                      decompress.c ---*/
-/*-------------------------------------------------------------*/
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/dlltest.c b/contrib/vmap_extractor_v2/stormlib/bzip2/dlltest.c
deleted file mode 100644
index eb86bb61a59..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/dlltest.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
-   minibz2
-      libbz2.dll test program.
-      by Yoshioka Tsuneo(QWF00133@nifty.ne.jp/tsuneo-y@is.aist-nara.ac.jp)
-      This file is Public Domain.
-      welcome any email to me.
-
-   usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename]
-*/
-
-#define BZ_IMPORT
-#include 
-#include 
-#include "bzlib.h"
-#ifdef _WIN32
-#include 
-#endif
-
-
-#ifdef _WIN32
-
-#define BZ2_LIBNAME "libbz2-1.0.2.DLL" 
-
-#include 
-static int BZ2DLLLoaded = 0;
-static HINSTANCE BZ2DLLhLib;
-int BZ2DLLLoadLibrary(void)
-{
-   HINSTANCE hLib;
-
-   if(BZ2DLLLoaded==1){return 0;}
-   hLib=LoadLibrary(BZ2_LIBNAME);
-   if(hLib == NULL){
-      fprintf(stderr,"Can't load %s\n",BZ2_LIBNAME);
-      return -1;
-   }
-   BZ2_bzlibVersion=GetProcAddress(hLib,"BZ2_bzlibVersion");
-   BZ2_bzopen=GetProcAddress(hLib,"BZ2_bzopen");
-   BZ2_bzdopen=GetProcAddress(hLib,"BZ2_bzdopen");
-   BZ2_bzread=GetProcAddress(hLib,"BZ2_bzread");
-   BZ2_bzwrite=GetProcAddress(hLib,"BZ2_bzwrite");
-   BZ2_bzflush=GetProcAddress(hLib,"BZ2_bzflush");
-   BZ2_bzclose=GetProcAddress(hLib,"BZ2_bzclose");
-   BZ2_bzerror=GetProcAddress(hLib,"BZ2_bzerror");
-
-   if (!BZ2_bzlibVersion || !BZ2_bzopen || !BZ2_bzdopen
-       || !BZ2_bzread || !BZ2_bzwrite || !BZ2_bzflush
-       || !BZ2_bzclose || !BZ2_bzerror) {
-      fprintf(stderr,"GetProcAddress failed.\n");
-      return -1;
-   }
-   BZ2DLLLoaded=1;
-   BZ2DLLhLib=hLib;
-   return 0;
-
-}
-int BZ2DLLFreeLibrary(void)
-{
-   if(BZ2DLLLoaded==0){return 0;}
-   FreeLibrary(BZ2DLLhLib);
-   BZ2DLLLoaded=0;
-}
-#endif /* WIN32 */
-
-void usage(void)
-{
-   puts("usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename]");
-}
-
-int main(int argc,char *argv[])
-{
-   int decompress = 0;
-   int level = 9;
-   char *fn_r = NULL;
-   char *fn_w = NULL;
-
-#ifdef _WIN32
-   if(BZ2DLLLoadLibrary()<0){
-      fprintf(stderr,"Loading of %s failed.  Giving up.\n", BZ2_LIBNAME);
-      exit(1);
-   }
-   printf("Loading of %s succeeded.  Library version is %s.\n",
-          BZ2_LIBNAME, BZ2_bzlibVersion() );
-#endif
-   while(++argv,--argc){
-      if(**argv =='-' || **argv=='/'){
-         char *p;
-
-         for(p=*argv+1;*p;p++){
-            if(*p=='d'){
-               decompress = 1;
-            }else if('1'<=*p && *p<='9'){
-               level = *p - '0';
-            }else{
-               usage();
-               exit(1);
-            }
-         }
-      }else{
-         break;
-      }
-   }
-   if(argc>=1){
-      fn_r = *argv;
-      argc--;argv++;
-   }else{
-      fn_r = NULL;
-   }
-   if(argc>=1){
-      fn_w = *argv;
-      argc--;argv++;
-   }else{
-      fn_w = NULL;
-   }
-   {
-      int len;
-      char buff[0x1000];
-      char mode[10];
-
-      if(decompress){
-         BZFILE *BZ2fp_r = NULL;
-         FILE *fp_w = NULL;
-
-         if(fn_w){
-            if((fp_w = fopen(fn_w,"wb"))==NULL){
-               printf("can't open [%s]\n",fn_w);
-               perror("reason:");
-               exit(1);
-            }
-         }else{
-            fp_w = stdout;
-         }
-         if((fn_r == NULL && (BZ2fp_r = BZ2_bzdopen(fileno(stdin),"rb"))==NULL)
-            || (fn_r != NULL && (BZ2fp_r = BZ2_bzopen(fn_r,"rb"))==NULL)){
-            printf("can't bz2openstream\n");
-            exit(1);
-         }
-         while((len=BZ2_bzread(BZ2fp_r,buff,0x1000))>0){
-            fwrite(buff,1,len,fp_w);
-         }
-         BZ2_bzclose(BZ2fp_r);
-         if(fp_w != stdout) fclose(fp_w);
-      }else{
-         BZFILE *BZ2fp_w = NULL;
-         FILE *fp_r = NULL;
-
-         if(fn_r){
-            if((fp_r = fopen(fn_r,"rb"))==NULL){
-               printf("can't open [%s]\n",fn_r);
-               perror("reason:");
-               exit(1);
-            }
-         }else{
-            fp_r = stdin;
-         }
-         mode[0]='w';
-         mode[1] = '0' + level;
-         mode[2] = '\0';
-
-         if((fn_w == NULL && (BZ2fp_w = BZ2_bzdopen(fileno(stdout),mode))==NULL)
-            || (fn_w !=NULL && (BZ2fp_w = BZ2_bzopen(fn_w,mode))==NULL)){
-            printf("can't bz2openstream\n");
-            exit(1);
-         }
-         while((len=fread(buff,1,0x1000,fp_r))>0){
-            BZ2_bzwrite(BZ2fp_w,buff,len);
-         }
-         BZ2_bzclose(BZ2fp_w);
-         if(fp_r!=stdin)fclose(fp_r);
-      }
-   }
-#ifdef _WIN32
-   BZ2DLLFreeLibrary();
-#endif
-   return 0;
-}
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/dlltest.dsp b/contrib/vmap_extractor_v2/stormlib/bzip2/dlltest.dsp
deleted file mode 100644
index 04819a49563..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/dlltest.dsp
+++ /dev/null
@@ -1,93 +0,0 @@
-# Microsoft Developer Studio Project File - Name="dlltest" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** •ÒW‚µ‚È‚¢‚Å‚­‚¾‚³‚¢ **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=dlltest - Win32 Debug
-!MESSAGE ‚±‚ê‚Í—LŒø‚ÈÒ²¸Ì§²Ù‚Å‚Í‚ ‚è‚Ü‚¹‚ñB ‚±‚ÌÌßÛ¼Þª¸Ä‚ðËÞÙÄÞ‚·‚邽‚ß‚É‚Í NMAKE ‚ðŽg—p‚µ‚Ä‚­‚¾‚³‚¢B
-!MESSAGE [Ò²¸Ì§²Ù‚Ì´¸½Îß°Ä] ºÏÝÄÞ‚ðŽg—p‚µ‚ÄŽÀs‚µ‚Ä‚­‚¾‚³‚¢
-!MESSAGE 
-!MESSAGE NMAKE /f "dlltest.mak".
-!MESSAGE 
-!MESSAGE NMAKE ‚ÌŽÀsŽž‚É\¬‚ðŽw’è‚Å‚«‚Ü‚·
-!MESSAGE ºÏÝÄÞ ×²Ýã‚ÅϸۂÌÝ’è‚ð’è‹`‚µ‚Ü‚·B—á:
-!MESSAGE 
-!MESSAGE NMAKE /f "dlltest.mak" CFG="dlltest - Win32 Debug"
-!MESSAGE 
-!MESSAGE ‘I‘ð‰Â”\‚ÈËÞÙÄÞ Ó°ÄÞ:
-!MESSAGE 
-!MESSAGE "dlltest - Win32 Release" ("Win32 (x86) Console Application" —p)
-!MESSAGE "dlltest - Win32 Debug" ("Win32 (x86) Console Application" —p)
-!MESSAGE 
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "dlltest - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x411 /d "NDEBUG"
-# ADD RSC /l 0x411 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# 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:console /machine:I386
-# 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:console /machine:I386 /out:"minibz2.exe"
-
-!ELSEIF  "$(CFG)" == "dlltest - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "dlltest_"
-# PROP BASE Intermediate_Dir "dlltest_"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "dlltest_"
-# PROP Intermediate_Dir "dlltest_"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x411 /d "_DEBUG"
-# ADD RSC /l 0x411 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# 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:console /debug /machine:I386 /pdbtype:sept
-# 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:console /debug /machine:I386 /out:"minibz2.exe" /pdbtype:sept
-
-!ENDIF 
-
-# Begin Target
-
-# Name "dlltest - Win32 Release"
-# Name "dlltest - Win32 Debug"
-# Begin Source File
-
-SOURCE=.\bzlib.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\dlltest.c
-# End Source File
-# End Target
-# End Project
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/entities.xml b/contrib/vmap_extractor_v2/stormlib/bzip2/entities.xml
deleted file mode 100644
index 6d0975fdbf6..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/entities.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/format.pl b/contrib/vmap_extractor_v2/stormlib/bzip2/format.pl
deleted file mode 100644
index 8ab47acd384..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/format.pl
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/usr/bin/perl -w
-use strict;
-
-# get command line values:
-if ( $#ARGV !=1 ) {
-    die "Usage:  $0 xml_infile xml_outfile\n";
-}
-
-my $infile = shift;
-# check infile exists
-die "Can't find file \"$infile\""
-  unless -f $infile;
-# check we can read infile
-if (! -r $infile) {
-    die "Can't read input $infile\n";
-}
-# check we can open infile
-open( INFILE,"<$infile" ) or 
-    die "Can't input $infile $!";
-
-#my $outfile = 'fmt-manual.xml';
-my $outfile = shift;
-#print "Infile: $infile, Outfile: $outfile\n";
-# check we can write to outfile
-open( OUTFILE,">$outfile" ) or 
-    die "Can't output $outfile $! for writing";
-
-my ($prev, $curr, $str);
-$prev = ''; $curr = '';
-while (  ) {
-
-		print OUTFILE $prev;
-    $prev = $curr;
-    $curr = $_;
-    $str = '';
-
-    if ( $prev =~ /$|$/ ) {
-        chomp $prev;
-        $curr = join( '', $prev, "|<\/screen>/ ) {
-        chomp $prev;
-        $curr = join( '', $prev, "]]>", $curr );
-				$prev = '';
-        next;
-    }
-}
-print OUTFILE $curr;
-close INFILE;
-close OUTFILE;
-exit;
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/huffman.c b/contrib/vmap_extractor_v2/stormlib/bzip2/huffman.c
deleted file mode 100644
index 5bf190be9a1..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/huffman.c
+++ /dev/null
@@ -1,245 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Huffman coding low-level stuff                        ---*/
-/*---                                             huffman.c ---*/
-/*-------------------------------------------------------------*/
-
-/*--
-  This file is a part of bzip2 and/or libbzip2, a program and
-  library for lossless, block-sorting data compression.
-
-  Copyright (C) 1996-2005 Julian R Seward.  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-  2. 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.
-
-  3. Altered source versions must be plainly marked as such, and must
-     not be misrepresented as being the original software.
-
-  4. The name of the author may not be used to endorse or promote 
-     products derived from this software without specific prior written 
-     permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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.
-
-  Julian Seward, Cambridge, UK.
-  jseward@bzip.org
-  bzip2/libbzip2 version 1.0 of 21 March 2000
-
-  This program is based on (at least) the work of:
-     Mike Burrows
-     David Wheeler
-     Peter Fenwick
-     Alistair Moffat
-     Radford Neal
-     Ian H. Witten
-     Robert Sedgewick
-     Jon L. Bentley
-
-  For more information on these sources, see the manual.
---*/
-
-
-#include "bzlib_private.h"
-
-/*---------------------------------------------------*/
-#define WEIGHTOF(zz0)  ((zz0) & 0xffffff00)
-#define DEPTHOF(zz1)   ((zz1) & 0x000000ff)
-#define MYMAX(zz2,zz3) ((zz2) > (zz3) ? (zz2) : (zz3))
-
-#define ADDWEIGHTS(zw1,zw2)                           \
-   (WEIGHTOF(zw1)+WEIGHTOF(zw2)) |                    \
-   (1 + MYMAX(DEPTHOF(zw1),DEPTHOF(zw2)))
-
-#define UPHEAP(z)                                     \
-{                                                     \
-   Int32 zz, tmp;                                     \
-   zz = z; tmp = heap[zz];                            \
-   while (weight[tmp] < weight[heap[zz >> 1]]) {      \
-      heap[zz] = heap[zz >> 1];                       \
-      zz >>= 1;                                       \
-   }                                                  \
-   heap[zz] = tmp;                                    \
-}
-
-#define DOWNHEAP(z)                                   \
-{                                                     \
-   Int32 zz, yy, tmp;                                 \
-   zz = z; tmp = heap[zz];                            \
-   while (True) {                                     \
-      yy = zz << 1;                                   \
-      if (yy > nHeap) break;                          \
-      if (yy < nHeap &&                               \
-          weight[heap[yy+1]] < weight[heap[yy]])      \
-         yy++;                                        \
-      if (weight[tmp] < weight[heap[yy]]) break;      \
-      heap[zz] = heap[yy];                            \
-      zz = yy;                                        \
-   }                                                  \
-   heap[zz] = tmp;                                    \
-}
-
-
-/*---------------------------------------------------*/
-void BZ2_hbMakeCodeLengths ( UChar *len, 
-                             Int32 *freq,
-                             Int32 alphaSize,
-                             Int32 maxLen )
-{
-   /*--
-      Nodes and heap entries run from 1.  Entry 0
-      for both the heap and nodes is a sentinel.
-   --*/
-   Int32 nNodes, nHeap, n1, n2, i, j, k;
-   Bool  tooLong;
-
-   Int32 heap   [ BZ_MAX_ALPHA_SIZE + 2 ];
-   Int32 weight [ BZ_MAX_ALPHA_SIZE * 2 ];
-   Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ]; 
-
-   for (i = 0; i < alphaSize; i++)
-      weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8;
-
-   while (True) {
-
-      nNodes = alphaSize;
-      nHeap = 0;
-
-      heap[0] = 0;
-      weight[0] = 0;
-      parent[0] = -2;
-
-      for (i = 1; i <= alphaSize; i++) {
-         parent[i] = -1;
-         nHeap++;
-         heap[nHeap] = i;
-         UPHEAP(nHeap);
-      }
-
-      AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 );
-   
-      while (nHeap > 1) {
-         n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
-         n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
-         nNodes++;
-         parent[n1] = parent[n2] = nNodes;
-         weight[nNodes] = ADDWEIGHTS(weight[n1], weight[n2]);
-         parent[nNodes] = -1;
-         nHeap++;
-         heap[nHeap] = nNodes;
-         UPHEAP(nHeap);
-      }
-
-      AssertH( nNodes < (BZ_MAX_ALPHA_SIZE * 2), 2002 );
-
-      tooLong = False;
-      for (i = 1; i <= alphaSize; i++) {
-         j = 0;
-         k = i;
-         while (parent[k] >= 0) { k = parent[k]; j++; }
-         len[i-1] = j;
-         if (j > maxLen) tooLong = True;
-      }
-      
-      if (! tooLong) break;
-
-      /* 17 Oct 04: keep-going condition for the following loop used
-         to be 'i < alphaSize', which missed the last element,
-         theoretically leading to the possibility of the compressor
-         looping.  However, this count-scaling step is only needed if
-         one of the generated Huffman code words is longer than
-         maxLen, which up to and including version 1.0.2 was 20 bits,
-         which is extremely unlikely.  In version 1.0.3 maxLen was
-         changed to 17 bits, which has minimal effect on compression
-         ratio, but does mean this scaling step is used from time to
-         time, enough to verify that it works.
-
-         This means that bzip2-1.0.3 and later will only produce
-         Huffman codes with a maximum length of 17 bits.  However, in
-         order to preserve backwards compatibility with bitstreams
-         produced by versions pre-1.0.3, the decompressor must still
-         handle lengths of up to 20. */
-
-      for (i = 1; i <= alphaSize; i++) {
-         j = weight[i] >> 8;
-         j = 1 + (j / 2);
-         weight[i] = j << 8;
-      }
-   }
-}
-
-
-/*---------------------------------------------------*/
-void BZ2_hbAssignCodes ( Int32 *code,
-                         UChar *length,
-                         Int32 minLen,
-                         Int32 maxLen,
-                         Int32 alphaSize )
-{
-   Int32 n, vec, i;
-
-   vec = 0;
-   for (n = minLen; n <= maxLen; n++) {
-      for (i = 0; i < alphaSize; i++)
-         if (length[i] == n) { code[i] = vec; vec++; };
-      vec <<= 1;
-   }
-}
-
-
-/*---------------------------------------------------*/
-void BZ2_hbCreateDecodeTables ( Int32 *limit,
-                                Int32 *base,
-                                Int32 *perm,
-                                UChar *length,
-                                Int32 minLen,
-                                Int32 maxLen,
-                                Int32 alphaSize )
-{
-   Int32 pp, i, j, vec;
-
-   pp = 0;
-   for (i = minLen; i <= maxLen; i++)
-      for (j = 0; j < alphaSize; j++)
-         if (length[j] == i) { perm[pp] = j; pp++; };
-
-   for (i = 0; i < BZ_MAX_CODE_LEN; i++) base[i] = 0;
-   for (i = 0; i < alphaSize; i++) base[length[i]+1]++;
-
-   for (i = 1; i < BZ_MAX_CODE_LEN; i++) base[i] += base[i-1];
-
-   for (i = 0; i < BZ_MAX_CODE_LEN; i++) limit[i] = 0;
-   vec = 0;
-
-   for (i = minLen; i <= maxLen; i++) {
-      vec += (base[i+1] - base[i]);
-      limit[i] = vec-1;
-      vec <<= 1;
-   }
-   for (i = minLen + 1; i <= maxLen; i++)
-      base[i] = ((limit[i-1] + 1) << 1) - base[i];
-}
-
-
-/*-------------------------------------------------------------*/
-/*--- end                                         huffman.c ---*/
-/*-------------------------------------------------------------*/
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/libbz2.def b/contrib/vmap_extractor_v2/stormlib/bzip2/libbz2.def
deleted file mode 100644
index 4f83fcc6102..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/libbz2.def
+++ /dev/null
@@ -1,27 +0,0 @@
-LIBRARY			LIBBZ2
-DESCRIPTION		"libbzip2: library for data compression"
-EXPORTS
-	BZ2_bzCompressInit
-	BZ2_bzCompress
-	BZ2_bzCompressEnd
-	BZ2_bzDecompressInit
-	BZ2_bzDecompress
-	BZ2_bzDecompressEnd
-	BZ2_bzReadOpen
-	BZ2_bzReadClose
-	BZ2_bzReadGetUnused
-	BZ2_bzRead
-	BZ2_bzWriteOpen
-	BZ2_bzWrite
-	BZ2_bzWriteClose
-	BZ2_bzWriteClose64
-	BZ2_bzBuffToBuffCompress
-	BZ2_bzBuffToBuffDecompress
-	BZ2_bzlibVersion
-	BZ2_bzopen
-	BZ2_bzdopen
-	BZ2_bzread
-	BZ2_bzwrite
-	BZ2_bzflush
-	BZ2_bzclose
-	BZ2_bzerror
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/libbz2.dsp b/contrib/vmap_extractor_v2/stormlib/bzip2/libbz2.dsp
deleted file mode 100644
index 06c1d376251..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/libbz2.dsp
+++ /dev/null
@@ -1,130 +0,0 @@
-# Microsoft Developer Studio Project File - Name="libbz2" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** •ÒW‚µ‚È‚¢‚Å‚­‚¾‚³‚¢ **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=libbz2 - Win32 Debug
-!MESSAGE ‚±‚ê‚Í—LŒø‚ÈÒ²¸Ì§²Ù‚Å‚Í‚ ‚è‚Ü‚¹‚ñB ‚±‚ÌÌßÛ¼Þª¸Ä‚ðËÞÙÄÞ‚·‚邽‚ß‚É‚Í NMAKE ‚ðŽg—p‚µ‚Ä‚­‚¾‚³‚¢B
-!MESSAGE [Ò²¸Ì§²Ù‚Ì´¸½Îß°Ä] ºÏÝÄÞ‚ðŽg—p‚µ‚ÄŽÀs‚µ‚Ä‚­‚¾‚³‚¢
-!MESSAGE 
-!MESSAGE NMAKE /f "libbz2.mak".
-!MESSAGE 
-!MESSAGE NMAKE ‚ÌŽÀsŽž‚É\¬‚ðŽw’è‚Å‚«‚Ü‚·
-!MESSAGE ºÏÝÄÞ ×²Ýã‚ÅϸۂÌÝ’è‚ð’è‹`‚µ‚Ü‚·B—á:
-!MESSAGE 
-!MESSAGE NMAKE /f "libbz2.mak" CFG="libbz2 - Win32 Debug"
-!MESSAGE 
-!MESSAGE ‘I‘ð‰Â”\‚ÈËÞÙÄÞ Ó°ÄÞ:
-!MESSAGE 
-!MESSAGE "libbz2 - Win32 Release" ("Win32 (x86) Dynamic-Link Library" —p)
-!MESSAGE "libbz2 - Win32 Debug" ("Win32 (x86) Dynamic-Link Library" —p)
-!MESSAGE 
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "libbz2 - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
-# ADD BASE RSC /l 0x411 /d "NDEBUG"
-# ADD RSC /l 0x411 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# 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 /dll /machine:I386
-# 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 /dll /machine:I386 /out:"libbz2.dll"
-
-!ELSEIF  "$(CFG)" == "libbz2 - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
-# ADD BASE RSC /l 0x411 /d "_DEBUG"
-# ADD RSC /l 0x411 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# 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 /dll /debug /machine:I386 /pdbtype:sept
-# 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 /dll /debug /machine:I386 /out:"libbz2.dll" /pdbtype:sept
-
-!ENDIF 
-
-# Begin Target
-
-# Name "libbz2 - Win32 Release"
-# Name "libbz2 - Win32 Debug"
-# Begin Source File
-
-SOURCE=.\blocksort.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\bzlib.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\bzlib.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\bzlib_private.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\compress.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\crctable.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\decompress.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\huffman.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libbz2.def
-# End Source File
-# Begin Source File
-
-SOURCE=.\randtable.c
-# End Source File
-# End Target
-# End Project
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/makefile.msc b/contrib/vmap_extractor_v2/stormlib/bzip2/makefile.msc
deleted file mode 100644
index 6a628a753a0..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/makefile.msc
+++ /dev/null
@@ -1,63 +0,0 @@
-# Makefile for Microsoft Visual C++ 6.0
-# usage: nmake -f makefile.msc
-# K.M. Syring (syring@gsf.de)
-# Fixed up by JRS for bzip2-0.9.5d release.
-
-CC=cl
-CFLAGS= -DWIN32 -MD -Ox -D_FILE_OFFSET_BITS=64 -nologo
-
-OBJS= blocksort.obj  \
-      huffman.obj    \
-      crctable.obj   \
-      randtable.obj  \
-      compress.obj   \
-      decompress.obj \
-      bzlib.obj
-
-all: lib bzip2 test
-
-bzip2: lib
-	$(CC) $(CFLAGS) -o bzip2 bzip2.c libbz2.lib setargv.obj
-	$(CC) $(CFLAGS) -o bzip2recover bzip2recover.c
-
-lib: $(OBJS)
-	lib /out:libbz2.lib $(OBJS)
-
-test: bzip2
-	type words1
-	.\\bzip2 -1  < sample1.ref > sample1.rb2
-	.\\bzip2 -2  < sample2.ref > sample2.rb2
-	.\\bzip2 -3  < sample3.ref > sample3.rb2
-	.\\bzip2 -d  < sample1.bz2 > sample1.tst
-	.\\bzip2 -d  < sample2.bz2 > sample2.tst
-	.\\bzip2 -ds < sample3.bz2 > sample3.tst
-	@echo All six of the fc's should find no differences.
-	@echo If fc finds an error on sample3.bz2, this could be
-	@echo because WinZip's 'TAR file smart CR/LF conversion'
-	@echo is too clever for its own good.  Disable this option.
-	@echo The correct size for sample3.ref is 120,244.  If it
-	@echo is 150,251, WinZip has messed it up.
-	fc sample1.bz2 sample1.rb2 
-	fc sample2.bz2 sample2.rb2
-	fc sample3.bz2 sample3.rb2
-	fc sample1.tst sample1.ref
-	fc sample2.tst sample2.ref
-	fc sample3.tst sample3.ref
-
-
-
-clean: 
-	del *.obj
-	del libbz2.lib 
-	del bzip2.exe
-	del bzip2recover.exe
-	del sample1.rb2 
-	del sample2.rb2 
-	del sample3.rb2
-	del sample1.tst 
-	del sample2.tst
-	del sample3.tst
-
-.c.obj: 
-	$(CC) $(CFLAGS) -c $*.c -o $*.obj
-
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/manual.html b/contrib/vmap_extractor_v2/stormlib/bzip2/manual.html
deleted file mode 100644
index b28cc79a8c6..00000000000
--- a/contrib/vmap_extractor_v2/stormlib/bzip2/manual.html
+++ /dev/null
@@ -1,2687 +0,0 @@
-
-
-
-bzip2 and libbzip2, version 1.0.3
-
-
-
-
-
-
-

-bzip2 and libbzip2, version 1.0.3

-

A program and library for data compression

-
-

-Julian Seward -

-
http://www.bzip.org
-
-

Version 1.0.3 of 15 February 2005

-
-
-

This program, bzip2, the - associated library libbzip2, and - all documentation, are copyright © 1996-2005 Julian Seward. - 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.

  • -
  • 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.

  • -
  • Altered source versions must be plainly marked - as such, and must not be misrepresented as being the original - software.

  • -
  • The name of the author may not be used to - endorse or promote products derived from this software without - specific prior written permission.

  • -
-

THIS SOFTWARE IS PROVIDED BY THE AUTHOR "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 THE - AUTHOR 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.

-

PATENTS: To the best of my knowledge, - bzip2 and - libbzip2 do not use any patented - algorithms. However, I do not have the resources to carry - out a patent search. Therefore I cannot give any guarantee of - the above statement. -

-
-
-
-
-
- -
-
-

-1. Introduction

-
-
-

bzip2 compresses files -using the Burrows-Wheeler block-sorting text compression -algorithm, and Huffman coding. Compression is generally -considerably better than that achieved by more conventional -LZ77/LZ78-based compressors, and approaches the performance of -the PPM family of statistical compressors.

-

bzip2 is built on top of -libbzip2, a flexible library for -handling compressed data in the -bzip2 format. This manual -describes both how to use the program and how to work with the -library interface. Most of the manual is devoted to this -library, not the program, which is good news if your interest is -only in the program.

-
    -
  • How to use bzip2 describes how to use - bzip2; this is the only part - you need to read if you just want to know how to operate the - program.

  • -
  • Programming with libbzip2 describes the - programming interfaces in detail, and

  • -
  • Miscellanea records some - miscellaneous notes which I thought ought to be recorded - somewhere.

  • -
-
-
-
-

-2. How to use bzip2

-
-
- -

This chapter contains a copy of the -bzip2 man page, and nothing -else.

-
-
-

-2.1. NAME

-
-
-
    -
  • bzip2, - bunzip2 - a block-sorting file - compressor, v1.0.3

  • -
  • bzcat - - decompresses files to stdout

  • -
  • bzip2recover - - recovers data from damaged bzip2 files

  • -
-
-
-
-

-2.2. SYNOPSIS

-
-
-
    -
  • bzip2 [ - -cdfkqstvzVL123456789 ] [ filenames ... ]

  • -
  • bunzip2 [ - -fkvsVL ] [ filenames ... ]

  • -
  • bzcat [ -s ] [ - filenames ... ]

  • -
  • bzip2recover - filename

  • -
-
-
-
-

-2.3. DESCRIPTION

-
-
-

bzip2 compresses files -using the Burrows-Wheeler block sorting text compression -algorithm, and Huffman coding. Compression is generally -considerably better than that achieved by more conventional -LZ77/LZ78-based compressors, and approaches the performance of -the PPM family of statistical compressors.

-

The command-line options are deliberately very similar to -those of GNU gzip, but they are -not identical.

-

bzip2 expects a list of -file names to accompany the command-line flags. Each file is -replaced by a compressed version of itself, with the name -original_name.bz2. Each -compressed file has the same modification date, permissions, and, -when possible, ownership as the corresponding original, so that -these properties can be correctly restored at decompression time. -File name handling is naive in the sense that there is no -mechanism for preserving original file names, permissions, -ownerships or dates in filesystems which lack these concepts, or -have serious file name length restrictions, such as -MS-DOS.

-

bzip2 and -bunzip2 will by default not -overwrite existing files. If you want this to happen, specify -the -f flag.

-

If no file names are specified, -bzip2 compresses from standard -input to standard output. In this case, -bzip2 will decline to write -compressed output to a terminal, as this would be entirely -incomprehensible and therefore pointless.

-

bunzip2 (or -bzip2 -d) decompresses all -specified files. Files which were not created by -bzip2 will be detected and -ignored, and a warning issued. -bzip2 attempts to guess the -filename for the decompressed file from that of the compressed -file as follows:

-
    -
  • filename.bz2 - becomes - filename

  • -
  • filename.bz - becomes - filename

  • -
  • filename.tbz2 - becomes - filename.tar

  • -
  • filename.tbz - becomes - filename.tar

  • -
  • anyothername - becomes - anyothername.out

  • -
-

If the file does not end in one of the recognised endings, -.bz2, -.bz, -.tbz2 or -.tbz, -bzip2 complains that it cannot -guess the name of the original file, and uses the original name -with .out appended.

-

As with compression, supplying no filenames causes -decompression from standard input to standard output.

-

bunzip2 will correctly -decompress a file which is the concatenation of two or more -compressed files. The result is the concatenation of the -corresponding uncompressed files. Integrity testing -(-t) of concatenated compressed -files is also supported.

-

You can also compress or decompress files to the standard -output by giving the -c flag. -Multiple files may be compressed and decompressed like this. The -resulting outputs are fed sequentially to stdout. Compression of -multiple files in this manner generates a stream containing -multiple compressed file representations. Such a stream can be -decompressed correctly only by -bzip2 version 0.9.0 or later. -Earlier versions of bzip2 will -stop after decompressing the first file in the stream.

-

bzcat (or -bzip2 -dc) decompresses all -specified files to the standard output.

-

bzip2 will read arguments -from the environment variables -BZIP2 and -BZIP, in that order, and will -process them before any arguments read from the command line. -This gives a convenient way to supply default arguments.

-

Compression is always performed, even if the compressed -file is slightly larger than the original. Files of less than -about one hundred bytes tend to get larger, since the compression -mechanism has a constant overhead in the region of 50 bytes. -Random data (including the output of most file compressors) is -coded at about 8.05 bits per byte, giving an expansion of around -0.5%.

-

As a self-check for your protection, -bzip2 uses 32-bit CRCs to make -sure that the decompressed version of a file is identical to the -original. This guards against corruption of the compressed data, -and against undetected bugs in -bzip2 (hopefully very unlikely). -The chances of data corruption going undetected is microscopic, -about one chance in four billion for each file processed. Be -aware, though, that the check occurs upon decompression, so it -can only tell you that something is wrong. It can't help you -recover the original uncompressed data. You can use -bzip2recover to try to recover -data from damaged files.

-

Return values: 0 for a normal exit, 1 for environmental -problems (file not found, invalid flags, I/O errors, etc.), 2 -to indicate a corrupt compressed file, 3 for an internal -consistency error (eg, bug) which caused -bzip2 to panic.

-
-
-
-

-2.4. OPTIONS

-
-
-
-
-c --stdout
-

Compress or decompress to standard - output.

-
-d --decompress
-

Force decompression. - bzip2, - bunzip2 and - bzcat are really the same - program, and the decision about what actions to take is done on - the basis of which name is used. This flag overrides that - mechanism, and forces bzip2 to decompress.

-
-z --compress
-

The complement to - -d: forces compression, - regardless of the invokation name.

-
-t --test
-

Check integrity of the specified file(s), but - don't decompress them. This really performs a trial - decompression and throws away the result.

-
-f --force
-
-

Force overwrite of output files. Normally, - bzip2 will not overwrite - existing output files. Also forces - bzip2 to break hard links to - files, which it otherwise wouldn't do.

-

bzip2 normally declines - to decompress files which don't have the correct magic header - bytes. If forced (-f), - however, it will pass such files through unmodified. This is - how GNU gzip behaves.

-
-
-k --keep
-

Keep (don't delete) input files during - compression or decompression.

-
-s --small
-
-

Reduce memory usage, for compression, - decompression and testing. Files are decompressed and tested - using a modified algorithm which only requires 2.5 bytes per - block byte. This means any file can be decompressed in 2300k - of memory, albeit at about half the normal speed.

-

During compression, -s - selects a block size of 200k, which limits memory use to around - the same figure, at the expense of your compression ratio. In - short, if your machine is low on memory (8 megabytes or less), - use -s for everything. See - MEMORY MANAGEMENT below.

-
-
-q --quiet
-

Suppress non-essential warning messages. - Messages pertaining to I/O errors and other critical events - will not be suppressed.

-
-v --verbose
-

Verbose mode -- show the compression ratio for - each file processed. Further - -v's increase the verbosity - level, spewing out lots of information which is primarily of - interest for diagnostic purposes.

-
-L --license -V --version
-

Display the software version, license terms and - conditions.

-
-1 (or - --fast) to - -9 (or - -best)
-

Set the block size to 100 k, 200 k ... 900 k - when compressing. Has no effect when decompressing. See MEMORY MANAGEMENT below. The - --fast and - --best aliases are primarily - for GNU gzip compatibility. - In particular, --fast doesn't - make things significantly faster. And - --best merely selects the - default behaviour.

-
--
-

Treats all subsequent arguments as file names, - even if they start with a dash. This is so you can handle - files with names beginning with a dash, for example: - bzip2 -- - -myfilename.

-
---repetitive-fast, --repetitive-best, -
-

These flags are redundant in versions 0.9.5 and - above. They provided some coarse control over the behaviour of - the sorting algorithm in earlier versions, which was sometimes - useful. 0.9.5 and above have an improved algorithm which - renders these flags irrelevant.

-
-
-
-
-

-2.5. MEMORY MANAGEMENT

-
-
-

bzip2 compresses large -files in blocks. The block size affects both the compression -ratio achieved, and the amount of memory needed for compression -and decompression. The flags -1 -through -9 specify the block -size to be 100,000 bytes through 900,000 bytes (the default) -respectively. At decompression time, the block size used for -compression is read from the header of the compressed file, and -bunzip2 then allocates itself -just enough memory to decompress the file. Since block sizes are -stored in compressed files, it follows that the flags --1 to --9 are irrelevant to and so -ignored during decompression.

-

Compression and decompression requirements, in bytes, can be -estimated as:

-
Compression:   400k + ( 8 x block size )
-
-Decompression: 100k + ( 4 x block size ), or
-               100k + ( 2.5 x block size )
-

Larger block sizes give rapidly diminishing marginal -returns. Most of the compression comes from the first two or -three hundred k of block size, a fact worth bearing in mind when -using bzip2 on small machines. -It is also important to appreciate that the decompression memory -requirement is set at compression time by the choice of block -size.

-

For files compressed with the default 900k block size, -bunzip2 will require about 3700 -kbytes to decompress. To support decompression of any file on a -4 megabyte machine, bunzip2 has -an option to decompress using approximately half this amount of -memory, about 2300 kbytes. Decompression speed is also halved, -so you should use this option only where necessary. The relevant -flag is -s.

-

In general, try and use the largest block size memory -constraints allow, since that maximises the compression achieved. -Compression and decompression speed are virtually unaffected by -block size.

-

Another significant point applies to files which fit in a -single block -- that means most files you'd encounter using a -large block size. The amount of real memory touched is -proportional to the size of the file, since the file is smaller -than a block. For example, compressing a file 20,000 bytes long -with the flag -9 will cause the -compressor to allocate around 7600k of memory, but only touch -400k + 20000 * 8 = 560 kbytes of it. Similarly, the decompressor -will allocate 3700k but only touch 100k + 20000 * 4 = 180 -kbytes.

-

Here is a table which summarises the maximum memory usage -for different block sizes. Also recorded is the total compressed -size for 14 files of the Calgary Text Compression Corpus -totalling 3,141,622 bytes. This column gives some feel for how -compression varies with block size. These figures tend to -understate the advantage of larger block sizes for larger files, -since the Corpus is dominated by smaller files.

-
        Compress   Decompress   Decompress   Corpus
-Flag     usage      usage       -s usage     Size
-
- -1      1200k       500k         350k      914704
- -2      2000k       900k         600k      877703
- -3      2800k      1300k         850k      860338
- -4      3600k      1700k        1100k      846899
- -5      4400k      2100k        1350k      845160
- -6      5200k      2500k        1600k      838626
- -7      6100k      2900k        1850k      834096
- -8      6800k      3300k        2100k      828642
- -9      7600k      3700k        2350k      828642
-
-
-
-

-2.6. RECOVERING DATA FROM DAMAGED FILES

-
-
-

bzip2 compresses files in -blocks, usually 900kbytes long. Each block is handled -independently. If a media or transmission error causes a -multi-block .bz2 file to become -damaged, it may be possible to recover data from the undamaged -blocks in the file.

-

The compressed representation of each block is delimited by -a 48-bit pattern, which makes it possible to find the block -boundaries with reasonable certainty. Each block also carries -its own 32-bit CRC, so damaged blocks can be distinguished from -undamaged ones.

-

bzip2recover is a simple -program whose purpose is to search for blocks in -.bz2 files, and write each block -out into its own .bz2 file. You -can then use bzip2 -t to test -the integrity of the resulting files, and decompress those which -are undamaged.

-

bzip2recover takes a -single argument, the name of the damaged file, and writes a -number of files rec0001file.bz2, -rec0002file.bz2, etc, containing -the extracted blocks. The output filenames are designed so that -the use of wildcards in subsequent processing -- for example, -bzip2 -dc rec*file.bz2 > -recovered_data -- lists the files in the correct -order.

-

bzip2recover should be of -most use dealing with large .bz2 -files, as these will contain many blocks. It is clearly futile -to use it on damaged single-block files, since a damaged block -cannot be recovered. If you wish to minimise any potential data -loss through media or transmission errors, you might consider -compressing with a smaller block size.

-
-
-
-

-2.7. PERFORMANCE NOTES

-
-
-

The sorting phase of compression gathers together similar -strings in the file. Because of this, files containing very long -runs of repeated symbols, like "aabaabaabaab ..." (repeated -several hundred times) may compress more slowly than normal. -Versions 0.9.5 and above fare much better than previous versions -in this respect. The ratio between worst-case and average-case -compression time is in the region of 10:1. For previous -versions, this figure was more like 100:1. You can use the --vvvv option to monitor progress -in great detail, if you want.

-

Decompression speed is unaffected by these -phenomena.

-

bzip2 usually allocates -several megabytes of memory to operate in, and then charges all -over it in a fairly random fashion. This means that performance, -both for compressing and decompressing, is largely determined by -the speed at which your machine can service cache misses. -Because of this, small changes to the code to reduce the miss -rate have been observed to give disproportionately large -performance improvements. I imagine -bzip2 will perform best on -machines with very large caches.

-
-
-
-

-2.8. CAVEATS

-
-
-

I/O error messages are not as helpful as they could be. -bzip2 tries hard to detect I/O -errors and exit cleanly, but the details of what the problem is -sometimes seem rather misleading.

-

This manual page pertains to version 1.0.3 of -bzip2. Compressed data created -by this version is entirely forwards and backwards compatible -with the previous public releases, versions 0.1pl2, 0.9.0 and -0.9.5, 1.0.0, 1.0.1 and 1.0.2, but with the following exception: 0.9.0 -and above can correctly decompress multiple concatenated -compressed files. 0.1pl2 cannot do this; it will stop after -decompressing just the first file in the stream.

-

bzip2recover versions -prior to 1.0.2 used 32-bit integers to represent bit positions in -compressed files, so it could not handle compressed files more -than 512 megabytes long. Versions 1.0.2 and above use 64-bit ints -on some platforms which support them (GNU supported targets, and -Windows). To establish whether or not -bzip2recover was built with such -a limitation, run it without arguments. In any event you can -build yourself an unlimited version if you can recompile it with -MaybeUInt64 set to be an -unsigned 64-bit integer.

-
-
-
-

-2.9. AUTHOR

-
-
-

Julian Seward, -jseward@bzip.org

-

The ideas embodied in -bzip2 are due to (at least) the -following people: Michael Burrows and David Wheeler (for the -block sorting transformation), David Wheeler (again, for the -Huffman coder), Peter Fenwick (for the structured coding model in -the original bzip, and many -refinements), and Alistair Moffat, Radford Neal and Ian Witten -(for the arithmetic coder in the original -bzip). I am much indebted for -their help, support and advice. See the manual in the source -distribution for pointers to sources of documentation. Christian -von Roques encouraged me to look for faster sorting algorithms, -so as to speed up compression. Bela Lubkin encouraged me to -improve the worst-case compression performance. -Donna Robinson XMLised the documentation. -Many people sent -patches, helped with portability problems, lent machines, gave -advice and were generally helpful.

-
-
-
-
-

-3.  -Programming with libbzip2 -

-
-
- -

This chapter describes the programming interface to -libbzip2.

-

For general background information, particularly about -memory use and performance aspects, you'd be well advised to read -How to use bzip2 as well.

-
-
-

-3.1. Top-level structure

-
-
-

libbzip2 is a flexible -library for compressing and decompressing data in the -bzip2 data format. Although -packaged as a single entity, it helps to regard the library as -three separate parts: the low level interface, and the high level -interface, and some utility functions.

-

The structure of -libbzip2's interfaces is similar -to that of Jean-loup Gailly's and Mark Adler's excellent -zlib library.

-

All externally visible symbols have names beginning -BZ2_. This is new in version -1.0. The intention is to minimise pollution of the namespaces of -library clients.

-

To use any part of the library, you need to -#include <bzlib.h> -into your sources.

-
-
-

-3.1.1. Low-level summary

-
-
-

This interface provides services for compressing and -decompressing data in memory. There's no provision for dealing -with files, streams or any other I/O mechanisms, just straight -memory-to-memory work. In fact, this part of the library can be -compiled without inclusion of -stdio.h, which may be helpful -for embedded applications.

-

The low-level part of the library has no global variables -and is therefore thread-safe.

-

Six routines make up the low level interface: -BZ2_bzCompressInit, -BZ2_bzCompress, and -BZ2_bzCompressEnd for -compression, and a corresponding trio -BZ2_bzDecompressInit, -BZ2_bzDecompress and -BZ2_bzDecompressEnd for -decompression. The *Init -functions allocate memory for compression/decompression and do -other initialisations, whilst the -*End functions close down -operations and release memory.

-

The real work is done by -BZ2_bzCompress and -BZ2_bzDecompress. These -compress and decompress data from a user-supplied input buffer to -a user-supplied output buffer. These buffers can be any size; -arbitrary quantities of data are handled by making repeated calls -to these functions. This is a flexible mechanism allowing a -consumer-pull style of activity, or producer-push, or a mixture -of both.

-
-
-
-

-3.1.2. High-level summary

-
-
-

This interface provides some handy wrappers around the -low-level interface to facilitate reading and writing -bzip2 format files -(.bz2 files). The routines -provide hooks to facilitate reading files in which the -bzip2 data stream is embedded -within some larger-scale file structure, or where there are -multiple bzip2 data streams -concatenated end-to-end.

-

For reading files, -BZ2_bzReadOpen, -BZ2_bzRead, -BZ2_bzReadClose and -BZ2_bzReadGetUnused are -supplied. For writing files, -BZ2_bzWriteOpen, -BZ2_bzWrite and -BZ2_bzWriteFinish are -available.

-

As with the low-level library, no global variables are used -so the library is per se thread-safe. However, if I/O errors -occur whilst reading or writing the underlying compressed files, -you may have to consult errno to -determine the cause of the error. In that case, you'd need a C -library which correctly supports -errno in a multithreaded -environment.

-

To make the library a little simpler and more portable, -BZ2_bzReadOpen and -BZ2_bzWriteOpen require you to -pass them file handles (FILE*s) -which have previously been opened for reading or writing -respectively. That avoids portability problems associated with -file operations and file attributes, whilst not being much of an -imposition on the programmer.

-
-
-
-

-3.1.3. Utility functions summary

-
-
-

For very simple needs, -BZ2_bzBuffToBuffCompress and -BZ2_bzBuffToBuffDecompress are -provided. These compress data in memory from one buffer to -another buffer in a single function call. You should assess -whether these functions fulfill your memory-to-memory -compression/decompression requirements before investing effort in -understanding the more general but more complex low-level -interface.

-

Yoshioka Tsuneo -(QWF00133@niftyserve.or.jp / -tsuneo-y@is.aist-nara.ac.jp) has -contributed some functions to give better -zlib compatibility. These -functions are BZ2_bzopen, -BZ2_bzread, -BZ2_bzwrite, -BZ2_bzflush, -BZ2_bzclose, -BZ2_bzerror and -BZ2_bzlibVersion. You may find -these functions more convenient for simple file reading and -writing, than those in the high-level interface. These functions -are not (yet) officially part of the library, and are minimally -documented here. If they break, you get to keep all the pieces. -I hope to document them properly when time permits.

-

Yoshioka also contributed modifications to allow the -library to be built as a Windows DLL.

-
-
-
-
-

-3.2. Error handling

-
-
-

The library is designed to recover cleanly in all -situations, including the worst-case situation of decompressing -random data. I'm not 100% sure that it can always do this, so -you might want to add a signal handler to catch segmentation -violations during decompression if you are feeling especially -paranoid. I would be interested in hearing more about the -robustness of the library to corrupted compressed data.

-

Version 1.0.3 more robust in this respect than any -previous version. Investigations with Valgrind (a tool for detecting -problems with memory management) indicate -that, at least for the few files I tested, all single-bit errors -in the decompressed data are caught properly, with no -segmentation faults, no uses of uninitialised data, no out of -range reads or writes, and no infinite looping in the decompressor. -So it's certainly pretty robust, although -I wouldn't claim it to be totally bombproof.

-

The file bzlib.h contains -all definitions needed to use the library. In particular, you -should definitely not include -bzlib_private.h.

-

In bzlib.h, the various -return values are defined. The following list is not intended as -an exhaustive description of the circumstances in which a given -value may be returned -- those descriptions are given later. -Rather, it is intended to convey the rough meaning of each return -value. The first five actions are normal and not intended to -denote an error situation.

-
-
BZ_OK
-

The requested action was completed - successfully.

-
BZ_RUN_OK, BZ_FLUSH_OK, - BZ_FINISH_OK
-

In - BZ2_bzCompress, the requested - flush/finish/nothing-special action was completed - successfully.

-
BZ_STREAM_END
-

Compression of data was completed, or the - logical stream end was detected during - decompression.

-
-

The following return values indicate an error of some -kind.

-
-
BZ_CONFIG_ERROR
-

Indicates that the library has been improperly - compiled on your platform -- a major configuration error. - Specifically, it means that - sizeof(char), - sizeof(short) and - sizeof(int) are not 1, 2 and - 4 respectively, as they should be. Note that the library - should still work properly on 64-bit platforms which follow - the LP64 programming model -- that is, where - sizeof(long) and - sizeof(void*) are 8. Under - LP64, sizeof(int) is still 4, - so libbzip2, which doesn't - use the long type, is - OK.

-
BZ_SEQUENCE_ERROR
-

When using the library, it is important to call - the functions in the correct sequence and with data structures - (buffers etc) in the correct states. - libbzip2 checks as much as it - can to ensure this is happening, and returns - BZ_SEQUENCE_ERROR if not. - Code which complies precisely with the function semantics, as - detailed below, should never receive this value; such an event - denotes buggy code which you should - investigate.

-
BZ_PARAM_ERROR
-

Returned when a parameter to a function call is - out of range or otherwise manifestly incorrect. As with - BZ_SEQUENCE_ERROR, this - denotes a bug in the client code. The distinction between - BZ_PARAM_ERROR and - BZ_SEQUENCE_ERROR is a bit - hazy, but still worth making.

-
BZ_MEM_ERROR
-

Returned when a request to allocate memory - failed. Note that the quantity of memory needed to decompress - a stream cannot be determined until the stream's header has - been read. So - BZ2_bzDecompress and - BZ2_bzRead may return - BZ_MEM_ERROR even though some - of the compressed data has been read. The same is not true - for compression; once - BZ2_bzCompressInit or - BZ2_bzWriteOpen have - successfully completed, - BZ_MEM_ERROR cannot - occur.

-
BZ_DATA_ERROR
-

Returned when a data integrity error is - detected during decompression. Most importantly, this means - when stored and computed CRCs for the data do not match. This - value is also returned upon detection of any other anomaly in - the compressed data.

-
BZ_DATA_ERROR_MAGIC
-

As a special case of - BZ_DATA_ERROR, it is - sometimes useful to know when the compressed stream does not - start with the correct magic bytes ('B' 'Z' - 'h').

-
BZ_IO_ERROR
-

Returned by - BZ2_bzRead and - BZ2_bzWrite when there is an - error reading or writing in the compressed file, and by - BZ2_bzReadOpen and - BZ2_bzWriteOpen for attempts - to use a file for which the error indicator (viz, - ferror(f)) is set. On - receipt of BZ_IO_ERROR, the - caller should consult errno - and/or perror to acquire - operating-system specific information about the - problem.

-
BZ_UNEXPECTED_EOF
-

Returned by - BZ2_bzRead when the - compressed file finishes before the logical end of stream is - detected.

-
BZ_OUTBUFF_FULL
-

Returned by - BZ2_bzBuffToBuffCompress and - BZ2_bzBuffToBuffDecompress to - indicate that the output data will not fit into the output - buffer provided.

-
-
-
-
-

-3.3. Low-level interface

-
-
-
-
-

-3.3.1. BZ2_bzCompressInit

-
-
-
typedef struct {
-  char *next_in;
-  unsigned int avail_in;
-  unsigned int total_in_lo32;
-  unsigned int total_in_hi32;
-
-  char *next_out;
-  unsigned int avail_out;
-  unsigned int total_out_lo32;
-  unsigned int total_out_hi32;
-
-  void *state;
-
-  void *(*bzalloc)(void *,int,int);
-  void (*bzfree)(void *,void *);
-  void *opaque;
-} bz_stream;
-
-int BZ2_bzCompressInit ( bz_stream *strm, 
-                         int blockSize100k, 
-                         int verbosity,
-                         int workFactor );
-

Prepares for compression. The -bz_stream structure holds all -data pertaining to the compression activity. A -bz_stream structure should be -allocated and initialised prior to the call. The fields of -bz_stream comprise the entirety -of the user-visible data. state -is a pointer to the private data structures required for -compression.

-

Custom memory allocators are supported, via fields -bzalloc, -bzfree, and -opaque. The value -opaque is passed to as the first -argument to all calls to bzalloc -and bzfree, but is otherwise -ignored by the library. The call bzalloc ( -opaque, n, m ) is expected to return a pointer -p to n * -m bytes of memory, and bzfree ( -opaque, p ) should free that memory.

-

If you don't want to use a custom memory allocator, set -bzalloc, -bzfree and -opaque to -NULL, and the library will then -use the standard malloc / -free routines.

-

Before calling -BZ2_bzCompressInit, fields -bzalloc, -bzfree and -opaque should be filled -appropriately, as just described. Upon return, the internal -state will have been allocated and initialised, and -total_in_lo32, -total_in_hi32, -total_out_lo32 and -total_out_hi32 will have been -set to zero. These four fields are used by the library to inform -the caller of the total amount of data passed into and out of the -library, respectively. You should not try to change them. As of -version 1.0, 64-bit counts are maintained, even on 32-bit -platforms, using the _hi32 -fields to store the upper 32 bits of the count. So, for example, -the total amount of data in is (total_in_hi32 -<< 32) + total_in_lo32.

-

Parameter blockSize100k -specifies the block size to be used for compression. It should -be a value between 1 and 9 inclusive, and the actual block size -used is 100000 x this figure. 9 gives the best compression but -takes most memory.

-

Parameter verbosity should -be set to a number between 0 and 4 inclusive. 0 is silent, and -greater numbers give increasingly verbose monitoring/debugging -output. If the library has been compiled with --DBZ_NO_STDIO, no such output -will appear for any verbosity setting.

-

Parameter workFactor -controls how the compression phase behaves when presented with -worst case, highly repetitive, input data. If compression runs -into difficulties caused by repetitive data, the library switches -from the standard sorting algorithm to a fallback algorithm. The -fallback is slower than the standard algorithm by perhaps a -factor of three, but always behaves reasonably, no matter how bad -the input.

-

Lower values of workFactor -reduce the amount of effort the standard algorithm will expend -before resorting to the fallback. You should set this parameter -carefully; too low, and many inputs will be handled by the -fallback algorithm and so compress rather slowly, too high, and -your average-to-worst case compression times can become very -large. The default value of 30 gives reasonable behaviour over a -wide range of circumstances.

-

Allowable values range from 0 to 250 inclusive. 0 is a -special case, equivalent to using the default value of 30.

-

Note that the compressed output generated is the same -regardless of whether or not the fallback algorithm is -used.

-

Be aware also that this parameter may disappear entirely in -future versions of the library. In principle it should be -possible to devise a good way to automatically choose which -algorithm to use. Such a mechanism would render the parameter -obsolete.

-

Possible return values:

-
BZ_CONFIG_ERROR
-  if the library has been mis-compiled
-BZ_PARAM_ERROR
-  if strm is NULL 
-  or blockSize < 1 or blockSize > 9
-  or verbosity < 0 or verbosity > 4
-  or workFactor < 0 or workFactor > 250
-BZ_MEM_ERROR 
-  if not enough memory is available
-BZ_OK 
-  otherwise
-

Allowable next actions:

-
BZ2_bzCompress
-  if BZ_OK is returned
-  no specific action needed in case of error
-
-
-
-

-3.3.2. BZ2_bzCompress

-
-
-
int BZ2_bzCompress ( bz_stream *strm, int action );
-

Provides more input and/or output buffer space for the -library. The caller maintains input and output buffers, and -calls BZ2_bzCompress to transfer -data between them.

-

Before each call to -BZ2_bzCompress, -next_in should point at the data -to be compressed, and avail_in -should indicate how many bytes the library may read. -BZ2_bzCompress updates -next_in, -avail_in and -total_in to reflect the number -of bytes it has read.

-

Similarly, next_out should -point to a buffer in which the compressed data is to be placed, -with avail_out indicating how -much output space is available. -BZ2_bzCompress updates -next_out, -avail_out and -total_out to reflect the number -of bytes output.

-

You may provide and remove as little or as much data as you -like on each call of -BZ2_bzCompress. In the limit, -it is acceptable to supply and remove data one byte at a time, -although this would be terribly inefficient. You should always -ensure that at least one byte of output space is available at -each call.

-

A second purpose of -BZ2_bzCompress is to request a -change of mode of the compressed stream.

-

Conceptually, a compressed stream can be in one of four -states: IDLE, RUNNING, FLUSHING and FINISHING. Before -initialisation -(BZ2_bzCompressInit) and after -termination (BZ2_bzCompressEnd), -a stream is regarded as IDLE.

-

Upon initialisation -(BZ2_bzCompressInit), the stream -is placed in the RUNNING state. Subsequent calls to -BZ2_bzCompress should pass -BZ_RUN as the requested action; -other actions are illegal and will result in -BZ_SEQUENCE_ERROR.

-

At some point, the calling program will have provided all -the input data it wants to. It will then want to finish up -- in -effect, asking the library to process any data it might have -buffered internally. In this state, -BZ2_bzCompress will no longer -attempt to read data from -next_in, but it will want to -write data to next_out. Because -the output buffer supplied by the user can be arbitrarily small, -the finishing-up operation cannot necessarily be done with a -single call of -BZ2_bzCompress.

-

Instead, the calling program passes -BZ_FINISH as an action to -BZ2_bzCompress. This changes -the stream's state to FINISHING. Any remaining input (ie, -next_in[0 .. avail_in-1]) is -compressed and transferred to the output buffer. To do this, -BZ2_bzCompress must be called -repeatedly until all the output has been consumed. At that -point, BZ2_bzCompress returns -BZ_STREAM_END, and the stream's -state is set back to IDLE. -BZ2_bzCompressEnd should then be -called.

-

Just to make sure the calling program does not cheat, the -library makes a note of avail_in -at the time of the first call to -BZ2_bzCompress which has -BZ_FINISH as an action (ie, at -the time the program has announced its intention to not supply -any more input). By comparing this value with that of -avail_in over subsequent calls -to BZ2_bzCompress, the library -can detect any attempts to slip in more data to compress. Any -calls for which this is detected will return -BZ_SEQUENCE_ERROR. This -indicates a programming mistake which should be corrected.

-

Instead of asking to finish, the calling program may ask -BZ2_bzCompress to take all the -remaining input, compress it and terminate the current -(Burrows-Wheeler) compression block. This could be useful for -error control purposes. The mechanism is analogous to that for -finishing: call BZ2_bzCompress -with an action of BZ_FLUSH, -remove output data, and persist with the -BZ_FLUSH action until the value -BZ_RUN is returned. As with -finishing, BZ2_bzCompress -detects any attempt to provide more input data once the flush has -begun.

-

Once the flush is complete, the stream returns to the -normal RUNNING state.

-

This all sounds pretty complex, but isn't really. Here's a -table which shows which actions are allowable in each state, what -action will be taken, what the next state is, and what the -non-error return values are. Note that you can't explicitly ask -what state the stream is in, but nor do you need to -- it can be -inferred from the values returned by -BZ2_bzCompress.

-
IDLE/any
-  Illegal.  IDLE state only exists after BZ2_bzCompressEnd or
-  before BZ2_bzCompressInit.
-  Return value = BZ_SEQUENCE_ERROR
-
-RUNNING/BZ_RUN
-  Compress from next_in to next_out as much as possible.
-  Next state = RUNNING
-  Return value = BZ_RUN_OK
-
-RUNNING/BZ_FLUSH
-  Remember current value of next_in. Compress from next_in
-  to next_out as much as possible, but do not accept any more input.
-  Next state = FLUSHING
-  Return value = BZ_FLUSH_OK
-
-RUNNING/BZ_FINISH
-  Remember current value of next_in. Compress from next_in
-  to next_out as much as possible, but do not accept any more input.
-  Next state = FINISHING
-  Return value = BZ_FINISH_OK
-
-FLUSHING/BZ_FLUSH
-  Compress from next_in to next_out as much as possible, 
-  but do not accept any more input.
-  If all the existing input has been used up and all compressed
-  output has been removed
-    Next state = RUNNING; Return value = BZ_RUN_OK
-  else
-    Next state = FLUSHING; Return value = BZ_FLUSH_OK
-
-FLUSHING/other     
-  Illegal.
-  Return value = BZ_SEQUENCE_ERROR
-
-FINISHING/BZ_FINISH
-  Compress from next_in to next_out as much as possible,
-  but to not accept any more input.  
-  If all the existing input has been used up and all compressed
-  output has been removed
-    Next state = IDLE; Return value = BZ_STREAM_END
-  else
-    Next state = FINISHING; Return value = BZ_FINISHING
-
-FINISHING/other
-  Illegal.
-  Return value = BZ_SEQUENCE_ERROR
-

That still looks complicated? Well, fair enough. The -usual sequence of calls for compressing a load of data is:

-
    -
  1. Get started with - BZ2_bzCompressInit.

  2. -
  3. Shovel data in and shlurp out its compressed form - using zero or more calls of - BZ2_bzCompress with action = - BZ_RUN.

  4. -
  5. Finish up. Repeatedly call - BZ2_bzCompress with action = - BZ_FINISH, copying out the - compressed output, until - BZ_STREAM_END is - returned.

  6. -
  7. Close up and go home. Call - BZ2_bzCompressEnd.

  8. -
-

If the data you want to compress fits into your input -buffer all at once, you can skip the calls of -BZ2_bzCompress ( ..., BZ_RUN ) -and just do the BZ2_bzCompress ( ..., BZ_FINISH -) calls.

-

All required memory is allocated by -BZ2_bzCompressInit. The -compression library can accept any data at all (obviously). So -you shouldn't get any error return values from the -BZ2_bzCompress calls. If you -do, they will be -BZ_SEQUENCE_ERROR, and indicate -a bug in your programming.

-

Trivial other possible return values:

-
BZ_PARAM_ERROR
-  if strm is NULL, or strm->s is NULL
-
-
-
-

-3.3.3. BZ2_bzCompressEnd

-
-
-
int BZ2_bzCompressEnd ( bz_stream *strm );
-

Releases all memory associated with a compression -stream.

-

Possible return values:

-
BZ_PARAM_ERROR  if strm is NULL or strm->s is NULL
-BZ_OK           otherwise
-
-
-
-

-3.3.4. BZ2_bzDecompressInit

-
-
-
int BZ2_bzDecompressInit ( bz_stream *strm, int verbosity, int small );
-

Prepares for decompression. As with -BZ2_bzCompressInit, a -bz_stream record should be -allocated and initialised before the call. Fields -bzalloc, -bzfree and -opaque should be set if a custom -memory allocator is required, or made -NULL for the normal -malloc / -free routines. Upon return, the -internal state will have been initialised, and -total_in and -total_out will be zero.

-

For the meaning of parameter -verbosity, see -BZ2_bzCompressInit.

-

If small is nonzero, the -library will use an alternative decompression algorithm which -uses less memory but at the cost of decompressing more slowly -(roughly speaking, half the speed, but the maximum memory -requirement drops to around 2300k). See How to use bzip2 -for more information on memory management.

-

Note that the amount of memory needed to decompress a -stream cannot be determined until the stream's header has been -read, so even if -BZ2_bzDecompressInit succeeds, a -subsequent BZ2_bzDecompress -could fail with -BZ_MEM_ERROR.

-

Possible return values:

-
BZ_CONFIG_ERROR
-  if the library has been mis-compiled
-BZ_PARAM_ERROR
-  if ( small != 0 && small != 1 )
-  or (verbosity <; 0 || verbosity > 4)
-BZ_MEM_ERROR
-  if insufficient memory is available
-

Allowable next actions:

-
BZ2_bzDecompress
-  if BZ_OK was returned
-  no specific action required in case of error
-
-
-
-

-3.3.5. BZ2_bzDecompress

-
-
-
int BZ2_bzDecompress ( bz_stream *strm );
-

Provides more input and/out output buffer space for the -library. The caller maintains input and output buffers, and uses -BZ2_bzDecompress to transfer -data between them.

-

Before each call to -BZ2_bzDecompress, -next_in should point at the -compressed data, and avail_in -should indicate how many bytes the library may read. -BZ2_bzDecompress updates -next_in, -avail_in and -total_in to reflect the number -of bytes it has read.

-

Similarly, next_out should -point to a buffer in which the uncompressed output is to be -placed, with avail_out -indicating how much output space is available. -BZ2_bzCompress updates -next_out, -avail_out and -total_out to reflect the number -of bytes output.

-

You may provide and remove as little or as much data as you -like on each call of -BZ2_bzDecompress. In the limit, -it is acceptable to supply and remove data one byte at a time, -although this would be terribly inefficient. You should always -ensure that at least one byte of output space is available at -each call.

-

Use of BZ2_bzDecompress is -simpler than -BZ2_bzCompress.

-

You should provide input and remove output as described -above, and repeatedly call -BZ2_bzDecompress until -BZ_STREAM_END is returned. -Appearance of BZ_STREAM_END -denotes that BZ2_bzDecompress -has detected the logical end of the compressed stream. -BZ2_bzDecompress will not -produce BZ_STREAM_END until all -output data has been placed into the output buffer, so once -BZ_STREAM_END appears, you are -guaranteed to have available all the decompressed output, and -BZ2_bzDecompressEnd can safely -be called.

-

If case of an error return value, you should call -BZ2_bzDecompressEnd to clean up -and release memory.

-

Possible return values:

-
BZ_PARAM_ERROR
-  if strm is NULL or strm->s is NULL
-  or strm->avail_out < 1
-BZ_DATA_ERROR
-  if a data integrity error is detected in the compressed stream
-BZ_DATA_ERROR_MAGIC
-  if the compressed stream doesn't begin with the right magic bytes
-BZ_MEM_ERROR
-  if there wasn't enough memory available
-BZ_STREAM_END
-  if the logical end of the data stream was detected and all
-  output in has been consumed, eg s-->avail_out > 0
-BZ_OK
-  otherwise
-

Allowable next actions:

-
BZ2_bzDecompress
-  if BZ_OK was returned
-BZ2_bzDecompressEnd
-  otherwise
-
-
-
-

-3.3.6. BZ2_bzDecompressEnd

-
-
-
int BZ2_bzDecompressEnd ( bz_stream *strm );
-

Releases all memory associated with a decompression -stream.

-

Possible return values:

-
BZ_PARAM_ERROR
-  if strm is NULL or strm->s is NULL
-BZ_OK
-  otherwise
-

Allowable next actions:

-
  None.
-
-
-
-
-

-3.4. High-level interface

-
-
-

This interface provides functions for reading and writing -bzip2 format files. First, some -general points.

-
    -
  • All of the functions take an - int* first argument, - bzerror. After each call, - bzerror should be consulted - first to determine the outcome of the call. If - bzerror is - BZ_OK, the call completed - successfully, and only then should the return value of the - function (if any) be consulted. If - bzerror is - BZ_IO_ERROR, there was an - error reading/writing the underlying compressed file, and you - should then consult errno / - perror to determine the cause - of the difficulty. bzerror - may also be set to various other values; precise details are - given on a per-function basis below.

  • -
  • If bzerror indicates - an error (ie, anything except - BZ_OK and - BZ_STREAM_END), you should - immediately call - BZ2_bzReadClose (or - BZ2_bzWriteClose, depending on - whether you are attempting to read or to write) to free up all - resources associated with the stream. Once an error has been - indicated, behaviour of all calls except - BZ2_bzReadClose - (BZ2_bzWriteClose) is - undefined. The implication is that (1) - bzerror should be checked - after each call, and (2) if - bzerror indicates an error, - BZ2_bzReadClose - (BZ2_bzWriteClose) should then - be called to clean up.

  • -
  • The FILE* arguments - passed to BZ2_bzReadOpen / - BZ2_bzWriteOpen should be set - to binary mode. Most Unix systems will do this by default, but - other platforms, including Windows and Mac, will not. If you - omit this, you may encounter problems when moving code to new - platforms.

  • -
  • Memory allocation requests are handled by - malloc / - free. At present there is no - facility for user-defined memory allocators in the file I/O - functions (could easily be added, though).

  • -
-
-
-

-3.4.1. BZ2_bzReadOpen

-
-
-
typedef void BZFILE;
-
-BZFILE *BZ2_bzReadOpen( int *bzerror, FILE *f, 
-                        int verbosity, int small,
-                        void *unused, int nUnused );
-

Prepare to read compressed data from file handle -f. -f should refer to a file which -has been opened for reading, and for which the error indicator -(ferror(f))is not set. If -small is 1, the library will try -to decompress using less memory, at the expense of speed.

-

For reasons explained below, -BZ2_bzRead will decompress the -nUnused bytes starting at -unused, before starting to read -from the file f. At most -BZ_MAX_UNUSED bytes may be -supplied like this. If this facility is not required, you should -pass NULL and -0 for -unused and -nUnused respectively.

-

For the meaning of parameters -small and -verbosity, see -BZ2_bzDecompressInit.

-

The amount of memory needed to decompress a file cannot be -determined until the file's header has been read. So it is -possible that BZ2_bzReadOpen -returns BZ_OK but a subsequent -call of BZ2_bzRead will return -BZ_MEM_ERROR.

-

Possible assignments to -bzerror:

-
BZ_CONFIG_ERROR
-  if the library has been mis-compiled
-BZ_PARAM_ERROR
-  if f is NULL
-  or small is neither 0 nor 1
-  or ( unused == NULL && nUnused != 0 )
-  or ( unused != NULL && !(0 <= nUnused <= BZ_MAX_UNUSED) )
-BZ_IO_ERROR
-  if ferror(f) is nonzero
-BZ_MEM_ERROR
-  if insufficient memory is available
-BZ_OK
-  otherwise.
-

Possible return values:

-
Pointer to an abstract BZFILE
-  if bzerror is BZ_OK
-NULL
-  otherwise
-

Allowable next actions:

-
BZ2_bzRead
-  if bzerror is BZ_OK
-BZ2_bzClose
-  otherwise
-
-
-
-

-3.4.2. BZ2_bzRead

-
-
-
int BZ2_bzRead ( int *bzerror, BZFILE *b, void *buf, int len );
-

Reads up to len -(uncompressed) bytes from the compressed file -b into the buffer -buf. If the read was -successful, bzerror is set to -BZ_OK and the number of bytes -read is returned. If the logical end-of-stream was detected, -bzerror will be set to -BZ_STREAM_END, and the number of -bytes read is returned. All other -bzerror values denote an -error.

-

BZ2_bzRead will supply -len bytes, unless the logical -stream end is detected or an error occurs. Because of this, it -is possible to detect the stream end by observing when the number -of bytes returned is less than the number requested. -Nevertheless, this is regarded as inadvisable; you should instead -check bzerror after every call -and watch out for -BZ_STREAM_END.

-

Internally, BZ2_bzRead -copies data from the compressed file in chunks of size -BZ_MAX_UNUSED bytes before -decompressing it. If the file contains more bytes than strictly -needed to reach the logical end-of-stream, -BZ2_bzRead will almost certainly -read some of the trailing data before signalling -BZ_SEQUENCE_END. To collect the -read but unused data once -BZ_SEQUENCE_END has appeared, -call BZ2_bzReadGetUnused -immediately before -BZ2_bzReadClose.

-

Possible assignments to -bzerror:

-
BZ_PARAM_ERROR
-  if b is NULL or buf is NULL or len < 0
-BZ_SEQUENCE_ERROR
-  if b was opened with BZ2_bzWriteOpen
-BZ_IO_ERROR
-  if there is an error reading from the compressed file
-BZ_UNEXPECTED_EOF
-  if the compressed file ended before 
-  the logical end-of-stream was detected
-BZ_DATA_ERROR
-  if a data integrity error was detected in the compressed stream
-BZ_DATA_ERROR_MAGIC
-  if the stream does not begin with the requisite header bytes 
-  (ie, is not a bzip2 data file).  This is really 
-  a special case of BZ_DATA_ERROR.
-BZ_MEM_ERROR
-  if insufficient memory was available
-BZ_STREAM_END
-  if the logical end of stream was detected.
-BZ_OK
-  otherwise.
-

Possible return values:

-
number of bytes read
-  if bzerror is BZ_OK or BZ_STREAM_END
-undefined
-  otherwise
-

Allowable next actions:

-
collect data from buf, then BZ2_bzRead or BZ2_bzReadClose
-  if bzerror is BZ_OK
-collect data from buf, then BZ2_bzReadClose or BZ2_bzReadGetUnused
-  if bzerror is BZ_SEQUENCE_END
-BZ2_bzReadClose
-  otherwise
-
-
-
-

-3.4.3. BZ2_bzReadGetUnused

-
-
-
void BZ2_bzReadGetUnused( int* bzerror, BZFILE *b, 
-                          void** unused, int* nUnused );
-

Returns data which was read from the compressed file but -was not needed to get to the logical end-of-stream. -*unused is set to the address of -the data, and *nUnused to the -number of bytes. *nUnused will -be set to a value between 0 and -BZ_MAX_UNUSED inclusive.

-

This function may only be called once -BZ2_bzRead has signalled -BZ_STREAM_END but before -BZ2_bzReadClose.

-

Possible assignments to -bzerror:

-
BZ_PARAM_ERROR
-  if b is NULL
-  or unused is NULL or nUnused is NULL
-BZ_SEQUENCE_ERROR
-  if BZ_STREAM_END has not been signalled
-  or if b was opened with BZ2_bzWriteOpen
-BZ_OK
-  otherwise
-

Allowable next actions:

-
BZ2_bzReadClose
-
-
-
-

-3.4.4. BZ2_bzReadClose

-
-
-
void BZ2_bzReadClose ( int *bzerror, BZFILE *b );
-

Releases all memory pertaining to the compressed file -b. -BZ2_bzReadClose does not call -fclose on the underlying file -handle, so you should do that yourself if appropriate. -BZ2_bzReadClose should be called -to clean up after all error situations.

-

Possible assignments to -bzerror:

-
BZ_SEQUENCE_ERROR
-  if b was opened with BZ2_bzOpenWrite
-BZ_OK
-  otherwise
-

Allowable next actions:

-
none
-
-
-
-

-3.4.5. BZ2_bzWriteOpen

-
-
-
BZFILE *BZ2_bzWriteOpen( int *bzerror, FILE *f, 
-                         int blockSize100k, int verbosity,
-                         int workFactor );
-

Prepare to write compressed data to file handle -f. -f should refer to a file which -has been opened for writing, and for which the error indicator -(ferror(f))is not set.

-

For the meaning of parameters -blockSize100k, -verbosity and -workFactor, see -BZ2_bzCompressInit.

-

All required memory is allocated at this stage, so if the -call completes successfully, -BZ_MEM_ERROR cannot be signalled -by a subsequent call to -BZ2_bzWrite.

-

Possible assignments to -bzerror:

-
BZ_CONFIG_ERROR
-  if the library has been mis-compiled
-BZ_PARAM_ERROR
-  if f is NULL
-  or blockSize100k < 1 or blockSize100k > 9
-BZ_IO_ERROR
-  if ferror(f) is nonzero
-BZ_MEM_ERROR
-  if insufficient memory is available
-BZ_OK
-  otherwise
-

Possible return values:

-
Pointer to an abstract BZFILE
-  if bzerror is BZ_OK
-NULL
-  otherwise
-

Allowable next actions:

-
BZ2_bzWrite
-  if bzerror is BZ_OK
-  (you could go directly to BZ2_bzWriteClose, but this would be pretty pointless)
-BZ2_bzWriteClose
-  otherwise
-
-
-
-

-3.4.6. BZ2_bzWrite

-
-
-
void BZ2_bzWrite ( int *bzerror, BZFILE *b, void *buf, int len );
-

Absorbs len bytes from the -buffer buf, eventually to be -compressed and written to the file.

-

Possible assignments to -bzerror:

-
BZ_PARAM_ERROR
-  if b is NULL or buf is NULL or len < 0
-BZ_SEQUENCE_ERROR
-  if b was opened with BZ2_bzReadOpen
-BZ_IO_ERROR
-  if there is an error writing the compressed file.
-BZ_OK
-  otherwise
-
-
-
-

-3.4.7. BZ2_bzWriteClose

-
-
-
void BZ2_bzWriteClose( int *bzerror, BZFILE* f,
-                       int abandon,
-                       unsigned int* nbytes_in,
-                       unsigned int* nbytes_out );
-
-void BZ2_bzWriteClose64( int *bzerror, BZFILE* f,
-                         int abandon,
-                         unsigned int* nbytes_in_lo32,
-                         unsigned int* nbytes_in_hi32,
-                         unsigned int* nbytes_out_lo32,
-                         unsigned int* nbytes_out_hi32 );
-

Compresses and flushes to the compressed file all data so -far supplied by BZ2_bzWrite. -The logical end-of-stream markers are also written, so subsequent -calls to BZ2_bzWrite are -illegal. All memory associated with the compressed file -b is released. -fflush is called on the -compressed file, but it is not -fclose'd.

-

If BZ2_bzWriteClose is -called to clean up after an error, the only action is to release -the memory. The library records the error codes issued by -previous calls, so this situation will be detected automatically. -There is no attempt to complete the compression operation, nor to -fflush the compressed file. You -can force this behaviour to happen even in the case of no error, -by passing a nonzero value to -abandon.

-

If nbytes_in is non-null, -*nbytes_in will be set to be the -total volume of uncompressed data handled. Similarly, -nbytes_out will be set to the -total volume of compressed data written. For compatibility with -older versions of the library, -BZ2_bzWriteClose only yields the -lower 32 bits of these counts. Use -BZ2_bzWriteClose64 if you want -the full 64 bit counts. These two functions are otherwise -absolutely identical.

-

Possible assignments to -bzerror:

-
BZ_SEQUENCE_ERROR
-  if b was opened with BZ2_bzReadOpen
-BZ_IO_ERROR
-  if there is an error writing the compressed file
-BZ_OK
-  otherwise
-
-
-
-

-3.4.8. Handling embedded compressed data streams

-
-
-

The high-level library facilitates use of -bzip2 data streams which form -some part of a surrounding, larger data stream.

-
    -
  • For writing, the library takes an open file handle, - writes compressed data to it, - fflushes it but does not - fclose it. The calling - application can write its own data before and after the - compressed data stream, using that same file handle.

  • -
  • Reading is more complex, and the facilities are not as - general as they could be since generality is hard to reconcile - with efficiency. BZ2_bzRead - reads from the compressed file in blocks of size - BZ_MAX_UNUSED bytes, and in - doing so probably will overshoot the logical end of compressed - stream. To recover this data once decompression has ended, - call BZ2_bzReadGetUnused after - the last call of BZ2_bzRead - (the one returning - BZ_STREAM_END) but before - calling - BZ2_bzReadClose.

  • -
-

This mechanism makes it easy to decompress multiple -bzip2 streams placed end-to-end. -As the end of one stream, when -BZ2_bzRead returns -BZ_STREAM_END, call -BZ2_bzReadGetUnused to collect -the unused data (copy it into your own buffer somewhere). That -data forms the start of the next compressed stream. To start -uncompressing that next stream, call -BZ2_bzReadOpen again, feeding in -the unused data via the unused / -nUnused parameters. Keep doing -this until BZ_STREAM_END return -coincides with the physical end of file -(feof(f)). In this situation -BZ2_bzReadGetUnused will of -course return no data.

-

This should give some feel for how the high-level interface -can be used. If you require extra flexibility, you'll have to -bite the bullet and get to grips with the low-level -interface.

-
-
-
-

-3.4.9. Standard file-reading/writing code

-
-
-

Here's how you'd write data to a compressed file:

-
FILE*   f;
-BZFILE* b;
-int     nBuf;
-char    buf[ /* whatever size you like */ ];
-int     bzerror;
-int     nWritten;
-
-f = fopen ( "myfile.bz2", "w" );
-if ( !f ) {
- /* handle error */
-}
-b = BZ2_bzWriteOpen( &bzerror, f, 9 );
-if (bzerror != BZ_OK) {
- BZ2_bzWriteClose ( b );
- /* handle error */
-}
-
-while ( /* condition */ ) {
- /* get data to write into buf, and set nBuf appropriately */
- nWritten = BZ2_bzWrite ( &bzerror, b, buf, nBuf );
- if (bzerror == BZ_IO_ERROR) { 
-   BZ2_bzWriteClose ( &bzerror, b );
-   /* handle error */
- }
-}
-
-BZ2_bzWriteClose( &bzerror, b );
-if (bzerror == BZ_IO_ERROR) {
- /* handle error */
-}
-

And to read from a compressed file:

-
FILE*   f;
-BZFILE* b;
-int     nBuf;
-char    buf[ /* whatever size you like */ ];
-int     bzerror;
-int     nWritten;
-
-f = fopen ( "myfile.bz2", "r" );
-if ( !f ) {
-  /* handle error */
-}
-b = BZ2_bzReadOpen ( &bzerror, f, 0, NULL, 0 );
-if ( bzerror != BZ_OK ) {
-  BZ2_bzReadClose ( &bzerror, b );
-  /* handle error */
-}
-
-bzerror = BZ_OK;
-while ( bzerror == BZ_OK && /* arbitrary other conditions */) {
-  nBuf = BZ2_bzRead ( &bzerror, b, buf, /* size of buf */ );
-  if ( bzerror == BZ_OK ) {
-    /* do something with buf[0 .. nBuf-1] */
-  }
-}
-if ( bzerror != BZ_STREAM_END ) {
-   BZ2_bzReadClose ( &bzerror, b );
-   /* handle error */
-} else {
-   BZ2_bzReadClose ( &bzerror );
-}
-
-
-
-
-

-3.5. Utility functions

-
-
-
-
-

-3.5.1. BZ2_bzBuffToBuffCompress

-
-
-
int BZ2_bzBuffToBuffCompress( char*         dest,
-                              unsigned int* destLen,
-                              char*         source,
-                              unsigned int  sourceLen,
-                              int           blockSize100k,
-                              int           verbosity,
-                              int           workFactor );
-

Attempts to compress the data in source[0 -.. sourceLen-1] into the destination buffer, -dest[0 .. *destLen-1]. If the -destination buffer is big enough, -*destLen is set to the size of -the compressed data, and BZ_OK -is returned. If the compressed data won't fit, -*destLen is unchanged, and -BZ_OUTBUFF_FULL is -returned.

-

Compression in this manner is a one-shot event, done with a -single call to this function. The resulting compressed data is a -complete bzip2 format data -stream. There is no mechanism for making additional calls to -provide extra input data. If you want that kind of mechanism, -use the low-level interface.

-

For the meaning of parameters -blockSize100k, -verbosity and -workFactor, see -BZ2_bzCompressInit.

-

To guarantee that the compressed data will fit in its -buffer, allocate an output buffer of size 1% larger than the -uncompressed data, plus six hundred extra bytes.

-

BZ2_bzBuffToBuffDecompress -will not write data at or beyond -dest[*destLen], even in case of -buffer overflow.

-

Possible return values:

-
BZ_CONFIG_ERROR
-  if the library has been mis-compiled
-BZ_PARAM_ERROR
-  if dest is NULL or destLen is NULL
-  or blockSize100k < 1 or blockSize100k > 9
-  or verbosity < 0 or verbosity > 4
-  or workFactor < 0 or workFactor > 250
-BZ_MEM_ERROR
-  if insufficient memory is available 
-BZ_OUTBUFF_FULL
-  if the size of the compressed data exceeds *destLen
-BZ_OK
-  otherwise
-
-
-
-

-3.5.2. BZ2_bzBuffToBuffDecompress

-
-
-
int BZ2_bzBuffToBuffDecompress( char*         dest,
-                                unsigned int* destLen,
-                                char*         source,
-                                unsigned int  sourceLen,
-                                int           small,
-                                int           verbosity );
-

Attempts to decompress the data in source[0 -.. sourceLen-1] into the destination buffer, -dest[0 .. *destLen-1]. If the -destination buffer is big enough, -*destLen is set to the size of -the uncompressed data, and BZ_OK -is returned. If the compressed data won't fit, -*destLen is unchanged, and -BZ_OUTBUFF_FULL is -returned.

-

source is assumed to hold -a complete bzip2 format data -stream. -BZ2_bzBuffToBuffDecompress tries -to decompress the entirety of the stream into the output -buffer.

-

For the meaning of parameters -small and -verbosity, see -BZ2_bzDecompressInit.

-

Because the compression ratio of the compressed data cannot -be known in advance, there is no easy way to guarantee that the -output buffer will be big enough. You may of course make -arrangements in your code to record the size of the uncompressed -data, but such a mechanism is beyond the scope of this -library.

-

BZ2_bzBuffToBuffDecompress -will not write data at or beyond -dest[*destLen], even in case of -buffer overflow.

-

Possible return values:

-
BZ_CONFIG_ERROR
-  if the library has been mis-compiled
-BZ_PARAM_ERROR
-  if dest is NULL or destLen is NULL
-  or small != 0 && small != 1
-  or verbosity < 0 or verbosity > 4
-BZ_MEM_ERROR
-  if insufficient memory is available 
-BZ_OUTBUFF_FULL
-  if the size of the compressed data exceeds *destLen
-BZ_DATA_ERROR
-  if a data integrity error was detected in the compressed data
-BZ_DATA_ERROR_MAGIC
-  if the compressed data doesn't begin with the right magic bytes
-BZ_UNEXPECTED_EOF
-  if the compressed data ends unexpectedly
-BZ_OK
-  otherwise
-
-
-
-
-

-3.6. zlib compatibility functions

-
-
-

Yoshioka Tsuneo has contributed some functions to give -better zlib compatibility. -These functions are BZ2_bzopen, -BZ2_bzread, -BZ2_bzwrite, -BZ2_bzflush, -BZ2_bzclose, -BZ2_bzerror and -BZ2_bzlibVersion. These -functions are not (yet) officially part of the library. If they -break, you get to keep all the pieces. Nevertheless, I think -they work ok.

-
typedef void BZFILE;
-
-const char * BZ2_bzlibVersion ( void );
-

Returns a string indicating the library version.

-
BZFILE * BZ2_bzopen  ( const char *path, const char *mode );
-BZFILE * BZ2_bzdopen ( int        fd,    const char *mode );
-

Opens a .bz2 file for -reading or writing, using either its name or a pre-existing file -descriptor. Analogous to fopen -and fdopen.

-
int BZ2_bzread  ( BZFILE* b, void* buf, int len );
-int BZ2_bzwrite ( BZFILE* b, void* buf, int len );
-

Reads/writes data from/to a previously opened -BZFILE. Analogous to -fread and -fwrite.

-
int  BZ2_bzflush ( BZFILE* b );
-void BZ2_bzclose ( BZFILE* b );
-

Flushes/closes a BZFILE. -BZ2_bzflush doesn't actually do -anything. Analogous to fflush -and fclose.

-
const char * BZ2_bzerror ( BZFILE *b, int *errnum )
-

Returns a string describing the more recent error status of -b, and also sets -*errnum to its numerical -value.

-
-
-
-

-3.7. Using the library in a stdio-free environment

-
-
-
-
-

-3.7.1. Getting rid of stdio

-
-
-

In a deeply embedded application, you might want to use -just the memory-to-memory functions. You can do this -conveniently by compiling the library with preprocessor symbol -BZ_NO_STDIO defined. Doing this -gives you a library containing only the following eight -functions:

-

BZ2_bzCompressInit, -BZ2_bzCompress, -BZ2_bzCompressEnd -BZ2_bzDecompressInit, -BZ2_bzDecompress, -BZ2_bzDecompressEnd -BZ2_bzBuffToBuffCompress, -BZ2_bzBuffToBuffDecompress

-

When compiled like this, all functions will ignore -verbosity settings.

-
-
-
-

-3.7.2. Critical error handling

-
-
-

libbzip2 contains a number -of internal assertion checks which should, needless to say, never -be activated. Nevertheless, if an assertion should fail, -behaviour depends on whether or not the library was compiled with -BZ_NO_STDIO set.

-

For a normal compile, an assertion failure yields the -message:

-
-

bzip2/libbzip2: internal error number N.

-

This is a bug in bzip2/libbzip2, 1.0.3 of 15 February 2005. -Please report it to me at: jseward@bzip.org. If this happened -when you were using some program which uses libbzip2 as a -component, you should also report this bug to the author(s) -of that program. Please make an effort to report this bug; -timely and accurate bug reports eventually lead to higher -quality software. Thanks. Julian Seward, 15 February 2005. -

-
-

where N is some error code -number. If N == 1007, it also -prints some extra text advising the reader that unreliable memory -is often associated with internal error 1007. (This is a -frequently-observed-phenomenon with versions 1.0.0/1.0.1).

-

exit(3) is then -called.

-

For a stdio-free library, -assertion failures result in a call to a function declared -as:

-
extern void bz_internal_error ( int errcode );
-

The relevant code is passed as a parameter. You should -supply such a function.

-

In either case, once an assertion failure has occurred, any -bz_stream records involved can -be regarded as invalid. You should not attempt to resume normal -operation with them.

-

You may, of course, change critical error handling to suit -your needs. As I said above, critical errors indicate bugs in -the library and should not occur. All "normal" error situations -are indicated via error return codes from functions, and can be -recovered from.

-
-
-
-
-

-3.8. Making a Windows DLL

-
-
-

Everything related to Windows has been contributed by -Yoshioka Tsuneo -(QWF00133@niftyserve.or.jp / -tsuneo-y@is.aist-nara.ac.jp), so -you should send your queries to him (but perhaps Cc: me, -jseward@bzip.org).

-

My vague understanding of what to do is: using Visual C++ -5.0, open the project file -libbz2.dsp, and build. That's -all.

-

If you can't open the project file for some reason, make a -new one, naming these files: -blocksort.c, -bzlib.c, -compress.c, -crctable.c, -decompress.c, -huffman.c, -randtable.c and -libbz2.def. You will also need -to name the header files bzlib.h -and bzlib_private.h.

-

If you don't use VC++, you may need to define the -proprocessor symbol -_WIN32.

-

Finally, dlltest.c is a -sample program using the DLL. It has a project file, -dlltest.dsp.

-

If you just want a makefile for Visual C, have a look at -makefile.msc.

-

Be aware that if you compile -bzip2 itself on Win32, you must -set BZ_UNIX to 0 and -BZ_LCCWIN32 to 1, in the file -bzip2.c, before compiling. -Otherwise the resulting binary won't work correctly.

-

I haven't tried any of this stuff myself, but it all looks -plausible.

-
-
-
-
-

-4. Miscellanea

-
-
- -

These are just some random thoughts of mine. Your mileage -may vary.

-
-
-

-4.1. Limitations of the compressed file format

-
-
-

bzip2-1.0.X, -0.9.5 and -0.9.0 use exactly the same file -format as the original version, -bzip2-0.1. This decision was -made in the interests of stability. Creating yet another -incompatible compressed file format would create further -confusion and disruption for users.

-

Nevertheless, this is not a painless decision. Development -work since the release of -bzip2-0.1 in August 1997 has -shown complexities in the file format which slow down -decompression and, in retrospect, are unnecessary. These -are:

-
    -
  • The run-length encoder, which is the first of the - compression transformations, is entirely irrelevant. The - original purpose was to protect the sorting algorithm from the - very worst case input: a string of repeated symbols. But - algorithm steps Q6a and Q6b in the original Burrows-Wheeler - technical report (SRC-124) show how repeats can be handled - without difficulty in block sorting.

  • -
  • -

    The randomisation mechanism doesn't really need to be - there. Udi Manber and Gene Myers published a suffix array - construction algorithm a few years back, which can be employed - to sort any block, no matter how repetitive, in O(N log N) - time. Subsequent work by Kunihiko Sadakane has produced a - derivative O(N (log N)^2) algorithm which usually outperforms - the Manber-Myers algorithm.

    -

    I could have changed to Sadakane's algorithm, but I find - it to be slower than bzip2's - existing algorithm for most inputs, and the randomisation - mechanism protects adequately against bad cases. I didn't - think it was a good tradeoff to make. Partly this is due to - the fact that I was not flooded with email complaints about - bzip2-0.1's performance on - repetitive data, so perhaps it isn't a problem for real - inputs.

    -

    Probably the best long-term solution, and the one I have - incorporated into 0.9.5 and above, is to use the existing - sorting algorithm initially, and fall back to a O(N (log N)^2) - algorithm if the standard algorithm gets into - difficulties.

    -
  • -
  • The compressed file format was never designed to be - handled by a library, and I have had to jump though some hoops - to produce an efficient implementation of decompression. It's - a bit hairy. Try passing - decompress.c through the C - preprocessor and you'll see what I mean. Much of this - complexity could have been avoided if the compressed size of - each block of data was recorded in the data stream.

  • -
  • An Adler-32 checksum, rather than a CRC32 checksum, - would be faster to compute.

  • -
-

It would be fair to say that the -bzip2 format was frozen before I -properly and fully understood the performance consequences of -doing so.

-

Improvements which I was able to incorporate into 0.9.0, -despite using the same file format, are:

-
    -
  • Single array implementation of the inverse BWT. This - significantly speeds up decompression, presumably because it - reduces the number of cache misses.

  • -
  • Faster inverse MTF transform for large MTF values. - The new implementation is based on the notion of sliding blocks - of values.

  • -
  • bzip2-0.9.0 now reads - and writes files with fread - and fwrite; version 0.1 used - putc and - getc. Duh! Well, you live - and learn.

  • -
-

Further ahead, it would be nice to be able to do random -access into files. This will require some careful design of -compressed file formats.

-
-
-
-

-4.2. Portability issues

-
-
-

After some consideration, I have decided not to use GNU -autoconf to configure 0.9.5 or -1.0.

-

autoconf, admirable and -wonderful though it is, mainly assists with portability problems -between Unix-like platforms. But -bzip2 doesn't have much in the -way of portability problems on Unix; most of the difficulties -appear when porting to the Mac, or to Microsoft's operating -systems. autoconf doesn't help -in those cases, and brings in a whole load of new -complexity.

-

Most people should be able to compile the library and -program under Unix straight out-of-the-box, so to speak, -especially if you have a version of GNU C available.

-

There are a couple of -__inline__ directives in the -code. GNU C (gcc) should be -able to handle them. If you're not using GNU C, your C compiler -shouldn't see them at all. If your compiler does, for some -reason, see them and doesn't like them, just -#define -__inline__ to be -/* */. One easy way to do this -is to compile with the flag --D__inline__=, which should be -understood by most Unix compilers.

-

If you still have difficulties, try compiling with the -macro BZ_STRICT_ANSI defined. -This should enable you to build the library in a strictly ANSI -compliant environment. Building the program itself like this is -dangerous and not supported, since you remove -bzip2's checks against -compressing directories, symbolic links, devices, and other -not-really-a-file entities. This could cause filesystem -corruption!

-

One other thing: if you create a -bzip2 binary for public distribution, -please consider linking it statically (gcc --static). This avoids all sorts of library-version -issues that others may encounter later on.

-

If you build bzip2 on -Win32, you must set BZ_UNIX to 0 -and BZ_LCCWIN32 to 1, in the -file bzip2.c, before compiling. -Otherwise the resulting binary won't work correctly.

-
-
-
-

-4.3. Reporting bugs

-
-
-

I tried pretty hard to make sure -bzip2 is bug free, both by -design and by testing. Hopefully you'll never need to read this -section for real.

-

Nevertheless, if bzip2 dies -with a segmentation fault, a bus error or an internal assertion -failure, it will ask you to email me a bug report. Experience from -years of feedback of bzip2 users indicates that almost all these -problems can be traced to either compiler bugs or hardware -problems.

-
    -
  • -

    Recompile the program with no optimisation, and - see if it works. And/or try a different compiler. I heard all - sorts of stories about various flavours of GNU C (and other - compilers) generating bad code for - bzip2, and I've run across two - such examples myself.

    -

    2.7.X versions of GNU C are known to generate bad code - from time to time, at high optimisation levels. If you get - problems, try using the flags - -O2 - -fomit-frame-pointer - -fno-strength-reduce. You - should specifically not use - -funroll-loops.

    -

    You may notice that the Makefile runs six tests as part - of the build process. If the program passes all of these, it's - a pretty good (but not 100%) indication that the compiler has - done its job correctly.

    -
  • -
  • -

    If bzip2 - crashes randomly, and the crashes are not repeatable, you may - have a flaky memory subsystem. - bzip2 really hammers your - memory hierarchy, and if it's a bit marginal, you may get these - problems. Ditto if your disk or I/O subsystem is slowly - failing. Yup, this really does happen.

    -

    Try using a different machine of the same type, and see - if you can repeat the problem.

    -
  • -
  • This isn't really a bug, but ... If - bzip2 tells you your file is - corrupted on decompression, and you obtained the file via FTP, - there is a possibility that you forgot to tell FTP to do a - binary mode transfer. That absolutely will cause the file to - be non-decompressible. You'll have to transfer it - again.

  • -
-

If you've incorporated -libbzip2 into your own program -and are getting problems, please, please, please, check that the -parameters you are passing in calls to the library, are correct, -and in accordance with what the documentation says is allowable. -I have tried to make the library robust against such problems, -but I'm sure I haven't succeeded.

-

Finally, if the above comments don't help, you'll have to -send me a bug report. Now, it's just amazing how many people -will send me a bug report saying something like:

-
bzip2 crashed with segmentation fault on my machine
-

and absolutely nothing else. Needless to say, a such a -report is totally, utterly, completely and -comprehensively 100% useless; a waste of your time, my time, and -net bandwidth. With no details at all, there's no way -I can possibly begin to figure out what the problem is.

-

The rules of the game are: facts, facts, facts. Don't omit -them because "oh, they won't be relevant". At the bare -minimum:

-
Machine type.  Operating system version.  
-Exact version of bzip2 (do bzip2 -V).  
-Exact version of the compiler used.  
-Flags passed to the compiler.
-

However, the most important single thing that will help me -is the file that you were trying to compress or decompress at the -time the problem happened. Without that, my ability to do -anything more than speculate about the cause, is limited.

-
-
-
-

-4.4. Did you get the right package?

-
-
-

bzip2 is a resource hog. -It soaks up large amounts of CPU cycles and memory. Also, it -gives very large latencies. In the worst case, you can feed many -megabytes of uncompressed data into the library before getting -any compressed output, so this probably rules out applications -requiring interactive behaviour.

-

These aren't faults of my implementation, I hope, but more -an intrinsic property of the Burrows-Wheeler transform -(unfortunately). Maybe this isn't what you want.

-

If you want a compressor and/or library which is faster, -uses less memory but gets pretty good compression, and has -minimal latency, consider Jean-loup Gailly's and Mark Adler's -work, zlib-1.2.1 and -gzip-1.2.4. Look for them at -http://www.zlib.org and -http://www.gzip.org -respectively.

-

For something faster and lighter still, you might try Markus F -X J Oberhumer's LZO real-time -compression/decompression library, at -http://www.oberhumer.com/opensource.

-
-
-
-

-4.5. Further Reading

-
-
-

bzip2 is not research -work, in the sense that it doesn't present any new ideas. -Rather, it's an engineering exercise based on existing -ideas.

-

Four documents describe essentially all the ideas behind -bzip2:

-

Michael Burrows and D. J. Wheeler:
-  "A block-sorting lossless data compression algorithm"
-   10th May 1994. 
-   Digital SRC Research Report 124.
-   ftp://ftp.digital.com/pub/DEC/SRC/research-reports/SRC-124.ps.gz
-   If you have trouble finding it, try searching at the
-   New Zealand Digital Library, http://www.nzdl.org.
-
-Daniel S. Hirschberg and Debra A. LeLewer
-  "Efficient Decoding of Prefix Codes"
-   Communications of the ACM, April 1990, Vol 33, Number 4.
-   You might be able to get an electronic copy of this
-   from the ACM Digital Library.
-
-David J. Wheeler
-   Program bred3.c and accompanying document bred3.ps.
-   This contains the idea behind the multi-table Huffman coding scheme.
-   ftp://ftp.cl.cam.ac.uk/users/djw3/
-
-Jon L. Bentley and Robert Sedgewick
-  "Fast Algorithms for Sorting and Searching Strings"
-   Available from Sedgewick's web page,
-   www.cs.princeton.edu/~rs
-

-

The following paper gives valuable additional insights into -the algorithm, but is not immediately the basis of any code used -in bzip2.

-

Peter Fenwick:
-   Block Sorting Text Compression
-   Proceedings of the 19th Australasian Computer Science Conference,
-     Melbourne, Australia.  Jan 31 - Feb 2, 1996.
-   ftp://ftp.cs.auckland.ac.nz/pub/peter-f/ACSC96paper.ps

-

Kunihiko Sadakane's sorting algorithm, mentioned above, is -available from:

-

http://naomi.is.s.u-tokyo.ac.jp/~sada/papers/Sada98b.ps.gz
-

-

The Manber-Myers suffix array construction algorithm is -described in a paper available from:

-

http://www.cs.arizona.edu/people/gene/PAPERS/suffix.ps
-

-

Finally, the following papers document some -investigations I made into the performance of sorting -and decompression algorithms:

-

Julian Seward
-   On the Performance of BWT Sorting Algorithms
-   Proceedings of the IEEE Data Compression Conference 2000
-     Snowbird, Utah.  28-30 March 2000.
-
-Julian Seward
-   Space-time Tradeoffs in the Inverse B-W Transform
-   Proceedings of the IEEE Data Compression Conference 2001
-     Snowbird, Utah.  27-29 March 2001.
-

-
-
-
- diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/manual.pdf b/contrib/vmap_extractor_v2/stormlib/bzip2/manual.pdf deleted file mode 100644 index 394b8092565..00000000000 Binary files a/contrib/vmap_extractor_v2/stormlib/bzip2/manual.pdf and /dev/null differ diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/manual.ps b/contrib/vmap_extractor_v2/stormlib/bzip2/manual.ps deleted file mode 100644 index 03831d194c8..00000000000 Binary files a/contrib/vmap_extractor_v2/stormlib/bzip2/manual.ps and /dev/null differ diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/manual.xml b/contrib/vmap_extractor_v2/stormlib/bzip2/manual.xml deleted file mode 100644 index 1ab5bd71d9e..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/manual.xml +++ /dev/null @@ -1,2966 +0,0 @@ - - - %common-ents; -]> - - - - - bzip2 and libbzip2, version 1.0.3 - A program and library for data compression - - &bz-lifespan; - Julian Seward - - Version &bz-version; of &bz-date; - - - - Julian - Seward - - &bz-url; - - - - - - - This program, bzip2, the - associated library libbzip2, and - all documentation, are copyright © &bz-lifespan; Julian Seward. - 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. - - 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. - - Altered source versions must be plainly marked - as such, and must not be misrepresented as being the original - software. - - The name of the author may not be used to - endorse or promote products derived from this software without - specific prior written permission. - - - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR "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 THE - AUTHOR 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. - - PATENTS: To the best of my knowledge, - bzip2 and - libbzip2 do not use any patented - algorithms. However, I do not have the resources to carry - out a patent search. Therefore I cannot give any guarantee of - the above statement. - - - - - - - - - -Introduction - -bzip2 compresses files -using the Burrows-Wheeler block-sorting text compression -algorithm, and Huffman coding. Compression is generally -considerably better than that achieved by more conventional -LZ77/LZ78-based compressors, and approaches the performance of -the PPM family of statistical compressors. - -bzip2 is built on top of -libbzip2, a flexible library for -handling compressed data in the -bzip2 format. This manual -describes both how to use the program and how to work with the -library interface. Most of the manual is devoted to this -library, not the program, which is good news if your interest is -only in the program. - - - - describes how to use - bzip2; this is the only part - you need to read if you just want to know how to operate the - program. - - describes the - programming interfaces in detail, and - - records some - miscellaneous notes which I thought ought to be recorded - somewhere. - - - - - - - -How to use bzip2 - -This chapter contains a copy of the -bzip2 man page, and nothing -else. - - -NAME - - - - bzip2, - bunzip2 - a block-sorting file - compressor, v1.0.3 - - bzcat - - decompresses files to stdout - - bzip2recover - - recovers data from damaged bzip2 files - - - - - - - -SYNOPSIS - - - - bzip2 [ - -cdfkqstvzVL123456789 ] [ filenames ... ] - - bunzip2 [ - -fkvsVL ] [ filenames ... ] - - bzcat [ -s ] [ - filenames ... ] - - bzip2recover - filename - - - - - - - -DESCRIPTION - -bzip2 compresses files -using the Burrows-Wheeler block sorting text compression -algorithm, and Huffman coding. Compression is generally -considerably better than that achieved by more conventional -LZ77/LZ78-based compressors, and approaches the performance of -the PPM family of statistical compressors. - -The command-line options are deliberately very similar to -those of GNU gzip, but they are -not identical. - -bzip2 expects a list of -file names to accompany the command-line flags. Each file is -replaced by a compressed version of itself, with the name -original_name.bz2. Each -compressed file has the same modification date, permissions, and, -when possible, ownership as the corresponding original, so that -these properties can be correctly restored at decompression time. -File name handling is naive in the sense that there is no -mechanism for preserving original file names, permissions, -ownerships or dates in filesystems which lack these concepts, or -have serious file name length restrictions, such as -MS-DOS. - -bzip2 and -bunzip2 will by default not -overwrite existing files. If you want this to happen, specify -the -f flag. - -If no file names are specified, -bzip2 compresses from standard -input to standard output. In this case, -bzip2 will decline to write -compressed output to a terminal, as this would be entirely -incomprehensible and therefore pointless. - -bunzip2 (or -bzip2 -d) decompresses all -specified files. Files which were not created by -bzip2 will be detected and -ignored, and a warning issued. -bzip2 attempts to guess the -filename for the decompressed file from that of the compressed -file as follows: - - - - filename.bz2 - becomes - filename - - filename.bz - becomes - filename - - filename.tbz2 - becomes - filename.tar - - filename.tbz - becomes - filename.tar - - anyothername - becomes - anyothername.out - - - -If the file does not end in one of the recognised endings, -.bz2, -.bz, -.tbz2 or -.tbz, -bzip2 complains that it cannot -guess the name of the original file, and uses the original name -with .out appended. - -As with compression, supplying no filenames causes -decompression from standard input to standard output. - -bunzip2 will correctly -decompress a file which is the concatenation of two or more -compressed files. The result is the concatenation of the -corresponding uncompressed files. Integrity testing -(-t) of concatenated compressed -files is also supported. - -You can also compress or decompress files to the standard -output by giving the -c flag. -Multiple files may be compressed and decompressed like this. The -resulting outputs are fed sequentially to stdout. Compression of -multiple files in this manner generates a stream containing -multiple compressed file representations. Such a stream can be -decompressed correctly only by -bzip2 version 0.9.0 or later. -Earlier versions of bzip2 will -stop after decompressing the first file in the stream. - -bzcat (or -bzip2 -dc) decompresses all -specified files to the standard output. - -bzip2 will read arguments -from the environment variables -BZIP2 and -BZIP, in that order, and will -process them before any arguments read from the command line. -This gives a convenient way to supply default arguments. - -Compression is always performed, even if the compressed -file is slightly larger than the original. Files of less than -about one hundred bytes tend to get larger, since the compression -mechanism has a constant overhead in the region of 50 bytes. -Random data (including the output of most file compressors) is -coded at about 8.05 bits per byte, giving an expansion of around -0.5%. - -As a self-check for your protection, -bzip2 uses 32-bit CRCs to make -sure that the decompressed version of a file is identical to the -original. This guards against corruption of the compressed data, -and against undetected bugs in -bzip2 (hopefully very unlikely). -The chances of data corruption going undetected is microscopic, -about one chance in four billion for each file processed. Be -aware, though, that the check occurs upon decompression, so it -can only tell you that something is wrong. It can't help you -recover the original uncompressed data. You can use -bzip2recover to try to recover -data from damaged files. - -Return values: 0 for a normal exit, 1 for environmental -problems (file not found, invalid flags, I/O errors, etc.), 2 -to indicate a corrupt compressed file, 3 for an internal -consistency error (eg, bug) which caused -bzip2 to panic. - - - - - -OPTIONS - - - - - -c --stdout - Compress or decompress to standard - output. - - - - -d --decompress - Force decompression. - bzip2, - bunzip2 and - bzcat are really the same - program, and the decision about what actions to take is done on - the basis of which name is used. This flag overrides that - mechanism, and forces bzip2 to decompress. - - - - -z --compress - The complement to - -d: forces compression, - regardless of the invokation name. - - - - -t --test - Check integrity of the specified file(s), but - don't decompress them. This really performs a trial - decompression and throws away the result. - - - - -f --force - Force overwrite of output files. Normally, - bzip2 will not overwrite - existing output files. Also forces - bzip2 to break hard links to - files, which it otherwise wouldn't do. - bzip2 normally declines - to decompress files which don't have the correct magic header - bytes. If forced (-f), - however, it will pass such files through unmodified. This is - how GNU gzip behaves. - - - - - -k --keep - Keep (don't delete) input files during - compression or decompression. - - - - -s --small - Reduce memory usage, for compression, - decompression and testing. Files are decompressed and tested - using a modified algorithm which only requires 2.5 bytes per - block byte. This means any file can be decompressed in 2300k - of memory, albeit at about half the normal speed. - During compression, -s - selects a block size of 200k, which limits memory use to around - the same figure, at the expense of your compression ratio. In - short, if your machine is low on memory (8 megabytes or less), - use -s for everything. See - below. - - - - -q --quiet - Suppress non-essential warning messages. - Messages pertaining to I/O errors and other critical events - will not be suppressed. - - - - -v --verbose - Verbose mode -- show the compression ratio for - each file processed. Further - -v's increase the verbosity - level, spewing out lots of information which is primarily of - interest for diagnostic purposes. - - - - -L --license -V --version - Display the software version, license terms and - conditions. - - - - -1 (or - --fast) to - -9 (or - -best) - Set the block size to 100 k, 200 k ... 900 k - when compressing. Has no effect when decompressing. See below. The - --fast and - --best aliases are primarily - for GNU gzip compatibility. - In particular, --fast doesn't - make things significantly faster. And - --best merely selects the - default behaviour. - - - - -- - Treats all subsequent arguments as file names, - even if they start with a dash. This is so you can handle - files with names beginning with a dash, for example: - bzip2 -- - -myfilename. - - - - --repetitive-fast - --repetitive-best - These flags are redundant in versions 0.9.5 and - above. They provided some coarse control over the behaviour of - the sorting algorithm in earlier versions, which was sometimes - useful. 0.9.5 and above have an improved algorithm which - renders these flags irrelevant. - - - - - - - - -MEMORY MANAGEMENT - -bzip2 compresses large -files in blocks. The block size affects both the compression -ratio achieved, and the amount of memory needed for compression -and decompression. The flags -1 -through -9 specify the block -size to be 100,000 bytes through 900,000 bytes (the default) -respectively. At decompression time, the block size used for -compression is read from the header of the compressed file, and -bunzip2 then allocates itself -just enough memory to decompress the file. Since block sizes are -stored in compressed files, it follows that the flags --1 to --9 are irrelevant to and so -ignored during decompression. - -Compression and decompression requirements, in bytes, can be -estimated as: - -Compression: 400k + ( 8 x block size ) - -Decompression: 100k + ( 4 x block size ), or - 100k + ( 2.5 x block size ) - - -Larger block sizes give rapidly diminishing marginal -returns. Most of the compression comes from the first two or -three hundred k of block size, a fact worth bearing in mind when -using bzip2 on small machines. -It is also important to appreciate that the decompression memory -requirement is set at compression time by the choice of block -size. - -For files compressed with the default 900k block size, -bunzip2 will require about 3700 -kbytes to decompress. To support decompression of any file on a -4 megabyte machine, bunzip2 has -an option to decompress using approximately half this amount of -memory, about 2300 kbytes. Decompression speed is also halved, -so you should use this option only where necessary. The relevant -flag is -s. - -In general, try and use the largest block size memory -constraints allow, since that maximises the compression achieved. -Compression and decompression speed are virtually unaffected by -block size. - -Another significant point applies to files which fit in a -single block -- that means most files you'd encounter using a -large block size. The amount of real memory touched is -proportional to the size of the file, since the file is smaller -than a block. For example, compressing a file 20,000 bytes long -with the flag -9 will cause the -compressor to allocate around 7600k of memory, but only touch -400k + 20000 * 8 = 560 kbytes of it. Similarly, the decompressor -will allocate 3700k but only touch 100k + 20000 * 4 = 180 -kbytes. - -Here is a table which summarises the maximum memory usage -for different block sizes. Also recorded is the total compressed -size for 14 files of the Calgary Text Compression Corpus -totalling 3,141,622 bytes. This column gives some feel for how -compression varies with block size. These figures tend to -understate the advantage of larger block sizes for larger files, -since the Corpus is dominated by smaller files. - - - Compress Decompress Decompress Corpus -Flag usage usage -s usage Size - - -1 1200k 500k 350k 914704 - -2 2000k 900k 600k 877703 - -3 2800k 1300k 850k 860338 - -4 3600k 1700k 1100k 846899 - -5 4400k 2100k 1350k 845160 - -6 5200k 2500k 1600k 838626 - -7 6100k 2900k 1850k 834096 - -8 6800k 3300k 2100k 828642 - -9 7600k 3700k 2350k 828642 - - - - - - -RECOVERING DATA FROM DAMAGED FILES - -bzip2 compresses files in -blocks, usually 900kbytes long. Each block is handled -independently. If a media or transmission error causes a -multi-block .bz2 file to become -damaged, it may be possible to recover data from the undamaged -blocks in the file. - -The compressed representation of each block is delimited by -a 48-bit pattern, which makes it possible to find the block -boundaries with reasonable certainty. Each block also carries -its own 32-bit CRC, so damaged blocks can be distinguished from -undamaged ones. - -bzip2recover is a simple -program whose purpose is to search for blocks in -.bz2 files, and write each block -out into its own .bz2 file. You -can then use bzip2 -t to test -the integrity of the resulting files, and decompress those which -are undamaged. - -bzip2recover takes a -single argument, the name of the damaged file, and writes a -number of files rec0001file.bz2, -rec0002file.bz2, etc, containing -the extracted blocks. The output filenames are designed so that -the use of wildcards in subsequent processing -- for example, -bzip2 -dc rec*file.bz2 > -recovered_data -- lists the files in the correct -order. - -bzip2recover should be of -most use dealing with large .bz2 -files, as these will contain many blocks. It is clearly futile -to use it on damaged single-block files, since a damaged block -cannot be recovered. If you wish to minimise any potential data -loss through media or transmission errors, you might consider -compressing with a smaller block size. - - - - - -PERFORMANCE NOTES - -The sorting phase of compression gathers together similar -strings in the file. Because of this, files containing very long -runs of repeated symbols, like "aabaabaabaab ..." (repeated -several hundred times) may compress more slowly than normal. -Versions 0.9.5 and above fare much better than previous versions -in this respect. The ratio between worst-case and average-case -compression time is in the region of 10:1. For previous -versions, this figure was more like 100:1. You can use the --vvvv option to monitor progress -in great detail, if you want. - -Decompression speed is unaffected by these -phenomena. - -bzip2 usually allocates -several megabytes of memory to operate in, and then charges all -over it in a fairly random fashion. This means that performance, -both for compressing and decompressing, is largely determined by -the speed at which your machine can service cache misses. -Because of this, small changes to the code to reduce the miss -rate have been observed to give disproportionately large -performance improvements. I imagine -bzip2 will perform best on -machines with very large caches. - - - - - - -CAVEATS - -I/O error messages are not as helpful as they could be. -bzip2 tries hard to detect I/O -errors and exit cleanly, but the details of what the problem is -sometimes seem rather misleading. - -This manual page pertains to version &bz-version; of -bzip2. Compressed data created -by this version is entirely forwards and backwards compatible -with the previous public releases, versions 0.1pl2, 0.9.0 and -0.9.5, 1.0.0, 1.0.1 and 1.0.2, but with the following exception: 0.9.0 -and above can correctly decompress multiple concatenated -compressed files. 0.1pl2 cannot do this; it will stop after -decompressing just the first file in the stream. - -bzip2recover versions -prior to 1.0.2 used 32-bit integers to represent bit positions in -compressed files, so it could not handle compressed files more -than 512 megabytes long. Versions 1.0.2 and above use 64-bit ints -on some platforms which support them (GNU supported targets, and -Windows). To establish whether or not -bzip2recover was built with such -a limitation, run it without arguments. In any event you can -build yourself an unlimited version if you can recompile it with -MaybeUInt64 set to be an -unsigned 64-bit integer. - - - - - - -AUTHOR - -Julian Seward, -&bz-email; - -The ideas embodied in -bzip2 are due to (at least) the -following people: Michael Burrows and David Wheeler (for the -block sorting transformation), David Wheeler (again, for the -Huffman coder), Peter Fenwick (for the structured coding model in -the original bzip, and many -refinements), and Alistair Moffat, Radford Neal and Ian Witten -(for the arithmetic coder in the original -bzip). I am much indebted for -their help, support and advice. See the manual in the source -distribution for pointers to sources of documentation. Christian -von Roques encouraged me to look for faster sorting algorithms, -so as to speed up compression. Bela Lubkin encouraged me to -improve the worst-case compression performance. -Donna Robinson XMLised the documentation. -Many people sent -patches, helped with portability problems, lent machines, gave -advice and were generally helpful. - - - - - - - - - -Programming with <computeroutput>libbzip2</computeroutput> - - -This chapter describes the programming interface to -libbzip2. - -For general background information, particularly about -memory use and performance aspects, you'd be well advised to read - as well. - - - -Top-level structure - -libbzip2 is a flexible -library for compressing and decompressing data in the -bzip2 data format. Although -packaged as a single entity, it helps to regard the library as -three separate parts: the low level interface, and the high level -interface, and some utility functions. - -The structure of -libbzip2's interfaces is similar -to that of Jean-loup Gailly's and Mark Adler's excellent -zlib library. - -All externally visible symbols have names beginning -BZ2_. This is new in version -1.0. The intention is to minimise pollution of the namespaces of -library clients. - -To use any part of the library, you need to -#include <bzlib.h> -into your sources. - - - - -Low-level summary - -This interface provides services for compressing and -decompressing data in memory. There's no provision for dealing -with files, streams or any other I/O mechanisms, just straight -memory-to-memory work. In fact, this part of the library can be -compiled without inclusion of -stdio.h, which may be helpful -for embedded applications. - -The low-level part of the library has no global variables -and is therefore thread-safe. - -Six routines make up the low level interface: -BZ2_bzCompressInit, -BZ2_bzCompress, and -BZ2_bzCompressEnd for -compression, and a corresponding trio -BZ2_bzDecompressInit, -BZ2_bzDecompress and -BZ2_bzDecompressEnd for -decompression. The *Init -functions allocate memory for compression/decompression and do -other initialisations, whilst the -*End functions close down -operations and release memory. - -The real work is done by -BZ2_bzCompress and -BZ2_bzDecompress. These -compress and decompress data from a user-supplied input buffer to -a user-supplied output buffer. These buffers can be any size; -arbitrary quantities of data are handled by making repeated calls -to these functions. This is a flexible mechanism allowing a -consumer-pull style of activity, or producer-push, or a mixture -of both. - - - - - -High-level summary - -This interface provides some handy wrappers around the -low-level interface to facilitate reading and writing -bzip2 format files -(.bz2 files). The routines -provide hooks to facilitate reading files in which the -bzip2 data stream is embedded -within some larger-scale file structure, or where there are -multiple bzip2 data streams -concatenated end-to-end. - -For reading files, -BZ2_bzReadOpen, -BZ2_bzRead, -BZ2_bzReadClose and -BZ2_bzReadGetUnused are -supplied. For writing files, -BZ2_bzWriteOpen, -BZ2_bzWrite and -BZ2_bzWriteFinish are -available. - -As with the low-level library, no global variables are used -so the library is per se thread-safe. However, if I/O errors -occur whilst reading or writing the underlying compressed files, -you may have to consult errno to -determine the cause of the error. In that case, you'd need a C -library which correctly supports -errno in a multithreaded -environment. - -To make the library a little simpler and more portable, -BZ2_bzReadOpen and -BZ2_bzWriteOpen require you to -pass them file handles (FILE*s) -which have previously been opened for reading or writing -respectively. That avoids portability problems associated with -file operations and file attributes, whilst not being much of an -imposition on the programmer. - - - - - -Utility functions summary - -For very simple needs, -BZ2_bzBuffToBuffCompress and -BZ2_bzBuffToBuffDecompress are -provided. These compress data in memory from one buffer to -another buffer in a single function call. You should assess -whether these functions fulfill your memory-to-memory -compression/decompression requirements before investing effort in -understanding the more general but more complex low-level -interface. - -Yoshioka Tsuneo -(QWF00133@niftyserve.or.jp / -tsuneo-y@is.aist-nara.ac.jp) has -contributed some functions to give better -zlib compatibility. These -functions are BZ2_bzopen, -BZ2_bzread, -BZ2_bzwrite, -BZ2_bzflush, -BZ2_bzclose, -BZ2_bzerror and -BZ2_bzlibVersion. You may find -these functions more convenient for simple file reading and -writing, than those in the high-level interface. These functions -are not (yet) officially part of the library, and are minimally -documented here. If they break, you get to keep all the pieces. -I hope to document them properly when time permits. - -Yoshioka also contributed modifications to allow the -library to be built as a Windows DLL. - - - - - - - -Error handling - -The library is designed to recover cleanly in all -situations, including the worst-case situation of decompressing -random data. I'm not 100% sure that it can always do this, so -you might want to add a signal handler to catch segmentation -violations during decompression if you are feeling especially -paranoid. I would be interested in hearing more about the -robustness of the library to corrupted compressed data. - -Version 1.0.3 more robust in this respect than any -previous version. Investigations with Valgrind (a tool for detecting -problems with memory management) indicate -that, at least for the few files I tested, all single-bit errors -in the decompressed data are caught properly, with no -segmentation faults, no uses of uninitialised data, no out of -range reads or writes, and no infinite looping in the decompressor. -So it's certainly pretty robust, although -I wouldn't claim it to be totally bombproof. - -The file bzlib.h contains -all definitions needed to use the library. In particular, you -should definitely not include -bzlib_private.h. - -In bzlib.h, the various -return values are defined. The following list is not intended as -an exhaustive description of the circumstances in which a given -value may be returned -- those descriptions are given later. -Rather, it is intended to convey the rough meaning of each return -value. The first five actions are normal and not intended to -denote an error situation. - - - - - BZ_OK - The requested action was completed - successfully. - - - - BZ_RUN_OK, BZ_FLUSH_OK, - BZ_FINISH_OK - In - BZ2_bzCompress, the requested - flush/finish/nothing-special action was completed - successfully. - - - - BZ_STREAM_END - Compression of data was completed, or the - logical stream end was detected during - decompression. - - - - -The following return values indicate an error of some -kind. - - - - - BZ_CONFIG_ERROR - Indicates that the library has been improperly - compiled on your platform -- a major configuration error. - Specifically, it means that - sizeof(char), - sizeof(short) and - sizeof(int) are not 1, 2 and - 4 respectively, as they should be. Note that the library - should still work properly on 64-bit platforms which follow - the LP64 programming model -- that is, where - sizeof(long) and - sizeof(void*) are 8. Under - LP64, sizeof(int) is still 4, - so libbzip2, which doesn't - use the long type, is - OK. - - - - BZ_SEQUENCE_ERROR - When using the library, it is important to call - the functions in the correct sequence and with data structures - (buffers etc) in the correct states. - libbzip2 checks as much as it - can to ensure this is happening, and returns - BZ_SEQUENCE_ERROR if not. - Code which complies precisely with the function semantics, as - detailed below, should never receive this value; such an event - denotes buggy code which you should - investigate. - - - - BZ_PARAM_ERROR - Returned when a parameter to a function call is - out of range or otherwise manifestly incorrect. As with - BZ_SEQUENCE_ERROR, this - denotes a bug in the client code. The distinction between - BZ_PARAM_ERROR and - BZ_SEQUENCE_ERROR is a bit - hazy, but still worth making. - - - - BZ_MEM_ERROR - Returned when a request to allocate memory - failed. Note that the quantity of memory needed to decompress - a stream cannot be determined until the stream's header has - been read. So - BZ2_bzDecompress and - BZ2_bzRead may return - BZ_MEM_ERROR even though some - of the compressed data has been read. The same is not true - for compression; once - BZ2_bzCompressInit or - BZ2_bzWriteOpen have - successfully completed, - BZ_MEM_ERROR cannot - occur. - - - - BZ_DATA_ERROR - Returned when a data integrity error is - detected during decompression. Most importantly, this means - when stored and computed CRCs for the data do not match. This - value is also returned upon detection of any other anomaly in - the compressed data. - - - - BZ_DATA_ERROR_MAGIC - As a special case of - BZ_DATA_ERROR, it is - sometimes useful to know when the compressed stream does not - start with the correct magic bytes ('B' 'Z' - 'h'). - - - - BZ_IO_ERROR - Returned by - BZ2_bzRead and - BZ2_bzWrite when there is an - error reading or writing in the compressed file, and by - BZ2_bzReadOpen and - BZ2_bzWriteOpen for attempts - to use a file for which the error indicator (viz, - ferror(f)) is set. On - receipt of BZ_IO_ERROR, the - caller should consult errno - and/or perror to acquire - operating-system specific information about the - problem. - - - - BZ_UNEXPECTED_EOF - Returned by - BZ2_bzRead when the - compressed file finishes before the logical end of stream is - detected. - - - - BZ_OUTBUFF_FULL - Returned by - BZ2_bzBuffToBuffCompress and - BZ2_bzBuffToBuffDecompress to - indicate that the output data will not fit into the output - buffer provided. - - - - - - - - - -Low-level interface - - - -<computeroutput>BZ2_bzCompressInit</computeroutput> - - -typedef struct { - char *next_in; - unsigned int avail_in; - unsigned int total_in_lo32; - unsigned int total_in_hi32; - - char *next_out; - unsigned int avail_out; - unsigned int total_out_lo32; - unsigned int total_out_hi32; - - void *state; - - void *(*bzalloc)(void *,int,int); - void (*bzfree)(void *,void *); - void *opaque; -} bz_stream; - -int BZ2_bzCompressInit ( bz_stream *strm, - int blockSize100k, - int verbosity, - int workFactor ); - - -Prepares for compression. The -bz_stream structure holds all -data pertaining to the compression activity. A -bz_stream structure should be -allocated and initialised prior to the call. The fields of -bz_stream comprise the entirety -of the user-visible data. state -is a pointer to the private data structures required for -compression. - -Custom memory allocators are supported, via fields -bzalloc, -bzfree, and -opaque. The value -opaque is passed to as the first -argument to all calls to bzalloc -and bzfree, but is otherwise -ignored by the library. The call bzalloc ( -opaque, n, m ) is expected to return a pointer -p to n * -m bytes of memory, and bzfree ( -opaque, p ) should free that memory. - -If you don't want to use a custom memory allocator, set -bzalloc, -bzfree and -opaque to -NULL, and the library will then -use the standard malloc / -free routines. - -Before calling -BZ2_bzCompressInit, fields -bzalloc, -bzfree and -opaque should be filled -appropriately, as just described. Upon return, the internal -state will have been allocated and initialised, and -total_in_lo32, -total_in_hi32, -total_out_lo32 and -total_out_hi32 will have been -set to zero. These four fields are used by the library to inform -the caller of the total amount of data passed into and out of the -library, respectively. You should not try to change them. As of -version 1.0, 64-bit counts are maintained, even on 32-bit -platforms, using the _hi32 -fields to store the upper 32 bits of the count. So, for example, -the total amount of data in is (total_in_hi32 -<< 32) + total_in_lo32. - -Parameter blockSize100k -specifies the block size to be used for compression. It should -be a value between 1 and 9 inclusive, and the actual block size -used is 100000 x this figure. 9 gives the best compression but -takes most memory. - -Parameter verbosity should -be set to a number between 0 and 4 inclusive. 0 is silent, and -greater numbers give increasingly verbose monitoring/debugging -output. If the library has been compiled with --DBZ_NO_STDIO, no such output -will appear for any verbosity setting. - -Parameter workFactor -controls how the compression phase behaves when presented with -worst case, highly repetitive, input data. If compression runs -into difficulties caused by repetitive data, the library switches -from the standard sorting algorithm to a fallback algorithm. The -fallback is slower than the standard algorithm by perhaps a -factor of three, but always behaves reasonably, no matter how bad -the input. - -Lower values of workFactor -reduce the amount of effort the standard algorithm will expend -before resorting to the fallback. You should set this parameter -carefully; too low, and many inputs will be handled by the -fallback algorithm and so compress rather slowly, too high, and -your average-to-worst case compression times can become very -large. The default value of 30 gives reasonable behaviour over a -wide range of circumstances. - -Allowable values range from 0 to 250 inclusive. 0 is a -special case, equivalent to using the default value of 30. - -Note that the compressed output generated is the same -regardless of whether or not the fallback algorithm is -used. - -Be aware also that this parameter may disappear entirely in -future versions of the library. In principle it should be -possible to devise a good way to automatically choose which -algorithm to use. Such a mechanism would render the parameter -obsolete. - -Possible return values: - - -BZ_CONFIG_ERROR - if the library has been mis-compiled -BZ_PARAM_ERROR - if strm is NULL - or blockSize < 1 or blockSize > 9 - or verbosity < 0 or verbosity > 4 - or workFactor < 0 or workFactor > 250 -BZ_MEM_ERROR - if not enough memory is available -BZ_OK - otherwise - - -Allowable next actions: - - -BZ2_bzCompress - if BZ_OK is returned - no specific action needed in case of error - - - - - - -<computeroutput>BZ2_bzCompress</computeroutput> - - -int BZ2_bzCompress ( bz_stream *strm, int action ); - - -Provides more input and/or output buffer space for the -library. The caller maintains input and output buffers, and -calls BZ2_bzCompress to transfer -data between them. - -Before each call to -BZ2_bzCompress, -next_in should point at the data -to be compressed, and avail_in -should indicate how many bytes the library may read. -BZ2_bzCompress updates -next_in, -avail_in and -total_in to reflect the number -of bytes it has read. - -Similarly, next_out should -point to a buffer in which the compressed data is to be placed, -with avail_out indicating how -much output space is available. -BZ2_bzCompress updates -next_out, -avail_out and -total_out to reflect the number -of bytes output. - -You may provide and remove as little or as much data as you -like on each call of -BZ2_bzCompress. In the limit, -it is acceptable to supply and remove data one byte at a time, -although this would be terribly inefficient. You should always -ensure that at least one byte of output space is available at -each call. - -A second purpose of -BZ2_bzCompress is to request a -change of mode of the compressed stream. - -Conceptually, a compressed stream can be in one of four -states: IDLE, RUNNING, FLUSHING and FINISHING. Before -initialisation -(BZ2_bzCompressInit) and after -termination (BZ2_bzCompressEnd), -a stream is regarded as IDLE. - -Upon initialisation -(BZ2_bzCompressInit), the stream -is placed in the RUNNING state. Subsequent calls to -BZ2_bzCompress should pass -BZ_RUN as the requested action; -other actions are illegal and will result in -BZ_SEQUENCE_ERROR. - -At some point, the calling program will have provided all -the input data it wants to. It will then want to finish up -- in -effect, asking the library to process any data it might have -buffered internally. In this state, -BZ2_bzCompress will no longer -attempt to read data from -next_in, but it will want to -write data to next_out. Because -the output buffer supplied by the user can be arbitrarily small, -the finishing-up operation cannot necessarily be done with a -single call of -BZ2_bzCompress. - -Instead, the calling program passes -BZ_FINISH as an action to -BZ2_bzCompress. This changes -the stream's state to FINISHING. Any remaining input (ie, -next_in[0 .. avail_in-1]) is -compressed and transferred to the output buffer. To do this, -BZ2_bzCompress must be called -repeatedly until all the output has been consumed. At that -point, BZ2_bzCompress returns -BZ_STREAM_END, and the stream's -state is set back to IDLE. -BZ2_bzCompressEnd should then be -called. - -Just to make sure the calling program does not cheat, the -library makes a note of avail_in -at the time of the first call to -BZ2_bzCompress which has -BZ_FINISH as an action (ie, at -the time the program has announced its intention to not supply -any more input). By comparing this value with that of -avail_in over subsequent calls -to BZ2_bzCompress, the library -can detect any attempts to slip in more data to compress. Any -calls for which this is detected will return -BZ_SEQUENCE_ERROR. This -indicates a programming mistake which should be corrected. - -Instead of asking to finish, the calling program may ask -BZ2_bzCompress to take all the -remaining input, compress it and terminate the current -(Burrows-Wheeler) compression block. This could be useful for -error control purposes. The mechanism is analogous to that for -finishing: call BZ2_bzCompress -with an action of BZ_FLUSH, -remove output data, and persist with the -BZ_FLUSH action until the value -BZ_RUN is returned. As with -finishing, BZ2_bzCompress -detects any attempt to provide more input data once the flush has -begun. - -Once the flush is complete, the stream returns to the -normal RUNNING state. - -This all sounds pretty complex, but isn't really. Here's a -table which shows which actions are allowable in each state, what -action will be taken, what the next state is, and what the -non-error return values are. Note that you can't explicitly ask -what state the stream is in, but nor do you need to -- it can be -inferred from the values returned by -BZ2_bzCompress. - - -IDLE/any - Illegal. IDLE state only exists after BZ2_bzCompressEnd or - before BZ2_bzCompressInit. - Return value = BZ_SEQUENCE_ERROR - -RUNNING/BZ_RUN - Compress from next_in to next_out as much as possible. - Next state = RUNNING - Return value = BZ_RUN_OK - -RUNNING/BZ_FLUSH - Remember current value of next_in. Compress from next_in - to next_out as much as possible, but do not accept any more input. - Next state = FLUSHING - Return value = BZ_FLUSH_OK - -RUNNING/BZ_FINISH - Remember current value of next_in. Compress from next_in - to next_out as much as possible, but do not accept any more input. - Next state = FINISHING - Return value = BZ_FINISH_OK - -FLUSHING/BZ_FLUSH - Compress from next_in to next_out as much as possible, - but do not accept any more input. - If all the existing input has been used up and all compressed - output has been removed - Next state = RUNNING; Return value = BZ_RUN_OK - else - Next state = FLUSHING; Return value = BZ_FLUSH_OK - -FLUSHING/other - Illegal. - Return value = BZ_SEQUENCE_ERROR - -FINISHING/BZ_FINISH - Compress from next_in to next_out as much as possible, - but to not accept any more input. - If all the existing input has been used up and all compressed - output has been removed - Next state = IDLE; Return value = BZ_STREAM_END - else - Next state = FINISHING; Return value = BZ_FINISHING - -FINISHING/other - Illegal. - Return value = BZ_SEQUENCE_ERROR - - - -That still looks complicated? Well, fair enough. The -usual sequence of calls for compressing a load of data is: - - - - Get started with - BZ2_bzCompressInit. - - Shovel data in and shlurp out its compressed form - using zero or more calls of - BZ2_bzCompress with action = - BZ_RUN. - - Finish up. Repeatedly call - BZ2_bzCompress with action = - BZ_FINISH, copying out the - compressed output, until - BZ_STREAM_END is - returned. Close up and go home. Call - BZ2_bzCompressEnd. - - - -If the data you want to compress fits into your input -buffer all at once, you can skip the calls of -BZ2_bzCompress ( ..., BZ_RUN ) -and just do the BZ2_bzCompress ( ..., BZ_FINISH -) calls. - -All required memory is allocated by -BZ2_bzCompressInit. The -compression library can accept any data at all (obviously). So -you shouldn't get any error return values from the -BZ2_bzCompress calls. If you -do, they will be -BZ_SEQUENCE_ERROR, and indicate -a bug in your programming. - -Trivial other possible return values: - - -BZ_PARAM_ERROR - if strm is NULL, or strm->s is NULL - - - - - - -<computeroutput>BZ2_bzCompressEnd</computeroutput> - - -int BZ2_bzCompressEnd ( bz_stream *strm ); - - -Releases all memory associated with a compression -stream. - -Possible return values: - - -BZ_PARAM_ERROR if strm is NULL or strm->s is NULL -BZ_OK otherwise - - - - - - -<computeroutput>BZ2_bzDecompressInit</computeroutput> - - -int BZ2_bzDecompressInit ( bz_stream *strm, int verbosity, int small ); - - -Prepares for decompression. As with -BZ2_bzCompressInit, a -bz_stream record should be -allocated and initialised before the call. Fields -bzalloc, -bzfree and -opaque should be set if a custom -memory allocator is required, or made -NULL for the normal -malloc / -free routines. Upon return, the -internal state will have been initialised, and -total_in and -total_out will be zero. - -For the meaning of parameter -verbosity, see -BZ2_bzCompressInit. - -If small is nonzero, the -library will use an alternative decompression algorithm which -uses less memory but at the cost of decompressing more slowly -(roughly speaking, half the speed, but the maximum memory -requirement drops to around 2300k). See -for more information on memory management. - -Note that the amount of memory needed to decompress a -stream cannot be determined until the stream's header has been -read, so even if -BZ2_bzDecompressInit succeeds, a -subsequent BZ2_bzDecompress -could fail with -BZ_MEM_ERROR. - -Possible return values: - - -BZ_CONFIG_ERROR - if the library has been mis-compiled -BZ_PARAM_ERROR - if ( small != 0 && small != 1 ) - or (verbosity <; 0 || verbosity > 4) -BZ_MEM_ERROR - if insufficient memory is available - - -Allowable next actions: - - -BZ2_bzDecompress - if BZ_OK was returned - no specific action required in case of error - - - - - - -<computeroutput>BZ2_bzDecompress</computeroutput> - - -int BZ2_bzDecompress ( bz_stream *strm ); - - -Provides more input and/out output buffer space for the -library. The caller maintains input and output buffers, and uses -BZ2_bzDecompress to transfer -data between them. - -Before each call to -BZ2_bzDecompress, -next_in should point at the -compressed data, and avail_in -should indicate how many bytes the library may read. -BZ2_bzDecompress updates -next_in, -avail_in and -total_in to reflect the number -of bytes it has read. - -Similarly, next_out should -point to a buffer in which the uncompressed output is to be -placed, with avail_out -indicating how much output space is available. -BZ2_bzCompress updates -next_out, -avail_out and -total_out to reflect the number -of bytes output. - -You may provide and remove as little or as much data as you -like on each call of -BZ2_bzDecompress. In the limit, -it is acceptable to supply and remove data one byte at a time, -although this would be terribly inefficient. You should always -ensure that at least one byte of output space is available at -each call. - -Use of BZ2_bzDecompress is -simpler than -BZ2_bzCompress. - -You should provide input and remove output as described -above, and repeatedly call -BZ2_bzDecompress until -BZ_STREAM_END is returned. -Appearance of BZ_STREAM_END -denotes that BZ2_bzDecompress -has detected the logical end of the compressed stream. -BZ2_bzDecompress will not -produce BZ_STREAM_END until all -output data has been placed into the output buffer, so once -BZ_STREAM_END appears, you are -guaranteed to have available all the decompressed output, and -BZ2_bzDecompressEnd can safely -be called. - -If case of an error return value, you should call -BZ2_bzDecompressEnd to clean up -and release memory. - -Possible return values: - - -BZ_PARAM_ERROR - if strm is NULL or strm->s is NULL - or strm->avail_out < 1 -BZ_DATA_ERROR - if a data integrity error is detected in the compressed stream -BZ_DATA_ERROR_MAGIC - if the compressed stream doesn't begin with the right magic bytes -BZ_MEM_ERROR - if there wasn't enough memory available -BZ_STREAM_END - if the logical end of the data stream was detected and all - output in has been consumed, eg s-->avail_out > 0 -BZ_OK - otherwise - - -Allowable next actions: - - -BZ2_bzDecompress - if BZ_OK was returned -BZ2_bzDecompressEnd - otherwise - - - - - - -<computeroutput>BZ2_bzDecompressEnd</computeroutput> - - -int BZ2_bzDecompressEnd ( bz_stream *strm ); - - -Releases all memory associated with a decompression -stream. - -Possible return values: - - -BZ_PARAM_ERROR - if strm is NULL or strm->s is NULL -BZ_OK - otherwise - - -Allowable next actions: - - - None. - - - - - - - - -High-level interface - -This interface provides functions for reading and writing -bzip2 format files. First, some -general points. - - - - All of the functions take an - int* first argument, - bzerror. After each call, - bzerror should be consulted - first to determine the outcome of the call. If - bzerror is - BZ_OK, the call completed - successfully, and only then should the return value of the - function (if any) be consulted. If - bzerror is - BZ_IO_ERROR, there was an - error reading/writing the underlying compressed file, and you - should then consult errno / - perror to determine the cause - of the difficulty. bzerror - may also be set to various other values; precise details are - given on a per-function basis below. - - If bzerror indicates - an error (ie, anything except - BZ_OK and - BZ_STREAM_END), you should - immediately call - BZ2_bzReadClose (or - BZ2_bzWriteClose, depending on - whether you are attempting to read or to write) to free up all - resources associated with the stream. Once an error has been - indicated, behaviour of all calls except - BZ2_bzReadClose - (BZ2_bzWriteClose) is - undefined. The implication is that (1) - bzerror should be checked - after each call, and (2) if - bzerror indicates an error, - BZ2_bzReadClose - (BZ2_bzWriteClose) should then - be called to clean up. - - The FILE* arguments - passed to BZ2_bzReadOpen / - BZ2_bzWriteOpen should be set - to binary mode. Most Unix systems will do this by default, but - other platforms, including Windows and Mac, will not. If you - omit this, you may encounter problems when moving code to new - platforms. - - Memory allocation requests are handled by - malloc / - free. At present there is no - facility for user-defined memory allocators in the file I/O - functions (could easily be added, though). - - - - - - -<computeroutput>BZ2_bzReadOpen</computeroutput> - - -typedef void BZFILE; - -BZFILE *BZ2_bzReadOpen( int *bzerror, FILE *f, - int verbosity, int small, - void *unused, int nUnused ); - - -Prepare to read compressed data from file handle -f. -f should refer to a file which -has been opened for reading, and for which the error indicator -(ferror(f))is not set. If -small is 1, the library will try -to decompress using less memory, at the expense of speed. - -For reasons explained below, -BZ2_bzRead will decompress the -nUnused bytes starting at -unused, before starting to read -from the file f. At most -BZ_MAX_UNUSED bytes may be -supplied like this. If this facility is not required, you should -pass NULL and -0 for -unused and -nUnused respectively. - -For the meaning of parameters -small and -verbosity, see -BZ2_bzDecompressInit. - -The amount of memory needed to decompress a file cannot be -determined until the file's header has been read. So it is -possible that BZ2_bzReadOpen -returns BZ_OK but a subsequent -call of BZ2_bzRead will return -BZ_MEM_ERROR. - -Possible assignments to -bzerror: - - -BZ_CONFIG_ERROR - if the library has been mis-compiled -BZ_PARAM_ERROR - if f is NULL - or small is neither 0 nor 1 - or ( unused == NULL && nUnused != 0 ) - or ( unused != NULL && !(0 <= nUnused <= BZ_MAX_UNUSED) ) -BZ_IO_ERROR - if ferror(f) is nonzero -BZ_MEM_ERROR - if insufficient memory is available -BZ_OK - otherwise. - - -Possible return values: - - -Pointer to an abstract BZFILE - if bzerror is BZ_OK -NULL - otherwise - - -Allowable next actions: - - -BZ2_bzRead - if bzerror is BZ_OK -BZ2_bzClose - otherwise - - - - - - -<computeroutput>BZ2_bzRead</computeroutput> - - -int BZ2_bzRead ( int *bzerror, BZFILE *b, void *buf, int len ); - - -Reads up to len -(uncompressed) bytes from the compressed file -b into the buffer -buf. If the read was -successful, bzerror is set to -BZ_OK and the number of bytes -read is returned. If the logical end-of-stream was detected, -bzerror will be set to -BZ_STREAM_END, and the number of -bytes read is returned. All other -bzerror values denote an -error. - -BZ2_bzRead will supply -len bytes, unless the logical -stream end is detected or an error occurs. Because of this, it -is possible to detect the stream end by observing when the number -of bytes returned is less than the number requested. -Nevertheless, this is regarded as inadvisable; you should instead -check bzerror after every call -and watch out for -BZ_STREAM_END. - -Internally, BZ2_bzRead -copies data from the compressed file in chunks of size -BZ_MAX_UNUSED bytes before -decompressing it. If the file contains more bytes than strictly -needed to reach the logical end-of-stream, -BZ2_bzRead will almost certainly -read some of the trailing data before signalling -BZ_SEQUENCE_END. To collect the -read but unused data once -BZ_SEQUENCE_END has appeared, -call BZ2_bzReadGetUnused -immediately before -BZ2_bzReadClose. - -Possible assignments to -bzerror: - - -BZ_PARAM_ERROR - if b is NULL or buf is NULL or len < 0 -BZ_SEQUENCE_ERROR - if b was opened with BZ2_bzWriteOpen -BZ_IO_ERROR - if there is an error reading from the compressed file -BZ_UNEXPECTED_EOF - if the compressed file ended before - the logical end-of-stream was detected -BZ_DATA_ERROR - if a data integrity error was detected in the compressed stream -BZ_DATA_ERROR_MAGIC - if the stream does not begin with the requisite header bytes - (ie, is not a bzip2 data file). This is really - a special case of BZ_DATA_ERROR. -BZ_MEM_ERROR - if insufficient memory was available -BZ_STREAM_END - if the logical end of stream was detected. -BZ_OK - otherwise. - - -Possible return values: - - -number of bytes read - if bzerror is BZ_OK or BZ_STREAM_END -undefined - otherwise - - -Allowable next actions: - - -collect data from buf, then BZ2_bzRead or BZ2_bzReadClose - if bzerror is BZ_OK -collect data from buf, then BZ2_bzReadClose or BZ2_bzReadGetUnused - if bzerror is BZ_SEQUENCE_END -BZ2_bzReadClose - otherwise - - - - - - -<computeroutput>BZ2_bzReadGetUnused</computeroutput> - - -void BZ2_bzReadGetUnused( int* bzerror, BZFILE *b, - void** unused, int* nUnused ); - - -Returns data which was read from the compressed file but -was not needed to get to the logical end-of-stream. -*unused is set to the address of -the data, and *nUnused to the -number of bytes. *nUnused will -be set to a value between 0 and -BZ_MAX_UNUSED inclusive. - -This function may only be called once -BZ2_bzRead has signalled -BZ_STREAM_END but before -BZ2_bzReadClose. - -Possible assignments to -bzerror: - - -BZ_PARAM_ERROR - if b is NULL - or unused is NULL or nUnused is NULL -BZ_SEQUENCE_ERROR - if BZ_STREAM_END has not been signalled - or if b was opened with BZ2_bzWriteOpen -BZ_OK - otherwise - - -Allowable next actions: - - -BZ2_bzReadClose - - - - - - -<computeroutput>BZ2_bzReadClose</computeroutput> - - -void BZ2_bzReadClose ( int *bzerror, BZFILE *b ); - - -Releases all memory pertaining to the compressed file -b. -BZ2_bzReadClose does not call -fclose on the underlying file -handle, so you should do that yourself if appropriate. -BZ2_bzReadClose should be called -to clean up after all error situations. - -Possible assignments to -bzerror: - - -BZ_SEQUENCE_ERROR - if b was opened with BZ2_bzOpenWrite -BZ_OK - otherwise - - -Allowable next actions: - - -none - - - - - - -<computeroutput>BZ2_bzWriteOpen</computeroutput> - - -BZFILE *BZ2_bzWriteOpen( int *bzerror, FILE *f, - int blockSize100k, int verbosity, - int workFactor ); - - -Prepare to write compressed data to file handle -f. -f should refer to a file which -has been opened for writing, and for which the error indicator -(ferror(f))is not set. - -For the meaning of parameters -blockSize100k, -verbosity and -workFactor, see -BZ2_bzCompressInit. - -All required memory is allocated at this stage, so if the -call completes successfully, -BZ_MEM_ERROR cannot be signalled -by a subsequent call to -BZ2_bzWrite. - -Possible assignments to -bzerror: - - -BZ_CONFIG_ERROR - if the library has been mis-compiled -BZ_PARAM_ERROR - if f is NULL - or blockSize100k < 1 or blockSize100k > 9 -BZ_IO_ERROR - if ferror(f) is nonzero -BZ_MEM_ERROR - if insufficient memory is available -BZ_OK - otherwise - - -Possible return values: - - -Pointer to an abstract BZFILE - if bzerror is BZ_OK -NULL - otherwise - - -Allowable next actions: - - -BZ2_bzWrite - if bzerror is BZ_OK - (you could go directly to BZ2_bzWriteClose, but this would be pretty pointless) -BZ2_bzWriteClose - otherwise - - - - - - -<computeroutput>BZ2_bzWrite</computeroutput> - - -void BZ2_bzWrite ( int *bzerror, BZFILE *b, void *buf, int len ); - - -Absorbs len bytes from the -buffer buf, eventually to be -compressed and written to the file. - -Possible assignments to -bzerror: - - -BZ_PARAM_ERROR - if b is NULL or buf is NULL or len < 0 -BZ_SEQUENCE_ERROR - if b was opened with BZ2_bzReadOpen -BZ_IO_ERROR - if there is an error writing the compressed file. -BZ_OK - otherwise - - - - - - -<computeroutput>BZ2_bzWriteClose</computeroutput> - - -void BZ2_bzWriteClose( int *bzerror, BZFILE* f, - int abandon, - unsigned int* nbytes_in, - unsigned int* nbytes_out ); - -void BZ2_bzWriteClose64( int *bzerror, BZFILE* f, - int abandon, - unsigned int* nbytes_in_lo32, - unsigned int* nbytes_in_hi32, - unsigned int* nbytes_out_lo32, - unsigned int* nbytes_out_hi32 ); - - -Compresses and flushes to the compressed file all data so -far supplied by BZ2_bzWrite. -The logical end-of-stream markers are also written, so subsequent -calls to BZ2_bzWrite are -illegal. All memory associated with the compressed file -b is released. -fflush is called on the -compressed file, but it is not -fclose'd. - -If BZ2_bzWriteClose is -called to clean up after an error, the only action is to release -the memory. The library records the error codes issued by -previous calls, so this situation will be detected automatically. -There is no attempt to complete the compression operation, nor to -fflush the compressed file. You -can force this behaviour to happen even in the case of no error, -by passing a nonzero value to -abandon. - -If nbytes_in is non-null, -*nbytes_in will be set to be the -total volume of uncompressed data handled. Similarly, -nbytes_out will be set to the -total volume of compressed data written. For compatibility with -older versions of the library, -BZ2_bzWriteClose only yields the -lower 32 bits of these counts. Use -BZ2_bzWriteClose64 if you want -the full 64 bit counts. These two functions are otherwise -absolutely identical. - -Possible assignments to -bzerror: - - -BZ_SEQUENCE_ERROR - if b was opened with BZ2_bzReadOpen -BZ_IO_ERROR - if there is an error writing the compressed file -BZ_OK - otherwise - - - - - - -Handling embedded compressed data streams - -The high-level library facilitates use of -bzip2 data streams which form -some part of a surrounding, larger data stream. - - - - For writing, the library takes an open file handle, - writes compressed data to it, - fflushes it but does not - fclose it. The calling - application can write its own data before and after the - compressed data stream, using that same file handle. - - Reading is more complex, and the facilities are not as - general as they could be since generality is hard to reconcile - with efficiency. BZ2_bzRead - reads from the compressed file in blocks of size - BZ_MAX_UNUSED bytes, and in - doing so probably will overshoot the logical end of compressed - stream. To recover this data once decompression has ended, - call BZ2_bzReadGetUnused after - the last call of BZ2_bzRead - (the one returning - BZ_STREAM_END) but before - calling - BZ2_bzReadClose. - - - -This mechanism makes it easy to decompress multiple -bzip2 streams placed end-to-end. -As the end of one stream, when -BZ2_bzRead returns -BZ_STREAM_END, call -BZ2_bzReadGetUnused to collect -the unused data (copy it into your own buffer somewhere). That -data forms the start of the next compressed stream. To start -uncompressing that next stream, call -BZ2_bzReadOpen again, feeding in -the unused data via the unused / -nUnused parameters. Keep doing -this until BZ_STREAM_END return -coincides with the physical end of file -(feof(f)). In this situation -BZ2_bzReadGetUnused will of -course return no data. - -This should give some feel for how the high-level interface -can be used. If you require extra flexibility, you'll have to -bite the bullet and get to grips with the low-level -interface. - - - - - -Standard file-reading/writing code - -Here's how you'd write data to a compressed file: - - -FILE* f; -BZFILE* b; -int nBuf; -char buf[ /* whatever size you like */ ]; -int bzerror; -int nWritten; - -f = fopen ( "myfile.bz2", "w" ); -if ( !f ) { - /* handle error */ -} -b = BZ2_bzWriteOpen( &bzerror, f, 9 ); -if (bzerror != BZ_OK) { - BZ2_bzWriteClose ( b ); - /* handle error */ -} - -while ( /* condition */ ) { - /* get data to write into buf, and set nBuf appropriately */ - nWritten = BZ2_bzWrite ( &bzerror, b, buf, nBuf ); - if (bzerror == BZ_IO_ERROR) { - BZ2_bzWriteClose ( &bzerror, b ); - /* handle error */ - } -} - -BZ2_bzWriteClose( &bzerror, b ); -if (bzerror == BZ_IO_ERROR) { - /* handle error */ -} - - -And to read from a compressed file: - - -FILE* f; -BZFILE* b; -int nBuf; -char buf[ /* whatever size you like */ ]; -int bzerror; -int nWritten; - -f = fopen ( "myfile.bz2", "r" ); -if ( !f ) { - /* handle error */ -} -b = BZ2_bzReadOpen ( &bzerror, f, 0, NULL, 0 ); -if ( bzerror != BZ_OK ) { - BZ2_bzReadClose ( &bzerror, b ); - /* handle error */ -} - -bzerror = BZ_OK; -while ( bzerror == BZ_OK && /* arbitrary other conditions */) { - nBuf = BZ2_bzRead ( &bzerror, b, buf, /* size of buf */ ); - if ( bzerror == BZ_OK ) { - /* do something with buf[0 .. nBuf-1] */ - } -} -if ( bzerror != BZ_STREAM_END ) { - BZ2_bzReadClose ( &bzerror, b ); - /* handle error */ -} else { - BZ2_bzReadClose ( &bzerror ); -} - - - - - - - - -Utility functions - - - -<computeroutput>BZ2_bzBuffToBuffCompress</computeroutput> - - -int BZ2_bzBuffToBuffCompress( char* dest, - unsigned int* destLen, - char* source, - unsigned int sourceLen, - int blockSize100k, - int verbosity, - int workFactor ); - - -Attempts to compress the data in source[0 -.. sourceLen-1] into the destination buffer, -dest[0 .. *destLen-1]. If the -destination buffer is big enough, -*destLen is set to the size of -the compressed data, and BZ_OK -is returned. If the compressed data won't fit, -*destLen is unchanged, and -BZ_OUTBUFF_FULL is -returned. - -Compression in this manner is a one-shot event, done with a -single call to this function. The resulting compressed data is a -complete bzip2 format data -stream. There is no mechanism for making additional calls to -provide extra input data. If you want that kind of mechanism, -use the low-level interface. - -For the meaning of parameters -blockSize100k, -verbosity and -workFactor, see -BZ2_bzCompressInit. - -To guarantee that the compressed data will fit in its -buffer, allocate an output buffer of size 1% larger than the -uncompressed data, plus six hundred extra bytes. - -BZ2_bzBuffToBuffDecompress -will not write data at or beyond -dest[*destLen], even in case of -buffer overflow. - -Possible return values: - - -BZ_CONFIG_ERROR - if the library has been mis-compiled -BZ_PARAM_ERROR - if dest is NULL or destLen is NULL - or blockSize100k < 1 or blockSize100k > 9 - or verbosity < 0 or verbosity > 4 - or workFactor < 0 or workFactor > 250 -BZ_MEM_ERROR - if insufficient memory is available -BZ_OUTBUFF_FULL - if the size of the compressed data exceeds *destLen -BZ_OK - otherwise - - - - - - -<computeroutput>BZ2_bzBuffToBuffDecompress</computeroutput> - - -int BZ2_bzBuffToBuffDecompress( char* dest, - unsigned int* destLen, - char* source, - unsigned int sourceLen, - int small, - int verbosity ); - - -Attempts to decompress the data in source[0 -.. sourceLen-1] into the destination buffer, -dest[0 .. *destLen-1]. If the -destination buffer is big enough, -*destLen is set to the size of -the uncompressed data, and BZ_OK -is returned. If the compressed data won't fit, -*destLen is unchanged, and -BZ_OUTBUFF_FULL is -returned. - -source is assumed to hold -a complete bzip2 format data -stream. -BZ2_bzBuffToBuffDecompress tries -to decompress the entirety of the stream into the output -buffer. - -For the meaning of parameters -small and -verbosity, see -BZ2_bzDecompressInit. - -Because the compression ratio of the compressed data cannot -be known in advance, there is no easy way to guarantee that the -output buffer will be big enough. You may of course make -arrangements in your code to record the size of the uncompressed -data, but such a mechanism is beyond the scope of this -library. - -BZ2_bzBuffToBuffDecompress -will not write data at or beyond -dest[*destLen], even in case of -buffer overflow. - -Possible return values: - - -BZ_CONFIG_ERROR - if the library has been mis-compiled -BZ_PARAM_ERROR - if dest is NULL or destLen is NULL - or small != 0 && small != 1 - or verbosity < 0 or verbosity > 4 -BZ_MEM_ERROR - if insufficient memory is available -BZ_OUTBUFF_FULL - if the size of the compressed data exceeds *destLen -BZ_DATA_ERROR - if a data integrity error was detected in the compressed data -BZ_DATA_ERROR_MAGIC - if the compressed data doesn't begin with the right magic bytes -BZ_UNEXPECTED_EOF - if the compressed data ends unexpectedly -BZ_OK - otherwise - - - - - - - - -<computeroutput>zlib</computeroutput> compatibility functions - -Yoshioka Tsuneo has contributed some functions to give -better zlib compatibility. -These functions are BZ2_bzopen, -BZ2_bzread, -BZ2_bzwrite, -BZ2_bzflush, -BZ2_bzclose, -BZ2_bzerror and -BZ2_bzlibVersion. These -functions are not (yet) officially part of the library. If they -break, you get to keep all the pieces. Nevertheless, I think -they work ok. - - -typedef void BZFILE; - -const char * BZ2_bzlibVersion ( void ); - - -Returns a string indicating the library version. - - -BZFILE * BZ2_bzopen ( const char *path, const char *mode ); -BZFILE * BZ2_bzdopen ( int fd, const char *mode ); - - -Opens a .bz2 file for -reading or writing, using either its name or a pre-existing file -descriptor. Analogous to fopen -and fdopen. - - -int BZ2_bzread ( BZFILE* b, void* buf, int len ); -int BZ2_bzwrite ( BZFILE* b, void* buf, int len ); - - -Reads/writes data from/to a previously opened -BZFILE. Analogous to -fread and -fwrite. - - -int BZ2_bzflush ( BZFILE* b ); -void BZ2_bzclose ( BZFILE* b ); - - -Flushes/closes a BZFILE. -BZ2_bzflush doesn't actually do -anything. Analogous to fflush -and fclose. - - -const char * BZ2_bzerror ( BZFILE *b, int *errnum ) - - -Returns a string describing the more recent error status of -b, and also sets -*errnum to its numerical -value. - - - - - -Using the library in a <computeroutput>stdio</computeroutput>-free environment - - - -Getting rid of <computeroutput>stdio</computeroutput> - -In a deeply embedded application, you might want to use -just the memory-to-memory functions. You can do this -conveniently by compiling the library with preprocessor symbol -BZ_NO_STDIO defined. Doing this -gives you a library containing only the following eight -functions: - -BZ2_bzCompressInit, -BZ2_bzCompress, -BZ2_bzCompressEnd -BZ2_bzDecompressInit, -BZ2_bzDecompress, -BZ2_bzDecompressEnd -BZ2_bzBuffToBuffCompress, -BZ2_bzBuffToBuffDecompress - -When compiled like this, all functions will ignore -verbosity settings. - - - - - -Critical error handling - -libbzip2 contains a number -of internal assertion checks which should, needless to say, never -be activated. Nevertheless, if an assertion should fail, -behaviour depends on whether or not the library was compiled with -BZ_NO_STDIO set. - -For a normal compile, an assertion failure yields the -message: - -
-bzip2/libbzip2: internal error number N. -This is a bug in bzip2/libbzip2, &bz-version; of &bz-date;. -Please report it to me at: &bz-email;. If this happened -when you were using some program which uses libbzip2 as a -component, you should also report this bug to the author(s) -of that program. Please make an effort to report this bug; -timely and accurate bug reports eventually lead to higher -quality software. Thanks. Julian Seward, &bz-date;. -
- -where N is some error code -number. If N == 1007, it also -prints some extra text advising the reader that unreliable memory -is often associated with internal error 1007. (This is a -frequently-observed-phenomenon with versions 1.0.0/1.0.1). - -exit(3) is then -called. - -For a stdio-free library, -assertion failures result in a call to a function declared -as: - - -extern void bz_internal_error ( int errcode ); - - -The relevant code is passed as a parameter. You should -supply such a function. - -In either case, once an assertion failure has occurred, any -bz_stream records involved can -be regarded as invalid. You should not attempt to resume normal -operation with them. - -You may, of course, change critical error handling to suit -your needs. As I said above, critical errors indicate bugs in -the library and should not occur. All "normal" error situations -are indicated via error return codes from functions, and can be -recovered from. - -
- -
- - - -Making a Windows DLL - -Everything related to Windows has been contributed by -Yoshioka Tsuneo -(QWF00133@niftyserve.or.jp / -tsuneo-y@is.aist-nara.ac.jp), so -you should send your queries to him (but perhaps Cc: me, -&bz-email;). - -My vague understanding of what to do is: using Visual C++ -5.0, open the project file -libbz2.dsp, and build. That's -all. - -If you can't open the project file for some reason, make a -new one, naming these files: -blocksort.c, -bzlib.c, -compress.c, -crctable.c, -decompress.c, -huffman.c, -randtable.c and -libbz2.def. You will also need -to name the header files bzlib.h -and bzlib_private.h. - -If you don't use VC++, you may need to define the -proprocessor symbol -_WIN32. - -Finally, dlltest.c is a -sample program using the DLL. It has a project file, -dlltest.dsp. - -If you just want a makefile for Visual C, have a look at -makefile.msc. - -Be aware that if you compile -bzip2 itself on Win32, you must -set BZ_UNIX to 0 and -BZ_LCCWIN32 to 1, in the file -bzip2.c, before compiling. -Otherwise the resulting binary won't work correctly. - -I haven't tried any of this stuff myself, but it all looks -plausible. - - - -
- - - - -Miscellanea - -These are just some random thoughts of mine. Your mileage -may vary. - - - -Limitations of the compressed file format - -bzip2-1.0.X, -0.9.5 and -0.9.0 use exactly the same file -format as the original version, -bzip2-0.1. This decision was -made in the interests of stability. Creating yet another -incompatible compressed file format would create further -confusion and disruption for users. - -Nevertheless, this is not a painless decision. Development -work since the release of -bzip2-0.1 in August 1997 has -shown complexities in the file format which slow down -decompression and, in retrospect, are unnecessary. These -are: - - - - The run-length encoder, which is the first of the - compression transformations, is entirely irrelevant. The - original purpose was to protect the sorting algorithm from the - very worst case input: a string of repeated symbols. But - algorithm steps Q6a and Q6b in the original Burrows-Wheeler - technical report (SRC-124) show how repeats can be handled - without difficulty in block sorting. - - The randomisation mechanism doesn't really need to be - there. Udi Manber and Gene Myers published a suffix array - construction algorithm a few years back, which can be employed - to sort any block, no matter how repetitive, in O(N log N) - time. Subsequent work by Kunihiko Sadakane has produced a - derivative O(N (log N)^2) algorithm which usually outperforms - the Manber-Myers algorithm. - - I could have changed to Sadakane's algorithm, but I find - it to be slower than bzip2's - existing algorithm for most inputs, and the randomisation - mechanism protects adequately against bad cases. I didn't - think it was a good tradeoff to make. Partly this is due to - the fact that I was not flooded with email complaints about - bzip2-0.1's performance on - repetitive data, so perhaps it isn't a problem for real - inputs. - - Probably the best long-term solution, and the one I have - incorporated into 0.9.5 and above, is to use the existing - sorting algorithm initially, and fall back to a O(N (log N)^2) - algorithm if the standard algorithm gets into - difficulties. - - The compressed file format was never designed to be - handled by a library, and I have had to jump though some hoops - to produce an efficient implementation of decompression. It's - a bit hairy. Try passing - decompress.c through the C - preprocessor and you'll see what I mean. Much of this - complexity could have been avoided if the compressed size of - each block of data was recorded in the data stream. - - An Adler-32 checksum, rather than a CRC32 checksum, - would be faster to compute. - - - -It would be fair to say that the -bzip2 format was frozen before I -properly and fully understood the performance consequences of -doing so. - -Improvements which I was able to incorporate into 0.9.0, -despite using the same file format, are: - - - - Single array implementation of the inverse BWT. This - significantly speeds up decompression, presumably because it - reduces the number of cache misses. - - Faster inverse MTF transform for large MTF values. - The new implementation is based on the notion of sliding blocks - of values. - - bzip2-0.9.0 now reads - and writes files with fread - and fwrite; version 0.1 used - putc and - getc. Duh! Well, you live - and learn. - - - -Further ahead, it would be nice to be able to do random -access into files. This will require some careful design of -compressed file formats. - - - - - -Portability issues - -After some consideration, I have decided not to use GNU -autoconf to configure 0.9.5 or -1.0. - -autoconf, admirable and -wonderful though it is, mainly assists with portability problems -between Unix-like platforms. But -bzip2 doesn't have much in the -way of portability problems on Unix; most of the difficulties -appear when porting to the Mac, or to Microsoft's operating -systems. autoconf doesn't help -in those cases, and brings in a whole load of new -complexity. - -Most people should be able to compile the library and -program under Unix straight out-of-the-box, so to speak, -especially if you have a version of GNU C available. - -There are a couple of -__inline__ directives in the -code. GNU C (gcc) should be -able to handle them. If you're not using GNU C, your C compiler -shouldn't see them at all. If your compiler does, for some -reason, see them and doesn't like them, just -#define -__inline__ to be -/* */. One easy way to do this -is to compile with the flag --D__inline__=, which should be -understood by most Unix compilers. - -If you still have difficulties, try compiling with the -macro BZ_STRICT_ANSI defined. -This should enable you to build the library in a strictly ANSI -compliant environment. Building the program itself like this is -dangerous and not supported, since you remove -bzip2's checks against -compressing directories, symbolic links, devices, and other -not-really-a-file entities. This could cause filesystem -corruption! - -One other thing: if you create a -bzip2 binary for public distribution, -please consider linking it statically (gcc --static). This avoids all sorts of library-version -issues that others may encounter later on. - -If you build bzip2 on -Win32, you must set BZ_UNIX to 0 -and BZ_LCCWIN32 to 1, in the -file bzip2.c, before compiling. -Otherwise the resulting binary won't work correctly. - - - - - -Reporting bugs - -I tried pretty hard to make sure -bzip2 is bug free, both by -design and by testing. Hopefully you'll never need to read this -section for real. - -Nevertheless, if bzip2 dies -with a segmentation fault, a bus error or an internal assertion -failure, it will ask you to email me a bug report. Experience from -years of feedback of bzip2 users indicates that almost all these -problems can be traced to either compiler bugs or hardware -problems. - - - - Recompile the program with no optimisation, and - see if it works. And/or try a different compiler. I heard all - sorts of stories about various flavours of GNU C (and other - compilers) generating bad code for - bzip2, and I've run across two - such examples myself. - - 2.7.X versions of GNU C are known to generate bad code - from time to time, at high optimisation levels. If you get - problems, try using the flags - -O2 - -fomit-frame-pointer - -fno-strength-reduce. You - should specifically not use - -funroll-loops. - - You may notice that the Makefile runs six tests as part - of the build process. If the program passes all of these, it's - a pretty good (but not 100%) indication that the compiler has - done its job correctly. - - If bzip2 - crashes randomly, and the crashes are not repeatable, you may - have a flaky memory subsystem. - bzip2 really hammers your - memory hierarchy, and if it's a bit marginal, you may get these - problems. Ditto if your disk or I/O subsystem is slowly - failing. Yup, this really does happen. - - Try using a different machine of the same type, and see - if you can repeat the problem. - - This isn't really a bug, but ... If - bzip2 tells you your file is - corrupted on decompression, and you obtained the file via FTP, - there is a possibility that you forgot to tell FTP to do a - binary mode transfer. That absolutely will cause the file to - be non-decompressible. You'll have to transfer it - again. - - - -If you've incorporated -libbzip2 into your own program -and are getting problems, please, please, please, check that the -parameters you are passing in calls to the library, are correct, -and in accordance with what the documentation says is allowable. -I have tried to make the library robust against such problems, -but I'm sure I haven't succeeded. - -Finally, if the above comments don't help, you'll have to -send me a bug report. Now, it's just amazing how many people -will send me a bug report saying something like: - - -bzip2 crashed with segmentation fault on my machine - - -and absolutely nothing else. Needless to say, a such a -report is totally, utterly, completely and -comprehensively 100% useless; a waste of your time, my time, and -net bandwidth. With no details at all, there's no way -I can possibly begin to figure out what the problem is. - -The rules of the game are: facts, facts, facts. Don't omit -them because "oh, they won't be relevant". At the bare -minimum: - - -Machine type. Operating system version. -Exact version of bzip2 (do bzip2 -V). -Exact version of the compiler used. -Flags passed to the compiler. - - -However, the most important single thing that will help me -is the file that you were trying to compress or decompress at the -time the problem happened. Without that, my ability to do -anything more than speculate about the cause, is limited. - - - - - -Did you get the right package? - -bzip2 is a resource hog. -It soaks up large amounts of CPU cycles and memory. Also, it -gives very large latencies. In the worst case, you can feed many -megabytes of uncompressed data into the library before getting -any compressed output, so this probably rules out applications -requiring interactive behaviour. - -These aren't faults of my implementation, I hope, but more -an intrinsic property of the Burrows-Wheeler transform -(unfortunately). Maybe this isn't what you want. - -If you want a compressor and/or library which is faster, -uses less memory but gets pretty good compression, and has -minimal latency, consider Jean-loup Gailly's and Mark Adler's -work, zlib-1.2.1 and -gzip-1.2.4. Look for them at -http://www.zlib.org and -http://www.gzip.org -respectively. - -For something faster and lighter still, you might try Markus F -X J Oberhumer's LZO real-time -compression/decompression library, at -http://www.oberhumer.com/opensource. - - - - - - -Further Reading - -bzip2 is not research -work, in the sense that it doesn't present any new ideas. -Rather, it's an engineering exercise based on existing -ideas. - -Four documents describe essentially all the ideas behind -bzip2: - -Michael Burrows and D. J. Wheeler: - "A block-sorting lossless data compression algorithm" - 10th May 1994. - Digital SRC Research Report 124. - ftp://ftp.digital.com/pub/DEC/SRC/research-reports/SRC-124.ps.gz - If you have trouble finding it, try searching at the - New Zealand Digital Library, http://www.nzdl.org. - -Daniel S. Hirschberg and Debra A. LeLewer - "Efficient Decoding of Prefix Codes" - Communications of the ACM, April 1990, Vol 33, Number 4. - You might be able to get an electronic copy of this - from the ACM Digital Library. - -David J. Wheeler - Program bred3.c and accompanying document bred3.ps. - This contains the idea behind the multi-table Huffman coding scheme. - ftp://ftp.cl.cam.ac.uk/users/djw3/ - -Jon L. Bentley and Robert Sedgewick - "Fast Algorithms for Sorting and Searching Strings" - Available from Sedgewick's web page, - www.cs.princeton.edu/~rs - - -The following paper gives valuable additional insights into -the algorithm, but is not immediately the basis of any code used -in bzip2. - -Peter Fenwick: - Block Sorting Text Compression - Proceedings of the 19th Australasian Computer Science Conference, - Melbourne, Australia. Jan 31 - Feb 2, 1996. - ftp://ftp.cs.auckland.ac.nz/pub/peter-f/ACSC96paper.ps - -Kunihiko Sadakane's sorting algorithm, mentioned above, is -available from: - -http://naomi.is.s.u-tokyo.ac.jp/~sada/papers/Sada98b.ps.gz - - -The Manber-Myers suffix array construction algorithm is -described in a paper available from: - -http://www.cs.arizona.edu/people/gene/PAPERS/suffix.ps - - -Finally, the following papers document some -investigations I made into the performance of sorting -and decompression algorithms: - -Julian Seward - On the Performance of BWT Sorting Algorithms - Proceedings of the IEEE Data Compression Conference 2000 - Snowbird, Utah. 28-30 March 2000. - -Julian Seward - Space-time Tradeoffs in the Inverse B-W Transform - Proceedings of the IEEE Data Compression Conference 2001 - Snowbird, Utah. 27-29 March 2001. - - - - - - -
diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/mk251.c b/contrib/vmap_extractor_v2/stormlib/bzip2/mk251.c deleted file mode 100644 index 205778a84e6..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/mk251.c +++ /dev/null @@ -1,16 +0,0 @@ - -/* Spew out a long sequence of the byte 251. When fed to bzip2 - versions 1.0.0 or 1.0.1, causes it to die with internal error - 1007 in blocksort.c. This assertion misses an extremely rare - case, which is fixed in this version (1.0.2) and above. -*/ - -#include - -int main () -{ - int i; - for (i = 0; i < 48500000 ; i++) - putchar(251); - return 0; -} diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/randtable.c b/contrib/vmap_extractor_v2/stormlib/bzip2/randtable.c deleted file mode 100644 index 940462d693d..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/randtable.c +++ /dev/null @@ -1,124 +0,0 @@ - -/*-------------------------------------------------------------*/ -/*--- Table for randomising repetitive blocks ---*/ -/*--- randtable.c ---*/ -/*-------------------------------------------------------------*/ - -/*-- - This file is a part of bzip2 and/or libbzip2, a program and - library for lossless, block-sorting data compression. - - Copyright (C) 1996-2005 Julian R Seward. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - 2. 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. - - 3. Altered source versions must be plainly marked as such, and must - not be misrepresented as being the original software. - - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written - permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 THE AUTHOR 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. - - Julian Seward, Cambridge, UK. - jseward@bzip.org - bzip2/libbzip2 version 1.0 of 21 March 2000 - - This program is based on (at least) the work of: - Mike Burrows - David Wheeler - Peter Fenwick - Alistair Moffat - Radford Neal - Ian H. Witten - Robert Sedgewick - Jon L. Bentley - - For more information on these sources, see the manual. ---*/ - - -#include "bzlib_private.h" - - -/*---------------------------------------------*/ -Int32 BZ2_rNums[512] = { - 619, 720, 127, 481, 931, 816, 813, 233, 566, 247, - 985, 724, 205, 454, 863, 491, 741, 242, 949, 214, - 733, 859, 335, 708, 621, 574, 73, 654, 730, 472, - 419, 436, 278, 496, 867, 210, 399, 680, 480, 51, - 878, 465, 811, 169, 869, 675, 611, 697, 867, 561, - 862, 687, 507, 283, 482, 129, 807, 591, 733, 623, - 150, 238, 59, 379, 684, 877, 625, 169, 643, 105, - 170, 607, 520, 932, 727, 476, 693, 425, 174, 647, - 73, 122, 335, 530, 442, 853, 695, 249, 445, 515, - 909, 545, 703, 919, 874, 474, 882, 500, 594, 612, - 641, 801, 220, 162, 819, 984, 589, 513, 495, 799, - 161, 604, 958, 533, 221, 400, 386, 867, 600, 782, - 382, 596, 414, 171, 516, 375, 682, 485, 911, 276, - 98, 553, 163, 354, 666, 933, 424, 341, 533, 870, - 227, 730, 475, 186, 263, 647, 537, 686, 600, 224, - 469, 68, 770, 919, 190, 373, 294, 822, 808, 206, - 184, 943, 795, 384, 383, 461, 404, 758, 839, 887, - 715, 67, 618, 276, 204, 918, 873, 777, 604, 560, - 951, 160, 578, 722, 79, 804, 96, 409, 713, 940, - 652, 934, 970, 447, 318, 353, 859, 672, 112, 785, - 645, 863, 803, 350, 139, 93, 354, 99, 820, 908, - 609, 772, 154, 274, 580, 184, 79, 626, 630, 742, - 653, 282, 762, 623, 680, 81, 927, 626, 789, 125, - 411, 521, 938, 300, 821, 78, 343, 175, 128, 250, - 170, 774, 972, 275, 999, 639, 495, 78, 352, 126, - 857, 956, 358, 619, 580, 124, 737, 594, 701, 612, - 669, 112, 134, 694, 363, 992, 809, 743, 168, 974, - 944, 375, 748, 52, 600, 747, 642, 182, 862, 81, - 344, 805, 988, 739, 511, 655, 814, 334, 249, 515, - 897, 955, 664, 981, 649, 113, 974, 459, 893, 228, - 433, 837, 553, 268, 926, 240, 102, 654, 459, 51, - 686, 754, 806, 760, 493, 403, 415, 394, 687, 700, - 946, 670, 656, 610, 738, 392, 760, 799, 887, 653, - 978, 321, 576, 617, 626, 502, 894, 679, 243, 440, - 680, 879, 194, 572, 640, 724, 926, 56, 204, 700, - 707, 151, 457, 449, 797, 195, 791, 558, 945, 679, - 297, 59, 87, 824, 713, 663, 412, 693, 342, 606, - 134, 108, 571, 364, 631, 212, 174, 643, 304, 329, - 343, 97, 430, 751, 497, 314, 983, 374, 822, 928, - 140, 206, 73, 263, 980, 736, 876, 478, 430, 305, - 170, 514, 364, 692, 829, 82, 855, 953, 676, 246, - 369, 970, 294, 750, 807, 827, 150, 790, 288, 923, - 804, 378, 215, 828, 592, 281, 565, 555, 710, 82, - 896, 831, 547, 261, 524, 462, 293, 465, 502, 56, - 661, 821, 976, 991, 658, 869, 905, 758, 745, 193, - 768, 550, 608, 933, 378, 286, 215, 979, 792, 961, - 61, 688, 793, 644, 986, 403, 106, 366, 905, 644, - 372, 567, 466, 434, 645, 210, 389, 550, 919, 135, - 780, 773, 635, 389, 707, 100, 626, 958, 165, 504, - 920, 176, 193, 713, 857, 265, 203, 50, 668, 108, - 645, 990, 626, 197, 510, 357, 358, 850, 858, 364, - 936, 638 -}; - - -/*-------------------------------------------------------------*/ -/*--- end randtable.c ---*/ -/*-------------------------------------------------------------*/ diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/sample1.bz2 b/contrib/vmap_extractor_v2/stormlib/bzip2/sample1.bz2 deleted file mode 100644 index 18dea60043b..00000000000 Binary files a/contrib/vmap_extractor_v2/stormlib/bzip2/sample1.bz2 and /dev/null differ diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/sample1.ref b/contrib/vmap_extractor_v2/stormlib/bzip2/sample1.ref deleted file mode 100644 index a56e52b77f9..00000000000 Binary files a/contrib/vmap_extractor_v2/stormlib/bzip2/sample1.ref and /dev/null differ diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/sample2.bz2 b/contrib/vmap_extractor_v2/stormlib/bzip2/sample2.bz2 deleted file mode 100644 index d5a6160ba20..00000000000 Binary files a/contrib/vmap_extractor_v2/stormlib/bzip2/sample2.bz2 and /dev/null differ diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/sample2.ref b/contrib/vmap_extractor_v2/stormlib/bzip2/sample2.ref deleted file mode 100644 index 34af95839a0..00000000000 Binary files a/contrib/vmap_extractor_v2/stormlib/bzip2/sample2.ref and /dev/null differ diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/sample3.bz2 b/contrib/vmap_extractor_v2/stormlib/bzip2/sample3.bz2 deleted file mode 100644 index d90cff9208f..00000000000 Binary files a/contrib/vmap_extractor_v2/stormlib/bzip2/sample3.bz2 and /dev/null differ diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/sample3.ref b/contrib/vmap_extractor_v2/stormlib/bzip2/sample3.ref deleted file mode 100644 index 775a2f68e21..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/sample3.ref +++ /dev/null @@ -1,30007 +0,0 @@ -This file is exceedingly boring. If you find yourself -reading it, please (1) take it from me that you can safely -guess what the rest of the file says, and (2) seek professional -help. - -ps. there are no further sarcastic remarks in this file. - -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh -ugh diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/spewG.c b/contrib/vmap_extractor_v2/stormlib/bzip2/spewG.c deleted file mode 100644 index 7934e765818..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/spewG.c +++ /dev/null @@ -1,39 +0,0 @@ - -/* spew out a thoroughly gigantic file designed so that bzip2 - can compress it reasonably rapidly. This is to help test - support for large files (> 2GB) in a reasonable amount of time. - I suggest you use the undocumented --exponential option to - bzip2 when compressing the resulting file; this saves a bit of - time. Note: *don't* bother with --exponential when compressing - Real Files; it'll just waste a lot of CPU time :-) - (but is otherwise harmless). -*/ - -#define _FILE_OFFSET_BITS 64 - -#include -#include - -/* The number of megabytes of junk to spew out (roughly) */ -#define MEGABYTES 5000 - -#define N_BUF 1000000 -char buf[N_BUF]; - -int main ( int argc, char** argv ) -{ - int ii, kk, p; - srandom(1); - setbuffer ( stdout, buf, N_BUF ); - for (kk = 0; kk < MEGABYTES * 515; kk+=3) { - p = 25+random()%50; - for (ii = 0; ii < p; ii++) - printf ( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ); - for (ii = 0; ii < p-1; ii++) - printf ( "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" ); - for (ii = 0; ii < p+1; ii++) - printf ( "ccccccccccccccccccccccccccccccccccccc" ); - } - fflush(stdout); - return 0; -} diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/unzcrash.c b/contrib/vmap_extractor_v2/stormlib/bzip2/unzcrash.c deleted file mode 100644 index f0f17fcca53..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/unzcrash.c +++ /dev/null @@ -1,126 +0,0 @@ - -/* A test program written to test robustness to decompression of - corrupted data. Usage is - unzcrash filename - and the program will read the specified file, compress it (in memory), - and then repeatedly decompress it, each time with a different bit of - the compressed data inverted, so as to test all possible one-bit errors. - This should not cause any invalid memory accesses. If it does, - I want to know about it! - - p.s. As you can see from the above description, the process is - incredibly slow. A file of size eg 5KB will cause it to run for - many hours. -*/ - -#include -#include -#include "bzlib.h" - -#define M_BLOCK 1000000 - -typedef unsigned char uchar; - -#define M_BLOCK_OUT (M_BLOCK + 1000000) -uchar inbuf[M_BLOCK]; -uchar outbuf[M_BLOCK_OUT]; -uchar zbuf[M_BLOCK + 600 + (M_BLOCK / 100)]; - -int nIn, nOut, nZ; - -static char *bzerrorstrings[] = { - "OK" - ,"SEQUENCE_ERROR" - ,"PARAM_ERROR" - ,"MEM_ERROR" - ,"DATA_ERROR" - ,"DATA_ERROR_MAGIC" - ,"IO_ERROR" - ,"UNEXPECTED_EOF" - ,"OUTBUFF_FULL" - ,"???" /* for future */ - ,"???" /* for future */ - ,"???" /* for future */ - ,"???" /* for future */ - ,"???" /* for future */ - ,"???" /* for future */ -}; - -void flip_bit ( int bit ) -{ - int byteno = bit / 8; - int bitno = bit % 8; - uchar mask = 1 << bitno; - //fprintf ( stderr, "(byte %d bit %d mask %d)", - // byteno, bitno, (int)mask ); - zbuf[byteno] ^= mask; -} - -int main ( int argc, char** argv ) -{ - FILE* f; - int r; - int bit; - int i; - - if (argc != 2) { - fprintf ( stderr, "usage: unzcrash filename\n" ); - return 1; - } - - f = fopen ( argv[1], "r" ); - if (!f) { - fprintf ( stderr, "unzcrash: can't open %s\n", argv[1] ); - return 1; - } - - nIn = fread ( inbuf, 1, M_BLOCK, f ); - fprintf ( stderr, "%d bytes read\n", nIn ); - - nZ = M_BLOCK; - r = BZ2_bzBuffToBuffCompress ( - zbuf, &nZ, inbuf, nIn, 9, 0, 30 ); - - assert (r == BZ_OK); - fprintf ( stderr, "%d after compression\n", nZ ); - - for (bit = 0; bit < nZ*8; bit++) { - fprintf ( stderr, "bit %d ", bit ); - flip_bit ( bit ); - nOut = M_BLOCK_OUT; - r = BZ2_bzBuffToBuffDecompress ( - outbuf, &nOut, zbuf, nZ, 0, 0 ); - fprintf ( stderr, " %d %s ", r, bzerrorstrings[-r] ); - - if (r != BZ_OK) { - fprintf ( stderr, "\n" ); - } else { - if (nOut != nIn) { - fprintf(stderr, "nIn/nOut mismatch %d %d\n", nIn, nOut ); - return 1; - } else { - for (i = 0; i < nOut; i++) - if (inbuf[i] != outbuf[i]) { - fprintf(stderr, "mismatch at %d\n", i ); - return 1; - } - if (i == nOut) fprintf(stderr, "really ok!\n" ); - } - } - - flip_bit ( bit ); - } - -#if 0 - assert (nOut == nIn); - for (i = 0; i < nOut; i++) { - if (inbuf[i] != outbuf[i]) { - fprintf ( stderr, "difference at %d !\n", i ); - return 1; - } - } -#endif - - fprintf ( stderr, "all ok\n" ); - return 0; -} diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/words0 b/contrib/vmap_extractor_v2/stormlib/bzip2/words0 deleted file mode 100644 index 164a8ed287a..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/words0 +++ /dev/null @@ -1,5 +0,0 @@ - -If compilation produces errors, or a large number of warnings, -please read README.COMPILATION.PROBLEMS -- you might be able to -adjust the flags in this Makefile to improve matters. - diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/words1 b/contrib/vmap_extractor_v2/stormlib/bzip2/words1 deleted file mode 100644 index 2e83de9f083..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/words1 +++ /dev/null @@ -1,4 +0,0 @@ - -Doing 6 tests (3 compress, 3 uncompress) ... -If there's a problem, things might stop at this point. - diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/words2 b/contrib/vmap_extractor_v2/stormlib/bzip2/words2 deleted file mode 100644 index 203ee39c4c2..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/words2 +++ /dev/null @@ -1,5 +0,0 @@ - -Checking test results. If any of the four "cmp"s which follow -report any differences, something is wrong. If you can't easily -figure out what, please let me know (jseward@acm.org). - diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/words3 b/contrib/vmap_extractor_v2/stormlib/bzip2/words3 deleted file mode 100644 index 7a6b462443c..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/words3 +++ /dev/null @@ -1,23 +0,0 @@ - -If you got this far and the "cmp"s didn't complain, it looks -like you're in business. - -To install in /usr/bin, /usr/lib, /usr/man and /usr/include, type - make install -To install somewhere else, eg, /xxx/yyy/{bin,lib,man,include}, type - make install PREFIX=/xxx/yyy -If you are (justifiably) paranoid and want to see what 'make install' -is going to do, you can first do - make -n install or - make -n install PREFIX=/xxx/yyy respectively. -The -n instructs make to show the commands it would execute, but -not actually execute them. - -Instructions for use are in the preformatted manual page, in the file -bzip2.txt. For more detailed documentation, read the full manual. -It is available in Postscript form (manual.ps), PDF form (manual.pdf), -and HTML form (manual_toc.html). - -You can also do "bzip2 --help" to see some helpful information. -"bzip2 -L" displays the software license. - diff --git a/contrib/vmap_extractor_v2/stormlib/bzip2/xmlproc.sh b/contrib/vmap_extractor_v2/stormlib/bzip2/xmlproc.sh deleted file mode 100644 index 6fe4d5748bb..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/bzip2/xmlproc.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/bash -# see the README in this directory for usage etc. - -usage() { - echo ''; - echo 'Usage: xmlproc.sh -[option] '; - echo 'Specify a target from:'; - echo '-v verify xml file conforms to dtd'; - echo '-html output in html format (single file)'; - echo '-ps output in postscript format'; - echo '-pdf output in pdf format'; - exit; -} - -if test $# -ne 2; then - usage -fi -# assign the variable for the output type -action=$1; shift -# assign the output filename -xmlfile=$1; shift -# and check user input it correct -if !(test -f $xmlfile); then - echo "No such file: $xmlfile"; - exit; -fi -# some other stuff we will use -OUT=output -xsl_fo=bz-fo.xsl -xsl_html=bz-html.xsl - -basename=$xmlfile -basename=${basename//'.xml'/''} - -fofile="${basename}.fo" -htmlfile="${basename}.html" -pdffile="${basename}.pdf" -psfile="${basename}.ps" -xmlfmtfile="${basename}.fmt" - -# first process the xmlfile with CDATA tags -./format.pl $xmlfile $xmlfmtfile -# so the shell knows where the catalogs live -export XML_CATALOG_FILES=/etc/xml/catalog - -# post-processing tidy up -cleanup() { - echo "Cleaning up: # $@" - while [ $# != 0 ] - do - arg=$1; shift; - echo " deleting $arg"; - rm $arg - done -} - -case $action in - -v) - flags='--noout --xinclude --noblanks --postvalid' - dtd='--dtdvalid http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd' - xmllint $flags $dtd $xmlfmtfile 2> $OUT - egrep 'error' $OUT - rm $OUT - ;; - - -html) - echo "Creating $htmlfile ..." - xsltproc --nonet --xinclude -o $htmlfile $xsl_html $xmlfmtfile - cleanup $xmlfmtfile - ;; - - -pdf) - echo "Creating $pdffile ..." - xsltproc --nonet --xinclude -o $fofile $xsl_fo $xmlfmtfile - pdfxmltex $fofile >$OUT $OUT $OUT $OUT $OUT $OUT $OUT $OUT $OUT 0x80000000) */ -/*****************************************************************************/ - -#include -#include - -#include "huff.h" - -// Special for Mac - we have to know if normal pointer greater or less -// than 0x80000000. This variable is used in the PTR_VALID and PTR_INVALID -// macros -static long mul = 1; - -#define PTR_VALID(ptr) (((LONG_PTR)(ptr) * mul) > 0) -#define PTR_INVALID(ptr) (((LONG_PTR)(ptr) * mul) < 0) -#define PTR_INVALID_OR_NULL(ptr) (((LONG_PTR)(ptr) * mul) <= 0) - - -//----------------------------------------------------------------------------- -// Methods of the THTreeItem struct - -// 1501DB70 -THTreeItem * THTreeItem::Call1501DB70(THTreeItem * pLast) -{ - if(pLast == NULL) - pLast = this + 1; - return pLast; -} - -// Gets previous Huffman tree item (?) -THTreeItem * THTreeItem::GetPrevItem(LONG_PTR value) -{ - if(PTR_INVALID(prev)) - return PTR_NOT(prev); - - if(value == -1 || PTR_INVALID(value)) - value = (long)(this - next->prev); - return prev + value; - -// OLD VERSION -// if(PTR_INT(value) < 0) -// value = PTR_INT((item - item->next->prev)); -// return (THTreeItem *)((char *)prev + value); -} - -// 1500F5E0 -void THTreeItem::ClearItemLinks() -{ - next = prev = NULL; -} - -// 1500BC90 -void THTreeItem::RemoveItem() -{ - THTreeItem * pTemp; // EDX - - if(next != NULL) - { - pTemp = prev; - - if(PTR_INVALID_OR_NULL(pTemp)) - pTemp = PTR_NOT(pTemp); - else - pTemp += (this - next->prev); - - pTemp->next = next; - next->prev = prev; - next = prev = NULL; - } -} - -/* -// OLD VERSION : Removes item from the tree (?) -static void RemoveItem(THTreeItem * item) -{ - THTreeItem * next = item->next; // ESI - THTreeItem * prev = item->prev; // EDX - - if(next == NULL) - return; - - if(PTR_INT(prev) < 0) - prev = PTR_NOT(prev); - else - // ??? usually item == next->prev, so what is it ? - prev = (THTreeItem *)((unsigned char *)prev + (unsigned long)((unsigned char *)item - (unsigned char *)(next->prev))); - - // Remove HTree item from the chain - prev->next = next; // Sets the 'first' pointer - next->prev = item->prev; - - // Invalidate pointers - item->next = NULL; - item->prev = NULL; -} -*/ - -//----------------------------------------------------------------------------- -// TOutputStream functions - -void TOutputStream::PutBits(unsigned long dwBuff, unsigned int nPutBits) -{ - dwBitBuff |= (dwBuff << nBits); - nBits += nPutBits; - - // Flush completed bytes - while(nBits >= 8) - { - if(dwOutSize != 0) - { - *pbOutPos++ = (unsigned char)dwBitBuff; - dwOutSize--; - } - - dwBitBuff >>= 8; - nBits -= 8; - } -} - -//----------------------------------------------------------------------------- -// TInputStream functions - -// Gets one bit from input stream -unsigned long TInputStream::GetBit() -{ - unsigned long dwBit = (dwBitBuff & 1); - - dwBitBuff >>= 1; - if(--nBits == 0) - { - dwBitBuff = BSWAP_INT32_UNSIGNED(*(unsigned long *)pbInBuffer); - pbInBuffer += sizeof(unsigned long); - nBits = 32; - } - return dwBit; -} - -// Gets 7 bits from the stream -unsigned long TInputStream::Get7Bits() -{ - if(nBits <= 7) - { - dwBitBuff |= BSWAP_INT16_UNSIGNED(*(unsigned short *)pbInBuffer) << nBits; - pbInBuffer += sizeof(unsigned short); - nBits += 16; - } - - // Get 7 bits from input stream - return (dwBitBuff & 0x7F); -} - -// Gets the whole byte from the input stream. -unsigned long TInputStream::Get8Bits() -{ - unsigned long dwOneByte; - - if(nBits <= 8) - { - dwBitBuff |= BSWAP_INT16_UNSIGNED(*(unsigned short *)pbInBuffer) << nBits; - pbInBuffer += sizeof(unsigned short); - nBits += 16; - } - - dwOneByte = (dwBitBuff & 0xFF); - dwBitBuff >>= 8; - nBits -= 8; - return dwOneByte; -} - -//----------------------------------------------------------------------------- -// Functions for huffmann tree items - -// Inserts item into the tree (?) -static void InsertItem(THTreeItem ** itemPtr, THTreeItem * item, unsigned long where, THTreeItem * item2) -{ - THTreeItem * next = item->next; // EDI - next to the first item - THTreeItem * prev = item->prev; // ESI - prev to the first item - THTreeItem * prev2; // Pointer to previous item - LONG_PTR next2; // Pointer to the next item - - // The same code like in RemoveItem(item); - if(next != 0) // If the first item already has next one - { - if(PTR_INVALID(prev)) - prev = PTR_NOT(prev); - else - prev += (item - next->prev); - - // 150083C1 - // Remove the item from the tree - prev->next = next; - next->prev = prev; - - // Invalidate 'prev' and 'next' pointer - item->next = 0; - item->prev = 0; - } - - if(item2 == NULL) // EDX - If the second item is not entered, - item2 = PTR_PTR(&itemPtr[1]); // take the first tree item - - switch(where) - { - case SWITCH_ITEMS : // Switch the two items - item->next = item2->next; // item2->next (Pointer to pointer to first) - item->prev = item2->next->prev; - item2->next->prev = item; - item2->next = item; // Set the first item - return; - - case INSERT_ITEM: // Insert as the last item - item->next = item2; // Set next item (or pointer to pointer to first item) - item->prev = item2->prev; // Set prev item (or last item in the tree) - - next2 = PTR_INT(itemPtr[0]);// Usually NULL - prev2 = item2->prev; // Prev item to the second (or last tree item) - - if(PTR_INVALID(prev2)) - { - prev2 = PTR_NOT(prev); - - prev2->next = item; - item2->prev = item; // Next after last item - return; - } - - if(PTR_INVALID(next2)) - next2 = (long)(item2 - item2->next->prev); -// next2 = (THTreeItem *)(unsigned long)((unsigned char *)item2 - (unsigned char *)(item2->next->prev)); - -// prev2 = (THTreeItem *)((char *)prev2 + (unsigned long)next2);// ??? - prev2 += next2; - prev2->next = item; - item2->prev = item; // Set the next/last item - return; - - default: - return; - } -} - -//----------------------------------------------------------------------------- -// THuffmannTree class functions - -THuffmannTree::THuffmannTree() -{ - // We have to check if the "this" pointer is less than zero - if((LONG_PTR)this < 0) - mul = -1; -} - -void THuffmannTree::InitTree(bool bCompression) -{ - THTreeItem * pItem; - unsigned int nCount; - - // Clear links for all the items in the tree - for(pItem = items0008, nCount = 0x203; nCount != 0; pItem++, nCount--) - pItem->ClearItemLinks(); - - pItem3050 = NULL; - pItem3054 = PTR_PTR(&pItem3054); - pItem3058 = PTR_NOT(pItem3054); - - pItem305C = NULL; - pFirst = PTR_PTR(&pFirst); - pLast = PTR_NOT(pFirst); - - offs0004 = 1; - nItems = 0; - - // Clear all TQDecompress items. Do this only if preparing for decompression - if(bCompression == false) - { - for(nCount = 0; nCount < sizeof(qd3474) / sizeof(TQDecompress); nCount++) - qd3474[nCount].offs00 = 0; - } -} - -// Builds Huffman tree. Called with the first 8 bits loaded from input stream -void THuffmannTree::BuildTree(unsigned int nCmpType) -{ - unsigned long maxByte; // [ESP+10] - The greatest character found in table - THTreeItem ** itemPtr; // [ESP+14] - Pointer to Huffman tree item pointer array - unsigned char * byteArray; // [ESP+1C] - Pointer to unsigned char in Table1502A630 - THTreeItem * child1; - unsigned long i; // egcs in linux doesn't like multiple for loops without an explicit i - - // Loop while pointer has a valid value - while(PTR_VALID(pLast)) // ESI - Last entry - { - THTreeItem * temp; // EAX - - if(pLast->next != NULL) // ESI->next - pLast->RemoveItem(); - // EDI = &offs3054 - pItem3058 = PTR_PTR(&pItem3054);// [EDI+4] - pLast->prev = pItem3058; // EAX - - temp = PTR_PTR(&pItem3054)->GetPrevItem(PTR_INT(&pItem3050)); - - temp->next = pLast; - pItem3054 = pLast; - } - - // Clear all pointers in HTree item array - memset(items306C, 0, sizeof(items306C)); - - maxByte = 0; // Greatest character found init to zero. - itemPtr = (THTreeItem **)&items306C; // Pointer to current entry in HTree item pointer array - - // Ensure we have low 8 bits only - nCmpType &= 0xFF; - byteArray = Table1502A630 + nCmpType * 258; // EDI also - - for(i = 0; i < 0x100; i++, itemPtr++) - { - THTreeItem * item = pItem3058; // Item to be created - THTreeItem * pItem3 = pItem3058; - unsigned char oneByte = byteArray[i]; - - // Skip all the bytes which are zero. - if(byteArray[i] == 0) - continue; - - // If not valid pointer, take the first available item in the array - if(PTR_INVALID_OR_NULL(item)) - item = &items0008[nItems++]; - - // Insert this item as the top of the tree - InsertItem(&pItem305C, item, SWITCH_ITEMS, NULL); - - item->parent = NULL; // Invalidate child and parent - item->child = NULL; - *itemPtr = item; // Store pointer into pointer array - - item->dcmpByte = i; // Store counter - item->byteValue = oneByte; // Store byte value - if(oneByte >= maxByte) - { - maxByte = oneByte; - continue; - } - - // Find the first item which has byte value greater than current one byte - if(PTR_VALID(pItem3 = pLast)) // EDI - Pointer to the last item - { - // 15006AF7 - if(pItem3 != NULL) - { - do // 15006AFB - { - if(pItem3->byteValue >= oneByte) - goto _15006B09; - pItem3 = pItem3->prev; - } - while(PTR_VALID(pItem3)); - } - } - pItem3 = NULL; - - // 15006B09 - _15006B09: - if(item->next != NULL) - item->RemoveItem(); - - // 15006B15 - if(pItem3 == NULL) - pItem3 = PTR_PTR(&pFirst); - - // 15006B1F - item->next = pItem3->next; - item->prev = pItem3->next->prev; - pItem3->next->prev = item; - pItem3->next = item; - } - - // 15006B4A - for(; i < 0x102; i++) - { - THTreeItem ** itemPtr = &items306C[i]; // EDI - - // 15006B59 - THTreeItem * item = pItem3058; // ESI - if(PTR_INVALID_OR_NULL(item)) - item = &items0008[nItems++]; - - InsertItem(&pItem305C, item, INSERT_ITEM, NULL); - - // 15006B89 - item->dcmpByte = i; - item->byteValue = 1; - item->parent = NULL; - item->child = NULL; - *itemPtr++ = item; - } - - // 15006BAA - if(PTR_VALID(child1 = pLast)) // EDI - last item (first child to item - { - THTreeItem * child2; // EBP - THTreeItem * item; // ESI - - // 15006BB8 - while(PTR_VALID(child2 = child1->prev)) - { - if(PTR_INVALID_OR_NULL(item = pItem3058)) - item = &items0008[nItems++]; - - // 15006BE3 - InsertItem(&pItem305C, item, SWITCH_ITEMS, NULL); - - // 15006BF3 - item->parent = NULL; - item->child = NULL; - - //EDX = child2->byteValue + child1->byteValue; - //EAX = child1->byteValue; - //ECX = maxByte; // The greatest character (0xFF usually) - - item->byteValue = child1->byteValue + child2->byteValue; // 0x02 - item->child = child1; // Prev item in the - child1->parent = item; - child2->parent = item; - - // EAX = item->byteValue; - if(item->byteValue >= maxByte) - maxByte = item->byteValue; - else - { - THTreeItem * pItem2 = child2->prev; // EDI - - // 15006C2D - while(PTR_VALID(pItem2)) - { - if(pItem2->byteValue >= item->byteValue) - goto _15006C3B; - pItem2 = pItem2->prev; - } - pItem2 = NULL; - - _15006C3B: - if(item->next != 0) - { - THTreeItem * temp4 = item->GetPrevItem(-1); - - temp4->next = item->next; // The first item changed - item->next->prev = item->prev; // First->prev changed to negative value - item->next = NULL; - item->prev = NULL; - } - - // 15006C62 - if(pItem2 == NULL) - pItem2 = PTR_PTR(&pFirst); - - item->next = pItem2->next; // Set item with 0x100 byte value - item->prev = pItem2->next->prev; // Set item with 0x17 byte value - pItem2->next->prev = item; // Changed prev of item with - pItem2->next = item; - } - - // 15006C7B - if(PTR_INVALID_OR_NULL(child1 = child2->prev)) - break; - } - } - // 15006C88 - offs0004 = 1; -} -/* -// Modifies Huffman tree. Adds new item and changes -void THuffmannTree::ModifyTree(unsigned long dwIndex) -{ - THTreeItem * pItem1 = pItem3058; // ESI - THTreeItem * pSaveLast = (PTR_INT(pLast) <= 0) ? NULL : pLast; // EBX - THTreeItem * temp; // EAX - - // Prepare the first item to insert to the tree - if(PTR_INT(pItem1) <= 0) - pItem1 = &items0008[nItems++]; - - // If item has any next item, remove it from the chain - if(pItem1->next != NULL) - { - THTreeItem * temp = pItem1->GetPrevItem(-1); // EAX - - temp->next = pItem1->next; - pItem1->next->prev = pItem1->prev; - pItem1->next = NULL; - pItem1->prev = NULL; - } - - pItem1->next = PTR_PTR(&pFirst); - pItem1->prev = pLast; - temp = pItem1->next->GetPrevItem(PTR_INT(pItem305C)); - - // 150068E9 - temp->next = pItem1; - pLast = pItem1; - - pItem1->parent = NULL; - pItem1->child = NULL; - - // 150068F6 - pItem1->dcmpByte = pSaveLast->dcmpByte; // Copy item index - pItem1->byteValue = pSaveLast->byteValue; // Copy item byte value - pItem1->parent = pSaveLast; // Set parent to last item - items306C[pSaveLast->dcmpByte] = pItem1; // Insert item into item pointer array - - // Prepare the second item to insert into the tree - if(PTR_INT((pItem1 = pItem3058)) <= 0) - pItem1 = &items0008[nItems++]; - - // 1500692E - if(pItem1->next != NULL) - { - temp = pItem1->GetPrevItem(-1); // EAX - - temp->next = pItem1->next; - pItem1->next->prev = pItem1->prev; - pItem1->next = NULL; - pItem1->prev = NULL; - } - // 1500694C - pItem1->next = PTR_PTR(&pFirst); - pItem1->prev = pLast; - temp = pItem1->next->GetPrevItem(PTR_INT(pItem305C)); - - // 15006968 - temp->next = pItem1; - pLast = pItem1; - - // 1500696E - pItem1->child = NULL; - pItem1->dcmpByte = dwIndex; - pItem1->byteValue = 0; - pItem1->parent = pSaveLast; - pSaveLast->child = pItem1; - items306C[dwIndex] = pItem1; - - do - { - THTreeItem * pItem2 = pItem1; - THTreeItem * pItem3; - unsigned long byteValue; - - // 15006993 - byteValue = ++pItem1->byteValue; - - // Pass through all previous which have its value greater than byteValue - while(PTR_INT((pItem3 = pItem2->prev)) > 0) // EBX - { - if(pItem3->byteValue >= byteValue) - goto _150069AE; - - pItem2 = pItem2->prev; - } - // 150069AC - pItem3 = NULL; - - _150069AE: - if(pItem2 == pItem1) - continue; - - // 150069B2 - // Switch pItem2 with item - InsertItem(&pItem305C, pItem2, SWITCH_ITEMS, pItem1); - InsertItem(&pItem305C, pItem1, SWITCH_ITEMS, pItem3); - - // 150069D0 - // Switch parents of pItem1 and pItem2 - temp = pItem2->parent->child; - if(pItem1 == pItem1->parent->child) - pItem1->parent->child = pItem2; - - if(pItem2 == temp) - pItem2->parent->child = pItem1; - - // 150069ED - // Switch parents of pItem1 and pItem3 - temp = pItem1->parent; - pItem1 ->parent = pItem2->parent; - pItem2->parent = temp; - offs0004++; - } - while(PTR_INT((pItem1 = pItem1->parent)) > 0); -} - -void THuffmannTree::UninitTree() -{ - while(PTR_INT(pLast) > 0) - { - pItem = pItem305C->Call1501DB70(pLast); - pItem->RemoveItem(); - } - - for(pItem = pFirst; PTR_INT(pItem3058) > 0; pItem = pItem3058) - pItem->RemoveItem(); - PTR_PTR(&pItem3054)->RemoveItem(); - - for(pItem = items0008 + 0x203, nCount = 0x203; nCount != 0; nCount--) - { - pItem--; - pItem->RemoveItem(); - pItem->RemoveItem(); - } -} -*/ - -THTreeItem * THuffmannTree::Call1500E740(unsigned int nValue) -{ - THTreeItem * pItem1 = pItem3058; // EDX - THTreeItem * pItem2; // EAX - THTreeItem * pNext; - THTreeItem * pPrev; - THTreeItem ** ppItem; - - if(PTR_INVALID_OR_NULL(pItem1) || (pItem2 = pItem1) == NULL) - { - if((pItem2 = &items0008[nItems++]) != NULL) - pItem1 = pItem2; - else - pItem1 = pFirst; - } - else - pItem1 = pItem2; - - pNext = pItem1->next; - if(pNext != NULL) - { - pPrev = pItem1->prev; - if(PTR_INVALID_OR_NULL(pPrev)) - pPrev = PTR_NOT(pPrev); - else - pPrev += (pItem1 - pItem1->next->prev); - - pPrev->next = pNext; - pNext->prev = pPrev; - pItem1->next = NULL; - pItem1->prev = NULL; - } - - ppItem = &pFirst; // esi - if(nValue > 1) - { - // ecx = pFirst->next; - pItem1->next = *ppItem; - pItem1->prev = (*ppItem)->prev; - - (*ppItem)->prev = pItem2; - *ppItem = pItem1; - - pItem2->parent = NULL; - pItem2->child = NULL; - } - else - { - pItem1->next = (THTreeItem *)ppItem; - pItem1->prev = ppItem[1]; - // edi = pItem305C; - pPrev = ppItem[1]; // ecx - if(PTR_INVALID_OR_NULL(pPrev)) - { - pPrev = PTR_NOT(pPrev); - pPrev->next = pItem1; - pPrev->prev = pItem2; - - pItem2->parent = NULL; - pItem2->child = NULL; - } - else - { - if(PTR_INVALID(pItem305C)) - pPrev += (THTreeItem *)ppItem - (*ppItem)->prev; - else - pPrev += PTR_INT(pItem305C); - - pPrev->next = pItem1; - ppItem[1] = pItem2; - pItem2->parent = NULL; - pItem2->child = NULL; - } - } - return pItem2; -} - -void THuffmannTree::Call1500E820(THTreeItem * pItem) -{ - THTreeItem * pItem1; // edi - THTreeItem * pItem2 = NULL; // eax - THTreeItem * pItem3; // edx - THTreeItem * pPrev; // ebx - - for(; pItem != NULL; pItem = pItem->parent) - { - pItem->byteValue++; - - for(pItem1 = pItem; ; pItem1 = pPrev) - { - pPrev = pItem1->prev; - if(PTR_INVALID_OR_NULL(pPrev)) - { - pPrev = NULL; - break; - } - - if(pPrev->byteValue >= pItem->byteValue) - break; - } - - if(pItem1 == pItem) - continue; - - if(pItem1->next != NULL) - { - pItem2 = pItem1->GetPrevItem(-1); - pItem2->next = pItem1->next; - pItem1->next->prev = pItem1->prev; - pItem1->next = NULL; - pItem1->prev = NULL; - } - - pItem2 = pItem->next; - pItem1->next = pItem2; - pItem1->prev = pItem2->prev; - pItem2->prev = pItem1; - pItem->next = pItem1; - if((pItem2 = pItem1) != NULL) - { - pItem2 = pItem->GetPrevItem(-1); - pItem2->next = pItem->next; - pItem->next->prev = pItem->prev; - pItem->next = NULL; - pItem->prev = NULL; - } - - if(pPrev == NULL) - pPrev = PTR_PTR(&pFirst); - - pItem2 = pPrev->next; - pItem->next = pItem2; - pItem->prev = pItem2->prev; - pItem2->prev = pItem; - pPrev->next = pItem; - - pItem3 = pItem1->parent->child; - pItem2 = pItem->parent; - if(pItem2->child == pItem) - pItem2->child = pItem1; - if(pItem3 == pItem1) - pItem1->parent->child = pItem; - - pItem2 = pItem->parent; - pItem->parent = pItem1->parent; - pItem1->parent = pItem2; - offs0004++; - } -} - -// 1500E920 -unsigned int THuffmannTree::DoCompression(TOutputStream * os, unsigned char * pbInBuffer, int nInLength, int nCmpType) -{ - THTreeItem * pItem1; - THTreeItem * pItem2; - THTreeItem * pItem3; - THTreeItem * pTemp; - unsigned long dwBitBuff; - unsigned int nBits; - unsigned int nBit; - - BuildTree(nCmpType); - bIsCmp0 = (nCmpType == 0); - - // Store the compression type into output buffer - os->dwBitBuff |= (nCmpType << os->nBits); - os->nBits += 8; - - // Flush completed bytes - while(os->nBits >= 8) - { - if(os->dwOutSize != 0) - { - *os->pbOutPos++ = (unsigned char)os->dwBitBuff; - os->dwOutSize--; - } - - os->dwBitBuff >>= 8; - os->nBits -= 8; - } - - for(; nInLength != 0; nInLength--) - { - unsigned char bOneByte = *pbInBuffer++; - - if((pItem1 = items306C[bOneByte]) == NULL) - { - pItem2 = items306C[0x101]; // ecx - pItem3 = pItem2->parent; // eax - dwBitBuff = 0; - nBits = 0; - - for(; pItem3 != NULL; pItem3 = pItem3->parent) - { - nBit = (pItem3->child != pItem2) ? 1 : 0; - dwBitBuff = (dwBitBuff << 1) | nBit; - nBits++; - pItem2 = pItem3; - } - os->PutBits(dwBitBuff, nBits); - - // Store the loaded byte into output stream - os->dwBitBuff |= (bOneByte << os->nBits); - os->nBits += 8; - - // Flush the whole byte(s) - while(os->nBits >= 8) - { - if(os->dwOutSize != 0) - { - *os->pbOutPos++ = (unsigned char)os->dwBitBuff; - os->dwOutSize--; - } - os->dwBitBuff >>= 8; - os->nBits -= 8; - } - - pItem1 = (PTR_INVALID_OR_NULL(pLast)) ? NULL : pLast; - pItem2 = Call1500E740(1); - pItem2->dcmpByte = pItem1->dcmpByte; - pItem2->byteValue = pItem1->byteValue; - pItem2->parent = pItem1; - items306C[pItem2->dcmpByte] = pItem2; - - pItem2 = Call1500E740(1); - pItem2->dcmpByte = bOneByte; - pItem2->byteValue = 0; - pItem2->parent = pItem1; - items306C[pItem2->dcmpByte] = pItem2; - pItem1->child = pItem2; - - Call1500E820(pItem2); - - if(bIsCmp0 != 0) - { - Call1500E820(items306C[bOneByte]); - continue; - } - - for(pItem1 = items306C[bOneByte]; pItem1 != NULL; pItem1 = pItem1->parent) - { - pItem1->byteValue++; - pItem2 = pItem1; - - for(;;) - { - pItem3 = pItem2->prev; - if(PTR_INVALID_OR_NULL(pItem3)) - { - pItem3 = NULL; - break; - } - if(pItem3->byteValue >= pItem1->byteValue) - break; - pItem2 = pItem3; - } - - if(pItem2 != pItem1) - { - InsertItem(&pItem305C, pItem2, SWITCH_ITEMS, pItem1); - InsertItem(&pItem305C, pItem1, SWITCH_ITEMS, pItem3); - - pItem3 = pItem2->parent->child; - if(pItem1->parent->child == pItem1) - pItem1->parent->child = pItem2; - - if(pItem3 == pItem2) - pItem2->parent->child = pItem1; - - pTemp = pItem1->parent; - pItem1->parent = pItem2->parent; - pItem2->parent = pTemp; - offs0004++; - } - } - } -// 1500EB62 - else - { - dwBitBuff = 0; - nBits = 0; - for(pItem2 = pItem1->parent; pItem2 != NULL; pItem2 = pItem2->parent) - { - nBit = (pItem2->child != pItem1) ? 1 : 0; - dwBitBuff = (dwBitBuff << 1) | nBit; - nBits++; - pItem1 = pItem2; - } - os->PutBits(dwBitBuff, nBits); - } - -// 1500EB98 - if(bIsCmp0 != 0) - Call1500E820(items306C[bOneByte]); // 1500EB9D -// 1500EBAF - } // for(; nInLength != 0; nInLength--) - -// 1500EBB8 - pItem1 = items306C[0x100]; - dwBitBuff = 0; - nBits = 0; - for(pItem2 = pItem1->parent; pItem2 != NULL; pItem2 = pItem2->parent) - { - nBit = (pItem2->child != pItem1) ? 1 : 0; - dwBitBuff = (dwBitBuff << 1) | nBit; - nBits++; - pItem1 = pItem2; - } - -// 1500EBE6 - os->PutBits(dwBitBuff, nBits); - -// 1500EBEF - // Flush the remaining bits - while(os->nBits != 0) - { - if(os->dwOutSize != 0) - { - *os->pbOutPos++ = (unsigned char)os->dwBitBuff; - os->dwOutSize--; - } - os->dwBitBuff >>= 8; - os->nBits -= ((os->nBits > 8) ? 8 : os->nBits); - } - - return (unsigned int)(os->pbOutPos - os->pbOutBuffer); -} - -// Decompression using Huffman tree (1500E450) -unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigned int dwOutLength, TInputStream * is) -{ - TQDecompress * qd; - THTreeItem * pItem1; - THTreeItem * pItem2; - unsigned char * pbOutPos = pbOutBuffer; - unsigned long nBitCount; - unsigned int nDcmpByte = 0; - unsigned int n8Bits; // 8 bits loaded from input stream - unsigned int n7Bits; // 7 bits loaded from input stream - bool bHasQdEntry; - - // Test the output length. Must not be NULL. - if(dwOutLength == 0) - return 0; - - // Get the compression type from the input stream - n8Bits = is->Get8Bits(); - - // Build the Huffman tree - BuildTree(n8Bits); - bIsCmp0 = (n8Bits == 0) ? 1 : 0; - - for(;;) - { - n7Bits = is->Get7Bits(); // Get 7 bits from input stream - - // Try to use quick decompression. Check TQDecompress array for corresponding item. - // If found, ise the result byte instead. - qd = &qd3474[n7Bits]; - - // If there is a quick-pass possible (ebx) - bHasQdEntry = (qd->offs00 >= offs0004) ? true : false; - - // If we can use quick decompress, use it. - if(bHasQdEntry) - { - if(qd->nBits > 7) - { - is->dwBitBuff >>= 7; - is->nBits -= 7; - pItem1 = qd->pItem; - goto _1500E549; - } - is->dwBitBuff >>= qd->nBits; - is->nBits -= qd->nBits; - nDcmpByte = qd->dcmpByte; - } - else - { - pItem1 = pFirst->next->prev; - if(PTR_INVALID_OR_NULL(pItem1)) - pItem1 = NULL; -_1500E549: - nBitCount = 0; - pItem2 = NULL; - - do - { - pItem1 = pItem1->child; // Move down by one level - if(is->GetBit()) // If current bit is set, move to previous - pItem1 = pItem1->prev; - - if(++nBitCount == 7) // If we are at 7th bit, save current HTree item. - pItem2 = pItem1; - } - while(pItem1->child != NULL); // Walk until tree has no deeper level - - if(bHasQdEntry == false) - { - if(nBitCount > 7) - { - qd->offs00 = offs0004; - qd->nBits = nBitCount; - qd->pItem = pItem2; - } - else - { - unsigned long nIndex = n7Bits & (0xFFFFFFFF >> (32 - nBitCount)); - unsigned long nAdd = (1 << nBitCount); - - for(qd = &qd3474[nIndex]; nIndex <= 0x7F; nIndex += nAdd, qd += nAdd) - { - qd->offs00 = offs0004; - qd->nBits = nBitCount; - qd->dcmpByte = pItem1->dcmpByte; - } - } - } - nDcmpByte = pItem1->dcmpByte; - } - - if(nDcmpByte == 0x101) // Huffman tree needs to be modified - { - n8Bits = is->Get8Bits(); - pItem1 = (PTR_INVALID_OR_NULL(pLast)) ? NULL : pLast; - - pItem2 = Call1500E740(1); - pItem2->parent = pItem1; - pItem2->dcmpByte = pItem1->dcmpByte; - pItem2->byteValue = pItem1->byteValue; - items306C[pItem2->dcmpByte] = pItem2; - - pItem2 = Call1500E740(1); - pItem2->parent = pItem1; - pItem2->dcmpByte = n8Bits; - pItem2->byteValue = 0; - items306C[pItem2->dcmpByte] = pItem2; - - pItem1->child = pItem2; - Call1500E820(pItem2); - if(bIsCmp0 == 0) - Call1500E820(items306C[n8Bits]); - - nDcmpByte = n8Bits; - } - - if(nDcmpByte == 0x100) - break; - - *pbOutPos++ = (unsigned char)nDcmpByte; - if(--dwOutLength == 0) - break; - - if(bIsCmp0) - Call1500E820(items306C[nDcmpByte]); - } - - return (unsigned int)(pbOutPos - pbOutBuffer); -} - -/* OLD VERSION -unsigned int THuffmannTree::DoDecompression(unsigned char * pbOutBuffer, unsigned int dwOutLength, TInputStream * is) -{ - THTreeItem * pItem1; // Current item if walking HTree - unsigned long bitCount; // Bit counter if walking HTree - unsigned long oneByte; // 8 bits from bit stream/Pointer to target - unsigned char * outPtr; // Current pointer to output buffer - bool hasQDEntry; // true if entry for quick decompression if filled - THTreeItem * itemAt7 = NULL; // HTree item found at 7th bit - THTreeItem * temp; // For every use - unsigned long dcmpByte = 0; // Decompressed byte value - bool bFlag = 0; - - // Test the output length. Must not be NULL. - if(dwOutLength == 0) - return 0; - - // If too few bits in input bit buffer, we have to load next 16 bits - is->EnsureHasMoreThan8Bits(); - - // Get 8 bits from input stream - oneByte = is->Get8Bits(); - - // Build the Huffman tree - BuildTree(oneByte); - - bIsCmp0 = (oneByte == 0) ? 1 : 0; - outPtr = pbOutBuffer; // Copy pointer to output data - - for(;;) - { - TQDecompress * qd; // For quick decompress - unsigned long sevenBits = is->Get7Bits();// 7 bits from input stream - - // Try to use quick decompression. Check TQDecompress array for corresponding item. - // If found, ise the result byte instead. - qd = &qd3474[sevenBits]; - - // If there is a quick-pass possible - hasQDEntry = (qd->offs00 == offs0004) ? 1 : 0; - - // Start passing the Huffman tree. Set item to tree root item - pItem1 = pFirst; - - // If we can use quick decompress, use it. - bFlag = 1; - if(hasQDEntry == 1) - { - // Check the bit count is greater than 7, move item to 7 levels deeper - if((bitCount = qd->bitCount) > 7) - { - is->dwBitBuff >>= 7; - is->nBits -= 7; - pItem1 = qd->item; // Don't start with root item, but with some deeper-laying - } - else - { - // If OK, use their byte value - is->dwBitBuff >>= bitCount; - is->nBits -= bitCount; - dcmpByte = qd->dcmpByte; - bFlag = 0; - } - } - else - { - pItem1 = pFirst->next->prev; - if(PTR_INT(pItem1) <= 0) - pItem1 = NULL; - } - - if(bFlag == 1) - { - // Walk through Huffman Tree - bitCount = 0; // Clear bit counter - do - { - pItem1 = pItem1->child; - if(is->GetBit() != 0) // If current bit is set, move to previous - pItem1 = pItem1->prev; // item in current level - - if(++bitCount == 7) // If we are at 7th bit, store current HTree item. - itemAt7 = pItem1; // Store Huffman tree item - } - while(pItem1->child != NULL); // Walk until tree has no deeper level - - // If quick decompress entry is not filled yet, fill it. - if(hasQDEntry == 0) - { - if(bitCount > 7) // If we passed more than 7 bits, store bitCount and item - { - qd->offs00 = offs0004; // Value indicates that entry is resolved - qd->bitCount = bitCount; // Number of bits passed - qd->item = itemAt7; // Store item at 7th bit - } - // If we passed less than 7 bits, fill entry and bit count multipliers - else - { - unsigned long index = sevenBits & (0xFFFFFFFF >> (32 - bitCount)); // Index for quick-decompress entry - unsigned long addIndex = (1 << bitCount); // Add value for index - - qd = &qd3474[index]; - - do - { - qd->offs00 = offs0004; - qd->bitCount = bitCount; - qd->dcmpByte = pItem1->dcmpByte; - - index += addIndex; - qd += addIndex; - } - while(index <= 0x7F); - } - } - dcmpByte = pItem1->dcmpByte; - } - - if(dcmpByte == 0x101) // Huffman tree needs to be modified - { - // Check if there is enough bits in the buffer - is->EnsureHasMoreThan8Bits(); - - // Get 8 bits from the buffer - oneByte = is->Get8Bits(); - - // Modify Huffman tree - ModifyTree(oneByte); - - // Get lastly added tree item - pItem1 = items306C[oneByte]; - - if(bIsCmp0 == 0 && pItem1 != NULL) - { - // 15006F15 - do - { - THTreeItem * pItem2 = pItem1; - THTreeItem * pItem3; - unsigned long byteValue; - - byteValue = ++pItem1->byteValue; - - while(PTR_INT((pItem3 = pItem2->prev)) > 0) - { - if(pItem3->byteValue >= byteValue) - goto _15006F30; - - pItem2 = pItem2->prev; - } - pItem3 = NULL; - - _15006F30: - if(pItem2 == pItem1) - continue; - - InsertItem(&pItem305C, pItem2, SWITCH_ITEMS, pItem1); - InsertItem(&pItem305C, pItem1, SWITCH_ITEMS, pItem3); - - temp = pItem2->parent->child; - if(pItem1 == pItem1->parent->child) - pItem1->parent->child = pItem2; - - if(pItem2 == temp) - pItem2->parent->child = pItem1; - - // Switch parents of pItem1 and pItem3 - temp = pItem1->parent; - pItem1->parent = pItem2->parent; - pItem2->parent = temp; - offs0004++; - } - while(PTR_INT((pItem1 = pItem1->parent)) > 0); - } - dcmpByte = oneByte; - } - - if(dcmpByte != 0x100) // Not at the end of data ? - { - *outPtr++ = (unsigned char)dcmpByte; - if(--dwOutLength > 0) - { - if(bIsCmp0 != 0) - Call1500E820(items306C[pItem1->byteValue]); - } - else - break; - } - else - break; - } - return (unsigned long)(outPtr - pbOutBuffer); -} -*/ - -// Table for (de)compression. Every compression type has 258 entries -unsigned char THuffmannTree::Table1502A630[] = -{ - // Data for compression type 0x00 - 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, - - // Data for compression type 0x01 - 0x54, 0x16, 0x16, 0x0D, 0x0C, 0x08, 0x06, 0x05, 0x06, 0x05, 0x06, 0x03, 0x04, 0x04, 0x03, 0x05, - 0x0E, 0x0B, 0x14, 0x13, 0x13, 0x09, 0x0B, 0x06, 0x05, 0x04, 0x03, 0x02, 0x03, 0x02, 0x02, 0x02, - 0x0D, 0x07, 0x09, 0x06, 0x06, 0x04, 0x03, 0x02, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, - 0x09, 0x06, 0x04, 0x04, 0x04, 0x04, 0x03, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x04, - 0x08, 0x03, 0x04, 0x07, 0x09, 0x05, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, - 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, - 0x06, 0x0A, 0x08, 0x08, 0x06, 0x07, 0x04, 0x03, 0x04, 0x04, 0x02, 0x02, 0x04, 0x02, 0x03, 0x03, - 0x04, 0x03, 0x07, 0x07, 0x09, 0x06, 0x04, 0x03, 0x03, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x0A, 0x02, 0x02, 0x03, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x06, 0x03, 0x05, 0x02, 0x03, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x03, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x04, 0x04, 0x04, 0x07, 0x09, 0x08, 0x0C, 0x02, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x03, - 0x04, 0x01, 0x02, 0x04, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, - 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x06, 0x4B, - 0x00, 0x00, - - // Data for compression type 0x02 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x27, 0x00, 0x00, 0x23, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x06, 0x0E, 0x10, 0x04, - 0x06, 0x08, 0x05, 0x04, 0x04, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, 0x01, 0x01, 0x02, 0x01, 0x01, - 0x01, 0x04, 0x02, 0x04, 0x02, 0x02, 0x02, 0x01, 0x01, 0x04, 0x01, 0x01, 0x02, 0x03, 0x03, 0x02, - 0x03, 0x01, 0x03, 0x06, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x01, 0x01, - 0x01, 0x29, 0x07, 0x16, 0x12, 0x40, 0x0A, 0x0A, 0x11, 0x25, 0x01, 0x03, 0x17, 0x10, 0x26, 0x2A, - 0x10, 0x01, 0x23, 0x23, 0x2F, 0x10, 0x06, 0x07, 0x02, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - - // Data for compression type 0x03 - 0xFF, 0x0B, 0x07, 0x05, 0x0B, 0x02, 0x02, 0x02, 0x06, 0x02, 0x02, 0x01, 0x04, 0x02, 0x01, 0x03, - 0x09, 0x01, 0x01, 0x01, 0x03, 0x04, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, - 0x05, 0x01, 0x01, 0x01, 0x0D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x0A, 0x04, 0x02, 0x01, 0x06, 0x03, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, - 0x05, 0x02, 0x03, 0x04, 0x03, 0x03, 0x03, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x03, 0x03, - 0x01, 0x03, 0x01, 0x01, 0x02, 0x05, 0x01, 0x01, 0x04, 0x03, 0x05, 0x01, 0x03, 0x01, 0x03, 0x03, - 0x02, 0x01, 0x04, 0x03, 0x0A, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x0A, 0x02, 0x05, 0x01, 0x01, 0x02, 0x07, 0x02, 0x17, 0x01, 0x05, 0x01, 0x01, - 0x0E, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x06, 0x02, 0x01, 0x04, 0x05, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x11, - 0x00, 0x00, - - // Data for compression type 0x04 - 0xFF, 0xFB, 0x98, 0x9A, 0x84, 0x85, 0x63, 0x64, 0x3E, 0x3E, 0x22, 0x22, 0x13, 0x13, 0x18, 0x17, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - - // Data for compression type 0x05 - 0xFF, 0xF1, 0x9D, 0x9E, 0x9A, 0x9B, 0x9A, 0x97, 0x93, 0x93, 0x8C, 0x8E, 0x86, 0x88, 0x80, 0x82, - 0x7C, 0x7C, 0x72, 0x73, 0x69, 0x6B, 0x5F, 0x60, 0x55, 0x56, 0x4A, 0x4B, 0x40, 0x41, 0x37, 0x37, - 0x2F, 0x2F, 0x27, 0x27, 0x21, 0x21, 0x1B, 0x1C, 0x17, 0x17, 0x13, 0x13, 0x10, 0x10, 0x0D, 0x0D, - 0x0B, 0x0B, 0x09, 0x09, 0x08, 0x08, 0x07, 0x07, 0x06, 0x05, 0x05, 0x04, 0x04, 0x04, 0x19, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - - // Data for compression type 0x06 - 0xC3, 0xCB, 0xF5, 0x41, 0xFF, 0x7B, 0xF7, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xBF, 0xCC, 0xF2, 0x40, 0xFD, 0x7C, 0xF7, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x7A, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - - // Data for compression type 0x07 - 0xC3, 0xD9, 0xEF, 0x3D, 0xF9, 0x7C, 0xE9, 0x1E, 0xFD, 0xAB, 0xF1, 0x2C, 0xFC, 0x5B, 0xFE, 0x17, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xBD, 0xD9, 0xEC, 0x3D, 0xF5, 0x7D, 0xE8, 0x1D, 0xFB, 0xAE, 0xF0, 0x2C, 0xFB, 0x5C, 0xFF, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x70, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, - - // Data for compression type 0x08 - 0xBA, 0xC5, 0xDA, 0x33, 0xE3, 0x6D, 0xD8, 0x18, 0xE5, 0x94, 0xDA, 0x23, 0xDF, 0x4A, 0xD1, 0x10, - 0xEE, 0xAF, 0xE4, 0x2C, 0xEA, 0x5A, 0xDE, 0x15, 0xF4, 0x87, 0xE9, 0x21, 0xF6, 0x43, 0xFC, 0x12, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xB0, 0xC7, 0xD8, 0x33, 0xE3, 0x6B, 0xD6, 0x18, 0xE7, 0x95, 0xD8, 0x23, 0xDB, 0x49, 0xD0, 0x11, - 0xE9, 0xB2, 0xE2, 0x2B, 0xE8, 0x5C, 0xDD, 0x15, 0xF1, 0x87, 0xE7, 0x20, 0xF7, 0x44, 0xFF, 0x13, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x5F, 0x9E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00 -}; \ No newline at end of file diff --git a/contrib/vmap_extractor_v2/stormlib/huffman/huff.h b/contrib/vmap_extractor_v2/stormlib/huffman/huff.h deleted file mode 100644 index f06aa771acd..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/huffman/huff.h +++ /dev/null @@ -1,142 +0,0 @@ -/*****************************************************************************/ -/* huffman.h Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Description : */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* xx.xx.xx 1.00 Lad The first version of huffman.h */ -/* 03.05.03 2.00 Lad Added compression */ -/* 08.12.03 2.01 Dan High-memory handling (> 0x80000000) */ -/*****************************************************************************/ - -#ifndef __HUFFMAN_H__ -#define __HUFFMAN_H__ - -#include "../StormPort.h" - -//----------------------------------------------------------------------------- -// Defines - -#define INSERT_ITEM 1 -#define SWITCH_ITEMS 2 // Switch the item1 and item2 - -#define PTR_NOT(ptr) (THTreeItem *)(~(DWORD_PTR)(ptr)) -#define PTR_PTR(ptr) ((THTreeItem *)(ptr)) -#define PTR_INT(ptr) (LONG_PTR)(ptr) - -#ifndef NULL -#define NULL 0 -#endif - -//----------------------------------------------------------------------------- -// Structures and classes - -// Input stream for Huffmann decompression -class TInputStream -{ - public: - - unsigned long GetBit(); - unsigned long Get7Bits(); - unsigned long Get8Bits(); - - unsigned char * pbInBuffer; // 00 - Input data - unsigned long dwBitBuff; // 04 - Input bit buffer - unsigned int nBits; // 08 - Number of bits remaining in 'dwValue' -}; - -// Output stream for Huffmann compression -class TOutputStream -{ - public: - - void PutBits(unsigned long dwBuff, unsigned int nPutBits); - - unsigned char * pbOutBuffer; // 00 : Output buffer - unsigned long dwOutSize; // 04 : Size of output buffer - unsigned char * pbOutPos; // 08 : Current output position - unsigned long dwBitBuff; // 0C : Bit buffer - unsigned long nBits; // 10 : Number of bits in the bit buffer -}; - -// Huffmann tree item (?) -struct THTreeItem -{ - public: - - THTreeItem * Call1501DB70(THTreeItem * pLast); - THTreeItem * GetPrevItem(LONG_PTR value); - void ClearItemLinks(); - void RemoveItem(); - - THTreeItem * next; // 00 - Pointer to next THTreeItem - THTreeItem * prev; // 04 - Pointer to prev THTreeItem (< 0 if none) - unsigned long dcmpByte; // 08 - Index of this item in item pointer array, decompressed byte value - unsigned long byteValue; // 0C - Some byte value - THTreeItem * parent; // 10 - Pointer to parent THTreeItem (NULL if none) - THTreeItem * child; // 14 - Pointer to child THTreeItem - int addressMultiplier; // -1 if object on negative address (>0x80000000), +1 if positive -}; - -// Structure used for quick decompress. The 'bitCount' contains number of bits -// and byte value contains result decompressed byte value. -// After each walk through Huffman tree are filled all entries which are -// multiplies of number of bits loaded from input stream. These entries -// contain number of bits and result value. At the next 7 bits is tested this -// structure first. If corresponding entry found, decompression routine will -// not walk through Huffman tree and directly stores output byte to output stream. -struct TQDecompress -{ - unsigned long offs00; // 00 - 1 if resolved - unsigned long nBits; // 04 - Bit count - union - { - unsigned long dcmpByte; // 08 - Byte value for decompress (if bitCount <= 7) - THTreeItem * pItem; // 08 - THTreeItem (if number of bits is greater than 7 - }; -}; - -// Structure for Huffman tree (Size 0x3674 bytes). Because I'm not expert -// for the decompression, I do not know actually if the class is really a Hufmann -// tree. If someone knows the decompression details, please let me know -class THuffmannTree -{ - public: - - THuffmannTree(); - void InitTree(bool bCompression); - void BuildTree(unsigned int nCmpType); -// void ModifyTree(unsigned long dwIndex); -// void UninitTree(); - -// void Call15007010(Bit32 dwInLength, THTreeItem * item); - THTreeItem * Call1500E740(unsigned int nValue); - void Call1500E820(THTreeItem * pItem); - unsigned int DoCompression(TOutputStream * os, unsigned char * pbInBuffer, int nInLength, int nCmpType); - unsigned int DoDecompression(unsigned char * pbOutBuffer, unsigned int dwOutLength, TInputStream * is); - - unsigned long bIsCmp0; // 0000 - 1 if compression type 0 - unsigned long offs0004; // 0004 - Some flag - THTreeItem items0008[0x203]; // 0008 - HTree items - - //- Sometimes used as HTree item ----------- - THTreeItem * pItem3050; // 3050 - Always NULL (?) - THTreeItem * pItem3054; // 3054 - Pointer to Huffman tree item - THTreeItem * pItem3058; // 3058 - Pointer to Huffman tree item (< 0 if invalid) - - //- Sometimes used as HTree item ----------- - THTreeItem * pItem305C; // 305C - Usually NULL - THTreeItem * pFirst; // 3060 - Pointer to top (first) Huffman tree item - THTreeItem * pLast; // 3064 - Pointer to bottom (last) Huffman tree item (< 0 if invalid) - unsigned long nItems; // 3068 - Number of used HTree items - - //------------------------------------------- - THTreeItem * items306C[0x102]; // 306C - THTreeItem pointer array - TQDecompress qd3474[0x80]; // 3474 - Array for quick decompression - int addressMultiplier; // -1 if object on negative address (>0x80000000), +1 if positive - - static unsigned char Table1502A630[];// Some table -}; - -#endif // __HUFFMAN_H__ diff --git a/contrib/vmap_extractor_v2/stormlib/pklib/crc32.c b/contrib/vmap_extractor_v2/stormlib/pklib/crc32.c deleted file mode 100644 index a7f52103be4..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/pklib/crc32.c +++ /dev/null @@ -1,72 +0,0 @@ -/*****************************************************************************/ -/* crc32.c Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Pkware Data Compression Library Version 1.11 */ -/* Dissassembled method crc32 - cdecl version */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 09.04.03 1.00 Lad The first version of crc32.c */ -/* 02.05.03 1.00 Lad Stress test done */ -/*****************************************************************************/ - -#include "pklib.h" - -static char CopyRight[] = "PKWARE Data Compression Library for Win32\r\n" - "Copyright 1989-1995 PKWARE Inc. All Rights Reserved\r\n" - "Patent No. 5,051,745\r\n" - "PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off.\r\n" - "Version 1.11\r\n"; - -static unsigned long crc_table[] = -{ - 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, - 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, - 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, - 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, - 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, - 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, - 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, - 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, - 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, - 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, - 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, - 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, - 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, - 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, - 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, - 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, - 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, - 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, - 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, - 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, - 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, - 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, - 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, - 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, - 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, - 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, - 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, - 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, - 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, - 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, - 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, - 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D -}; - - -unsigned long PKEXPORT crc32pk(char * buffer, unsigned int * psize, unsigned long * old_crc) -{ - unsigned int size = *psize; - unsigned long ch; - unsigned long crc_value = *old_crc; - - while(size-- != 0) - { - ch = *buffer++ ^ (char)crc_value; - crc_value >>= 8; - - crc_value = crc_table[ch & 0x0FF] ^ crc_value; - } - return crc_value; -} diff --git a/contrib/vmap_extractor_v2/stormlib/pklib/crc32_pk.c b/contrib/vmap_extractor_v2/stormlib/pklib/crc32_pk.c deleted file mode 100644 index a7f52103be4..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/pklib/crc32_pk.c +++ /dev/null @@ -1,72 +0,0 @@ -/*****************************************************************************/ -/* crc32.c Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Pkware Data Compression Library Version 1.11 */ -/* Dissassembled method crc32 - cdecl version */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 09.04.03 1.00 Lad The first version of crc32.c */ -/* 02.05.03 1.00 Lad Stress test done */ -/*****************************************************************************/ - -#include "pklib.h" - -static char CopyRight[] = "PKWARE Data Compression Library for Win32\r\n" - "Copyright 1989-1995 PKWARE Inc. All Rights Reserved\r\n" - "Patent No. 5,051,745\r\n" - "PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off.\r\n" - "Version 1.11\r\n"; - -static unsigned long crc_table[] = -{ - 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, - 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, - 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, - 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, - 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, - 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, - 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, - 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, - 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, - 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, - 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, - 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, - 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, - 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, - 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, - 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, - 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, - 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, - 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, - 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, - 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, - 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, - 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, - 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, - 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, - 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, - 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, - 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, - 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, - 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, - 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, - 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D -}; - - -unsigned long PKEXPORT crc32pk(char * buffer, unsigned int * psize, unsigned long * old_crc) -{ - unsigned int size = *psize; - unsigned long ch; - unsigned long crc_value = *old_crc; - - while(size-- != 0) - { - ch = *buffer++ ^ (char)crc_value; - crc_value >>= 8; - - crc_value = crc_table[ch & 0x0FF] ^ crc_value; - } - return crc_value; -} diff --git a/contrib/vmap_extractor_v2/stormlib/pklib/explode.c b/contrib/vmap_extractor_v2/stormlib/pklib/explode.c deleted file mode 100644 index a5b41e3dcf9..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/pklib/explode.c +++ /dev/null @@ -1,480 +0,0 @@ -/*****************************************************************************/ -/* explode.c Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Implode function of PKWARE Data Compression library */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 11.03.03 1.00 Lad Splitted from Pkware.cpp */ -/* 08.04.03 1.01 Lad Renamed to explode.c to be compatible with pklib */ -/* 02.05.03 1.01 Lad Stress test done */ -/*****************************************************************************/ - -#include -#include - -#include "pklib.h" - -//----------------------------------------------------------------------------- -// Tables - -static unsigned char DistBits[] = -{ - 0x02, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 -}; - -static unsigned char DistCode[] = -{ - 0x03, 0x0D, 0x05, 0x19, 0x09, 0x11, 0x01, 0x3E, 0x1E, 0x2E, 0x0E, 0x36, 0x16, 0x26, 0x06, 0x3A, - 0x1A, 0x2A, 0x0A, 0x32, 0x12, 0x22, 0x42, 0x02, 0x7C, 0x3C, 0x5C, 0x1C, 0x6C, 0x2C, 0x4C, 0x0C, - 0x74, 0x34, 0x54, 0x14, 0x64, 0x24, 0x44, 0x04, 0x78, 0x38, 0x58, 0x18, 0x68, 0x28, 0x48, 0x08, - 0xF0, 0x70, 0xB0, 0x30, 0xD0, 0x50, 0x90, 0x10, 0xE0, 0x60, 0xA0, 0x20, 0xC0, 0x40, 0x80, 0x00 -}; - -static unsigned char ExLenBits[] = -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 -}; - -static unsigned short LenBase[] = -{ - 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, - 0x0008, 0x000A, 0x000E, 0x0016, 0x0026, 0x0046, 0x0086, 0x0106 -}; - -static unsigned char LenBits[] = -{ - 0x03, 0x02, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x07, 0x07 -}; - -static unsigned char LenCode[] = -{ - 0x05, 0x03, 0x01, 0x06, 0x0A, 0x02, 0x0C, 0x14, 0x04, 0x18, 0x08, 0x30, 0x10, 0x20, 0x40, 0x00 -}; - -static unsigned char ChBitsAsc[] = -{ - 0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x08, 0x07, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x04, 0x0A, 0x08, 0x0C, 0x0A, 0x0C, 0x0A, 0x08, 0x07, 0x07, 0x08, 0x09, 0x07, 0x06, 0x07, 0x08, - 0x07, 0x06, 0x07, 0x07, 0x07, 0x07, 0x08, 0x07, 0x07, 0x08, 0x08, 0x0C, 0x0B, 0x07, 0x09, 0x0B, - 0x0C, 0x06, 0x07, 0x06, 0x06, 0x05, 0x07, 0x08, 0x08, 0x06, 0x0B, 0x09, 0x06, 0x07, 0x06, 0x06, - 0x07, 0x0B, 0x06, 0x06, 0x06, 0x07, 0x09, 0x08, 0x09, 0x09, 0x0B, 0x08, 0x0B, 0x09, 0x0C, 0x08, - 0x0C, 0x05, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x05, 0x0B, 0x07, 0x05, 0x06, 0x05, 0x05, - 0x06, 0x0A, 0x05, 0x05, 0x05, 0x05, 0x08, 0x07, 0x08, 0x08, 0x0A, 0x0B, 0x0B, 0x0C, 0x0C, 0x0C, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, - 0x0D, 0x0D, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D -}; - -static unsigned short ChCodeAsc[] = -{ - 0x0490, 0x0FE0, 0x07E0, 0x0BE0, 0x03E0, 0x0DE0, 0x05E0, 0x09E0, - 0x01E0, 0x00B8, 0x0062, 0x0EE0, 0x06E0, 0x0022, 0x0AE0, 0x02E0, - 0x0CE0, 0x04E0, 0x08E0, 0x00E0, 0x0F60, 0x0760, 0x0B60, 0x0360, - 0x0D60, 0x0560, 0x1240, 0x0960, 0x0160, 0x0E60, 0x0660, 0x0A60, - 0x000F, 0x0250, 0x0038, 0x0260, 0x0050, 0x0C60, 0x0390, 0x00D8, - 0x0042, 0x0002, 0x0058, 0x01B0, 0x007C, 0x0029, 0x003C, 0x0098, - 0x005C, 0x0009, 0x001C, 0x006C, 0x002C, 0x004C, 0x0018, 0x000C, - 0x0074, 0x00E8, 0x0068, 0x0460, 0x0090, 0x0034, 0x00B0, 0x0710, - 0x0860, 0x0031, 0x0054, 0x0011, 0x0021, 0x0017, 0x0014, 0x00A8, - 0x0028, 0x0001, 0x0310, 0x0130, 0x003E, 0x0064, 0x001E, 0x002E, - 0x0024, 0x0510, 0x000E, 0x0036, 0x0016, 0x0044, 0x0030, 0x00C8, - 0x01D0, 0x00D0, 0x0110, 0x0048, 0x0610, 0x0150, 0x0060, 0x0088, - 0x0FA0, 0x0007, 0x0026, 0x0006, 0x003A, 0x001B, 0x001A, 0x002A, - 0x000A, 0x000B, 0x0210, 0x0004, 0x0013, 0x0032, 0x0003, 0x001D, - 0x0012, 0x0190, 0x000D, 0x0015, 0x0005, 0x0019, 0x0008, 0x0078, - 0x00F0, 0x0070, 0x0290, 0x0410, 0x0010, 0x07A0, 0x0BA0, 0x03A0, - 0x0240, 0x1C40, 0x0C40, 0x1440, 0x0440, 0x1840, 0x0840, 0x1040, - 0x0040, 0x1F80, 0x0F80, 0x1780, 0x0780, 0x1B80, 0x0B80, 0x1380, - 0x0380, 0x1D80, 0x0D80, 0x1580, 0x0580, 0x1980, 0x0980, 0x1180, - 0x0180, 0x1E80, 0x0E80, 0x1680, 0x0680, 0x1A80, 0x0A80, 0x1280, - 0x0280, 0x1C80, 0x0C80, 0x1480, 0x0480, 0x1880, 0x0880, 0x1080, - 0x0080, 0x1F00, 0x0F00, 0x1700, 0x0700, 0x1B00, 0x0B00, 0x1300, - 0x0DA0, 0x05A0, 0x09A0, 0x01A0, 0x0EA0, 0x06A0, 0x0AA0, 0x02A0, - 0x0CA0, 0x04A0, 0x08A0, 0x00A0, 0x0F20, 0x0720, 0x0B20, 0x0320, - 0x0D20, 0x0520, 0x0920, 0x0120, 0x0E20, 0x0620, 0x0A20, 0x0220, - 0x0C20, 0x0420, 0x0820, 0x0020, 0x0FC0, 0x07C0, 0x0BC0, 0x03C0, - 0x0DC0, 0x05C0, 0x09C0, 0x01C0, 0x0EC0, 0x06C0, 0x0AC0, 0x02C0, - 0x0CC0, 0x04C0, 0x08C0, 0x00C0, 0x0F40, 0x0740, 0x0B40, 0x0340, - 0x0300, 0x0D40, 0x1D00, 0x0D00, 0x1500, 0x0540, 0x0500, 0x1900, - 0x0900, 0x0940, 0x1100, 0x0100, 0x1E00, 0x0E00, 0x0140, 0x1600, - 0x0600, 0x1A00, 0x0E40, 0x0640, 0x0A40, 0x0A00, 0x1200, 0x0200, - 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000 -}; - -//----------------------------------------------------------------------------- -// Local variables - -static char Copyright[] = "PKWARE Data Compression Library for Win32\r\n" - "Copyright 1989-1995 PKWARE Inc. All Rights Reserved\r\n" - "Patent No. 5,051,745\r\n" - "PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off.\r\n" - "Version 1.11\r\n"; - -//----------------------------------------------------------------------------- -// Local functions - -// Copies a block to another location -static void lmemcpy(void * trg, const void * src, size_t count) -{ - memcpy(trg, src, count); -} - -static void GenDecodeTabs(long count, unsigned char * bits, unsigned char * pCode, unsigned char * buffer2) -{ - long i; - - for(i = count-1; i >= 0; i--) // EBX - count - { - unsigned long idx1 = pCode[i]; - unsigned long idx2 = 1 << bits[i]; - - do - { - buffer2[idx1] = (unsigned char)i; - idx1 += idx2; - } - while(idx1 < 0x100); - } -} - -static void GenAscTabs(TDcmpStruct * pWork) -{ - unsigned short * pChCodeAsc = &ChCodeAsc[0xFF]; - unsigned long acc, add; - unsigned short count; - - for(count = 0x00FF; pChCodeAsc >= ChCodeAsc; pChCodeAsc--, count--) - { - unsigned char * pChBitsAsc = pWork->ChBitsAsc + count; - unsigned char bits_asc = *pChBitsAsc; - - if(bits_asc <= 8) - { - add = (1 << bits_asc); - acc = *pChCodeAsc; - - do - { - pWork->offs2C34[acc] = (unsigned char)count; - acc += add; - } - while(acc < 0x100); - } - else if((acc = (*pChCodeAsc & 0xFF)) != 0) - { - pWork->offs2C34[acc] = 0xFF; - - if(*pChCodeAsc & 0x3F) - { - bits_asc -= 4; - *pChBitsAsc = bits_asc; - - add = (1 << bits_asc); - acc = *pChCodeAsc >> 4; - do - { - pWork->offs2D34[acc] = (unsigned char)count; - acc += add; - } - while(acc < 0x100); - } - else - { - bits_asc -= 6; - *pChBitsAsc = bits_asc; - - add = (1 << bits_asc); - acc = *pChCodeAsc >> 6; - do - { - pWork->offs2E34[acc] = (unsigned char)count; - acc += add; - } - while(acc < 0x80); - } - } - else - { - bits_asc -= 8; - *pChBitsAsc = bits_asc; - - add = (1 << bits_asc); - acc = *pChCodeAsc >> 8; - do - { - pWork->offs2EB4[acc] = (unsigned char)count; - acc += add; - } - while(acc < 0x100); - } - } -} - -//----------------------------------------------------------------------------- -// Skips given number of bits in bit buffer. Result is stored in pWork->bit_buff -// If no data in input buffer, returns true - -static int WasteBits(TDcmpStruct * pWork, unsigned long nBits) -{ - // If number of bits required is less than number of (bits in the buffer) ? - if(nBits <= pWork->extra_bits) - { - pWork->extra_bits -= nBits; - pWork->bit_buff >>= nBits; - return 0; - } - - // Load input buffer if necessary - pWork->bit_buff >>= pWork->extra_bits; - if(pWork->in_pos == pWork->in_bytes) - { - pWork->in_pos = sizeof(pWork->in_buff); - if((pWork->in_bytes = pWork->read_buf((char *)pWork->in_buff, &pWork->in_pos, pWork->param)) == 0) - return 1; - pWork->in_pos = 0; - } - - // Update bit buffer - pWork->bit_buff |= (pWork->in_buff[pWork->in_pos++] << 8); - pWork->bit_buff >>= (nBits - pWork->extra_bits); - pWork->extra_bits = (pWork->extra_bits - nBits) + 8; - return 0; -} - -//----------------------------------------------------------------------------- -// Returns : 0x000 - 0x0FF : One byte from compressed file. -// 0x100 - 0x305 : Copy previous block (0x100 = 1 byte) -// 0x306 : Out of buffer (?) - -static unsigned long DecodeLit(TDcmpStruct * pWork) -{ - unsigned long nBits; // Number of bits to skip - unsigned long value; // Position in buffers - - // Test the current bit in byte buffer. If is not set, simply return the next byte. - if(pWork->bit_buff & 1) - { - // Skip current bit in the buffer - if(WasteBits(pWork, 1)) - return 0x306; - - // The next bits are position in buffers - value = pWork->position2[(pWork->bit_buff & 0xFF)]; - - // Get number of bits to skip - if(WasteBits(pWork, pWork->LenBits[value])) - return 0x306; - - if((nBits = pWork->ExLenBits[value]) != 0) - { - unsigned long val2 = pWork->bit_buff & ((1 << nBits) - 1); - - if(WasteBits(pWork, nBits)) - { - if((value + val2) != 0x10E) - return 0x306; - } - value = pWork->LenBase[value] + val2; - } - return value + 0x100; // Return number of bytes to repeat - } - - // Waste one bit - if(WasteBits(pWork, 1)) - return 0x306; - - // If the binary compression type, read 8 bits and return them as one byte. - if(pWork->ctype == CMP_BINARY) - { - value = pWork->bit_buff & 0xFF; - if(WasteBits(pWork, 8)) - return 0x306; - return value; - } - - // When ASCII compression ... - if(pWork->bit_buff & 0xFF) - { - value = pWork->offs2C34[pWork->bit_buff & 0xFF]; - - if(value == 0xFF) - { - if(pWork->bit_buff & 0x3F) - { - if(WasteBits(pWork, 4)) - return 0x306; - - value = pWork->offs2D34[pWork->bit_buff & 0xFF]; - } - else - { - if(WasteBits(pWork, 6)) - return 0x306; - - value = pWork->offs2E34[pWork->bit_buff & 0x7F]; - } - } - } - else - { - if(WasteBits(pWork, 8)) - return 0x306; - - value = pWork->offs2EB4[pWork->bit_buff & 0xFF]; - } - - return WasteBits(pWork, pWork->ChBitsAsc[value]) ? 0x306 : value; -} - -//----------------------------------------------------------------------------- -// Retrieves the number of bytes to move back - -static unsigned long DecodeDist(TDcmpStruct * pWork, unsigned long dwLength) -{ - unsigned long pos = pWork->position1[(pWork->bit_buff & 0xFF)]; - unsigned long nSkip = pWork->DistBits[pos]; // Number of bits to skip - - // Skip the appropriate number of bits - if(WasteBits(pWork, nSkip) == 1) - return 0; - - if(dwLength == 2) - { - pos = (pos << 2) | (pWork->bit_buff & 0x03); - - if(WasteBits(pWork, 2) == 1) - return 0; - } - else - { - pos = (pos << pWork->dsize_bits) | (pWork->bit_buff & pWork->dsize_mask); - - // Skip the bits - if(WasteBits(pWork, pWork->dsize_bits) == 1) - return 0; - } - return pos+1; -} - -static unsigned long Expand(TDcmpStruct * pWork) -{ - unsigned int copyBytes; // Number of bytes to copy - unsigned long oneByte; // One byte from compressed file - unsigned long dwResult; - - pWork->outputPos = 0x1000; // Initialize output buffer position - - // If end of data or error, terminate decompress - while((dwResult = oneByte = DecodeLit(pWork)) < 0x305) - { - // If one byte is greater than 0x100, means "Repeat n - 0xFE bytes" - if(oneByte >= 0x100) - { - unsigned char * source; // ECX - unsigned char * target; // EDX - unsigned long copyLength = oneByte - 0xFE; - unsigned long moveBack; - - // Get length of data to copy - if((moveBack = DecodeDist(pWork, copyLength)) == 0) - { - dwResult = 0x306; - break; - } - - // Target and source pointer - target = &pWork->out_buff[pWork->outputPos]; - source = target - moveBack; - pWork->outputPos += copyLength; - - while(copyLength-- > 0) - *target++ = *source++; - } - else - pWork->out_buff[pWork->outputPos++] = (unsigned char)oneByte; - - // If number of extracted bytes has reached 1/2 of output buffer, - // flush output buffer. - if(pWork->outputPos >= 0x2000) - { - // Copy decompressed data into user buffer - copyBytes = 0x1000; - pWork->write_buf((char *)&pWork->out_buff[0x1000], ©Bytes, pWork->param); - - // If there are some data left, keep them alive - lmemcpy(pWork->out_buff, &pWork->out_buff[0x1000], pWork->outputPos - 0x1000); - pWork->outputPos -= 0x1000; - } - } - - copyBytes = pWork->outputPos - 0x1000; - pWork->write_buf((char *)&pWork->out_buff[0x1000], ©Bytes, pWork->param); - return dwResult; -} - - -//----------------------------------------------------------------------------- -// Main exploding function. - -unsigned int explode( - unsigned int (*read_buf)(char *buf, unsigned int *size, void *param), - void (*write_buf)(char *buf, unsigned int *size, void *param), - char *work_buf, - void *param) -{ - TDcmpStruct * pWork = (TDcmpStruct *)work_buf; - - // Set the whole work buffer to zeros - memset(pWork, 0, sizeof(TDcmpStruct)); - - // Initialize work struct and load compressed data - pWork->read_buf = read_buf; - pWork->write_buf = write_buf; - pWork->param = param; - pWork->in_pos = sizeof(pWork->in_buff); - pWork->in_bytes = pWork->read_buf((char *)pWork->in_buff, &pWork->in_pos, pWork->param); - if(pWork->in_bytes <= 4) - return CMP_BAD_DATA; - - pWork->ctype = pWork->in_buff[0]; // Get the compression type - pWork->dsize_bits = pWork->in_buff[1]; // Get the dictionary size - pWork->bit_buff = pWork->in_buff[2]; // Initialize 16-bit bit buffer - pWork->extra_bits = 0; // Extra (over 8) bits - pWork->in_pos = 3; // Position in input buffer - - // Test for the valid dictionary size - if(4 > pWork->dsize_bits || pWork->dsize_bits > 6) - return CMP_INVALID_DICTSIZE; - - pWork->dsize_mask = 0xFFFF >> (0x10 - pWork->dsize_bits); // Shifted by 'sar' instruction - - if(pWork->ctype != CMP_BINARY) - { - if(pWork->ctype != CMP_ASCII) - return CMP_INVALID_MODE; - - lmemcpy(pWork->ChBitsAsc, ChBitsAsc, sizeof(pWork->ChBitsAsc)); - GenAscTabs(pWork); - } - - lmemcpy(pWork->LenBits, LenBits, sizeof(pWork->LenBits)); - GenDecodeTabs(0x10, pWork->LenBits, LenCode, pWork->position2); - lmemcpy(pWork->ExLenBits, ExLenBits, sizeof(pWork->ExLenBits)); - lmemcpy(pWork->LenBase, LenBase, sizeof(pWork->LenBase)); - lmemcpy(pWork->DistBits, DistBits, sizeof(pWork->DistBits)); - GenDecodeTabs(0x40, pWork->DistBits, DistCode, pWork->position1); - if(Expand(pWork) != 0x306) - return CMP_NO_ERROR; - - return CMP_ABORT; -} diff --git a/contrib/vmap_extractor_v2/stormlib/pklib/implode.c b/contrib/vmap_extractor_v2/stormlib/pklib/implode.c deleted file mode 100644 index 68d5301cc8d..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/pklib/implode.c +++ /dev/null @@ -1,674 +0,0 @@ -/*****************************************************************************/ -/* implode.c Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Implode function of PKWARE Data Compression library */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 11.04.03 1.00 Lad First version of implode.c */ -/* 02.05.03 1.00 Lad Stress test done */ -/*****************************************************************************/ - -#include -#include - -#include "pklib.h" - -#if ((1200 < _MSC_VER) && (_MSC_VER < 1400)) -#pragma optimize("", off) // Fucking Microsoft VS.NET 2003 compiler !!! - // (_MSC_VER=1310) -#endif - -//----------------------------------------------------------------------------- -// Defines - -#define DICT_OFFSET 0x204 -#define UNCMP_OFFSET (pWork->dsize_bytes + DICT_OFFSET) - -//----------------------------------------------------------------------------- -// Tables - -static unsigned char DistBits[] = -{ - 0x02, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 -}; - -static unsigned char DistCode[] = -{ - 0x03, 0x0D, 0x05, 0x19, 0x09, 0x11, 0x01, 0x3E, 0x1E, 0x2E, 0x0E, 0x36, 0x16, 0x26, 0x06, 0x3A, - 0x1A, 0x2A, 0x0A, 0x32, 0x12, 0x22, 0x42, 0x02, 0x7C, 0x3C, 0x5C, 0x1C, 0x6C, 0x2C, 0x4C, 0x0C, - 0x74, 0x34, 0x54, 0x14, 0x64, 0x24, 0x44, 0x04, 0x78, 0x38, 0x58, 0x18, 0x68, 0x28, 0x48, 0x08, - 0xF0, 0x70, 0xB0, 0x30, 0xD0, 0x50, 0x90, 0x10, 0xE0, 0x60, 0xA0, 0x20, 0xC0, 0x40, 0x80, 0x00 -}; - -static unsigned char ExLenBits[] = -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 -}; - -static unsigned char LenBits[] = -{ - 0x03, 0x02, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x07, 0x07 -}; - -static unsigned char LenCode[] = -{ - 0x05, 0x03, 0x01, 0x06, 0x0A, 0x02, 0x0C, 0x14, 0x04, 0x18, 0x08, 0x30, 0x10, 0x20, 0x40, 0x00 -}; - -static unsigned char ChBitsAsc[] = -{ - 0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x08, 0x07, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x04, 0x0A, 0x08, 0x0C, 0x0A, 0x0C, 0x0A, 0x08, 0x07, 0x07, 0x08, 0x09, 0x07, 0x06, 0x07, 0x08, - 0x07, 0x06, 0x07, 0x07, 0x07, 0x07, 0x08, 0x07, 0x07, 0x08, 0x08, 0x0C, 0x0B, 0x07, 0x09, 0x0B, - 0x0C, 0x06, 0x07, 0x06, 0x06, 0x05, 0x07, 0x08, 0x08, 0x06, 0x0B, 0x09, 0x06, 0x07, 0x06, 0x06, - 0x07, 0x0B, 0x06, 0x06, 0x06, 0x07, 0x09, 0x08, 0x09, 0x09, 0x0B, 0x08, 0x0B, 0x09, 0x0C, 0x08, - 0x0C, 0x05, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x05, 0x0B, 0x07, 0x05, 0x06, 0x05, 0x05, - 0x06, 0x0A, 0x05, 0x05, 0x05, 0x05, 0x08, 0x07, 0x08, 0x08, 0x0A, 0x0B, 0x0B, 0x0C, 0x0C, 0x0C, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, - 0x0D, 0x0D, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D -}; - -static unsigned short ChCodeAsc[] = -{ - 0x0490, 0x0FE0, 0x07E0, 0x0BE0, 0x03E0, 0x0DE0, 0x05E0, 0x09E0, - 0x01E0, 0x00B8, 0x0062, 0x0EE0, 0x06E0, 0x0022, 0x0AE0, 0x02E0, - 0x0CE0, 0x04E0, 0x08E0, 0x00E0, 0x0F60, 0x0760, 0x0B60, 0x0360, - 0x0D60, 0x0560, 0x1240, 0x0960, 0x0160, 0x0E60, 0x0660, 0x0A60, - 0x000F, 0x0250, 0x0038, 0x0260, 0x0050, 0x0C60, 0x0390, 0x00D8, - 0x0042, 0x0002, 0x0058, 0x01B0, 0x007C, 0x0029, 0x003C, 0x0098, - 0x005C, 0x0009, 0x001C, 0x006C, 0x002C, 0x004C, 0x0018, 0x000C, - 0x0074, 0x00E8, 0x0068, 0x0460, 0x0090, 0x0034, 0x00B0, 0x0710, - 0x0860, 0x0031, 0x0054, 0x0011, 0x0021, 0x0017, 0x0014, 0x00A8, - 0x0028, 0x0001, 0x0310, 0x0130, 0x003E, 0x0064, 0x001E, 0x002E, - 0x0024, 0x0510, 0x000E, 0x0036, 0x0016, 0x0044, 0x0030, 0x00C8, - 0x01D0, 0x00D0, 0x0110, 0x0048, 0x0610, 0x0150, 0x0060, 0x0088, - 0x0FA0, 0x0007, 0x0026, 0x0006, 0x003A, 0x001B, 0x001A, 0x002A, - 0x000A, 0x000B, 0x0210, 0x0004, 0x0013, 0x0032, 0x0003, 0x001D, - 0x0012, 0x0190, 0x000D, 0x0015, 0x0005, 0x0019, 0x0008, 0x0078, - 0x00F0, 0x0070, 0x0290, 0x0410, 0x0010, 0x07A0, 0x0BA0, 0x03A0, - 0x0240, 0x1C40, 0x0C40, 0x1440, 0x0440, 0x1840, 0x0840, 0x1040, - 0x0040, 0x1F80, 0x0F80, 0x1780, 0x0780, 0x1B80, 0x0B80, 0x1380, - 0x0380, 0x1D80, 0x0D80, 0x1580, 0x0580, 0x1980, 0x0980, 0x1180, - 0x0180, 0x1E80, 0x0E80, 0x1680, 0x0680, 0x1A80, 0x0A80, 0x1280, - 0x0280, 0x1C80, 0x0C80, 0x1480, 0x0480, 0x1880, 0x0880, 0x1080, - 0x0080, 0x1F00, 0x0F00, 0x1700, 0x0700, 0x1B00, 0x0B00, 0x1300, - 0x0DA0, 0x05A0, 0x09A0, 0x01A0, 0x0EA0, 0x06A0, 0x0AA0, 0x02A0, - 0x0CA0, 0x04A0, 0x08A0, 0x00A0, 0x0F20, 0x0720, 0x0B20, 0x0320, - 0x0D20, 0x0520, 0x0920, 0x0120, 0x0E20, 0x0620, 0x0A20, 0x0220, - 0x0C20, 0x0420, 0x0820, 0x0020, 0x0FC0, 0x07C0, 0x0BC0, 0x03C0, - 0x0DC0, 0x05C0, 0x09C0, 0x01C0, 0x0EC0, 0x06C0, 0x0AC0, 0x02C0, - 0x0CC0, 0x04C0, 0x08C0, 0x00C0, 0x0F40, 0x0740, 0x0B40, 0x0340, - 0x0300, 0x0D40, 0x1D00, 0x0D00, 0x1500, 0x0540, 0x0500, 0x1900, - 0x0900, 0x0940, 0x1100, 0x0100, 0x1E00, 0x0E00, 0x0140, 0x1600, - 0x0600, 0x1A00, 0x0E40, 0x0640, 0x0A40, 0x0A00, 0x1200, 0x0200, - 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000 -}; - -//----------------------------------------------------------------------------- -// Local variables - -static char Copyright[] = "PKWARE Data Compression Library for Win32\r\n" - "Copyright 1989-1995 PKWARE Inc. All Rights Reserved\r\n" - "Patent No. 5,051,745\r\n" - "PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off.\r\n" - "Version 1.11\r\n"; - -//----------------------------------------------------------------------------- -// Local functions - -// Fills memory block with a character -static void lmemset(void * buff, int c, size_t count) -{ - memset(buff, c, count); -} - -// Copies memory block to another location -static void lmemcpy(void * trg, const void * src, size_t count) -{ - memcpy(trg, src, count); -} - -static void SortBuffer(TCmpStruct * pWork, unsigned char * uncmp_data, unsigned char * work_end) -{ - unsigned short * pin0DC8; - unsigned char * puncmp; - unsigned long offs1, offs2; - unsigned long ndwords; - unsigned int add; - - // Fill 0x480 dwords (0x1200 bytes) - ndwords = (unsigned long)((pWork->out_buff - (char *)pWork->offs0DC8 + 1) >> 2); - if(ndwords <= 1) - ndwords = 1; - memset(pWork->offs0DC8, 0, ndwords << 2); - - for(puncmp = uncmp_data; work_end > puncmp; puncmp++) - pWork->offs0DC8[(puncmp[0] * 4) + (puncmp[1] * 5)]++; - - add = 0; - for(pin0DC8 = pWork->offs0DC8; pin0DC8 < &pWork->offs1FC8; pin0DC8++) - { - add += *pin0DC8; - *pin0DC8 = (unsigned short)add; - } - - for(work_end--; work_end >= uncmp_data; work_end--) - { - offs1 = (work_end[0] * 4) + (work_end[1] * 5); // EAX - offs2 = (unsigned long)(work_end - pWork->work_buff); // EDI - - pWork->offs0DC8[offs1]--; - pWork->offs49D0[pWork->offs0DC8[offs1]] = (unsigned short)offs2; - } -} - -static void FlushBuf(TCmpStruct * pWork) -{ - unsigned char save_ch1; - unsigned char save_ch2; - unsigned int size = 0x800; - - pWork->write_buf(pWork->out_buff, &size, pWork->param); - - save_ch1 = pWork->out_buff[0x800]; - save_ch2 = pWork->out_buff[pWork->out_bytes]; - pWork->out_bytes -= 0x800; - - lmemset(pWork->out_buff, 0, 0x802); - - if(pWork->out_bytes != 0) - pWork->out_buff[0] = save_ch1; - if(pWork->out_bits != 0) - pWork->out_buff[pWork->out_bytes] = save_ch2; -} - -static void OutputBits(TCmpStruct * pWork, unsigned int nbits, unsigned long bit_buff) -{ - unsigned int out_bits; - - // If more than 8 bits to output, do recursion - if(nbits > 8) - { - OutputBits(pWork, 8, bit_buff); - bit_buff >>= 8; - nbits -= 8; - } - - // Add bits to the last out byte in out_buff; - out_bits = pWork->out_bits; - pWork->out_buff[pWork->out_bytes] |= (unsigned char)(bit_buff << out_bits); - pWork->out_bits += nbits; - - // If 8 or more bits, increment number of bytes - if(pWork->out_bits > 8) - { - pWork->out_bytes++; - bit_buff >>= (8 - out_bits); - - pWork->out_buff[pWork->out_bytes] = (unsigned char)bit_buff; - pWork->out_bits &= 7; - } - else - { - pWork->out_bits &= 7; - if(pWork->out_bits == 0) - pWork->out_bytes++; - } - - // If there is enough compressed bytes, flush them - if(pWork->out_bytes >= 0x800) - FlushBuf(pWork); -} - -static unsigned long FindRep(TCmpStruct * pWork, unsigned char * srcbuff) -{ - unsigned short esp12; - unsigned char * esp14; - unsigned short esp18; - unsigned char * srcbuff2; - unsigned char esp20; - - unsigned char * srcbuff3; - unsigned short * pin0DC8; - unsigned char * pin27CC; - unsigned short * pin49D0; - unsigned long nreps = 1; // EAX - unsigned long ebx, esi; - unsigned short di; - - pin0DC8 = pWork->offs0DC8 + (srcbuff[0] * 4) + (srcbuff[1] * 5); - esi = (unsigned long)(srcbuff - pWork->dsize_bytes - pWork->work_buff + 1); - esp18 = *pin0DC8; - pin49D0 = pWork->offs49D0 + esp18; - - if(*pin49D0 < esi) - { - while(*pin49D0 < esi) - { - pin49D0++; - esp18++; - } - *pin0DC8 = esp18; - } -//--------------------------------------------------------------------------- - srcbuff2 = srcbuff - 1; - pin49D0 = pWork->offs49D0 + esp18; - pin27CC = pWork->work_buff + *pin49D0; - if(srcbuff2 <= pin27CC) - return 0; -//--------------------------------------------------------------------------- - srcbuff3 = srcbuff; - for(;;) - { - if(srcbuff3[nreps-1] == pin27CC[nreps-1] && *srcbuff3 == *pin27CC) - { - // - // The following code does not work when compiled with MSVC.NET 2003 - // optimizing compiler. We have to switch the optimizations off to make it work - // I found that in debug version (where the optimizations are off), the value - // of "pin27CC" gets incremented twice (once at below, once in the "for" loop) - // - - pin27CC++; - srcbuff3++; - - for(ebx = 2; ebx < DICT_OFFSET; ebx++) - { - pin27CC++; - srcbuff3++; - if(*pin27CC != *srcbuff3) - break; - } - - srcbuff3 = srcbuff; - if(ebx >= nreps) - { - pWork->offs0000 = (unsigned int)(srcbuff3 - pin27CC + ebx - 1); - if((nreps = ebx) > 10) - break; - } - } - - pin49D0++; - esp18++; - pin27CC = pWork->work_buff + *pin49D0; - - if(srcbuff2 > pin27CC) - continue; - - return (nreps >= 2) ? nreps : 0; - } -//--------------------------------------------------------------------------- - if(ebx == DICT_OFFSET) - { - pWork->offs0000--; - return ebx; - } -//--------------------------------------------------------------------------- - pin49D0 = pWork->offs49D0 + esp18; - if(pWork->work_buff + pin49D0[1] >= srcbuff2) - return nreps; -//--------------------------------------------------------------------------- - di = 0; - pWork->offs09BC[0] = 0xFFFF; - pWork->offs09BC[1] = di; - esp12 = 1; - - do - { - esi = di; - if(srcbuff[esp12] != srcbuff[esi]) - { - di = pWork->offs09BC[esi]; - if(di != 0xFFFF) - continue; - } - pWork->offs09BC[++esp12] = ++di; - } - while(esp12 < nreps); -//--------------------------------------------------------------------------- - esi = nreps; - pin27CC = pWork->work_buff + pin49D0[0] + nreps; - esp14 = pin27CC; - - for(;;) // 0040268B - { - esi = pWork->offs09BC[esi]; - if(esi == 0xFFFF) - esi = 0; - - pin49D0 = pWork->offs49D0 + esp18; - do - { - pin49D0++; - esp18++; - pin27CC = pWork->work_buff + pin49D0[0]; - if(pin27CC >= srcbuff2) - return nreps; - } - while(pin27CC + esi < esp14); -//--------------------------------------------------------------------------- - esp20 = srcbuff[nreps - 2]; - if(esp20 == pin27CC[nreps - 2]) - { - if(pin27CC + esi != esp14) - { - esp14 = pin27CC; - esi = 0; - } - } - else - { - pin49D0 = pWork->offs49D0 + esp18; - do - { - pin49D0++; - esp18++; - pin27CC = pWork->work_buff + pin49D0[0]; - if(pin27CC >= srcbuff2) - return nreps; - } - while(pin27CC[nreps - 2] != esp20 || pin27CC[0] != *srcbuff); - - esp14 = pin27CC + 2; - esi = 2; - } -//--------------------------------------------------------------------------- - for(; esp14[0] == srcbuff[esi]; esp14++) - { - if(++esi >= DICT_OFFSET) - break; - } - - if(esi < nreps) - continue; - pWork->offs0000 = (unsigned int)(srcbuff - pin27CC - 1); - if(esi <= nreps) - continue; - nreps = esi; - if(esi == DICT_OFFSET) - return nreps; - - do - { - if(srcbuff[esp12] != srcbuff[di]) - { - di = pWork->offs09BC[di]; - if(di != 0xFFFF) - continue; - } - pWork->offs09BC[++esp12] = ++di; - } - while(esp12 < esi); - } -} - -static void WriteCmpData(TCmpStruct * pWork) -{ - unsigned int nreps = 0; // ESP+10 : Number of repeats - unsigned char * uncmp_end; // ESP+14 : End of uncompressed data - unsigned int esp18 = 0; // ESP+18 : - unsigned int bytes_required; // ESP+1C : Number of bytes required to read - unsigned int esp20 = 0; // ESP+20 : - unsigned char * uncmp_begin = pWork->work_buff + UNCMP_OFFSET; // EDI - unsigned long nreps1; - unsigned long save_offs0000 = 0; - - // Store the compression type and dictionary size - pWork->out_buff[0] = (char)pWork->ctype; - pWork->out_buff[1] = (char)pWork->dsize_bits; - pWork->out_bytes = 2; - - // Reset output buffer to zero - lmemset(&pWork->out_buff[2], 0, sizeof(pWork->out_buff) - 2); - pWork->out_bits = 0; - - do - { - int total_loaded = 0; - - for(bytes_required = 0x1000; bytes_required != 0; ) - { - int loaded = pWork->read_buf((char *)pWork->work_buff + UNCMP_OFFSET + total_loaded, - &bytes_required, pWork->param); - - if(loaded == 0) - { - if(total_loaded == 0 && esp20 == 0) - goto __Exit; - esp18 = 1; - break; - } - else - { - total_loaded += loaded; - bytes_required -= loaded; - } - } - - uncmp_end = pWork->work_buff + pWork->dsize_bytes + total_loaded; - if(esp18 != 0) - uncmp_end += DICT_OFFSET; - - // - // Warning: Passing "uncmp_end + 1" to the SortBuffer function may cause - // the output to be unpredictable in Storm.dll's compression. Because Storm.dll - // does not pass the zeroed buffer to the "implode" function, the byte after - // uncmp_end contains random data. This causes difference within dictionary - // created in SortBuffer function and may also cause different compressed output. - // We always zero the data before compression, so this thing never occurs. - // Funny is that it is actually not a bug, because if we decompress the data back, - // we'll get the identical data with the original input. - // - switch(esp20) - { - case 0: - SortBuffer(pWork, uncmp_begin, uncmp_end + 1); - esp20++; - if(pWork->dsize_bytes != 0x1000) - esp20++; - break; - - case 1: - SortBuffer(pWork, uncmp_begin - pWork->dsize_bytes + DICT_OFFSET, uncmp_end + 1); - esp20++; - break; - - default: - SortBuffer(pWork, uncmp_begin - pWork->dsize_bytes, uncmp_end + 1); - break; - } - - while(uncmp_end > uncmp_begin) - { - nreps1 = FindRep(pWork, uncmp_begin); - while(nreps1 != 0) - { - if(nreps1 == 2 && pWork->offs0000 >= 0x100) - break; - - if(esp18 != 0 && uncmp_begin + nreps1 > uncmp_end) - goto _004022DB; - - if(nreps1 >= 8 || uncmp_begin + 1 >= uncmp_end) - goto _004022FF; - - save_offs0000 = pWork->offs0000; // ebp - nreps = nreps1; - nreps1 = FindRep(pWork, uncmp_begin + 1); - - if(nreps >= nreps1) - goto _004022F9; - - if(nreps + 1 >= nreps1 && save_offs0000 <= 0x80) - goto _004022F9; - - OutputBits(pWork, pWork->nChBits[*uncmp_begin], pWork->nChCodes[*uncmp_begin]); - uncmp_begin++; - } - -_0040222F: - OutputBits(pWork, pWork->nChBits[*uncmp_begin], pWork->nChCodes[*uncmp_begin]); - uncmp_begin++; -_00402252:; - } - - if(esp18 == 0) - { - uncmp_begin -= 0x1000; - lmemcpy(pWork->work_buff, pWork->work_buff + 0x1000, pWork->dsize_bytes + DICT_OFFSET); - } - } - while(esp18 == 0); - -__Exit: - OutputBits(pWork, pWork->nChBits[0x305], pWork->nChCodes[0x305]); - if(pWork->out_bits != 0) - pWork->out_bytes++; - pWork->write_buf(pWork->out_buff, &pWork->out_bytes, pWork->param); - return; - -_004022DB: - nreps1 = (unsigned long)(uncmp_end - uncmp_begin); - if(nreps1 < 2) - goto _0040222F; - - if(nreps1 != 2 || pWork->offs0000 < 0x100) - goto _004022FF; - goto _0040222F; - -_004022F9: - nreps1 = nreps; - pWork->offs0000 = save_offs0000; - -_004022FF: - OutputBits(pWork, pWork->nChBits[nreps1 + 0xFE], pWork->nChCodes[nreps1 + 0xFE]); - - if(nreps1 == 2) - { - OutputBits(pWork, pWork->dist_bits[pWork->offs0000 >> 2], - pWork->dist_codes[pWork->offs0000 >> 2]); - OutputBits(pWork, 2, pWork->offs0000 & 3); - } - else - { - OutputBits(pWork, pWork->dist_bits[pWork->offs0000 >> pWork->dsize_bits], - pWork->dist_codes[pWork->offs0000 >> pWork->dsize_bits]); - OutputBits(pWork, pWork->dsize_bits, pWork->dsize_mask & pWork->offs0000); - } - uncmp_begin += nreps1; - goto _00402252; -} - -//----------------------------------------------------------------------------- -// Main imploding function - -unsigned int PKEXPORT implode( - unsigned int (*read_buf)(char *buf, unsigned int *size, void *param), - void (*write_buf)(char *buf, unsigned int *size, void *param), - char *work_buf, - void *param, - unsigned int *type, - unsigned int *dsize) -{ - TCmpStruct * pWork = (TCmpStruct *)work_buf; - unsigned int nChCode; - unsigned int nCount; - unsigned int i; - - // Initialize the work buffer. This is not in the Pklib, - // but it seems to be a bug. Storm always pre-fills the data with zeros, - // and always compresses one block only. So the bug will not appear. - // But when a larger data block (size > 0x1000) is compressed, - // it may fail. - memset(pWork, 0, sizeof(TCmpStruct)); - - // Fill the work buffer information - pWork->read_buf = read_buf; - pWork->write_buf = write_buf; - pWork->dsize_bytes = *dsize; - pWork->ctype = *type; - pWork->param = param; - pWork->dsize_bits = 4; - pWork->dsize_mask = 0x0F; - - // Test dictionary size - switch(*dsize) - { - case 0x1000 : - pWork->dsize_bits++; - pWork->dsize_mask |= 0x20; - // No break here !!! - - case 0x0800 : - pWork->dsize_bits++; - pWork->dsize_mask |= 0x10; - // No break here !!! - - case 0x0400 : - break; - - default: - return CMP_INVALID_DICTSIZE; - } - - // Test the compression type - switch(*type) - { - case CMP_BINARY: // We will compress data with binary compression type - for(nChCode = 0, nCount = 0; nCount < 0x100; nCount++) - { - pWork->nChBits[nCount] = 9; - pWork->nChCodes[nCount] = (unsigned short)nChCode; - nChCode = (nChCode & 0x0000FFFF) + 2; - } - break; - - - case CMP_ASCII: // We will compress data with ASCII compression type - for(nCount = 0; nCount < 0x100; nCount++) - { - pWork->nChBits[nCount] = (unsigned char )(ChBitsAsc[nCount] + 1); - pWork->nChCodes[nCount] = (unsigned short)(ChCodeAsc[nCount] * 2); - } - break; - - default: - return CMP_INVALID_MODE; - } - - for(i = 0; i < 0x10; i++) - { - int nCount2 = 0; // EBX - - if((1 << ExLenBits[i]) == 0) - continue; - - do - { - pWork->nChBits[nCount] = (unsigned char)(ExLenBits[i] + LenBits[i] + 1); - pWork->nChCodes[nCount] = (unsigned short)((nCount2 << (LenBits[i] + 1)) | ((LenCode[i] & 0xFFFF00FF) * 2) | 1); - - nCount2++; - nCount++; - } - while((1 << ExLenBits[i]) > nCount2); - } - - // Copy the distance codes and distance bits and perform the compression - lmemcpy(&pWork->dist_codes, DistCode, sizeof(DistCode)); - lmemcpy(&pWork->dist_bits, DistBits, sizeof(DistBits)); - WriteCmpData(pWork); - return CMP_NO_ERROR; -} diff --git a/contrib/vmap_extractor_v2/stormlib/pklib/pklib.h b/contrib/vmap_extractor_v2/stormlib/pklib/pklib.h deleted file mode 100644 index 881262e3839..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/pklib/pklib.h +++ /dev/null @@ -1,137 +0,0 @@ -/*****************************************************************************/ -/* pklib.h Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Header file for PKWARE Data Compression Library */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 31.03.03 1.00 Lad The first version of pkware.h */ -/*****************************************************************************/ - -#ifndef __PKLIB_H__ -#define __PKLIB_H__ - -#include "../StormPort.h" - -//----------------------------------------------------------------------------- -// Defines - -#define CMP_BINARY 0 // Binary compression -#define CMP_ASCII 1 // Ascii compression - -#define CMP_NO_ERROR 0 -#define CMP_INVALID_DICTSIZE 1 -#define CMP_INVALID_MODE 2 -#define CMP_BAD_DATA 3 -#define CMP_ABORT 4 - -//----------------------------------------------------------------------------- -// Define calling convention - -#ifndef PKEXPORT -#define PKEXPORT //__cdecl // Use for normal __cdecl calling -#endif -//#define PKEXPORT __stdcall -//#define PKEXPORT __fastcall - -//----------------------------------------------------------------------------- -// Internal structures - -// Compression structure -typedef struct -{ - unsigned int offs0000; // 0000 : - unsigned int out_bytes; // 0004 : # bytes available in out_buff - unsigned int out_bits; // 0008 : # of bits available in the last out byte - unsigned int dsize_bits; // 000C : Dict size : 4=0x400, 5=0x800, 6=0x1000 - unsigned int dsize_mask; // 0010 : Dict size : 0x0F=0x400, 0x1F=0x800, 0x3F=0x1000 - unsigned int ctype; // 0014 : Compression type (Ascii or binary) - unsigned int dsize_bytes; // 0018 : Dictionary size in bytes - unsigned char dist_bits[0x40]; // 001C : Distance bits - unsigned char dist_codes[0x40]; // 005C : Distance codes - unsigned char nChBits[0x306]; // 009C : - unsigned short nChCodes[0x306]; // 03A2 : - unsigned short offs09AE; // 09AE : - - void * param; // 09B0 : User parameter - unsigned int (*read_buf)(char *buf, unsigned int *size, void *param); // 9B4 - void (*write_buf)(char *buf, unsigned int *size, void *param); // 9B8 - - unsigned short offs09BC[0x204]; // 09BC : - unsigned long offs0DC4; // 0DC4 : - unsigned short offs0DC8[0x900]; // 0DC8 : - unsigned short offs1FC8; // 1FC8 : - char out_buff[0x802]; // 1FCA : Output (compressed) data - unsigned char work_buff[0x2204]; // 27CC : Work buffer - // + DICT_OFFSET => Dictionary - // + UNCMP_OFFSET => Uncompressed data - unsigned short offs49D0[0x2000]; // 49D0 : -} TCmpStruct; - -#define CMP_BUFFER_SIZE sizeof(TCmpStruct) // Size of compression buffer - - -// Decompression structure -typedef struct -{ - unsigned long offs0000; // 0000 - unsigned long ctype; // 0004 - Compression type (CMP_BINARY or CMP_ASCII) - unsigned long outputPos; // 0008 - Position in output buffer - unsigned long dsize_bits; // 000C - Dict size (4, 5, 6 for 0x400, 0x800, 0x1000) - unsigned long dsize_mask; // 0010 - Dict size bitmask (0x0F, 0x1F, 0x3F for 0x400, 0x800, 0x1000) - unsigned long bit_buff; // 0014 - 16-bit buffer for processing input data - unsigned long extra_bits; // 0018 - Number of extra (above 8) bits in bit buffer - unsigned int in_pos; // 001C - Position in in_buff - unsigned long in_bytes; // 0020 - Number of bytes in input buffer - void * param; // 0024 - Custom parameter - unsigned int (*read_buf)(char *buf, unsigned int *size, void *param); // 0028 - void (*write_buf)(char *buf, unsigned int *size, void *param);// 002C - unsigned char out_buff[0x2000]; // 0030 - Output circle buffer. Starting position is 0x1000 - unsigned char offs2030[0x204]; // 2030 - ??? - unsigned char in_buff[0x800]; // 2234 - Buffer for data to be decompressed - unsigned char position1[0x100]; // 2A34 - Positions in buffers - unsigned char position2[0x100]; // 2B34 - Positions in buffers - unsigned char offs2C34[0x100]; // 2C34 - Buffer for - unsigned char offs2D34[0x100]; // 2D34 - Buffer for - unsigned char offs2E34[0x80]; // 2EB4 - Buffer for - unsigned char offs2EB4[0x100]; // 2EB4 - Buffer for - unsigned char ChBitsAsc[0x100]; // 2FB4 - Buffer for - unsigned char DistBits[0x40]; // 30B4 - Numbers of bytes to skip copied block length - unsigned char LenBits[0x10]; // 30F4 - Numbers of bits for skip copied block length - unsigned char ExLenBits[0x10]; // 3104 - Number of valid bits for copied block - unsigned short LenBase[0x10]; // 3114 - Buffer for -} TDcmpStruct; - -#define EXP_BUFFER_SIZE sizeof(TDcmpStruct) // Size of decompress buffer - -//----------------------------------------------------------------------------- -// Public functions - -#ifdef __cplusplus - extern "C" { -#endif - -unsigned int PKEXPORT implode( - unsigned int (*read_buf)(char *buf, unsigned int *size, void *param), - void (*write_buf)(char *buf, unsigned int *size, void *param), - char *work_buf, - void *param, - unsigned int *type, - unsigned int *dsize); - - -unsigned int PKEXPORT explode( - unsigned int (*read_buf)(char *buf, unsigned int *size, void *param), - void (*write_buf)(char *buf, unsigned int *size, void *param), - char *work_buf, - void *param); - -// The original name "crc32" was changed to "crc32pk" due -// to compatibility with zlib -unsigned long PKEXPORT crc32pk(char *buffer, unsigned int *size, unsigned long *old_crc); - -#ifdef __cplusplus - } // End of 'extern "C"' declaration -#endif - -#endif // __PKLIB_H__ diff --git a/contrib/vmap_extractor_v2/stormlib/wave/wave.cpp b/contrib/vmap_extractor_v2/stormlib/wave/wave.cpp deleted file mode 100644 index 936525f4eae..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/wave/wave.cpp +++ /dev/null @@ -1,356 +0,0 @@ -/*****************************************************************************/ -/* wave.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* This module contains decompression methods used by Storm.dll to decompress*/ -/* WAVe files. Thanks to Tom Amigo for releasing his sources. */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 11.03.03 1.00 Lad Splitted from Pkware.cpp */ -/* 20.05.03 2.00 Lad Added compression */ -/* 19.11.03 2.01 Dan Big endian handling */ -/*****************************************************************************/ - -#include "wave.h" - -//------------------------------------------------------------------------------ -// Structures - -union TByteAndWordPtr -{ - short * pw; - unsigned char * pb; -}; - -union TWordAndByteArray -{ - short w; - unsigned char b[2]; -}; - -//----------------------------------------------------------------------------- -// Tables necessary dor decompression - -static long Table1503F120[] = -{ - 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000004, 0xFFFFFFFF, 0x00000002, 0xFFFFFFFF, 0x00000006, - 0xFFFFFFFF, 0x00000001, 0xFFFFFFFF, 0x00000005, 0xFFFFFFFF, 0x00000003, 0xFFFFFFFF, 0x00000007, - 0xFFFFFFFF, 0x00000001, 0xFFFFFFFF, 0x00000005, 0xFFFFFFFF, 0x00000003, 0xFFFFFFFF, 0x00000007, - 0xFFFFFFFF, 0x00000002, 0xFFFFFFFF, 0x00000004, 0xFFFFFFFF, 0x00000006, 0xFFFFFFFF, 0x00000008 -}; - -static long Table1503F1A0[] = -{ - 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, - 0x00000010, 0x00000011, 0x00000013, 0x00000015, 0x00000017, 0x00000019, 0x0000001C, 0x0000001F, - 0x00000022, 0x00000025, 0x00000029, 0x0000002D, 0x00000032, 0x00000037, 0x0000003C, 0x00000042, - 0x00000049, 0x00000050, 0x00000058, 0x00000061, 0x0000006B, 0x00000076, 0x00000082, 0x0000008F, - 0x0000009D, 0x000000AD, 0x000000BE, 0x000000D1, 0x000000E6, 0x000000FD, 0x00000117, 0x00000133, - 0x00000151, 0x00000173, 0x00000198, 0x000001C1, 0x000001EE, 0x00000220, 0x00000256, 0x00000292, - 0x000002D4, 0x0000031C, 0x0000036C, 0x000003C3, 0x00000424, 0x0000048E, 0x00000502, 0x00000583, - 0x00000610, 0x000006AB, 0x00000756, 0x00000812, 0x000008E0, 0x000009C3, 0x00000ABD, 0x00000BD0, - 0x00000CFF, 0x00000E4C, 0x00000FBA, 0x0000114C, 0x00001307, 0x000014EE, 0x00001706, 0x00001954, - 0x00001BDC, 0x00001EA5, 0x000021B6, 0x00002515, 0x000028CA, 0x00002CDF, 0x0000315B, 0x0000364B, - 0x00003BB9, 0x000041B2, 0x00004844, 0x00004F7E, 0x00005771, 0x0000602F, 0x000069CE, 0x00007462, - 0x00007FFF -}; - -//---------------------------------------------------------------------------- -// CompressWave - -// 1500EF70 -int CompressWave(unsigned char * pbOutBuffer, int dwOutLength, short * pwInBuffer, int dwInLength, int nChannels, int nCmpLevel) -// ECX EDX -{ - TWordAndByteArray Wcmp; - TByteAndWordPtr out; // Pointer to the output buffer - long SInt32Array1[2]; - long SInt32Array2[2]; - long SInt32Array3[2]; - long nBytesRemains = dwOutLength; // Number of bytes remaining - long nWordsRemains; // Number of words remaining -// unsigned char * pbSaveOutBuffer; // Copy of output buffer (actually not used) - unsigned long dwBitBuff; - unsigned long dwStopBit; - unsigned long dwBit; - unsigned long ebx; - unsigned long esi; - long nTableValue; - long nOneWord; - long var_1C; - long var_2C; - int nLength; - int nIndex; - int nValue; - - // If less than 2 bytes remain, don't decompress anything -// pbSaveOutBuffer = pbOutBuffer; - out.pb = pbOutBuffer; - if(nBytesRemains < 2) - return 2; - - Wcmp.b[1] = (unsigned char)(nCmpLevel - 1); - Wcmp.b[0] = (unsigned char)0; - - *out.pw++ = BSWAP_INT16_SIGNED(Wcmp.w); - if((out.pb - pbOutBuffer + (nChannels * 2)) > nBytesRemains) - return (int)(out.pb - pbOutBuffer + (nChannels * 2)); - - SInt32Array1[0] = SInt32Array1[1] = 0x2C; - - for(int i = 0; i < nChannels; i++) - { - nOneWord = BSWAP_INT16_SIGNED(*pwInBuffer++); - *out.pw++ = BSWAP_INT16_SIGNED((short)nOneWord); - SInt32Array2[i] = nOneWord; - } - - // Weird. But it's there - nLength = dwInLength; - if(nLength < 0) // mov eax, dwInLength; cdq; sub eax, edx; - nLength++; - - nLength = (nLength / 2) - (int)(out.pb - pbOutBuffer); - nLength = (nLength < 0) ? 0 : nLength; - - nIndex = nChannels - 1; // edi - nWordsRemains = dwInLength / 2; // eax - - // ebx - nChannels - // ecx - pwOutPos - for(int chnl = nChannels; chnl < nWordsRemains; chnl++) - { - // 1500F030 - if((out.pb - pbOutBuffer + 2) > nBytesRemains) - return (int)(out.pb - pbOutBuffer + 2); - - // Switch index - if(nChannels == 2) - nIndex = (nIndex == 0) ? 1 : 0; - - // Load one word from the input stream - nOneWord = BSWAP_INT16_SIGNED(*pwInBuffer++); // ecx - nOneWord - SInt32Array3[nIndex] = nOneWord; - - // esi - SInt32Array2[nIndex] - // eax - nValue - nValue = nOneWord - SInt32Array2[nIndex]; - nValue = (nValue < 0) ? ((nValue ^ 0xFFFFFFFF) + 1) : nValue; - - ebx = (nOneWord >= SInt32Array2[nIndex]) ? 0 : 0x40; - - // esi - SInt32Array2[nIndex] - // edx - Table1503F1A0[SInt32Array2[nIndex]] - // edi - (Table1503F1A0[SInt32Array1[nIndex]] >> nCmpLevel) - nTableValue = Table1503F1A0[SInt32Array1[nIndex]]; - dwStopBit = (unsigned long)nCmpLevel; - - // edi - nIndex; - if(nValue < (nTableValue >> nCmpLevel)) - { - if(SInt32Array1[nIndex] != 0) - SInt32Array1[nIndex]--; - *out.pb++ = 0x80; - } - else - { - while(nValue > nTableValue * 2) - { - if(SInt32Array1[nIndex] >= 0x58 || nLength == 0) - break; - - SInt32Array1[nIndex] += 8; - if(SInt32Array1[nIndex] > 0x58) - SInt32Array1[nIndex] = 0x58; - - nTableValue = Table1503F1A0[SInt32Array1[nIndex]]; - *out.pb++ = 0x81; - nLength--; - } - - var_2C = nTableValue >> Wcmp.b[1]; - dwBitBuff = 0; - - esi = (1 << (dwStopBit - 2)); - dwStopBit = (esi <= 0x20) ? esi : 0x20; - - for(var_1C = 0, dwBit = 1; ; dwBit <<= 1) - { -// esi = var_1C + nTableValue; - if((var_1C + nTableValue) <= nValue) - { - var_1C += nTableValue; - dwBitBuff |= dwBit; - } - if(dwBit == dwStopBit) - break; - - nTableValue >>= 1; - } - - nValue = SInt32Array2[nIndex]; - if(ebx != 0) - { - nValue -= (var_1C + var_2C); - if(nValue < -32768) - nValue = -32768; - } - else - { - nValue += (var_1C + var_2C); - if(nValue > 32767) - nValue = 32767; - } - - SInt32Array2[nIndex] = nValue; - *out.pb++ = (unsigned char)(dwBitBuff | ebx); - nTableValue = Table1503F120[dwBitBuff & 0x1F]; - SInt32Array1[nIndex] = SInt32Array1[nIndex] + nTableValue; - if(SInt32Array1[nIndex] < 0) - SInt32Array1[nIndex] = 0; - else if(SInt32Array1[nIndex] > 0x58) - SInt32Array1[nIndex] = 0x58; - } - } - - return (int)(out.pb - pbOutBuffer); -} - -//---------------------------------------------------------------------------- -// DecompressWave - -// 1500F230 -int DecompressWave(unsigned char * pbOutBuffer, int dwOutLength, unsigned char * pbInBuffer, int dwInLength, int nChannels) -{ - TByteAndWordPtr out; // Output buffer - TByteAndWordPtr in; - unsigned char * pbInBufferEnd = (pbInBuffer + dwInLength); - long SInt32Array1[2]; - long SInt32Array2[2]; - long nOneWord; - int dwOutLengthCopy = dwOutLength; - int nIndex; - - SInt32Array1[0] = SInt32Array1[1] = 0x2C; - out.pb = pbOutBuffer; - in.pb = pbInBuffer; - in.pw++; - - // Fill the Uint32Array2 array by channel values. - for(int i = 0; i < nChannels; i++) - { - nOneWord = BSWAP_INT16_SIGNED(*in.pw++); - SInt32Array2[i] = nOneWord; - if(dwOutLengthCopy < 2) - return (int)(out.pb - pbOutBuffer); - - *out.pw++ = BSWAP_INT16_SIGNED((short)nOneWord); - dwOutLengthCopy -= sizeof(short); - } - - // Get the initial index - nIndex = nChannels - 1; - - // Perform the decompression - while(in.pb < pbInBufferEnd) - { - unsigned char nOneByte = *in.pb++; - - // Switch index - if(nChannels == 2) - nIndex = (nIndex == 0) ? 1 : 0; - - // 1500F2A2: Get one byte from input buffer - if(nOneByte & 0x80) - { - switch(nOneByte & 0x7F) - { - case 0: // 1500F315 - if(SInt32Array1[nIndex] != 0) - SInt32Array1[nIndex]--; - - if(dwOutLengthCopy < 2) - return (int)(out.pb - pbOutBuffer); - - *out.pw++ = BSWAP_INT16_SIGNED((unsigned short)SInt32Array2[nIndex]); - dwOutLength -= sizeof(unsigned short); - break; - - case 1: // 1500F2E8 - SInt32Array1[nIndex] += 8; - if(SInt32Array1[nIndex] > 0x58) - SInt32Array1[nIndex] = 0x58; - - if(nChannels == 2) - nIndex = (nIndex == 0) ? 1 : 0; - break; - - case 2: // 1500F41E - break; - - default: // 1500F2C4 - SInt32Array1[nIndex] -= 8; - if(SInt32Array1[nIndex] < 0) - SInt32Array1[nIndex] = 0; - - if(nChannels == 2) - nIndex = (nIndex == 0) ? 1 : 0; - break; - } - } - else - { - // 1500F349 - long temp1 = Table1503F1A0[SInt32Array1[nIndex]]; // EDI - long temp2 = temp1 >> pbInBuffer[1]; // ESI - long temp3 = SInt32Array2[nIndex]; // ECX - - if(nOneByte & 0x01) // EBX = nOneByte - temp2 += (temp1 >> 0); - - if(nOneByte & 0x02) - temp2 += (temp1 >> 1); - - if(nOneByte & 0x04) - temp2 += (temp1 >> 2); - - if(nOneByte & 0x08) - temp2 += (temp1 >> 3); - - if(nOneByte & 0x10) - temp2 += (temp1 >> 4); - - if(nOneByte & 0x20) - temp2 += (temp1 >> 5); - - if(nOneByte & 0x40) - { - temp3 = temp3 - temp2; - if(temp3 <= -32768) - temp3 = -32768; - } - else - { - temp3 = temp3 + temp2; - if(temp3 >= 32767) - temp3 = 32767; - } - - SInt32Array2[nIndex] = temp3; - if(dwOutLength < 2) - break; - - // Store the output 16-bit value - *out.pw++ = BSWAP_INT16_SIGNED((short)SInt32Array2[nIndex]); - dwOutLength -= 2; - - SInt32Array1[nIndex] += Table1503F120[nOneByte & 0x1F]; - - if(SInt32Array1[nIndex] < 0) - SInt32Array1[nIndex] = 0; - else if(SInt32Array1[nIndex] > 0x58) - SInt32Array1[nIndex] = 0x58; - } - } - return (int)(out.pb - pbOutBuffer); -} diff --git a/contrib/vmap_extractor_v2/stormlib/wave/wave.h b/contrib/vmap_extractor_v2/stormlib/wave/wave.h deleted file mode 100644 index 81b5add9cfc..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/wave/wave.h +++ /dev/null @@ -1,22 +0,0 @@ -/*****************************************************************************/ -/* Wave.h Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Header file for WAVe unplode functions */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 31.03.03 1.00 Lad The first version of Wave.h */ -/*****************************************************************************/ - -#ifndef __WAVE_H__ -#define __WAVE_H__ - -//----------------------------------------------------------------------------- -// Functions - -#include "../StormPort.h" - -int CompressWave (unsigned char * pbOutBuffer, int dwOutLength, short * pwInBuffer, int dwInLength, int nCmpType, int nChannels); -int DecompressWave(unsigned char * pbOutBuffer, int dwOutLength, unsigned char * pbInBuffer, int dwInLength, int nChannels); - -#endif // __WAVE_H__ diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/ChangeLog b/contrib/vmap_extractor_v2/stormlib/zlib/ChangeLog deleted file mode 100644 index bf2e3f925bc..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/ChangeLog +++ /dev/null @@ -1,481 +0,0 @@ - - ChangeLog file for zlib - -Changes in 1.1.4 (11 March 2002) -- ZFREE was repeated on same allocation on some error conditions. - This creates a security problem described in - http://www.zlib.org/advisory-2002-03-11.txt -- Returned incorrect error (Z_MEM_ERROR) on some invalid data -- Avoid accesses before window for invalid distances with inflate window - less than 32K. -- force windowBits > 8 to avoid a bug in the encoder for a window size - of 256 bytes. (A complete fix will be available in 1.1.5). - -Changes in 1.1.3 (9 July 1998) -- fix "an inflate input buffer bug that shows up on rare but persistent - occasions" (Mark) -- fix gzread and gztell for concatenated .gz files (Didier Le Botlan) -- fix gzseek(..., SEEK_SET) in write mode -- fix crc check after a gzeek (Frank Faubert) -- fix miniunzip when the last entry in a zip file is itself a zip file - (J Lillge) -- add contrib/asm586 and contrib/asm686 (Brian Raiter) - See http://www.muppetlabs.com/~breadbox/software/assembly.html -- add support for Delphi 3 in contrib/delphi (Bob Dellaca) -- add support for C++Builder 3 and Delphi 3 in contrib/delphi2 (Davide Moretti) -- do not exit prematurely in untgz if 0 at start of block (Magnus Holmgren) -- use macro EXTERN instead of extern to support DLL for BeOS (Sander Stoks) -- added a FAQ file - -- Support gzdopen on Mac with Metrowerks (Jason Linhart) -- Do not redefine Byte on Mac (Brad Pettit & Jason Linhart) -- define SEEK_END too if SEEK_SET is not defined (Albert Chin-A-Young) -- avoid some warnings with Borland C (Tom Tanner) -- fix a problem in contrib/minizip/zip.c for 16-bit MSDOS (Gilles Vollant) -- emulate utime() for WIN32 in contrib/untgz (Gilles Vollant) -- allow several arguments to configure (Tim Mooney, Frodo Looijaard) -- use libdir and includedir in Makefile.in (Tim Mooney) -- support shared libraries on OSF1 V4 (Tim Mooney) -- remove so_locations in "make clean" (Tim Mooney) -- fix maketree.c compilation error (Glenn, Mark) -- Python interface to zlib now in Python 1.5 (Jeremy Hylton) -- new Makefile.riscos (Rich Walker) -- initialize static descriptors in trees.c for embedded targets (Nick Smith) -- use "foo-gz" in example.c for RISCOS and VMS (Nick Smith) -- add the OS/2 files in Makefile.in too (Andrew Zabolotny) -- fix fdopen and halloc macros for Microsoft C 6.0 (Tom Lane) -- fix maketree.c to allow clean compilation of inffixed.h (Mark) -- fix parameter check in deflateCopy (Gunther Nikl) -- cleanup trees.c, use compressed_len only in debug mode (Christian Spieler) -- Many portability patches by Christian Spieler: - . zutil.c, zutil.h: added "const" for zmem* - . Make_vms.com: fixed some typos - . Make_vms.com: msdos/Makefile.*: removed zutil.h from some dependency lists - . msdos/Makefile.msc: remove "default rtl link library" info from obj files - . msdos/Makefile.*: use model-dependent name for the built zlib library - . msdos/Makefile.emx, nt/Makefile.emx, nt/Makefile.gcc: - new makefiles, for emx (DOS/OS2), emx&rsxnt and mingw32 (Windows 9x / NT) -- use define instead of typedef for Bytef also for MSC small/medium (Tom Lane) -- replace __far with _far for better portability (Christian Spieler, Tom Lane) -- fix test for errno.h in configure (Tim Newsham) - -Changes in 1.1.2 (19 March 98) -- added contrib/minzip, mini zip and unzip based on zlib (Gilles Vollant) - See http://www.winimage.com/zLibDll/unzip.html -- preinitialize the inflate tables for fixed codes, to make the code - completely thread safe (Mark) -- some simplifications and slight speed-up to the inflate code (Mark) -- fix gzeof on non-compressed files (Allan Schrum) -- add -std1 option in configure for OSF1 to fix gzprintf (Martin Mokrejs) -- use default value of 4K for Z_BUFSIZE for 16-bit MSDOS (Tim Wegner + Glenn) -- added os2/Makefile.def and os2/zlib.def (Andrew Zabolotny) -- add shared lib support for UNIX_SV4.2MP (MATSUURA Takanori) -- do not wrap extern "C" around system includes (Tom Lane) -- mention zlib binding for TCL in README (Andreas Kupries) -- added amiga/Makefile.pup for Amiga powerUP SAS/C PPC (Andreas Kleinert) -- allow "make install prefix=..." even after configure (Glenn Randers-Pehrson) -- allow "configure --prefix $HOME" (Tim Mooney) -- remove warnings in example.c and gzio.c (Glenn Randers-Pehrson) -- move Makefile.sas to amiga/Makefile.sas - -Changes in 1.1.1 (27 Feb 98) -- fix macros _tr_tally_* in deflate.h for debug mode (Glenn Randers-Pehrson) -- remove block truncation heuristic which had very marginal effect for zlib - (smaller lit_bufsize than in gzip 1.2.4) and degraded a little the - compression ratio on some files. This also allows inlining _tr_tally for - matches in deflate_slow. -- added msdos/Makefile.w32 for WIN32 Microsoft Visual C++ (Bob Frazier) - -Changes in 1.1.0 (24 Feb 98) -- do not return STREAM_END prematurely in inflate (John Bowler) -- revert to the zlib 1.0.8 inflate to avoid the gcc 2.8.0 bug (Jeremy Buhler) -- compile with -DFASTEST to get compression code optimized for speed only -- in minigzip, try mmap'ing the input file first (Miguel Albrecht) -- increase size of I/O buffers in minigzip.c and gzio.c (not a big gain - on Sun but significant on HP) - -- add a pointer to experimental unzip library in README (Gilles Vollant) -- initialize variable gcc in configure (Chris Herborth) - -Changes in 1.0.9 (17 Feb 1998) -- added gzputs and gzgets functions -- do not clear eof flag in gzseek (Mark Diekhans) -- fix gzseek for files in transparent mode (Mark Diekhans) -- do not assume that vsprintf returns the number of bytes written (Jens Krinke) -- replace EXPORT with ZEXPORT to avoid conflict with other programs -- added compress2 in zconf.h, zlib.def, zlib.dnt -- new asm code from Gilles Vollant in contrib/asm386 -- simplify the inflate code (Mark): - . Replace ZALLOC's in huft_build() with single ZALLOC in inflate_blocks_new() - . ZALLOC the length list in inflate_trees_fixed() instead of using stack - . ZALLOC the value area for huft_build() instead of using stack - . Simplify Z_FINISH check in inflate() - -- Avoid gcc 2.8.0 comparison bug a little differently than zlib 1.0.8 -- in inftrees.c, avoid cc -O bug on HP (Farshid Elahi) -- in zconf.h move the ZLIB_DLL stuff earlier to avoid problems with - the declaration of FAR (Gilles VOllant) -- install libz.so* with mode 755 (executable) instead of 644 (Marc Lehmann) -- read_buf buf parameter of type Bytef* instead of charf* -- zmemcpy parameters are of type Bytef*, not charf* (Joseph Strout) -- do not redeclare unlink in minigzip.c for WIN32 (John Bowler) -- fix check for presence of directories in "make install" (Ian Willis) - -Changes in 1.0.8 (27 Jan 1998) -- fixed offsets in contrib/asm386/gvmat32.asm (Gilles Vollant) -- fix gzgetc and gzputc for big endian systems (Markus Oberhumer) -- added compress2() to allow setting the compression level -- include sys/types.h to get off_t on some systems (Marc Lehmann & QingLong) -- use constant arrays for the static trees in trees.c instead of computing - them at run time (thanks to Ken Raeburn for this suggestion). To create - trees.h, compile with GEN_TREES_H and run "make test". -- check return code of example in "make test" and display result -- pass minigzip command line options to file_compress -- simplifying code of inflateSync to avoid gcc 2.8 bug - -- support CC="gcc -Wall" in configure -s (QingLong) -- avoid a flush caused by ftell in gzopen for write mode (Ken Raeburn) -- fix test for shared library support to avoid compiler warnings -- zlib.lib -> zlib.dll in msdos/zlib.rc (Gilles Vollant) -- check for TARGET_OS_MAC in addition to MACOS (Brad Pettit) -- do not use fdopen for Metrowerks on Mac (Brad Pettit)) -- add checks for gzputc and gzputc in example.c -- avoid warnings in gzio.c and deflate.c (Andreas Kleinert) -- use const for the CRC table (Ken Raeburn) -- fixed "make uninstall" for shared libraries -- use Tracev instead of Trace in infblock.c -- in example.c use correct compressed length for test_sync -- suppress +vnocompatwarnings in configure for HPUX (not always supported) - -Changes in 1.0.7 (20 Jan 1998) -- fix gzseek which was broken in write mode -- return error for gzseek to negative absolute position -- fix configure for Linux (Chun-Chung Chen) -- increase stack space for MSC (Tim Wegner) -- get_crc_table and inflateSyncPoint are EXPORTed (Gilles Vollant) -- define EXPORTVA for gzprintf (Gilles Vollant) -- added man page zlib.3 (Rick Rodgers) -- for contrib/untgz, fix makedir() and improve Makefile - -- check gzseek in write mode in example.c -- allocate extra buffer for seeks only if gzseek is actually called -- avoid signed/unsigned comparisons (Tim Wegner, Gilles Vollant) -- add inflateSyncPoint in zconf.h -- fix list of exported functions in nt/zlib.dnt and mdsos/zlib.def - -Changes in 1.0.6 (19 Jan 1998) -- add functions gzprintf, gzputc, gzgetc, gztell, gzeof, gzseek, gzrewind and - gzsetparams (thanks to Roland Giersig and Kevin Ruland for some of this code) -- Fix a deflate bug occuring only with compression level 0 (thanks to - Andy Buckler for finding this one). -- In minigzip, pass transparently also the first byte for .Z files. -- return Z_BUF_ERROR instead of Z_OK if output buffer full in uncompress() -- check Z_FINISH in inflate (thanks to Marc Schluper) -- Implement deflateCopy (thanks to Adam Costello) -- make static libraries by default in configure, add --shared option. -- move MSDOS or Windows specific files to directory msdos -- suppress the notion of partial flush to simplify the interface - (but the symbol Z_PARTIAL_FLUSH is kept for compatibility with 1.0.4) -- suppress history buffer provided by application to simplify the interface - (this feature was not implemented anyway in 1.0.4) -- next_in and avail_in must be initialized before calling inflateInit or - inflateInit2 -- add EXPORT in all exported functions (for Windows DLL) -- added Makefile.nt (thanks to Stephen Williams) -- added the unsupported "contrib" directory: - contrib/asm386/ by Gilles Vollant - 386 asm code replacing longest_match(). - contrib/iostream/ by Kevin Ruland - A C++ I/O streams interface to the zlib gz* functions - contrib/iostream2/ by Tyge Løvset - Another C++ I/O streams interface - contrib/untgz/ by "Pedro A. Aranda Guti\irrez" - A very simple tar.gz file extractor using zlib - contrib/visual-basic.txt by Carlos Rios - How to use compress(), uncompress() and the gz* functions from VB. -- pass params -f (filtered data), -h (huffman only), -1 to -9 (compression - level) in minigzip (thanks to Tom Lane) - -- use const for rommable constants in deflate -- added test for gzseek and gztell in example.c -- add undocumented function inflateSyncPoint() (hack for Paul Mackerras) -- add undocumented function zError to convert error code to string - (for Tim Smithers) -- Allow compilation of gzio with -DNO_DEFLATE to avoid the compression code. -- Use default memcpy for Symantec MSDOS compiler. -- Add EXPORT keyword for check_func (needed for Windows DLL) -- add current directory to LD_LIBRARY_PATH for "make test" -- create also a link for libz.so.1 -- added support for FUJITSU UXP/DS (thanks to Toshiaki Nomura) -- use $(SHAREDLIB) instead of libz.so in Makefile.in (for HPUX) -- added -soname for Linux in configure (Chun-Chung Chen, -- assign numbers to the exported functions in zlib.def (for Windows DLL) -- add advice in zlib.h for best usage of deflateSetDictionary -- work around compiler bug on Atari (cast Z_NULL in call of s->checkfn) -- allow compilation with ANSI keywords only enabled for TurboC in large model -- avoid "versionString"[0] (Borland bug) -- add NEED_DUMMY_RETURN for Borland -- use variable z_verbose for tracing in debug mode (L. Peter Deutsch). -- allow compilation with CC -- defined STDC for OS/2 (David Charlap) -- limit external names to 8 chars for MVS (Thomas Lund) -- in minigzip.c, use static buffers only for 16-bit systems -- fix suffix check for "minigzip -d foo.gz" -- do not return an error for the 2nd of two consecutive gzflush() (Felix Lee) -- use _fdopen instead of fdopen for MSC >= 6.0 (Thomas Fanslau) -- added makelcc.bat for lcc-win32 (Tom St Denis) -- in Makefile.dj2, use copy and del instead of install and rm (Frank Donahoe) -- Avoid expanded $Id$. Use "rcs -kb" or "cvs admin -kb" to avoid Id expansion. -- check for unistd.h in configure (for off_t) -- remove useless check parameter in inflate_blocks_free -- avoid useless assignment of s->check to itself in inflate_blocks_new -- do not flush twice in gzclose (thanks to Ken Raeburn) -- rename FOPEN as F_OPEN to avoid clash with /usr/include/sys/file.h -- use NO_ERRNO_H instead of enumeration of operating systems with errno.h -- work around buggy fclose on pipes for HP/UX -- support zlib DLL with BORLAND C++ 5.0 (thanks to Glenn Randers-Pehrson) -- fix configure if CC is already equal to gcc - -Changes in 1.0.5 (3 Jan 98) -- Fix inflate to terminate gracefully when fed corrupted or invalid data -- Use const for rommable constants in inflate -- Eliminate memory leaks on error conditions in inflate -- Removed some vestigial code in inflate -- Update web address in README - -Changes in 1.0.4 (24 Jul 96) -- In very rare conditions, deflate(s, Z_FINISH) could fail to produce an EOF - bit, so the decompressor could decompress all the correct data but went - on to attempt decompressing extra garbage data. This affected minigzip too. -- zlibVersion and gzerror return const char* (needed for DLL) -- port to RISCOS (no fdopen, no multiple dots, no unlink, no fileno) -- use z_error only for DEBUG (avoid problem with DLLs) - -Changes in 1.0.3 (2 Jul 96) -- use z_streamp instead of z_stream *, which is now a far pointer in MSDOS - small and medium models; this makes the library incompatible with previous - versions for these models. (No effect in large model or on other systems.) -- return OK instead of BUF_ERROR if previous deflate call returned with - avail_out as zero but there is nothing to do -- added memcmp for non STDC compilers -- define NO_DUMMY_DECL for more Mac compilers (.h files merged incorrectly) -- define __32BIT__ if __386__ or i386 is defined (pb. with Watcom and SCO) -- better check for 16-bit mode MSC (avoids problem with Symantec) - -Changes in 1.0.2 (23 May 96) -- added Windows DLL support -- added a function zlibVersion (for the DLL support) -- fixed declarations using Bytef in infutil.c (pb with MSDOS medium model) -- Bytef is define's instead of typedef'd only for Borland C -- avoid reading uninitialized memory in example.c -- mention in README that the zlib format is now RFC1950 -- updated Makefile.dj2 -- added algorithm.doc - -Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion] -- fix array overlay in deflate.c which sometimes caused bad compressed data -- fix inflate bug with empty stored block -- fix MSDOS medium model which was broken in 0.99 -- fix deflateParams() which could generated bad compressed data. -- Bytef is define'd instead of typedef'ed (work around Borland bug) -- added an INDEX file -- new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32), - Watcom (Makefile.wat), Amiga SAS/C (Makefile.sas) -- speed up adler32 for modern machines without auto-increment -- added -ansi for IRIX in configure -- static_init_done in trees.c is an int -- define unlink as delete for VMS -- fix configure for QNX -- add configure branch for SCO and HPUX -- avoid many warnings (unused variables, dead assignments, etc...) -- no fdopen for BeOS -- fix the Watcom fix for 32 bit mode (define FAR as empty) -- removed redefinition of Byte for MKWERKS -- work around an MWKERKS bug (incorrect merge of all .h files) - -Changes in 0.99 (27 Jan 96) -- allow preset dictionary shared between compressor and decompressor -- allow compression level 0 (no compression) -- add deflateParams in zlib.h: allow dynamic change of compression level - and compression strategy. -- test large buffers and deflateParams in example.c -- add optional "configure" to build zlib as a shared library -- suppress Makefile.qnx, use configure instead -- fixed deflate for 64-bit systems (detected on Cray) -- fixed inflate_blocks for 64-bit systems (detected on Alpha) -- declare Z_DEFLATED in zlib.h (possible parameter for deflateInit2) -- always return Z_BUF_ERROR when deflate() has nothing to do -- deflateInit and inflateInit are now macros to allow version checking -- prefix all global functions and types with z_ with -DZ_PREFIX -- make falloc completely reentrant (inftrees.c) -- fixed very unlikely race condition in ct_static_init -- free in reverse order of allocation to help memory manager -- use zlib-1.0/* instead of zlib/* inside the tar.gz -- make zlib warning-free with "gcc -O3 -Wall -Wwrite-strings -Wpointer-arith - -Wconversion -Wstrict-prototypes -Wmissing-prototypes" -- allow gzread on concatenated .gz files -- deflateEnd now returns Z_DATA_ERROR if it was premature -- deflate is finally (?) fully deterministic (no matches beyond end of input) -- Document Z_SYNC_FLUSH -- add uninstall in Makefile -- Check for __cpluplus in zlib.h -- Better test in ct_align for partial flush -- avoid harmless warnings for Borland C++ -- initialize hash_head in deflate.c -- avoid warning on fdopen (gzio.c) for HP cc -Aa -- include stdlib.h for STDC compilers -- include errno.h for Cray -- ignore error if ranlib doesn't exist -- call ranlib twice for NeXTSTEP -- use exec_prefix instead of prefix for libz.a -- renamed ct_* as _tr_* to avoid conflict with applications -- clear z->msg in inflateInit2 before any error return -- initialize opaque in example.c, gzio.c, deflate.c and inflate.c -- fixed typo in zconf.h (_GNUC__ => __GNUC__) -- check for WIN32 in zconf.h and zutil.c (avoid farmalloc in 32-bit mode) -- fix typo in Make_vms.com (f$trnlnm -> f$getsyi) -- in fcalloc, normalize pointer if size > 65520 bytes -- don't use special fcalloc for 32 bit Borland C++ -- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc... -- use Z_BINARY instead of BINARY -- document that gzclose after gzdopen will close the file -- allow "a" as mode in gzopen. -- fix error checking in gzread -- allow skipping .gz extra-field on pipes -- added reference to Perl interface in README -- put the crc table in FAR data (I dislike more and more the medium model :) -- added get_crc_table -- added a dimension to all arrays (Borland C can't count). -- workaround Borland C bug in declaration of inflate_codes_new & inflate_fast -- guard against multiple inclusion of *.h (for precompiled header on Mac) -- Watcom C pretends to be Microsoft C small model even in 32 bit mode. -- don't use unsized arrays to avoid silly warnings by Visual C++: - warning C4746: 'inflate_mask' : unsized array treated as '__far' - (what's wrong with far data in far model?). -- define enum out of inflate_blocks_state to allow compilation with C++ - -Changes in 0.95 (16 Aug 95) -- fix MSDOS small and medium model (now easier to adapt to any compiler) -- inlined send_bits -- fix the final (:-) bug for deflate with flush (output was correct but - not completely flushed in rare occasions). -- default window size is same for compression and decompression - (it's now sufficient to set MAX_WBITS in zconf.h). -- voidp -> voidpf and voidnp -> voidp (for consistency with other - typedefs and because voidnp was not near in large model). - -Changes in 0.94 (13 Aug 95) -- support MSDOS medium model -- fix deflate with flush (could sometimes generate bad output) -- fix deflateReset (zlib header was incorrectly suppressed) -- added support for VMS -- allow a compression level in gzopen() -- gzflush now calls fflush -- For deflate with flush, flush even if no more input is provided. -- rename libgz.a as libz.a -- avoid complex expression in infcodes.c triggering Turbo C bug -- work around a problem with gcc on Alpha (in INSERT_STRING) -- don't use inline functions (problem with some gcc versions) -- allow renaming of Byte, uInt, etc... with #define. -- avoid warning about (unused) pointer before start of array in deflate.c -- avoid various warnings in gzio.c, example.c, infblock.c, adler32.c, zutil.c -- avoid reserved word 'new' in trees.c - -Changes in 0.93 (25 June 95) -- temporarily disable inline functions -- make deflate deterministic -- give enough lookahead for PARTIAL_FLUSH -- Set binary mode for stdin/stdout in minigzip.c for OS/2 -- don't even use signed char in inflate (not portable enough) -- fix inflate memory leak for segmented architectures - -Changes in 0.92 (3 May 95) -- don't assume that char is signed (problem on SGI) -- Clear bit buffer when starting a stored block -- no memcpy on Pyramid -- suppressed inftest.c -- optimized fill_window, put longest_match inline for gcc -- optimized inflate on stored blocks. -- untabify all sources to simplify patches - -Changes in 0.91 (2 May 95) -- Default MEM_LEVEL is 8 (not 9 for Unix) as documented in zlib.h -- Document the memory requirements in zconf.h -- added "make install" -- fix sync search logic in inflateSync -- deflate(Z_FULL_FLUSH) now works even if output buffer too short -- after inflateSync, don't scare people with just "lo world" -- added support for DJGPP - -Changes in 0.9 (1 May 95) -- don't assume that zalloc clears the allocated memory (the TurboC bug - was Mark's bug after all :) -- let again gzread copy uncompressed data unchanged (was working in 0.71) -- deflate(Z_FULL_FLUSH), inflateReset and inflateSync are now fully implemented -- added a test of inflateSync in example.c -- moved MAX_WBITS to zconf.h because users might want to change that. -- document explicitly that zalloc(64K) on MSDOS must return a normalized - pointer (zero offset) -- added Makefiles for Microsoft C, Turbo C, Borland C++ -- faster crc32() - -Changes in 0.8 (29 April 95) -- added fast inflate (inffast.c) -- deflate(Z_FINISH) now returns Z_STREAM_END when done. Warning: this - is incompatible with previous versions of zlib which returned Z_OK. -- work around a TurboC compiler bug (bad code for b << 0, see infutil.h) - (actually that was not a compiler bug, see 0.81 above) -- gzread no longer reads one extra byte in certain cases -- In gzio destroy(), don't reference a freed structure -- avoid many warnings for MSDOS -- avoid the ERROR symbol which is used by MS Windows - -Changes in 0.71 (14 April 95) -- Fixed more MSDOS compilation problems :( There is still a bug with - TurboC large model. - -Changes in 0.7 (14 April 95) -- Added full inflate support. -- Simplified the crc32() interface. The pre- and post-conditioning - (one's complement) is now done inside crc32(). WARNING: this is - incompatible with previous versions; see zlib.h for the new usage. - -Changes in 0.61 (12 April 95) -- workaround for a bug in TurboC. example and minigzip now work on MSDOS. - -Changes in 0.6 (11 April 95) -- added minigzip.c -- added gzdopen to reopen a file descriptor as gzFile -- added transparent reading of non-gziped files in gzread. -- fixed bug in gzread (don't read crc as data) -- fixed bug in destroy (gzio.c) (don't return Z_STREAM_END for gzclose). -- don't allocate big arrays in the stack (for MSDOS) -- fix some MSDOS compilation problems - -Changes in 0.5: -- do real compression in deflate.c. Z_PARTIAL_FLUSH is supported but - not yet Z_FULL_FLUSH. -- support decompression but only in a single step (forced Z_FINISH) -- added opaque object for zalloc and zfree. -- added deflateReset and inflateReset -- added a variable zlib_version for consistency checking. -- renamed the 'filter' parameter of deflateInit2 as 'strategy'. - Added Z_FILTERED and Z_HUFFMAN_ONLY constants. - -Changes in 0.4: -- avoid "zip" everywhere, use zlib instead of ziplib. -- suppress Z_BLOCK_FLUSH, interpret Z_PARTIAL_FLUSH as block flush - if compression method == 8. -- added adler32 and crc32 -- renamed deflateOptions as deflateInit2, call one or the other but not both -- added the method parameter for deflateInit2. -- added inflateInit2 -- simplied considerably deflateInit and inflateInit by not supporting - user-provided history buffer. This is supported only in deflateInit2 - and inflateInit2. - -Changes in 0.3: -- prefix all macro names with Z_ -- use Z_FINISH instead of deflateEnd to finish compression. -- added Z_HUFFMAN_ONLY -- added gzerror() diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/FAQ b/contrib/vmap_extractor_v2/stormlib/zlib/FAQ deleted file mode 100644 index 47a7d60c6de..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/FAQ +++ /dev/null @@ -1,100 +0,0 @@ - - Frequently Asked Questions about zlib - - -If your question is not there, please check the zlib home page -http://www.zlib.org which may have more recent information. -The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html - - - 1. Is zlib Y2K-compliant? - - Yes. zlib doesn't handle dates. - - 2. Where can I get a Windows DLL version? - - The zlib sources can be compiled without change to produce a DLL. If you - want a precompiled DLL, see http://www.winimage.com/zLibDll/ . Questions - about the zlib DLL should be sent to Gilles Vollant (info@winimage.com). - - 3. Where can I get a Visual Basic interface to zlib? - - See - * http://www.winimage.com/zLibDll/cmp-z-it.zip - * http://www.dogma.net/markn/articles/zlibtool/zlibtool.htm - * contrib/visual-basic.txt in the zlib distribution - - 4. compress() returns Z_BUF_ERROR - - Make sure that before the call of compress, the length of the compressed - buffer is equal to the total size of the compressed buffer and not - zero. For Visual Basic, check that this parameter is passed by reference - ("as any"), not by value ("as long"). - - 5. deflate() or inflate() returns Z_BUF_ERROR - - Before making the call, make sure that avail_in and avail_out are not - zero. When setting the parameter flush equal to Z_FINISH, also make sure - that avail_out is big enough to allow processing all pending input. - - 6. Where's the zlib documentation (man pages, etc.)? - - It's in zlib.h for the moment, and Francis S. Lin has converted it to a - web page zlib.html. Volunteers to transform this to Unix-style man pages, - please contact Jean-loup Gailly (jloup@gzip.org). Examples of zlib usage - are in the files example.c and minigzip.c. - - 7. Why don't you use GNU autoconf or libtool or ...? - - Because we would like to keep zlib as a very small and simple - package. zlib is rather portable and doesn't need much configuration. - - 8. I found a bug in zlib. - - Most of the time, such problems are due to an incorrect usage of - zlib. Please try to reproduce the problem with a small program and send - the corresponding source to us at zlib@gzip.org . Do not send - multi-megabyte data files without prior agreement. - - 9. Why do I get "undefined reference to gzputc"? - - If "make test" produces something like - - example.o(.text+0x154): undefined reference to `gzputc' - - check that you don't have old files libz.* in /usr/lib, /usr/local/lib or - /usr/X11R6/lib. Remove any old versions, then do "make install". - -10. I need a Delphi interface to zlib. - - See the directories contrib/delphi and contrib/delphi2 in the zlib - distribution. - -11. Can zlib handle .zip archives? - - See the directory contrib/minizip in the zlib distribution. - -12. Can zlib handle .Z files? - - No, sorry. You have to spawn an uncompress or gunzip subprocess, or adapt - the code of uncompress on your own. - -13. How can I make a Unix shared library? - - make clean - ./configure -s - make - -14. Why does "make test" fail on Mac OS X? - - Mac OS X already includes zlib as a shared library, and so -lz links the - shared library instead of the one that the "make" compiled. For zlib - 1.1.3, the two are incompatible due to different compile-time - options. Simply change the -lz in the Makefile to libz.a, and it will use - the compiled library instead of the shared one and the "make test" will - succeed. - -15. I have a question about OttoPDF - - We are not the authors of OttoPDF. The real author is on the OttoPDF web - site Joel Hainley jhainley@myndkryme.com. diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/INDEX b/contrib/vmap_extractor_v2/stormlib/zlib/INDEX deleted file mode 100644 index 8a245766402..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/INDEX +++ /dev/null @@ -1,86 +0,0 @@ -ChangeLog history of changes -INDEX this file -FAQ Frequently Asked Questions about zlib -Make_vms.com script for Vax/VMS -Makefile makefile for Unix (generated by configure) -Makefile.in makefile for Unix (template for configure) -Makefile.riscos makefile for RISCOS -README guess what -algorithm.txt description of the (de)compression algorithm -configure configure script for Unix -descrip.mms makefile for Vax/VMS -zlib.3 mini man page for zlib (volunteers to write full - man pages from zlib.h welcome. write to jloup@gzip.org) - -amiga/Makefile.sas makefile for Amiga SAS/C -amiga/Makefile.pup makefile for Amiga powerUP SAS/C PPC - -msdos/Makefile.w32 makefile for Microsoft Visual C++ 32-bit -msdos/Makefile.b32 makefile for Borland C++ 32-bit -msdos/Makefile.bor makefile for Borland C/C++ 16-bit -msdos/Makefile.dj2 makefile for DJGPP 2.x -msdos/Makefile.emx makefile for EMX 0.9c (32-bit DOS/OS2) -msdos/Makefile.msc makefile for Microsoft C 16-bit -msdos/Makefile.tc makefile for Turbo C -msdos/Makefile.wat makefile for Watcom C -msdos/zlib.def definition file for Windows DLL -msdos/zlib.rc definition file for Windows DLL - -nt/Makefile.nt makefile for Windows NT -nt/zlib.dnt definition file for Windows NT DLL -nt/Makefile.emx makefile for EMX 0.9c/RSXNT 1.41 (Win32 Intel) -nt/Makefile.gcc makefile for Windows NT using GCC (mingw32) - - - zlib public header files (must be kept): -zconf.h -zlib.h - - private source files used to build the zlib library: -adler32.c -compress.c -crc32.c -deflate.c -deflate.h -gzio.c -infblock.c -infblock.h -infcodes.c -infcodes.h -inffast.c -inffast.h -inflate.c -inftrees.c -inftrees.h -infutil.c -infutil.h -maketree.c -trees.c -uncompr.c -zutil.c -zutil.h - - source files for sample programs: -example.c -minigzip.c - - unsupported contribution by third parties - -contrib/asm386/ by Gilles Vollant - 386 asm code replacing longest_match(). - -contrib/minizip/ by Gilles Vollant - Mini zip and unzip based on zlib - See http://www.winimage.com/zLibDll/unzip.html - -contrib/iostream/ by Kevin Ruland - A C++ I/O streams interface to the zlib gz* functions - -contrib/iostream2/ by Tyge Løvset - Another C++ I/O streams interface - -contrib/untgz/ by "Pedro A. Aranda Guti\irrez" - A very simple tar.gz extractor using zlib - -contrib/visual-basic.txt by Carlos Rios - How to use compress(), uncompress() and the gz* functions from VB. diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/Makefile.riscos b/contrib/vmap_extractor_v2/stormlib/zlib/Makefile.riscos deleted file mode 100644 index d97f4492370..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/Makefile.riscos +++ /dev/null @@ -1,151 +0,0 @@ -# Project: zlib_1_03 -# Patched for zlib 1.1.2 rw@shadow.org.uk 19980430 -# test works out-of-the-box, installs `somewhere' on demand - -# Toolflags: -CCflags = -c -depend !Depend -IC: -g -throwback -DRISCOS -fah -C++flags = -c -depend !Depend -IC: -throwback -Linkflags = -aif -c++ -o $@ -ObjAsmflags = -throwback -NoCache -depend !Depend -CMHGflags = -LibFileflags = -c -l -o $@ -Squeezeflags = -o $@ - -# change the line below to where _you_ want the library installed. -libdest = lib:zlib - -# Final targets: -@.lib: @.o.adler32 @.o.compress @.o.crc32 @.o.deflate @.o.gzio \ - @.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil @.o.trees \ - @.o.uncompr @.o.zutil - LibFile $(LibFileflags) @.o.adler32 @.o.compress @.o.crc32 @.o.deflate \ - @.o.gzio @.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil \ - @.o.trees @.o.uncompr @.o.zutil -test: @.minigzip @.example @.lib - @copy @.lib @.libc A~C~DF~L~N~P~Q~RS~TV - @echo running tests: hang on. - @/@.minigzip -f -9 libc - @/@.minigzip -d libc-gz - @/@.minigzip -f -1 libc - @/@.minigzip -d libc-gz - @/@.minigzip -h -9 libc - @/@.minigzip -d libc-gz - @/@.minigzip -h -1 libc - @/@.minigzip -d libc-gz - @/@.minigzip -9 libc - @/@.minigzip -d libc-gz - @/@.minigzip -1 libc - @/@.minigzip -d libc-gz - @diff @.lib @.libc - @echo that should have reported '@.lib and @.libc identical' if you have diff. - @/@.example @.fred @.fred - @echo that will have given lots of hello!'s. - -@.minigzip: @.o.minigzip @.lib C:o.Stubs - Link $(Linkflags) @.o.minigzip @.lib C:o.Stubs -@.example: @.o.example @.lib C:o.Stubs - Link $(Linkflags) @.o.example @.lib C:o.Stubs - -install: @.lib - cdir $(libdest) - cdir $(libdest).h - @copy @.h.zlib $(libdest).h.zlib A~C~DF~L~N~P~Q~RS~TV - @copy @.h.zconf $(libdest).h.zconf A~C~DF~L~N~P~Q~RS~TV - @copy @.lib $(libdest).lib A~C~DF~L~N~P~Q~RS~TV - @echo okay, installed zlib in $(libdest) - -clean:; remove @.minigzip - remove @.example - remove @.libc - -wipe @.o.* F~r~cV - remove @.fred - -# User-editable dependencies: -.c.o: - cc $(ccflags) -o $@ $< - -# Static dependencies: - -# Dynamic dependencies: -o.example: c.example -o.example: h.zlib -o.example: h.zconf -o.minigzip: c.minigzip -o.minigzip: h.zlib -o.minigzip: h.zconf -o.adler32: c.adler32 -o.adler32: h.zlib -o.adler32: h.zconf -o.compress: c.compress -o.compress: h.zlib -o.compress: h.zconf -o.crc32: c.crc32 -o.crc32: h.zlib -o.crc32: h.zconf -o.deflate: c.deflate -o.deflate: h.deflate -o.deflate: h.zutil -o.deflate: h.zlib -o.deflate: h.zconf -o.gzio: c.gzio -o.gzio: h.zutil -o.gzio: h.zlib -o.gzio: h.zconf -o.infblock: c.infblock -o.infblock: h.zutil -o.infblock: h.zlib -o.infblock: h.zconf -o.infblock: h.infblock -o.infblock: h.inftrees -o.infblock: h.infcodes -o.infblock: h.infutil -o.infcodes: c.infcodes -o.infcodes: h.zutil -o.infcodes: h.zlib -o.infcodes: h.zconf -o.infcodes: h.inftrees -o.infcodes: h.infblock -o.infcodes: h.infcodes -o.infcodes: h.infutil -o.infcodes: h.inffast -o.inffast: c.inffast -o.inffast: h.zutil -o.inffast: h.zlib -o.inffast: h.zconf -o.inffast: h.inftrees -o.inffast: h.infblock -o.inffast: h.infcodes -o.inffast: h.infutil -o.inffast: h.inffast -o.inflate: c.inflate -o.inflate: h.zutil -o.inflate: h.zlib -o.inflate: h.zconf -o.inflate: h.infblock -o.inftrees: c.inftrees -o.inftrees: h.zutil -o.inftrees: h.zlib -o.inftrees: h.zconf -o.inftrees: h.inftrees -o.inftrees: h.inffixed -o.infutil: c.infutil -o.infutil: h.zutil -o.infutil: h.zlib -o.infutil: h.zconf -o.infutil: h.infblock -o.infutil: h.inftrees -o.infutil: h.infcodes -o.infutil: h.infutil -o.trees: c.trees -o.trees: h.deflate -o.trees: h.zutil -o.trees: h.zlib -o.trees: h.zconf -o.trees: h.trees -o.uncompr: c.uncompr -o.uncompr: h.zlib -o.uncompr: h.zconf -o.zutil: c.zutil -o.zutil: h.zutil -o.zutil: h.zlib -o.zutil: h.zconf diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/README b/contrib/vmap_extractor_v2/stormlib/zlib/README deleted file mode 100644 index 29d67146a9b..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/README +++ /dev/null @@ -1,147 +0,0 @@ -zlib 1.1.4 is a general purpose data compression library. All the code -is thread safe. The data format used by the zlib library -is described by RFCs (Request for Comments) 1950 to 1952 in the files -http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate -format) and rfc1952.txt (gzip format). These documents are also available in -other formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html - -All functions of the compression library are documented in the file zlib.h -(volunteer to write man pages welcome, contact jloup@gzip.org). A usage -example of the library is given in the file example.c which also tests that -the library is working correctly. Another example is given in the file -minigzip.c. The compression library itself is composed of all source files -except example.c and minigzip.c. - -To compile all files and run the test program, follow the instructions -given at the top of Makefile. In short "make test; make install" -should work for most machines. For Unix: "./configure; make test; make install" -For MSDOS, use one of the special makefiles such as Makefile.msc. -For VMS, use Make_vms.com or descrip.mms. - -Questions about zlib should be sent to , or to -Gilles Vollant for the Windows DLL version. -The zlib home page is http://www.zlib.org or http://www.gzip.org/zlib/ -Before reporting a problem, please check this site to verify that -you have the latest version of zlib; otherwise get the latest version and -check whether the problem still exists or not. - -PLEASE read the zlib FAQ http://www.gzip.org/zlib/zlib_faq.html -before asking for help. - -Mark Nelson wrote an article about zlib for the Jan. 1997 -issue of Dr. Dobb's Journal; a copy of the article is available in -http://dogma.net/markn/articles/zlibtool/zlibtool.htm - -The changes made in version 1.1.4 are documented in the file ChangeLog. -The only changes made since 1.1.3 are bug corrections: - -- ZFREE was repeated on same allocation on some error conditions. - This creates a security problem described in - http://www.zlib.org/advisory-2002-03-11.txt -- Returned incorrect error (Z_MEM_ERROR) on some invalid data -- Avoid accesses before window for invalid distances with inflate window - less than 32K. -- force windowBits > 8 to avoid a bug in the encoder for a window size - of 256 bytes. (A complete fix will be available in 1.1.5). - -The beta version 1.1.5beta includes many more changes. A new official -version 1.1.5 will be released as soon as extensive testing has been -completed on it. - - -Unsupported third party contributions are provided in directory "contrib". - -A Java implementation of zlib is available in the Java Development Kit -http://www.javasoft.com/products/JDK/1.1/docs/api/Package-java.util.zip.html -See the zlib home page http://www.zlib.org for details. - -A Perl interface to zlib written by Paul Marquess -is in the CPAN (Comprehensive Perl Archive Network) sites -http://www.cpan.org/modules/by-module/Compress/ - -A Python interface to zlib written by A.M. Kuchling -is available in Python 1.5 and later versions, see -http://www.python.org/doc/lib/module-zlib.html - -A zlib binding for TCL written by Andreas Kupries -is availlable at http://www.westend.com/~kupries/doc/trf/man/man.html - -An experimental package to read and write files in .zip format, -written on top of zlib by Gilles Vollant , is -available at http://www.winimage.com/zLibDll/unzip.html -and also in the contrib/minizip directory of zlib. - - -Notes for some targets: - -- To build a Windows DLL version, include in a DLL project zlib.def, zlib.rc - and all .c files except example.c and minigzip.c; compile with -DZLIB_DLL - The zlib DLL support was initially done by Alessandro Iacopetti and is - now maintained by Gilles Vollant . Check the zlib DLL - home page at http://www.winimage.com/zLibDll - - From Visual Basic, you can call the DLL functions which do not take - a structure as argument: compress, uncompress and all gz* functions. - See contrib/visual-basic.txt for more information, or get - http://www.tcfb.com/dowseware/cmp-z-it.zip - -- For 64-bit Irix, deflate.c must be compiled without any optimization. - With -O, one libpng test fails. The test works in 32 bit mode (with - the -n32 compiler flag). The compiler bug has been reported to SGI. - -- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 - it works when compiled with cc. - -- on Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 - is necessary to get gzprintf working correctly. This is done by configure. - -- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works - with other compilers. Use "make test" to check your compiler. - -- gzdopen is not supported on RISCOS, BEOS and by some Mac compilers. - -- For Turbo C the small model is supported only with reduced performance to - avoid any far allocation; it was tested with -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3 - -- For PalmOs, see http://www.cs.uit.no/~perm/PASTA/pilot/software.html - Per Harald Myrvang - - -Acknowledgments: - - The deflate format used by zlib was defined by Phil Katz. The deflate - and zlib specifications were written by L. Peter Deutsch. Thanks to all the - people who reported problems and suggested various improvements in zlib; - they are too numerous to cite here. - -Copyright notice: - - (C) 1995-2002 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 - -If you use the zlib library in a product, we would appreciate *not* -receiving lengthy legal documents to sign. The sources are provided -for free but without warranty of any kind. The library has been -entirely written by Jean-loup Gailly and Mark Adler; it does not -include third-party code. - -If you redistribute modified sources, we would appreciate that you include -in the file ChangeLog history information documenting your changes. diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/adler32.c b/contrib/vmap_extractor_v2/stormlib/zlib/adler32.c deleted file mode 100644 index fae88b65593..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/adler32.c +++ /dev/null @@ -1,48 +0,0 @@ -/* adler32.c -- compute the Adler-32 checksum of a data stream - * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#include "zlib.h" - -#define BASE 65521L /* 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); - -/* ========================================================================= */ -uLong ZEXPORT adler32(adler, buf, len) - uLong adler; - const Bytef *buf; - uInt len; -{ - unsigned long s1 = adler & 0xffff; - unsigned long s2 = (adler >> 16) & 0xffff; - int k; - - if (buf == Z_NULL) return 1L; - - while (len > 0) { - k = len < NMAX ? len : NMAX; - len -= k; - while (k >= 16) { - DO16(buf); - buf += 16; - k -= 16; - } - if (k != 0) do { - s1 += *buf++; - s2 += s1; - } while (--k); - s1 %= BASE; - s2 %= BASE; - } - return (s2 << 16) | s1; -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/algorithm.txt b/contrib/vmap_extractor_v2/stormlib/zlib/algorithm.txt deleted file mode 100644 index cdc830b5deb..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/algorithm.txt +++ /dev/null @@ -1,213 +0,0 @@ -1. Compression algorithm (deflate) - -The deflation algorithm used by gzip (also zip and zlib) is a variation of -LZ77 (Lempel-Ziv 1977, see reference below). It finds duplicated strings in -the input data. The second occurrence of a string is replaced by a -pointer to the previous string, in the form of a pair (distance, -length). Distances are limited to 32K bytes, and lengths are limited -to 258 bytes. When a string does not occur anywhere in the previous -32K bytes, it is emitted as a sequence of literal bytes. (In this -description, `string' must be taken as an arbitrary sequence of bytes, -and is not restricted to printable characters.) - -Literals or match lengths are compressed with one Huffman tree, and -match distances are compressed with another tree. The trees are stored -in a compact form at the start of each block. The blocks can have any -size (except that the compressed data for one block must fit in -available memory). A block is terminated when deflate() determines that -it would be useful to start another block with fresh trees. (This is -somewhat similar to the behavior of LZW-based _compress_.) - -Duplicated strings are found using a hash table. All input strings of -length 3 are inserted in the hash table. A hash index is computed for -the next 3 bytes. If the hash chain for this index is not empty, all -strings in the chain are compared with the current input string, and -the longest match is selected. - -The hash chains are searched starting with the most recent strings, to -favor small distances and thus take advantage of the Huffman encoding. -The hash chains are singly linked. There are no deletions from the -hash chains, the algorithm simply discards matches that are too old. - -To avoid a worst-case situation, very long hash chains are arbitrarily -truncated at a certain length, determined by a runtime option (level -parameter of deflateInit). So deflate() does not always find the longest -possible match but generally finds a match which is long enough. - -deflate() also defers the selection of matches with a lazy evaluation -mechanism. After a match of length N has been found, deflate() searches for -a longer match at the next input byte. If a longer match is found, the -previous match is truncated to a length of one (thus producing a single -literal byte) and the process of lazy evaluation begins again. Otherwise, -the original match is kept, and the next match search is attempted only N -steps later. - -The lazy match evaluation is also subject to a runtime parameter. If -the current match is long enough, deflate() reduces the search for a longer -match, thus speeding up the whole process. If compression ratio is more -important than speed, deflate() attempts a complete second search even if -the first match is already long enough. - -The lazy match evaluation is not performed for the fastest compression -modes (level parameter 1 to 3). For these fast modes, new strings -are inserted in the hash table only when no match was found, or -when the match is not too long. This degrades the compression ratio -but saves time since there are both fewer insertions and fewer searches. - - -2. Decompression algorithm (inflate) - -2.1 Introduction - -The real question is, given a Huffman tree, how to decode fast. The most -important realization is that shorter codes are much more common than -longer codes, so pay attention to decoding the short codes fast, and let -the long codes take longer to decode. - -inflate() sets up a first level table that covers some number of bits of -input less than the length of longest code. It gets that many bits from the -stream, and looks it up in the table. The table will tell if the next -code is that many bits or less and how many, and if it is, it will tell -the value, else it will point to the next level table for which inflate() -grabs more bits and tries to decode a longer code. - -How many bits to make the first lookup is a tradeoff between the time it -takes to decode and the time it takes to build the table. If building the -table took no time (and if you had infinite memory), then there would only -be a first level table to cover all the way to the longest code. However, -building the table ends up taking a lot longer for more bits since short -codes are replicated many times in such a table. What inflate() does is -simply to make the number of bits in the first table a variable, and set it -for the maximum speed. - -inflate() sends new trees relatively often, so it is possibly set for a -smaller first level table than an application that has only one tree for -all the data. For inflate, which has 286 possible codes for the -literal/length tree, the size of the first table is nine bits. Also the -distance trees have 30 possible values, and the size of the first table is -six bits. Note that for each of those cases, the table ended up one bit -longer than the ``average'' code length, i.e. the code length of an -approximately flat code which would be a little more than eight bits for -286 symbols and a little less than five bits for 30 symbols. It would be -interesting to see if optimizing the first level table for other -applications gave values within a bit or two of the flat code size. - - -2.2 More details on the inflate table lookup - -Ok, you want to know what this cleverly obfuscated inflate tree actually -looks like. You are correct that it's not a Huffman tree. It is simply a -lookup table for the first, let's say, nine bits of a Huffman symbol. The -symbol could be as short as one bit or as long as 15 bits. If a particular -symbol is shorter than nine bits, then that symbol's translation is duplicated -in all those entries that start with that symbol's bits. For example, if the -symbol is four bits, then it's duplicated 32 times in a nine-bit table. If a -symbol is nine bits long, it appears in the table once. - -If the symbol is longer than nine bits, then that entry in the table points -to another similar table for the remaining bits. Again, there are duplicated -entries as needed. The idea is that most of the time the symbol will be short -and there will only be one table look up. (That's whole idea behind data -compression in the first place.) For the less frequent long symbols, there -will be two lookups. If you had a compression method with really long -symbols, you could have as many levels of lookups as is efficient. For -inflate, two is enough. - -So a table entry either points to another table (in which case nine bits in -the above example are gobbled), or it contains the translation for the symbol -and the number of bits to gobble. Then you start again with the next -ungobbled bit. - -You may wonder: why not just have one lookup table for how ever many bits the -longest symbol is? The reason is that if you do that, you end up spending -more time filling in duplicate symbol entries than you do actually decoding. -At least for deflate's output that generates new trees every several 10's of -kbytes. You can imagine that filling in a 2^15 entry table for a 15-bit code -would take too long if you're only decoding several thousand symbols. At the -other extreme, you could make a new table for every bit in the code. In fact, -that's essentially a Huffman tree. But then you spend two much time -traversing the tree while decoding, even for short symbols. - -So the number of bits for the first lookup table is a trade of the time to -fill out the table vs. the time spent looking at the second level and above of -the table. - -Here is an example, scaled down: - -The code being decoded, with 10 symbols, from 1 to 6 bits long: - -A: 0 -B: 10 -C: 1100 -D: 11010 -E: 11011 -F: 11100 -G: 11101 -H: 11110 -I: 111110 -J: 111111 - -Let's make the first table three bits long (eight entries): - -000: A,1 -001: A,1 -010: A,1 -011: A,1 -100: B,2 -101: B,2 -110: -> table X (gobble 3 bits) -111: -> table Y (gobble 3 bits) - -Each entry is what the bits decode to and how many bits that is, i.e. how -many bits to gobble. Or the entry points to another table, with the number of -bits to gobble implicit in the size of the table. - -Table X is two bits long since the longest code starting with 110 is five bits -long: - -00: C,1 -01: C,1 -10: D,2 -11: E,2 - -Table Y is three bits long since the longest code starting with 111 is six -bits long: - -000: F,2 -001: F,2 -010: G,2 -011: G,2 -100: H,2 -101: H,2 -110: I,3 -111: J,3 - -So what we have here are three tables with a total of 20 entries that had to -be constructed. That's compared to 64 entries for a single table. Or -compared to 16 entries for a Huffman tree (six two entry tables and one four -entry table). Assuming that the code ideally represents the probability of -the symbols, it takes on the average 1.25 lookups per symbol. That's compared -to one lookup for the single table, or 1.66 lookups per symbol for the -Huffman tree. - -There, I think that gives you a picture of what's going on. For inflate, the -meaning of a particular symbol is often more than just a letter. It can be a -byte (a "literal"), or it can be either a length or a distance which -indicates a base value and a number of bits to fetch after the code that is -added to the base value. Or it might be the special end-of-block code. The -data structures created in inftrees.c try to encode all that information -compactly in the tables. - - -Jean-loup Gailly Mark Adler -jloup@gzip.org madler@alumni.caltech.edu - - -References: - -[LZ77] Ziv J., Lempel A., ``A Universal Algorithm for Sequential Data -Compression,'' IEEE Transactions on Information Theory, Vol. 23, No. 3, -pp. 337-343. - -``DEFLATE Compressed Data Format Specification'' available in -ftp://ds.internic.net/rfc/rfc1951.txt diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/amiga/Makefile.pup b/contrib/vmap_extractor_v2/stormlib/zlib/amiga/Makefile.pup deleted file mode 100644 index 6cfad1dc04a..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/amiga/Makefile.pup +++ /dev/null @@ -1,66 +0,0 @@ -# Amiga powerUP (TM) Makefile -# makefile for libpng and SAS C V6.58/7.00 PPC compiler -# Copyright (C) 1998 by Andreas R. Kleinert - -CC = scppc -CFLAGS = NOSTKCHK NOSINT OPTIMIZE OPTGO OPTPEEP OPTINLOCAL OPTINL \ - OPTLOOP OPTRDEP=8 OPTDEP=8 OPTCOMP=8 -LIBNAME = libzip.a -AR = ppc-amigaos-ar -AR_FLAGS = cr -RANLIB = ppc-amigaos-ranlib -LDFLAGS = -r -o -LDLIBS = LIB:scppc.a -LN = ppc-amigaos-ld -RM = delete quiet - -OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ - zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o - -TEST_OBJS = example.o minigzip.o - -all: example minigzip - -test: all - example - echo hello world | minigzip | minigzip -d - -$(LIBNAME): $(OBJS) - $(AR) $(AR_FLAGS) $@ $(OBJS) - $(RANLIB) $@ - -example: example.o $(LIBNAME) - $(LN) $(LDFLAGS) example LIB:c_ppc.o example.o $(LIBNAME) $(LDLIBS) LIB:end.o - -minigzip: minigzip.o $(LIBNAME) - $(LN) $(LDFLAGS) minigzip LIB:c_ppc.o minigzip.o $(LIBNAME) $(LDLIBS) LIB:end.o - -clean: - $(RM) *.o example minigzip $(LIBNAME) foo.gz - -zip: - zip -ul9 zlib README ChangeLog Makefile Make????.??? Makefile.?? \ - descrip.mms *.[ch] - -tgz: - cd ..; tar cfz zlib/zlib.tgz zlib/README zlib/ChangeLog zlib/Makefile \ - zlib/Make????.??? zlib/Makefile.?? zlib/descrip.mms zlib/*.[ch] - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -adler32.o: zutil.h zlib.h zconf.h -compress.o: zlib.h zconf.h -crc32.o: zutil.h zlib.h zconf.h -deflate.o: deflate.h zutil.h zlib.h zconf.h -example.o: zlib.h zconf.h -gzio.o: zutil.h zlib.h zconf.h -infblock.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h -infcodes.o: zutil.h zlib.h zconf.h inftrees.h infutil.h infcodes.h inffast.h -inffast.o: zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h -inflate.o: zutil.h zlib.h zconf.h infblock.h -inftrees.o: zutil.h zlib.h zconf.h inftrees.h -infutil.o: zutil.h zlib.h zconf.h inftrees.h infutil.h -minigzip.o: zlib.h zconf.h -trees.o: deflate.h zutil.h zlib.h zconf.h -uncompr.o: zlib.h zconf.h -zutil.o: zutil.h zlib.h zconf.h diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/amiga/Makefile.sas b/contrib/vmap_extractor_v2/stormlib/zlib/amiga/Makefile.sas deleted file mode 100644 index 5323e821708..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/amiga/Makefile.sas +++ /dev/null @@ -1,64 +0,0 @@ -# SMakefile for zlib -# Modified from the standard UNIX Makefile Copyright Jean-loup Gailly -# Osma Ahvenlampi -# Amiga, SAS/C 6.56 & Smake - -CC=sc -CFLAGS=OPT -#CFLAGS=OPT CPU=68030 -#CFLAGS=DEBUG=LINE -LDFLAGS=LIB z.lib - -SCOPTIONS=OPTSCHED OPTINLINE OPTALIAS OPTTIME OPTINLOCAL STRMERGE \ - NOICONS PARMS=BOTH NOSTACKCHECK UTILLIB NOVERSION ERRORREXX - -OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ - zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o - -TEST_OBJS = example.o minigzip.o - -all: SCOPTIONS example minigzip - -test: all - `cd`/example - echo hello world | minigzip | minigzip -d - -install: z.lib - copy zlib.h zconf.h INCLUDE: clone - copy z.lib LIB: clone - -z.lib: $(OBJS) - oml z.lib r $(OBJS) - -example: example.o z.lib - $(CC) $(CFLAGS) LINK TO $@ example.o $(LDFLAGS) - -minigzip: minigzip.o z.lib - $(CC) $(CFLAGS) LINK TO $@ minigzip.o $(LDFLAGS) - -clean: - -delete force quiet *.o example minigzip z.lib foo.gz *.lnk SCOPTIONS - -SCOPTIONS: Smakefile - copy to $@ 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 = (alloc_func)0; - stream.zfree = (free_func)0; - 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 (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ - return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/README.contrib b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/README.contrib deleted file mode 100644 index 7ad191cf598..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/README.contrib +++ /dev/null @@ -1,34 +0,0 @@ -All files under this contrib directory are UNSUPPORTED. There were -provided by users of zlib and were not tested by the authors of zlib. -Use at your own risk. Please contact the authors of the contributions -for help about these, not the zlib authors. Thanks. - - -asm386/ by Gilles Vollant - 386 asm code replacing longest_match(), for Visual C++ 4.2 and ML 6.11c - -asm586/ and asm686/ by Brian Raiter - asm code for Pentium and Pentium Pro - See http://www.muppetlabs.com/~breadbox/software/assembly.html - -delphi/ by Bob Dellaca - Support for Delphi - -delphi2/ by Davide Moretti - Another support for C++Builder and Delphi - -minizip/ by Gilles Vollant - Mini zip and unzip based on zlib - See http://www.winimage.com/zLibDll/unzip.html - -iostream/ by Kevin Ruland - A C++ I/O streams interface to the zlib gz* functions - -iostream2/ by Tyge Løvset - Another C++ I/O streams interface - -untgz/ by "Pedro A. Aranda Guti\irrez" - A very simple tar.gz file extractor using zlib - -visual-basic.txt by Carlos Rios - How to use compress(), uncompress() and the gz* functions from VB. diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/gvmat32.asm b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/gvmat32.asm deleted file mode 100644 index 28d527f47f8..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/gvmat32.asm +++ /dev/null @@ -1,559 +0,0 @@ -; -; gvmat32.asm -- Asm portion of the optimized longest_match for 32 bits x86 -; Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant. -; File written by Gilles Vollant, by modifiying the longest_match -; from Jean-loup Gailly in deflate.c -; It need wmask == 0x7fff -; (assembly code is faster with a fixed wmask) -; -; For Visual C++ 4.2 and ML 6.11c (version in directory \MASM611C of Win95 DDK) -; I compile with : "ml /coff /Zi /c gvmat32.asm" -; - -;uInt longest_match_7fff(s, cur_match) -; deflate_state *s; -; IPos cur_match; /* current match */ - - NbStack equ 76 - cur_match equ dword ptr[esp+NbStack-0] - str_s equ dword ptr[esp+NbStack-4] -; 5 dword on top (ret,ebp,esi,edi,ebx) - adrret equ dword ptr[esp+NbStack-8] - pushebp equ dword ptr[esp+NbStack-12] - pushedi equ dword ptr[esp+NbStack-16] - pushesi equ dword ptr[esp+NbStack-20] - pushebx equ dword ptr[esp+NbStack-24] - - chain_length equ dword ptr [esp+NbStack-28] - limit equ dword ptr [esp+NbStack-32] - best_len equ dword ptr [esp+NbStack-36] - window equ dword ptr [esp+NbStack-40] - prev equ dword ptr [esp+NbStack-44] - scan_start equ word ptr [esp+NbStack-48] - wmask equ dword ptr [esp+NbStack-52] - match_start_ptr equ dword ptr [esp+NbStack-56] - nice_match equ dword ptr [esp+NbStack-60] - scan equ dword ptr [esp+NbStack-64] - - windowlen equ dword ptr [esp+NbStack-68] - match_start equ dword ptr [esp+NbStack-72] - strend equ dword ptr [esp+NbStack-76] - NbStackAdd equ (NbStack-24) - - .386p - - name gvmatch - .MODEL FLAT - - - -; all the +4 offsets are due to the addition of pending_buf_size (in zlib -; in the deflate_state structure since the asm code was first written -; (if you compile with zlib 1.0.4 or older, remove the +4). -; Note : these value are good with a 8 bytes boundary pack structure - dep_chain_length equ 70h+4 - dep_window equ 2ch+4 - dep_strstart equ 60h+4 - dep_prev_length equ 6ch+4 - dep_nice_match equ 84h+4 - dep_w_size equ 20h+4 - dep_prev equ 34h+4 - dep_w_mask equ 28h+4 - dep_good_match equ 80h+4 - dep_match_start equ 64h+4 - dep_lookahead equ 68h+4 - - -_TEXT segment - -IFDEF NOUNDERLINE - public longest_match_7fff -; public match_init -ELSE - public _longest_match_7fff -; public _match_init -ENDIF - - MAX_MATCH equ 258 - MIN_MATCH equ 3 - MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1) - - - -IFDEF NOUNDERLINE -;match_init proc near -; ret -;match_init endp -ELSE -;_match_init proc near -; ret -;_match_init endp -ENDIF - - -IFDEF NOUNDERLINE -longest_match_7fff proc near -ELSE -_longest_match_7fff proc near -ENDIF - - mov edx,[esp+4] - - - - push ebp - push edi - push esi - push ebx - - sub esp,NbStackAdd - -; initialize or check the variables used in match.asm. - mov ebp,edx - -; chain_length = s->max_chain_length -; if (prev_length>=good_match) chain_length >>= 2 - mov edx,[ebp+dep_chain_length] - mov ebx,[ebp+dep_prev_length] - cmp [ebp+dep_good_match],ebx - ja noshr - shr edx,2 -noshr: -; we increment chain_length because in the asm, the --chain_lenght is in the beginning of the loop - inc edx - mov edi,[ebp+dep_nice_match] - mov chain_length,edx - mov eax,[ebp+dep_lookahead] - cmp eax,edi -; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; - jae nolookaheadnicematch - mov edi,eax -nolookaheadnicematch: -; best_len = s->prev_length - mov best_len,ebx - -; window = s->window - mov esi,[ebp+dep_window] - mov ecx,[ebp+dep_strstart] - mov window,esi - - mov nice_match,edi -; scan = window + strstart - add esi,ecx - mov scan,esi -; dx = *window - mov dx,word ptr [esi] -; bx = *(window+best_len-1) - mov bx,word ptr [esi+ebx-1] - add esi,MAX_MATCH-1 -; scan_start = *scan - mov scan_start,dx -; strend = scan + MAX_MATCH-1 - mov strend,esi -; bx = scan_end = *(window+best_len-1) - -; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? -; s->strstart - (IPos)MAX_DIST(s) : NIL; - - mov esi,[ebp+dep_w_size] - sub esi,MIN_LOOKAHEAD -; here esi = MAX_DIST(s) - sub ecx,esi - ja nodist - xor ecx,ecx -nodist: - mov limit,ecx - -; prev = s->prev - mov edx,[ebp+dep_prev] - mov prev,edx - -; - mov edx,dword ptr [ebp+dep_match_start] - mov bp,scan_start - mov eax,cur_match - mov match_start,edx - - mov edx,window - mov edi,edx - add edi,best_len - mov esi,prev - dec edi -; windowlen = window + best_len -1 - mov windowlen,edi - - jmp beginloop2 - align 4 - -; here, in the loop -; eax = ax = cur_match -; ecx = limit -; bx = scan_end -; bp = scan_start -; edi = windowlen (window + best_len -1) -; esi = prev - - -;// here; chain_length <=16 -normalbeg0add16: - add chain_length,16 - jz exitloop -normalbeg0: - cmp word ptr[edi+eax],bx - je normalbeg2noroll -rcontlabnoroll: -; cur_match = prev[cur_match & wmask] - and eax,7fffh - mov ax,word ptr[esi+eax*2] -; if cur_match > limit, go to exitloop - cmp ecx,eax - jnb exitloop -; if --chain_length != 0, go to exitloop - dec chain_length - jnz normalbeg0 - jmp exitloop - -normalbeg2noroll: -; if (scan_start==*(cur_match+window)) goto normalbeg2 - cmp bp,word ptr[edx+eax] - jne rcontlabnoroll - jmp normalbeg2 - -contloop3: - mov edi,windowlen - -; cur_match = prev[cur_match & wmask] - and eax,7fffh - mov ax,word ptr[esi+eax*2] -; if cur_match > limit, go to exitloop - cmp ecx,eax -jnbexitloopshort1: - jnb exitloop -; if --chain_length != 0, go to exitloop - - -; begin the main loop -beginloop2: - sub chain_length,16+1 -; if chain_length <=16, don't use the unrolled loop - jna normalbeg0add16 - -do16: - cmp word ptr[edi+eax],bx - je normalbeg2dc0 - -maccn MACRO lab - and eax,7fffh - mov ax,word ptr[esi+eax*2] - cmp ecx,eax - jnb exitloop - cmp word ptr[edi+eax],bx - je lab - ENDM - -rcontloop0: - maccn normalbeg2dc1 - -rcontloop1: - maccn normalbeg2dc2 - -rcontloop2: - maccn normalbeg2dc3 - -rcontloop3: - maccn normalbeg2dc4 - -rcontloop4: - maccn normalbeg2dc5 - -rcontloop5: - maccn normalbeg2dc6 - -rcontloop6: - maccn normalbeg2dc7 - -rcontloop7: - maccn normalbeg2dc8 - -rcontloop8: - maccn normalbeg2dc9 - -rcontloop9: - maccn normalbeg2dc10 - -rcontloop10: - maccn short normalbeg2dc11 - -rcontloop11: - maccn short normalbeg2dc12 - -rcontloop12: - maccn short normalbeg2dc13 - -rcontloop13: - maccn short normalbeg2dc14 - -rcontloop14: - maccn short normalbeg2dc15 - -rcontloop15: - and eax,7fffh - mov ax,word ptr[esi+eax*2] - cmp ecx,eax - jnb exitloop - - sub chain_length,16 - ja do16 - jmp normalbeg0add16 - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -normbeg MACRO rcontlab,valsub -; if we are here, we know that *(match+best_len-1) == scan_end - cmp bp,word ptr[edx+eax] -; if (match != scan_start) goto rcontlab - jne rcontlab -; calculate the good chain_length, and we'll compare scan and match string - add chain_length,16-valsub - jmp iseq - ENDM - - -normalbeg2dc11: - normbeg rcontloop11,11 - -normalbeg2dc12: - normbeg short rcontloop12,12 - -normalbeg2dc13: - normbeg short rcontloop13,13 - -normalbeg2dc14: - normbeg short rcontloop14,14 - -normalbeg2dc15: - normbeg short rcontloop15,15 - -normalbeg2dc10: - normbeg rcontloop10,10 - -normalbeg2dc9: - normbeg rcontloop9,9 - -normalbeg2dc8: - normbeg rcontloop8,8 - -normalbeg2dc7: - normbeg rcontloop7,7 - -normalbeg2dc6: - normbeg rcontloop6,6 - -normalbeg2dc5: - normbeg rcontloop5,5 - -normalbeg2dc4: - normbeg rcontloop4,4 - -normalbeg2dc3: - normbeg rcontloop3,3 - -normalbeg2dc2: - normbeg rcontloop2,2 - -normalbeg2dc1: - normbeg rcontloop1,1 - -normalbeg2dc0: - normbeg rcontloop0,0 - - -; we go in normalbeg2 because *(ushf*)(match+best_len-1) == scan_end - -normalbeg2: - mov edi,window - - cmp bp,word ptr[edi+eax] - jne contloop3 ; if *(ushf*)match != scan_start, continue - -iseq: -; if we are here, we know that *(match+best_len-1) == scan_end -; and (match == scan_start) - - mov edi,edx - mov esi,scan ; esi = scan - add edi,eax ; edi = window + cur_match = match - - mov edx,[esi+3] ; compare manually dword at match+3 - xor edx,[edi+3] ; and scan +3 - - jz begincompare ; if equal, go to long compare - -; we will determine the unmatch byte and calculate len (in esi) - or dl,dl - je eq1rr - mov esi,3 - jmp trfinval -eq1rr: - or dx,dx - je eq1 - - mov esi,4 - jmp trfinval -eq1: - and edx,0ffffffh - jz eq11 - mov esi,5 - jmp trfinval -eq11: - mov esi,6 - jmp trfinval - -begincompare: - ; here we now scan and match begin same - add edi,6 - add esi,6 - mov ecx,(MAX_MATCH-(2+4))/4 ; scan for at most MAX_MATCH bytes - repe cmpsd ; loop until mismatch - - je trfin ; go to trfin if not unmatch -; we determine the unmatch byte - sub esi,4 - mov edx,[edi-4] - xor edx,[esi] - - or dl,dl - jnz trfin - inc esi - - or dx,dx - jnz trfin - inc esi - - and edx,0ffffffh - jnz trfin - inc esi - -trfin: - sub esi,scan ; esi = len -trfinval: -; here we have finised compare, and esi contain len of equal string - cmp esi,best_len ; if len > best_len, go newbestlen - ja short newbestlen -; now we restore edx, ecx and esi, for the big loop - mov esi,prev - mov ecx,limit - mov edx,window - jmp contloop3 - -newbestlen: - mov best_len,esi ; len become best_len - - mov match_start,eax ; save new position as match_start - cmp esi,nice_match ; if best_len >= nice_match, exit - jae exitloop - mov ecx,scan - mov edx,window ; restore edx=window - add ecx,esi - add esi,edx - - dec esi - mov windowlen,esi ; windowlen = window + best_len-1 - mov bx,[ecx-1] ; bx = *(scan+best_len-1) = scan_end - -; now we restore ecx and esi, for the big loop : - mov esi,prev - mov ecx,limit - jmp contloop3 - -exitloop: -; exit : s->match_start=match_start - mov ebx,match_start - mov ebp,str_s - mov ecx,best_len - mov dword ptr [ebp+dep_match_start],ebx - mov eax,dword ptr [ebp+dep_lookahead] - cmp ecx,eax - ja minexlo - mov eax,ecx -minexlo: -; return min(best_len,s->lookahead) - -; restore stack and register ebx,esi,edi,ebp - add esp,NbStackAdd - - pop ebx - pop esi - pop edi - pop ebp - ret -InfoAuthor: -; please don't remove this string ! -; Your are free use gvmat32 in any fre or commercial apps if you don't remove the string in the binary! - db 0dh,0ah,"GVMat32 optimised assembly code written 1996-98 by Gilles Vollant",0dh,0ah - - - -IFDEF NOUNDERLINE -longest_match_7fff endp -ELSE -_longest_match_7fff endp -ENDIF - - -IFDEF NOUNDERLINE -cpudetect32 proc near -ELSE -_cpudetect32 proc near -ENDIF - - - pushfd ; push original EFLAGS - pop eax ; get original EFLAGS - mov ecx, eax ; save original EFLAGS - xor eax, 40000h ; flip AC bit in EFLAGS - push eax ; save new EFLAGS value on stack - popfd ; replace current EFLAGS value - pushfd ; get new EFLAGS - pop eax ; store new EFLAGS in EAX - xor eax, ecx ; can’t toggle AC bit, processor=80386 - jz end_cpu_is_386 ; jump if 80386 processor - push ecx - popfd ; restore AC bit in EFLAGS first - - pushfd - pushfd - pop ecx - - mov eax, ecx ; get original EFLAGS - xor eax, 200000h ; flip ID bit in EFLAGS - push eax ; save new EFLAGS value on stack - popfd ; replace current EFLAGS value - pushfd ; get new EFLAGS - pop eax ; store new EFLAGS in EAX - popfd ; restore original EFLAGS - xor eax, ecx ; can’t toggle ID bit, - je is_old_486 ; processor=old - - mov eax,1 - db 0fh,0a2h ;CPUID - -exitcpudetect: - ret - -end_cpu_is_386: - mov eax,0300h - jmp exitcpudetect - -is_old_486: - mov eax,0400h - jmp exitcpudetect - -IFDEF NOUNDERLINE -cpudetect32 endp -ELSE -_cpudetect32 endp -ENDIF - -_TEXT ends -end diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/gvmat32c.c b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/gvmat32c.c deleted file mode 100644 index d853bb7ce8a..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/gvmat32c.c +++ /dev/null @@ -1,200 +0,0 @@ -/* gvmat32.c -- C portion of the optimized longest_match for 32 bits x86 - * Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant. - * File written by Gilles Vollant, by modifiying the longest_match - * from Jean-loup Gailly in deflate.c - * it prepare all parameters and call the assembly longest_match_gvasm - * longest_match execute standard C code is wmask != 0x7fff - * (assembly code is faster with a fixed wmask) - * - */ - -#include "deflate.h" - -#undef FAR -#include - -#ifdef ASMV -#define NIL 0 - -#define UNALIGNED_OK - - -/* if your C compiler don't add underline before function name, - define ADD_UNDERLINE_ASMFUNC */ -#ifdef ADD_UNDERLINE_ASMFUNC -#define longest_match_7fff _longest_match_7fff -#endif - - - -void match_init() -{ -} - -unsigned long cpudetect32(); - -uInt longest_match_c( - deflate_state *s, - IPos cur_match); /* current match */ - - -uInt longest_match_7fff( - deflate_state *s, - IPos cur_match); /* current match */ - -uInt longest_match( - deflate_state *s, - IPos cur_match) /* current match */ -{ - static uInt iIsPPro=2; - - if ((s->w_mask == 0x7fff) && (iIsPPro==0)) - return longest_match_7fff(s,cur_match); - - if (iIsPPro==2) - iIsPPro = (((cpudetect32()/0x100)&0xf)>=6) ? 1 : 0; - - return longest_match_c(s,cur_match); -} - - - -uInt longest_match_c(s, cur_match) - deflate_state *s; - IPos cur_match; /* current 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: - */ -#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 */ diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/mkgvmt32.bat b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/mkgvmt32.bat deleted file mode 100644 index 6c5ffd7a024..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/mkgvmt32.bat +++ /dev/null @@ -1 +0,0 @@ -c:\masm611\bin\ml /coff /Zi /c /Flgvmat32.lst gvmat32.asm diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/zlibvc.def b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/zlibvc.def deleted file mode 100644 index 7e9d60d55d9..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/zlibvc.def +++ /dev/null @@ -1,74 +0,0 @@ -LIBRARY "zlib" - -DESCRIPTION '"""zlib data compression library"""' - - -VERSION 1.11 - - -HEAPSIZE 1048576,8192 - -EXPORTS - adler32 @1 - compress @2 - crc32 @3 - deflate @4 - deflateCopy @5 - deflateEnd @6 - deflateInit2_ @7 - deflateInit_ @8 - deflateParams @9 - deflateReset @10 - deflateSetDictionary @11 - gzclose @12 - gzdopen @13 - gzerror @14 - gzflush @15 - gzopen @16 - gzread @17 - gzwrite @18 - inflate @19 - inflateEnd @20 - inflateInit2_ @21 - inflateInit_ @22 - inflateReset @23 - inflateSetDictionary @24 - inflateSync @25 - uncompress @26 - zlibVersion @27 - gzprintf @28 - gzputc @29 - gzgetc @30 - gzseek @31 - gzrewind @32 - gztell @33 - gzeof @34 - gzsetparams @35 - zError @36 - inflateSyncPoint @37 - get_crc_table @38 - compress2 @39 - gzputs @40 - gzgets @41 - - unzOpen @61 - unzClose @62 - unzGetGlobalInfo @63 - unzGetCurrentFileInfo @64 - unzGoToFirstFile @65 - unzGoToNextFile @66 - unzOpenCurrentFile @67 - unzReadCurrentFile @68 - unztell @70 - unzeof @71 - unzCloseCurrentFile @72 - unzGetGlobalComment @73 - unzStringFileNameCompare @74 - unzLocateFile @75 - unzGetLocalExtrafield @76 - - zipOpen @80 - zipOpenNewFileInZip @81 - zipWriteInFileInZip @82 - zipCloseFileInZip @83 - zipClose @84 diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/zlibvc.dsp b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/zlibvc.dsp deleted file mode 100644 index a70d4d4a6b0..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/zlibvc.dsp +++ /dev/null @@ -1,651 +0,0 @@ -# Microsoft Developer Studio Project File - Name="zlibvc" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 5.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 -# TARGTYPE "Win32 (ALPHA) Dynamic-Link Library" 0x0602 - -CFG=zlibvc - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "zlibvc.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "zlibvc.mak" CFG="zlibvc - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "zlibvc - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "zlibvc - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "zlibvc - Win32 ReleaseAxp" (based on\ - "Win32 (ALPHA) Dynamic-Link Library") -!MESSAGE "zlibvc - Win32 ReleaseWithoutAsm" (based on\ - "Win32 (x86) Dynamic-Link Library") -!MESSAGE "zlibvc - Win32 ReleaseWithoutCrtdll" (based on\ - "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir ".\Release" -# PROP BASE Intermediate_Dir ".\Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir ".\Release" -# PROP Intermediate_Dir ".\Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /FD /c -# SUBTRACT CPP /YX -MTL=midl.exe -# ADD BASE MTL /nologo /D "NDEBUG" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -RSC=rc.exe -# ADD BASE RSC /l 0x40c /d "NDEBUG" -# ADD RSC /l 0x40c /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# 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 /dll /machine:I386 -# ADD LINK32 gvmat32.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib crtdll.lib /nologo /subsystem:windows /dll /map /machine:I386 /nodefaultlib /out:".\Release\zlib.dll" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir ".\Debug" -# PROP BASE Intermediate_Dir ".\Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir ".\Debug" -# PROP Intermediate_Dir ".\Debug" -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /FD /c -# SUBTRACT CPP /YX -MTL=midl.exe -# ADD BASE MTL /nologo /D "_DEBUG" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -RSC=rc.exe -# ADD BASE RSC /l 0x40c /d "_DEBUG" -# ADD RSC /l 0x40c /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# 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 /dll /debug /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:".\Debug\zlib.dll" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "zlibvc__" -# PROP BASE Intermediate_Dir "zlibvc__" -# PROP BASE Ignore_Export_Lib 0 -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "zlibvc__" -# PROP Intermediate_Dir "zlibvc__" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -MTL=midl.exe -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -CPP=cl.exe -# ADD BASE CPP /nologo /MT /Gt0 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /YX /FD /c -# ADD CPP /nologo /MT /Gt0 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /FD /c -# SUBTRACT CPP /YX -RSC=rc.exe -# ADD BASE RSC /l 0x40c /d "NDEBUG" -# ADD RSC /l 0x40c /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 crtdll.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /map /machine:ALPHA /nodefaultlib /out:".\Release\zlib.dll" -# SUBTRACT BASE LINK32 /pdb:none -# ADD LINK32 crtdll.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /map /machine:ALPHA /nodefaultlib /out:"zlibvc__\zlib.dll" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "zlibvc_0" -# PROP BASE Intermediate_Dir "zlibvc_0" -# PROP BASE Ignore_Export_Lib 0 -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "zlibvc_0" -# PROP Intermediate_Dir "zlibvc_0" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /FD /c -# SUBTRACT CPP /YX -MTL=midl.exe -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -RSC=rc.exe -# ADD BASE RSC /l 0x40c /d "NDEBUG" -# ADD RSC /l 0x40c /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib crtdll.lib /nologo /subsystem:windows /dll /map /machine:I386 /nodefaultlib /out:".\Release\zlib.dll" -# SUBTRACT BASE LINK32 /pdb:none -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib crtdll.lib /nologo /subsystem:windows /dll /map /machine:I386 /nodefaultlib /out:".\zlibvc_0\zlib.dll" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "zlibvc_1" -# PROP BASE Intermediate_Dir "zlibvc_1" -# PROP BASE Ignore_Export_Lib 0 -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "zlibvc_1" -# PROP Intermediate_Dir "zlibvc_1" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /FD /c -# SUBTRACT CPP /YX -MTL=midl.exe -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -RSC=rc.exe -# ADD BASE RSC /l 0x40c /d "NDEBUG" -# ADD RSC /l 0x40c /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 gvmat32.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib crtdll.lib /nologo /subsystem:windows /dll /map /machine:I386 /nodefaultlib /out:".\Release\zlib.dll" -# SUBTRACT BASE LINK32 /pdb:none -# ADD LINK32 gvmat32.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib crtdll.lib /nologo /subsystem:windows /dll /map /machine:I386 /nodefaultlib /out:".\zlibvc_1\zlib.dll" -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "zlibvc - Win32 Release" -# Name "zlibvc - Win32 Debug" -# Name "zlibvc - Win32 ReleaseAxp" -# Name "zlibvc - Win32 ReleaseWithoutAsm" -# Name "zlibvc - Win32 ReleaseWithoutCrtdll" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90" -# Begin Source File - -SOURCE=.\adler32.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_ADLER=\ - ".\zconf.h"\ - ".\zlib.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\compress.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_COMPR=\ - ".\zconf.h"\ - ".\zlib.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\crc32.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_CRC32=\ - ".\zconf.h"\ - ".\zlib.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\deflate.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_DEFLA=\ - ".\deflate.h"\ - ".\zconf.h"\ - ".\zlib.h"\ - ".\zutil.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\gvmat32c.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\gzio.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_GZIO_=\ - ".\zconf.h"\ - ".\zlib.h"\ - ".\zutil.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\infblock.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_INFBL=\ - ".\infblock.h"\ - ".\infcodes.h"\ - ".\inftrees.h"\ - ".\infutil.h"\ - ".\zconf.h"\ - ".\zlib.h"\ - ".\zutil.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\infcodes.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_INFCO=\ - ".\infblock.h"\ - ".\infcodes.h"\ - ".\inffast.h"\ - ".\inftrees.h"\ - ".\infutil.h"\ - ".\zconf.h"\ - ".\zlib.h"\ - ".\zutil.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\inffast.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_INFFA=\ - ".\infblock.h"\ - ".\infcodes.h"\ - ".\inffast.h"\ - ".\inftrees.h"\ - ".\infutil.h"\ - ".\zconf.h"\ - ".\zlib.h"\ - ".\zutil.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\inflate.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_INFLA=\ - ".\infblock.h"\ - ".\zconf.h"\ - ".\zlib.h"\ - ".\zutil.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\inftrees.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_INFTR=\ - ".\inftrees.h"\ - ".\zconf.h"\ - ".\zlib.h"\ - ".\zutil.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\infutil.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_INFUT=\ - ".\infblock.h"\ - ".\infcodes.h"\ - ".\inftrees.h"\ - ".\infutil.h"\ - ".\zconf.h"\ - ".\zlib.h"\ - ".\zutil.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\trees.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_TREES=\ - ".\deflate.h"\ - ".\zconf.h"\ - ".\zlib.h"\ - ".\zutil.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\uncompr.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_UNCOM=\ - ".\zconf.h"\ - ".\zlib.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\unzip.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\zip.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\zlib.rc -# End Source File -# Begin Source File - -SOURCE=.\zlibvc.def -# End Source File -# Begin Source File - -SOURCE=.\zutil.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_ZUTIL=\ - ".\zconf.h"\ - ".\zlib.h"\ - ".\zutil.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd" -# Begin Source File - -SOURCE=.\deflate.h -# End Source File -# Begin Source File - -SOURCE=.\infblock.h -# End Source File -# Begin Source File - -SOURCE=.\infcodes.h -# End Source File -# Begin Source File - -SOURCE=.\inffast.h -# End Source File -# Begin Source File - -SOURCE=.\inftrees.h -# End Source File -# Begin Source File - -SOURCE=.\infutil.h -# End Source File -# Begin Source File - -SOURCE=.\zconf.h -# End Source File -# Begin Source File - -SOURCE=.\zlib.h -# End Source File -# Begin Source File - -SOURCE=.\zutil.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" -# End Group -# End Target -# End Project diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/zlibvc.dsw b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/zlibvc.dsw deleted file mode 100644 index 493cd870365..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm386/zlibvc.dsw +++ /dev/null @@ -1,41 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 5.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "zlibstat"=.\zlibstat.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "zlibvc"=.\zlibvc.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm586/README.586 b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm586/README.586 deleted file mode 100644 index 6bb78f32069..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm586/README.586 +++ /dev/null @@ -1,43 +0,0 @@ -This is a patched version of zlib modified to use -Pentium-optimized assembly code in the deflation algorithm. The files -changed/added by this patch are: - -README.586 -match.S - -The effectiveness of these modifications is a bit marginal, as the the -program's bottleneck seems to be mostly L1-cache contention, for which -there is no real way to work around without rewriting the basic -algorithm. The speedup on average is around 5-10% (which is generally -less than the amount of variance between subsequent executions). -However, when used at level 9 compression, the cache contention can -drop enough for the assembly version to achieve 10-20% speedup (and -sometimes more, depending on the amount of overall redundancy in the -files). Even here, though, cache contention can still be the limiting -factor, depending on the nature of the program using the zlib library. -This may also mean that better improvements will be seen on a Pentium -with MMX, which suffers much less from L1-cache contention, but I have -not yet verified this. - -Note that this code has been tailored for the Pentium in particular, -and will not perform well on the Pentium Pro (due to the use of a -partial register in the inner loop). - -If you are using an assembler other than GNU as, you will have to -translate match.S to use your assembler's syntax. (Have fun.) - -Brian Raiter -breadbox@muppetlabs.com -April, 1998 - - -Added for zlib 1.1.3: - -The patches come from -http://www.muppetlabs.com/~breadbox/software/assembly.html - -To compile zlib with this asm file, copy match.S to the zlib directory -then do: - -CFLAGS="-O3 -DASMV" ./configure -make OBJA=match.o diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm586/match.S b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm586/match.S deleted file mode 100644 index 8f1614078f8..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm586/match.S +++ /dev/null @@ -1,354 +0,0 @@ -/* match.s -- Pentium-optimized version of longest_match() - * Written for zlib 1.1.2 - * Copyright (C) 1998 Brian Raiter - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License. - */ - -#ifndef NO_UNDERLINE -#define match_init _match_init -#define longest_match _longest_match -#endif - -#define MAX_MATCH (258) -#define MIN_MATCH (3) -#define MIN_LOOKAHEAD (MAX_MATCH + MIN_MATCH + 1) -#define MAX_MATCH_8 ((MAX_MATCH + 7) & ~7) - -/* stack frame offsets */ - -#define wmask 0 /* local copy of s->wmask */ -#define window 4 /* local copy of s->window */ -#define windowbestlen 8 /* s->window + bestlen */ -#define chainlenscanend 12 /* high word: current chain len */ - /* low word: last bytes sought */ -#define scanstart 16 /* first two bytes of string */ -#define scanalign 20 /* dword-misalignment of string */ -#define nicematch 24 /* a good enough match size */ -#define bestlen 28 /* size of best match so far */ -#define scan 32 /* ptr to string wanting match */ - -#define LocalVarsSize (36) -/* saved ebx 36 */ -/* saved edi 40 */ -/* saved esi 44 */ -/* saved ebp 48 */ -/* return address 52 */ -#define deflatestate 56 /* the function arguments */ -#define curmatch 60 - -/* Offsets for fields in the deflate_state structure. These numbers - * are calculated from the definition of deflate_state, with the - * assumption that the compiler will dword-align the fields. (Thus, - * changing the definition of deflate_state could easily cause this - * program to crash horribly, without so much as a warning at - * compile time. Sigh.) - */ -#define dsWSize 36 -#define dsWMask 44 -#define dsWindow 48 -#define dsPrev 56 -#define dsMatchLen 88 -#define dsPrevMatch 92 -#define dsStrStart 100 -#define dsMatchStart 104 -#define dsLookahead 108 -#define dsPrevLen 112 -#define dsMaxChainLen 116 -#define dsGoodMatch 132 -#define dsNiceMatch 136 - - -.file "match.S" - -.globl match_init, longest_match - -.text - -/* uInt longest_match(deflate_state *deflatestate, IPos curmatch) */ - -longest_match: - -/* Save registers that the compiler may be using, and adjust %esp to */ -/* make room for our stack frame. */ - - pushl %ebp - pushl %edi - pushl %esi - pushl %ebx - subl $LocalVarsSize, %esp - -/* Retrieve the function arguments. %ecx will hold cur_match */ -/* throughout the entire function. %edx will hold the pointer to the */ -/* deflate_state structure during the function's setup (before */ -/* entering the main loop). */ - - movl deflatestate(%esp), %edx - movl curmatch(%esp), %ecx - -/* if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; */ - - movl dsNiceMatch(%edx), %eax - movl dsLookahead(%edx), %ebx - cmpl %eax, %ebx - jl LookaheadLess - movl %eax, %ebx -LookaheadLess: movl %ebx, nicematch(%esp) - -/* register Bytef *scan = s->window + s->strstart; */ - - movl dsWindow(%edx), %esi - movl %esi, window(%esp) - movl dsStrStart(%edx), %ebp - lea (%esi,%ebp), %edi - movl %edi, scan(%esp) - -/* Determine how many bytes the scan ptr is off from being */ -/* dword-aligned. */ - - movl %edi, %eax - negl %eax - andl $3, %eax - movl %eax, scanalign(%esp) - -/* IPos limit = s->strstart > (IPos)MAX_DIST(s) ? */ -/* s->strstart - (IPos)MAX_DIST(s) : NIL; */ - - movl dsWSize(%edx), %eax - subl $MIN_LOOKAHEAD, %eax - subl %eax, %ebp - jg LimitPositive - xorl %ebp, %ebp -LimitPositive: - -/* unsigned chain_length = s->max_chain_length; */ -/* if (s->prev_length >= s->good_match) { */ -/* chain_length >>= 2; */ -/* } */ - - movl dsPrevLen(%edx), %eax - movl dsGoodMatch(%edx), %ebx - cmpl %ebx, %eax - movl dsMaxChainLen(%edx), %ebx - jl LastMatchGood - shrl $2, %ebx -LastMatchGood: - -/* chainlen is decremented once beforehand so that the function can */ -/* use the sign flag instead of the zero flag for the exit test. */ -/* It is then shifted into the high word, to make room for the scanend */ -/* scanend value, which it will always accompany. */ - - decl %ebx - shll $16, %ebx - -/* int best_len = s->prev_length; */ - - movl dsPrevLen(%edx), %eax - movl %eax, bestlen(%esp) - -/* Store the sum of s->window + best_len in %esi locally, and in %esi. */ - - addl %eax, %esi - movl %esi, windowbestlen(%esp) - -/* register ush scan_start = *(ushf*)scan; */ -/* register ush scan_end = *(ushf*)(scan+best_len-1); */ - - movw (%edi), %bx - movw %bx, scanstart(%esp) - movw -1(%edi,%eax), %bx - movl %ebx, chainlenscanend(%esp) - -/* Posf *prev = s->prev; */ -/* uInt wmask = s->w_mask; */ - - movl dsPrev(%edx), %edi - movl dsWMask(%edx), %edx - mov %edx, wmask(%esp) - -/* Jump into the main loop. */ - - jmp LoopEntry - -.balign 16 - -/* do { - * match = s->window + cur_match; - * if (*(ushf*)(match+best_len-1) != scan_end || - * *(ushf*)match != scan_start) continue; - * [...] - * } while ((cur_match = prev[cur_match & wmask]) > limit - * && --chain_length != 0); - * - * Here is the inner loop of the function. The function will spend the - * majority of its time in this loop, and majority of that time will - * be spent in the first ten instructions. - * - * Within this loop: - * %ebx = chainlenscanend - i.e., ((chainlen << 16) | scanend) - * %ecx = curmatch - * %edx = curmatch & wmask - * %esi = windowbestlen - i.e., (window + bestlen) - * %edi = prev - * %ebp = limit - * - * Two optimization notes on the choice of instructions: - * - * The first instruction uses a 16-bit address, which costs an extra, - * unpairable cycle. This is cheaper than doing a 32-bit access and - * zeroing the high word, due to the 3-cycle misalignment penalty which - * would occur half the time. This also turns out to be cheaper than - * doing two separate 8-bit accesses, as the memory is so rarely in the - * L1 cache. - * - * The window buffer, however, apparently spends a lot of time in the - * cache, and so it is faster to retrieve the word at the end of the - * match string with two 8-bit loads. The instructions that test the - * word at the beginning of the match string, however, are executed - * much less frequently, and there it was cheaper to use 16-bit - * instructions, which avoided the necessity of saving off and - * subsequently reloading one of the other registers. - */ -LookupLoop: - /* 1 U & V */ - movw (%edi,%edx,2), %cx /* 2 U pipe */ - movl wmask(%esp), %edx /* 2 V pipe */ - cmpl %ebp, %ecx /* 3 U pipe */ - jbe LeaveNow /* 3 V pipe */ - subl $0x00010000, %ebx /* 4 U pipe */ - js LeaveNow /* 4 V pipe */ -LoopEntry: movb -1(%esi,%ecx), %al /* 5 U pipe */ - andl %ecx, %edx /* 5 V pipe */ - cmpb %bl, %al /* 6 U pipe */ - jnz LookupLoop /* 6 V pipe */ - movb (%esi,%ecx), %ah - cmpb %bh, %ah - jnz LookupLoop - movl window(%esp), %eax - movw (%eax,%ecx), %ax - cmpw scanstart(%esp), %ax - jnz LookupLoop - -/* Store the current value of chainlen. */ - - movl %ebx, chainlenscanend(%esp) - -/* Point %edi to the string under scrutiny, and %esi to the string we */ -/* are hoping to match it up with. In actuality, %esi and %edi are */ -/* both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and %edx is */ -/* initialized to -(MAX_MATCH_8 - scanalign). */ - - movl window(%esp), %esi - movl scan(%esp), %edi - addl %ecx, %esi - movl scanalign(%esp), %eax - movl $(-MAX_MATCH_8), %edx - lea MAX_MATCH_8(%edi,%eax), %edi - lea MAX_MATCH_8(%esi,%eax), %esi - -/* Test the strings for equality, 8 bytes at a time. At the end, - * adjust %edx so that it is offset to the exact byte that mismatched. - * - * We already know at this point that the first three bytes of the - * strings match each other, and they can be safely passed over before - * starting the compare loop. So what this code does is skip over 0-3 - * bytes, as much as necessary in order to dword-align the %edi - * pointer. (%esi will still be misaligned three times out of four.) - * - * It should be confessed that this loop usually does not represent - * much of the total running time. Replacing it with a more - * straightforward "rep cmpsb" would not drastically degrade - * performance. - */ -LoopCmps: - movl (%esi,%edx), %eax - movl (%edi,%edx), %ebx - xorl %ebx, %eax - jnz LeaveLoopCmps - movl 4(%esi,%edx), %eax - movl 4(%edi,%edx), %ebx - xorl %ebx, %eax - jnz LeaveLoopCmps4 - addl $8, %edx - jnz LoopCmps - jmp LenMaximum -LeaveLoopCmps4: addl $4, %edx -LeaveLoopCmps: testl $0x0000FFFF, %eax - jnz LenLower - addl $2, %edx - shrl $16, %eax -LenLower: subb $1, %al - adcl $0, %edx - -/* Calculate the length of the match. If it is longer than MAX_MATCH, */ -/* then automatically accept it as the best possible match and leave. */ - - lea (%edi,%edx), %eax - movl scan(%esp), %edi - subl %edi, %eax - cmpl $MAX_MATCH, %eax - jge LenMaximum - -/* If the length of the match is not longer than the best match we */ -/* have so far, then forget it and return to the lookup loop. */ - - movl deflatestate(%esp), %edx - movl bestlen(%esp), %ebx - cmpl %ebx, %eax - jg LongerMatch - movl chainlenscanend(%esp), %ebx - movl windowbestlen(%esp), %esi - movl dsPrev(%edx), %edi - movl wmask(%esp), %edx - andl %ecx, %edx - jmp LookupLoop - -/* s->match_start = cur_match; */ -/* best_len = len; */ -/* if (len >= nice_match) break; */ -/* scan_end = *(ushf*)(scan+best_len-1); */ - -LongerMatch: movl nicematch(%esp), %ebx - movl %eax, bestlen(%esp) - movl %ecx, dsMatchStart(%edx) - cmpl %ebx, %eax - jge LeaveNow - movl window(%esp), %esi - addl %eax, %esi - movl %esi, windowbestlen(%esp) - movl chainlenscanend(%esp), %ebx - movw -1(%edi,%eax), %bx - movl dsPrev(%edx), %edi - movl %ebx, chainlenscanend(%esp) - movl wmask(%esp), %edx - andl %ecx, %edx - jmp LookupLoop - -/* Accept the current string, with the maximum possible length. */ - -LenMaximum: movl deflatestate(%esp), %edx - movl $MAX_MATCH, bestlen(%esp) - movl %ecx, dsMatchStart(%edx) - -/* if ((uInt)best_len <= s->lookahead) return (uInt)best_len; */ -/* return s->lookahead; */ - -LeaveNow: - movl deflatestate(%esp), %edx - movl bestlen(%esp), %ebx - movl dsLookahead(%edx), %eax - cmpl %eax, %ebx - jg LookaheadRet - movl %ebx, %eax -LookaheadRet: - -/* Restore the stack and return from whence we came. */ - - addl $LocalVarsSize, %esp - popl %ebx - popl %esi - popl %edi - popl %ebp -match_init: ret diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm686/README.686 b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm686/README.686 deleted file mode 100644 index a593f23afd6..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm686/README.686 +++ /dev/null @@ -1,34 +0,0 @@ -This is a patched version of zlib, modified to use -Pentium-Pro-optimized assembly code in the deflation algorithm. The -files changed/added by this patch are: - -README.686 -match.S - -The speedup that this patch provides varies, depending on whether the -compiler used to build the original version of zlib falls afoul of the -PPro's speed traps. My own tests show a speedup of around 10-20% at -the default compression level, and 20-30% using -9, against a version -compiled using gcc 2.7.2.3. Your mileage may vary. - -Note that this code has been tailored for the PPro/PII in particular, -and will not perform particuarly well on a Pentium. - -If you are using an assembler other than GNU as, you will have to -translate match.S to use your assembler's syntax. (Have fun.) - -Brian Raiter -breadbox@muppetlabs.com -April, 1998 - - -Added for zlib 1.1.3: - -The patches come from -http://www.muppetlabs.com/~breadbox/software/assembly.html - -To compile zlib with this asm file, copy match.S to the zlib directory -then do: - -CFLAGS="-O3 -DASMV" ./configure -make OBJA=match.o diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm686/match.S b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm686/match.S deleted file mode 100644 index 8e86c33c288..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/asm686/match.S +++ /dev/null @@ -1,327 +0,0 @@ -/* match.s -- Pentium-Pro-optimized version of longest_match() - * Written for zlib 1.1.2 - * Copyright (C) 1998 Brian Raiter - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License. - */ - -#ifndef NO_UNDERLINE -#define match_init _match_init -#define longest_match _longest_match -#endif - -#define MAX_MATCH (258) -#define MIN_MATCH (3) -#define MIN_LOOKAHEAD (MAX_MATCH + MIN_MATCH + 1) -#define MAX_MATCH_8 ((MAX_MATCH + 7) & ~7) - -/* stack frame offsets */ - -#define chainlenwmask 0 /* high word: current chain len */ - /* low word: s->wmask */ -#define window 4 /* local copy of s->window */ -#define windowbestlen 8 /* s->window + bestlen */ -#define scanstart 16 /* first two bytes of string */ -#define scanend 12 /* last two bytes of string */ -#define scanalign 20 /* dword-misalignment of string */ -#define nicematch 24 /* a good enough match size */ -#define bestlen 28 /* size of best match so far */ -#define scan 32 /* ptr to string wanting match */ - -#define LocalVarsSize (36) -/* saved ebx 36 */ -/* saved edi 40 */ -/* saved esi 44 */ -/* saved ebp 48 */ -/* return address 52 */ -#define deflatestate 56 /* the function arguments */ -#define curmatch 60 - -/* Offsets for fields in the deflate_state structure. These numbers - * are calculated from the definition of deflate_state, with the - * assumption that the compiler will dword-align the fields. (Thus, - * changing the definition of deflate_state could easily cause this - * program to crash horribly, without so much as a warning at - * compile time. Sigh.) - */ -#define dsWSize 36 -#define dsWMask 44 -#define dsWindow 48 -#define dsPrev 56 -#define dsMatchLen 88 -#define dsPrevMatch 92 -#define dsStrStart 100 -#define dsMatchStart 104 -#define dsLookahead 108 -#define dsPrevLen 112 -#define dsMaxChainLen 116 -#define dsGoodMatch 132 -#define dsNiceMatch 136 - - -.file "match.S" - -.globl match_init, longest_match - -.text - -/* uInt longest_match(deflate_state *deflatestate, IPos curmatch) */ - -longest_match: - -/* Save registers that the compiler may be using, and adjust %esp to */ -/* make room for our stack frame. */ - - pushl %ebp - pushl %edi - pushl %esi - pushl %ebx - subl $LocalVarsSize, %esp - -/* Retrieve the function arguments. %ecx will hold cur_match */ -/* throughout the entire function. %edx will hold the pointer to the */ -/* deflate_state structure during the function's setup (before */ -/* entering the main loop). */ - - movl deflatestate(%esp), %edx - movl curmatch(%esp), %ecx - -/* uInt wmask = s->w_mask; */ -/* unsigned chain_length = s->max_chain_length; */ -/* if (s->prev_length >= s->good_match) { */ -/* chain_length >>= 2; */ -/* } */ - - movl dsPrevLen(%edx), %eax - movl dsGoodMatch(%edx), %ebx - cmpl %ebx, %eax - movl dsWMask(%edx), %eax - movl dsMaxChainLen(%edx), %ebx - jl LastMatchGood - shrl $2, %ebx -LastMatchGood: - -/* chainlen is decremented once beforehand so that the function can */ -/* use the sign flag instead of the zero flag for the exit test. */ -/* It is then shifted into the high word, to make room for the wmask */ -/* value, which it will always accompany. */ - - decl %ebx - shll $16, %ebx - orl %eax, %ebx - movl %ebx, chainlenwmask(%esp) - -/* if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; */ - - movl dsNiceMatch(%edx), %eax - movl dsLookahead(%edx), %ebx - cmpl %eax, %ebx - jl LookaheadLess - movl %eax, %ebx -LookaheadLess: movl %ebx, nicematch(%esp) - -/* register Bytef *scan = s->window + s->strstart; */ - - movl dsWindow(%edx), %esi - movl %esi, window(%esp) - movl dsStrStart(%edx), %ebp - lea (%esi,%ebp), %edi - movl %edi, scan(%esp) - -/* Determine how many bytes the scan ptr is off from being */ -/* dword-aligned. */ - - movl %edi, %eax - negl %eax - andl $3, %eax - movl %eax, scanalign(%esp) - -/* IPos limit = s->strstart > (IPos)MAX_DIST(s) ? */ -/* s->strstart - (IPos)MAX_DIST(s) : NIL; */ - - movl dsWSize(%edx), %eax - subl $MIN_LOOKAHEAD, %eax - subl %eax, %ebp - jg LimitPositive - xorl %ebp, %ebp -LimitPositive: - -/* int best_len = s->prev_length; */ - - movl dsPrevLen(%edx), %eax - movl %eax, bestlen(%esp) - -/* Store the sum of s->window + best_len in %esi locally, and in %esi. */ - - addl %eax, %esi - movl %esi, windowbestlen(%esp) - -/* register ush scan_start = *(ushf*)scan; */ -/* register ush scan_end = *(ushf*)(scan+best_len-1); */ -/* Posf *prev = s->prev; */ - - movzwl (%edi), %ebx - movl %ebx, scanstart(%esp) - movzwl -1(%edi,%eax), %ebx - movl %ebx, scanend(%esp) - movl dsPrev(%edx), %edi - -/* Jump into the main loop. */ - - movl chainlenwmask(%esp), %edx - jmp LoopEntry - -.balign 16 - -/* do { - * match = s->window + cur_match; - * if (*(ushf*)(match+best_len-1) != scan_end || - * *(ushf*)match != scan_start) continue; - * [...] - * } while ((cur_match = prev[cur_match & wmask]) > limit - * && --chain_length != 0); - * - * Here is the inner loop of the function. The function will spend the - * majority of its time in this loop, and majority of that time will - * be spent in the first ten instructions. - * - * Within this loop: - * %ebx = scanend - * %ecx = curmatch - * %edx = chainlenwmask - i.e., ((chainlen << 16) | wmask) - * %esi = windowbestlen - i.e., (window + bestlen) - * %edi = prev - * %ebp = limit - */ -LookupLoop: - andl %edx, %ecx - movzwl (%edi,%ecx,2), %ecx - cmpl %ebp, %ecx - jbe LeaveNow - subl $0x00010000, %edx - js LeaveNow -LoopEntry: movzwl -1(%esi,%ecx), %eax - cmpl %ebx, %eax - jnz LookupLoop - movl window(%esp), %eax - movzwl (%eax,%ecx), %eax - cmpl scanstart(%esp), %eax - jnz LookupLoop - -/* Store the current value of chainlen. */ - - movl %edx, chainlenwmask(%esp) - -/* Point %edi to the string under scrutiny, and %esi to the string we */ -/* are hoping to match it up with. In actuality, %esi and %edi are */ -/* both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and %edx is */ -/* initialized to -(MAX_MATCH_8 - scanalign). */ - - movl window(%esp), %esi - movl scan(%esp), %edi - addl %ecx, %esi - movl scanalign(%esp), %eax - movl $(-MAX_MATCH_8), %edx - lea MAX_MATCH_8(%edi,%eax), %edi - lea MAX_MATCH_8(%esi,%eax), %esi - -/* Test the strings for equality, 8 bytes at a time. At the end, - * adjust %edx so that it is offset to the exact byte that mismatched. - * - * We already know at this point that the first three bytes of the - * strings match each other, and they can be safely passed over before - * starting the compare loop. So what this code does is skip over 0-3 - * bytes, as much as necessary in order to dword-align the %edi - * pointer. (%esi will still be misaligned three times out of four.) - * - * It should be confessed that this loop usually does not represent - * much of the total running time. Replacing it with a more - * straightforward "rep cmpsb" would not drastically degrade - * performance. - */ -LoopCmps: - movl (%esi,%edx), %eax - xorl (%edi,%edx), %eax - jnz LeaveLoopCmps - movl 4(%esi,%edx), %eax - xorl 4(%edi,%edx), %eax - jnz LeaveLoopCmps4 - addl $8, %edx - jnz LoopCmps - jmp LenMaximum -LeaveLoopCmps4: addl $4, %edx -LeaveLoopCmps: testl $0x0000FFFF, %eax - jnz LenLower - addl $2, %edx - shrl $16, %eax -LenLower: subb $1, %al - adcl $0, %edx - -/* Calculate the length of the match. If it is longer than MAX_MATCH, */ -/* then automatically accept it as the best possible match and leave. */ - - lea (%edi,%edx), %eax - movl scan(%esp), %edi - subl %edi, %eax - cmpl $MAX_MATCH, %eax - jge LenMaximum - -/* If the length of the match is not longer than the best match we */ -/* have so far, then forget it and return to the lookup loop. */ - - movl deflatestate(%esp), %edx - movl bestlen(%esp), %ebx - cmpl %ebx, %eax - jg LongerMatch - movl windowbestlen(%esp), %esi - movl dsPrev(%edx), %edi - movl scanend(%esp), %ebx - movl chainlenwmask(%esp), %edx - jmp LookupLoop - -/* s->match_start = cur_match; */ -/* best_len = len; */ -/* if (len >= nice_match) break; */ -/* scan_end = *(ushf*)(scan+best_len-1); */ - -LongerMatch: movl nicematch(%esp), %ebx - movl %eax, bestlen(%esp) - movl %ecx, dsMatchStart(%edx) - cmpl %ebx, %eax - jge LeaveNow - movl window(%esp), %esi - addl %eax, %esi - movl %esi, windowbestlen(%esp) - movzwl -1(%edi,%eax), %ebx - movl dsPrev(%edx), %edi - movl %ebx, scanend(%esp) - movl chainlenwmask(%esp), %edx - jmp LookupLoop - -/* Accept the current string, with the maximum possible length. */ - -LenMaximum: movl deflatestate(%esp), %edx - movl $MAX_MATCH, bestlen(%esp) - movl %ecx, dsMatchStart(%edx) - -/* if ((uInt)best_len <= s->lookahead) return (uInt)best_len; */ -/* return s->lookahead; */ - -LeaveNow: - movl deflatestate(%esp), %edx - movl bestlen(%esp), %ebx - movl dsLookahead(%edx), %eax - cmpl %eax, %ebx - jg LookaheadRet - movl %ebx, %eax -LookaheadRet: - -/* Restore the stack and return from whence we came. */ - - addl $LocalVarsSize, %esp - popl %ebx - popl %esi - popl %edi - popl %ebp -match_init: ret diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi/zlib.mak b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi/zlib.mak deleted file mode 100644 index ba557e2b977..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi/zlib.mak +++ /dev/null @@ -1,36 +0,0 @@ -# Makefile for zlib32bd.lib -# ------------- Borland C++ 4.5 ------------- - -# The (32-bit) zlib32bd.lib made with this makefile is intended for use -# in making the (32-bit) DLL, png32bd.dll. It uses the "stdcall" calling -# convention. - -CFLAGS= -ps -O2 -C -K -N- -k- -d -3 -r- -w-par -w-aus -WDE -CC=f:\bc45\bin\bcc32 -LIBFLAGS= /C -LIB=f:\bc45\bin\tlib -ZLIB=zlib32bd.lib - -.autodepend -.c.obj: - $(CC) -c $(CFLAGS) $< - -OBJ1=adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infblock.obj -OBJ2=infcodes.obj inflate.obj inftrees.obj infutil.obj inffast.obj -OBJ3=trees.obj uncompr.obj zutil.obj -pOBJ1=+adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infblock.obj -pOBJ2=+infcodes.obj+inflate.obj+inftrees.obj+infutil.obj+inffast.obj -pOBJ3=+trees.obj+uncompr.obj+zutil.obj - -all: $(ZLIB) - -$(ZLIB): $(OBJ1) $(OBJ2) $(OBJ3) - @if exist $@ del $@ - $(LIB) @&&| -$@ $(LIBFLAGS) & -$(pOBJ1) & -$(pOBJ2) & -$(pOBJ3) -| - -# End of makefile for zlib32bd.lib diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi/zlibdef.pas b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi/zlibdef.pas deleted file mode 100644 index 4f96b7d2c50..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi/zlibdef.pas +++ /dev/null @@ -1,169 +0,0 @@ -unit zlibdef; - -interface - -uses - Windows; - -const - ZLIB_VERSION = '1.1.3'; - -type - voidpf = Pointer; - int = Integer; - uInt = Cardinal; - pBytef = PChar; - uLong = Cardinal; - - alloc_func = function(opaque: voidpf; items, size: uInt): voidpf; - stdcall; - free_func = procedure(opaque, address: voidpf); - stdcall; - - internal_state = Pointer; - - z_streamp = ^z_stream; - z_stream = packed record - next_in: pBytef; // next input byte - avail_in: uInt; // number of bytes available at next_in - total_in: uLong; // total nb of input bytes read so far - - next_out: pBytef; // next output byte should be put there - avail_out: uInt; // remaining free space at next_out - total_out: uLong; // total nb of bytes output so far - - msg: PChar; // last error message, NULL if no error - state: internal_state; // not visible by applications - - zalloc: alloc_func; // used to allocate the internal state - zfree: free_func; // used to free the internal state - opaque: voidpf; // private data object passed to zalloc and zfree - - data_type: int; // best guess about the data type: ascii or binary - adler: uLong; // adler32 value of the uncompressed data - reserved: uLong; // reserved for future use - end; - -const - Z_NO_FLUSH = 0; - Z_SYNC_FLUSH = 2; - Z_FULL_FLUSH = 3; - Z_FINISH = 4; - - Z_OK = 0; - Z_STREAM_END = 1; - - Z_NO_COMPRESSION = 0; - Z_BEST_SPEED = 1; - Z_BEST_COMPRESSION = 9; - Z_DEFAULT_COMPRESSION = -1; - - Z_FILTERED = 1; - Z_HUFFMAN_ONLY = 2; - Z_DEFAULT_STRATEGY = 0; - - Z_BINARY = 0; - Z_ASCII = 1; - Z_UNKNOWN = 2; - - Z_DEFLATED = 8; - - MAX_MEM_LEVEL = 9; - -function adler32(adler: uLong; const buf: pBytef; len: uInt): uLong; - stdcall; -function crc32(crc: uLong; const buf: pBytef; len: uInt): uLong; - stdcall; -function deflate(strm: z_streamp; flush: int): int; - stdcall; -function deflateCopy(dest, source: z_streamp): int; - stdcall; -function deflateEnd(strm: z_streamp): int; - stdcall; -function deflateInit2_(strm: z_streamp; level, method, - windowBits, memLevel, strategy: int; - const version: PChar; stream_size: int): int; - stdcall; -function deflateInit_(strm: z_streamp; level: int; - const version: PChar; stream_size: int): int; - stdcall; -function deflateParams(strm: z_streamp; level, strategy: int): int; - stdcall; -function deflateReset(strm: z_streamp): int; - stdcall; -function deflateSetDictionary(strm: z_streamp; - const dictionary: pBytef; - dictLength: uInt): int; - stdcall; -function inflate(strm: z_streamp; flush: int): int; - stdcall; -function inflateEnd(strm: z_streamp): int; - stdcall; -function inflateInit2_(strm: z_streamp; windowBits: int; - const version: PChar; stream_size: int): int; - stdcall; -function inflateInit_(strm: z_streamp; const version: PChar; - stream_size: int): int; - stdcall; -function inflateReset(strm: z_streamp): int; - stdcall; -function inflateSetDictionary(strm: z_streamp; - const dictionary: pBytef; - dictLength: uInt): int; - stdcall; -function inflateSync(strm: z_streamp): int; - stdcall; - -function deflateInit(strm: z_streamp; level: int): int; -function deflateInit2(strm: z_streamp; level, method, windowBits, - memLevel, strategy: int): int; -function inflateInit(strm: z_streamp): int; -function inflateInit2(strm: z_streamp; windowBits: int): int; - -implementation - -function deflateInit(strm: z_streamp; level: int): int; -begin - Result := deflateInit_(strm, level, ZLIB_VERSION, sizeof(z_stream)); -end; - -function deflateInit2(strm: z_streamp; level, method, windowBits, - memLevel, strategy: int): int; -begin - Result := deflateInit2_(strm, level, method, windowBits, memLevel, - strategy, ZLIB_VERSION, sizeof(z_stream)); -end; - -function inflateInit(strm: z_streamp): int; -begin - Result := inflateInit_(strm, ZLIB_VERSION, sizeof(z_stream)); -end; - -function inflateInit2(strm: z_streamp; windowBits: int): int; -begin - Result := inflateInit2_(strm, windowBits, ZLIB_VERSION, - sizeof(z_stream)); -end; - -const - zlibDLL = 'png32bd.dll'; - -function adler32; external zlibDLL; -function crc32; external zlibDLL; -function deflate; external zlibDLL; -function deflateCopy; external zlibDLL; -function deflateEnd; external zlibDLL; -function deflateInit2_; external zlibDLL; -function deflateInit_; external zlibDLL; -function deflateParams; external zlibDLL; -function deflateReset; external zlibDLL; -function deflateSetDictionary; external zlibDLL; -function inflate; external zlibDLL; -function inflateEnd; external zlibDLL; -function inflateInit2_; external zlibDLL; -function inflateInit_; external zlibDLL; -function inflateReset; external zlibDLL; -function inflateSetDictionary; external zlibDLL; -function inflateSync; external zlibDLL; - -end. diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/d_zlib.bpr b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/d_zlib.bpr deleted file mode 100644 index 78bb254088a..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/d_zlib.bpr +++ /dev/null @@ -1,224 +0,0 @@ -# --------------------------------------------------------------------------- -!if !$d(BCB) -BCB = $(MAKEDIR)\.. -!endif - -# --------------------------------------------------------------------------- -# IDE SECTION -# --------------------------------------------------------------------------- -# The following section of the project makefile is managed by the BCB IDE. -# It is recommended to use the IDE to change any of the values in this -# section. -# --------------------------------------------------------------------------- - -VERSION = BCB.03 -# --------------------------------------------------------------------------- -PROJECT = d_zlib.lib -OBJFILES = d_zlib.obj adler32.obj deflate.obj infblock.obj infcodes.obj inffast.obj \ - inflate.obj inftrees.obj infutil.obj trees.obj -RESFILES = -RESDEPEN = $(RESFILES) -LIBFILES = -LIBRARIES = VCL35.lib -SPARELIBS = VCL35.lib -DEFFILE = -PACKAGES = VCLX35.bpi VCL35.bpi VCLDB35.bpi VCLDBX35.bpi ibsmp35.bpi bcbsmp35.bpi \ - dclocx35.bpi QRPT35.bpi TEEUI35.bpi TEEDB35.bpi TEE35.bpi DSS35.bpi \ - NMFAST35.bpi INETDB35.bpi INET35.bpi VCLMID35.bpi -# --------------------------------------------------------------------------- -PATHCPP = .; -PATHASM = .; -PATHPAS = .; -PATHRC = .; -DEBUGLIBPATH = $(BCB)\lib\debug -RELEASELIBPATH = $(BCB)\lib\release -# --------------------------------------------------------------------------- -CFLAG1 = -O2 -Ve -d -k- -vi -CFLAG2 = -I$(BCB)\include;$(BCB)\include\vcl -H=$(BCB)\lib\vcl35.csm -CFLAG3 = -ff -pr -5 -PFLAGS = -U;$(DEBUGLIBPATH) -I$(BCB)\include;$(BCB)\include\vcl -H -W -$I- -v -JPHN -M -RFLAGS = -i$(BCB)\include;$(BCB)\include\vcl -AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /mx /w2 /zn -LFLAGS = -IFLAGS = -g -Gn -# --------------------------------------------------------------------------- -ALLOBJ = c0w32.obj $(OBJFILES) -ALLRES = $(RESFILES) -ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mt.lib -# --------------------------------------------------------------------------- -!!ifdef IDEOPTIONS - -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=0 -Locale=1040 -CodePage=1252 - -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion=1.0.0.0 -Comments= - -[HistoryLists\hlIncludePath] -Count=2 -Item0=$(BCB)\include -Item1=$(BCB)\include;$(BCB)\include\vcl - -[HistoryLists\hlLibraryPath] -Count=1 -Item0=$(BCB)\lib\obj;$(BCB)\lib - -[HistoryLists\hlDebugSourcePath] -Count=1 -Item0=$(BCB)\source\vcl - -[Debugging] -DebugSourceDirs= - -[Parameters] -RunParams= -HostApplication= - -!endif - - --------------------------------------------------------------------------- -# MAKE SECTION -# --------------------------------------------------------------------------- -# This section of the project file is not used by the BCB IDE. It is for -# the benefit of building from the command-line using the MAKE utility. -# --------------------------------------------------------------------------- - -.autodepend -# --------------------------------------------------------------------------- -!if !$d(BCC32) -BCC32 = bcc32 -!endif - -!if !$d(DCC32) -DCC32 = dcc32 -!endif - -!if !$d(TASM32) -TASM32 = tasm32 -!endif - -!if !$d(LINKER) -LINKER = TLib -!endif - -!if !$d(BRCC32) -BRCC32 = brcc32 -!endif -# --------------------------------------------------------------------------- -!if $d(PATHCPP) -.PATH.CPP = $(PATHCPP) -.PATH.C = $(PATHCPP) -!endif - -!if $d(PATHPAS) -.PATH.PAS = $(PATHPAS) -!endif - -!if $d(PATHASM) -.PATH.ASM = $(PATHASM) -!endif - -!if $d(PATHRC) -.PATH.RC = $(PATHRC) -!endif -# --------------------------------------------------------------------------- -!ifdef IDEOPTIONS - -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=0 -Locale=1040 -CodePage=1252 - -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion=1.0.0.0 -Comments= - -[HistoryLists\hlIncludePath] -Count=2 -Item0=$(BCB)\include;$(BCB)\include\vcl -Item1=$(BCB)\include - -[HistoryLists\hlLibraryPath] -Count=1 -Item0=$(BCB)\lib\obj;$(BCB)\lib - -[HistoryLists\hlDebugSourcePath] -Count=1 -Item0=$(BCB)\source\vcl - -[Debugging] -DebugSourceDirs= - -[Parameters] -RunParams= -HostApplication= - -!endif - -$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE) - $(BCB)\BIN\$(LINKER) @&&! - $(LFLAGS) $(IFLAGS) + - $(ALLOBJ), + - $(PROJECT),, + - $(ALLLIB), + - $(DEFFILE), + - $(ALLRES) -! -# --------------------------------------------------------------------------- -.pas.hpp: - $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } - -.pas.obj: - $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } - -.cpp.obj: - $(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< } - -.c.obj: - $(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< } - -.asm.obj: - $(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@ - -.rc.res: - $(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $< -# --------------------------------------------------------------------------- diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/d_zlib.cpp b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/d_zlib.cpp deleted file mode 100644 index f5dea59b762..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/d_zlib.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#pragma hdrstop -//--------------------------------------------------------------------------- -USEUNIT("adler32.c"); -USEUNIT("deflate.c"); -USEUNIT("infblock.c"); -USEUNIT("infcodes.c"); -USEUNIT("inffast.c"); -USEUNIT("inflate.c"); -USEUNIT("inftrees.c"); -USEUNIT("infutil.c"); -USEUNIT("trees.c"); -//--------------------------------------------------------------------------- -#define Library - -// To add a file to the library use the Project menu 'Add to Project'. - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/readme.txt b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/readme.txt deleted file mode 100644 index cbd31620d87..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/readme.txt +++ /dev/null @@ -1,17 +0,0 @@ -These are files used to compile zlib under Borland C++ Builder 3. - -zlib.bpg is the main project group that can be loaded in the BCB IDE and -loads all other *.bpr projects - -zlib.bpr is a project used to create a static zlib.lib library with C calling -convention for functions. - -zlib32.bpr creates a zlib32.dll dynamic link library with Windows standard -calling convention. - -d_zlib.bpr creates a set of .obj files with register calling convention. -These files are used by zlib.pas to create a Delphi unit containing zlib. -The d_zlib.lib file generated isn't useful and can be deleted. - -zlib.cpp, zlib32.cpp and d_zlib.cpp are used by the above projects. - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib.bpg b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib.bpg deleted file mode 100644 index b6c9acdf8c9..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib.bpg +++ /dev/null @@ -1,26 +0,0 @@ -#------------------------------------------------------------------------------ -VERSION = BWS.01 -#------------------------------------------------------------------------------ -!ifndef ROOT -ROOT = $(MAKEDIR)\.. -!endif -#------------------------------------------------------------------------------ -MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$** -DCC = $(ROOT)\bin\dcc32.exe $** -BRCC = $(ROOT)\bin\brcc32.exe $** -#------------------------------------------------------------------------------ -PROJECTS = zlib zlib32 d_zlib -#------------------------------------------------------------------------------ -default: $(PROJECTS) -#------------------------------------------------------------------------------ - -zlib: zlib.bpr - $(MAKE) - -zlib32: zlib32.bpr - $(MAKE) - -d_zlib: d_zlib.bpr - $(MAKE) - - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib.bpr b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib.bpr deleted file mode 100644 index cf3945b2523..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib.bpr +++ /dev/null @@ -1,225 +0,0 @@ -# --------------------------------------------------------------------------- -!if !$d(BCB) -BCB = $(MAKEDIR)\.. -!endif - -# --------------------------------------------------------------------------- -# IDE SECTION -# --------------------------------------------------------------------------- -# The following section of the project makefile is managed by the BCB IDE. -# It is recommended to use the IDE to change any of the values in this -# section. -# --------------------------------------------------------------------------- - -VERSION = BCB.03 -# --------------------------------------------------------------------------- -PROJECT = zlib.lib -OBJFILES = zlib.obj adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infblock.obj \ - infcodes.obj inffast.obj inflate.obj inftrees.obj infutil.obj trees.obj \ - uncompr.obj zutil.obj -RESFILES = -RESDEPEN = $(RESFILES) -LIBFILES = -LIBRARIES = VCL35.lib -SPARELIBS = VCL35.lib -DEFFILE = -PACKAGES = VCLX35.bpi VCL35.bpi VCLDB35.bpi VCLDBX35.bpi ibsmp35.bpi bcbsmp35.bpi \ - dclocx35.bpi QRPT35.bpi TEEUI35.bpi TEEDB35.bpi TEE35.bpi DSS35.bpi \ - NMFAST35.bpi INETDB35.bpi INET35.bpi VCLMID35.bpi -# --------------------------------------------------------------------------- -PATHCPP = .; -PATHASM = .; -PATHPAS = .; -PATHRC = .; -DEBUGLIBPATH = $(BCB)\lib\debug -RELEASELIBPATH = $(BCB)\lib\release -# --------------------------------------------------------------------------- -CFLAG1 = -O2 -Ve -d -k- -vi -CFLAG2 = -I$(BCB)\include;$(BCB)\include\vcl -H=$(BCB)\lib\vcl35.csm -CFLAG3 = -ff -5 -PFLAGS = -U;$(DEBUGLIBPATH) -I$(BCB)\include;$(BCB)\include\vcl -H -W -$I- -v -JPHN -M -RFLAGS = -i$(BCB)\include;$(BCB)\include\vcl -AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /mx /w2 /zn -LFLAGS = -IFLAGS = -g -Gn -# --------------------------------------------------------------------------- -ALLOBJ = c0w32.obj $(OBJFILES) -ALLRES = $(RESFILES) -ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mt.lib -# --------------------------------------------------------------------------- -!!ifdef IDEOPTIONS - -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=0 -Locale=1040 -CodePage=1252 - -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion=1.0.0.0 -Comments= - -[HistoryLists\hlIncludePath] -Count=2 -Item0=$(BCB)\include -Item1=$(BCB)\include;$(BCB)\include\vcl - -[HistoryLists\hlLibraryPath] -Count=1 -Item0=$(BCB)\lib\obj;$(BCB)\lib - -[HistoryLists\hlDebugSourcePath] -Count=1 -Item0=$(BCB)\source\vcl - -[Debugging] -DebugSourceDirs= - -[Parameters] -RunParams= -HostApplication= - -!endif - - --------------------------------------------------------------------------- -# MAKE SECTION -# --------------------------------------------------------------------------- -# This section of the project file is not used by the BCB IDE. It is for -# the benefit of building from the command-line using the MAKE utility. -# --------------------------------------------------------------------------- - -.autodepend -# --------------------------------------------------------------------------- -!if !$d(BCC32) -BCC32 = bcc32 -!endif - -!if !$d(DCC32) -DCC32 = dcc32 -!endif - -!if !$d(TASM32) -TASM32 = tasm32 -!endif - -!if !$d(LINKER) -LINKER = TLib -!endif - -!if !$d(BRCC32) -BRCC32 = brcc32 -!endif -# --------------------------------------------------------------------------- -!if $d(PATHCPP) -.PATH.CPP = $(PATHCPP) -.PATH.C = $(PATHCPP) -!endif - -!if $d(PATHPAS) -.PATH.PAS = $(PATHPAS) -!endif - -!if $d(PATHASM) -.PATH.ASM = $(PATHASM) -!endif - -!if $d(PATHRC) -.PATH.RC = $(PATHRC) -!endif -# --------------------------------------------------------------------------- -!ifdef IDEOPTIONS - -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=0 -Locale=1040 -CodePage=1252 - -[Version Info Keys] -CompanyName= -FileDescription= -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion=1.0.0.0 -Comments= - -[HistoryLists\hlIncludePath] -Count=2 -Item0=$(BCB)\include;$(BCB)\include\vcl -Item1=$(BCB)\include - -[HistoryLists\hlLibraryPath] -Count=1 -Item0=$(BCB)\lib\obj;$(BCB)\lib - -[HistoryLists\hlDebugSourcePath] -Count=1 -Item0=$(BCB)\source\vcl - -[Debugging] -DebugSourceDirs= - -[Parameters] -RunParams= -HostApplication= - -!endif - -$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE) - $(BCB)\BIN\$(LINKER) @&&! - $(LFLAGS) $(IFLAGS) + - $(ALLOBJ), + - $(PROJECT),, + - $(ALLLIB), + - $(DEFFILE), + - $(ALLRES) -! -# --------------------------------------------------------------------------- -.pas.hpp: - $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } - -.pas.obj: - $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } - -.cpp.obj: - $(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< } - -.c.obj: - $(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< } - -.asm.obj: - $(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@ - -.rc.res: - $(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $< -# --------------------------------------------------------------------------- diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib.cpp b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib.cpp deleted file mode 100644 index bf6953ba198..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#pragma hdrstop -//--------------------------------------------------------------------------- -USEUNIT("adler32.c"); -USEUNIT("compress.c"); -USEUNIT("crc32.c"); -USEUNIT("deflate.c"); -USEUNIT("gzio.c"); -USEUNIT("infblock.c"); -USEUNIT("infcodes.c"); -USEUNIT("inffast.c"); -USEUNIT("inflate.c"); -USEUNIT("inftrees.c"); -USEUNIT("infutil.c"); -USEUNIT("trees.c"); -USEUNIT("uncompr.c"); -USEUNIT("zutil.c"); -//--------------------------------------------------------------------------- -#define Library - -// To add a file to the library use the Project menu 'Add to Project'. - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib.pas b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib.pas deleted file mode 100644 index 10ae4cae256..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib.pas +++ /dev/null @@ -1,534 +0,0 @@ -{*******************************************************} -{ } -{ Delphi Supplemental Components } -{ ZLIB Data Compression Interface Unit } -{ } -{ Copyright (c) 1997 Borland International } -{ } -{*******************************************************} - -{ Modified for zlib 1.1.3 by Davide Moretti Z_STREAM_END do - begin - P := OutBuf; - Inc(OutBytes, 256); - ReallocMem(OutBuf, OutBytes); - strm.next_out := PChar(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P))); - strm.avail_out := 256; - end; - finally - CCheck(deflateEnd(strm)); - end; - ReallocMem(OutBuf, strm.total_out); - OutBytes := strm.total_out; - except - FreeMem(OutBuf); - raise - end; -end; - - -procedure DecompressBuf(const InBuf: Pointer; InBytes: Integer; - OutEstimate: Integer; out OutBuf: Pointer; out OutBytes: Integer); -var - strm: TZStreamRec; - P: Pointer; - BufInc: Integer; -begin - FillChar(strm, sizeof(strm), 0); - BufInc := (InBytes + 255) and not 255; - if OutEstimate = 0 then - OutBytes := BufInc - else - OutBytes := OutEstimate; - GetMem(OutBuf, OutBytes); - try - strm.next_in := InBuf; - strm.avail_in := InBytes; - strm.next_out := OutBuf; - strm.avail_out := OutBytes; - DCheck(inflateInit_(strm, zlib_version, sizeof(strm))); - try - while DCheck(inflate(strm, Z_FINISH)) <> Z_STREAM_END do - begin - P := OutBuf; - Inc(OutBytes, BufInc); - ReallocMem(OutBuf, OutBytes); - strm.next_out := PChar(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P))); - strm.avail_out := BufInc; - end; - finally - DCheck(inflateEnd(strm)); - end; - ReallocMem(OutBuf, strm.total_out); - OutBytes := strm.total_out; - except - FreeMem(OutBuf); - raise - end; -end; - - -// TCustomZlibStream - -constructor TCustomZLibStream.Create(Strm: TStream); -begin - inherited Create; - FStrm := Strm; - FStrmPos := Strm.Position; -end; - -procedure TCustomZLibStream.Progress(Sender: TObject); -begin - if Assigned(FOnProgress) then FOnProgress(Sender); -end; - - -// TCompressionStream - -constructor TCompressionStream.Create(CompressionLevel: TCompressionLevel; - Dest: TStream); -const - Levels: array [TCompressionLevel] of ShortInt = - (Z_NO_COMPRESSION, Z_BEST_SPEED, Z_DEFAULT_COMPRESSION, Z_BEST_COMPRESSION); -begin - inherited Create(Dest); - FZRec.next_out := FBuffer; - FZRec.avail_out := sizeof(FBuffer); - CCheck(deflateInit_(FZRec, Levels[CompressionLevel], zlib_version, sizeof(FZRec))); -end; - -destructor TCompressionStream.Destroy; -begin - FZRec.next_in := nil; - FZRec.avail_in := 0; - try - if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos; - while (CCheck(deflate(FZRec, Z_FINISH)) <> Z_STREAM_END) - and (FZRec.avail_out = 0) do - begin - FStrm.WriteBuffer(FBuffer, sizeof(FBuffer)); - FZRec.next_out := FBuffer; - FZRec.avail_out := sizeof(FBuffer); - end; - if FZRec.avail_out < sizeof(FBuffer) then - FStrm.WriteBuffer(FBuffer, sizeof(FBuffer) - FZRec.avail_out); - finally - deflateEnd(FZRec); - end; - inherited Destroy; -end; - -function TCompressionStream.Read(var Buffer; Count: Longint): Longint; -begin - raise ECompressionError.Create('Invalid stream operation'); -end; - -function TCompressionStream.Write(const Buffer; Count: Longint): Longint; -begin - FZRec.next_in := @Buffer; - FZRec.avail_in := Count; - if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos; - while (FZRec.avail_in > 0) do - begin - CCheck(deflate(FZRec, 0)); - if FZRec.avail_out = 0 then - begin - FStrm.WriteBuffer(FBuffer, sizeof(FBuffer)); - FZRec.next_out := FBuffer; - FZRec.avail_out := sizeof(FBuffer); - FStrmPos := FStrm.Position; - Progress(Self); - end; - end; - Result := Count; -end; - -function TCompressionStream.Seek(Offset: Longint; Origin: Word): Longint; -begin - if (Offset = 0) and (Origin = soFromCurrent) then - Result := FZRec.total_in - else - raise ECompressionError.Create('Invalid stream operation'); -end; - -function TCompressionStream.GetCompressionRate: Single; -begin - if FZRec.total_in = 0 then - Result := 0 - else - Result := (1.0 - (FZRec.total_out / FZRec.total_in)) * 100.0; -end; - - -// TDecompressionStream - -constructor TDecompressionStream.Create(Source: TStream); -begin - inherited Create(Source); - FZRec.next_in := FBuffer; - FZRec.avail_in := 0; - DCheck(inflateInit_(FZRec, zlib_version, sizeof(FZRec))); -end; - -destructor TDecompressionStream.Destroy; -begin - inflateEnd(FZRec); - inherited Destroy; -end; - -function TDecompressionStream.Read(var Buffer; Count: Longint): Longint; -begin - FZRec.next_out := @Buffer; - FZRec.avail_out := Count; - if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos; - while (FZRec.avail_out > 0) do - begin - if FZRec.avail_in = 0 then - begin - FZRec.avail_in := FStrm.Read(FBuffer, sizeof(FBuffer)); - if FZRec.avail_in = 0 then - begin - Result := Count - FZRec.avail_out; - Exit; - end; - FZRec.next_in := FBuffer; - FStrmPos := FStrm.Position; - Progress(Self); - end; - DCheck(inflate(FZRec, 0)); - end; - Result := Count; -end; - -function TDecompressionStream.Write(const Buffer; Count: Longint): Longint; -begin - raise EDecompressionError.Create('Invalid stream operation'); -end; - -function TDecompressionStream.Seek(Offset: Longint; Origin: Word): Longint; -var - I: Integer; - Buf: array [0..4095] of Char; -begin - if (Offset = 0) and (Origin = soFromBeginning) then - begin - DCheck(inflateReset(FZRec)); - FZRec.next_in := FBuffer; - FZRec.avail_in := 0; - FStrm.Position := 0; - FStrmPos := 0; - end - else if ( (Offset >= 0) and (Origin = soFromCurrent)) or - ( ((Offset - FZRec.total_out) > 0) and (Origin = soFromBeginning)) then - begin - if Origin = soFromBeginning then Dec(Offset, FZRec.total_out); - if Offset > 0 then - begin - for I := 1 to Offset div sizeof(Buf) do - ReadBuffer(Buf, sizeof(Buf)); - ReadBuffer(Buf, Offset mod sizeof(Buf)); - end; - end - else - raise EDecompressionError.Create('Invalid stream operation'); - Result := FZRec.total_out; -end; - -end. diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib32.bpr b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib32.bpr deleted file mode 100644 index cabcec44947..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib32.bpr +++ /dev/null @@ -1,174 +0,0 @@ -# --------------------------------------------------------------------------- -!if !$d(BCB) -BCB = $(MAKEDIR)\.. -!endif - -# --------------------------------------------------------------------------- -# IDE SECTION -# --------------------------------------------------------------------------- -# The following section of the project makefile is managed by the BCB IDE. -# It is recommended to use the IDE to change any of the values in this -# section. -# --------------------------------------------------------------------------- - -VERSION = BCB.03 -# --------------------------------------------------------------------------- -PROJECT = zlib32.dll -OBJFILES = zlib32.obj adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infblock.obj \ - infcodes.obj inffast.obj inflate.obj inftrees.obj infutil.obj trees.obj \ - uncompr.obj zutil.obj -RESFILES = -RESDEPEN = $(RESFILES) -LIBFILES = -LIBRARIES = -SPARELIBS = -DEFFILE = -PACKAGES = VCLX35.bpi VCL35.bpi VCLDB35.bpi VCLDBX35.bpi ibsmp35.bpi bcbsmp35.bpi \ - dclocx35.bpi QRPT35.bpi TEEUI35.bpi TEEDB35.bpi TEE35.bpi DSS35.bpi \ - NMFAST35.bpi INETDB35.bpi INET35.bpi VCLMID35.bpi -# --------------------------------------------------------------------------- -PATHCPP = .; -PATHASM = .; -PATHPAS = .; -PATHRC = .; -DEBUGLIBPATH = $(BCB)\lib\debug -RELEASELIBPATH = $(BCB)\lib\release -# --------------------------------------------------------------------------- -CFLAG1 = -WD -O2 -Ve -d -k- -vi -c -tWD -CFLAG2 = -D_NO_VCL;ZLIB_DLL -I$(BCB)\include -CFLAG3 = -ff -5 -PFLAGS = -D_NO_VCL;ZLIB_DLL -U$(BCB)\lib;$(RELEASELIBPATH) -I$(BCB)\include -$I- -v \ - -JPHN -M -RFLAGS = -D_NO_VCL;ZLIB_DLL -i$(BCB)\include -AFLAGS = /i$(BCB)\include /d_NO_VCL /dZLIB_DLL /mx /w2 /zn -LFLAGS = -L$(BCB)\lib;$(RELEASELIBPATH) -aa -Tpd -x -Gi -IFLAGS = -Gn -g -# --------------------------------------------------------------------------- -ALLOBJ = c0d32.obj $(OBJFILES) -ALLRES = $(RESFILES) -ALLLIB = $(LIBFILES) import32.lib cw32mt.lib -# --------------------------------------------------------------------------- -!ifdef IDEOPTIONS - -[Version Info] -IncludeVerInfo=0 -AutoIncBuild=0 -MajorVer=1 -MinorVer=0 -Release=0 -Build=0 -Debug=0 -PreRelease=0 -Special=0 -Private=0 -DLL=1 -Locale=1040 -CodePage=1252 - -[Version Info Keys] -CompanyName= -FileDescription=DLL (GUI) -FileVersion=1.0.0.0 -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion=1.0.0.0 -Comments= - -[HistoryLists\hlIncludePath] -Count=1 -Item0=$(BCB)\include - -[HistoryLists\hlLibraryPath] -Count=1 -Item0=$(BCB)\lib - -[HistoryLists\hlConditionals] -Count=1 -Item0=_NO_VCL;ZLIB_DLL - -[Debugging] -DebugSourceDirs= - -[Parameters] -RunParams= -HostApplication= - -!endif - -# --------------------------------------------------------------------------- -# MAKE SECTION -# --------------------------------------------------------------------------- -# This section of the project file is not used by the BCB IDE. It is for -# the benefit of building from the command-line using the MAKE utility. -# --------------------------------------------------------------------------- - -.autodepend -# --------------------------------------------------------------------------- -!if !$d(BCC32) -BCC32 = bcc32 -!endif - -!if !$d(DCC32) -DCC32 = dcc32 -!endif - -!if !$d(TASM32) -TASM32 = tasm32 -!endif - -!if !$d(LINKER) -LINKER = ilink32 -!endif - -!if !$d(BRCC32) -BRCC32 = brcc32 -!endif -# --------------------------------------------------------------------------- -!if $d(PATHCPP) -.PATH.CPP = $(PATHCPP) -.PATH.C = $(PATHCPP) -!endif - -!if $d(PATHPAS) -.PATH.PAS = $(PATHPAS) -!endif - -!if $d(PATHASM) -.PATH.ASM = $(PATHASM) -!endif - -!if $d(PATHRC) -.PATH.RC = $(PATHRC) -!endif -# --------------------------------------------------------------------------- -$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE) - $(BCB)\BIN\$(LINKER) @&&! - $(LFLAGS) $(IFLAGS) + - $(ALLOBJ), + - $(PROJECT),, + - $(ALLLIB), + - $(DEFFILE), + - $(ALLRES) -! -# --------------------------------------------------------------------------- -.pas.hpp: - $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } - -.pas.obj: - $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } - -.cpp.obj: - $(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< } - -.c.obj: - $(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< } - -.asm.obj: - $(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@ - -.rc.res: - $(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $< -# --------------------------------------------------------------------------- diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib32.cpp b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib32.cpp deleted file mode 100644 index 7372f6b985f..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/delphi2/zlib32.cpp +++ /dev/null @@ -1,42 +0,0 @@ - -#include -#pragma hdrstop -#include - - -//--------------------------------------------------------------------------- -// Important note about DLL memory management in a VCL DLL: -// -// -// -// If your DLL uses VCL and exports any functions that pass VCL String objects -// (or structs/classes containing nested Strings) as parameter or function -// results, you will need to build both your DLL project and any EXE projects -// that use your DLL with the dynamic RTL (the RTL DLL). This will change your -// DLL and its calling EXE's to use BORLNDMM.DLL as their memory manager. In -// these cases, the file BORLNDMM.DLL should be deployed along with your DLL -// and the RTL DLL (CP3240MT.DLL). To avoid the requiring BORLNDMM.DLL in -// these situations, pass string information using "char *" or ShortString -// parameters and then link with the static RTL. -// -//--------------------------------------------------------------------------- -USEUNIT("adler32.c"); -USEUNIT("compress.c"); -USEUNIT("crc32.c"); -USEUNIT("deflate.c"); -USEUNIT("gzio.c"); -USEUNIT("infblock.c"); -USEUNIT("infcodes.c"); -USEUNIT("inffast.c"); -USEUNIT("inflate.c"); -USEUNIT("inftrees.c"); -USEUNIT("infutil.c"); -USEUNIT("trees.c"); -USEUNIT("uncompr.c"); -USEUNIT("zutil.c"); -//--------------------------------------------------------------------------- -#pragma argsused -int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) -{ - return 1; -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/test.cpp b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/test.cpp deleted file mode 100644 index 7d265b3b5c0..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/test.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -#include "zfstream.h" - -int main() { - - // Construct a stream object with this filebuffer. Anything sent - // to this stream will go to standard out. - gzofstream os( 1, ios::out ); - - // This text is getting compressed and sent to stdout. - // To prove this, run 'test | zcat'. - os << "Hello, Mommy" << endl; - - os << setcompressionlevel( Z_NO_COMPRESSION ); - os << "hello, hello, hi, ho!" << endl; - - setcompressionlevel( os, Z_DEFAULT_COMPRESSION ) - << "I'm compressing again" << endl; - - os.close(); - - return 0; - -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.cpp b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.cpp deleted file mode 100644 index a690bbefceb..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.cpp +++ /dev/null @@ -1,329 +0,0 @@ - -#include -#include "zfstream.h" - -gzfilebuf::gzfilebuf() : - file(NULL), - mode(0), - own_file_descriptor(0) -{ } - -gzfilebuf::~gzfilebuf() { - - sync(); - if ( own_file_descriptor ) - close(); - -} - -gzfilebuf *gzfilebuf::open( const char *name, - int io_mode ) { - - if ( is_open() ) - return NULL; - - char char_mode[10]; - char *p; - memset(char_mode,'\0',10); - p = char_mode; - - if ( io_mode & ios::in ) { - mode = ios::in; - *p++ = 'r'; - } else if ( io_mode & ios::app ) { - mode = ios::app; - *p++ = 'a'; - } else { - mode = ios::out; - *p++ = 'w'; - } - - if ( io_mode & ios::binary ) { - mode |= ios::binary; - *p++ = 'b'; - } - - // Hard code the compression level - if ( io_mode & (ios::out|ios::app )) { - *p++ = '9'; - } - - if ( (file = gzopen(name, char_mode)) == NULL ) - return NULL; - - own_file_descriptor = 1; - - return this; - -} - -gzfilebuf *gzfilebuf::attach( int file_descriptor, - int io_mode ) { - - if ( is_open() ) - return NULL; - - char char_mode[10]; - char *p; - memset(char_mode,'\0',10); - p = char_mode; - - if ( io_mode & ios::in ) { - mode = ios::in; - *p++ = 'r'; - } else if ( io_mode & ios::app ) { - mode = ios::app; - *p++ = 'a'; - } else { - mode = ios::out; - *p++ = 'w'; - } - - if ( io_mode & ios::binary ) { - mode |= ios::binary; - *p++ = 'b'; - } - - // Hard code the compression level - if ( io_mode & (ios::out|ios::app )) { - *p++ = '9'; - } - - if ( (file = gzdopen(file_descriptor, char_mode)) == NULL ) - return NULL; - - own_file_descriptor = 0; - - return this; - -} - -gzfilebuf *gzfilebuf::close() { - - if ( is_open() ) { - - sync(); - gzclose( file ); - file = NULL; - - } - - return this; - -} - -int gzfilebuf::setcompressionlevel( short comp_level ) { - - return gzsetparams(file, comp_level, -2); - -} - -int gzfilebuf::setcompressionstrategy( short comp_strategy ) { - - return gzsetparams(file, -2, comp_strategy); - -} - - -streampos gzfilebuf::seekoff( streamoff off, ios::seek_dir dir, int which ) { - - return streampos(EOF); - -} - -int gzfilebuf::underflow() { - - // If the file hasn't been opened for reading, error. - if ( !is_open() || !(mode & ios::in) ) - return EOF; - - // if a buffer doesn't exists, allocate one. - if ( !base() ) { - - if ( (allocate()) == EOF ) - return EOF; - setp(0,0); - - } else { - - if ( in_avail() ) - return (unsigned char) *gptr(); - - if ( out_waiting() ) { - if ( flushbuf() == EOF ) - return EOF; - } - - } - - // Attempt to fill the buffer. - - int result = fillbuf(); - if ( result == EOF ) { - // disable get area - setg(0,0,0); - return EOF; - } - - return (unsigned char) *gptr(); - -} - -int gzfilebuf::overflow( int c ) { - - if ( !is_open() || !(mode & ios::out) ) - return EOF; - - if ( !base() ) { - if ( allocate() == EOF ) - return EOF; - setg(0,0,0); - } else { - if (in_avail()) { - return EOF; - } - if (out_waiting()) { - if (flushbuf() == EOF) - return EOF; - } - } - - int bl = blen(); - setp( base(), base() + bl); - - if ( c != EOF ) { - - *pptr() = c; - pbump(1); - - } - - return 0; - -} - -int gzfilebuf::sync() { - - if ( !is_open() ) - return EOF; - - if ( out_waiting() ) - return flushbuf(); - - return 0; - -} - -int gzfilebuf::flushbuf() { - - int n; - char *q; - - q = pbase(); - n = pptr() - q; - - if ( gzwrite( file, q, n) < n ) - return EOF; - - setp(0,0); - - return 0; - -} - -int gzfilebuf::fillbuf() { - - int required; - char *p; - - p = base(); - - required = blen(); - - int t = gzread( file, p, required ); - - if ( t <= 0) return EOF; - - setg( base(), base(), base()+t); - - return t; - -} - -gzfilestream_common::gzfilestream_common() : - ios( gzfilestream_common::rdbuf() ) -{ } - -gzfilestream_common::~gzfilestream_common() -{ } - -void gzfilestream_common::attach( int fd, int io_mode ) { - - if ( !buffer.attach( fd, io_mode) ) - clear( ios::failbit | ios::badbit ); - else - clear(); - -} - -void gzfilestream_common::open( const char *name, int io_mode ) { - - if ( !buffer.open( name, io_mode ) ) - clear( ios::failbit | ios::badbit ); - else - clear(); - -} - -void gzfilestream_common::close() { - - if ( !buffer.close() ) - clear( ios::failbit | ios::badbit ); - -} - -gzfilebuf *gzfilestream_common::rdbuf() { - - return &buffer; - -} - -gzifstream::gzifstream() : - ios( gzfilestream_common::rdbuf() ) -{ - clear( ios::badbit ); -} - -gzifstream::gzifstream( const char *name, int io_mode ) : - ios( gzfilestream_common::rdbuf() ) -{ - gzfilestream_common::open( name, io_mode ); -} - -gzifstream::gzifstream( int fd, int io_mode ) : - ios( gzfilestream_common::rdbuf() ) -{ - gzfilestream_common::attach( fd, io_mode ); -} - -gzifstream::~gzifstream() { } - -gzofstream::gzofstream() : - ios( gzfilestream_common::rdbuf() ) -{ - clear( ios::badbit ); -} - -gzofstream::gzofstream( const char *name, int io_mode ) : - ios( gzfilestream_common::rdbuf() ) -{ - gzfilestream_common::open( name, io_mode ); -} - -gzofstream::gzofstream( int fd, int io_mode ) : - ios( gzfilestream_common::rdbuf() ) -{ - gzfilestream_common::attach( fd, io_mode ); -} - -gzofstream::~gzofstream() { } diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.h b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.h deleted file mode 100644 index c87fa08e9d1..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream/zfstream.h +++ /dev/null @@ -1,142 +0,0 @@ - -#ifndef _zfstream_h -#define _zfstream_h - -#include -#include "zlib.h" - -class gzfilebuf : public streambuf { - -public: - - gzfilebuf( ); - virtual ~gzfilebuf(); - - gzfilebuf *open( const char *name, int io_mode ); - gzfilebuf *attach( int file_descriptor, int io_mode ); - gzfilebuf *close(); - - int setcompressionlevel( short comp_level ); - int setcompressionstrategy( short comp_strategy ); - - inline int is_open() const { return (file !=NULL); } - - virtual streampos seekoff( streamoff, ios::seek_dir, int ); - - virtual int sync(); - -protected: - - virtual int underflow(); - virtual int overflow( int = EOF ); - -private: - - gzFile file; - short mode; - short own_file_descriptor; - - int flushbuf(); - int fillbuf(); - -}; - -class gzfilestream_common : virtual public ios { - - friend class gzifstream; - friend class gzofstream; - friend gzofstream &setcompressionlevel( gzofstream &, int ); - friend gzofstream &setcompressionstrategy( gzofstream &, int ); - -public: - virtual ~gzfilestream_common(); - - void attach( int fd, int io_mode ); - void open( const char *name, int io_mode ); - void close(); - -protected: - gzfilestream_common(); - -private: - gzfilebuf *rdbuf(); - - gzfilebuf buffer; - -}; - -class gzifstream : public gzfilestream_common, public istream { - -public: - - gzifstream(); - gzifstream( const char *name, int io_mode = ios::in ); - gzifstream( int fd, int io_mode = ios::in ); - - virtual ~gzifstream(); - -}; - -class gzofstream : public gzfilestream_common, public ostream { - -public: - - gzofstream(); - gzofstream( const char *name, int io_mode = ios::out ); - gzofstream( int fd, int io_mode = ios::out ); - - virtual ~gzofstream(); - -}; - -template class gzomanip { - friend gzofstream &operator<<(gzofstream &, const gzomanip &); -public: - gzomanip(gzofstream &(*f)(gzofstream &, T), T v) : func(f), val(v) { } -private: - gzofstream &(*func)(gzofstream &, T); - T val; -}; - -template gzofstream &operator<<(gzofstream &s, - const gzomanip &m) { - return (*m.func)(s, m.val); - -} - -inline gzofstream &setcompressionlevel( gzofstream &s, int l ) { - (s.rdbuf())->setcompressionlevel(l); - return s; -} - -inline gzofstream &setcompressionstrategy( gzofstream &s, int l ) { - (s.rdbuf())->setcompressionstrategy(l); - return s; -} - -inline gzomanip setcompressionlevel(int l) -{ - return gzomanip(&setcompressionlevel,l); -} - -inline gzomanip setcompressionstrategy(int l) -{ - return gzomanip(&setcompressionstrategy,l); -} - -#endif - - - - - - - - - - - - - - - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream.h b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream.h deleted file mode 100644 index 43d2332b79b..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream.h +++ /dev/null @@ -1,307 +0,0 @@ -/* - * - * Copyright (c) 1997 - * Christian Michelsen Research AS - * Advanced Computing - * Fantoftvegen 38, 5036 BERGEN, Norway - * http://www.cmr.no - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Christian Michelsen Research AS makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef ZSTREAM__H -#define ZSTREAM__H - -/* - * zstream.h - C++ interface to the 'zlib' general purpose compression library - * $Id: zstream.h 1.1 1997-06-25 12:00:56+02 tyge Exp tyge $ - */ - -#include -#include -#include -#include "zlib.h" - -#if defined(_WIN32) -# include -# include -# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) -#else -# define SET_BINARY_MODE(file) -#endif - -class zstringlen { -public: - zstringlen(class izstream&); - zstringlen(class ozstream&, const char*); - size_t value() const { return val.word; } -private: - struct Val { unsigned char byte; size_t word; } val; -}; - -// ----------------------------- izstream ----------------------------- - -class izstream -{ - public: - izstream() : m_fp(0) {} - izstream(FILE* fp) : m_fp(0) { open(fp); } - izstream(const char* name) : m_fp(0) { open(name); } - ~izstream() { close(); } - - /* Opens a gzip (.gz) file for reading. - * open() can be used to read a file which is not in gzip format; - * in this case read() will directly read from the file without - * decompression. errno can be checked to distinguish two error - * cases (if errno is zero, the zlib error is Z_MEM_ERROR). - */ - void open(const char* name) { - if (m_fp) close(); - m_fp = ::gzopen(name, "rb"); - } - - void open(FILE* fp) { - SET_BINARY_MODE(fp); - if (m_fp) close(); - m_fp = ::gzdopen(fileno(fp), "rb"); - } - - /* Flushes all pending input if necessary, closes the compressed file - * and deallocates all the (de)compression state. The return value is - * the zlib error number (see function error() below). - */ - int close() { - int r = ::gzclose(m_fp); - m_fp = 0; return r; - } - - /* Binary read the given number of bytes from the compressed file. - */ - int read(void* buf, size_t len) { - return ::gzread(m_fp, buf, len); - } - - /* 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. - */ - const char* error(int* errnum) { - return ::gzerror(m_fp, errnum); - } - - gzFile fp() { return m_fp; } - - private: - gzFile m_fp; -}; - -/* - * Binary read the given (array of) object(s) from the compressed file. - * If the input file was not in gzip format, read() copies the objects number - * of bytes into the buffer. - * returns the number of uncompressed bytes actually read - * (0 for end of file, -1 for error). - */ -template -inline int read(izstream& zs, T* x, Items items) { - return ::gzread(zs.fp(), x, items*sizeof(T)); -} - -/* - * Binary input with the '>' operator. - */ -template -inline izstream& operator>(izstream& zs, T& x) { - ::gzread(zs.fp(), &x, sizeof(T)); - return zs; -} - - -inline zstringlen::zstringlen(izstream& zs) { - zs > val.byte; - if (val.byte == 255) zs > val.word; - else val.word = val.byte; -} - -/* - * Read length of string + the string with the '>' operator. - */ -inline izstream& operator>(izstream& zs, char* x) { - zstringlen len(zs); - ::gzread(zs.fp(), x, len.value()); - x[len.value()] = '\0'; - return zs; -} - -inline char* read_string(izstream& zs) { - zstringlen len(zs); - char* x = new char[len.value()+1]; - ::gzread(zs.fp(), x, len.value()); - x[len.value()] = '\0'; - return x; -} - -// ----------------------------- ozstream ----------------------------- - -class ozstream -{ - public: - ozstream() : m_fp(0), m_os(0) { - } - ozstream(FILE* fp, int level = Z_DEFAULT_COMPRESSION) - : m_fp(0), m_os(0) { - open(fp, level); - } - ozstream(const char* name, int level = Z_DEFAULT_COMPRESSION) - : m_fp(0), m_os(0) { - open(name, level); - } - ~ozstream() { - close(); - } - - /* Opens a gzip (.gz) file for writing. - * The compression level parameter should be in 0..9 - * errno can be checked to distinguish two error cases - * (if errno is zero, the zlib error is Z_MEM_ERROR). - */ - void open(const char* name, int level = Z_DEFAULT_COMPRESSION) { - char mode[4] = "wb\0"; - if (level != Z_DEFAULT_COMPRESSION) mode[2] = '0'+level; - if (m_fp) close(); - m_fp = ::gzopen(name, mode); - } - - /* open from a FILE pointer. - */ - void open(FILE* fp, int level = Z_DEFAULT_COMPRESSION) { - SET_BINARY_MODE(fp); - char mode[4] = "wb\0"; - if (level != Z_DEFAULT_COMPRESSION) mode[2] = '0'+level; - if (m_fp) close(); - m_fp = ::gzdopen(fileno(fp), mode); - } - - /* Flushes all pending output if necessary, closes the compressed file - * and deallocates all the (de)compression state. The return value is - * the zlib error number (see function error() below). - */ - int close() { - if (m_os) { - ::gzwrite(m_fp, m_os->str(), m_os->pcount()); - delete[] m_os->str(); delete m_os; m_os = 0; - } - int r = ::gzclose(m_fp); m_fp = 0; return r; - } - - /* Binary write the given number of bytes into the compressed file. - */ - int write(const void* buf, size_t len) { - return ::gzwrite(m_fp, (voidp) buf, len); - } - - /* 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). flush() returns Z_OK if - * the flush_ parameter is Z_FINISH and all output could be flushed. - * flush() should be called only when strictly necessary because it can - * degrade compression. - */ - int flush(int _flush) { - os_flush(); - return ::gzflush(m_fp, _flush); - } - - /* 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. - */ - const char* error(int* errnum) { - return ::gzerror(m_fp, errnum); - } - - gzFile fp() { return m_fp; } - - ostream& os() { - if (m_os == 0) m_os = new ostrstream; - return *m_os; - } - - void os_flush() { - if (m_os && m_os->pcount()>0) { - ostrstream* oss = new ostrstream; - oss->fill(m_os->fill()); - oss->flags(m_os->flags()); - oss->precision(m_os->precision()); - oss->width(m_os->width()); - ::gzwrite(m_fp, m_os->str(), m_os->pcount()); - delete[] m_os->str(); delete m_os; m_os = oss; - } - } - - private: - gzFile m_fp; - ostrstream* m_os; -}; - -/* - * Binary write the given (array of) object(s) into the compressed file. - * returns the number of uncompressed bytes actually written - * (0 in case of error). - */ -template -inline int write(ozstream& zs, const T* x, Items items) { - return ::gzwrite(zs.fp(), (voidp) x, items*sizeof(T)); -} - -/* - * Binary output with the '<' operator. - */ -template -inline ozstream& operator<(ozstream& zs, const T& x) { - ::gzwrite(zs.fp(), (voidp) &x, sizeof(T)); - return zs; -} - -inline zstringlen::zstringlen(ozstream& zs, const char* x) { - val.byte = 255; val.word = ::strlen(x); - if (val.word < 255) zs < (val.byte = val.word); - else zs < val; -} - -/* - * Write length of string + the string with the '<' operator. - */ -inline ozstream& operator<(ozstream& zs, const char* x) { - zstringlen len(zs, x); - ::gzwrite(zs.fp(), (voidp) x, len.value()); - return zs; -} - -#ifdef _MSC_VER -inline ozstream& operator<(ozstream& zs, char* const& x) { - return zs < (const char*) x; -} -#endif - -/* - * Ascii write with the << operator; - */ -template -inline ostream& operator<<(ozstream& zs, const T& x) { - zs.os_flush(); - return zs.os() << x; -} - -#endif diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream_test.cpp b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream_test.cpp deleted file mode 100644 index 5bbd56c3ad8..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/iostream2/zstream_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "zstream.h" -#include -#include -#include - -void main() { - char h[256] = "Hello"; - char* g = "Goodbye"; - ozstream out("temp.gz"); - out < "This works well" < h < g; - out.close(); - - izstream in("temp.gz"); // read it back - char *x = read_string(in), *y = new char[256], z[256]; - in > y > z; - in.close(); - cout << x << endl << y << endl << z << endl; - - out.open("temp.gz"); // try ascii output; zcat temp.gz to see the results - out << setw(50) << setfill('#') << setprecision(20) << x << endl << y << endl << z << endl; - out << z << endl << y << endl << x << endl; - out << 1.1234567890123456789 << endl; - - delete[] x; delete[] y; -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/ChangeLogUnzip b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/ChangeLogUnzip deleted file mode 100644 index 9987c543cdc..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/ChangeLogUnzip +++ /dev/null @@ -1,38 +0,0 @@ -Change in 0.15: (19 Mar 98) -- fix memory leak in minizip.c - -Change in 0.14: (10 Mar 98) -- fix bugs in minizip.c sample for zipping big file -- fix problem in month in date handling -- fix bug in unzlocal_GetCurrentFileInfoInternal in unzip.c for - comment handling - -Change in 0.13: (6 Mar 98) -- fix bugs in zip.c -- add real minizip sample - -Change in 0.12: (4 Mar 98) -- add zip.c and zip.h for creates .zip file -- fix change_file_date in miniunz.c for Unix (Jean-loup Gailly) -- fix miniunz.c for file without specific record for directory - -Change in 0.11: (3 Mar 98) -- fix bug in unzGetCurrentFileInfo for get extra field and comment -- enhance miniunz sample, remove the bad unztst.c sample - -Change in 0.10: (2 Mar 98) -- fix bug in unzReadCurrentFile -- rename unzip* to unz* function and structure -- remove Windows-like hungary notation variable name -- modify some structure in unzip.h -- add somes comment in source -- remove unzipGetcCurrentFile function -- replace ZUNZEXPORT by ZEXPORT -- add unzGetLocalExtrafield for get the local extrafield info -- add a new sample, miniunz.c - -Change in 0.4: (25 Feb 98) -- suppress the type unzipFileInZip. - Only on file in the zipfile can be open at the same time -- fix somes typo in code -- added tm_unz structure in unzip_file_info (date/time in readable format) diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/miniunz.c b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/miniunz.c deleted file mode 100644 index f3b7832878f..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/miniunz.c +++ /dev/null @@ -1,508 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#ifdef unix -# include -# include -#else -# include -# include -#endif - -#include "unzip.h" - -#define CASESENSITIVITY (0) -#define WRITEBUFFERSIZE (8192) - -/* - mini unzip, demo of unzip package - - usage : - Usage : miniunz [-exvlo] file.zip [file_to_extract] - - list the file in the zipfile, and print the content of FILE_ID.ZIP or README.TXT - if it exists -*/ - - -/* change_file_date : change the date/time of a file - filename : the filename of the file where date/time must be modified - dosdate : the new date at the MSDos format (4 bytes) - tmu_date : the SAME new date at the tm_unz format */ -void change_file_date(filename,dosdate,tmu_date) - const char *filename; - uLong dosdate; - tm_unz tmu_date; -{ -#ifdef WIN32 - HANDLE hFile; - FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite; - - hFile = CreateFile(filename,GENERIC_READ | GENERIC_WRITE, - 0,NULL,OPEN_EXISTING,0,NULL); - GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite); - DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal); - LocalFileTimeToFileTime(&ftLocal,&ftm); - SetFileTime(hFile,&ftm,&ftLastAcc,&ftm); - CloseHandle(hFile); -#else -#ifdef unix - struct utimbuf ut; - struct tm newdate; - newdate.tm_sec = tmu_date.tm_sec; - newdate.tm_min=tmu_date.tm_min; - newdate.tm_hour=tmu_date.tm_hour; - newdate.tm_mday=tmu_date.tm_mday; - newdate.tm_mon=tmu_date.tm_mon; - if (tmu_date.tm_year > 1900) - newdate.tm_year=tmu_date.tm_year - 1900; - else - newdate.tm_year=tmu_date.tm_year ; - newdate.tm_isdst=-1; - - ut.actime=ut.modtime=mktime(&newdate); - utime(filename,&ut); -#endif -#endif -} - - -/* mymkdir and change_file_date are not 100 % portable - As I don't know well Unix, I wait feedback for the unix portion */ - -int mymkdir(dirname) - const char* dirname; -{ - int ret=0; -#ifdef WIN32 - ret = mkdir(dirname); -#else -#ifdef unix - ret = mkdir (dirname,0775); -#endif -#endif - return ret; -} - -int makedir (newdir) - char *newdir; -{ - char *buffer ; - char *p; - int len = strlen(newdir); - - if (len <= 0) - return 0; - - buffer = (char*)malloc(len+1); - strcpy(buffer,newdir); - - if (buffer[len-1] == '/') { - buffer[len-1] = '\0'; - } - if (mymkdir(buffer) == 0) - { - free(buffer); - return 1; - } - - p = buffer+1; - while (1) - { - char hold; - - while(*p && *p != '\\' && *p != '/') - p++; - hold = *p; - *p = 0; - if ((mymkdir(buffer) == -1) && (errno == ENOENT)) - { - printf("couldn't create directory %s\n",buffer); - free(buffer); - return 0; - } - if (hold == 0) - break; - *p++ = hold; - } - free(buffer); - return 1; -} - -void do_banner() -{ - printf("MiniUnz 0.15, demo of zLib + Unz package written by Gilles Vollant\n"); - printf("more info at http://wwww.winimage/zLibDll/unzip.htm\n\n"); -} - -void do_help() -{ - printf("Usage : miniunz [-exvlo] file.zip [file_to_extract]\n\n") ; -} - - -int do_list(uf) - unzFile uf; -{ - uLong i; - unz_global_info gi; - int err; - - err = unzGetGlobalInfo (uf,&gi); - if (err!=UNZ_OK) - printf("error %d with zipfile in unzGetGlobalInfo \n",err); - printf(" Length Method Size Ratio Date Time CRC-32 Name\n"); - printf(" ------ ------ ---- ----- ---- ---- ------ ----\n"); - for (i=0;i0) - ratio = (file_info.compressed_size*100)/file_info.uncompressed_size; - - if (file_info.compression_method==0) - string_method="Stored"; - else - if (file_info.compression_method==Z_DEFLATED) - { - uInt iLevel=(uInt)((file_info.flag & 0x6)/2); - if (iLevel==0) - string_method="Defl:N"; - else if (iLevel==1) - string_method="Defl:X"; - else if ((iLevel==2) || (iLevel==3)) - string_method="Defl:F"; /* 2:fast , 3 : extra fast*/ - } - else - string_method="Unkn. "; - - printf("%7lu %6s %7lu %3lu%% %2.2lu-%2.2lu-%2.2lu %2.2lu:%2.2lu %8.8lx %s\n", - file_info.uncompressed_size,string_method,file_info.compressed_size, - ratio, - (uLong)file_info.tmu_date.tm_mon + 1, - (uLong)file_info.tmu_date.tm_mday, - (uLong)file_info.tmu_date.tm_year % 100, - (uLong)file_info.tmu_date.tm_hour,(uLong)file_info.tmu_date.tm_min, - (uLong)file_info.crc,filename_inzip); - if ((i+1)='a') && (rep<='z')) - rep -= 0x20; - } - while ((rep!='Y') && (rep!='N') && (rep!='A')); - } - - if (rep == 'N') - skip = 1; - - if (rep == 'A') - *popt_overwrite=1; - } - - if ((skip==0) && (err==UNZ_OK)) - { - fout=fopen(write_filename,"wb"); - - /* some zipfile don't contain directory alone before file */ - if ((fout==NULL) && ((*popt_extract_without_path)==0) && - (filename_withoutpath!=(char*)filename_inzip)) - { - char c=*(filename_withoutpath-1); - *(filename_withoutpath-1)='\0'; - makedir(write_filename); - *(filename_withoutpath-1)=c; - fout=fopen(write_filename,"wb"); - } - - if (fout==NULL) - { - printf("error opening %s\n",write_filename); - } - } - - if (fout!=NULL) - { - printf(" extracting: %s\n",write_filename); - - do - { - err = unzReadCurrentFile(uf,buf,size_buf); - if (err<0) - { - printf("error %d with zipfile in unzReadCurrentFile\n",err); - break; - } - if (err>0) - if (fwrite(buf,err,1,fout)!=1) - { - printf("error in writing extracted file\n"); - err=UNZ_ERRNO; - break; - } - } - while (err>0); - fclose(fout); - if (err==0) - change_file_date(write_filename,file_info.dosDate, - file_info.tmu_date); - } - - if (err==UNZ_OK) - { - err = unzCloseCurrentFile (uf); - if (err!=UNZ_OK) - { - printf("error %d with zipfile in unzCloseCurrentFile\n",err); - } - } - else - unzCloseCurrentFile(uf); /* don't lose the error */ - } - - free(buf); - return err; -} - - -int do_extract(uf,opt_extract_without_path,opt_overwrite) - unzFile uf; - int opt_extract_without_path; - int opt_overwrite; -{ - uLong i; - unz_global_info gi; - int err; - FILE* fout=NULL; - - err = unzGetGlobalInfo (uf,&gi); - if (err!=UNZ_OK) - printf("error %d with zipfile in unzGetGlobalInfo \n",err); - - for (i=0;i -#include -#include -#include -#include -#include - -#ifdef unix -# include -# include -# include -# include -#else -# include -# include -#endif - -#include "zip.h" - - -#define WRITEBUFFERSIZE (16384) -#define MAXFILENAME (256) - -#ifdef WIN32 -uLong filetime(f, tmzip, dt) - char *f; /* name of file to get info on */ - tm_zip *tmzip; /* return value: access, modific. and creation times */ - uLong *dt; /* dostime */ -{ - int ret = 0; - { - FILETIME ftLocal; - HANDLE hFind; - WIN32_FIND_DATA ff32; - - hFind = FindFirstFile(f,&ff32); - if (hFind != INVALID_HANDLE_VALUE) - { - FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal); - FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0); - FindClose(hFind); - ret = 1; - } - } - return ret; -} -#else -#ifdef unix -uLong filetime(f, tmzip, dt) - char *f; /* name of file to get info on */ - tm_zip *tmzip; /* return value: access, modific. and creation times */ - uLong *dt; /* dostime */ -{ - int ret=0; - struct stat s; /* results of stat() */ - struct tm* filedate; - time_t tm_t=0; - - if (strcmp(f,"-")!=0) - { - char name[MAXFILENAME]; - int len = strlen(f); - strcpy(name, f); - if (name[len - 1] == '/') - name[len - 1] = '\0'; - /* not all systems allow stat'ing a file with / appended */ - if (stat(name,&s)==0) - { - tm_t = s.st_mtime; - ret = 1; - } - } - filedate = localtime(&tm_t); - - tmzip->tm_sec = filedate->tm_sec; - tmzip->tm_min = filedate->tm_min; - tmzip->tm_hour = filedate->tm_hour; - tmzip->tm_mday = filedate->tm_mday; - tmzip->tm_mon = filedate->tm_mon ; - tmzip->tm_year = filedate->tm_year; - - return ret; -} -#else -uLong filetime(f, tmzip, dt) - char *f; /* name of file to get info on */ - tm_zip *tmzip; /* return value: access, modific. and creation times */ - uLong *dt; /* dostime */ -{ - return 0; -} -#endif -#endif - - - - -int check_exist_file(filename) - const char* filename; -{ - FILE* ftestexist; - int ret = 1; - ftestexist = fopen(filename,"rb"); - if (ftestexist==NULL) - ret = 0; - else - fclose(ftestexist); - return ret; -} - -void do_banner() -{ - printf("MiniZip 0.15, demo of zLib + Zip package written by Gilles Vollant\n"); - printf("more info at http://wwww.winimage/zLibDll/unzip.htm\n\n"); -} - -void do_help() -{ - printf("Usage : minizip [-o] file.zip [files_to_add]\n\n") ; -} - -int main(argc,argv) - int argc; - char *argv[]; -{ - int i; - int opt_overwrite=0; - int opt_compress_level=Z_DEFAULT_COMPRESSION; - int zipfilenamearg = 0; - char filename_try[MAXFILENAME]; - int zipok; - int err=0; - int size_buf=0; - void* buf=NULL, - - - do_banner(); - if (argc==1) - { - do_help(); - exit(0); - return 0; - } - else - { - for (i=1;i='0') && (c<='9')) - opt_compress_level = c-'0'; - } - } - else - if (zipfilenamearg == 0) - zipfilenamearg = i ; - } - } - - size_buf = WRITEBUFFERSIZE; - buf = (void*)malloc(size_buf); - if (buf==NULL) - { - printf("Error allocating memory\n"); - return ZIP_INTERNALERROR; - } - - if (zipfilenamearg==0) - zipok=0; - else - { - int i,len; - int dot_found=0; - - zipok = 1 ; - strcpy(filename_try,argv[zipfilenamearg]); - len=strlen(filename_try); - for (i=0;i='a') && (rep<='z')) - rep -= 0x20; - } - while ((rep!='Y') && (rep!='N')); - if (rep=='N') - zipok = 0; - } - } - - if (zipok==1) - { - zipFile zf; - int errclose; - zf = zipOpen(filename_try,0); - if (zf == NULL) - { - printf("error opening %s\n",filename_try); - err= ZIP_ERRNO; - } - else - printf("creating %s\n",filename_try); - - for (i=zipfilenamearg+1;(i0) - { - err = zipWriteInFileInZip (zf,buf,size_read); - if (err<0) - { - printf("error in writing %s in the zipfile\n", - filenameinzip); - } - - } - } while ((err == ZIP_OK) && (size_read>0)); - - fclose(fin); - if (err<0) - err=ZIP_ERRNO; - else - { - err = zipCloseFileInZip(zf); - if (err!=ZIP_OK) - printf("error in closing %s in the zipfile\n", - filenameinzip); - } - } - } - errclose = zipClose(zf,NULL); - if (errclose != ZIP_OK) - printf("error in closing %s\n",filename_try); - } - - free(buf); - exit(0); - return 0; /* to avoid warning */ -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/readme.txt b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/readme.txt deleted file mode 100644 index 1fc023c720b..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/readme.txt +++ /dev/null @@ -1,37 +0,0 @@ - -UnZip 0.15 additionnal library - - - This unzip package allow extract file from .ZIP file, compatible with -PKZip 2.04g, WinZip, InfoZip tools and compatible. - - Multi volume ZipFile (span) are not supported, and old compression used by old -PKZip 1.x are not supported. - -See probdesc.zip from PKWare for specification of .ZIP format. - -What is Unzip - The Zlib library support the deflate compression and the creation of gzip (.gz) -file. Zlib is free and small. - The .Zip format, which can contain several compressed files (.gz can containt -only one file) is a very popular format. This is why I've written a package for reading file compressed in Zipfile. - -Using Unzip package - -You need source of Zlib (get zlib111.zip and read zlib.h). -Get unzlb015.zip and read unzip.h (whith documentation of unzip functions) - -The Unzip package is only two file : unzip.h and unzip.c. But it use the Zlib - files. -unztst.c is a simple sample program, which list file in a zipfile and display - README.TXT or FILE_ID.DIZ (if these files are found). -miniunz.c is a mini unzip program. - -I'm also currenlyt writing a zipping portion (zip.h, zip.c and test with minizip.c) - -Please email me for feedback. -I hope my source is compatible with Unix system, but I need your help for be sure - -Latest revision : Mar 04th, 1998 - -Check http://www.winimage.com/zLibDll/unzip.html for up to date info. diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.c b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.c deleted file mode 100644 index ff71a474da1..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.c +++ /dev/null @@ -1,1294 +0,0 @@ -/* unzip.c -- IO on .zip files using zlib - Version 0.15 beta, Mar 19th, 1998, - - Read unzip.h for more info -*/ - - -#include -#include -#include -#include "zlib.h" -#include "unzip.h" - -#ifdef STDC -# include -# include -# include -#endif -#ifdef NO_ERRNO_H - extern int errno; -#else -# include -#endif - - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - - - -#if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) && \ - !defined(CASESENSITIVITYDEFAULT_NO) -#define CASESENSITIVITYDEFAULT_NO -#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) - - -/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ - -#ifndef SEEK_CUR -#define SEEK_CUR 1 -#endif - -#ifndef SEEK_END -#define SEEK_END 2 -#endif - -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif - -const char unz_copyright[] = - " unzip 0.15 Copyright 1998 Gilles Vollant "; - -/* unz_file_info_interntal contain internal info about a file in zipfile*/ -typedef struct unz_file_info_internal_s -{ - uLong offset_curfile;/* relative offset of local header 4 bytes */ -} unz_file_info_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 */ - - uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ - uLong stream_initialised; /* flag set if stream structure is initialised*/ - - uLong offset_local_extrafield;/* offset of the local extra field */ - uInt size_local_extrafield;/* size of the local extra field */ - uLong pos_local_extrafield; /* position in the local extra field in read*/ - - uLong crc32; /* crc32 of all data uncompressed */ - uLong crc32_wait; /* crc32 we must obtain after decompress all */ - uLong rest_read_compressed; /* number of byte to be decompressed */ - uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/ - FILE* file; /* io structore of the zipfile */ - uLong compression_method; /* compression method (0==store) */ - uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ -} file_in_zip_read_info_s; - - -/* unz_s contain internal information about the zipfile -*/ -typedef struct -{ - FILE* file; /* io structore of the zipfile */ - unz_global_info gi; /* public global information */ - uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ - uLong num_file; /* number of the current file in the zipfile*/ - uLong pos_in_central_dir; /* pos of the current file in the central dir*/ - uLong current_file_ok; /* flag about the usability of the current file*/ - uLong central_pos; /* position of the beginning of the central dir*/ - - uLong size_central_dir; /* size of the central directory */ - uLong offset_central_dir; /* offset of start of central directory with - respect to the starting disk number */ - - unz_file_info cur_file_info; /* public info about the current file in zip*/ - unz_file_info_internal cur_file_info_internal; /* private info about it*/ - file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current - file if we are decompressing it */ -} unz_s; - - -/* =========================================================================== - 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 unzlocal_getByte(fin,pi) - FILE *fin; - int *pi; -{ - unsigned char c; - int err = fread(&c, 1, 1, fin); - if (err==1) - { - *pi = (int)c; - return UNZ_OK; - } - else - { - if (ferror(fin)) - return UNZ_ERRNO; - else - return UNZ_EOF; - } -} - - -/* =========================================================================== - Reads a long in LSB order from the given gz_stream. Sets -*/ -local int unzlocal_getShort (fin,pX) - FILE* fin; - uLong *pX; -{ - uLong x ; - int i; - int err; - - err = unzlocal_getByte(fin,&i); - x = (uLong)i; - - if (err==UNZ_OK) - err = unzlocal_getByte(fin,&i); - x += ((uLong)i)<<8; - - if (err==UNZ_OK) - *pX = x; - else - *pX = 0; - return err; -} - -local int unzlocal_getLong (fin,pX) - FILE* fin; - uLong *pX; -{ - uLong x ; - int i; - int err; - - err = unzlocal_getByte(fin,&i); - x = (uLong)i; - - if (err==UNZ_OK) - err = unzlocal_getByte(fin,&i); - x += ((uLong)i)<<8; - - if (err==UNZ_OK) - err = unzlocal_getByte(fin,&i); - x += ((uLong)i)<<16; - - if (err==UNZ_OK) - err = unzlocal_getByte(fin,&i); - x += ((uLong)i)<<24; - - if (err==UNZ_OK) - *pX = x; - else - *pX = 0; - return err; -} - - -/* My own strcmpi / strcasecmp */ -local int strcmpcasenosensitive_internal (fileName1,fileName2) - 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 (c1c2) - 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 (fileName1,fileName2,iCaseSensitivity) - const char* fileName1; - const char* fileName2; - int iCaseSensitivity; -{ - if (iCaseSensitivity==0) - iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; - - if (iCaseSensitivity==1) - return strcmp(fileName1,fileName2); - - return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); -} - -#define BUFREADCOMMENT (0x400) - -/* - Locate the Central directory of a zipfile (at the end, just before - the global comment) -*/ -local uLong unzlocal_SearchCentralDir(fin) - FILE *fin; -{ - unsigned char* buf; - uLong uSizeFile; - uLong uBackRead; - uLong uMaxBack=0xffff; /* maximum size of global comment */ - uLong uPosFound=0; - - if (fseek(fin,0,SEEK_END) != 0) - return 0; - - - uSizeFile = ftell( fin ); - - if (uMaxBack>uSizeFile) - uMaxBack = uSizeFile; - - buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); - if (buf==NULL) - return 0; - - uBackRead = 4; - while (uBackReaduMaxBack) - uBackRead = uMaxBack; - else - uBackRead+=BUFREADCOMMENT; - uReadPos = uSizeFile-uBackRead ; - - uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? - (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); - if (fseek(fin,uReadPos,SEEK_SET)!=0) - break; - - if (fread(buf,(uInt)uReadSize,1,fin)!=1) - 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; -} - -/* - Open a Zip file. path contain the full pathname (by example, - on a Windows NT computer "c:\\test\\zlib109.zip" or on an Unix computer - "zlib/zlib109.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. -*/ -extern unzFile ZEXPORT unzOpen (path) - const char *path; -{ - unz_s us; - unz_s *s; - uLong central_pos,uL; - FILE * fin ; - - 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*/ - uLong 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; - - fin=fopen(path,"rb"); - if (fin==NULL) - return NULL; - - central_pos = unzlocal_SearchCentralDir(fin); - if (central_pos==0) - err=UNZ_ERRNO; - - if (fseek(fin,central_pos,SEEK_SET)!=0) - err=UNZ_ERRNO; - - /* the signature, already checked */ - if (unzlocal_getLong(fin,&uL)!=UNZ_OK) - err=UNZ_ERRNO; - - /* number of this disk */ - if (unzlocal_getShort(fin,&number_disk)!=UNZ_OK) - err=UNZ_ERRNO; - - /* number of the disk with the start of the central directory */ - if (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK) - err=UNZ_ERRNO; - - /* total number of entries in the central dir on this disk */ - if (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK) - err=UNZ_ERRNO; - - /* total number of entries in the central dir */ - if (unzlocal_getShort(fin,&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 (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK) - err=UNZ_ERRNO; - - /* offset of start of central directory with respect to the - starting disk number */ - if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK) - err=UNZ_ERRNO; - - /* zipfile comment length */ - if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK) - err=UNZ_ERRNO; - - if ((central_pospfile_in_zip_read!=NULL) - unzCloseCurrentFile(file); - - fclose(s->file); - 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 unzGetGlobalInfo (file,pglobal_info) - unzFile file; - unz_global_info *pglobal_info; -{ - unz_s* s; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - *pglobal_info=s->gi; - return UNZ_OK; -} - - -/* - Translate date/time from Dos format to tm_unz (readable more easilty) -*/ -local void unzlocal_DosDateToTmuDate (ulDosDate, ptm) - uLong ulDosDate; - tm_unz* ptm; -{ - uLong uDate; - uDate = (uLong)(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 unzlocal_GetCurrentFileInfoInternal OF((unzFile file, - unz_file_info *pfile_info, - unz_file_info_internal - *pfile_info_internal, - char *szFileName, - uLong fileNameBufferSize, - void *extraField, - uLong extraFieldBufferSize, - char *szComment, - uLong commentBufferSize)); - -local int unzlocal_GetCurrentFileInfoInternal (file, - pfile_info, - pfile_info_internal, - szFileName, fileNameBufferSize, - extraField, extraFieldBufferSize, - szComment, commentBufferSize) - unzFile file; - unz_file_info *pfile_info; - unz_file_info_internal *pfile_info_internal; - char *szFileName; - uLong fileNameBufferSize; - void *extraField; - uLong extraFieldBufferSize; - char *szComment; - uLong commentBufferSize; -{ - unz_s* s; - unz_file_info file_info; - unz_file_info_internal file_info_internal; - int err=UNZ_OK; - uLong uMagic; - long lSeek=0; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0) - err=UNZ_ERRNO; - - - /* we check the magic */ - if (err==UNZ_OK) - if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) - err=UNZ_ERRNO; - else if (uMagic!=0x02014b50) - err=UNZ_BADZIPFILE; - - if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK) - err=UNZ_ERRNO; - - unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); - - if (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK) - err=UNZ_ERRNO; - - lSeek+=file_info.size_filename; - if ((err==UNZ_OK) && (szFileName!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_filename0) && (fileNameBufferSize>0)) - if (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1) - err=UNZ_ERRNO; - lSeek -= uSizeRead; - } - - - if ((err==UNZ_OK) && (extraField!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_file_extrafile,lSeek,SEEK_CUR)==0) - lSeek=0; - else - err=UNZ_ERRNO; - if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) - if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1) - err=UNZ_ERRNO; - lSeek += file_info.size_file_extra - uSizeRead; - } - else - lSeek+=file_info.size_file_extra; - - - if ((err==UNZ_OK) && (szComment!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_file_commentfile,lSeek,SEEK_CUR)==0) - lSeek=0; - else - err=UNZ_ERRNO; - if ((file_info.size_file_comment>0) && (commentBufferSize>0)) - if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1) - 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 unzGetCurrentFileInfo (file, - pfile_info, - szFileName, fileNameBufferSize, - extraField, extraFieldBufferSize, - szComment, commentBufferSize) - unzFile file; - unz_file_info *pfile_info; - char *szFileName; - uLong fileNameBufferSize; - void *extraField; - uLong extraFieldBufferSize; - char *szComment; - uLong commentBufferSize; -{ - return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, - szFileName,fileNameBufferSize, - extraField,extraFieldBufferSize, - szComment,commentBufferSize); -} - -/* - Set the current file of the zipfile to the first file. - return UNZ_OK if there is no problem -*/ -extern int ZEXPORT unzGoToFirstFile (file) - unzFile file; -{ - int err=UNZ_OK; - unz_s* s; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - s->pos_in_central_dir=s->offset_central_dir; - s->num_file=0; - err=unzlocal_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 (file) - unzFile file; -{ - unz_s* s; - int err; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (!s->current_file_ok) - return UNZ_END_OF_LIST_OF_FILE; - 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 = unzlocal_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 (file, szFileName, iCaseSensitivity) - unzFile file; - const char *szFileName; - int iCaseSensitivity; -{ - unz_s* s; - int err; - - - uLong num_fileSaved; - uLong pos_in_central_dirSaved; - - - if (file==NULL) - return UNZ_PARAMERROR; - - if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) - return UNZ_PARAMERROR; - - s=(unz_s*)file; - if (!s->current_file_ok) - return UNZ_END_OF_LIST_OF_FILE; - - num_fileSaved = s->num_file; - pos_in_central_dirSaved = s->pos_in_central_dir; - - err = unzGoToFirstFile(file); - - while (err == UNZ_OK) - { - char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; - unzGetCurrentFileInfo(file,NULL, - szCurrentFileName,sizeof(szCurrentFileName)-1, - NULL,0,NULL,0); - if (unzStringFileNameCompare(szCurrentFileName, - szFileName,iCaseSensitivity)==0) - return UNZ_OK; - err = unzGoToNextFile(file); - } - - s->num_file = num_fileSaved ; - s->pos_in_central_dir = pos_in_central_dirSaved ; - return err; -} - - -/* - 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 unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, - poffset_local_extrafield, - psize_local_extrafield) - unz_s* s; - uInt* piSizeVar; - uLong *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 (fseek(s->file,s->cur_file_info_internal.offset_curfile + - s->byte_before_the_zipfile,SEEK_SET)!=0) - return UNZ_ERRNO; - - - if (err==UNZ_OK) - if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) - err=UNZ_ERRNO; - else if (uMagic!=0x04034b50) - err=UNZ_BADZIPFILE; - - if (unzlocal_getShort(s->file,&uData) != UNZ_OK) - err=UNZ_ERRNO; -/* - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) - err=UNZ_BADZIPFILE; -*/ - if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&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) && - (s->cur_file_info.compression_method!=Z_DEFLATED)) - err=UNZ_BADZIPFILE; - - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */ - err=UNZ_ERRNO; - - if (unzlocal_getLong(s->file,&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 (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */ - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && - ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; - - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */ - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && - ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; - - - if (unzlocal_getShort(s->file,&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 (unzlocal_getShort(s->file,&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 unzOpenCurrentFile (file) - unzFile file; -{ - int err=UNZ_OK; - int Store; - uInt iSizeVar; - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - uLong offset_local_extrafield; /* offset of the local extra field */ - uInt size_local_extrafield; /* size of the local extra field */ - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (!s->current_file_ok) - return UNZ_PARAMERROR; - - if (s->pfile_in_zip_read != NULL) - unzCloseCurrentFile(file); - - if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, - &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) - return UNZ_BADZIPFILE; - - pfile_in_zip_read_info = (file_in_zip_read_info_s*) - ALLOC(sizeof(file_in_zip_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; - - 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 ((s->cur_file_info.compression_method!=0) && - (s->cur_file_info.compression_method!=Z_DEFLATED)) - err=UNZ_BADZIPFILE; - Store = s->cur_file_info.compression_method==0; - - pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; - pfile_in_zip_read_info->crc32=0; - pfile_in_zip_read_info->compression_method = - s->cur_file_info.compression_method; - pfile_in_zip_read_info->file=s->file; - pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; - - pfile_in_zip_read_info->stream.total_out = 0; - - if (!Store) - { - 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; - - err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); - if (err == Z_OK) - pfile_in_zip_read_info->stream_initialised=1; - /* 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; - return UNZ_OK; -} - - -/* - 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 (file, buf, len) - unzFile file; - voidp buf; - unsigned len; -{ - int err=UNZ_OK; - uInt iRead = 0; - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_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->stream.avail_out = - (uInt)pfile_in_zip_read_info->rest_read_uncompressed; - - 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_compressedrest_read_compressed; - if (uReadThis == 0) - return UNZ_EOF; - if (fseek(pfile_in_zip_read_info->file, - pfile_in_zip_read_info->pos_in_zipfile + - pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0) - return UNZ_ERRNO; - if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1, - pfile_in_zip_read_info->file)!=1) - return UNZ_ERRNO; - 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) - { - uInt uDoCopy,i ; - 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;istream.next_out+i) = - *(pfile_in_zip_read_info->stream.next_in+i); - - 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 - { - uLong uTotalOutBefore,uTotalOutAfter; - const Bytef *bufBefore; - uLong 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); - - uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; - uOutThis = uTotalOutAfter-uTotalOutBefore; - - 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 (file) - unzFile file; -{ - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_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; -} - - -/* - return 1 if the end of file was reached, 0 elsewhere -*/ -extern int ZEXPORT unzeof (file) - unzFile file; -{ - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_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 (file,buf,len) - unzFile file; - voidp buf; - unsigned len; -{ - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - uInt read_now; - uLong size_to_read; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_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 (fseek(pfile_in_zip_read_info->file, - pfile_in_zip_read_info->offset_local_extrafield + - pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0) - return UNZ_ERRNO; - - if (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1) - 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 (file) - unzFile file; -{ - int err=UNZ_OK; - - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_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) - { - 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) - inflateEnd(&pfile_in_zip_read_info->stream); - - 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 (file, szComment, uSizeBuf) - unzFile file; - char *szComment; - uLong uSizeBuf; -{ - int err=UNZ_OK; - unz_s* s; - uLong uReadThis ; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - - uReadThis = uSizeBuf; - if (uReadThis>s->gi.size_comment) - uReadThis = s->gi.size_comment; - - if (fseek(s->file,s->central_pos+22,SEEK_SET)!=0) - return UNZ_ERRNO; - - if (uReadThis>0) - { - *szComment='\0'; - if (fread(szComment,(uInt)uReadThis,1,s->file)!=1) - return UNZ_ERRNO; - } - - if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) - *(szComment+s->gi.size_comment)='\0'; - return (int)uReadThis; -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.def b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.def deleted file mode 100644 index f6ede89bc96..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.def +++ /dev/null @@ -1,15 +0,0 @@ - unzOpen @61 - unzClose @62 - unzGetGlobalInfo @63 - unzGetCurrentFileInfo @64 - unzGoToFirstFile @65 - unzGoToNextFile @66 - unzOpenCurrentFile @67 - unzReadCurrentFile @68 - unztell @70 - unzeof @71 - unzCloseCurrentFile @72 - unzGetGlobalComment @73 - unzStringFileNameCompare @74 - unzLocateFile @75 - unzGetLocalExtrafield @76 diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.h b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.h deleted file mode 100644 index 76692cb703c..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/unzip.h +++ /dev/null @@ -1,275 +0,0 @@ -/* unzip.h -- IO for uncompress .zip files using zlib - Version 0.15 beta, Mar 19th, 1998, - - Copyright (C) 1998 Gilles Vollant - - This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g - WinZip, InfoZip tools and compatible. - Encryption and multi volume ZipFile (span) are not supported. - Old compressions used by old PKZip 1.x are not supported - - THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE - CAN CHANGE IN FUTURE VERSION !! - I WAIT FEEDBACK at mail info@winimage.com - Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution - - 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. - - -*/ -/* for more info about .ZIP format, see - ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip - PkWare has also a specification at : - ftp://ftp.pkware.com/probdesc.zip */ - -#ifndef _unz_H -#define _unz_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _ZLIB_H -#include "zlib.h" -#endif - -#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_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_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)); -/* - Open a Zip file. path contain the full pathname (by example, - on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer - "zlib/zlib111.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. -*/ - -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)); -/* - 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 -*/ - - -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) -*/ - -/***************************************************************************/ -/* 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 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)); -/* - 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 -*/ - -#ifdef __cplusplus -} -#endif - -#endif /* _unz_H */ diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.c b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.c deleted file mode 100644 index 0cae64ab7b1..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.c +++ /dev/null @@ -1,718 +0,0 @@ -/* zip.c -- IO on .zip files using zlib - Version 0.15 beta, Mar 19th, 1998, - - Read zip.h for more info -*/ - - -#include -#include -#include -#include "zlib.h" -#include "zip.h" - -#ifdef STDC -# include -# include -# include -#endif -#ifdef NO_ERRNO_H - extern int errno; -#else -# include -#endif - - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - -#ifndef VERSIONMADEBY -# define VERSIONMADEBY (0x0) /* platform depedent */ -#endif - -#ifndef Z_BUFSIZE -#define Z_BUFSIZE (16384) -#endif - -#ifndef Z_MAXFILENAMEINZIP -#define Z_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) -*/ - -/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ - -#ifndef SEEK_CUR -#define SEEK_CUR 1 -#endif - -#ifndef SEEK_END -#define SEEK_END 2 -#endif - -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif - -const char zip_copyright[] = - " zip 0.15 Copyright 1998 Gilles Vollant "; - - -#define SIZEDATA_INDATABLOCK (4096-(4*4)) - -#define LOCALHEADERMAGIC (0x04034b50) -#define CENTRALHEADERMAGIC (0x02014b50) -#define ENDHEADERMAGIC (0x06054b50) - -#define FLAG_LOCALHEADER_OFFSET (0x06) -#define CRC_LOCALHEADER_OFFSET (0x0e) - -#define SIZECENTRALHEADER (0x2e) /* 46 */ - -typedef struct linkedlist_datablock_internal_s -{ - struct linkedlist_datablock_internal_s* next_datablock; - uLong avail_in_this_block; - uLong filled_in_this_block; - uLong unused; /* for future use and alignement */ - unsigned char data[SIZEDATA_INDATABLOCK]; -} linkedlist_datablock_internal; - -typedef struct linkedlist_data_s -{ - linkedlist_datablock_internal* first_block; - linkedlist_datablock_internal* last_block; -} linkedlist_data; - - -typedef struct -{ - z_stream stream; /* zLib stream structure for inflate */ - int stream_initialised; /* 1 is stream is initialised */ - uInt pos_in_buffered_data; /* last written byte in buffered_data */ - - uLong pos_local_header; /* offset of the local header of the file - currenty writing */ - char* central_header; /* central header data for the current file */ - uLong size_centralheader; /* size of the central header for cur file */ - uLong flag; /* flag of the file currently writing */ - - int method; /* compression method of file currenty wr.*/ - Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/ - uLong dosDate; - uLong crc32; -} curfile_info; - -typedef struct -{ - FILE * filezip; - linkedlist_data central_dir;/* datablock with central dir in construction*/ - int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/ - curfile_info ci; /* info on the file curretly writing */ - - uLong begin_pos; /* position of the beginning of the zipfile */ - uLong number_entry; -} zip_internal; - -local linkedlist_datablock_internal* allocate_new_datablock() -{ - linkedlist_datablock_internal* ldi; - ldi = (linkedlist_datablock_internal*) - ALLOC(sizeof(linkedlist_datablock_internal)); - if (ldi!=NULL) - { - ldi->next_datablock = NULL ; - ldi->filled_in_this_block = 0 ; - ldi->avail_in_this_block = SIZEDATA_INDATABLOCK ; - } - return ldi; -} - -local void free_datablock(ldi) - linkedlist_datablock_internal* ldi; -{ - while (ldi!=NULL) - { - linkedlist_datablock_internal* ldinext = ldi->next_datablock; - TRYFREE(ldi); - ldi = ldinext; - } -} - -local void init_linkedlist(ll) - linkedlist_data* ll; -{ - ll->first_block = ll->last_block = NULL; -} - -local void free_linkedlist(ll) - linkedlist_data* ll; -{ - free_datablock(ll->first_block); - ll->first_block = ll->last_block = NULL; -} - - -local int add_data_in_datablock(ll,buf,len) - linkedlist_data* ll; - const void* buf; - uLong len; -{ - linkedlist_datablock_internal* ldi; - const unsigned char* from_copy; - - if (ll==NULL) - return ZIP_INTERNALERROR; - - if (ll->last_block == NULL) - { - ll->first_block = ll->last_block = allocate_new_datablock(); - if (ll->first_block == NULL) - return ZIP_INTERNALERROR; - } - - ldi = ll->last_block; - from_copy = (unsigned char*)buf; - - while (len>0) - { - uInt copy_this; - uInt i; - unsigned char* to_copy; - - if (ldi->avail_in_this_block==0) - { - ldi->next_datablock = allocate_new_datablock(); - if (ldi->next_datablock == NULL) - return ZIP_INTERNALERROR; - ldi = ldi->next_datablock ; - ll->last_block = ldi; - } - - if (ldi->avail_in_this_block < len) - copy_this = (uInt)ldi->avail_in_this_block; - else - copy_this = (uInt)len; - - to_copy = &(ldi->data[ldi->filled_in_this_block]); - - for (i=0;ifilled_in_this_block += copy_this; - ldi->avail_in_this_block -= copy_this; - from_copy += copy_this ; - len -= copy_this; - } - return ZIP_OK; -} - - -local int write_datablock(fout,ll) - FILE * fout; - linkedlist_data* ll; -{ - linkedlist_datablock_internal* ldi; - ldi = ll->first_block; - while (ldi!=NULL) - { - if (ldi->filled_in_this_block > 0) - if (fwrite(ldi->data,(uInt)ldi->filled_in_this_block,1,fout)!=1) - return ZIP_ERRNO; - ldi = ldi->next_datablock; - } - return ZIP_OK; -} - -/****************************************************************************/ - -/* =========================================================================== - Outputs a long in LSB order to the given file - nbByte == 1, 2 or 4 (byte, short or long) -*/ - -local int ziplocal_putValue OF((FILE *file, uLong x, int nbByte)); -local int ziplocal_putValue (file, x, nbByte) - FILE *file; - uLong x; - int nbByte; -{ - unsigned char buf[4]; - int n; - for (n = 0; n < nbByte; n++) { - buf[n] = (unsigned char)(x & 0xff); - x >>= 8; - } - if (fwrite(buf,nbByte,1,file)!=1) - return ZIP_ERRNO; - else - return ZIP_OK; -} - -local void ziplocal_putValue_inmemory OF((void* dest, uLong x, int nbByte)); -local void ziplocal_putValue_inmemory (dest, x, nbByte) - void* dest; - uLong x; - int nbByte; -{ - unsigned char* buf=(unsigned char*)dest; - int n; - for (n = 0; n < nbByte; n++) { - buf[n] = (unsigned char)(x & 0xff); - x >>= 8; - } -} -/****************************************************************************/ - - -local uLong ziplocal_TmzDateToDosDate(ptm,dosDate) - tm_zip* ptm; - uLong dosDate; -{ - uLong year = (uLong)ptm->tm_year; - if (year>1980) - year-=1980; - else if (year>80) - year-=80; - return - (uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) | - ((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour)); -} - - -/****************************************************************************/ - -extern zipFile ZEXPORT zipOpen (pathname, append) - const char *pathname; - int append; -{ - zip_internal ziinit; - zip_internal* zi; - - ziinit.filezip = fopen(pathname,(append == 0) ? "wb" : "ab"); - if (ziinit.filezip == NULL) - return NULL; - ziinit.begin_pos = ftell(ziinit.filezip); - ziinit.in_opened_file_inzip = 0; - ziinit.ci.stream_initialised = 0; - ziinit.number_entry = 0; - init_linkedlist(&(ziinit.central_dir)); - - - zi = (zip_internal*)ALLOC(sizeof(zip_internal)); - if (zi==NULL) - { - fclose(ziinit.filezip); - return NULL; - } - - *zi = ziinit; - return (zipFile)zi; -} - -extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level) - zipFile file; - const char* filename; - const zip_fileinfo* zipfi; - const void* extrafield_local; - uInt size_extrafield_local; - const void* extrafield_global; - uInt size_extrafield_global; - const char* comment; - int method; - int level; -{ - zip_internal* zi; - uInt size_filename; - uInt size_comment; - uInt i; - int err = ZIP_OK; - - if (file == NULL) - return ZIP_PARAMERROR; - if ((method!=0) && (method!=Z_DEFLATED)) - return ZIP_PARAMERROR; - - zi = (zip_internal*)file; - - if (zi->in_opened_file_inzip == 1) - { - err = zipCloseFileInZip (file); - if (err != ZIP_OK) - return err; - } - - - if (filename==NULL) - filename="-"; - - if (comment==NULL) - size_comment = 0; - else - size_comment = strlen(comment); - - size_filename = strlen(filename); - - if (zipfi == NULL) - zi->ci.dosDate = 0; - else - { - if (zipfi->dosDate != 0) - zi->ci.dosDate = zipfi->dosDate; - else zi->ci.dosDate = ziplocal_TmzDateToDosDate(&zipfi->tmz_date,zipfi->dosDate); - } - - zi->ci.flag = 0; - if ((level==8) || (level==9)) - zi->ci.flag |= 2; - if ((level==2)) - zi->ci.flag |= 4; - if ((level==1)) - zi->ci.flag |= 6; - - zi->ci.crc32 = 0; - zi->ci.method = method; - zi->ci.stream_initialised = 0; - zi->ci.pos_in_buffered_data = 0; - zi->ci.pos_local_header = ftell(zi->filezip); - zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + - size_extrafield_global + size_comment; - zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader); - - ziplocal_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4); - /* version info */ - ziplocal_putValue_inmemory(zi->ci.central_header+4,(uLong)VERSIONMADEBY,2); - ziplocal_putValue_inmemory(zi->ci.central_header+6,(uLong)20,2); - ziplocal_putValue_inmemory(zi->ci.central_header+8,(uLong)zi->ci.flag,2); - ziplocal_putValue_inmemory(zi->ci.central_header+10,(uLong)zi->ci.method,2); - ziplocal_putValue_inmemory(zi->ci.central_header+12,(uLong)zi->ci.dosDate,4); - ziplocal_putValue_inmemory(zi->ci.central_header+16,(uLong)0,4); /*crc*/ - ziplocal_putValue_inmemory(zi->ci.central_header+20,(uLong)0,4); /*compr size*/ - ziplocal_putValue_inmemory(zi->ci.central_header+24,(uLong)0,4); /*uncompr size*/ - ziplocal_putValue_inmemory(zi->ci.central_header+28,(uLong)size_filename,2); - ziplocal_putValue_inmemory(zi->ci.central_header+30,(uLong)size_extrafield_global,2); - ziplocal_putValue_inmemory(zi->ci.central_header+32,(uLong)size_comment,2); - ziplocal_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/ - - if (zipfi==NULL) - ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2); - else - ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2); - - if (zipfi==NULL) - ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4); - else - ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4); - - ziplocal_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header,4); - - for (i=0;ici.central_header+SIZECENTRALHEADER+i) = *(filename+i); - - for (i=0;ici.central_header+SIZECENTRALHEADER+size_filename+i) = - *(((const char*)extrafield_global)+i); - - for (i=0;ici.central_header+SIZECENTRALHEADER+size_filename+ - size_extrafield_global+i) = *(filename+i); - if (zi->ci.central_header == NULL) - return ZIP_INTERNALERROR; - - /* write the local header */ - err = ziplocal_putValue(zi->filezip,(uLong)LOCALHEADERMAGIC,4); - - if (err==ZIP_OK) - err = ziplocal_putValue(zi->filezip,(uLong)20,2);/* version needed to extract */ - if (err==ZIP_OK) - err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.flag,2); - - if (err==ZIP_OK) - err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.method,2); - - if (err==ZIP_OK) - err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.dosDate,4); - - if (err==ZIP_OK) - err = ziplocal_putValue(zi->filezip,(uLong)0,4); /* crc 32, unknown */ - if (err==ZIP_OK) - err = ziplocal_putValue(zi->filezip,(uLong)0,4); /* compressed size, unknown */ - if (err==ZIP_OK) - err = ziplocal_putValue(zi->filezip,(uLong)0,4); /* uncompressed size, unknown */ - - if (err==ZIP_OK) - err = ziplocal_putValue(zi->filezip,(uLong)size_filename,2); - - if (err==ZIP_OK) - err = ziplocal_putValue(zi->filezip,(uLong)size_extrafield_local,2); - - if ((err==ZIP_OK) && (size_filename>0)) - if (fwrite(filename,(uInt)size_filename,1,zi->filezip)!=1) - err = ZIP_ERRNO; - - if ((err==ZIP_OK) && (size_extrafield_local>0)) - if (fwrite(extrafield_local,(uInt)size_extrafield_local,1,zi->filezip) - !=1) - err = ZIP_ERRNO; - - zi->ci.stream.avail_in = (uInt)0; - zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; - zi->ci.stream.next_out = zi->ci.buffered_data; - zi->ci.stream.total_in = 0; - zi->ci.stream.total_out = 0; - - if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED)) - { - zi->ci.stream.zalloc = (alloc_func)0; - zi->ci.stream.zfree = (free_func)0; - zi->ci.stream.opaque = (voidpf)0; - - err = deflateInit2(&zi->ci.stream, level, - Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, 0); - - if (err==Z_OK) - zi->ci.stream_initialised = 1; - } - - - if (err==Z_OK) - zi->in_opened_file_inzip = 1; - return err; -} - -extern int ZEXPORT zipWriteInFileInZip (file, buf, len) - zipFile file; - const voidp buf; - unsigned len; -{ - zip_internal* zi; - int err=ZIP_OK; - - if (file == NULL) - return ZIP_PARAMERROR; - zi = (zip_internal*)file; - - if (zi->in_opened_file_inzip == 0) - return ZIP_PARAMERROR; - - zi->ci.stream.next_in = buf; - zi->ci.stream.avail_in = len; - zi->ci.crc32 = crc32(zi->ci.crc32,buf,len); - - while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) - { - if (zi->ci.stream.avail_out == 0) - { - if (fwrite(zi->ci.buffered_data,(uInt)zi->ci.pos_in_buffered_data,1,zi->filezip) - !=1) - err = ZIP_ERRNO; - zi->ci.pos_in_buffered_data = 0; - zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; - zi->ci.stream.next_out = zi->ci.buffered_data; - } - - if (zi->ci.method == Z_DEFLATED) - { - uLong uTotalOutBefore = zi->ci.stream.total_out; - err=deflate(&zi->ci.stream, Z_NO_FLUSH); - zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; - - } - else - { - uInt copy_this,i; - if (zi->ci.stream.avail_in < zi->ci.stream.avail_out) - copy_this = zi->ci.stream.avail_in; - else - copy_this = zi->ci.stream.avail_out; - for (i=0;ici.stream.next_out)+i) = - *(((const char*)zi->ci.stream.next_in)+i); - { - zi->ci.stream.avail_in -= copy_this; - zi->ci.stream.avail_out-= copy_this; - zi->ci.stream.next_in+= copy_this; - zi->ci.stream.next_out+= copy_this; - zi->ci.stream.total_in+= copy_this; - zi->ci.stream.total_out+= copy_this; - zi->ci.pos_in_buffered_data += copy_this; - } - } - } - - return 0; -} - -extern int ZEXPORT zipCloseFileInZip (file) - zipFile file; -{ - zip_internal* zi; - int err=ZIP_OK; - - if (file == NULL) - return ZIP_PARAMERROR; - zi = (zip_internal*)file; - - if (zi->in_opened_file_inzip == 0) - return ZIP_PARAMERROR; - zi->ci.stream.avail_in = 0; - - if (zi->ci.method == Z_DEFLATED) - while (err==ZIP_OK) - { - uLong uTotalOutBefore; - if (zi->ci.stream.avail_out == 0) - { - if (fwrite(zi->ci.buffered_data,(uInt)zi->ci.pos_in_buffered_data,1,zi->filezip) - !=1) - err = ZIP_ERRNO; - zi->ci.pos_in_buffered_data = 0; - zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; - zi->ci.stream.next_out = zi->ci.buffered_data; - } - uTotalOutBefore = zi->ci.stream.total_out; - err=deflate(&zi->ci.stream, Z_FINISH); - zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; - } - - if (err==Z_STREAM_END) - err=ZIP_OK; /* this is normal */ - - if ((zi->ci.pos_in_buffered_data>0) && (err==ZIP_OK)) - if (fwrite(zi->ci.buffered_data,(uInt)zi->ci.pos_in_buffered_data,1,zi->filezip) - !=1) - err = ZIP_ERRNO; - - if ((zi->ci.method == Z_DEFLATED) && (err==ZIP_OK)) - { - err=deflateEnd(&zi->ci.stream); - zi->ci.stream_initialised = 0; - } - - ziplocal_putValue_inmemory(zi->ci.central_header+16,(uLong)zi->ci.crc32,4); /*crc*/ - ziplocal_putValue_inmemory(zi->ci.central_header+20, - (uLong)zi->ci.stream.total_out,4); /*compr size*/ - ziplocal_putValue_inmemory(zi->ci.central_header+24, - (uLong)zi->ci.stream.total_in,4); /*uncompr size*/ - - if (err==ZIP_OK) - err = add_data_in_datablock(&zi->central_dir,zi->ci.central_header, - (uLong)zi->ci.size_centralheader); - free(zi->ci.central_header); - - if (err==ZIP_OK) - { - long cur_pos_inzip = ftell(zi->filezip); - if (fseek(zi->filezip, - zi->ci.pos_local_header + 14,SEEK_SET)!=0) - err = ZIP_ERRNO; - - if (err==ZIP_OK) - err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.crc32,4); /* crc 32, unknown */ - - if (err==ZIP_OK) /* compressed size, unknown */ - err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.stream.total_out,4); - - if (err==ZIP_OK) /* uncompressed size, unknown */ - err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.stream.total_in,4); - - if (fseek(zi->filezip, - cur_pos_inzip,SEEK_SET)!=0) - err = ZIP_ERRNO; - } - - zi->number_entry ++; - zi->in_opened_file_inzip = 0; - - return err; -} - -extern int ZEXPORT zipClose (file, global_comment) - zipFile file; - const char* global_comment; -{ - zip_internal* zi; - int err = 0; - uLong size_centraldir = 0; - uLong centraldir_pos_inzip ; - uInt size_global_comment; - if (file == NULL) - return ZIP_PARAMERROR; - zi = (zip_internal*)file; - - if (zi->in_opened_file_inzip == 1) - { - err = zipCloseFileInZip (file); - } - - if (global_comment==NULL) - size_global_comment = 0; - else - size_global_comment = strlen(global_comment); - - - centraldir_pos_inzip = ftell(zi->filezip); - if (err==ZIP_OK) - { - linkedlist_datablock_internal* ldi = zi->central_dir.first_block ; - while (ldi!=NULL) - { - if ((err==ZIP_OK) && (ldi->filled_in_this_block>0)) - if (fwrite(ldi->data,(uInt)ldi->filled_in_this_block, - 1,zi->filezip) !=1 ) - err = ZIP_ERRNO; - - size_centraldir += ldi->filled_in_this_block; - ldi = ldi->next_datablock; - } - } - free_datablock(zi->central_dir.first_block); - - if (err==ZIP_OK) /* Magic End */ - err = ziplocal_putValue(zi->filezip,(uLong)ENDHEADERMAGIC,4); - - if (err==ZIP_OK) /* number of this disk */ - err = ziplocal_putValue(zi->filezip,(uLong)0,2); - - if (err==ZIP_OK) /* number of the disk with the start of the central directory */ - err = ziplocal_putValue(zi->filezip,(uLong)0,2); - - if (err==ZIP_OK) /* total number of entries in the central dir on this disk */ - err = ziplocal_putValue(zi->filezip,(uLong)zi->number_entry,2); - - if (err==ZIP_OK) /* total number of entries in the central dir */ - err = ziplocal_putValue(zi->filezip,(uLong)zi->number_entry,2); - - if (err==ZIP_OK) /* size of the central directory */ - err = ziplocal_putValue(zi->filezip,(uLong)size_centraldir,4); - - if (err==ZIP_OK) /* offset of start of central directory with respect to the - starting disk number */ - err = ziplocal_putValue(zi->filezip,(uLong)centraldir_pos_inzip ,4); - - if (err==ZIP_OK) /* zipfile comment length */ - err = ziplocal_putValue(zi->filezip,(uLong)size_global_comment,2); - - if ((err==ZIP_OK) && (size_global_comment>0)) - if (fwrite(global_comment,(uInt)size_global_comment,1,zi->filezip) !=1 ) - err = ZIP_ERRNO; - fclose(zi->filezip); - TRYFREE(zi); - - return err; -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.def b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.def deleted file mode 100644 index 5d5079fbcee..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.def +++ /dev/null @@ -1,5 +0,0 @@ - zipOpen @80 - zipOpenNewFileInZip @81 - zipWriteInFileInZip @82 - zipCloseFileInZip @83 - zipClose @84 diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.h b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.h deleted file mode 100644 index 678260b330b..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zip.h +++ /dev/null @@ -1,150 +0,0 @@ -/* zip.h -- IO for compress .zip files using zlib - Version 0.15 alpha, Mar 19th, 1998, - - Copyright (C) 1998 Gilles Vollant - - This unzip package allow creates .ZIP file, compatible with PKZip 2.04g - WinZip, InfoZip tools and compatible. - Encryption and multi volume ZipFile (span) are not supported. - Old compressions used by old PKZip 1.x are not supported - - For uncompress .zip file, look at unzip.h - - THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE - CAN CHANGE IN FUTURE VERSION !! - I WAIT FEEDBACK at mail info@winimage.com - Visit also http://www.winimage.com/zLibDll/zip.htm for evolution - - 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. - - -*/ - -/* for more info about .ZIP format, see - ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip - PkWare has also a specification at : - ftp://ftp.pkware.com/probdesc.zip -*/ - -#ifndef _zip_H -#define _zip_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _ZLIB_H -#include "zlib.h" -#endif - -#if defined(STRICTZIP) || defined(STRICTZIPUNZIP) -/* like the STRICT of WIN32, we define a pointer that cannot be converted - from (void*) without cast */ -typedef struct TagzipFile__ { int unused; } zipFile__; -typedef zipFile__ *zipFile; -#else -typedef voidp zipFile; -#endif - -#define ZIP_OK (0) -#define ZIP_ERRNO (Z_ERRNO) -#define ZIP_PARAMERROR (-102) -#define ZIP_INTERNALERROR (-104) - -/* tm_zip contain date/time info */ -typedef struct tm_zip_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_zip; - -typedef struct -{ - tm_zip tmz_date; /* date in understandable format */ - uLong dosDate; /* if dos_date == 0, tmu_date is used */ -/* uLong flag; */ /* general purpose bit flag 2 bytes */ - - uLong internal_fa; /* internal file attributes 2 bytes */ - uLong external_fa; /* external file attributes 4 bytes */ -} zip_fileinfo; - -extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); -/* - Create a zipfile. - pathname contain on Windows NT a filename like "c:\\zlib\\zlib111.zip" or on - an Unix computer "zlib/zlib111.zip". - if the file pathname exist and append=1, the zip will be created at the end - of the file. (useful if the file contain a self extractor code) - If the zipfile cannot be opened, the return value is NULL. - Else, the return value is a zipFile Handle, usable with other function - of this zip package. - - -*/ - -extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level)); -/* - Open a file in the ZIP for writing. - filename : the filename in zip (if NULL, '-' without quote will be used - *zipfi contain supplemental information - if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local - contains the extrafield data the the local header - if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global - contains the extrafield data the the local header - if comment != NULL, comment contain the comment string - method contain the compression method (0 for store, Z_DEFLATED for deflate) - level contain the level of compression (can be Z_DEFAULT_COMPRESSION) -*/ - -extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, - const voidp buf, - unsigned len)); -/* - Write data in the zipfile -*/ - -extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); -/* - Close the current file in the zipfile -*/ - -extern int ZEXPORT zipClose OF((zipFile file, - const char* global_comment)); -/* - Close the zipfile -*/ - -#ifdef __cplusplus -} -#endif - -#endif /* _zip_H */ diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zlibvc.def b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zlibvc.def deleted file mode 100644 index 7e9d60d55d9..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zlibvc.def +++ /dev/null @@ -1,74 +0,0 @@ -LIBRARY "zlib" - -DESCRIPTION '"""zlib data compression library"""' - - -VERSION 1.11 - - -HEAPSIZE 1048576,8192 - -EXPORTS - adler32 @1 - compress @2 - crc32 @3 - deflate @4 - deflateCopy @5 - deflateEnd @6 - deflateInit2_ @7 - deflateInit_ @8 - deflateParams @9 - deflateReset @10 - deflateSetDictionary @11 - gzclose @12 - gzdopen @13 - gzerror @14 - gzflush @15 - gzopen @16 - gzread @17 - gzwrite @18 - inflate @19 - inflateEnd @20 - inflateInit2_ @21 - inflateInit_ @22 - inflateReset @23 - inflateSetDictionary @24 - inflateSync @25 - uncompress @26 - zlibVersion @27 - gzprintf @28 - gzputc @29 - gzgetc @30 - gzseek @31 - gzrewind @32 - gztell @33 - gzeof @34 - gzsetparams @35 - zError @36 - inflateSyncPoint @37 - get_crc_table @38 - compress2 @39 - gzputs @40 - gzgets @41 - - unzOpen @61 - unzClose @62 - unzGetGlobalInfo @63 - unzGetCurrentFileInfo @64 - unzGoToFirstFile @65 - unzGoToNextFile @66 - unzOpenCurrentFile @67 - unzReadCurrentFile @68 - unztell @70 - unzeof @71 - unzCloseCurrentFile @72 - unzGetGlobalComment @73 - unzStringFileNameCompare @74 - unzLocateFile @75 - unzGetLocalExtrafield @76 - - zipOpen @80 - zipOpenNewFileInZip @81 - zipWriteInFileInZip @82 - zipCloseFileInZip @83 - zipClose @84 diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zlibvc.dsp b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zlibvc.dsp deleted file mode 100644 index a70d4d4a6b0..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zlibvc.dsp +++ /dev/null @@ -1,651 +0,0 @@ -# Microsoft Developer Studio Project File - Name="zlibvc" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 5.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 -# TARGTYPE "Win32 (ALPHA) Dynamic-Link Library" 0x0602 - -CFG=zlibvc - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "zlibvc.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "zlibvc.mak" CFG="zlibvc - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "zlibvc - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "zlibvc - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "zlibvc - Win32 ReleaseAxp" (based on\ - "Win32 (ALPHA) Dynamic-Link Library") -!MESSAGE "zlibvc - Win32 ReleaseWithoutAsm" (based on\ - "Win32 (x86) Dynamic-Link Library") -!MESSAGE "zlibvc - Win32 ReleaseWithoutCrtdll" (based on\ - "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir ".\Release" -# PROP BASE Intermediate_Dir ".\Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir ".\Release" -# PROP Intermediate_Dir ".\Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /FD /c -# SUBTRACT CPP /YX -MTL=midl.exe -# ADD BASE MTL /nologo /D "NDEBUG" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -RSC=rc.exe -# ADD BASE RSC /l 0x40c /d "NDEBUG" -# ADD RSC /l 0x40c /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# 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 /dll /machine:I386 -# ADD LINK32 gvmat32.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib crtdll.lib /nologo /subsystem:windows /dll /map /machine:I386 /nodefaultlib /out:".\Release\zlib.dll" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir ".\Debug" -# PROP BASE Intermediate_Dir ".\Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir ".\Debug" -# PROP Intermediate_Dir ".\Debug" -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /FD /c -# SUBTRACT CPP /YX -MTL=midl.exe -# ADD BASE MTL /nologo /D "_DEBUG" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -RSC=rc.exe -# ADD BASE RSC /l 0x40c /d "_DEBUG" -# ADD RSC /l 0x40c /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# 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 /dll /debug /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:".\Debug\zlib.dll" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "zlibvc__" -# PROP BASE Intermediate_Dir "zlibvc__" -# PROP BASE Ignore_Export_Lib 0 -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "zlibvc__" -# PROP Intermediate_Dir "zlibvc__" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -MTL=midl.exe -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -CPP=cl.exe -# ADD BASE CPP /nologo /MT /Gt0 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /YX /FD /c -# ADD CPP /nologo /MT /Gt0 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /FD /c -# SUBTRACT CPP /YX -RSC=rc.exe -# ADD BASE RSC /l 0x40c /d "NDEBUG" -# ADD RSC /l 0x40c /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 crtdll.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /map /machine:ALPHA /nodefaultlib /out:".\Release\zlib.dll" -# SUBTRACT BASE LINK32 /pdb:none -# ADD LINK32 crtdll.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /map /machine:ALPHA /nodefaultlib /out:"zlibvc__\zlib.dll" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "zlibvc_0" -# PROP BASE Intermediate_Dir "zlibvc_0" -# PROP BASE Ignore_Export_Lib 0 -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "zlibvc_0" -# PROP Intermediate_Dir "zlibvc_0" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /FD /c -# SUBTRACT CPP /YX -MTL=midl.exe -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -RSC=rc.exe -# ADD BASE RSC /l 0x40c /d "NDEBUG" -# ADD RSC /l 0x40c /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib crtdll.lib /nologo /subsystem:windows /dll /map /machine:I386 /nodefaultlib /out:".\Release\zlib.dll" -# SUBTRACT BASE LINK32 /pdb:none -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib crtdll.lib /nologo /subsystem:windows /dll /map /machine:I386 /nodefaultlib /out:".\zlibvc_0\zlib.dll" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "zlibvc_1" -# PROP BASE Intermediate_Dir "zlibvc_1" -# PROP BASE Ignore_Export_Lib 0 -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "zlibvc_1" -# PROP Intermediate_Dir "zlibvc_1" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /FD /c -# SUBTRACT CPP /YX -MTL=midl.exe -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -RSC=rc.exe -# ADD BASE RSC /l 0x40c /d "NDEBUG" -# ADD RSC /l 0x40c /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 gvmat32.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib crtdll.lib /nologo /subsystem:windows /dll /map /machine:I386 /nodefaultlib /out:".\Release\zlib.dll" -# SUBTRACT BASE LINK32 /pdb:none -# ADD LINK32 gvmat32.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib crtdll.lib /nologo /subsystem:windows /dll /map /machine:I386 /nodefaultlib /out:".\zlibvc_1\zlib.dll" -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "zlibvc - Win32 Release" -# Name "zlibvc - Win32 Debug" -# Name "zlibvc - Win32 ReleaseAxp" -# Name "zlibvc - Win32 ReleaseWithoutAsm" -# Name "zlibvc - Win32 ReleaseWithoutCrtdll" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90" -# Begin Source File - -SOURCE=.\adler32.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_ADLER=\ - ".\zconf.h"\ - ".\zlib.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\compress.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_COMPR=\ - ".\zconf.h"\ - ".\zlib.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\crc32.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_CRC32=\ - ".\zconf.h"\ - ".\zlib.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\deflate.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_DEFLA=\ - ".\deflate.h"\ - ".\zconf.h"\ - ".\zlib.h"\ - ".\zutil.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\gvmat32c.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\gzio.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_GZIO_=\ - ".\zconf.h"\ - ".\zlib.h"\ - ".\zutil.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\infblock.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_INFBL=\ - ".\infblock.h"\ - ".\infcodes.h"\ - ".\inftrees.h"\ - ".\infutil.h"\ - ".\zconf.h"\ - ".\zlib.h"\ - ".\zutil.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\infcodes.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_INFCO=\ - ".\infblock.h"\ - ".\infcodes.h"\ - ".\inffast.h"\ - ".\inftrees.h"\ - ".\infutil.h"\ - ".\zconf.h"\ - ".\zlib.h"\ - ".\zutil.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\inffast.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_INFFA=\ - ".\infblock.h"\ - ".\infcodes.h"\ - ".\inffast.h"\ - ".\inftrees.h"\ - ".\infutil.h"\ - ".\zconf.h"\ - ".\zlib.h"\ - ".\zutil.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\inflate.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_INFLA=\ - ".\infblock.h"\ - ".\zconf.h"\ - ".\zlib.h"\ - ".\zutil.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\inftrees.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_INFTR=\ - ".\inftrees.h"\ - ".\zconf.h"\ - ".\zlib.h"\ - ".\zutil.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\infutil.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_INFUT=\ - ".\infblock.h"\ - ".\infcodes.h"\ - ".\inftrees.h"\ - ".\infutil.h"\ - ".\zconf.h"\ - ".\zlib.h"\ - ".\zutil.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\trees.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_TREES=\ - ".\deflate.h"\ - ".\zconf.h"\ - ".\zlib.h"\ - ".\zutil.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\uncompr.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_UNCOM=\ - ".\zconf.h"\ - ".\zlib.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\unzip.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\zip.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\zlib.rc -# End Source File -# Begin Source File - -SOURCE=.\zlibvc.def -# End Source File -# Begin Source File - -SOURCE=.\zutil.c - -!IF "$(CFG)" == "zlibvc - Win32 Release" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" - -DEP_CPP_ZUTIL=\ - ".\zconf.h"\ - ".\zlib.h"\ - ".\zutil.h"\ - - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" - -!ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" - -!ENDIF - -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd" -# Begin Source File - -SOURCE=.\deflate.h -# End Source File -# Begin Source File - -SOURCE=.\infblock.h -# End Source File -# Begin Source File - -SOURCE=.\infcodes.h -# End Source File -# Begin Source File - -SOURCE=.\inffast.h -# End Source File -# Begin Source File - -SOURCE=.\inftrees.h -# End Source File -# Begin Source File - -SOURCE=.\infutil.h -# End Source File -# Begin Source File - -SOURCE=.\zconf.h -# End Source File -# Begin Source File - -SOURCE=.\zlib.h -# End Source File -# Begin Source File - -SOURCE=.\zutil.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" -# End Group -# End Target -# End Project diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zlibvc.dsw b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zlibvc.dsw deleted file mode 100644 index 493cd870365..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/minizip/zlibvc.dsw +++ /dev/null @@ -1,41 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 5.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "zlibstat"=.\zlibstat.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "zlibvc"=.\zlibvc.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/untgz/makefile.w32 b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/untgz/makefile.w32 deleted file mode 100644 index c99dc28cf55..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/untgz/makefile.w32 +++ /dev/null @@ -1,63 +0,0 @@ -# Makefile for zlib. Modified for mingw32 -# For conditions of distribution and use, see copyright notice in zlib.h - -# To compile, -# -# make -fmakefile.w32 -# - -CC=gcc - -# Generate dependencies (see end of the file) - -CPPFLAGS=-MMD - -#CFLAGS=-MMD -O -#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 -#CFLAGS=-MMD -g -DDEBUG -CFLAGS=-O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ - -Wstrict-prototypes -Wmissing-prototypes - -# If cp.exe is not found, replace with copy /Y . -CP=cp -f - -# The default value of RM is "rm -f." -# If "rm.exe" is not found, uncomment: -# RM=del - -LD=gcc -LDLIBS=-L. -lz -LDFLAGS=-s - - -INCL=zlib.h zconf.h -LIBS=libz.a - -AR=ar rcs - -OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ - zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o \ - inffast.o - -TEST_OBJS = minigzip.o untgz.o - -all: minigzip.exe untgz.exe - -rebuild: clean all - -libz.a: $(OBJS) - $(AR) $@ $(OBJS) - -%.exe : %.o $(LIBS) - $(LD) $(LDFLAGS) -o $@ $< $(LDLIBS) - -.PHONY : clean - -clean: - $(RM) *.d *.o *.exe libz.a foo.gz - -DEPS := $(wildcard *.d) -ifneq ($(DEPS),) -include $(DEPS) -endif - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/untgz/untgz.c b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/untgz/untgz.c deleted file mode 100644 index 4a431ff3163..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/untgz/untgz.c +++ /dev/null @@ -1,522 +0,0 @@ -/* - * untgz.c -- Display contents and/or extract file from - * a gzip'd TAR file - * written by "Pedro A. Aranda Guti\irrez" - * adaptation to Unix by Jean-loup Gailly - */ - -#include -#include -#include -#include -#include -#include -#ifdef unix -# include -#else -# include -# include -#endif - -#include "zlib.h" - -#ifdef WIN32 -# ifndef F_OK -# define F_OK (0) -# endif -# ifdef _MSC_VER -# define mkdir(dirname,mode) _mkdir(dirname) -# define strdup(str) _strdup(str) -# define unlink(fn) _unlink(fn) -# define access(path,mode) _access(path,mode) -# else -# define mkdir(dirname,mode) _mkdir(dirname) -# endif -#else -# include -#endif - - -/* Values used in typeflag field. */ - -#define REGTYPE '0' /* regular file */ -#define AREGTYPE '\0' /* regular file */ -#define LNKTYPE '1' /* link */ -#define SYMTYPE '2' /* reserved */ -#define CHRTYPE '3' /* character special */ -#define BLKTYPE '4' /* block special */ -#define DIRTYPE '5' /* directory */ -#define FIFOTYPE '6' /* FIFO special */ -#define CONTTYPE '7' /* reserved */ - -#define BLOCKSIZE 512 - -struct tar_header -{ /* byte offset */ - char name[100]; /* 0 */ - char mode[8]; /* 100 */ - char uid[8]; /* 108 */ - char gid[8]; /* 116 */ - char size[12]; /* 124 */ - char mtime[12]; /* 136 */ - char chksum[8]; /* 148 */ - char typeflag; /* 156 */ - char linkname[100]; /* 157 */ - char magic[6]; /* 257 */ - char version[2]; /* 263 */ - char uname[32]; /* 265 */ - char gname[32]; /* 297 */ - char devmajor[8]; /* 329 */ - char devminor[8]; /* 337 */ - char prefix[155]; /* 345 */ - /* 500 */ -}; - -union tar_buffer { - char buffer[BLOCKSIZE]; - struct tar_header header; -}; - -enum { TGZ_EXTRACT = 0, TGZ_LIST }; - -static char *TGZfname OF((const char *)); -void TGZnotfound OF((const char *)); - -int getoct OF((char *, int)); -char *strtime OF((time_t *)); -int ExprMatch OF((char *,char *)); - -int makedir OF((char *)); -int matchname OF((int,int,char **,char *)); - -void error OF((const char *)); -int tar OF((gzFile, int, int, int, char **)); - -void help OF((int)); -int main OF((int, char **)); - -char *prog; - -/* This will give a benign warning */ - -static char *TGZprefix[] = { "\0", ".tgz", ".tar.gz", ".tar", NULL }; - -/* Return the real name of the TGZ archive */ -/* or NULL if it does not exist. */ - -static char *TGZfname OF((const char *fname)) -{ - static char buffer[1024]; - int origlen,i; - - strcpy(buffer,fname); - origlen = strlen(buffer); - - for (i=0; TGZprefix[i]; i++) - { - strcpy(buffer+origlen,TGZprefix[i]); - if (access(buffer,F_OK) == 0) - return buffer; - } - return NULL; -} - -/* error message for the filename */ - -void TGZnotfound OF((const char *fname)) -{ - int i; - - fprintf(stderr,"%s : couldn't find ",prog); - for (i=0;TGZprefix[i];i++) - fprintf(stderr,(TGZprefix[i+1]) ? "%s%s, " : "or %s%s\n", - fname, - TGZprefix[i]); - exit(1); -} - - -/* help functions */ - -int getoct(char *p,int width) -{ - int result = 0; - char c; - - while (width --) - { - c = *p++; - if (c == ' ') - continue; - if (c == 0) - break; - result = result * 8 + (c - '0'); - } - return result; -} - -char *strtime (time_t *t) -{ - struct tm *local; - static char result[32]; - - local = localtime(t); - sprintf(result,"%2d/%02d/%4d %02d:%02d:%02d", - local->tm_mday, local->tm_mon+1, local->tm_year+1900, - local->tm_hour, local->tm_min, local->tm_sec); - return result; -} - - -/* regular expression matching */ - -#define ISSPECIAL(c) (((c) == '*') || ((c) == '/')) - -int ExprMatch(char *string,char *expr) -{ - while (1) - { - if (ISSPECIAL(*expr)) - { - if (*expr == '/') - { - if (*string != '\\' && *string != '/') - return 0; - string ++; expr++; - } - else if (*expr == '*') - { - if (*expr ++ == 0) - return 1; - while (*++string != *expr) - if (*string == 0) - return 0; - } - } - else - { - if (*string != *expr) - return 0; - if (*expr++ == 0) - return 1; - string++; - } - } -} - -/* recursive make directory */ -/* abort if you get an ENOENT errno somewhere in the middle */ -/* e.g. ignore error "mkdir on existing directory" */ -/* */ -/* return 1 if OK */ -/* 0 on error */ - -int makedir (char *newdir) -{ - char *buffer = strdup(newdir); - char *p; - int len = strlen(buffer); - - if (len <= 0) { - free(buffer); - return 0; - } - if (buffer[len-1] == '/') { - buffer[len-1] = '\0'; - } - if (mkdir(buffer, 0775) == 0) - { - free(buffer); - return 1; - } - - p = buffer+1; - while (1) - { - char hold; - - while(*p && *p != '\\' && *p != '/') - p++; - hold = *p; - *p = 0; - if ((mkdir(buffer, 0775) == -1) && (errno == ENOENT)) - { - fprintf(stderr,"%s: couldn't create directory %s\n",prog,buffer); - free(buffer); - return 0; - } - if (hold == 0) - break; - *p++ = hold; - } - free(buffer); - return 1; -} - -int matchname (int arg,int argc,char **argv,char *fname) -{ - if (arg == argc) /* no arguments given (untgz tgzarchive) */ - return 1; - - while (arg < argc) - if (ExprMatch(fname,argv[arg++])) - return 1; - - return 0; /* ignore this for the moment being */ -} - - -/* Tar file list or extract */ - -int tar (gzFile in,int action,int arg,int argc,char **argv) -{ - union tar_buffer buffer; - int len; - int err; - int getheader = 1; - int remaining = 0; - FILE *outfile = NULL; - char fname[BLOCKSIZE]; - time_t tartime; - - if (action == TGZ_LIST) - printf(" day time size file\n" - " ---------- -------- --------- -------------------------------------\n"); - while (1) - { - len = gzread(in, &buffer, BLOCKSIZE); - if (len < 0) - error (gzerror(in, &err)); - /* - * Always expect complete blocks to process - * the tar information. - */ - if (len != BLOCKSIZE) - error("gzread: incomplete block read"); - - /* - * If we have to get a tar header - */ - if (getheader == 1) - { - /* - * if we met the end of the tar - * or the end-of-tar block, - * we are done - */ - if ((len == 0) || (buffer.header.name[0]== 0)) break; - - tartime = (time_t)getoct(buffer.header.mtime,12); - strcpy(fname,buffer.header.name); - - switch (buffer.header.typeflag) - { - case DIRTYPE: - if (action == TGZ_LIST) - printf(" %s %s\n",strtime(&tartime),fname); - if (action == TGZ_EXTRACT) - makedir(fname); - break; - case REGTYPE: - case AREGTYPE: - remaining = getoct(buffer.header.size,12); - if (action == TGZ_LIST) - printf(" %s %9d %s\n",strtime(&tartime),remaining,fname); - if (action == TGZ_EXTRACT) - { - if ((remaining) && (matchname(arg,argc,argv,fname))) - { - outfile = fopen(fname,"wb"); - if (outfile == NULL) { - /* try creating directory */ - char *p = strrchr(fname, '/'); - if (p != NULL) { - *p = '\0'; - makedir(fname); - *p = '/'; - outfile = fopen(fname,"wb"); - } - } - fprintf(stderr, - "%s %s\n", - (outfile) ? "Extracting" : "Couldn't create", - fname); - } - else - outfile = NULL; - } - /* - * could have no contents - */ - getheader = (remaining) ? 0 : 1; - break; - default: - if (action == TGZ_LIST) - printf(" %s <---> %s\n",strtime(&tartime),fname); - break; - } - } - else - { - unsigned int bytes = (remaining > BLOCKSIZE) ? BLOCKSIZE : remaining; - - if ((action == TGZ_EXTRACT) && (outfile != NULL)) - { - if (fwrite(&buffer,sizeof(char),bytes,outfile) != bytes) - { - fprintf(stderr,"%s : error writing %s skipping...\n",prog,fname); - fclose(outfile); - unlink(fname); - } - } - remaining -= bytes; - if (remaining == 0) - { - getheader = 1; - if ((action == TGZ_EXTRACT) && (outfile != NULL)) - { -#ifdef WIN32 - HANDLE hFile; - FILETIME ftm,ftLocal; - SYSTEMTIME st; - struct tm localt; - - fclose(outfile); - - localt = *localtime(&tartime); - - hFile = CreateFile(fname, GENERIC_READ | GENERIC_WRITE, - 0, NULL, OPEN_EXISTING, 0, NULL); - - st.wYear = (WORD)localt.tm_year+1900; - st.wMonth = (WORD)localt.tm_mon; - st.wDayOfWeek = (WORD)localt.tm_wday; - st.wDay = (WORD)localt.tm_mday; - st.wHour = (WORD)localt.tm_hour; - st.wMinute = (WORD)localt.tm_min; - st.wSecond = (WORD)localt.tm_sec; - st.wMilliseconds = 0; - SystemTimeToFileTime(&st,&ftLocal); - LocalFileTimeToFileTime(&ftLocal,&ftm); - SetFileTime(hFile,&ftm,NULL,&ftm); - CloseHandle(hFile); - - outfile = NULL; -#else - struct utimbuf settime; - - settime.actime = settime.modtime = tartime; - - fclose(outfile); - outfile = NULL; - utime(fname,&settime); -#endif - } - } - } - } - - if (gzclose(in) != Z_OK) - error("failed gzclose"); - - return 0; -} - - -/* =========================================================== */ - -void help(int exitval) -{ - fprintf(stderr, - "untgz v 0.1\n" - " an sample application of zlib 1.0.4\n\n" - "Usage : untgz TGZfile to extract all files\n" - " untgz TGZfile fname ... to extract selected files\n" - " untgz -l TGZfile to list archive contents\n" - " untgz -h to display this help\n\n"); - exit(exitval); -} - -void error(const char *msg) -{ - fprintf(stderr, "%s: %s\n", prog, msg); - exit(1); -} - - -/* ====================================================================== */ - -int _CRT_glob = 0; /* disable globbing of the arguments */ - -int main(int argc,char **argv) -{ - int action = TGZ_EXTRACT; - int arg = 1; - char *TGZfile; - gzFile *f; - - - prog = strrchr(argv[0],'\\'); - if (prog == NULL) - { - prog = strrchr(argv[0],'/'); - if (prog == NULL) - { - prog = strrchr(argv[0],':'); - if (prog == NULL) - prog = argv[0]; - else - prog++; - } - else - prog++; - } - else - prog++; - - if (argc == 1) - help(0); - - if (strcmp(argv[arg],"-l") == 0) - { - action = TGZ_LIST; - if (argc == ++arg) - help(0); - } - else if (strcmp(argv[arg],"-h") == 0) - { - help(0); - } - - if ((TGZfile = TGZfname(argv[arg])) == NULL) - TGZnotfound(argv[arg]); - - ++arg; - if ((action == TGZ_LIST) && (arg != argc)) - help(1); - -/* - * Process the TGZ file - */ - switch(action) - { - case TGZ_LIST: - case TGZ_EXTRACT: - f = gzopen(TGZfile,"rb"); - if (f == NULL) - { - fprintf(stderr,"%s: Couldn't gzopen %s\n", - prog, - TGZfile); - return 1; - } - exit(tar(f, action, arg, argc, argv)); - break; - - default: - error("Unknown option!"); - exit(1); - } - - return 0; -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/visual-basic.txt b/contrib/vmap_extractor_v2/stormlib/zlib/contrib/visual-basic.txt deleted file mode 100644 index 10fb44bc593..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/contrib/visual-basic.txt +++ /dev/null @@ -1,69 +0,0 @@ -See below some functions declarations for Visual Basic. - -Frequently Asked Question: - -Q: Each time I use the compress function I get the -5 error (not enough - room in the output buffer). - -A: Make sure that the length of the compressed buffer is passed by - reference ("as any"), not by value ("as long"). Also check that - before the call of compress this length is equal to the total size of - the compressed buffer and not zero. - - -From: "Jon Caruana" -Subject: Re: How to port zlib declares to vb? -Date: Mon, 28 Oct 1996 18:33:03 -0600 - -Got the answer! (I haven't had time to check this but it's what I got, and -looks correct): - -He has the following routines working: - compress - uncompress - gzopen - gzwrite - gzread - gzclose - -Declares follow: (Quoted from Carlos Rios , in Vb4 form) - -#If Win16 Then 'Use Win16 calls. -Declare Function compress Lib "ZLIB.DLL" (ByVal compr As - String, comprLen As Any, ByVal buf As String, ByVal buflen - As Long) As Integer -Declare Function uncompress Lib "ZLIB.DLL" (ByVal uncompr - As String, uncomprLen As Any, ByVal compr As String, ByVal - lcompr As Long) As Integer -Declare Function gzopen Lib "ZLIB.DLL" (ByVal filePath As - String, ByVal mode As String) As Long -Declare Function gzread Lib "ZLIB.DLL" (ByVal file As - Long, ByVal uncompr As String, ByVal uncomprLen As Integer) - As Integer -Declare Function gzwrite Lib "ZLIB.DLL" (ByVal file As - Long, ByVal uncompr As String, ByVal uncomprLen As Integer) - As Integer -Declare Function gzclose Lib "ZLIB.DLL" (ByVal file As - Long) As Integer -#Else -Declare Function compress Lib "ZLIB32.DLL" - (ByVal compr As String, comprLen As Any, ByVal buf As - String, ByVal buflen As Long) As Integer -Declare Function uncompress Lib "ZLIB32.DLL" - (ByVal uncompr As String, uncomprLen As Any, ByVal compr As - String, ByVal lcompr As Long) As Long -Declare Function gzopen Lib "ZLIB32.DLL" - (ByVal file As String, ByVal mode As String) As Long -Declare Function gzread Lib "ZLIB32.DLL" - (ByVal file As Long, ByVal uncompr As String, ByVal - uncomprLen As Long) As Long -Declare Function gzwrite Lib "ZLIB32.DLL" - (ByVal file As Long, ByVal uncompr As String, ByVal - uncomprLen As Long) As Long -Declare Function gzclose Lib "ZLIB32.DLL" - (ByVal file As Long) As Long -#End If - --Jon Caruana -jon-net@usa.net -Microsoft Sitebuilder Network Level 1 Member - HTML Writer's Guild Member diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/crc32.c b/contrib/vmap_extractor_v2/stormlib/zlib/crc32.c deleted file mode 100644 index 60deca2ddf4..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/crc32.c +++ /dev/null @@ -1,162 +0,0 @@ -/* crc32.c -- compute the CRC-32 of a data stream - * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#include "zlib.h" - -#define local static - -#ifdef DYNAMIC_CRC_TABLE - -local int crc_table_empty = 1; -local uLongf crc_table[256]; -local void make_crc_table OF((void)); - -/* - Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: - x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. - - Polynomials over GF(2) are represented in binary, one bit per coefficient, - with the lowest powers in the most significant bit. Then adding polynomials - is just exclusive-or, and multiplying a polynomial by x is a right shift by - one. If we call the above polynomial p, and represent a byte as the - polynomial q, also with the lowest power in the most significant bit (so the - byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, - where a mod b means the remainder after dividing a by b. - - This calculation is done using the shift-register method of multiplying and - taking the remainder. The register is initialized to zero, and for each - incoming bit, x^32 is added mod p to the register if the bit is a one (where - x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by - x (which is shifting right by one and adding x^32 mod p if the bit shifted - out is a one). We start with the highest power (least significant bit) of - q and repeat for all eight bits of q. - - The table is simply the CRC of all possible eight bit values. This is all - the information needed to generate CRC's on data a byte at a time for all - combinations of CRC register values and incoming bytes. -*/ -local void make_crc_table() -{ - uLong c; - int n, k; - uLong poly; /* polynomial exclusive-or pattern */ - /* terms of polynomial defining this crc (except x^32): */ - static const Byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; - - /* make exclusive-or pattern from polynomial (0xedb88320L) */ - poly = 0L; - for (n = 0; n < sizeof(p)/sizeof(Byte); n++) - poly |= 1L << (31 - p[n]); - - for (n = 0; n < 256; n++) - { - c = (uLong)n; - for (k = 0; k < 8; k++) - c = c & 1 ? poly ^ (c >> 1) : c >> 1; - crc_table[n] = c; - } - crc_table_empty = 0; -} -#else -/* ======================================================================== - * Table of CRC-32's of all single-byte values (made by make_crc_table) - */ -local const uLongf 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 -}; -#endif - -/* ========================================================================= - * This function can be used by asm versions of crc32() - */ -const uLongf * ZEXPORT get_crc_table() -{ -#ifdef DYNAMIC_CRC_TABLE - if (crc_table_empty) make_crc_table(); -#endif - return (const uLongf *)crc_table; -} - -/* ========================================================================= */ -#define DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8); -#define DO2(buf) DO1(buf); DO1(buf); -#define DO4(buf) DO2(buf); DO2(buf); -#define DO8(buf) DO4(buf); DO4(buf); - -/* ========================================================================= */ -uLong ZEXPORT crc32(crc, buf, len) - uLong crc; - const Bytef *buf; - uInt len; -{ - if (buf == Z_NULL) return 0L; -#ifdef DYNAMIC_CRC_TABLE - if (crc_table_empty) - make_crc_table(); -#endif - crc = crc ^ 0xffffffffL; - while (len >= 8) - { - DO8(buf); - len -= 8; - } - if (len) do { - DO1(buf); - } while (--len); - return crc ^ 0xffffffffL; -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/deflate.c b/contrib/vmap_extractor_v2/stormlib/zlib/deflate.c deleted file mode 100644 index 16ebdade3f1..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/deflate.c +++ /dev/null @@ -1,1350 +0,0 @@ -/* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-2002 Jean-loup Gailly. - * 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 ftp://ds.internic.net/rfc/rfc1951.txt - * - * 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.1.4 Copyright 1995-2002 Jean-loup Gailly "; -/* - 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)); -local block_state deflate_slow 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 */ - -#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. - */ - -/* 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; - -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}, /* maximum 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}}; /* maximum compression */ - -/* 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 */ - -struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ - -/* =========================================================================== - * 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)<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)]), \ - s->prev[(str) & s->w_mask] = match_head = 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 deflateInit_(strm, level, version, stream_size) - 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_(strm, level, method, windowBits, memLevel, strategy, - version, stream_size) - z_streamp strm; - int level; - int method; - int windowBits; - int memLevel; - int strategy; - const char *version; - int stream_size; -{ - deflate_state *s; - int noheader = 0; - 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 == Z_NULL) { - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; - } - if (strm->zfree == Z_NULL) strm->zfree = zcfree; - - if (level == Z_DEFAULT_COMPRESSION) level = 6; -#ifdef FASTEST - level = 1; -#endif - - if (windowBits < 0) { /* undocumented feature: suppress zlib header */ - noheader = 1; - windowBits = -windowBits; - } - if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || - windowBits < 9 || windowBits > 15 || level < 0 || level > 9 || - strategy < 0 || strategy > Z_HUFFMAN_ONLY) { - return Z_STREAM_ERROR; - } - s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); - if (s == Z_NULL) return Z_MEM_ERROR; - strm->state = (struct internal_state FAR *)s; - s->strm = strm; - - s->noheader = noheader; - 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->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) { - strm->msg = (char*)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 (strm, dictionary, dictLength) - z_streamp strm; - const Bytef *dictionary; - uInt dictLength; -{ - deflate_state *s; - uInt length = dictLength; - uInt n; - IPos hash_head = 0; - - if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL || - strm->state->status != INIT_STATE) return Z_STREAM_ERROR; - - s = strm->state; - strm->adler = adler32(strm->adler, dictionary, dictLength); - - if (length < MIN_MATCH) return Z_OK; - if (length > MAX_DIST(s)) { - length = MAX_DIST(s); -#ifndef USE_DICT_HEAD - dictionary += dictLength - length; /* use the tail of the dictionary */ -#endif - } - zmemcpy(s->window, dictionary, length); - s->strstart = length; - s->block_start = (long)length; - - /* Insert all strings in the hash table (except for the last two bytes). - * s->lookahead stays null, so s->ins_h will be recomputed at the next - * call of fill_window. - */ - s->ins_h = s->window[0]; - UPDATE_HASH(s, s->ins_h, s->window[1]); - for (n = 0; n <= length - MIN_MATCH; n++) { - INSERT_STRING(s, n, hash_head); - } - if (hash_head) hash_head = 0; /* to make compiler happy */ - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateReset (strm) - 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->noheader < 0) { - s->noheader = 0; /* was set to -1 by deflate(..., Z_FINISH); */ - } - s->status = s->noheader ? BUSY_STATE : INIT_STATE; - strm->adler = 1; - s->last_flush = Z_NO_FLUSH; - - _tr_init(s); - lm_init(s); - - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateParams(strm, level, strategy) - 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 = strm->state; - - if (level == Z_DEFAULT_COMPRESSION) { - level = 6; - } - if (level < 0 || level > 9 || strategy < 0 || strategy > Z_HUFFMAN_ONLY) { - return Z_STREAM_ERROR; - } - func = configuration_table[s->level].func; - - if (func != configuration_table[level].func && strm->total_in != 0) { - /* Flush the last buffer: */ - err = deflate(strm, Z_PARTIAL_FLUSH); - } - 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; -} - -/* ========================================================================= - * 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 (s, b) - 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(strm) - z_streamp strm; -{ - unsigned len = strm->state->pending; - - if (len > strm->avail_out) len = strm->avail_out; - if (len == 0) return; - - zmemcpy(strm->next_out, strm->state->pending_out, len); - strm->next_out += len; - strm->state->pending_out += len; - strm->total_out += len; - strm->avail_out -= len; - strm->state->pending -= len; - if (strm->state->pending == 0) { - strm->state->pending_out = strm->state->pending_buf; - } -} - -/* ========================================================================= */ -int ZEXPORT deflate (strm, flush) - 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_FINISH || flush < 0) { - return Z_STREAM_ERROR; - } - s = 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 zlib header */ - if (s->status == INIT_STATE) { - - uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; - uInt level_flags = (s->level-1) >> 1; - - if (level_flags > 3) 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 = 1L; - } - - /* 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_BUFF_ERROR. - */ - } else if (strm->avail_in == 0 && flush <= 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 = (*(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 { /* 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 */ - } - } - 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->noheader) return Z_STREAM_END; - - /* Write the zlib trailer (adler32) */ - 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. - */ - s->noheader = -1; /* write the trailer only once! */ - return s->pending != 0 ? Z_OK : Z_STREAM_END; -} - -/* ========================================================================= */ -int ZEXPORT deflateEnd (strm) - z_streamp strm; -{ - int status; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - - status = strm->state->status; - if (status != INIT_STATE && status != BUSY_STATE && - status != FINISH_STATE) { - return Z_STREAM_ERROR; - } - - /* Deallocate in reverse order of allocations: */ - TRY_FREE(strm, strm->state->pending_buf); - TRY_FREE(strm, strm->state->head); - TRY_FREE(strm, strm->state->prev); - TRY_FREE(strm, strm->state->window); - - ZFREE(strm, strm->state); - strm->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 (dest, source) - 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 = source->state; - - *dest = *source; - - ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); - if (ds == Z_NULL) return Z_MEM_ERROR; - dest->state = (struct internal_state FAR *) ds; - *ds = *ss; - 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(ds->prev, ss->prev, ds->w_size * sizeof(Pos)); - zmemcpy(ds->head, 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 -} - -/* =========================================================================== - * 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(strm, buf, size) - z_streamp strm; - Bytef *buf; - unsigned size; -{ - unsigned len = strm->avail_in; - - if (len > size) len = size; - if (len == 0) return 0; - - strm->avail_in -= len; - - if (!strm->state->noheader) { - strm->adler = adler32(strm->adler, strm->next_in, len); - } - zmemcpy(buf, strm->next_in, len); - 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 (s) - 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->match_length = s->prev_length = MIN_MATCH-1; - s->match_available = 0; - s->ins_h = 0; -#ifdef ASMV - match_init(); /* initialize the asm code */ -#endif -} - -/* =========================================================================== - * 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. - */ -#ifndef FASTEST -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current 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: - */ -#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; -} - -#else /* FASTEST */ -/* --------------------------------------------------------------------------- - * Optimized version for level == 1 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 len <= s->lookahead ? len : s->lookahead; -} -#endif /* FASTEST */ -#endif /* ASMV */ - -#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 - -/* =========================================================================== - * 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(s) - 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; - - do { - more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); - - /* Deal with !@#$% 64K limit: */ - 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 - * and lookahead == 1 (input done one 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. - */ - } else 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) return; - - /* 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 >= MIN_MATCH) { - 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 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); -} - -/* =========================================================================== - * 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, eof) { \ - _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), \ - (eof)); \ - s->block_start = s->strstart; \ - flush_pending(s->strm); \ - Tracev((stderr,"[FLUSH]")); \ -} - -/* Same but force premature exit if necessary. */ -#define FLUSH_BLOCK(s, eof) { \ - FLUSH_BLOCK_ONLY(s, eof); \ - if (s->strm->avail_out == 0) return (eof) ? 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(s, flush) - 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); - } - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : 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(s, flush) - deflate_state *s; - int flush; -{ - IPos hash_head = NIL; /* 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: - */ - 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). - */ - if (s->strategy != Z_HUFFMAN_ONLY) { - 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 hash 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); - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} - -/* =========================================================================== - * 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(s, flush) - deflate_state *s; - int flush; -{ - IPos hash_head = NIL; /* 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: - */ - 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). - */ - if (s->strategy != Z_HUFFMAN_ONLY) { - s->match_length = longest_match (s, hash_head); - } - /* longest_match() sets match_start */ - - if (s->match_length <= 5 && (s->strategy == Z_FILTERED || - (s->match_length == MIN_MATCH && - s->strstart - s->match_start > TOO_FAR))) { - - /* 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; - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/deflate.h b/contrib/vmap_extractor_v2/stormlib/zlib/deflate.h deleted file mode 100644 index b99a48a5214..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/deflate.h +++ /dev/null @@ -1,318 +0,0 @@ -/* deflate.h -- internal compression state - * Copyright (C) 1995-2002 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" - -/* =========================================================================== - * 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 INIT_STATE 42 -#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 { - 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 */ - int pending; /* nb of bytes in the pending buffer */ - int noheader; /* suppress zlib header and adler32 */ - Byte data_type; /* UNKNOWN, BINARY or ASCII */ - Byte method; /* STORED (for zip only) or 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 supress 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 */ - int last_eob_len; /* bit length of EOB code for last block */ - -#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. - */ - -} FAR 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. - */ - - /* in trees.c */ -void _tr_init OF((deflate_state *s)); -int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); -void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, - int eof)); -void _tr_align OF((deflate_state *s)); -void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, - int eof)); - -#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 _length_code[]; - extern uch _dist_code[]; -#else - extern const uch _length_code[]; - extern const uch _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 diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/descrip.mms b/contrib/vmap_extractor_v2/stormlib/zlib/descrip.mms deleted file mode 100644 index 9d364598a27..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/descrip.mms +++ /dev/null @@ -1,48 +0,0 @@ -# descrip.mms: MMS description file for building zlib on VMS -# written by Martin P.J. Zinser - -cc_defs = -c_deb = - -.ifdef __DECC__ -pref = /prefix=all -.endif - -OBJS = adler32.obj, compress.obj, crc32.obj, gzio.obj, uncompr.obj,\ - deflate.obj, trees.obj, zutil.obj, inflate.obj, infblock.obj,\ - inftrees.obj, infcodes.obj, infutil.obj, inffast.obj - -CFLAGS= $(C_DEB) $(CC_DEFS) $(PREF) - -all : example.exe minigzip.exe - @ write sys$output " Example applications available" -libz.olb : libz.olb($(OBJS)) - @ write sys$output " libz available" - -example.exe : example.obj libz.olb - link example,libz.olb/lib - -minigzip.exe : minigzip.obj libz.olb - link minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib - -clean : - delete *.obj;*,libz.olb;* - - -# Other dependencies. -adler32.obj : zutil.h zlib.h zconf.h -compress.obj : zlib.h zconf.h -crc32.obj : zutil.h zlib.h zconf.h -deflate.obj : deflate.h zutil.h zlib.h zconf.h -example.obj : zlib.h zconf.h -gzio.obj : zutil.h zlib.h zconf.h -infblock.obj : zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h -infcodes.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h infcodes.h inffast.h -inffast.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h -inflate.obj : zutil.h zlib.h zconf.h infblock.h -inftrees.obj : zutil.h zlib.h zconf.h inftrees.h -infutil.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h -minigzip.obj : zlib.h zconf.h -trees.obj : deflate.h zutil.h zlib.h zconf.h -uncompr.obj : zlib.h zconf.h -zutil.obj : zutil.h zlib.h zconf.h diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/example.c b/contrib/vmap_extractor_v2/stormlib/zlib/example.c deleted file mode 100644 index e7e3673333e..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/example.c +++ /dev/null @@ -1,556 +0,0 @@ -/* example.c -- usage example of the zlib compression library - * Copyright (C) 1995-2002 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#include -#include "zlib.h" - -#ifdef STDC -# include -# include -#else - extern void exit OF((int)); -#endif - -#if defined(VMS) || defined(RISCOS) -# define TESTFILE "foo-gz" -#else -# define TESTFILE "foo.gz" -#endif - -#define CHECK_ERR(err, msg) { \ - if (err != Z_OK) { \ - fprintf(stderr, "%s error: %d\n", msg, err); \ - exit(1); \ - } \ -} - -const char hello[] = "hello, hello!"; -/* "hello world" would be more standard, but the repeated "hello" - * stresses the compression code better, sorry... - */ - -const char dictionary[] = "hello"; -uLong dictId; /* Adler32 value of the dictionary */ - -void test_compress OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); -void test_gzio OF((const char *out, const char *in, - Byte *uncompr, int uncomprLen)); -void test_deflate OF((Byte *compr, uLong comprLen)); -void test_inflate OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); -void test_large_deflate OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); -void test_large_inflate OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); -void test_flush OF((Byte *compr, uLong *comprLen)); -void test_sync OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); -void test_dict_deflate OF((Byte *compr, uLong comprLen)); -void test_dict_inflate OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); -int main OF((int argc, char *argv[])); - -/* =========================================================================== - * Test compress() and uncompress() - */ -void test_compress(compr, comprLen, uncompr, uncomprLen) - Byte *compr, *uncompr; - uLong comprLen, uncomprLen; -{ - int err; - uLong len = strlen(hello)+1; - - err = compress(compr, &comprLen, (const Bytef*)hello, len); - CHECK_ERR(err, "compress"); - - strcpy((char*)uncompr, "garbage"); - - err = uncompress(uncompr, &uncomprLen, compr, comprLen); - CHECK_ERR(err, "uncompress"); - - if (strcmp((char*)uncompr, hello)) { - fprintf(stderr, "bad uncompress\n"); - exit(1); - } else { - printf("uncompress(): %s\n", (char *)uncompr); - } -} - -/* =========================================================================== - * Test read/write of .gz files - */ -void test_gzio(out, in, uncompr, uncomprLen) - const char *out; /* compressed output file */ - const char *in; /* compressed input file */ - Byte *uncompr; - int uncomprLen; -{ - int err; - int len = strlen(hello)+1; - gzFile file; - z_off_t pos; - - file = gzopen(out, "wb"); - if (file == NULL) { - fprintf(stderr, "gzopen error\n"); - exit(1); - } - gzputc(file, 'h'); - if (gzputs(file, "ello") != 4) { - fprintf(stderr, "gzputs err: %s\n", gzerror(file, &err)); - exit(1); - } - if (gzprintf(file, ", %s!", "hello") != 8) { - fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err)); - exit(1); - } - gzseek(file, 1L, SEEK_CUR); /* add one zero byte */ - gzclose(file); - - file = gzopen(in, "rb"); - if (file == NULL) { - fprintf(stderr, "gzopen error\n"); - } - strcpy((char*)uncompr, "garbage"); - - uncomprLen = gzread(file, uncompr, (unsigned)uncomprLen); - if (uncomprLen != len) { - fprintf(stderr, "gzread err: %s\n", gzerror(file, &err)); - exit(1); - } - if (strcmp((char*)uncompr, hello)) { - fprintf(stderr, "bad gzread: %s\n", (char*)uncompr); - exit(1); - } else { - printf("gzread(): %s\n", (char *)uncompr); - } - - pos = gzseek(file, -8L, SEEK_CUR); - if (pos != 6 || gztell(file) != pos) { - fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n", - (long)pos, (long)gztell(file)); - exit(1); - } - - if (gzgetc(file) != ' ') { - fprintf(stderr, "gzgetc error\n"); - exit(1); - } - - gzgets(file, (char*)uncompr, uncomprLen); - uncomprLen = strlen((char*)uncompr); - if (uncomprLen != 6) { /* "hello!" */ - fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err)); - exit(1); - } - if (strcmp((char*)uncompr, hello+7)) { - fprintf(stderr, "bad gzgets after gzseek\n"); - exit(1); - } else { - printf("gzgets() after gzseek: %s\n", (char *)uncompr); - } - - gzclose(file); -} - -/* =========================================================================== - * Test deflate() with small buffers - */ -void test_deflate(compr, comprLen) - Byte *compr; - uLong comprLen; -{ - z_stream c_stream; /* compression stream */ - int err; - int len = strlen(hello)+1; - - c_stream.zalloc = (alloc_func)0; - c_stream.zfree = (free_func)0; - c_stream.opaque = (voidpf)0; - - err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); - CHECK_ERR(err, "deflateInit"); - - c_stream.next_in = (Bytef*)hello; - c_stream.next_out = compr; - - while (c_stream.total_in != (uLong)len && c_stream.total_out < comprLen) { - c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ - err = deflate(&c_stream, Z_NO_FLUSH); - CHECK_ERR(err, "deflate"); - } - /* Finish the stream, still forcing small buffers: */ - for (;;) { - c_stream.avail_out = 1; - err = deflate(&c_stream, Z_FINISH); - if (err == Z_STREAM_END) break; - CHECK_ERR(err, "deflate"); - } - - err = deflateEnd(&c_stream); - CHECK_ERR(err, "deflateEnd"); -} - -/* =========================================================================== - * Test inflate() with small buffers - */ -void test_inflate(compr, comprLen, uncompr, uncomprLen) - Byte *compr, *uncompr; - uLong comprLen, uncomprLen; -{ - int err; - z_stream d_stream; /* decompression stream */ - - strcpy((char*)uncompr, "garbage"); - - d_stream.zalloc = (alloc_func)0; - d_stream.zfree = (free_func)0; - d_stream.opaque = (voidpf)0; - - d_stream.next_in = compr; - d_stream.avail_in = 0; - d_stream.next_out = uncompr; - - err = inflateInit(&d_stream); - CHECK_ERR(err, "inflateInit"); - - while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen) { - d_stream.avail_in = d_stream.avail_out = 1; /* force small buffers */ - err = inflate(&d_stream, Z_NO_FLUSH); - if (err == Z_STREAM_END) break; - CHECK_ERR(err, "inflate"); - } - - err = inflateEnd(&d_stream); - CHECK_ERR(err, "inflateEnd"); - - if (strcmp((char*)uncompr, hello)) { - fprintf(stderr, "bad inflate\n"); - exit(1); - } else { - printf("inflate(): %s\n", (char *)uncompr); - } -} - -/* =========================================================================== - * Test deflate() with large buffers and dynamic change of compression level - */ -void test_large_deflate(compr, comprLen, uncompr, uncomprLen) - Byte *compr, *uncompr; - uLong comprLen, uncomprLen; -{ - z_stream c_stream; /* compression stream */ - int err; - - c_stream.zalloc = (alloc_func)0; - c_stream.zfree = (free_func)0; - c_stream.opaque = (voidpf)0; - - err = deflateInit(&c_stream, Z_BEST_SPEED); - CHECK_ERR(err, "deflateInit"); - - c_stream.next_out = compr; - c_stream.avail_out = (uInt)comprLen; - - /* At this point, uncompr is still mostly zeroes, so it should compress - * very well: - */ - c_stream.next_in = uncompr; - c_stream.avail_in = (uInt)uncomprLen; - err = deflate(&c_stream, Z_NO_FLUSH); - CHECK_ERR(err, "deflate"); - if (c_stream.avail_in != 0) { - fprintf(stderr, "deflate not greedy\n"); - exit(1); - } - - /* Feed in already compressed data and switch to no compression: */ - deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); - c_stream.next_in = compr; - c_stream.avail_in = (uInt)comprLen/2; - err = deflate(&c_stream, Z_NO_FLUSH); - CHECK_ERR(err, "deflate"); - - /* Switch back to compressing mode: */ - deflateParams(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED); - c_stream.next_in = uncompr; - c_stream.avail_in = (uInt)uncomprLen; - err = deflate(&c_stream, Z_NO_FLUSH); - CHECK_ERR(err, "deflate"); - - err = deflate(&c_stream, Z_FINISH); - if (err != Z_STREAM_END) { - fprintf(stderr, "deflate should report Z_STREAM_END\n"); - exit(1); - } - err = deflateEnd(&c_stream); - CHECK_ERR(err, "deflateEnd"); -} - -/* =========================================================================== - * Test inflate() with large buffers - */ -void test_large_inflate(compr, comprLen, uncompr, uncomprLen) - Byte *compr, *uncompr; - uLong comprLen, uncomprLen; -{ - int err; - z_stream d_stream; /* decompression stream */ - - strcpy((char*)uncompr, "garbage"); - - d_stream.zalloc = (alloc_func)0; - d_stream.zfree = (free_func)0; - d_stream.opaque = (voidpf)0; - - d_stream.next_in = compr; - d_stream.avail_in = (uInt)comprLen; - - err = inflateInit(&d_stream); - CHECK_ERR(err, "inflateInit"); - - for (;;) { - d_stream.next_out = uncompr; /* discard the output */ - d_stream.avail_out = (uInt)uncomprLen; - err = inflate(&d_stream, Z_NO_FLUSH); - if (err == Z_STREAM_END) break; - CHECK_ERR(err, "large inflate"); - } - - err = inflateEnd(&d_stream); - CHECK_ERR(err, "inflateEnd"); - - if (d_stream.total_out != 2*uncomprLen + comprLen/2) { - fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out); - exit(1); - } else { - printf("large_inflate(): OK\n"); - } -} - -/* =========================================================================== - * Test deflate() with full flush - */ -void test_flush(compr, comprLen) - Byte *compr; - uLong *comprLen; -{ - z_stream c_stream; /* compression stream */ - int err; - int len = strlen(hello)+1; - - c_stream.zalloc = (alloc_func)0; - c_stream.zfree = (free_func)0; - c_stream.opaque = (voidpf)0; - - err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); - CHECK_ERR(err, "deflateInit"); - - c_stream.next_in = (Bytef*)hello; - c_stream.next_out = compr; - c_stream.avail_in = 3; - c_stream.avail_out = (uInt)*comprLen; - err = deflate(&c_stream, Z_FULL_FLUSH); - CHECK_ERR(err, "deflate"); - - compr[3]++; /* force an error in first compressed block */ - c_stream.avail_in = len - 3; - - err = deflate(&c_stream, Z_FINISH); - if (err != Z_STREAM_END) { - CHECK_ERR(err, "deflate"); - } - err = deflateEnd(&c_stream); - CHECK_ERR(err, "deflateEnd"); - - *comprLen = c_stream.total_out; -} - -/* =========================================================================== - * Test inflateSync() - */ -void test_sync(compr, comprLen, uncompr, uncomprLen) - Byte *compr, *uncompr; - uLong comprLen, uncomprLen; -{ - int err; - z_stream d_stream; /* decompression stream */ - - strcpy((char*)uncompr, "garbage"); - - d_stream.zalloc = (alloc_func)0; - d_stream.zfree = (free_func)0; - d_stream.opaque = (voidpf)0; - - d_stream.next_in = compr; - d_stream.avail_in = 2; /* just read the zlib header */ - - err = inflateInit(&d_stream); - CHECK_ERR(err, "inflateInit"); - - d_stream.next_out = uncompr; - d_stream.avail_out = (uInt)uncomprLen; - - inflate(&d_stream, Z_NO_FLUSH); - CHECK_ERR(err, "inflate"); - - d_stream.avail_in = (uInt)comprLen-2; /* read all compressed data */ - err = inflateSync(&d_stream); /* but skip the damaged part */ - CHECK_ERR(err, "inflateSync"); - - err = inflate(&d_stream, Z_FINISH); - if (err != Z_DATA_ERROR) { - fprintf(stderr, "inflate should report DATA_ERROR\n"); - /* Because of incorrect adler32 */ - exit(1); - } - err = inflateEnd(&d_stream); - CHECK_ERR(err, "inflateEnd"); - - printf("after inflateSync(): hel%s\n", (char *)uncompr); -} - -/* =========================================================================== - * Test deflate() with preset dictionary - */ -void test_dict_deflate(compr, comprLen) - Byte *compr; - uLong comprLen; -{ - z_stream c_stream; /* compression stream */ - int err; - - c_stream.zalloc = (alloc_func)0; - c_stream.zfree = (free_func)0; - c_stream.opaque = (voidpf)0; - - err = deflateInit(&c_stream, Z_BEST_COMPRESSION); - CHECK_ERR(err, "deflateInit"); - - err = deflateSetDictionary(&c_stream, - (const Bytef*)dictionary, sizeof(dictionary)); - CHECK_ERR(err, "deflateSetDictionary"); - - dictId = c_stream.adler; - c_stream.next_out = compr; - c_stream.avail_out = (uInt)comprLen; - - c_stream.next_in = (Bytef*)hello; - c_stream.avail_in = (uInt)strlen(hello)+1; - - err = deflate(&c_stream, Z_FINISH); - if (err != Z_STREAM_END) { - fprintf(stderr, "deflate should report Z_STREAM_END\n"); - exit(1); - } - err = deflateEnd(&c_stream); - CHECK_ERR(err, "deflateEnd"); -} - -/* =========================================================================== - * Test inflate() with a preset dictionary - */ -void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) - Byte *compr, *uncompr; - uLong comprLen, uncomprLen; -{ - int err; - z_stream d_stream; /* decompression stream */ - - strcpy((char*)uncompr, "garbage"); - - d_stream.zalloc = (alloc_func)0; - d_stream.zfree = (free_func)0; - d_stream.opaque = (voidpf)0; - - d_stream.next_in = compr; - d_stream.avail_in = (uInt)comprLen; - - err = inflateInit(&d_stream); - CHECK_ERR(err, "inflateInit"); - - d_stream.next_out = uncompr; - d_stream.avail_out = (uInt)uncomprLen; - - for (;;) { - err = inflate(&d_stream, Z_NO_FLUSH); - if (err == Z_STREAM_END) break; - if (err == Z_NEED_DICT) { - if (d_stream.adler != dictId) { - fprintf(stderr, "unexpected dictionary"); - exit(1); - } - err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary, - sizeof(dictionary)); - } - CHECK_ERR(err, "inflate with dict"); - } - - err = inflateEnd(&d_stream); - CHECK_ERR(err, "inflateEnd"); - - if (strcmp((char*)uncompr, hello)) { - fprintf(stderr, "bad inflate with dict\n"); - exit(1); - } else { - printf("inflate with dictionary: %s\n", (char *)uncompr); - } -} - -/* =========================================================================== - * Usage: example [output.gz [input.gz]] - */ - -int main(argc, argv) - int argc; - char *argv[]; -{ - Byte *compr, *uncompr; - uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ - uLong uncomprLen = comprLen; - static const char* myVersion = ZLIB_VERSION; - - if (zlibVersion()[0] != myVersion[0]) { - fprintf(stderr, "incompatible zlib version\n"); - exit(1); - - } else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) { - fprintf(stderr, "warning: different zlib version\n"); - } - - compr = (Byte*)calloc((uInt)comprLen, 1); - uncompr = (Byte*)calloc((uInt)uncomprLen, 1); - /* compr and uncompr are cleared to avoid reading uninitialized - * data and to ensure that uncompr compresses well. - */ - if (compr == Z_NULL || uncompr == Z_NULL) { - printf("out of memory\n"); - exit(1); - } - test_compress(compr, comprLen, uncompr, uncomprLen); - - test_gzio((argc > 1 ? argv[1] : TESTFILE), - (argc > 2 ? argv[2] : TESTFILE), - uncompr, (int)uncomprLen); - - test_deflate(compr, comprLen); - test_inflate(compr, comprLen, uncompr, uncomprLen); - - test_large_deflate(compr, comprLen, uncompr, uncomprLen); - test_large_inflate(compr, comprLen, uncompr, uncomprLen); - - test_flush(compr, &comprLen); - test_sync(compr, comprLen, uncompr, uncomprLen); - comprLen = uncomprLen; - - test_dict_deflate(compr, comprLen); - test_dict_inflate(compr, comprLen, uncompr, uncomprLen); - - exit(0); - return 0; /* to avoid warning */ -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/gzio.c b/contrib/vmap_extractor_v2/stormlib/zlib/gzio.c deleted file mode 100644 index 09e0a20b8ce..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/gzio.c +++ /dev/null @@ -1,875 +0,0 @@ -/* gzio.c -- IO on .gz files - * Copyright (C) 1995-2002 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - * - * Compile this file with -DNO_DEFLATE to avoid the compression code. - */ - -/* @(#) $Id$ */ - -#include - -#include "zutil.h" - -struct internal_state {int dummy;}; /* for buggy compilers */ - -#ifndef Z_BUFSIZE -# ifdef MAXSEG_64K -# define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */ -# else -# define Z_BUFSIZE 16384 -# endif -#endif -#ifndef Z_PRINTF_BUFSIZE -# define Z_PRINTF_BUFSIZE 4096 -#endif - -#define ALLOC(size) malloc(size) -#define TRYFREE(p) {if (p) free(p);} - -static int gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ - -/* gzip flag byte */ -#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ -#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */ -#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ -#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ -#define COMMENT 0x10 /* bit 4 set: file comment present */ -#define RESERVED 0xE0 /* bits 5..7: reserved */ - -typedef struct gz_stream { - z_stream stream; - int z_err; /* error code for last stream operation */ - int z_eof; /* set if end of input file */ - FILE *file; /* .gz file */ - Byte *inbuf; /* input buffer */ - Byte *outbuf; /* output buffer */ - uLong crc; /* crc32 of uncompressed data */ - char *msg; /* error message */ - char *path; /* path name for debugging only */ - int transparent; /* 1 if input file is not a .gz file */ - char mode; /* 'w' or 'r' */ - long startpos; /* start of compressed data in file (header skipped) */ -} gz_stream; - - -local gzFile gz_open OF((const char *path, const char *mode, int fd)); -local int do_flush OF((gzFile file, int flush)); -local int get_byte OF((gz_stream *s)); -local void check_header OF((gz_stream *s)); -local int destroy OF((gz_stream *s)); -local void putLong OF((FILE *file, uLong x)); -local uLong getLong OF((gz_stream *s)); - -/* =========================================================================== - Opens a gzip (.gz) file for reading or writing. The mode parameter - is as in fopen ("rb" or "wb"). The file is given either by file descriptor - or path name (if fd == -1). - gz_open return NULL if the file could not be opened or if there was - insufficient memory to allocate the (de)compression state; errno - can be checked to distinguish the two cases (if errno is zero, the - zlib error is Z_MEM_ERROR). -*/ -local gzFile gz_open (path, mode, fd) - const char *path; - const char *mode; - int fd; -{ - int err; - int level = Z_DEFAULT_COMPRESSION; /* compression level */ - int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */ - char *p = (char*)mode; - gz_stream *s; - char fmode[80]; /* copy of mode, without the compression level */ - char *m = fmode; - - if (!path || !mode) return Z_NULL; - - s = (gz_stream *)ALLOC(sizeof(gz_stream)); - if (!s) return Z_NULL; - - s->stream.zalloc = (alloc_func)0; - s->stream.zfree = (free_func)0; - s->stream.opaque = (voidpf)0; - s->stream.next_in = s->inbuf = Z_NULL; - s->stream.next_out = s->outbuf = Z_NULL; - s->stream.avail_in = s->stream.avail_out = 0; - s->file = NULL; - s->z_err = Z_OK; - s->z_eof = 0; - s->crc = crc32(0L, Z_NULL, 0); - s->msg = NULL; - s->transparent = 0; - - s->path = (char*)ALLOC(strlen(path)+1); - if (s->path == NULL) { - return destroy(s), (gzFile)Z_NULL; - } - strcpy(s->path, path); /* do this early for debugging */ - - s->mode = '\0'; - do { - if (*p == 'r') s->mode = 'r'; - if (*p == 'w' || *p == 'a') s->mode = 'w'; - if (*p >= '0' && *p <= '9') { - level = *p - '0'; - } else if (*p == 'f') { - strategy = Z_FILTERED; - } else if (*p == 'h') { - strategy = Z_HUFFMAN_ONLY; - } else { - *m++ = *p; /* copy the mode */ - } - } while (*p++ && m != fmode + sizeof(fmode)); - if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL; - - if (s->mode == 'w') { -#ifdef NO_DEFLATE - err = Z_STREAM_ERROR; -#else - err = deflateInit2(&(s->stream), level, - Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy); - /* windowBits is passed < 0 to suppress zlib header */ - - s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); -#endif - if (err != Z_OK || s->outbuf == Z_NULL) { - return destroy(s), (gzFile)Z_NULL; - } - } else { - s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); - - err = inflateInit2(&(s->stream), -MAX_WBITS); - /* 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. Here the gzip CRC32 ensures that 4 bytes are - * present after the compressed stream. - */ - if (err != Z_OK || s->inbuf == Z_NULL) { - return destroy(s), (gzFile)Z_NULL; - } - } - s->stream.avail_out = Z_BUFSIZE; - - errno = 0; - s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode); - - if (s->file == NULL) { - return destroy(s), (gzFile)Z_NULL; - } - if (s->mode == 'w') { - /* Write a very simple .gz header: - */ - fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1], - Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE); - s->startpos = 10L; - /* We use 10L instead of ftell(s->file) to because ftell causes an - * fflush on some systems. This version of the library doesn't use - * startpos anyway in write mode, so this initialization is not - * necessary. - */ - } else { - check_header(s); /* skip the .gz header */ - s->startpos = (ftell(s->file) - s->stream.avail_in); - } - - return (gzFile)s; -} - -/* =========================================================================== - Opens a gzip (.gz) file for reading or writing. -*/ -gzFile ZEXPORT gzopen (path, mode) - const char *path; - const char *mode; -{ - return gz_open (path, mode, -1); -} - -/* =========================================================================== - Associate a gzFile with the file descriptor fd. fd is not dup'ed here - to mimic the behavio(u)r of fdopen. -*/ -gzFile ZEXPORT gzdopen (fd, mode) - int fd; - const char *mode; -{ - char name[20]; - - if (fd < 0) return (gzFile)Z_NULL; - sprintf(name, "", fd); /* for debugging */ - - return gz_open (name, mode, fd); -} - -/* =========================================================================== - * Update the compression level and strategy - */ -int ZEXPORT gzsetparams (file, level, strategy) - gzFile file; - int level; - int strategy; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; - - /* Make room to allow flushing */ - if (s->stream.avail_out == 0) { - - s->stream.next_out = s->outbuf; - if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { - s->z_err = Z_ERRNO; - } - s->stream.avail_out = Z_BUFSIZE; - } - - return deflateParams (&(s->stream), level, strategy); -} - -/* =========================================================================== - 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 get_byte(s) - gz_stream *s; -{ - if (s->z_eof) return EOF; - if (s->stream.avail_in == 0) { - errno = 0; - s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file); - if (s->stream.avail_in == 0) { - s->z_eof = 1; - if (ferror(s->file)) s->z_err = Z_ERRNO; - return EOF; - } - s->stream.next_in = s->inbuf; - } - s->stream.avail_in--; - return *(s->stream.next_in)++; -} - -/* =========================================================================== - Check the gzip header of a gz_stream opened for reading. Set the stream - mode to transparent if the gzip magic header is not present; set s->err - to Z_DATA_ERROR if the magic header is present but the rest of the header - is incorrect. - IN assertion: the stream s has already been created sucessfully; - s->stream.avail_in is zero for the first time, but may be non-zero - for concatenated .gz files. -*/ -local void check_header(s) - gz_stream *s; -{ - int method; /* method byte */ - int flags; /* flags byte */ - uInt len; - int c; - - /* Check the gzip magic header */ - for (len = 0; len < 2; len++) { - c = get_byte(s); - if (c != gz_magic[len]) { - if (len != 0) s->stream.avail_in++, s->stream.next_in--; - if (c != EOF) { - s->stream.avail_in++, s->stream.next_in--; - s->transparent = 1; - } - s->z_err = s->stream.avail_in != 0 ? Z_OK : Z_STREAM_END; - return; - } - } - method = get_byte(s); - flags = get_byte(s); - if (method != Z_DEFLATED || (flags & RESERVED) != 0) { - s->z_err = Z_DATA_ERROR; - return; - } - - /* Discard time, xflags and OS code: */ - for (len = 0; len < 6; len++) (void)get_byte(s); - - if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */ - len = (uInt)get_byte(s); - len += ((uInt)get_byte(s))<<8; - /* len is garbage if EOF but the loop below will quit anyway */ - while (len-- != 0 && get_byte(s) != EOF) ; - } - if ((flags & ORIG_NAME) != 0) { /* skip the original file name */ - while ((c = get_byte(s)) != 0 && c != EOF) ; - } - if ((flags & COMMENT) != 0) { /* skip the .gz file comment */ - while ((c = get_byte(s)) != 0 && c != EOF) ; - } - if ((flags & HEAD_CRC) != 0) { /* skip the header crc */ - for (len = 0; len < 2; len++) (void)get_byte(s); - } - s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK; -} - - /* =========================================================================== - * Cleanup then free the given gz_stream. Return a zlib error code. - Try freeing in the reverse order of allocations. - */ -local int destroy (s) - gz_stream *s; -{ - int err = Z_OK; - - if (!s) return Z_STREAM_ERROR; - - TRYFREE(s->msg); - - if (s->stream.state != NULL) { - if (s->mode == 'w') { -#ifdef NO_DEFLATE - err = Z_STREAM_ERROR; -#else - err = deflateEnd(&(s->stream)); -#endif - } else if (s->mode == 'r') { - err = inflateEnd(&(s->stream)); - } - } - if (s->file != NULL && fclose(s->file)) { -#ifdef ESPIPE - if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */ -#endif - err = Z_ERRNO; - } - if (s->z_err < 0) err = s->z_err; - - TRYFREE(s->inbuf); - TRYFREE(s->outbuf); - TRYFREE(s->path); - TRYFREE(s); - return err; -} - -/* =========================================================================== - Reads the given number of uncompressed bytes from the compressed file. - gzread returns the number of bytes actually read (0 for end of file). -*/ -int ZEXPORT gzread (file, buf, len) - gzFile file; - voidp buf; - unsigned len; -{ - gz_stream *s = (gz_stream*)file; - Bytef *start = (Bytef*)buf; /* starting point for crc computation */ - Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */ - - if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR; - - if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1; - if (s->z_err == Z_STREAM_END) return 0; /* EOF */ - - next_out = (Byte*)buf; - s->stream.next_out = (Bytef*)buf; - s->stream.avail_out = len; - - while (s->stream.avail_out != 0) { - - if (s->transparent) { - /* Copy first the lookahead bytes: */ - uInt n = s->stream.avail_in; - if (n > s->stream.avail_out) n = s->stream.avail_out; - if (n > 0) { - zmemcpy(s->stream.next_out, s->stream.next_in, n); - next_out += n; - s->stream.next_out = next_out; - s->stream.next_in += n; - s->stream.avail_out -= n; - s->stream.avail_in -= n; - } - if (s->stream.avail_out > 0) { - s->stream.avail_out -= fread(next_out, 1, s->stream.avail_out, - s->file); - } - len -= s->stream.avail_out; - s->stream.total_in += (uLong)len; - s->stream.total_out += (uLong)len; - if (len == 0) s->z_eof = 1; - return (int)len; - } - if (s->stream.avail_in == 0 && !s->z_eof) { - - errno = 0; - s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file); - if (s->stream.avail_in == 0) { - s->z_eof = 1; - if (ferror(s->file)) { - s->z_err = Z_ERRNO; - break; - } - } - s->stream.next_in = s->inbuf; - } - s->z_err = inflate(&(s->stream), Z_NO_FLUSH); - - if (s->z_err == Z_STREAM_END) { - /* Check CRC and original size */ - s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); - start = s->stream.next_out; - - if (getLong(s) != s->crc) { - s->z_err = Z_DATA_ERROR; - } else { - (void)getLong(s); - /* The uncompressed length returned by above getlong() may - * be different from s->stream.total_out) in case of - * concatenated .gz files. Check for such files: - */ - check_header(s); - if (s->z_err == Z_OK) { - uLong total_in = s->stream.total_in; - uLong total_out = s->stream.total_out; - - inflateReset(&(s->stream)); - s->stream.total_in = total_in; - s->stream.total_out = total_out; - s->crc = crc32(0L, Z_NULL, 0); - } - } - } - if (s->z_err != Z_OK || s->z_eof) break; - } - s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); - - return (int)(len - s->stream.avail_out); -} - - -/* =========================================================================== - Reads one byte from the compressed file. gzgetc returns this byte - or -1 in case of end of file or error. -*/ -int ZEXPORT gzgetc(file) - gzFile file; -{ - unsigned char c; - - return gzread(file, &c, 1) == 1 ? c : -1; -} - - -/* =========================================================================== - 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. The string is then terminated - with a null character. - gzgets returns buf, or Z_NULL in case of error. - - The current implementation is not optimized at all. -*/ -char * ZEXPORT gzgets(file, buf, len) - gzFile file; - char *buf; - int len; -{ - char *b = buf; - if (buf == Z_NULL || len <= 0) return Z_NULL; - - while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ; - *buf = '\0'; - return b == buf && len > 0 ? Z_NULL : b; -} - - -#ifndef NO_DEFLATE -/* =========================================================================== - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of bytes actually written (0 in case of error). -*/ -int ZEXPORT gzwrite (file, buf, len) - gzFile file; - const voidp buf; - unsigned len; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; - - s->stream.next_in = (Bytef*)buf; - s->stream.avail_in = len; - - while (s->stream.avail_in != 0) { - - if (s->stream.avail_out == 0) { - - s->stream.next_out = s->outbuf; - if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { - s->z_err = Z_ERRNO; - break; - } - s->stream.avail_out = Z_BUFSIZE; - } - s->z_err = deflate(&(s->stream), Z_NO_FLUSH); - if (s->z_err != Z_OK) break; - } - s->crc = crc32(s->crc, (const Bytef *)buf, len); - - return (int)(len - s->stream.avail_in); -} - -/* =========================================================================== - Converts, formats, and writes the args to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written (0 in case of error). -*/ -#ifdef STDC -#include - -int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...) -{ - char buf[Z_PRINTF_BUFSIZE]; - va_list va; - int len; - - va_start(va, format); -#ifdef HAS_vsnprintf - (void)vsnprintf(buf, sizeof(buf), format, va); -#else - (void)vsprintf(buf, format, va); -#endif - va_end(va); - len = strlen(buf); /* some *sprintf don't return the nb of bytes written */ - if (len <= 0) return 0; - - return gzwrite(file, buf, (unsigned)len); -} -#else /* not ANSI C */ - -int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) - gzFile file; - const char *format; - int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; -{ - char buf[Z_PRINTF_BUFSIZE]; - int len; - -#ifdef HAS_snprintf - snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); -#else - sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); -#endif - len = strlen(buf); /* old sprintf doesn't return the nb of bytes written */ - if (len <= 0) return 0; - - return gzwrite(file, buf, len); -} -#endif - -/* =========================================================================== - Writes c, converted to an unsigned char, into the compressed file. - gzputc returns the value that was written, or -1 in case of error. -*/ -int ZEXPORT gzputc(file, c) - gzFile file; - int c; -{ - unsigned char cc = (unsigned char) c; /* required for big endian systems */ - - return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1; -} - - -/* =========================================================================== - 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. -*/ -int ZEXPORT gzputs(file, s) - gzFile file; - const char *s; -{ - return gzwrite(file, (char*)s, (unsigned)strlen(s)); -} - - -/* =========================================================================== - Flushes all pending output into the compressed file. The parameter - flush is as in the deflate() function. -*/ -local int do_flush (file, flush) - gzFile file; - int flush; -{ - uInt len; - int done = 0; - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; - - s->stream.avail_in = 0; /* should be zero already anyway */ - - for (;;) { - len = Z_BUFSIZE - s->stream.avail_out; - - if (len != 0) { - if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) { - s->z_err = Z_ERRNO; - return Z_ERRNO; - } - s->stream.next_out = s->outbuf; - s->stream.avail_out = Z_BUFSIZE; - } - if (done) break; - s->z_err = deflate(&(s->stream), flush); - - /* Ignore the second of two consecutive flushes: */ - if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK; - - /* deflate has finished flushing only when it hasn't used up - * all the available space in the output buffer: - */ - done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END); - - if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break; - } - return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; -} - -int ZEXPORT gzflush (file, flush) - gzFile file; - int flush; -{ - gz_stream *s = (gz_stream*)file; - int err = do_flush (file, flush); - - if (err) return err; - fflush(s->file); - return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; -} -#endif /* NO_DEFLATE */ - -/* =========================================================================== - Sets the starting position for the next gzread or gzwrite on the given - compressed file. The offset represents a number of bytes in the - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error. - SEEK_END is not implemented, returns error. - In this version of the library, gzseek can be extremely slow. -*/ -z_off_t ZEXPORT gzseek (file, offset, whence) - gzFile file; - z_off_t offset; - int whence; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || whence == SEEK_END || - s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) { - return -1L; - } - - if (s->mode == 'w') { -#ifdef NO_DEFLATE - return -1L; -#else - if (whence == SEEK_SET) { - offset -= s->stream.total_in; - } - if (offset < 0) return -1L; - - /* At this point, offset is the number of zero bytes to write. */ - if (s->inbuf == Z_NULL) { - s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */ - zmemzero(s->inbuf, Z_BUFSIZE); - } - while (offset > 0) { - uInt size = Z_BUFSIZE; - if (offset < Z_BUFSIZE) size = (uInt)offset; - - size = gzwrite(file, s->inbuf, size); - if (size == 0) return -1L; - - offset -= size; - } - return (z_off_t)s->stream.total_in; -#endif - } - /* Rest of function is for reading only */ - - /* compute absolute position */ - if (whence == SEEK_CUR) { - offset += s->stream.total_out; - } - if (offset < 0) return -1L; - - if (s->transparent) { - /* map to fseek */ - s->stream.avail_in = 0; - s->stream.next_in = s->inbuf; - if (fseek(s->file, offset, SEEK_SET) < 0) return -1L; - - s->stream.total_in = s->stream.total_out = (uLong)offset; - return offset; - } - - /* For a negative seek, rewind and use positive seek */ - if ((uLong)offset >= s->stream.total_out) { - offset -= s->stream.total_out; - } else if (gzrewind(file) < 0) { - return -1L; - } - /* offset is now the number of bytes to skip. */ - - if (offset != 0 && s->outbuf == Z_NULL) { - s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); - } - while (offset > 0) { - int size = Z_BUFSIZE; - if (offset < Z_BUFSIZE) size = (int)offset; - - size = gzread(file, s->outbuf, (uInt)size); - if (size <= 0) return -1L; - offset -= size; - } - return (z_off_t)s->stream.total_out; -} - -/* =========================================================================== - Rewinds input file. -*/ -int ZEXPORT gzrewind (file) - gzFile file; -{ - gz_stream *s = (gz_stream*)file; - - if (s == NULL || s->mode != 'r') return -1; - - s->z_err = Z_OK; - s->z_eof = 0; - s->stream.avail_in = 0; - s->stream.next_in = s->inbuf; - s->crc = crc32(0L, Z_NULL, 0); - - if (s->startpos == 0) { /* not a compressed file */ - rewind(s->file); - return 0; - } - - (void) inflateReset(&s->stream); - return fseek(s->file, s->startpos, SEEK_SET); -} - -/* =========================================================================== - 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. -*/ -z_off_t ZEXPORT gztell (file) - gzFile file; -{ - return gzseek(file, 0L, SEEK_CUR); -} - -/* =========================================================================== - Returns 1 when EOF has previously been detected reading the given - input stream, otherwise zero. -*/ -int ZEXPORT gzeof (file) - gzFile file; -{ - gz_stream *s = (gz_stream*)file; - - return (s == NULL || s->mode != 'r') ? 0 : s->z_eof; -} - -/* =========================================================================== - Outputs a long in LSB order to the given file -*/ -local void putLong (file, x) - FILE *file; - uLong x; -{ - int n; - for (n = 0; n < 4; n++) { - fputc((int)(x & 0xff), file); - x >>= 8; - } -} - -/* =========================================================================== - Reads a long in LSB order from the given gz_stream. Sets z_err in case - of error. -*/ -local uLong getLong (s) - gz_stream *s; -{ - uLong x = (uLong)get_byte(s); - int c; - - x += ((uLong)get_byte(s))<<8; - x += ((uLong)get_byte(s))<<16; - c = get_byte(s); - if (c == EOF) s->z_err = Z_DATA_ERROR; - x += ((uLong)c)<<24; - return x; -} - -/* =========================================================================== - Flushes all pending output if necessary, closes the compressed file - and deallocates all the (de)compression state. -*/ -int ZEXPORT gzclose (file) - gzFile file; -{ - int err; - gz_stream *s = (gz_stream*)file; - - if (s == NULL) return Z_STREAM_ERROR; - - if (s->mode == 'w') { -#ifdef NO_DEFLATE - return Z_STREAM_ERROR; -#else - err = do_flush (file, Z_FINISH); - if (err != Z_OK) return destroy((gz_stream*)file); - - putLong (s->file, s->crc); - putLong (s->file, s->stream.total_in); -#endif - } - return destroy((gz_stream*)file); -} - -/* =========================================================================== - Returns the error message for the last error which occured on the - given compressed file. errnum is set to zlib error number. If an - error occured 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. -*/ -const char* ZEXPORT gzerror (file, errnum) - gzFile file; - int *errnum; -{ - char *m; - gz_stream *s = (gz_stream*)file; - - if (s == NULL) { - *errnum = Z_STREAM_ERROR; - return (const char*)ERR_MSG(Z_STREAM_ERROR); - } - *errnum = s->z_err; - if (*errnum == Z_OK) return (const char*)""; - - m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg); - - if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err); - - TRYFREE(s->msg); - s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3); - strcpy(s->msg, s->path); - strcat(s->msg, ": "); - strcat(s->msg, m); - return (const char*)s->msg; -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/infblock.c b/contrib/vmap_extractor_v2/stormlib/zlib/infblock.c deleted file mode 100644 index dd7a6d40a8d..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/infblock.c +++ /dev/null @@ -1,403 +0,0 @@ -/* infblock.c -- interpret and process block types to last block - * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "infblock.h" -#include "inftrees.h" -#include "infcodes.h" -#include "infutil.h" - -struct inflate_codes_state {int dummy;}; /* for buggy compilers */ - -/* simplify the use of the inflate_huft type with some defines */ -#define exop word.what.Exop -#define bits word.what.Bits - -/* Table for deflate from PKZIP's appnote.txt. */ -local const uInt border[] = { /* Order of the bit length code lengths */ - 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - -/* - Notes beyond the 1.93a appnote.txt: - - 1. Distance pointers never point before the beginning of the output - stream. - 2. Distance pointers can point back across blocks, up to 32k away. - 3. There is an implied maximum of 7 bits for the bit length table and - 15 bits for the actual data. - 4. If only one code exists, then it is encoded using one bit. (Zero - would be more efficient, but perhaps a little confusing.) If two - codes exist, they are coded using one bit each (0 and 1). - 5. There is no way of sending zero distance codes--a dummy must be - sent if there are none. (History: a pre 2.0 version of PKZIP would - store blocks with no distance codes, but this was discovered to be - too harsh a criterion.) Valid only for 1.93a. 2.04c does allow - zero distance codes, which is sent as one code of zero bits in - length. - 6. There are up to 286 literal/length codes. Code 256 represents the - end-of-block. Note however that the static length tree defines - 288 codes just to fill out the Huffman codes. Codes 286 and 287 - cannot be used though, since there is no length base or extra bits - defined for them. Similarily, there are up to 30 distance codes. - However, static trees define 32 codes (all 5 bits) to fill out the - Huffman codes, but the last two had better not show up in the data. - 7. Unzip can check dynamic Huffman blocks for complete code sets. - The exception is that a single code would not be complete (see #4). - 8. The five bits following the block type is really the number of - literal codes sent minus 257. - 9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits - (1+6+6). Therefore, to output three times the length, you output - three codes (1+1+1), whereas to output four times the same length, - you only need two codes (1+3). Hmm. - 10. In the tree reconstruction algorithm, Code = Code + Increment - only if BitLength(i) is not zero. (Pretty obvious.) - 11. Correction: 4 Bits: # of Bit Length codes - 4 (4 - 19) - 12. Note: length code 284 can represent 227-258, but length code 285 - really is 258. The last length deserves its own, short code - since it gets used a lot in very redundant files. The length - 258 is special since 258 - 3 (the min match length) is 255. - 13. The literal/length and distance code bit lengths are read as a - single stream of lengths. It is possible (and advantageous) for - a repeat code (16, 17, or 18) to go across the boundary between - the two sets of lengths. - */ - - -void inflate_blocks_reset(s, z, c) -inflate_blocks_statef *s; -z_streamp z; -uLongf *c; -{ - if (c != Z_NULL) - *c = s->check; - if (s->mode == BTREE || s->mode == DTREE) - ZFREE(z, s->sub.trees.blens); - if (s->mode == CODES) - inflate_codes_free(s->sub.decode.codes, z); - s->mode = TYPE; - s->bitk = 0; - s->bitb = 0; - s->read = s->write = s->window; - if (s->checkfn != Z_NULL) - z->adler = s->check = (*s->checkfn)(0L, (const Bytef *)Z_NULL, 0); - Tracev((stderr, "inflate: blocks reset\n")); -} - - -inflate_blocks_statef *inflate_blocks_new(z, c, w) -z_streamp z; -check_func c; -uInt w; -{ - inflate_blocks_statef *s; - - if ((s = (inflate_blocks_statef *)ZALLOC - (z,1,sizeof(struct inflate_blocks_state))) == Z_NULL) - return s; - if ((s->hufts = - (inflate_huft *)ZALLOC(z, sizeof(inflate_huft), MANY)) == Z_NULL) - { - ZFREE(z, s); - return Z_NULL; - } - if ((s->window = (Bytef *)ZALLOC(z, 1, w)) == Z_NULL) - { - ZFREE(z, s->hufts); - ZFREE(z, s); - return Z_NULL; - } - s->end = s->window + w; - s->checkfn = c; - s->mode = TYPE; - Tracev((stderr, "inflate: blocks allocated\n")); - inflate_blocks_reset(s, z, Z_NULL); - return s; -} - - -int inflate_blocks(s, z, r) -inflate_blocks_statef *s; -z_streamp z; -int r; -{ - uInt t; /* temporary storage */ - uLong b; /* bit buffer */ - uInt k; /* bits in bit buffer */ - Bytef *p; /* input data pointer */ - uInt n; /* bytes available there */ - Bytef *q; /* output window write pointer */ - uInt m; /* bytes to end of window or read pointer */ - - /* copy input/output information to locals (UPDATE macro restores) */ - LOAD - - /* process input based on current state */ - while (1) switch (s->mode) - { - case TYPE: - NEEDBITS(3) - t = (uInt)b & 7; - s->last = t & 1; - switch (t >> 1) - { - case 0: /* stored */ - Tracev((stderr, "inflate: stored block%s\n", - s->last ? " (last)" : "")); - DUMPBITS(3) - t = k & 7; /* go to byte boundary */ - DUMPBITS(t) - s->mode = LENS; /* get length of stored block */ - break; - case 1: /* fixed */ - Tracev((stderr, "inflate: fixed codes block%s\n", - s->last ? " (last)" : "")); - { - uInt bl, bd; - inflate_huft *tl, *td; - - inflate_trees_fixed(&bl, &bd, &tl, &td, z); - s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z); - if (s->sub.decode.codes == Z_NULL) - { - r = Z_MEM_ERROR; - LEAVE - } - } - DUMPBITS(3) - s->mode = CODES; - break; - case 2: /* dynamic */ - Tracev((stderr, "inflate: dynamic codes block%s\n", - s->last ? " (last)" : "")); - DUMPBITS(3) - s->mode = TABLE; - break; - case 3: /* illegal */ - DUMPBITS(3) - s->mode = BAD; - z->msg = (char*)"invalid block type"; - r = Z_DATA_ERROR; - LEAVE - } - break; - case LENS: - NEEDBITS(32) - if ((((~b) >> 16) & 0xffff) != (b & 0xffff)) - { - s->mode = BAD; - z->msg = (char*)"invalid stored block lengths"; - r = Z_DATA_ERROR; - LEAVE - } - s->sub.left = (uInt)b & 0xffff; - b = k = 0; /* dump bits */ - Tracev((stderr, "inflate: stored length %u\n", s->sub.left)); - s->mode = s->sub.left ? STORED : (s->last ? DRY : TYPE); - break; - case STORED: - if (n == 0) - LEAVE - NEEDOUT - t = s->sub.left; - if (t > n) t = n; - if (t > m) t = m; - zmemcpy(q, p, t); - p += t; n -= t; - q += t; m -= t; - if ((s->sub.left -= t) != 0) - break; - Tracev((stderr, "inflate: stored end, %lu total out\n", - z->total_out + (q >= s->read ? q - s->read : - (s->end - s->read) + (q - s->window)))); - s->mode = s->last ? DRY : TYPE; - break; - case TABLE: - NEEDBITS(14) - s->sub.trees.table = t = (uInt)b & 0x3fff; -#ifndef PKZIP_BUG_WORKAROUND - if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) - { - s->mode = BAD; - z->msg = (char*)"too many length or distance symbols"; - r = Z_DATA_ERROR; - LEAVE - } -#endif - t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); - if ((s->sub.trees.blens = (uIntf*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL) - { - r = Z_MEM_ERROR; - LEAVE - } - DUMPBITS(14) - s->sub.trees.index = 0; - Tracev((stderr, "inflate: table sizes ok\n")); - s->mode = BTREE; - case BTREE: - while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10)) - { - NEEDBITS(3) - s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7; - DUMPBITS(3) - } - while (s->sub.trees.index < 19) - s->sub.trees.blens[border[s->sub.trees.index++]] = 0; - s->sub.trees.bb = 7; - t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb, - &s->sub.trees.tb, s->hufts, z); - if (t != Z_OK) - { - r = t; - if (r == Z_DATA_ERROR) - { - ZFREE(z, s->sub.trees.blens); - s->mode = BAD; - } - LEAVE - } - s->sub.trees.index = 0; - Tracev((stderr, "inflate: bits tree ok\n")); - s->mode = DTREE; - case DTREE: - while (t = s->sub.trees.table, - s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f)) - { - inflate_huft *h; - uInt i, j, c; - - t = s->sub.trees.bb; - NEEDBITS(t) - h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]); - t = h->bits; - c = h->base; - if (c < 16) - { - DUMPBITS(t) - s->sub.trees.blens[s->sub.trees.index++] = c; - } - else /* c == 16..18 */ - { - i = c == 18 ? 7 : c - 14; - j = c == 18 ? 11 : 3; - NEEDBITS(t + i) - DUMPBITS(t) - j += (uInt)b & inflate_mask[i]; - DUMPBITS(i) - i = s->sub.trees.index; - t = s->sub.trees.table; - if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || - (c == 16 && i < 1)) - { - ZFREE(z, s->sub.trees.blens); - s->mode = BAD; - z->msg = (char*)"invalid bit length repeat"; - r = Z_DATA_ERROR; - LEAVE - } - c = c == 16 ? s->sub.trees.blens[i - 1] : 0; - do { - s->sub.trees.blens[i++] = c; - } while (--j); - s->sub.trees.index = i; - } - } - s->sub.trees.tb = Z_NULL; - { - uInt bl, bd; - inflate_huft *tl, *td; - inflate_codes_statef *c; - - bl = 9; /* must be <= 9 for lookahead assumptions */ - bd = 6; /* must be <= 9 for lookahead assumptions */ - t = s->sub.trees.table; - t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), - s->sub.trees.blens, &bl, &bd, &tl, &td, - s->hufts, z); - if (t != Z_OK) - { - if (t == (uInt)Z_DATA_ERROR) - { - ZFREE(z, s->sub.trees.blens); - s->mode = BAD; - } - r = t; - LEAVE - } - Tracev((stderr, "inflate: trees ok\n")); - if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL) - { - r = Z_MEM_ERROR; - LEAVE - } - s->sub.decode.codes = c; - } - ZFREE(z, s->sub.trees.blens); - s->mode = CODES; - case CODES: - UPDATE - if ((r = inflate_codes(s, z, r)) != Z_STREAM_END) - return inflate_flush(s, z, r); - r = Z_OK; - inflate_codes_free(s->sub.decode.codes, z); - LOAD - Tracev((stderr, "inflate: codes end, %lu total out\n", - z->total_out + (q >= s->read ? q - s->read : - (s->end - s->read) + (q - s->window)))); - if (!s->last) - { - s->mode = TYPE; - break; - } - s->mode = DRY; - case DRY: - FLUSH - if (s->read != s->write) - LEAVE - s->mode = DONE; - case DONE: - r = Z_STREAM_END; - LEAVE - case BAD: - r = Z_DATA_ERROR; - LEAVE - default: - r = Z_STREAM_ERROR; - LEAVE - } -} - - -int inflate_blocks_free(s, z) -inflate_blocks_statef *s; -z_streamp z; -{ - inflate_blocks_reset(s, z, Z_NULL); - ZFREE(z, s->window); - ZFREE(z, s->hufts); - ZFREE(z, s); - Tracev((stderr, "inflate: blocks freed\n")); - return Z_OK; -} - - -void inflate_set_dictionary(s, d, n) -inflate_blocks_statef *s; -const Bytef *d; -uInt n; -{ - zmemcpy(s->window, d, n); - s->read = s->write = s->window + n; -} - - -/* Returns true if inflate is currently at the end of a block generated - * by Z_SYNC_FLUSH or Z_FULL_FLUSH. - * IN assertion: s != Z_NULL - */ -int inflate_blocks_sync_point(s) -inflate_blocks_statef *s; -{ - return s->mode == LENS; -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/infblock.h b/contrib/vmap_extractor_v2/stormlib/zlib/infblock.h deleted file mode 100644 index 173b2267ade..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/infblock.h +++ /dev/null @@ -1,39 +0,0 @@ -/* infblock.h -- header to use infblock.c - * Copyright (C) 1995-2002 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. - */ - -struct inflate_blocks_state; -typedef struct inflate_blocks_state FAR inflate_blocks_statef; - -extern inflate_blocks_statef * inflate_blocks_new OF(( - z_streamp z, - check_func c, /* check function */ - uInt w)); /* window size */ - -extern int inflate_blocks OF(( - inflate_blocks_statef *, - z_streamp , - int)); /* initial return code */ - -extern void inflate_blocks_reset OF(( - inflate_blocks_statef *, - z_streamp , - uLongf *)); /* check value on output */ - -extern int inflate_blocks_free OF(( - inflate_blocks_statef *, - z_streamp)); - -extern void inflate_set_dictionary OF(( - inflate_blocks_statef *s, - const Bytef *d, /* dictionary */ - uInt n)); /* dictionary length */ - -extern int inflate_blocks_sync_point OF(( - inflate_blocks_statef *s)); diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/infcodes.c b/contrib/vmap_extractor_v2/stormlib/zlib/infcodes.c deleted file mode 100644 index 9abe5412b9c..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/infcodes.c +++ /dev/null @@ -1,251 +0,0 @@ -/* infcodes.c -- process literals and length/distance pairs - * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "inftrees.h" -#include "infblock.h" -#include "infcodes.h" -#include "infutil.h" -#include "inffast.h" - -/* simplify the use of the inflate_huft type with some defines */ -#define exop word.what.Exop -#define bits word.what.Bits - -typedef enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */ - START, /* x: set up for LEN */ - LEN, /* i: get length/literal/eob next */ - LENEXT, /* i: getting length extra (have base) */ - DIST, /* i: get distance next */ - DISTEXT, /* i: getting distance extra */ - COPY, /* o: copying bytes in window, waiting for space */ - LIT, /* o: got literal, waiting for output space */ - WASH, /* o: got eob, possibly still output waiting */ - END, /* x: got eob and all data flushed */ - BADCODE} /* x: got error */ -inflate_codes_mode; - -/* inflate codes private state */ -struct inflate_codes_state { - - /* mode */ - inflate_codes_mode mode; /* current inflate_codes mode */ - - /* mode dependent information */ - uInt len; - union { - struct { - inflate_huft *tree; /* pointer into tree */ - uInt need; /* bits needed */ - } code; /* if LEN or DIST, where in tree */ - uInt lit; /* if LIT, literal */ - struct { - uInt get; /* bits to get for extra */ - uInt dist; /* distance back to copy from */ - } copy; /* if EXT or COPY, where and how much */ - } sub; /* submode */ - - /* mode independent information */ - Byte lbits; /* ltree bits decoded per branch */ - Byte dbits; /* dtree bits decoder per branch */ - inflate_huft *ltree; /* literal/length/eob tree */ - inflate_huft *dtree; /* distance tree */ - -}; - - -inflate_codes_statef *inflate_codes_new(bl, bd, tl, td, z) -uInt bl, bd; -inflate_huft *tl; -inflate_huft *td; /* need separate declaration for Borland C++ */ -z_streamp z; -{ - inflate_codes_statef *c; - - if ((c = (inflate_codes_statef *) - ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL) - { - c->mode = START; - c->lbits = (Byte)bl; - c->dbits = (Byte)bd; - c->ltree = tl; - c->dtree = td; - Tracev((stderr, "inflate: codes new\n")); - } - return c; -} - - -int inflate_codes(s, z, r) -inflate_blocks_statef *s; -z_streamp z; -int r; -{ - uInt j; /* temporary storage */ - inflate_huft *t; /* temporary pointer */ - uInt e; /* extra bits or operation */ - uLong b; /* bit buffer */ - uInt k; /* bits in bit buffer */ - Bytef *p; /* input data pointer */ - uInt n; /* bytes available there */ - Bytef *q; /* output window write pointer */ - uInt m; /* bytes to end of window or read pointer */ - Bytef *f; /* pointer to copy strings from */ - inflate_codes_statef *c = s->sub.decode.codes; /* codes state */ - - /* copy input/output information to locals (UPDATE macro restores) */ - LOAD - - /* process input and output based on current state */ - while (1) switch (c->mode) - { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */ - case START: /* x: set up for LEN */ -#ifndef SLOW - if (m >= 258 && n >= 10) - { - UPDATE - r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z); - LOAD - if (r != Z_OK) - { - c->mode = r == Z_STREAM_END ? WASH : BADCODE; - break; - } - } -#endif /* !SLOW */ - c->sub.code.need = c->lbits; - c->sub.code.tree = c->ltree; - c->mode = LEN; - case LEN: /* i: get length/literal/eob next */ - j = c->sub.code.need; - NEEDBITS(j) - t = c->sub.code.tree + ((uInt)b & inflate_mask[j]); - DUMPBITS(t->bits) - e = (uInt)(t->exop); - if (e == 0) /* literal */ - { - c->sub.lit = t->base; - Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", t->base)); - c->mode = LIT; - break; - } - if (e & 16) /* length */ - { - c->sub.copy.get = e & 15; - c->len = t->base; - c->mode = LENEXT; - break; - } - if ((e & 64) == 0) /* next table */ - { - c->sub.code.need = e; - c->sub.code.tree = t + t->base; - break; - } - if (e & 32) /* end of block */ - { - Tracevv((stderr, "inflate: end of block\n")); - c->mode = WASH; - break; - } - c->mode = BADCODE; /* invalid code */ - z->msg = (char*)"invalid literal/length code"; - r = Z_DATA_ERROR; - LEAVE - case LENEXT: /* i: getting length extra (have base) */ - j = c->sub.copy.get; - NEEDBITS(j) - c->len += (uInt)b & inflate_mask[j]; - DUMPBITS(j) - c->sub.code.need = c->dbits; - c->sub.code.tree = c->dtree; - Tracevv((stderr, "inflate: length %u\n", c->len)); - c->mode = DIST; - case DIST: /* i: get distance next */ - j = c->sub.code.need; - NEEDBITS(j) - t = c->sub.code.tree + ((uInt)b & inflate_mask[j]); - DUMPBITS(t->bits) - e = (uInt)(t->exop); - if (e & 16) /* distance */ - { - c->sub.copy.get = e & 15; - c->sub.copy.dist = t->base; - c->mode = DISTEXT; - break; - } - if ((e & 64) == 0) /* next table */ - { - c->sub.code.need = e; - c->sub.code.tree = t + t->base; - break; - } - c->mode = BADCODE; /* invalid code */ - z->msg = (char*)"invalid distance code"; - r = Z_DATA_ERROR; - LEAVE - case DISTEXT: /* i: getting distance extra */ - j = c->sub.copy.get; - NEEDBITS(j) - c->sub.copy.dist += (uInt)b & inflate_mask[j]; - DUMPBITS(j) - Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist)); - c->mode = COPY; - case COPY: /* o: copying bytes in window, waiting for space */ - f = q - c->sub.copy.dist; - while (f < s->window) /* modulo window size-"while" instead */ - f += s->end - s->window; /* of "if" handles invalid distances */ - while (c->len) - { - NEEDOUT - OUTBYTE(*f++) - if (f == s->end) - f = s->window; - c->len--; - } - c->mode = START; - break; - case LIT: /* o: got literal, waiting for output space */ - NEEDOUT - OUTBYTE(c->sub.lit) - c->mode = START; - break; - case WASH: /* o: got eob, possibly more output */ - if (k > 7) /* return unused byte, if any */ - { - Assert(k < 16, "inflate_codes grabbed too many bytes") - k -= 8; - n++; - p--; /* can always return one */ - } - FLUSH - if (s->read != s->write) - LEAVE - c->mode = END; - case END: - r = Z_STREAM_END; - LEAVE - case BADCODE: /* x: got error */ - r = Z_DATA_ERROR; - LEAVE - default: - r = Z_STREAM_ERROR; - LEAVE - } -#ifdef NEED_DUMMY_RETURN - return Z_STREAM_ERROR; /* Some dumb compilers complain without this */ -#endif -} - - -void inflate_codes_free(c, z) -inflate_codes_statef *c; -z_streamp z; -{ - ZFREE(z, c); - Tracev((stderr, "inflate: codes free\n")); -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/infcodes.h b/contrib/vmap_extractor_v2/stormlib/zlib/infcodes.h deleted file mode 100644 index 46821a02be6..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/infcodes.h +++ /dev/null @@ -1,27 +0,0 @@ -/* infcodes.h -- header to use infcodes.c - * Copyright (C) 1995-2002 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. - */ - -struct inflate_codes_state; -typedef struct inflate_codes_state FAR inflate_codes_statef; - -extern inflate_codes_statef *inflate_codes_new OF(( - uInt, uInt, - inflate_huft *, inflate_huft *, - z_streamp )); - -extern int inflate_codes OF(( - inflate_blocks_statef *, - z_streamp , - int)); - -extern void inflate_codes_free OF(( - inflate_codes_statef *, - z_streamp )); - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/inffast.c b/contrib/vmap_extractor_v2/stormlib/zlib/inffast.c deleted file mode 100644 index aa7f1d4d2ad..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/inffast.c +++ /dev/null @@ -1,183 +0,0 @@ -/* inffast.c -- process literals and length/distance pairs fast - * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "inftrees.h" -#include "infblock.h" -#include "infcodes.h" -#include "infutil.h" -#include "inffast.h" - -struct inflate_codes_state {int dummy;}; /* for buggy compilers */ - -/* simplify the use of the inflate_huft type with some defines */ -#define exop word.what.Exop -#define bits word.what.Bits - -/* macros for bit input with no checking and for returning unused bytes */ -#define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<avail_in-n;c=(k>>3)>3:c;n+=c;p-=c;k-=c<<3;} - -/* Called with number of bytes left to write in window at least 258 - (the maximum string length) and number of input bytes available - at least ten. The ten bytes are six bytes for the longest length/ - distance pair plus four bytes for overloading the bit buffer. */ - -int inflate_fast(bl, bd, tl, td, s, z) -uInt bl, bd; -inflate_huft *tl; -inflate_huft *td; /* need separate declaration for Borland C++ */ -inflate_blocks_statef *s; -z_streamp z; -{ - inflate_huft *t; /* temporary pointer */ - uInt e; /* extra bits or operation */ - uLong b; /* bit buffer */ - uInt k; /* bits in bit buffer */ - Bytef *p; /* input data pointer */ - uInt n; /* bytes available there */ - Bytef *q; /* output window write pointer */ - uInt m; /* bytes to end of window or read pointer */ - uInt ml; /* mask for literal/length tree */ - uInt md; /* mask for distance tree */ - uInt c; /* bytes to copy */ - uInt d; /* distance back to copy from */ - Bytef *r; /* copy source pointer */ - - /* load input, output, bit values */ - LOAD - - /* initialize masks */ - ml = inflate_mask[bl]; - md = inflate_mask[bd]; - - /* do until not enough input or output space for fast loop */ - do { /* assume called with m >= 258 && n >= 10 */ - /* get literal/length code */ - GRABBITS(20) /* max bits for literal/length code */ - if ((e = (t = tl + ((uInt)b & ml))->exop) == 0) - { - DUMPBITS(t->bits) - Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? - "inflate: * literal '%c'\n" : - "inflate: * literal 0x%02x\n", t->base)); - *q++ = (Byte)t->base; - m--; - continue; - } - do { - DUMPBITS(t->bits) - if (e & 16) - { - /* get extra bits for length */ - e &= 15; - c = t->base + ((uInt)b & inflate_mask[e]); - DUMPBITS(e) - Tracevv((stderr, "inflate: * length %u\n", c)); - - /* decode distance base of block to copy */ - GRABBITS(15); /* max bits for distance code */ - e = (t = td + ((uInt)b & md))->exop; - do { - DUMPBITS(t->bits) - if (e & 16) - { - /* get extra bits to add to distance base */ - e &= 15; - GRABBITS(e) /* get extra bits (up to 13) */ - d = t->base + ((uInt)b & inflate_mask[e]); - DUMPBITS(e) - Tracevv((stderr, "inflate: * distance %u\n", d)); - - /* do the copy */ - m -= c; - r = q - d; - if (r < s->window) /* wrap if needed */ - { - do { - r += s->end - s->window; /* force pointer in window */ - } while (r < s->window); /* covers invalid distances */ - e = s->end - r; - if (c > e) - { - c -= e; /* wrapped copy */ - do { - *q++ = *r++; - } while (--e); - r = s->window; - do { - *q++ = *r++; - } while (--c); - } - else /* normal copy */ - { - *q++ = *r++; c--; - *q++ = *r++; c--; - do { - *q++ = *r++; - } while (--c); - } - } - else /* normal copy */ - { - *q++ = *r++; c--; - *q++ = *r++; c--; - do { - *q++ = *r++; - } while (--c); - } - break; - } - else if ((e & 64) == 0) - { - t += t->base; - e = (t += ((uInt)b & inflate_mask[e]))->exop; - } - else - { - z->msg = (char*)"invalid distance code"; - UNGRAB - UPDATE - return Z_DATA_ERROR; - } - } while (1); - break; - } - if ((e & 64) == 0) - { - t += t->base; - if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0) - { - DUMPBITS(t->bits) - Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? - "inflate: * literal '%c'\n" : - "inflate: * literal 0x%02x\n", t->base)); - *q++ = (Byte)t->base; - m--; - break; - } - } - else if (e & 32) - { - Tracevv((stderr, "inflate: * end of block\n")); - UNGRAB - UPDATE - return Z_STREAM_END; - } - else - { - z->msg = (char*)"invalid literal/length code"; - UNGRAB - UPDATE - return Z_DATA_ERROR; - } - } while (1); - } while (m >= 258 && n >= 10); - - /* not enough input or output--restore pointers and return */ - UNGRAB - UPDATE - return Z_OK; -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/inffast.h b/contrib/vmap_extractor_v2/stormlib/zlib/inffast.h deleted file mode 100644 index a31a4bbb058..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/inffast.h +++ /dev/null @@ -1,17 +0,0 @@ -/* inffast.h -- header to use inffast.c - * Copyright (C) 1995-2002 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. - */ - -extern int inflate_fast OF(( - uInt, - uInt, - inflate_huft *, - inflate_huft *, - inflate_blocks_statef *, - z_streamp )); diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/inffixed.h b/contrib/vmap_extractor_v2/stormlib/zlib/inffixed.h deleted file mode 100644 index 77f7e763145..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/inffixed.h +++ /dev/null @@ -1,151 +0,0 @@ -/* inffixed.h -- table for decoding fixed codes - * Generated automatically by the maketree.c program - */ - -/* 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. - */ - -local uInt fixed_bl = 9; -local uInt fixed_bd = 5; -local inflate_huft fixed_tl[] = { - {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115}, - {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},192}, - {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},160}, - {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},224}, - {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},144}, - {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},208}, - {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},176}, - {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},240}, - {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227}, - {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},200}, - {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},168}, - {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},232}, - {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},152}, - {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},216}, - {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},184}, - {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},248}, - {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163}, - {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},196}, - {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},164}, - {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},228}, - {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},148}, - {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},212}, - {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},180}, - {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},244}, - {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0}, - {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},204}, - {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},172}, - {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},236}, - {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},156}, - {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},220}, - {{{82,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}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131}, - {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},194}, - {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},162}, - {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},226}, - {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},146}, - {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},210}, - {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},178}, - {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},242}, - {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258}, - {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},202}, - {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},170}, - {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},234}, - {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},154}, - {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},218}, - {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},186}, - {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},250}, - {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195}, - {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},198}, - {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},166}, - {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},230}, - {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},150}, - {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},214}, - {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},182}, - {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},246}, - {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0}, - {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},206}, - {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},174}, - {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},238}, - {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},158}, - {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},222}, - {{{82,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}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115}, - {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},193}, - {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},161}, - {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},225}, - {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},145}, - {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},209}, - {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},177}, - {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},241}, - {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227}, - {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},201}, - {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},169}, - {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},233}, - {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},153}, - {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},217}, - {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},185}, - {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},249}, - {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163}, - {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},197}, - {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},165}, - {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},229}, - {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},149}, - {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},213}, - {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},181}, - {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},245}, - {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0}, - {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},205}, - {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},173}, - {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},237}, - {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},157}, - {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},221}, - {{{82,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}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131}, - {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},195}, - {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},163}, - {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},227}, - {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},147}, - {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},211}, - {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},179}, - {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},243}, - {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258}, - {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},203}, - {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},171}, - {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},235}, - {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},155}, - {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},219}, - {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},187}, - {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},251}, - {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195}, - {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},199}, - {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},167}, - {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},231}, - {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},151}, - {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},215}, - {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},183}, - {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},247}, - {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0}, - {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},207}, - {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},175}, - {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},239}, - {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},159}, - {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},223}, - {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},191}, - {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},255} - }; -local inflate_huft fixed_td[] = { - {{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097}, - {{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385}, - {{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193}, - {{{82,5}},9}, {{{90,5}},2049}, {{{86,5}},129}, {{{192,5}},24577}, - {{{80,5}},2}, {{{87,5}},385}, {{{83,5}},25}, {{{91,5}},6145}, - {{{81,5}},7}, {{{89,5}},1537}, {{{85,5}},97}, {{{93,5}},24577}, - {{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289}, - {{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577} - }; diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/inflate.c b/contrib/vmap_extractor_v2/stormlib/zlib/inflate.c deleted file mode 100644 index dfb2e867d81..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/inflate.c +++ /dev/null @@ -1,366 +0,0 @@ -/* inflate.c -- zlib interface to inflate modules - * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "infblock.h" - -struct inflate_blocks_state {int dummy;}; /* for buggy compilers */ - -typedef enum { - METHOD, /* waiting for method byte */ - FLAG, /* waiting for flag byte */ - DICT4, /* four dictionary check bytes to go */ - DICT3, /* three dictionary check bytes to go */ - DICT2, /* two dictionary check bytes to go */ - DICT1, /* one dictionary check byte to go */ - DICT0, /* waiting for inflateSetDictionary */ - BLOCKS, /* decompressing blocks */ - CHECK4, /* four check bytes to go */ - CHECK3, /* three check bytes to go */ - CHECK2, /* two check bytes to go */ - CHECK1, /* one check byte to go */ - DONE, /* finished check, done */ - BAD} /* got an error--stay here */ -inflate_mode; - -/* inflate private state */ -struct internal_state { - - /* mode */ - inflate_mode mode; /* current inflate mode */ - - /* mode dependent information */ - union { - uInt method; /* if FLAGS, method byte */ - struct { - uLong was; /* computed check value */ - uLong need; /* stream check value */ - } check; /* if CHECK, check values to compare */ - uInt marker; /* if BAD, inflateSync's marker bytes count */ - } sub; /* submode */ - - /* mode independent information */ - int nowrap; /* flag for no wrapper */ - uInt wbits; /* log2(window size) (8..15, defaults to 15) */ - inflate_blocks_statef - *blocks; /* current inflate_blocks state */ - -}; - - -int ZEXPORT inflateReset(z) -z_streamp z; -{ - if (z == Z_NULL || z->state == Z_NULL) - return Z_STREAM_ERROR; - z->total_in = z->total_out = 0; - z->msg = Z_NULL; - z->state->mode = z->state->nowrap ? BLOCKS : METHOD; - inflate_blocks_reset(z->state->blocks, z, Z_NULL); - Tracev((stderr, "inflate: reset\n")); - return Z_OK; -} - - -int ZEXPORT inflateEnd(z) -z_streamp z; -{ - if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL) - return Z_STREAM_ERROR; - if (z->state->blocks != Z_NULL) - inflate_blocks_free(z->state->blocks, z); - ZFREE(z, z->state); - z->state = Z_NULL; - Tracev((stderr, "inflate: end\n")); - return Z_OK; -} - - -int ZEXPORT inflateInit2_(z, w, version, stream_size) -z_streamp z; -int w; -const char *version; -int stream_size; -{ - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || - stream_size != sizeof(z_stream)) - return Z_VERSION_ERROR; - - /* initialize state */ - if (z == Z_NULL) - return Z_STREAM_ERROR; - z->msg = Z_NULL; - if (z->zalloc == Z_NULL) - { - z->zalloc = zcalloc; - z->opaque = (voidpf)0; - } - if (z->zfree == Z_NULL) z->zfree = zcfree; - if ((z->state = (struct internal_state FAR *) - ZALLOC(z,1,sizeof(struct internal_state))) == Z_NULL) - return Z_MEM_ERROR; - z->state->blocks = Z_NULL; - - /* handle undocumented nowrap option (no zlib header or check) */ - z->state->nowrap = 0; - if (w < 0) - { - w = - w; - z->state->nowrap = 1; - } - - /* set window size */ - if (w < 8 || w > 15) - { - inflateEnd(z); - return Z_STREAM_ERROR; - } - z->state->wbits = (uInt)w; - - /* create inflate_blocks state */ - if ((z->state->blocks = - inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, (uInt)1 << w)) - == Z_NULL) - { - inflateEnd(z); - return Z_MEM_ERROR; - } - Tracev((stderr, "inflate: allocated\n")); - - /* reset state */ - inflateReset(z); - return Z_OK; -} - - -int ZEXPORT inflateInit_(z, version, stream_size) -z_streamp z; -const char *version; -int stream_size; -{ - return inflateInit2_(z, DEF_WBITS, version, stream_size); -} - - -#define NEEDBYTE {if(z->avail_in==0)return r;r=f;} -#define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++) - -int ZEXPORT inflate(z, f) -z_streamp z; -int f; -{ - int r; - uInt b; - - if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL) - return Z_STREAM_ERROR; - f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK; - r = Z_BUF_ERROR; - while (1) switch (z->state->mode) - { - case METHOD: - NEEDBYTE - if (((z->state->sub.method = NEXTBYTE) & 0xf) != Z_DEFLATED) - { - z->state->mode = BAD; - z->msg = (char*)"unknown compression method"; - z->state->sub.marker = 5; /* can't try inflateSync */ - break; - } - if ((z->state->sub.method >> 4) + 8 > z->state->wbits) - { - z->state->mode = BAD; - z->msg = (char*)"invalid window size"; - z->state->sub.marker = 5; /* can't try inflateSync */ - break; - } - z->state->mode = FLAG; - case FLAG: - NEEDBYTE - b = NEXTBYTE; - if (((z->state->sub.method << 8) + b) % 31) - { - z->state->mode = BAD; - z->msg = (char*)"incorrect header check"; - z->state->sub.marker = 5; /* can't try inflateSync */ - break; - } - Tracev((stderr, "inflate: zlib header ok\n")); - if (!(b & PRESET_DICT)) - { - z->state->mode = BLOCKS; - break; - } - z->state->mode = DICT4; - case DICT4: - NEEDBYTE - z->state->sub.check.need = (uLong)NEXTBYTE << 24; - z->state->mode = DICT3; - case DICT3: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE << 16; - z->state->mode = DICT2; - case DICT2: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE << 8; - z->state->mode = DICT1; - case DICT1: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE; - z->adler = z->state->sub.check.need; - z->state->mode = DICT0; - return Z_NEED_DICT; - case DICT0: - z->state->mode = BAD; - z->msg = (char*)"need dictionary"; - z->state->sub.marker = 0; /* can try inflateSync */ - return Z_STREAM_ERROR; - case BLOCKS: - r = inflate_blocks(z->state->blocks, z, r); - if (r == Z_DATA_ERROR) - { - z->state->mode = BAD; - z->state->sub.marker = 0; /* can try inflateSync */ - break; - } - if (r == Z_OK) - r = f; - if (r != Z_STREAM_END) - return r; - r = f; - inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was); - if (z->state->nowrap) - { - z->state->mode = DONE; - break; - } - z->state->mode = CHECK4; - case CHECK4: - NEEDBYTE - z->state->sub.check.need = (uLong)NEXTBYTE << 24; - z->state->mode = CHECK3; - case CHECK3: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE << 16; - z->state->mode = CHECK2; - case CHECK2: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE << 8; - z->state->mode = CHECK1; - case CHECK1: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE; - - if (z->state->sub.check.was != z->state->sub.check.need) - { - z->state->mode = BAD; - z->msg = (char*)"incorrect data check"; - z->state->sub.marker = 5; /* can't try inflateSync */ - break; - } - Tracev((stderr, "inflate: zlib check ok\n")); - z->state->mode = DONE; - case DONE: - return Z_STREAM_END; - case BAD: - return Z_DATA_ERROR; - default: - return Z_STREAM_ERROR; - } -#ifdef NEED_DUMMY_RETURN - return Z_STREAM_ERROR; /* Some dumb compilers complain without this */ -#endif -} - - -int ZEXPORT inflateSetDictionary(z, dictionary, dictLength) -z_streamp z; -const Bytef *dictionary; -uInt dictLength; -{ - uInt length = dictLength; - - if (z == Z_NULL || z->state == Z_NULL || z->state->mode != DICT0) - return Z_STREAM_ERROR; - - if (adler32(1L, dictionary, dictLength) != z->adler) return Z_DATA_ERROR; - z->adler = 1L; - - if (length >= ((uInt)1<state->wbits)) - { - length = (1<state->wbits)-1; - dictionary += dictLength - length; - } - inflate_set_dictionary(z->state->blocks, dictionary, length); - z->state->mode = BLOCKS; - return Z_OK; -} - - -int ZEXPORT inflateSync(z) -z_streamp z; -{ - uInt n; /* number of bytes to look at */ - Bytef *p; /* pointer to bytes */ - uInt m; /* number of marker bytes found in a row */ - uLong r, w; /* temporaries to save total_in and total_out */ - - /* set up */ - if (z == Z_NULL || z->state == Z_NULL) - return Z_STREAM_ERROR; - if (z->state->mode != BAD) - { - z->state->mode = BAD; - z->state->sub.marker = 0; - } - if ((n = z->avail_in) == 0) - return Z_BUF_ERROR; - p = z->next_in; - m = z->state->sub.marker; - - /* search */ - while (n && m < 4) - { - static const Byte mark[4] = {0, 0, 0xff, 0xff}; - if (*p == mark[m]) - m++; - else if (*p) - m = 0; - else - m = 4 - m; - p++, n--; - } - - /* restore */ - z->total_in += p - z->next_in; - z->next_in = p; - z->avail_in = n; - z->state->sub.marker = m; - - /* return no joy or set up to restart on a new block */ - if (m != 4) - return Z_DATA_ERROR; - r = z->total_in; w = z->total_out; - inflateReset(z); - z->total_in = r; z->total_out = w; - z->state->mode = BLOCKS; - 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) -z_streamp z; -{ - if (z == Z_NULL || z->state == Z_NULL || z->state->blocks == Z_NULL) - return Z_STREAM_ERROR; - return inflate_blocks_sync_point(z->state->blocks); -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/inftrees.c b/contrib/vmap_extractor_v2/stormlib/zlib/inftrees.c deleted file mode 100644 index 4c32ca30d99..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/inftrees.c +++ /dev/null @@ -1,454 +0,0 @@ -/* inftrees.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "inftrees.h" - -#if !defined(BUILDFIXED) && !defined(STDC) -# define BUILDFIXED /* non ANSI compilers may not accept inffixed.h */ -#endif - -const char inflate_copyright[] = - " inflate 1.1.4 Copyright 1995-2002 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. - */ -struct internal_state {int dummy;}; /* for buggy compilers */ - -/* simplify the use of the inflate_huft type with some defines */ -#define exop word.what.Exop -#define bits word.what.Bits - - -local int huft_build OF(( - uIntf *, /* code lengths in bits */ - uInt, /* number of codes */ - uInt, /* number of "simple" codes */ - const uIntf *, /* list of base values for non-simple codes */ - const uIntf *, /* list of extra bits for non-simple codes */ - inflate_huft * FAR*,/* result: starting table */ - uIntf *, /* maximum lookup bits (returns actual) */ - inflate_huft *, /* space for trees */ - uInt *, /* hufts used in space */ - uIntf * )); /* space for values */ - -/* Tables for deflate from PKZIP's appnote.txt. */ -local const uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */ - 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}; - /* see note #13 above about 258 */ -local const uInt cplext[31] = { /* Extra bits for literal codes 257..285 */ - 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, 112, 112}; /* 112==invalid */ -local const uInt cpdist[30] = { /* Copy offsets for distance codes 0..29 */ - 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}; -local const uInt cpdext[30] = { /* Extra bits for distance codes */ - 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}; - -/* - Huffman code decoding is performed using a multi-level table lookup. - The fastest way to decode is to simply build a lookup table whose - size is determined by the longest code. However, the time it takes - to build this table can also be a factor if the data being decoded - is not very long. The most common codes are necessarily the - shortest codes, so those codes dominate the decoding time, and hence - the speed. The idea is you can have a shorter table that decodes the - shorter, more probable codes, and then point to subsidiary tables for - the longer codes. The time it costs to decode the longer codes is - then traded against the time it takes to make longer tables. - - This results of this trade are in the variables lbits and dbits - below. lbits is the number of bits the first level table for literal/ - length codes can decode in one step, and dbits is the same thing for - the distance codes. Subsequent tables are also less than or equal to - those sizes. These values may be adjusted either when all of the - codes are shorter than that, in which case the longest code length in - bits is used, or when the shortest code is *longer* than the requested - table size, in which case the length of the shortest code in bits is - used. - - There are two different values for the two tables, since they code a - different number of possibilities each. The literal/length table - codes 286 possible values, or in a flat code, a little over eight - bits. The distance table codes 30 possible values, or a little less - than five bits, flat. The optimum values for speed end up being - about one bit more than those, so lbits is 8+1 and dbits is 5+1. - The optimum values may differ though from machine to machine, and - possibly even between compilers. Your mileage may vary. - */ - - -/* If BMAX needs to be larger than 16, then h and x[] should be uLong. */ -#define BMAX 15 /* maximum bit length of any code */ - -local int huft_build(b, n, s, d, e, t, m, hp, hn, v) -uIntf *b; /* code lengths in bits (all assumed <= BMAX) */ -uInt n; /* number of codes (assumed <= 288) */ -uInt s; /* number of simple-valued codes (0..s-1) */ -const uIntf *d; /* list of base values for non-simple codes */ -const uIntf *e; /* list of extra bits for non-simple codes */ -inflate_huft * FAR *t; /* result: starting table */ -uIntf *m; /* maximum lookup bits, returns actual */ -inflate_huft *hp; /* space for trees */ -uInt *hn; /* hufts used in space */ -uIntf *v; /* working area: values in order of bit length */ -/* Given a list of code lengths and a maximum table size, make a set of - tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR - if the given code set is incomplete (the tables are still built in this - case), or Z_DATA_ERROR if the input is invalid. */ -{ - - uInt a; /* counter for codes of length k */ - uInt c[BMAX+1]; /* bit length count table */ - uInt f; /* i repeats in table every f entries */ - int g; /* maximum code length */ - int h; /* table level */ - register uInt i; /* counter, current code */ - register uInt j; /* counter */ - register int k; /* number of bits in current code */ - int l; /* bits per table (returned in m) */ - uInt mask; /* (1 << w) - 1, to avoid cc -O bug on HP */ - register uIntf *p; /* pointer into c[], b[], or v[] */ - inflate_huft *q; /* points to current table */ - struct inflate_huft_s r; /* table entry for structure assignment */ - inflate_huft *u[BMAX]; /* table stack */ - register int w; /* bits before this table == (l * h) */ - uInt x[BMAX+1]; /* bit offsets, then code stack */ - uIntf *xp; /* pointer into x */ - int y; /* number of dummy codes added */ - uInt z; /* number of entries in current table */ - - - /* Generate counts for each bit length */ - p = c; -#define C0 *p++ = 0; -#define C2 C0 C0 C0 C0 -#define C4 C2 C2 C2 C2 - C4 /* clear c[]--assume BMAX+1 is 16 */ - p = b; i = n; - do { - c[*p++]++; /* assume all entries <= BMAX */ - } while (--i); - if (c[0] == n) /* null input--all zero length codes */ - { - *t = (inflate_huft *)Z_NULL; - *m = 0; - return Z_OK; - } - - - /* Find minimum and maximum length, bound *m by those */ - l = *m; - for (j = 1; j <= BMAX; j++) - if (c[j]) - break; - k = j; /* minimum code length */ - if ((uInt)l < j) - l = j; - for (i = BMAX; i; i--) - if (c[i]) - break; - g = i; /* maximum code length */ - if ((uInt)l > i) - l = i; - *m = l; - - - /* Adjust last length count to fill out codes, if needed */ - for (y = 1 << j; j < i; j++, y <<= 1) - if ((y -= c[j]) < 0) - return Z_DATA_ERROR; - if ((y -= c[i]) < 0) - return Z_DATA_ERROR; - c[i] += y; - - - /* Generate starting offsets into the value table for each length */ - x[1] = j = 0; - p = c + 1; xp = x + 2; - while (--i) { /* note that i == g from above */ - *xp++ = (j += *p++); - } - - - /* Make a table of values in order of bit lengths */ - p = b; i = 0; - do { - if ((j = *p++) != 0) - v[x[j]++] = i; - } while (++i < n); - n = x[g]; /* set n to length of v */ - - - /* Generate the Huffman codes and for each, make the table entries */ - x[0] = i = 0; /* first Huffman code is zero */ - p = v; /* grab values in bit order */ - h = -1; /* no tables yet--level -1 */ - w = -l; /* bits decoded == (l * h) */ - u[0] = (inflate_huft *)Z_NULL; /* just to keep compilers happy */ - q = (inflate_huft *)Z_NULL; /* ditto */ - z = 0; /* ditto */ - - /* go through the bit lengths (k already is bits in shortest code) */ - for (; k <= g; k++) - { - a = c[k]; - while (a--) - { - /* here i is the Huffman code of length k bits for value *p */ - /* make tables up to required level */ - while (k > w + l) - { - h++; - w += l; /* previous table always l bits */ - - /* compute minimum size table less than or equal to l bits */ - z = g - w; - z = z > (uInt)l ? l : z; /* table size upper limit */ - if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */ - { /* too few codes for k-w bit table */ - f -= a + 1; /* deduct codes from patterns left */ - xp = c + k; - if (j < z) - while (++j < z) /* try smaller tables up to z bits */ - { - if ((f <<= 1) <= *++xp) - break; /* enough codes to use up j bits */ - f -= *xp; /* else deduct codes from patterns */ - } - } - z = 1 << j; /* table entries for j-bit table */ - - /* allocate new table */ - if (*hn + z > MANY) /* (note: doesn't matter for fixed) */ - return Z_DATA_ERROR; /* overflow of MANY */ - u[h] = q = hp + *hn; - *hn += z; - - /* connect to last table, if there is one */ - if (h) - { - x[h] = i; /* save pattern for backing up */ - r.bits = (Byte)l; /* bits to dump before this table */ - r.exop = (Byte)j; /* bits in this table */ - j = i >> (w - l); - r.base = (uInt)(q - u[h-1] - j); /* offset to this table */ - u[h-1][j] = r; /* connect to last table */ - } - else - *t = q; /* first table is returned result */ - } - - /* set up table entry in r */ - r.bits = (Byte)(k - w); - if (p >= v + n) - r.exop = 128 + 64; /* out of values--invalid code */ - else if (*p < s) - { - r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */ - r.base = *p++; /* simple code is just the value */ - } - else - { - r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */ - r.base = d[*p++ - s]; - } - - /* fill code-like entries with r */ - f = 1 << (k - w); - for (j = i >> w; j < z; j += f) - q[j] = r; - - /* backwards increment the k-bit code i */ - for (j = 1 << (k - 1); i & j; j >>= 1) - i ^= j; - i ^= j; - - /* backup over finished tables */ - mask = (1 << w) - 1; /* needed on HP, cc -O bug */ - while ((i & mask) != x[h]) - { - h--; /* don't need to update q */ - w -= l; - mask = (1 << w) - 1; - } - } - } - - - /* Return Z_BUF_ERROR if we were given an incomplete table */ - return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK; -} - - -int inflate_trees_bits(c, bb, tb, hp, z) -uIntf *c; /* 19 code lengths */ -uIntf *bb; /* bits tree desired/actual depth */ -inflate_huft * FAR *tb; /* bits tree result */ -inflate_huft *hp; /* space for trees */ -z_streamp z; /* for messages */ -{ - int r; - uInt hn = 0; /* hufts used in space */ - uIntf *v; /* work area for huft_build */ - - if ((v = (uIntf*)ZALLOC(z, 19, sizeof(uInt))) == Z_NULL) - return Z_MEM_ERROR; - r = huft_build(c, 19, 19, (uIntf*)Z_NULL, (uIntf*)Z_NULL, - tb, bb, hp, &hn, v); - if (r == Z_DATA_ERROR) - z->msg = (char*)"oversubscribed dynamic bit lengths tree"; - else if (r == Z_BUF_ERROR || *bb == 0) - { - z->msg = (char*)"incomplete dynamic bit lengths tree"; - r = Z_DATA_ERROR; - } - ZFREE(z, v); - return r; -} - - -int inflate_trees_dynamic(nl, nd, c, bl, bd, tl, td, hp, z) -uInt nl; /* number of literal/length codes */ -uInt nd; /* number of distance codes */ -uIntf *c; /* that many (total) code lengths */ -uIntf *bl; /* literal desired/actual bit depth */ -uIntf *bd; /* distance desired/actual bit depth */ -inflate_huft * FAR *tl; /* literal/length tree result */ -inflate_huft * FAR *td; /* distance tree result */ -inflate_huft *hp; /* space for trees */ -z_streamp z; /* for messages */ -{ - int r; - uInt hn = 0; /* hufts used in space */ - uIntf *v; /* work area for huft_build */ - - /* allocate work area */ - if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL) - return Z_MEM_ERROR; - - /* build literal/length tree */ - r = huft_build(c, nl, 257, cplens, cplext, tl, bl, hp, &hn, v); - if (r != Z_OK || *bl == 0) - { - if (r == Z_DATA_ERROR) - z->msg = (char*)"oversubscribed literal/length tree"; - else if (r != Z_MEM_ERROR) - { - z->msg = (char*)"incomplete literal/length tree"; - r = Z_DATA_ERROR; - } - ZFREE(z, v); - return r; - } - - /* build distance tree */ - r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, hp, &hn, v); - if (r != Z_OK || (*bd == 0 && nl > 257)) - { - if (r == Z_DATA_ERROR) - z->msg = (char*)"oversubscribed distance tree"; - else if (r == Z_BUF_ERROR) { -#ifdef PKZIP_BUG_WORKAROUND - r = Z_OK; - } -#else - z->msg = (char*)"incomplete distance tree"; - r = Z_DATA_ERROR; - } - else if (r != Z_MEM_ERROR) - { - z->msg = (char*)"empty distance tree with lengths"; - r = Z_DATA_ERROR; - } - ZFREE(z, v); - return r; -#endif - } - - /* done */ - ZFREE(z, v); - return Z_OK; -} - - -/* build fixed tables only once--keep them here */ -#ifdef BUILDFIXED -local int fixed_built = 0; -#define FIXEDH 544 /* number of hufts used by fixed tables */ -local inflate_huft fixed_mem[FIXEDH]; -local uInt fixed_bl; -local uInt fixed_bd; -local inflate_huft *fixed_tl; -local inflate_huft *fixed_td; -#else -#include "inffixed.h" -#endif - - -int inflate_trees_fixed(bl, bd, tl, td, z) -uIntf *bl; /* literal desired/actual bit depth */ -uIntf *bd; /* distance desired/actual bit depth */ -inflate_huft * FAR *tl; /* literal/length tree result */ -inflate_huft * FAR *td; /* distance tree result */ -z_streamp z; /* for memory allocation */ -{ -#ifdef BUILDFIXED - /* build fixed tables if not already */ - if (!fixed_built) - { - int k; /* temporary variable */ - uInt f = 0; /* number of hufts used in fixed_mem */ - uIntf *c; /* length list for huft_build */ - uIntf *v; /* work area for huft_build */ - - /* allocate memory */ - if ((c = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL) - return Z_MEM_ERROR; - if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL) - { - ZFREE(z, c); - return Z_MEM_ERROR; - } - - /* literal table */ - for (k = 0; k < 144; k++) - c[k] = 8; - for (; k < 256; k++) - c[k] = 9; - for (; k < 280; k++) - c[k] = 7; - for (; k < 288; k++) - c[k] = 8; - fixed_bl = 9; - huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl, - fixed_mem, &f, v); - - /* distance table */ - for (k = 0; k < 30; k++) - c[k] = 5; - fixed_bd = 5; - huft_build(c, 30, 0, cpdist, cpdext, &fixed_td, &fixed_bd, - fixed_mem, &f, v); - - /* done */ - ZFREE(z, v); - ZFREE(z, c); - fixed_built = 1; - } -#endif - *bl = fixed_bl; - *bd = fixed_bd; - *tl = fixed_tl; - *td = fixed_td; - return Z_OK; -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/inftrees.h b/contrib/vmap_extractor_v2/stormlib/zlib/inftrees.h deleted file mode 100644 index 04b73b7296a..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/inftrees.h +++ /dev/null @@ -1,58 +0,0 @@ -/* inftrees.h -- header to use inftrees.c - * Copyright (C) 1995-2002 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. - */ - -/* Huffman code lookup table entry--this entry is four bytes for machines - that have 16-bit pointers (e.g. PC's in the small or medium model). */ - -typedef struct inflate_huft_s FAR inflate_huft; - -struct inflate_huft_s { - union { - struct { - Byte Exop; /* number of extra bits or operation */ - Byte Bits; /* number of bits in this code or subcode */ - } what; - uInt pad; /* pad structure to a power of 2 (4 bytes for */ - } word; /* 16-bit, 8 bytes for 32-bit int's) */ - uInt base; /* literal, length base, distance base, - or table offset */ -}; - -/* Maximum size of dynamic tree. The maximum found in a long but non- - exhaustive search was 1004 huft structures (850 for length/literals - and 154 for distances, the latter actually the result of an - exhaustive search). The actual maximum is not known, but the - value below is more than safe. */ -#define MANY 1440 - -extern int inflate_trees_bits OF(( - uIntf *, /* 19 code lengths */ - uIntf *, /* bits tree desired/actual depth */ - inflate_huft * FAR *, /* bits tree result */ - inflate_huft *, /* space for trees */ - z_streamp)); /* for messages */ - -extern int inflate_trees_dynamic OF(( - uInt, /* number of literal/length codes */ - uInt, /* number of distance codes */ - uIntf *, /* that many (total) code lengths */ - uIntf *, /* literal desired/actual bit depth */ - uIntf *, /* distance desired/actual bit depth */ - inflate_huft * FAR *, /* literal/length tree result */ - inflate_huft * FAR *, /* distance tree result */ - inflate_huft *, /* space for trees */ - z_streamp)); /* for messages */ - -extern int inflate_trees_fixed OF(( - uIntf *, /* literal desired/actual bit depth */ - uIntf *, /* distance desired/actual bit depth */ - inflate_huft * FAR *, /* literal/length tree result */ - inflate_huft * FAR *, /* distance tree result */ - z_streamp)); /* for memory allocation */ diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/infutil.c b/contrib/vmap_extractor_v2/stormlib/zlib/infutil.c deleted file mode 100644 index 9a076221f2a..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/infutil.c +++ /dev/null @@ -1,87 +0,0 @@ -/* inflate_util.c -- data and routines common to blocks and codes - * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "infblock.h" -#include "inftrees.h" -#include "infcodes.h" -#include "infutil.h" - -struct inflate_codes_state {int dummy;}; /* for buggy compilers */ - -/* And'ing with mask[n] masks the lower n bits */ -uInt inflate_mask[17] = { - 0x0000, - 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, - 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff -}; - - -/* copy as much as possible from the sliding window to the output area */ -int inflate_flush(s, z, r) -inflate_blocks_statef *s; -z_streamp z; -int r; -{ - uInt n; - Bytef *p; - Bytef *q; - - /* local copies of source and destination pointers */ - p = z->next_out; - q = s->read; - - /* compute number of bytes to copy as far as end of window */ - n = (uInt)((q <= s->write ? s->write : s->end) - q); - if (n > z->avail_out) n = z->avail_out; - if (n && r == Z_BUF_ERROR) r = Z_OK; - - /* update counters */ - z->avail_out -= n; - z->total_out += n; - - /* update check information */ - if (s->checkfn != Z_NULL) - z->adler = s->check = (*s->checkfn)(s->check, q, n); - - /* copy as far as end of window */ - zmemcpy(p, q, n); - p += n; - q += n; - - /* see if more to copy at beginning of window */ - if (q == s->end) - { - /* wrap pointers */ - q = s->window; - if (s->write == s->end) - s->write = s->window; - - /* compute bytes to copy */ - n = (uInt)(s->write - q); - if (n > z->avail_out) n = z->avail_out; - if (n && r == Z_BUF_ERROR) r = Z_OK; - - /* update counters */ - z->avail_out -= n; - z->total_out += n; - - /* update check information */ - if (s->checkfn != Z_NULL) - z->adler = s->check = (*s->checkfn)(s->check, q, n); - - /* copy */ - zmemcpy(p, q, n); - p += n; - q += n; - } - - /* update pointers */ - z->next_out = p; - s->read = q; - - /* done */ - return r; -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/infutil.h b/contrib/vmap_extractor_v2/stormlib/zlib/infutil.h deleted file mode 100644 index 4401df82fc8..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/infutil.h +++ /dev/null @@ -1,98 +0,0 @@ -/* infutil.h -- types and macros common to blocks and codes - * Copyright (C) 1995-2002 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 _INFUTIL_H -#define _INFUTIL_H - -typedef enum { - TYPE, /* get type bits (3, including end bit) */ - LENS, /* get lengths for stored */ - STORED, /* processing stored block */ - TABLE, /* get table lengths */ - BTREE, /* get bit lengths tree for a dynamic block */ - DTREE, /* get length, distance trees for a dynamic block */ - CODES, /* processing fixed or dynamic block */ - DRY, /* output remaining window bytes */ - DONE, /* finished last block, done */ - BAD} /* got a data error--stuck here */ -inflate_block_mode; - -/* inflate blocks semi-private state */ -struct inflate_blocks_state { - - /* mode */ - inflate_block_mode mode; /* current inflate_block mode */ - - /* mode dependent information */ - union { - uInt left; /* if STORED, bytes left to copy */ - struct { - uInt table; /* table lengths (14 bits) */ - uInt index; /* index into blens (or border) */ - uIntf *blens; /* bit lengths of codes */ - uInt bb; /* bit length tree depth */ - inflate_huft *tb; /* bit length decoding tree */ - } trees; /* if DTREE, decoding info for trees */ - struct { - inflate_codes_statef - *codes; - } decode; /* if CODES, current state */ - } sub; /* submode */ - uInt last; /* true if this block is the last block */ - - /* mode independent information */ - uInt bitk; /* bits in bit buffer */ - uLong bitb; /* bit buffer */ - inflate_huft *hufts; /* single malloc for tree space */ - Bytef *window; /* sliding window */ - Bytef *end; /* one byte after sliding window */ - Bytef *read; /* window read pointer */ - Bytef *write; /* window write pointer */ - check_func checkfn; /* check function */ - uLong check; /* check on output */ - -}; - - -/* defines for inflate input/output */ -/* update pointers and return */ -#define UPDBITS {s->bitb=b;s->bitk=k;} -#define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;} -#define UPDOUT {s->write=q;} -#define UPDATE {UPDBITS UPDIN UPDOUT} -#define LEAVE {UPDATE return inflate_flush(s,z,r);} -/* get bytes and bits */ -#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;} -#define NEEDBYTE {if(n)r=Z_OK;else LEAVE} -#define NEXTBYTE (n--,*p++) -#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<>=(j);k-=(j);} -/* output bytes */ -#define WAVAIL (uInt)(qread?s->read-q-1:s->end-q) -#define LOADOUT {q=s->write;m=(uInt)WAVAIL;} -#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}} -#define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT} -#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;} -#define OUTBYTE(a) {*q++=(Byte)(a);m--;} -/* load local pointers */ -#define LOAD {LOADIN LOADOUT} - -/* masks for lower bits (size given to avoid silly warnings with Visual C++) */ -extern uInt inflate_mask[17]; - -/* copy as much as possible from the sliding window to the output area */ -extern int inflate_flush OF(( - inflate_blocks_statef *, - z_streamp , - int)); - -struct internal_state {int dummy;}; /* for buggy compilers */ - -#endif diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/maketree.c b/contrib/vmap_extractor_v2/stormlib/zlib/maketree.c deleted file mode 100644 index a16d4b14608..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/maketree.c +++ /dev/null @@ -1,85 +0,0 @@ -/* maketree.c -- make inffixed.h table for decoding fixed codes - * Copyright (C) 1995-2002 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. - */ - -/* This program is included in the distribution for completeness. - You do not need to compile or run this program since inffixed.h - is already included in the distribution. To use this program - you need to compile zlib with BUILDFIXED defined and then compile - and link this program with the zlib library. Then the output of - this program can be piped to inffixed.h. */ - -#include -#include -#include "zutil.h" -#include "inftrees.h" - -/* simplify the use of the inflate_huft type with some defines */ -#define exop word.what.Exop -#define bits word.what.Bits - -/* generate initialization table for an inflate_huft structure array */ -void maketree(uInt b, inflate_huft *t) -{ - int i, e; - - i = 0; - while (1) - { - e = t[i].exop; - if (e && (e & (16+64)) == 0) /* table pointer */ - { - fprintf(stderr, "maketree: cannot initialize sub-tables!\n"); - exit(1); - } - if (i % 4 == 0) - printf("\n "); - printf(" {{{%u,%u}},%u}", t[i].exop, t[i].bits, t[i].base); - if (++i == (1< -#include "zlib.h" - -#ifdef STDC -# include -# include -#else - extern void exit OF((int)); -#endif - -#ifdef USE_MMAP -# include -# include -# include -#endif - -#if defined(MSDOS) || defined(OS2) || defined(WIN32) -# include -# include -# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) -#else -# define SET_BINARY_MODE(file) -#endif - -#ifdef VMS -# define unlink delete -# define GZ_SUFFIX "-gz" -#endif -#ifdef RISCOS -# define unlink remove -# define GZ_SUFFIX "-gz" -# define fileno(file) file->__file -#endif -#if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include /* for fileno */ -#endif - -#ifndef WIN32 /* unlink already in stdio.h for WIN32 */ - extern int unlink OF((const char *)); -#endif - -#ifndef GZ_SUFFIX -# define GZ_SUFFIX ".gz" -#endif -#define SUFFIX_LEN (sizeof(GZ_SUFFIX)-1) - -#define BUFLEN 16384 -#define MAX_NAME_LEN 1024 - -#ifdef MAXSEG_64K -# define local static - /* Needed for systems with limitation on stack size. */ -#else -# define local -#endif - -char *prog; - -void error OF((const char *msg)); -void gz_compress OF((FILE *in, gzFile out)); -#ifdef USE_MMAP -int gz_compress_mmap OF((FILE *in, gzFile out)); -#endif -void gz_uncompress OF((gzFile in, FILE *out)); -void file_compress OF((char *file, char *mode)); -void file_uncompress OF((char *file)); -int main OF((int argc, char *argv[])); - -/* =========================================================================== - * Display error message and exit - */ -void error(msg) - const char *msg; -{ - fprintf(stderr, "%s: %s\n", prog, msg); - exit(1); -} - -/* =========================================================================== - * Compress input to output then close both files. - */ - -void gz_compress(in, out) - FILE *in; - gzFile out; -{ - local char buf[BUFLEN]; - int len; - int err; - -#ifdef USE_MMAP - /* Try first compressing with mmap. If mmap fails (minigzip used in a - * pipe), use the normal fread loop. - */ - if (gz_compress_mmap(in, out) == Z_OK) return; -#endif - for (;;) { - len = fread(buf, 1, sizeof(buf), in); - if (ferror(in)) { - perror("fread"); - exit(1); - } - if (len == 0) break; - - if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err)); - } - fclose(in); - if (gzclose(out) != Z_OK) error("failed gzclose"); -} - -#ifdef USE_MMAP /* MMAP version, Miguel Albrecht */ - -/* Try compressing the input file at once using mmap. Return Z_OK if - * if success, Z_ERRNO otherwise. - */ -int gz_compress_mmap(in, out) - FILE *in; - gzFile out; -{ - int len; - int err; - int ifd = fileno(in); - caddr_t buf; /* mmap'ed buffer for the entire input file */ - off_t buf_len; /* length of the input file */ - struct stat sb; - - /* Determine the size of the file, needed for mmap: */ - if (fstat(ifd, &sb) < 0) return Z_ERRNO; - buf_len = sb.st_size; - if (buf_len <= 0) return Z_ERRNO; - - /* Now do the actual mmap: */ - buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0); - if (buf == (caddr_t)(-1)) return Z_ERRNO; - - /* Compress the whole file at once: */ - len = gzwrite(out, (char *)buf, (unsigned)buf_len); - - if (len != (int)buf_len) error(gzerror(out, &err)); - - munmap(buf, buf_len); - fclose(in); - if (gzclose(out) != Z_OK) error("failed gzclose"); - return Z_OK; -} -#endif /* USE_MMAP */ - -/* =========================================================================== - * Uncompress input to output then close both files. - */ -void gz_uncompress(in, out) - gzFile in; - FILE *out; -{ - local char buf[BUFLEN]; - int len; - int err; - - for (;;) { - len = gzread(in, buf, sizeof(buf)); - if (len < 0) error (gzerror(in, &err)); - if (len == 0) break; - - if ((int)fwrite(buf, 1, (unsigned)len, out) != len) { - error("failed fwrite"); - } - } - if (fclose(out)) error("failed fclose"); - - if (gzclose(in) != Z_OK) error("failed gzclose"); -} - - -/* =========================================================================== - * Compress the given file: create a corresponding .gz file and remove the - * original. - */ -void file_compress(file, mode) - char *file; - char *mode; -{ - local char outfile[MAX_NAME_LEN]; - FILE *in; - gzFile out; - - strcpy(outfile, file); - strcat(outfile, GZ_SUFFIX); - - in = fopen(file, "rb"); - if (in == NULL) { - perror(file); - exit(1); - } - out = gzopen(outfile, mode); - if (out == NULL) { - fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile); - exit(1); - } - gz_compress(in, out); - - unlink(file); -} - - -/* =========================================================================== - * Uncompress the given file and remove the original. - */ -void file_uncompress(file) - char *file; -{ - local char buf[MAX_NAME_LEN]; - char *infile, *outfile; - FILE *out; - gzFile in; - int len = strlen(file); - - strcpy(buf, file); - - if (len > SUFFIX_LEN && strcmp(file+len-SUFFIX_LEN, GZ_SUFFIX) == 0) { - infile = file; - outfile = buf; - outfile[len-3] = '\0'; - } else { - outfile = file; - infile = buf; - strcat(infile, GZ_SUFFIX); - } - in = gzopen(infile, "rb"); - if (in == NULL) { - fprintf(stderr, "%s: can't gzopen %s\n", prog, infile); - exit(1); - } - out = fopen(outfile, "wb"); - if (out == NULL) { - perror(file); - exit(1); - } - - gz_uncompress(in, out); - - unlink(infile); -} - - -/* =========================================================================== - * Usage: minigzip [-d] [-f] [-h] [-1 to -9] [files...] - * -d : decompress - * -f : compress with Z_FILTERED - * -h : compress with Z_HUFFMAN_ONLY - * -1 to -9 : compression level - */ - -int main(argc, argv) - int argc; - char *argv[]; -{ - int uncompr = 0; - gzFile file; - char outmode[20]; - - strcpy(outmode, "wb6 "); - - prog = argv[0]; - argc--, argv++; - - while (argc > 0) { - if (strcmp(*argv, "-d") == 0) - uncompr = 1; - else if (strcmp(*argv, "-f") == 0) - outmode[3] = 'f'; - else if (strcmp(*argv, "-h") == 0) - outmode[3] = 'h'; - else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' && - (*argv)[2] == 0) - outmode[2] = (*argv)[1]; - else - break; - argc--, argv++; - } - if (argc == 0) { - SET_BINARY_MODE(stdin); - SET_BINARY_MODE(stdout); - if (uncompr) { - file = gzdopen(fileno(stdin), "rb"); - if (file == NULL) error("can't gzdopen stdin"); - gz_uncompress(file, stdout); - } else { - file = gzdopen(fileno(stdout), outmode); - if (file == NULL) error("can't gzdopen stdout"); - gz_compress(stdin, file); - } - } else { - do { - if (uncompr) { - file_uncompress(*argv); - } else { - file_compress(*argv, outmode); - } - } while (argv++, --argc); - } - exit(0); - return 0; /* to avoid warning */ -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.b32 b/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.b32 deleted file mode 100644 index f476da91649..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.b32 +++ /dev/null @@ -1,104 +0,0 @@ -# Makefile for zlib -# Borland C++ - -# This version of the zlib makefile was adapted by Chris Young for use -# with Borland C 4.5x with the Dos Power Pack for a 32-bit protected mode -# flat memory model. It was created for use with POV-Ray ray tracer and -# you may choose to edit the CFLAGS to suit your needs but the -# switches -WX and -DMSDOS are required. -# -- Chris Young 76702.1655@compuserve.com - -# To use, do "make -fmakefile.b32" - -# See zconf.h for details about the memory requirements. - -# ------------- Borland C++ ------------- -MODEL=-WX -CFLAGS= $(MODEL) -P-C -K -N- -k- -d -3 -r- -v- -f -DMSDOS -CC=bcc32 -LD=bcc32 -LIB=tlib -LDFLAGS= $(MODEL) -O=.obj - -# variables -OBJ1 = adler32$(O) compress$(O) crc32$(O) gzio$(O) uncompr$(O) deflate$(O) \ - trees$(O) -OBJP1 = adler32$(O)+compress$(O)+crc32$(O)+gzio$(O)+uncompr$(O)+deflate$(O)+\ - trees$(O) -OBJ2 = zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O) \ - infutil$(O) inffast$(O) -OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\ - infutil$(O)+inffast$(O) - -all: test - -adler32.obj: adler32.c zlib.h zconf.h - $(CC) -c $(CFLAGS) $*.c - -compress.obj: compress.c zlib.h zconf.h - $(CC) -c $(CFLAGS) $*.c - -crc32.obj: crc32.c zlib.h zconf.h - $(CC) -c $(CFLAGS) $*.c - -deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h - $(CC) -c $(CFLAGS) $*.c - -gzio.obj: gzio.c zutil.h zlib.h zconf.h - $(CC) -c $(CFLAGS) $*.c - -infblock.obj: infblock.c zutil.h zlib.h zconf.h infblock.h inftrees.h\ - infcodes.h infutil.h - $(CC) -c $(CFLAGS) $*.c - -infcodes.obj: infcodes.c zutil.h zlib.h zconf.h inftrees.h infutil.h\ - infcodes.h inffast.h - $(CC) -c $(CFLAGS) $*.c - -inflate.obj: inflate.c zutil.h zlib.h zconf.h infblock.h - $(CC) -c $(CFLAGS) $*.c - -inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h - $(CC) -c $(CFLAGS) $*.c - -infutil.obj: infutil.c zutil.h zlib.h zconf.h inftrees.h infutil.h - $(CC) -c $(CFLAGS) $*.c - -inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h - $(CC) -c $(CFLAGS) $*.c - -trees.obj: trees.c deflate.h zutil.h zlib.h zconf.h - $(CC) -c $(CFLAGS) $*.c - -uncompr.obj: uncompr.c zlib.h zconf.h - $(CC) -c $(CFLAGS) $*.c - -zutil.obj: zutil.c zutil.h zlib.h zconf.h - $(CC) -c $(CFLAGS) $*.c - -example.obj: example.c zlib.h zconf.h - $(CC) -c $(CFLAGS) $*.c - -minigzip.obj: minigzip.c zlib.h zconf.h - $(CC) -c $(CFLAGS) $*.c - -# we must cut the command line to fit in the MS/DOS 128 byte limit: -zlib.lib: $(OBJ1) $(OBJ2) - del zlib.lib - $(LIB) zlib +$(OBJP1) - $(LIB) zlib +$(OBJP2) - -example.exe: example.obj zlib.lib - $(LD) $(LDFLAGS) example.obj zlib.lib - -minigzip.exe: minigzip.obj zlib.lib - $(LD) $(LDFLAGS) minigzip.obj zlib.lib - -test: example.exe minigzip.exe - example - echo hello world | minigzip | minigzip -d - -#clean: -# del *.obj -# del *.exe diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.bor b/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.bor deleted file mode 100644 index f5651b40fec..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.bor +++ /dev/null @@ -1,125 +0,0 @@ -# Makefile for zlib -# Borland C++ ************ UNTESTED *********** - -# To use, do "make -fmakefile.bor" -# To compile in small model, set below: MODEL=s - -# WARNING: the small model is supported but only for small values of -# MAX_WBITS and MAX_MEM_LEVEL. For example: -# -DMAX_WBITS=11 -DDEF_WBITS=11 -DMAX_MEM_LEVEL=3 -# If you wish to reduce the memory requirements (default 256K for big -# objects plus a few K), you can add to the LOC macro below: -# -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 -# See zconf.h for details about the memory requirements. - -# ------------- Turbo C++, Borland C++ ------------- - -# Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) -# should be added to the environment via "set LOCAL_ZLIB=-DFOO" or added -# to the declaration of LOC here: -LOC = $(LOCAL_ZLIB) - -# Type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc. -CPU_TYP = 0 - -# Memory model: one of s, m, c, l (small, medium, compact, large) -MODEL=l - -CC=bcc -# replace bcc with tcc for Turbo C++ 1.0, with bcc32 for the 32 bit version -LD=$(CC) -AR=tlib - -# compiler flags -CFLAGS=-O2 -Z -m$(MODEL) $(LOC) -# replace "-O2" by "-O -G -a -d" for Turbo C++ 1.0 - -LDFLAGS=-m$(MODEL) - -O=.obj - -# variables -OBJ1 = adler32$(O) compress$(O) crc32$(O) gzio$(O) uncompr$(O) deflate$(O) \ - trees$(O) -OBJP1 = adler32$(O)+compress$(O)+crc32$(O)+gzio$(O)+uncompr$(O)+deflate$(O)+\ - trees$(O) -OBJ2 = zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O) \ - infutil$(O) inffast$(O) -OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\ - infutil$(O)+inffast$(O) - -ZLIB_H = zlib.h zconf.h -ZUTIL_H = zutil.h $(ZLIB_H) - -ZLIB_LIB = zlib_$(MODEL).lib - -all: test - -# individual dependencies and action rules: -adler32.obj: adler32.c $(ZLIB_H) - $(CC) -c $(CFLAGS) $*.c - -compress.obj: compress.c $(ZLIB_H) - $(CC) -c $(CFLAGS) $*.c - -crc32.obj: crc32.c $(ZLIB_H) - $(CC) -c $(CFLAGS) $*.c - -deflate.obj: deflate.c deflate.h $(ZUTIL_H) - $(CC) -c $(CFLAGS) $*.c - -gzio.obj: gzio.c $(ZUTIL_H) - $(CC) -c $(CFLAGS) $*.c - -infblock.obj: infblock.c $(ZUTIL_H) infblock.h inftrees.h infcodes.h infutil.h - $(CC) -c $(CFLAGS) $*.c - -infcodes.obj: infcodes.c $(ZUTIL_H) inftrees.h infutil.h infcodes.h inffast.h - $(CC) -c $(CFLAGS) $*.c - -inflate.obj: inflate.c $(ZUTIL_H) infblock.h - $(CC) -c $(CFLAGS) $*.c - -inftrees.obj: inftrees.c $(ZUTIL_H) inftrees.h - $(CC) -c $(CFLAGS) $*.c - -infutil.obj: infutil.c $(ZUTIL_H) inftrees.h infutil.h - $(CC) -c $(CFLAGS) $*.c - -inffast.obj: inffast.c $(ZUTIL_H) inftrees.h infutil.h inffast.h - $(CC) -c $(CFLAGS) $*.c - -trees.obj: trees.c deflate.h $(ZUTIL_H) - $(CC) -c $(CFLAGS) $*.c - -uncompr.obj: uncompr.c $(ZLIB_H) - $(CC) -c $(CFLAGS) $*.c - -zutil.obj: zutil.c $(ZUTIL_H) - $(CC) -c $(CFLAGS) $*.c - -example.obj: example.c $(ZLIB_H) - $(CC) -c $(CFLAGS) $*.c - -minigzip.obj: minigzip.c $(ZLIB_H) - $(CC) -c $(CFLAGS) $*.c - -# we must cut the command line to fit in the MS/DOS 128 byte limit: -$(ZLIB_LIB): $(OBJ1) $(OBJ2) - del $(ZLIB_LIB) - $(AR) $(ZLIB_LIB) +$(OBJP1) - $(AR) $(ZLIB_LIB) +$(OBJP2) - -example.exe: example.obj $(ZLIB_LIB) - $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) - -minigzip.exe: minigzip.obj $(ZLIB_LIB) - $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) - -test: example.exe minigzip.exe - example - echo hello world | minigzip | minigzip -d - -#clean: -# del *.obj -# del *.exe diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.dj2 b/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.dj2 deleted file mode 100644 index 0ab431c8a11..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.dj2 +++ /dev/null @@ -1,100 +0,0 @@ -# Makefile for zlib. Modified for djgpp v2.0 by F. J. Donahoe, 3/15/96. -# Copyright (C) 1995-1998 Jean-loup Gailly. -# For conditions of distribution and use, see copyright notice in zlib.h - -# To compile, or to compile and test, type: -# -# make -fmakefile.dj2; make test -fmakefile.dj2 -# -# To install libz.a, zconf.h and zlib.h in the djgpp directories, type: -# -# make install -fmakefile.dj2 -# -# after first defining LIBRARY_PATH and INCLUDE_PATH in djgpp.env as -# in the sample below if the pattern of the DJGPP distribution is to -# be followed. Remember that, while 'es around <=> are ignored in -# makefiles, they are *not* in batch files or in djgpp.env. -# - - - - - -# [make] -# INCLUDE_PATH=%\>;INCLUDE_PATH%%\DJDIR%\include -# LIBRARY_PATH=%\>;LIBRARY_PATH%%\DJDIR%\lib -# BUTT=-m486 -# - - - - - -# Alternately, these variables may be defined below, overriding the values -# in djgpp.env, as -# INCLUDE_PATH=c:\usr\include -# LIBRARY_PATH=c:\usr\lib - -CC=gcc - -#CFLAGS=-MMD -O -#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 -#CFLAGS=-MMD -g -DDEBUG -CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ - -Wstrict-prototypes -Wmissing-prototypes - -# If cp.exe is available, replace "copy /Y" with "cp -fp" . -CP=copy /Y -# If gnu install.exe is available, replace $(CP) with ginstall. -INSTALL=$(CP) -# The default value of RM is "rm -f." If "rm.exe" is found, comment out: -RM=del -LDLIBS=-L. -lz -LD=$(CC) -s -o -LDSHARED=$(CC) - -INCL=zlib.h zconf.h -LIBS=libz.a - -AR=ar rcs - -prefix=/usr/local -exec_prefix = $(prefix) - -OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ - zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o - -TEST_OBJS = example.o minigzip.o - -all: example.exe minigzip.exe - -test: all - ./example - echo hello world | .\minigzip | .\minigzip -d - -%.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - -libz.a: $(OBJS) - $(AR) $@ $(OBJS) - -%.exe : %.o $(LIBS) - $(LD) $@ $< $(LDLIBS) - -# INCLUDE_PATH and LIBRARY_PATH were set for [make] in djgpp.env . - -.PHONY : uninstall clean - -install: $(INCL) $(LIBS) - -@if not exist $(INCLUDE_PATH)\nul mkdir $(INCLUDE_PATH) - -@if not exist $(LIBRARY_PATH)\nul mkdir $(LIBRARY_PATH) - $(INSTALL) zlib.h $(INCLUDE_PATH) - $(INSTALL) zconf.h $(INCLUDE_PATH) - $(INSTALL) libz.a $(LIBRARY_PATH) - -uninstall: - $(RM) $(INCLUDE_PATH)\zlib.h - $(RM) $(INCLUDE_PATH)\zconf.h - $(RM) $(LIBRARY_PATH)\libz.a - -clean: - $(RM) *.d - $(RM) *.o - $(RM) *.exe - $(RM) libz.a - $(RM) foo.gz - -DEPS := $(wildcard *.d) -ifneq ($(DEPS),) -include $(DEPS) -endif diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.emx b/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.emx deleted file mode 100644 index 0e5e5cc4338..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.emx +++ /dev/null @@ -1,69 +0,0 @@ -# Makefile for zlib. Modified for emx 0.9c by Chr. Spieler, 6/17/98. -# Copyright (C) 1995-1998 Jean-loup Gailly. -# For conditions of distribution and use, see copyright notice in zlib.h - -# To compile, or to compile and test, type: -# -# make -fmakefile.emx; make test -fmakefile.emx -# - -CC=gcc - -#CFLAGS=-MMD -O -#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 -#CFLAGS=-MMD -g -DDEBUG -CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ - -Wstrict-prototypes -Wmissing-prototypes - -# If cp.exe is available, replace "copy /Y" with "cp -fp" . -CP=copy /Y -# If gnu install.exe is available, replace $(CP) with ginstall. -INSTALL=$(CP) -# The default value of RM is "rm -f." If "rm.exe" is found, comment out: -RM=del -LDLIBS=-L. -lzlib -LD=$(CC) -s -o -LDSHARED=$(CC) - -INCL=zlib.h zconf.h -LIBS=zlib.a - -AR=ar rcs - -prefix=/usr/local -exec_prefix = $(prefix) - -OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ - zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o - -TEST_OBJS = example.o minigzip.o - -all: example.exe minigzip.exe - -test: all - ./example - echo hello world | .\minigzip | .\minigzip -d - -%.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - -zlib.a: $(OBJS) - $(AR) $@ $(OBJS) - -%.exe : %.o $(LIBS) - $(LD) $@ $< $(LDLIBS) - - -.PHONY : clean - -clean: - $(RM) *.d - $(RM) *.o - $(RM) *.exe - $(RM) zlib.a - $(RM) foo.gz - -DEPS := $(wildcard *.d) -ifneq ($(DEPS),) -include $(DEPS) -endif diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.msc b/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.msc deleted file mode 100644 index 562201d87ea..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.msc +++ /dev/null @@ -1,121 +0,0 @@ -# Makefile for zlib -# Microsoft C 5.1 or later - -# To use, do "make makefile.msc" -# To compile in small model, set below: MODEL=S - -# If you wish to reduce the memory requirements (default 256K for big -# objects plus a few K), you can add to the LOC macro below: -# -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 -# See zconf.h for details about the memory requirements. - -# ------------- Microsoft C 5.1 and later ------------- - -# Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) -# should be added to the environment via "set LOCAL_ZLIB=-DFOO" or added -# to the declaration of LOC here: -LOC = $(LOCAL_ZLIB) - -# Type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc. -CPU_TYP = 0 - -# Memory model: one of S, M, C, L (small, medium, compact, large) -MODEL=L - -CC=cl -CFLAGS=-nologo -A$(MODEL) -G$(CPU_TYP) -W3 -Oait -Gs $(LOC) -#-Ox generates bad code with MSC 5.1 -LIB_CFLAGS=-Zl $(CFLAGS) - -LD=link -LDFLAGS=/noi/e/st:0x1500/noe/farcall/packcode -# "/farcall/packcode" are only useful for `large code' memory models -# but should be a "no-op" for small code models. - -O=.obj - -# variables -OBJ1 = adler32$(O) compress$(O) crc32$(O) gzio$(O) uncompr$(O) deflate$(O) \ - trees$(O) -OBJP1 = adler32$(O)+compress$(O)+crc32$(O)+gzio$(O)+uncompr$(O)+deflate$(O)+\ - trees$(O) -OBJ2 = zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O) \ - infutil$(O) inffast$(O) -OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\ - infutil$(O)+inffast$(O) - -ZLIB_H = zlib.h zconf.h -ZUTIL_H = zutil.h $(ZLIB_H) - -ZLIB_LIB = zlib_$(MODEL).lib - -all: $(ZLIB_LIB) example.exe minigzip.exe - -# individual dependencies and action rules: -adler32.obj: adler32.c $(ZLIB_H) - $(CC) -c $(LIB_CFLAGS) $*.c - -compress.obj: compress.c $(ZLIB_H) - $(CC) -c $(LIB_CFLAGS) $*.c - -crc32.obj: crc32.c $(ZLIB_H) - $(CC) -c $(LIB_CFLAGS) $*.c - -deflate.obj: deflate.c deflate.h $(ZUTIL_H) - $(CC) -c $(LIB_CFLAGS) $*.c - -gzio.obj: gzio.c $(ZUTIL_H) - $(CC) -c $(LIB_CFLAGS) $*.c - -infblock.obj: infblock.c $(ZUTIL_H) infblock.h inftrees.h infcodes.h infutil.h - $(CC) -c $(LIB_CFLAGS) $*.c - -infcodes.obj: infcodes.c $(ZUTIL_H) inftrees.h infutil.h infcodes.h inffast.h - $(CC) -c $(LIB_CFLAGS) $*.c - -inflate.obj: inflate.c $(ZUTIL_H) infblock.h - $(CC) -c $(LIB_CFLAGS) $*.c - -inftrees.obj: inftrees.c $(ZUTIL_H) inftrees.h - $(CC) -c $(LIB_CFLAGS) $*.c - -infutil.obj: infutil.c $(ZUTIL_H) inftrees.h infutil.h - $(CC) -c $(LIB_CFLAGS) $*.c - -inffast.obj: inffast.c $(ZUTIL_H) inftrees.h infutil.h inffast.h - $(CC) -c $(LIB_CFLAGS) $*.c - -trees.obj: trees.c deflate.h $(ZUTIL_H) - $(CC) -c $(LIB_CFLAGS) $*.c - -uncompr.obj: uncompr.c $(ZLIB_H) - $(CC) -c $(LIB_CFLAGS) $*.c - -zutil.obj: zutil.c $(ZUTIL_H) - $(CC) -c $(LIB_CFLAGS) $*.c - -example.obj: example.c $(ZLIB_H) - $(CC) -c $(CFLAGS) $*.c - -minigzip.obj: minigzip.c $(ZLIB_H) - $(CC) -c $(CFLAGS) $*.c - -# we must cut the command line to fit in the MS/DOS 128 byte limit: -$(ZLIB_LIB): $(OBJ1) $(OBJ2) - if exist $(ZLIB_LIB) del $(ZLIB_LIB) - lib $(ZLIB_LIB) $(OBJ1); - lib $(ZLIB_LIB) $(OBJ2); - -example.exe: example.obj $(ZLIB_LIB) - $(LD) $(LDFLAGS) example.obj,,,$(ZLIB_LIB); - -minigzip.exe: minigzip.obj $(ZLIB_LIB) - $(LD) $(LDFLAGS) minigzip.obj,,,$(ZLIB_LIB); - -test: example.exe minigzip.exe - example - echo hello world | minigzip | minigzip -d - -#clean: -# del *.obj -# del *.exe diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.tc b/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.tc deleted file mode 100644 index 63e0550359f..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.tc +++ /dev/null @@ -1,108 +0,0 @@ -# Makefile for zlib -# TurboC 2.0 - -# To use, do "make -fmakefile.tc" -# To compile in small model, set below: MODEL=-ms - -# WARNING: the small model is supported but only for small values of -# MAX_WBITS and MAX_MEM_LEVEL. For example: -# -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3 -# If you wish to reduce the memory requirements (default 256K for big -# objects plus a few K), you can add to CFLAGS below: -# -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 -# See zconf.h for details about the memory requirements. - -# ------------- Turbo C 2.0 ------------- -MODEL=l -# CFLAGS=-O2 -G -Z -m$(MODEL) -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3 -CFLAGS=-O2 -G -Z -m$(MODEL) -CC=tcc -I\tc\include -LD=tcc -L\tc\lib -AR=tlib -LDFLAGS=-m$(MODEL) -f- -O=.obj - -# variables -OBJ1 = adler32$(O) compress$(O) crc32$(O) gzio$(O) uncompr$(O) deflate$(O) \ - trees$(O) -OBJP1 = adler32$(O)+compress$(O)+crc32$(O)+gzio$(O)+uncompr$(O)+deflate$(O)+\ - trees$(O) -OBJ2 = zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O) \ - infutil$(O) inffast$(O) -OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\ - infutil$(O)+inffast$(O) - -ZLIB_H = zlib.h zconf.h -ZUTIL_H = zutil.h $(ZLIB_H) - -ZLIB_LIB = zlib_$(MODEL).lib - -all: test - -adler32.obj: adler32.c $(ZLIB_H) - $(CC) -c $(CFLAGS) $*.c - -compress.obj: compress.c $(ZLIB_H) - $(CC) -c $(CFLAGS) $*.c - -crc32.obj: crc32.c $(ZLIB_H) - $(CC) -c $(CFLAGS) $*.c - -deflate.obj: deflate.c deflate.h $(ZUTIL_H) - $(CC) -c $(CFLAGS) $*.c - -gzio.obj: gzio.c $(ZUTIL_H) - $(CC) -c $(CFLAGS) $*.c - -infblock.obj: infblock.c $(ZUTIL_H) infblock.h inftrees.h infcodes.h infutil.h - $(CC) -c $(CFLAGS) $*.c - -infcodes.obj: infcodes.c $(ZUTIL_H) inftrees.h infutil.h infcodes.h inffast.h - $(CC) -c $(CFLAGS) $*.c - -inflate.obj: inflate.c $(ZUTIL_H) infblock.h - $(CC) -c $(CFLAGS) $*.c - -inftrees.obj: inftrees.c $(ZUTIL_H) inftrees.h - $(CC) -c $(CFLAGS) $*.c - -infutil.obj: infutil.c $(ZUTIL_H) inftrees.h infutil.h - $(CC) -c $(CFLAGS) $*.c - -inffast.obj: inffast.c $(ZUTIL_H) inftrees.h infutil.h inffast.h - $(CC) -c $(CFLAGS) $*.c - -trees.obj: trees.c deflate.h $(ZUTIL_H) - $(CC) -c $(CFLAGS) $*.c - -uncompr.obj: uncompr.c $(ZLIB_H) - $(CC) -c $(CFLAGS) $*.c - -zutil.obj: zutil.c $(ZUTIL_H) - $(CC) -c $(CFLAGS) $*.c - -example.obj: example.c $(ZLIB_H) - $(CC) -c $(CFLAGS) $*.c - -minigzip.obj: minigzip.c $(ZLIB_H) - $(CC) -c $(CFLAGS) $*.c - -# we must cut the command line to fit in the MS/DOS 128 byte limit: -$(ZLIB_LIB): $(OBJ1) $(OBJ2) - del $(ZLIB_LIB) - $(AR) $(ZLIB_LIB) +$(OBJP1) - $(AR) $(ZLIB_LIB) +$(OBJP2) - -example.exe: example.obj $(ZLIB_LIB) - $(LD) $(LDFLAGS) -eexample.exe example.obj $(ZLIB_LIB) - -minigzip.exe: minigzip.obj $(ZLIB_LIB) - $(LD) $(LDFLAGS) -eminigzip.exe minigzip.obj $(ZLIB_LIB) - -test: example.exe minigzip.exe - example - echo hello world | minigzip | minigzip -d - -#clean: -# del *.obj -# del *.exe diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.w32 b/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.w32 deleted file mode 100644 index 0a05fa9a469..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.w32 +++ /dev/null @@ -1,97 +0,0 @@ -# Makefile for zlib -# Microsoft 32-bit Visual C++ 4.0 or later (may work on earlier versions) - -# To use, do "nmake /f makefile.w32" - -# If you wish to reduce the memory requirements (default 256K for big -# objects plus a few K), you can add to CFLAGS below: -# -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 -# See zconf.h for details about the memory requirements. - -# ------------- Microsoft Visual C++ 4.0 and later ------------- -MODEL= -CFLAGS=-Ox -GA3s -nologo -W3 -CC=cl -LD=link -LDFLAGS= -O=.obj - -# variables -OBJ1 = adler32$(O) compress$(O) crc32$(O) gzio$(O) uncompr$(O) deflate$(O) \ - trees$(O) -OBJP1 = adler32$(O)+compress$(O)+crc32$(O)+gzio$(O)+uncompr$(O)+deflate$(O)+\ - trees$(O) -OBJ2 = zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O) \ - infutil$(O) inffast$(O) -OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\ - infutil$(O)+inffast$(O) - -all: zlib.lib example.exe minigzip.exe - -adler32.obj: adler32.c zlib.h zconf.h - $(CC) -c $(CFLAGS) $*.c - -compress.obj: compress.c zlib.h zconf.h - $(CC) -c $(CFLAGS) $*.c - -crc32.obj: crc32.c zlib.h zconf.h - $(CC) -c $(CFLAGS) $*.c - -deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h - $(CC) -c $(CFLAGS) $*.c - -gzio.obj: gzio.c zutil.h zlib.h zconf.h - $(CC) -c $(CFLAGS) $*.c - -infblock.obj: infblock.c zutil.h zlib.h zconf.h infblock.h inftrees.h\ - infcodes.h infutil.h - $(CC) -c $(CFLAGS) $*.c - -infcodes.obj: infcodes.c zutil.h zlib.h zconf.h inftrees.h infutil.h\ - infcodes.h inffast.h - $(CC) -c $(CFLAGS) $*.c - -inflate.obj: inflate.c zutil.h zlib.h zconf.h infblock.h - $(CC) -c $(CFLAGS) $*.c - -inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h - $(CC) -c $(CFLAGS) $*.c - -infutil.obj: infutil.c zutil.h zlib.h zconf.h inftrees.h infutil.h - $(CC) -c $(CFLAGS) $*.c - -inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h - $(CC) -c $(CFLAGS) $*.c - -trees.obj: trees.c deflate.h zutil.h zlib.h zconf.h - $(CC) -c $(CFLAGS) $*.c - -uncompr.obj: uncompr.c zlib.h zconf.h - $(CC) -c $(CFLAGS) $*.c - -zutil.obj: zutil.c zutil.h zlib.h zconf.h - $(CC) -c $(CFLAGS) $*.c - -example.obj: example.c zlib.h zconf.h - $(CC) -c $(CFLAGS) $*.c - -minigzip.obj: minigzip.c zlib.h zconf.h - $(CC) -c $(CFLAGS) $*.c - -zlib.lib: $(OBJ1) $(OBJ2) - if exist zlib.lib del zlib.lib - lib /OUT:zlib.lib $(OBJ1) $(OBJ2) - -example.exe: example.obj zlib.lib - $(LD) $(LDFLAGS) example.obj zlib.lib /OUT:example.exe /SUBSYSTEM:CONSOLE - -minigzip.exe: minigzip.obj zlib.lib - $(LD) $(LDFLAGS) minigzip.obj zlib.lib /OUT:minigzip.exe /SUBSYSTEM:CONSOLE - -test: example.exe minigzip.exe - example - echo hello world | minigzip | minigzip -d - -#clean: -# del *.obj -# del *.exe diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.wat b/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.wat deleted file mode 100644 index 44bf8607f6f..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/msdos/Makefile.wat +++ /dev/null @@ -1,103 +0,0 @@ -# Makefile for zlib -# Watcom 10a - -# This version of the zlib makefile was adapted by Chris Young for use -# with Watcom 10a 32-bit protected mode flat memory model. It was created -# for use with POV-Ray ray tracer and you may choose to edit the CFLAGS to -# suit your needs but the -DMSDOS is required. -# -- Chris Young 76702.1655@compuserve.com - -# To use, do "wmake -f makefile.wat" - -# See zconf.h for details about the memory requirements. - -# ------------- Watcom 10a ------------- -MODEL=-mf -CFLAGS= $(MODEL) -fpi87 -fp5 -zp4 -5r -w5 -oneatx -DMSDOS -CC=wcc386 -LD=wcl386 -LIB=wlib -b -c -LDFLAGS= -O=.obj - -# variables -OBJ1=adler32$(O) compress$(O) crc32$(O) gzio$(O) uncompr$(O) deflate$(O) -OBJ2=trees$(O) zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O) -OBJ3=infutil$(O) inffast$(O) -OBJP1=adler32$(O)+compress$(O)+crc32$(O)+gzio$(O)+uncompr$(O)+deflate$(O) -OBJP2=trees$(O)+zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O) -OBJP3=infutil$(O)+inffast$(O) - -all: test - -adler32.obj: adler32.c zlib.h zconf.h - $(CC) $(CFLAGS) $*.c - -compress.obj: compress.c zlib.h zconf.h - $(CC) $(CFLAGS) $*.c - -crc32.obj: crc32.c zlib.h zconf.h - $(CC) $(CFLAGS) $*.c - -deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h - $(CC) $(CFLAGS) $*.c - -gzio.obj: gzio.c zutil.h zlib.h zconf.h - $(CC) $(CFLAGS) $*.c - -infblock.obj: infblock.c zutil.h zlib.h zconf.h infblock.h inftrees.h & - infcodes.h infutil.h - $(CC) $(CFLAGS) $*.c - -infcodes.obj: infcodes.c zutil.h zlib.h zconf.h inftrees.h infutil.h & - infcodes.h inffast.h - $(CC) $(CFLAGS) $*.c - -inflate.obj: inflate.c zutil.h zlib.h zconf.h infblock.h - $(CC) $(CFLAGS) $*.c - -inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h - $(CC) $(CFLAGS) $*.c - -infutil.obj: infutil.c zutil.h zlib.h zconf.h inftrees.h infutil.h - $(CC) $(CFLAGS) $*.c - -inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h - $(CC) $(CFLAGS) $*.c - -trees.obj: trees.c deflate.h zutil.h zlib.h zconf.h - $(CC) $(CFLAGS) $*.c - -uncompr.obj: uncompr.c zlib.h zconf.h - $(CC) $(CFLAGS) $*.c - -zutil.obj: zutil.c zutil.h zlib.h zconf.h - $(CC) $(CFLAGS) $*.c - -example.obj: example.c zlib.h zconf.h - $(CC) $(CFLAGS) $*.c - -minigzip.obj: minigzip.c zlib.h zconf.h - $(CC) $(CFLAGS) $*.c - -# we must cut the command line to fit in the MS/DOS 128 byte limit: -zlib.lib: $(OBJ1) $(OBJ2) $(OBJ3) - del zlib.lib - $(LIB) zlib.lib +$(OBJP1) - $(LIB) zlib.lib +$(OBJP2) - $(LIB) zlib.lib +$(OBJP3) - -example.exe: example.obj zlib.lib - $(LD) $(LDFLAGS) example.obj zlib.lib - -minigzip.exe: minigzip.obj zlib.lib - $(LD) $(LDFLAGS) minigzip.obj zlib.lib - -test: minigzip.exe example.exe - example - echo hello world | minigzip | minigzip -d >test - type test - -#clean: -# del *.obj -# del *.exe diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/msdos/zlib.def b/contrib/vmap_extractor_v2/stormlib/zlib/msdos/zlib.def deleted file mode 100644 index 6c04412f9b0..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/msdos/zlib.def +++ /dev/null @@ -1,60 +0,0 @@ -LIBRARY "zlib" - -DESCRIPTION '"""zlib data compression library"""' - -EXETYPE NT - -SUBSYSTEM WINDOWS - -STUB 'WINSTUB.EXE' - -VERSION 1.13 - -CODE EXECUTE READ - -DATA READ WRITE - -HEAPSIZE 1048576,4096 - -EXPORTS - adler32 @1 - compress @2 - crc32 @3 - deflate @4 - deflateCopy @5 - deflateEnd @6 - deflateInit2_ @7 - deflateInit_ @8 - deflateParams @9 - deflateReset @10 - deflateSetDictionary @11 - gzclose @12 - gzdopen @13 - gzerror @14 - gzflush @15 - gzopen @16 - gzread @17 - gzwrite @18 - inflate @19 - inflateEnd @20 - inflateInit2_ @21 - inflateInit_ @22 - inflateReset @23 - inflateSetDictionary @24 - inflateSync @25 - uncompress @26 - zlibVersion @27 - gzprintf @28 - gzputc @29 - gzgetc @30 - gzseek @31 - gzrewind @32 - gztell @33 - gzeof @34 - gzsetparams @35 - zError @36 - inflateSyncPoint @37 - get_crc_table @38 - compress2 @39 - gzputs @40 - gzgets @41 diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/msdos/zlib.rc b/contrib/vmap_extractor_v2/stormlib/zlib/msdos/zlib.rc deleted file mode 100644 index 556d4ff950a..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/msdos/zlib.rc +++ /dev/null @@ -1,32 +0,0 @@ -#include - -#define IDR_VERSION1 1 -IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE - FILEVERSION 1,1,3,0 - PRODUCTVERSION 1,1,3,0 - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK - FILEFLAGS 0 - FILEOS VOS_DOS_WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE 0 // not used -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904E4" - //language ID = U.S. English, char set = Windows, Multilingual - - BEGIN - VALUE "FileDescription", "zlib data compression library\0" - VALUE "FileVersion", "1.1.3\0" - VALUE "InternalName", "zlib\0" - VALUE "OriginalFilename", "zlib.dll\0" - VALUE "ProductName", "ZLib.DLL\0" - VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" - VALUE "LegalCopyright", "(C) 1995-1998 Jean-loup Gailly & Mark Adler\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0409, 1252 - END -END diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/nt/Makefile.emx b/contrib/vmap_extractor_v2/stormlib/zlib/nt/Makefile.emx deleted file mode 100644 index 2d475b1847e..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/nt/Makefile.emx +++ /dev/null @@ -1,138 +0,0 @@ -# Makefile for zlib. Modified for emx/rsxnt by Chr. Spieler, 6/16/98. -# Copyright (C) 1995-1998 Jean-loup Gailly. -# For conditions of distribution and use, see copyright notice in zlib.h - -# To compile, or to compile and test, type: -# -# make -fmakefile.emx; make test -fmakefile.emx -# - -CC=gcc -Zwin32 - -#CFLAGS=-MMD -O -#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 -#CFLAGS=-MMD -g -DDEBUG -CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ - -Wstrict-prototypes -Wmissing-prototypes - -# If cp.exe is available, replace "copy /Y" with "cp -fp" . -CP=copy /Y -# If gnu install.exe is available, replace $(CP) with ginstall. -INSTALL=$(CP) -# The default value of RM is "rm -f." If "rm.exe" is found, comment out: -RM=del -LDLIBS=-L. -lzlib -LD=$(CC) -s -o -LDSHARED=$(CC) - -INCL=zlib.h zconf.h -LIBS=zlib.a - -AR=ar rcs - -prefix=/usr/local -exec_prefix = $(prefix) - -OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ - zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o - -TEST_OBJS = example.o minigzip.o - -all: example.exe minigzip.exe - -test: all - ./example - echo hello world | .\minigzip | .\minigzip -d - -%.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - -zlib.a: $(OBJS) - $(AR) $@ $(OBJS) - -%.exe : %.o $(LIBS) - $(LD) $@ $< $(LDLIBS) - - -.PHONY : clean - -clean: - $(RM) *.d - $(RM) *.o - $(RM) *.exe - $(RM) zlib.a - $(RM) foo.gz - -DEPS := $(wildcard *.d) -ifneq ($(DEPS),) -include $(DEPS) -endif -# Makefile for zlib. Modified for emx 0.9c by Chr. Spieler, 6/17/98. -# Copyright (C) 1995-1998 Jean-loup Gailly. -# For conditions of distribution and use, see copyright notice in zlib.h - -# To compile, or to compile and test, type: -# -# make -fmakefile.emx; make test -fmakefile.emx -# - -CC=gcc - -#CFLAGS=-MMD -O -#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 -#CFLAGS=-MMD -g -DDEBUG -CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ - -Wstrict-prototypes -Wmissing-prototypes - -# If cp.exe is available, replace "copy /Y" with "cp -fp" . -CP=copy /Y -# If gnu install.exe is available, replace $(CP) with ginstall. -INSTALL=$(CP) -# The default value of RM is "rm -f." If "rm.exe" is found, comment out: -RM=del -LDLIBS=-L. -lzlib -LD=$(CC) -s -o -LDSHARED=$(CC) - -INCL=zlib.h zconf.h -LIBS=zlib.a - -AR=ar rcs - -prefix=/usr/local -exec_prefix = $(prefix) - -OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ - zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o - -TEST_OBJS = example.o minigzip.o - -all: example.exe minigzip.exe - -test: all - ./example - echo hello world | .\minigzip | .\minigzip -d - -%.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - -zlib.a: $(OBJS) - $(AR) $@ $(OBJS) - -%.exe : %.o $(LIBS) - $(LD) $@ $< $(LDLIBS) - - -.PHONY : clean - -clean: - $(RM) *.d - $(RM) *.o - $(RM) *.exe - $(RM) zlib.a - $(RM) foo.gz - -DEPS := $(wildcard *.d) -ifneq ($(DEPS),) -include $(DEPS) -endif diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/nt/Makefile.gcc b/contrib/vmap_extractor_v2/stormlib/zlib/nt/Makefile.gcc deleted file mode 100644 index cdd652f2360..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/nt/Makefile.gcc +++ /dev/null @@ -1,87 +0,0 @@ -# Makefile for zlib. Modified for mingw32 by C. Spieler, 6/16/98. -# (This Makefile is directly derived from Makefile.dj2) -# Copyright (C) 1995-1998 Jean-loup Gailly. -# For conditions of distribution and use, see copyright notice in zlib.h - -# To compile, or to compile and test, type: -# -# make -fmakefile.gcc; make test -fmakefile.gcc -# -# To install libz.a, zconf.h and zlib.h in the mingw32 directories, type: -# -# make install -fmakefile.gcc -# - -CC=gcc - -#CFLAGS=-MMD -O -#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 -#CFLAGS=-MMD -g -DDEBUG -CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ - -Wstrict-prototypes -Wmissing-prototypes - -# If cp.exe is available, replace "copy /Y" with "cp -fp" . -CP=copy /Y -# If gnu install.exe is available, replace $(CP) with ginstall. -INSTALL=$(CP) -# The default value of RM is "rm -f." If "rm.exe" is found, comment out: -RM=del -LDLIBS=-L. -lz -LD=$(CC) -s -o -LDSHARED=$(CC) - -INCL=zlib.h zconf.h -LIBS=libz.a - -AR=ar rcs - -prefix=/usr/local -exec_prefix = $(prefix) - -OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ - zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o - -TEST_OBJS = example.o minigzip.o - -all: example.exe minigzip.exe - -test: all - ./example - echo hello world | .\minigzip | .\minigzip -d - -%.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - -libz.a: $(OBJS) - $(AR) $@ $(OBJS) - -%.exe : %.o $(LIBS) - $(LD) $@ $< $(LDLIBS) - -# INCLUDE_PATH and LIBRARY_PATH were set for [make] in djgpp.env . - -.PHONY : uninstall clean - -install: $(INCL) $(LIBS) - -@if not exist $(INCLUDE_PATH)\nul mkdir $(INCLUDE_PATH) - -@if not exist $(LIBRARY_PATH)\nul mkdir $(LIBRARY_PATH) - $(INSTALL) zlib.h $(INCLUDE_PATH) - $(INSTALL) zconf.h $(INCLUDE_PATH) - $(INSTALL) libz.a $(LIBRARY_PATH) - -uninstall: - $(RM) $(INCLUDE_PATH)\zlib.h - $(RM) $(INCLUDE_PATH)\zconf.h - $(RM) $(LIBRARY_PATH)\libz.a - -clean: - $(RM) *.d - $(RM) *.o - $(RM) *.exe - $(RM) libz.a - $(RM) foo.gz - -DEPS := $(wildcard *.d) -ifneq ($(DEPS),) -include $(DEPS) -endif diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/nt/Makefile.nt b/contrib/vmap_extractor_v2/stormlib/zlib/nt/Makefile.nt deleted file mode 100644 index b250f2ac7d2..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/nt/Makefile.nt +++ /dev/null @@ -1,88 +0,0 @@ -# Makefile for zlib - -!include - -CC=cl -LD=link -CFLAGS=-O -nologo -LDFLAGS= -O=.obj - -# variables -OBJ1 = adler32$(O) compress$(O) crc32$(O) gzio$(O) uncompr$(O) deflate$(O) \ - trees$(O) -OBJ2 = zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O) \ - infutil$(O) inffast$(O) - -all: zlib.dll example.exe minigzip.exe - -adler32.obj: adler32.c zutil.h zlib.h zconf.h - $(CC) -c $(cvarsdll) $(CFLAGS) $*.c - -compress.obj: compress.c zlib.h zconf.h - $(CC) -c $(cvarsdll) $(CFLAGS) $*.c - -crc32.obj: crc32.c zutil.h zlib.h zconf.h - $(CC) -c $(cvarsdll) $(CFLAGS) $*.c - -deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h - $(CC) -c $(cvarsdll) $(CFLAGS) $*.c - -gzio.obj: gzio.c zutil.h zlib.h zconf.h - $(CC) -c $(cvarsdll) $(CFLAGS) $*.c - -infblock.obj: infblock.c zutil.h zlib.h zconf.h infblock.h inftrees.h\ - infcodes.h infutil.h - $(CC) -c $(cvarsdll) $(CFLAGS) $*.c - -infcodes.obj: infcodes.c zutil.h zlib.h zconf.h inftrees.h infutil.h\ - infcodes.h inffast.h - $(CC) -c $(cvarsdll) $(CFLAGS) $*.c - -inflate.obj: inflate.c zutil.h zlib.h zconf.h infblock.h - $(CC) -c $(cvarsdll) $(CFLAGS) $*.c - -inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h - $(CC) -c $(cvarsdll) $(CFLAGS) $*.c - -infutil.obj: infutil.c zutil.h zlib.h zconf.h inftrees.h infutil.h - $(CC) -c $(cvarsdll) $(CFLAGS) $*.c - -inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h - $(CC) -c $(cvarsdll) $(CFLAGS) $*.c - -trees.obj: trees.c deflate.h zutil.h zlib.h zconf.h - $(CC) -c $(cvarsdll) $(CFLAGS) $*.c - -uncompr.obj: uncompr.c zlib.h zconf.h - $(CC) -c $(cvarsdll) $(CFLAGS) $*.c - -zutil.obj: zutil.c zutil.h zlib.h zconf.h - $(CC) -c $(cvarsdll) $(CFLAGS) $*.c - -example.obj: example.c zlib.h zconf.h - $(CC) -c $(cvarsdll) $(CFLAGS) $*.c - -minigzip.obj: minigzip.c zlib.h zconf.h - $(CC) -c $(cvarsdll) $(CFLAGS) $*.c - -zlib.dll: $(OBJ1) $(OBJ2) zlib.dnt - link $(dlllflags) -out:$@ -def:zlib.dnt $(OBJ1) $(OBJ2) $(guilibsdll) - -zlib.lib: zlib.dll - -example.exe: example.obj zlib.lib - $(LD) $(LDFLAGS) example.obj zlib.lib - -minigzip.exe: minigzip.obj zlib.lib - $(LD) $(LDFLAGS) minigzip.obj zlib.lib - -test: example.exe minigzip.exe - example - echo hello world | minigzip | minigzip -d - -clean: - del *.obj - del *.exe - del *.dll - del *.lib diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/nt/zlib.dnt b/contrib/vmap_extractor_v2/stormlib/zlib/nt/zlib.dnt deleted file mode 100644 index 7f9475cfb0e..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/nt/zlib.dnt +++ /dev/null @@ -1,47 +0,0 @@ -LIBRARY zlib.dll -EXETYPE WINDOWS -CODE PRELOAD MOVEABLE DISCARDABLE -DATA PRELOAD MOVEABLE MULTIPLE - -EXPORTS - adler32 @1 - compress @2 - crc32 @3 - deflate @4 - deflateCopy @5 - deflateEnd @6 - deflateInit2_ @7 - deflateInit_ @8 - deflateParams @9 - deflateReset @10 - deflateSetDictionary @11 - gzclose @12 - gzdopen @13 - gzerror @14 - gzflush @15 - gzopen @16 - gzread @17 - gzwrite @18 - inflate @19 - inflateEnd @20 - inflateInit2_ @21 - inflateInit_ @22 - inflateReset @23 - inflateSetDictionary @24 - inflateSync @25 - uncompress @26 - zlibVersion @27 - gzprintf @28 - gzputc @29 - gzgetc @30 - gzseek @31 - gzrewind @32 - gztell @33 - gzeof @34 - gzsetparams @35 - zError @36 - inflateSyncPoint @37 - get_crc_table @38 - compress2 @39 - gzputs @40 - gzgets @41 diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/os2/Makefile.os2 b/contrib/vmap_extractor_v2/stormlib/zlib/os2/Makefile.os2 deleted file mode 100644 index 4f569471eca..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/os2/Makefile.os2 +++ /dev/null @@ -1,136 +0,0 @@ -# Makefile for zlib under OS/2 using GCC (PGCC) -# For conditions of distribution and use, see copyright notice in zlib.h - -# To compile and test, type: -# cp Makefile.os2 .. -# cd .. -# make -f Makefile.os2 test - -# This makefile will build a static library z.lib, a shared library -# z.dll and a import library zdll.lib. You can use either z.lib or -# zdll.lib by specifying either -lz or -lzdll on gcc's command line - -CC=gcc -Zomf -s - -CFLAGS=-O6 -Wall -#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 -#CFLAGS=-g -DDEBUG -#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ -# -Wstrict-prototypes -Wmissing-prototypes - -#################### BUG WARNING: ##################### -## infcodes.c hits a bug in pgcc-1.0, so you have to use either -## -O# where # <= 4 or one of (-fno-ommit-frame-pointer or -fno-force-mem) -## This bug is reportedly fixed in pgcc >1.0, but this was not tested -CFLAGS+=-fno-force-mem - -LDFLAGS=-s -L. -lzdll -Zcrtdll -LDSHARED=$(CC) -s -Zomf -Zdll -Zcrtdll - -VER=1.1.0 -ZLIB=z.lib -SHAREDLIB=z.dll -SHAREDLIBIMP=zdll.lib -LIBS=$(ZLIB) $(SHAREDLIB) $(SHAREDLIBIMP) - -AR=emxomfar cr -IMPLIB=emximp -RANLIB=echo -TAR=tar -SHELL=bash - -prefix=/usr/local -exec_prefix = $(prefix) - -OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ - zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o - -TEST_OBJS = example.o minigzip.o - -DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] *.[ch] descrip.mms \ - algorithm.txt zlib.3 msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \ - nt/Makefile.nt nt/zlib.dnt contrib/README.contrib contrib/*.txt \ - contrib/asm386/*.asm contrib/asm386/*.c \ - contrib/asm386/*.bat contrib/asm386/zlibvc.d?? contrib/iostream/*.cpp \ - contrib/iostream/*.h contrib/iostream2/*.h contrib/iostream2/*.cpp \ - contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32 - -all: example.exe minigzip.exe - -test: all - @LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ - echo hello world | ./minigzip | ./minigzip -d || \ - echo ' *** minigzip test FAILED ***' ; \ - if ./example; then \ - echo ' *** zlib test OK ***'; \ - else \ - echo ' *** zlib test FAILED ***'; \ - fi - -$(ZLIB): $(OBJS) - $(AR) $@ $(OBJS) - -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 - -$(SHAREDLIB): $(OBJS) os2/z.def - $(LDSHARED) -o $@ $^ - -$(SHAREDLIBIMP): os2/z.def - $(IMPLIB) -o $@ $^ - -example.exe: example.o $(LIBS) - $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS) - -minigzip.exe: minigzip.o $(LIBS) - $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) - -clean: - rm -f *.o *~ example minigzip libz.a libz.so* foo.gz - -distclean: clean - -zip: - mv Makefile Makefile~; cp -p Makefile.in Makefile - rm -f test.c ztest*.c - v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ - zip -ul9 zlib$$v $(DISTFILES) - mv Makefile~ Makefile - -dist: - mv Makefile Makefile~; cp -p Makefile.in Makefile - rm -f test.c ztest*.c - d=zlib-`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ - rm -f $$d.tar.gz; \ - if test ! -d ../$$d; then rm -f ../$$d; ln -s `pwd` ../$$d; fi; \ - files=""; \ - for f in $(DISTFILES); do files="$$files $$d/$$f"; done; \ - cd ..; \ - GZIP=-9 $(TAR) chofz $$d/$$d.tar.gz $$files; \ - if test ! -d $$d; then rm -f $$d; fi - mv Makefile~ Makefile - -tags: - etags *.[ch] - -depend: - makedepend -- $(CFLAGS) -- *.[ch] - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -adler32.o: zlib.h zconf.h -compress.o: zlib.h zconf.h -crc32.o: zlib.h zconf.h -deflate.o: deflate.h zutil.h zlib.h zconf.h -example.o: zlib.h zconf.h -gzio.o: zutil.h zlib.h zconf.h -infblock.o: infblock.h inftrees.h infcodes.h infutil.h zutil.h zlib.h zconf.h -infcodes.o: zutil.h zlib.h zconf.h -infcodes.o: inftrees.h infblock.h infcodes.h infutil.h inffast.h -inffast.o: zutil.h zlib.h zconf.h inftrees.h -inffast.o: infblock.h infcodes.h infutil.h inffast.h -inflate.o: zutil.h zlib.h zconf.h infblock.h -inftrees.o: zutil.h zlib.h zconf.h inftrees.h -infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h -minigzip.o: zlib.h zconf.h -trees.o: deflate.h zutil.h zlib.h zconf.h trees.h -uncompr.o: zlib.h zconf.h -zutil.o: zutil.h zlib.h zconf.h diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/os2/zlib.def b/contrib/vmap_extractor_v2/stormlib/zlib/os2/zlib.def deleted file mode 100644 index 4c753f1a3b9..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/os2/zlib.def +++ /dev/null @@ -1,51 +0,0 @@ -; -; Slightly modified version of ../nt/zlib.dnt :-) -; - -LIBRARY Z -DESCRIPTION "Zlib compression library for OS/2" -CODE PRELOAD MOVEABLE DISCARDABLE -DATA PRELOAD MOVEABLE MULTIPLE - -EXPORTS - adler32 - compress - crc32 - deflate - deflateCopy - deflateEnd - deflateInit2_ - deflateInit_ - deflateParams - deflateReset - deflateSetDictionary - gzclose - gzdopen - gzerror - gzflush - gzopen - gzread - gzwrite - inflate - inflateEnd - inflateInit2_ - inflateInit_ - inflateReset - inflateSetDictionary - inflateSync - uncompress - zlibVersion - gzprintf - gzputc - gzgetc - gzseek - gzrewind - gztell - gzeof - gzsetparams - zError - inflateSyncPoint - get_crc_table - compress2 - gzputs - gzgets diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/trees.c b/contrib/vmap_extractor_v2/stormlib/zlib/trees.c deleted file mode 100644 index 0a984056738..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/trees.c +++ /dev/null @@ -1,1214 +0,0 @@ -/* trees.c -- output deflated data using Huffman coding - * Copyright (C) 1995-2002 Jean-loup Gailly - * 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 -#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. - */ - -#define Buf_size (8 * 2*sizeof(char)) -/* Number of bits used within bi_buf. (bi_buf might be implemented on - * more than 16 bits on some systems.) - */ - -/* =========================================================================== - * 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, ct_data *ltree, - ct_data *dtree)); -local void set_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(s, value, length) - deflate_state *s; - int value; /* value to send */ - int length; /* number of bits */ -{ - 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 |= (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 |= 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 |= (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 |= (value) << s->bi_valid;\ - s->bi_valid += len;\ - }\ -} -#endif /* DEBUG */ - - -#define MAX(a,b) (a >= b ? a : b) -/* the arguments must not have side effects */ - -/* =========================================================================== - * Initialize the various 'constant' tables. - */ -local void tr_static_init() -{ -#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 code; /* 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: */ - 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; - - /* Initialize the mapping length (0..255) -> length code (0..28) */ - length = 0; - for (code = 0; code < LENGTH_CODES-1; code++) { - base_length[code] = length; - for (n = 0; n < (1< dist code (0..29) */ - dist = 0; - for (code = 0 ; code < 16; code++) { - base_dist[code] = dist; - for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */ - for ( ; code < D_CODES; code++) { - base_dist[code] = dist << 7; - for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { - _dist_code[256 + dist++] = (uch)code; - } - } - 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 -# endif - -# define SEPARATOR(i, last, width) \ - ((i) == (last)? "\n};\n\n" : \ - ((i) % (width) == (width)-1 ? ",\n" : ", ")) - -void gen_trees_header() -{ - 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 _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 _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 _tr_init(s) - 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; - s->last_eob_len = 8; /* enough lookahead for inflate */ -#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(s) - 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(s, tree, k) - deflate_state *s; - ct_data *tree; /* the tree to restore */ - int k; /* node to move down */ -{ - 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(s, desc) - deflate_state *s; - tree_desc *desc; /* the tree descriptor */ -{ - 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 (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 (tree, max_code, bl_count) - ct_data *tree; /* the tree to decorate */ - int max_code; /* largest code with non zero frequency */ - ushf *bl_count; /* number of codes at each bit length */ -{ - ush next_code[MAX_BITS+1]; /* next code value for each bit length */ - ush code = 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] = code = (code + bl_count[bits-1]) << 1; - } - /* Check that the bit counts in bl_count are consistent. The last code - * must be all ones. - */ - Assert (code + bl_count[MAX_BITS]-1 == (1<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) (MAX(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 (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - 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 (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - 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(s) - 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(s, lcodes, dcodes, blcodes) - deflate_state *s; - int lcodes, dcodes, blcodes; /* number of codes for each tree */ -{ - 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 _tr_stored_block(s, buf, stored_len, eof) - deflate_state *s; - charf *buf; /* input block */ - ulg stored_len; /* length of input block */ - int eof; /* true if this is the last block for a file */ -{ - send_bits(s, (STORED_BLOCK<<1)+eof, 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 */ -} - -/* =========================================================================== - * Send one empty static block to give enough lookahead for inflate. - * This takes 10 bits, of which 7 may remain in the bit buffer. - * The current inflate code requires 9 bits of lookahead. If the - * last two codes for the previous block (real code plus EOB) were coded - * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode - * the last real code. In this case we send two empty static blocks instead - * of one. (There are no problems if the previous block is stored or fixed.) - * To simplify the code, we assume the worst case of last real code encoded - * on one bit only. - */ -void _tr_align(s) - 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); - /* Of the 10 bits for the empty block, we have already sent - * (10 - bi_valid) bits. The lookahead for the last real code (before - * the EOB of the previous block) was thus at least one plus the length - * of the EOB plus what we have just sent of the empty static block. - */ - if (1 + s->last_eob_len + 10 - s->bi_valid < 9) { - send_bits(s, STATIC_TREES<<1, 3); - send_code(s, END_BLOCK, static_ltree); -#ifdef DEBUG - s->compressed_len += 10L; -#endif - bi_flush(s); - } - s->last_eob_len = 7; -} - -/* =========================================================================== - * Determine the best encoding for the current block: dynamic trees, static - * trees or store, and output the encoded block to the zip file. - */ -void _tr_flush_block(s, buf, stored_len, eof) - deflate_state *s; - charf *buf; /* input block, or NULL if too old */ - ulg stored_len; /* length of input block */ - int eof; /* true if this is the last block for a file */ -{ - 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 ascii or binary */ - if (s->data_type == Z_UNKNOWN) set_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 first the block length 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, eof); - -#ifdef FORCE_STATIC - } else if (static_lenb >= 0) { /* force static trees */ -#else - } else if (static_lenb == opt_lenb) { -#endif - send_bits(s, (STATIC_TREES<<1)+eof, 3); - compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree); -#ifdef DEBUG - s->compressed_len += 3 + s->static_len; -#endif - } else { - send_bits(s, (DYN_TREES<<1)+eof, 3); - send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, - max_blindex+1); - compress_block(s, (ct_data *)s->dyn_ltree, (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 (eof) { - 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*eof)); -} - -/* =========================================================================== - * Save the match info and tally the frequency counts. Return true if - * the current block must be flushed. - */ -int _tr_tally (s, dist, lc) - deflate_state *s; - unsigned dist; /* distance of matched string */ - unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ -{ - 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(s, ltree, dtree) - deflate_state *s; - ct_data *ltree; /* literal tree */ - ct_data *dtree; /* distance tree */ -{ - 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 code; /* 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 */ - code = _length_code[lc]; - send_code(s, code+LITERALS+1, ltree); /* send the length code */ - extra = extra_lbits[code]; - if (extra != 0) { - lc -= base_length[code]; - send_bits(s, lc, extra); /* send the extra length bits */ - } - dist--; /* dist is now the match distance - 1 */ - code = d_code(dist); - Assert (code < D_CODES, "bad d_code"); - - send_code(s, code, dtree); /* send the distance code */ - extra = extra_dbits[code]; - if (extra != 0) { - dist -= base_dist[code]; - 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(s->pending < s->lit_bufsize + 2*lx, "pendingBuf overflow"); - - } while (lx < s->last_lit); - - send_code(s, END_BLOCK, ltree); - s->last_eob_len = ltree[END_BLOCK].Len; -} - -/* =========================================================================== - * Set the data type to ASCII or BINARY, using a crude approximation: - * binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise. - * IN assertion: the fields freq of dyn_ltree are set and the total of all - * frequencies does not exceed 64K (to fit in an int on 16 bit machines). - */ -local void set_data_type(s) - deflate_state *s; -{ - int n = 0; - unsigned ascii_freq = 0; - unsigned bin_freq = 0; - while (n < 7) bin_freq += s->dyn_ltree[n++].Freq; - while (n < 128) ascii_freq += s->dyn_ltree[n++].Freq; - while (n < LITERALS) bin_freq += s->dyn_ltree[n++].Freq; - s->data_type = (Byte)(bin_freq > (ascii_freq >> 2) ? Z_BINARY : Z_ASCII); -} - -/* =========================================================================== - * 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(code, len) - unsigned code; /* the value to invert */ - int len; /* its bit length */ -{ - register unsigned res = 0; - do { - res |= code & 1; - code >>= 1, res <<= 1; - } while (--len > 0); - return res >> 1; -} - -/* =========================================================================== - * Flush the bit buffer, keeping at most 7 bits in it. - */ -local void bi_flush(s) - 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(s) - 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(s, buf, len, header) - deflate_state *s; - charf *buf; /* the input data */ - unsigned len; /* its length */ - int header; /* true if block header must be written */ -{ - bi_windup(s); /* align on byte boundary */ - s->last_eob_len = 8; /* enough lookahead for inflate */ - - 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/contrib/vmap_extractor_v2/stormlib/zlib/trees.h b/contrib/vmap_extractor_v2/stormlib/zlib/trees.h deleted file mode 100644 index 72facf900f7..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/trees.h +++ /dev/null @@ -1,128 +0,0 @@ -/* header created automatically with -DGEN_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 _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 _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 -}; - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/uncompr.c b/contrib/vmap_extractor_v2/stormlib/zlib/uncompr.c deleted file mode 100644 index a287714f5de..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/uncompr.c +++ /dev/null @@ -1,58 +0,0 @@ -/* uncompr.c -- decompress a memory buffer - * Copyright (C) 1995-2002 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#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. - This function can be used to decompress a whole file at once if the - input file is mmap'ed. - - 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 (dest, destLen, source, sourceLen) - 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 = (alloc_func)0; - stream.zfree = (free_func)0; - - err = inflateInit(&stream); - if (err != Z_OK) return err; - - err = inflate(&stream, Z_FINISH); - if (err != Z_STREAM_END) { - inflateEnd(&stream); - return err == Z_OK ? Z_BUF_ERROR : err; - } - *destLen = stream.total_out; - - err = inflateEnd(&stream); - return err; -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/zconf.h b/contrib/vmap_extractor_v2/stormlib/zlib/zconf.h deleted file mode 100644 index eb0ae2e1a0c..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/zconf.h +++ /dev/null @@ -1,279 +0,0 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2002 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. - */ -#ifdef Z_PREFIX -# define deflateInit_ z_deflateInit_ -# define deflate z_deflate -# define deflateEnd z_deflateEnd -# define inflateInit_ z_inflateInit_ -# define inflate z_inflate -# define inflateEnd z_inflateEnd -# define deflateInit2_ z_deflateInit2_ -# define deflateSetDictionary z_deflateSetDictionary -# define deflateCopy z_deflateCopy -# define deflateReset z_deflateReset -# define deflateParams z_deflateParams -# define inflateInit2_ z_inflateInit2_ -# define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateReset z_inflateReset -# define compress z_compress -# define compress2 z_compress2 -# define uncompress z_uncompress -# define adler32 z_adler32 -# define crc32 z_crc32 -# define get_crc_table z_get_crc_table - -# define Byte z_Byte -# define uInt z_uInt -# define uLong z_uLong -# define Bytef z_Bytef -# define charf z_charf -# define intf z_intf -# define uIntf z_uIntf -# define uLongf z_uLongf -# define voidpf z_voidpf -# define voidp z_voidp -#endif - -#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) -# define WIN32 -#endif -#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386) -# ifndef __32BIT__ -# define __32BIT__ -# endif -#endif -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#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). - */ -#if defined(MSDOS) && !defined(__32BIT__) -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC) -# define STDC -#endif -#if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__) -# ifndef STDC -# define STDC -# endif -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const -# endif -#endif - -/* Some Mac compilers merge all .h files incorrectly: */ -#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__) -# define NO_DUMMY_DECL -#endif - -/* Old Borland C incorrectly complains about missing returns: */ -#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) -# define NEED_DUMMY_RETURN -#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 - -/* 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. - */ -#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -#endif -#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) -# ifndef __32BIT__ -# define SMALL_MEDIUM -# define FAR _far -# endif -#endif - -/* Compile with -DZLIB_DLL for Windows DLL support */ -#if defined(ZLIB_DLL) -# if defined(_WINDOWS) || defined(WINDOWS) -# ifdef FAR -# undef FAR -# endif -# include -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR _cdecl _export -# endif -# endif -# if defined (__BORLANDC__) -# if (__BORLANDC__ >= 0x0500) && defined (WIN32) -# include -# define ZEXPORT __declspec(dllexport) WINAPI -# define ZEXPORTRVA __declspec(dllexport) WINAPIV -# else -# if defined (_Windows) && defined (__DLL__) -# define ZEXPORT _export -# define ZEXPORTVA _export -# endif -# endif -# endif -#endif - -#if defined (__BEOS__) -# if defined (ZLIB_DLL) -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -#endif - -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif -#ifndef ZEXTERN -# define ZEXTERN extern -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(MACOS) && !defined(TARGET_OS_MAC) -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 FAR *voidpf; - typedef void *voidp; -#else - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#ifdef HAVE_UNISTD_H -# include /* for off_t */ -# include /* for SEEK_* and off_t */ -# define z_off_t off_t -#endif -#ifndef SEEK_SET -# 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 - -/* 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(inflateInit_,"ININ") -# pragma map(inflateInit2_,"ININ2") -# pragma map(inflateEnd,"INEND") -# pragma map(inflateSync,"INSY") -# pragma map(inflateSetDictionary,"INSEDI") -# pragma map(inflate_blocks,"INBL") -# pragma map(inflate_blocks_new,"INBLNE") -# pragma map(inflate_blocks_free,"INBLFR") -# pragma map(inflate_blocks_reset,"INBLRE") -# pragma map(inflate_codes_free,"INCOFR") -# pragma map(inflate_codes,"INCO") -# pragma map(inflate_fast,"INFA") -# pragma map(inflate_flush,"INFLU") -# pragma map(inflate_mask,"INMA") -# pragma map(inflate_set_dictionary,"INSEDI2") -# pragma map(inflate_copyright,"INCOPY") -# pragma map(inflate_trees_bits,"INTRBI") -# pragma map(inflate_trees_dynamic,"INTRDY") -# pragma map(inflate_trees_fixed,"INTRFI") -# pragma map(inflate_trees_free,"INTRFR") -#endif - -#endif /* _ZCONF_H */ diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/zlib.3 b/contrib/vmap_extractor_v2/stormlib/zlib/zlib.3 deleted file mode 100644 index 3a6e45047fe..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/zlib.3 +++ /dev/null @@ -1,107 +0,0 @@ -.TH ZLIB 3 "11 March 2002" -.SH NAME -zlib \- compression/decompression library -.SH SYNOPSIS -[see -.I zlib.h -for full description] -.SH DESCRIPTION -The -.I zlib -library is a general purpose data compression library. -The code is thread safe. -It 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. -.LP -Compression can be done in a single step if the buffers are large enough -(for example if an input file is mmap'ed), -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. -.LP -The library also supports reading and writing files in -.I gzip -(.gz) format -with an interface similar to that of stdio. -.LP -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. -.LP -All functions of the compression library are documented in the file -.IR zlib.h. -The distribution source includes examples of use of the library -the files -.I example.c -and -.IR minigzip.c . -.LP -A Java implementation of -.IR zlib -is available in the Java Development Kit 1.1 -.IP -http://www.javasoft.com/products/JDK/1.1/docs/api/Package-java.util.zip.html -.LP -A Perl interface to -.IR zlib , -written by Paul Marquess (pmarquess@bfsec.bt.co.uk) -is available at CPAN (Comprehensive Perl Archive Network) sites, -such as: -.IP -ftp://ftp.cis.ufl.edu/pub/perl/CPAN/modules/by-module/Compress/Compress-Zlib* -.LP -A Python interface to -.IR zlib -written by A.M. Kuchling -is available from the Python Software Association sites, such as: -.IP -ftp://ftp.python.org/pub/python/contrib/Encoding/zlib*.tar.gz -.SH "SEE ALSO" -Questions about zlib should be sent to: -.IP -zlib@quest.jpl.nasa.gov -or, if this fails, to the author addresses given below. -The zlib home page is: -.IP -http://www.cdrom.com/pub/infozip/zlib/ -.LP -The data format used by the zlib library is described by RFC -(Request for Comments) 1950 to 1952 in the files: -.IP -ftp://ds.internic.net/rfc/rfc1950.txt (zlib format) -.br -rfc1951.txt (deflate format) -.br -rfc1952.txt (gzip format) -.LP -These documents are also available in other formats from: -.IP -ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html -.SH AUTHORS -Version 1.1.4 -Copyright (C) 1995-2002 Jean-loup Gailly (jloup@gzip.org) -and Mark Adler (madler@alumni.caltech.edu). -.LP -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. -See the distribution directory with respect to requirements -governing redistribution. -The deflate format used by -.I zlib -was defined by Phil Katz. -The deflate and -.I zlib -specifications were written by L. Peter Deutsch. -Thanks to all the people who reported problems and suggested various -improvements in -.IR zlib ; -who are too numerous to cite here. -.LP -UNIX manual page by R. P. C. Rodgers, -U.S. National Library of Medicine (rodgers@nlm.nih.gov). -.\" end of man page diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/zlib.h b/contrib/vmap_extractor_v2/stormlib/zlib/zlib.h deleted file mode 100644 index 52cb529f6f3..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/zlib.h +++ /dev/null @@ -1,893 +0,0 @@ -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.1.4, March 11th, 2002 - - Copyright (C) 1995-2002 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 ftp://ds.internic.net/rfc/rfc1950.txt - (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). -*/ - -#ifndef _ZLIB_H -#define _ZLIB_H - -#include "zconf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ZLIB_VERSION "1.1.4" - -/* - 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 (for example if an input file is mmap'ed), 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 library also supports reading and writing files in gzip (.gz) format - with an interface similar to that of stdio. - - 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 { - Bytef *next_in; /* next input byte */ - uInt avail_in; /* number of bytes available at next_in */ - uLong total_in; /* total nb 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 nb of bytes output so far */ - - char *msg; /* last error message, NULL if no error */ - struct internal_state FAR *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: ascii or binary */ - uLong adler; /* adler32 value of the uncompressed data */ - uLong reserved; /* reserved for future use */ -} z_stream; - -typedef z_stream FAR *z_streamp; - -/* - 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 /* will be removed, use Z_SYNC_FLUSH instead */ -#define Z_SYNC_FLUSH 2 -#define Z_FULL_FLUSH 3 -#define Z_FINISH 4 -/* Allowed flush values; see deflate() 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_DEFAULT_STRATEGY 0 -/* compression strategy; see deflateInit2() below for details */ - -#define Z_BINARY 0 -#define Z_ASCII 1 -#define Z_UNKNOWN 2 -/* Possible values of the data_type field */ - -#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, - 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. - - 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. - - 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 - the 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). - - 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 - 0.1% larger than avail_in plus 12 bytes. If deflate does not return - Z_STREAM_END, then 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 data_type if it can make a good guess about - the input data type (Z_ASCII or Z_BINARY). 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 NULL), Z_BUF_ERROR if no progress is possible - (for example avail_in or avail_out was zero). -*/ - - -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. msg is set to null if there is no error - message. inflateInit does not perform any decompression apart from reading - the zlib header if present: this will be done by inflate(). (So next_in and - avail_in may be modified, but next_out and avail_out are unchanged.) -*/ - - -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 some - 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. - - If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much - output as possible to the output buffer. The flushing behavior of inflate is - not specified for values of the flush parameter other than Z_SYNC_FLUSH - and Z_FINISH, but the current implementation actually flushes as much output - as possible anyway. - - 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 the - uncompressed data. (The size of the uncompressed data may have been saved - by the compressor for this purpose.) The next operation on this stream must - be inflateEnd to deallocate the decompression state. The use of Z_FINISH - is never required, but can be used to inform inflate that a faster routine - may be used for the single inflate() call. - - If a preset dictionary is needed at this point (see inflateSetDictionary - below), inflate sets strm-adler to the adler32 checksum of the - dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise - it sets strm->adler to the adler32 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() 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 - adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent - (for example if next_in or next_out was 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. In the Z_DATA_ERROR - case, the application may then call inflateSync to look for a good - compression block. -*/ - - -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. - - 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), or Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match). 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 and Z_HUFFMAN_ONLY. The strategy parameter only affects - the compression ratio but not the correctness of the compressed output even - if it is not set appropriately. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid - method). 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. This function must be called - immediately after deflateInit, deflateInit2 or deflateReset, before any - call of deflate. 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 in - deflate or deflate2. Thus the strings most likely to be useful should be - put at the end of the dictionary, not at the front. - - 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.) - - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state is - inconsistent (for example if deflate has already been called for this stream - or if the compression method is bsort). 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 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 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 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. 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. - - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative - memLevel). msg is set to null if there is no error message. inflateInit2 - does not perform any decompression apart from reading the zlib header if - present: this will be done by inflate(). (So next_in and avail_in may be - modified, but next_out and avail_out are unchanged.) -*/ - -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 this call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the Adler32 value returned by this call of - inflate. The compressor and decompressor must use exactly the same - dictionary (see deflateSetDictionary). - - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) 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 inflateSync OF((z_streamp strm)); -/* - Skips invalid compressed data until a full flush point (see above the - description of deflate with Z_FULL_FLUSH) can be found, or until all - available input is skipped. No output is provided. - - inflateSync returns Z_OK if a 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 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 NULL). -*/ - - - /* 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 easily 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 0.1% larger than - sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the - compressed buffer. - This function can be used to compress a whole file at once if the - input file is mmap'ed. - 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 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. -*/ - -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 compressed buffer. - This function can be used to decompress a whole file at once if the - input file is mmap'ed. - - 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. -*/ - - -typedef voidp gzFile; - -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". (See the description - of deflateInit2 for more information about the strategy parameter.) - - 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. - - gzopen returns NULL if the file could not be opened or if there was - insufficient memory to allocate the (de)compression state; errno - can be checked to distinguish the two cases (if errno is zero, the - zlib error is Z_MEM_ERROR). */ - -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 (in 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 gzdopen(dup(fd), mode). - gzdopen returns NULL if there was insufficient memory to allocate - the (de)compression state. -*/ - -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 was not in gzip format, gzread copies the given number - of bytes into the buffer. - gzread returns the number of uncompressed bytes actually read (0 for - end of file, -1 for error). */ - -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - const voidp buf, unsigned len)); -/* - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of uncompressed bytes actually written - (0 in case of error). -*/ - -ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); -/* - Converts, formats, and writes the args to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written (0 in case of error). -*/ - -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. The string is then terminated with a null - character. - gzgets returns buf, or Z_NULL in case of error. -*/ - -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. -*/ - -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 returns Z_OK if - the flush parameter is Z_FINISH and all output could be flushed. - gzflush should be called only when strictly necessary because it can - degrade compression. -*/ - -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. - - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) -*/ - -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); -/* - Returns 1 when EOF has previously been detected reading the given - input stream, otherwise zero. -*/ - -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); -/* - Flushes all pending output if necessary, closes the compressed file - and deallocates all the (de)compression state. The return value is the zlib - error number (see function gzerror below). -*/ - -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. -*/ - - /* 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 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 crc32 OF((uLong crc, const Bytef *buf, uInt len)); -/* - Update a running crc with the bytes buf[0..len-1] and return the updated - crc. If buf is 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(); -*/ - - - /* 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)); -#define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) -#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) - - -#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL) - struct internal_state {int dummy;}; /* hack for buggy compilers */ -#endif - -ZEXTERN const char * ZEXPORT zError OF((int err)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); -ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); - -#ifdef __cplusplus -} -#endif - -#endif /* _ZLIB_H */ diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/zlib.html b/contrib/vmap_extractor_v2/stormlib/zlib/zlib.html deleted file mode 100644 index c3437038693..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/zlib.html +++ /dev/null @@ -1,971 +0,0 @@ - - - - zlib general purpose compression library version 1.1.4 - - - - - -

zlib 1.1.4 Manual

-
-

Contents

-
    -
  1. Prologue -
  2. Introduction -
  3. Utility functions -
  4. Basic functions -
  5. Advanced functions -
  6. Constants -
  7. struct z_stream_s -
  8. Checksum functions -
  9. Misc -
-
-

Prologue

- 'zlib' general purpose compression library version 1.1.4, March 11th, 2002 -

- Copyright (C) 1995-2002 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 -
jloup@gzip.org -
Mark Adler -
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 - - ftp://ds.internic.net/rfc/rfc1950.txt - (zlib format), - - rfc1951.txt - (deflate format) and - - rfc1952.txt - (gzip format). -

- This manual is converted from zlib.h by - piaip -

- Visit - http://ftp.cdrom.com/pub/infozip/zlib/ - for the official zlib web page. -

- -


-

Introduction

- 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 (for example if an input file is mmap'ed), 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 library also supports reading and writing files in gzip (.gz) format - with an interface similar to that of stdio. -

- - 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. -

- -


-

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 easily be modified if you need special options. -

Function list

-
    -
  • int compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); -
  • int compress2 (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level); -
  • int uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); -
  • typedef voidp gzFile; -
  • gzFile gzopen (const char *path, const char *mode); -
  • gzFile gzdopen (int fd, const char *mode); -
  • int gzsetparams (gzFile file, int level, int strategy); -
  • int gzread (gzFile file, voidp buf, unsigned len); -
  • int gzwrite (gzFile file, const voidp buf, unsigned len); -
  • int VA gzprintf (gzFile file, const char *format, ...); -
  • int gzputs (gzFile file, const char *s); -
  • char * gzgets (gzFile file, char *buf, int len); -
  • int gzputc (gzFile file, int c); -
  • int gzgetc (gzFile file); -
  • int gzflush (gzFile file, int flush); -
  • z_off_t gzseek (gzFile file, z_off_t offset, int whence); -
  • z_off_t gztell (gzFile file); -
  • int gzrewind (gzFile file); -
  • int gzeof (gzFile file); -
  • int gzclose (gzFile file); -
  • const char * gzerror (gzFile file, int *errnum); -
-

Function description

-
-
int compress (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 0.1% larger than - sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the - compressed buffer.

- This function can be used to compress a whole file at once if the - input file is mmap'ed.

- 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.

- -

int compress2 (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 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 uncompress (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 compressed buffer.

- This function can be used to decompress a whole file at once if the - input file is mmap'ed. -

- - 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. -

- -

typedef voidp gzFile; -

- -

gzFile gzopen (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". (See the description - of deflateInit2 for more information about the strategy parameter.) -

- - 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. -

- - gzopen returns NULL if the file could not be opened or if there was - insufficient memory to allocate the (de)compression state ; errno - can be checked to distinguish the two cases (if errno is zero, the - zlib error is Z_MEM_ERROR). -

- -

gzFile gzdopen (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 (in 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 gzdopen(dup(fd), mode). -

- gzdopen returns NULL if there was insufficient memory to allocate - the (de)compression state. -

- -

int gzsetparams (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. -

- -

int gzread (gzFile file, voidp buf, unsigned len); -
- Reads the given number of uncompressed bytes from the compressed file. - If the input file was not in gzip format, gzread copies the given number - of bytes into the buffer. -

- gzread returns the number of uncompressed bytes actually read (0 for - end of file, -1 for error). -

- -

int gzwrite (gzFile file, const voidp buf, unsigned len); -
- Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of uncompressed bytes actually written - (0 in case of error). -

- -

int VA gzprintf (gzFile file, const char *format, ...); -
- Converts, formats, and writes the args to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written (0 in case of error). -

- -

int gzputs (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. -

- -

char * gzgets (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. The string is then terminated with a null - character. -

- gzgets returns buf, or Z_NULL in case of error. -

- -

int gzputc (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. -

- -

int gzgetc (gzFile file); -
- Reads one byte from the compressed file. gzgetc returns this byte - or -1 in case of end of file or error. -

- -

int gzflush (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 returns Z_OK if - the flush parameter is Z_FINISH and all output could be flushed. -

- gzflush should be called only when strictly necessary because it can - degrade compression. -

- -

z_off_t gzseek (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. -

- -

int gzrewind (gzFile file); -
- Rewinds the given file. This function is supported only for reading. -

- gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) -

- -

z_off_t gztell (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. -

- - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) -

- -

int gzeof (gzFile file); -
- Returns 1 when EOF has previously been detected reading the given - input stream, otherwise zero. -

- -

int gzclose (gzFile file); -
- Flushes all pending output if necessary, closes the compressed file - and deallocates all the (de)compression state. The return value is the zlib - error number (see function gzerror below). -

- -

const char * gzerror (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. -

-

-
-

Basic functions

-

Function list

-
- -

Function description

-
-
const char * zlibVersion (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. -

- -

int deflateInit (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, - 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(). -

- -

int deflate (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. -

- - 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. -

- - 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 - the 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). -

- - 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 - 0.1% larger than avail_in plus 12 bytes. If deflate does not return - Z_STREAM_END, then 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 data_type if it can make a good guess about - the input data type (Z_ASCII or Z_BINARY). 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 NULL), Z_BUF_ERROR if no progress is possible - (for example avail_in or avail_out was zero). -

- -

int deflateEnd (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). -

- -

int inflateInit (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. msg is set to null if there is no error - message. inflateInit does not perform any decompression apart from reading - the zlib header if present: this will be done by inflate(). (So next_in and - avail_in may be modified, but next_out and avail_out are unchanged.) -

- -

int inflate (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 some - 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. -

- - If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much - output as possible to the output buffer. The flushing behavior of inflate is - not specified for values of the flush parameter other than Z_SYNC_FLUSH - and Z_FINISH, but the current implementation actually flushes as much output - as possible anyway. -

- - 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 the - uncompressed data. (The size of the uncompressed data may have been saved - by the compressor for this purpose.) The next operation on this stream must - be inflateEnd to deallocate the decompression state. The use of Z_FINISH - is never required, but can be used to inform inflate that a faster routine - may be used for the single inflate() call. -

- - If a preset dictionary is needed at this point (see inflateSetDictionary - below), inflate sets strm-adler to the adler32 checksum of the - dictionary chosen by the compressor and returns Z_NEED_DICT ; otherwise - it sets strm-> adler to the adler32 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() 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 - adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent - (for example if next_in or next_out was 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. In the Z_DATA_ERROR - case, the application may then call inflateSync to look for a good - compression block. -

- -

int inflateEnd (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. -

Function list

-
-

Function description

-
-
int deflateInit2 (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.

- - 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), or Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match). 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 and Z_HUFFMAN_ONLY. The strategy parameter only affects - the compression ratio but not the correctness of the compressed output even - if it is not set appropriately.

- - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid - method). msg is set to null if there is no error message. deflateInit2 does - not perform any compression: this will be done by deflate().

- -

int deflateSetDictionary (z_streamp strm, const Bytef *dictionary, uInt dictLength); -
- Initializes the compression dictionary from the given byte sequence - without producing any compressed output. This function must be called - immediately after deflateInit, deflateInit2 or deflateReset, before any - call of deflate. 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 in - deflate or deflate2. Thus the strings most likely to be useful should be - put at the end of the dictionary, not at the front.

- - 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.)

- - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state is - inconsistent (for example if deflate has already been called for this stream - or if the compression method is bsort). deflateSetDictionary does not - perform any compression: this will be done by deflate().

- -

int deflateCopy (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 NULL). msg is left unchanged in both source and - destination.

- -

int deflateReset (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 NULL).

- -

int deflateParams (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.

- -

int inflateInit2 (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. 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.

- - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative - memLevel). msg is set to null if there is no error message. inflateInit2 - does not perform any decompression apart from reading the zlib header if - present: this will be done by inflate(). (So next_in and avail_in may be - modified, but next_out and avail_out are unchanged.)

- -

int inflateSetDictionary (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 this call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the Adler32 value returned by this call of - inflate. The compressor and decompressor must use exactly the same - dictionary (see deflateSetDictionary).

- - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) 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().

- -

int inflateSync (z_streamp strm); - -
Skips invalid compressed data until a full flush point (see above the - description of deflate with Z_FULL_FLUSH) can be found, or until all - available input is skipped. No output is provided.

- - inflateSync returns Z_OK if a 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.

- -

int inflateReset (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 NULL). -

-

- -
-

Checksum functions

- These functions are not related to compression but are exported - anyway because they might be useful in applications using the - compression library. -

Function list

-
-

Function description

-
-
uLong adler32 (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 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();
-   
- -
uLong crc32 (uLong crc, const Bytef *buf, uInt len); -
- Update a running crc with the bytes buf[0..len-1] and return the updated - crc. If buf is 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();
-   
-
-
-

struct z_stream_s

- -
-
-typedef struct z_stream_s {
-    Bytef    *next_in;  /* next input byte */
-    uInt     avail_in;  /* number of bytes available at next_in */
-    uLong    total_in;  /* total nb 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 nb of bytes output so far */
-
-    char     *msg;      /* last error message, NULL if no error */
-    struct internal_state FAR *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: ascii or binary */
-    uLong   adler;      /* adler32 value of the uncompressed data */
-    uLong   reserved;   /* reserved for future use */
-} z_stream ;
-
-typedef z_stream FAR * z_streamp;  ÿ 
-
-
- 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 
-	/* will be removed, use Z_SYNC_FLUSH instead */
-#define Z_SYNC_FLUSH    2
-#define Z_FULL_FLUSH    3
-#define Z_FINISH        4
-/* Allowed flush values ; see deflate() 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_DEFAULT_STRATEGY    0
-/* compression strategy ; see deflateInit2() below for details */
-
-#define Z_BINARY   0
-#define Z_ASCII    1
-#define Z_UNKNOWN  2
-/* Possible values of the data_type field */
-
-#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 less than 1.0.2 */
-
-
- -
-

Misc

-
deflateInit and inflateInit are macros to allow checking the zlib version - and the compiler's view of z_stream. -

- Other functions: -

-
const char * zError (int err); -
int inflateSyncPoint (z_streamp z); -
const uLongf * get_crc_table (void); -
-
- - Last update: Wed Oct 13 20:42:34 1999
- piapi@csie.ntu.edu.tw -
- - - diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/zmemory.c b/contrib/vmap_extractor_v2/stormlib/zlib/zmemory.c deleted file mode 100644 index fc9749c5711..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/zmemory.c +++ /dev/null @@ -1,19 +0,0 @@ -/* zmemory.c - Internal memory alloc and memory free functions - */ - -#include - -#include "zlib.h" - -const char *z_errmsg[10]; // Needed by zlib - -voidpf zcalloc(voidpf opaque, uInt items, uInt size) -{ - return (voidpf)calloc(items, size); -} - -void zcfree(voidpf opaque, voidpf address) -{ - free(address); -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/zutil.c b/contrib/vmap_extractor_v2/stormlib/zlib/zutil.c deleted file mode 100644 index 9a076221f2a..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/zutil.c +++ /dev/null @@ -1,87 +0,0 @@ -/* inflate_util.c -- data and routines common to blocks and codes - * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "infblock.h" -#include "inftrees.h" -#include "infcodes.h" -#include "infutil.h" - -struct inflate_codes_state {int dummy;}; /* for buggy compilers */ - -/* And'ing with mask[n] masks the lower n bits */ -uInt inflate_mask[17] = { - 0x0000, - 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, - 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff -}; - - -/* copy as much as possible from the sliding window to the output area */ -int inflate_flush(s, z, r) -inflate_blocks_statef *s; -z_streamp z; -int r; -{ - uInt n; - Bytef *p; - Bytef *q; - - /* local copies of source and destination pointers */ - p = z->next_out; - q = s->read; - - /* compute number of bytes to copy as far as end of window */ - n = (uInt)((q <= s->write ? s->write : s->end) - q); - if (n > z->avail_out) n = z->avail_out; - if (n && r == Z_BUF_ERROR) r = Z_OK; - - /* update counters */ - z->avail_out -= n; - z->total_out += n; - - /* update check information */ - if (s->checkfn != Z_NULL) - z->adler = s->check = (*s->checkfn)(s->check, q, n); - - /* copy as far as end of window */ - zmemcpy(p, q, n); - p += n; - q += n; - - /* see if more to copy at beginning of window */ - if (q == s->end) - { - /* wrap pointers */ - q = s->window; - if (s->write == s->end) - s->write = s->window; - - /* compute bytes to copy */ - n = (uInt)(s->write - q); - if (n > z->avail_out) n = z->avail_out; - if (n && r == Z_BUF_ERROR) r = Z_OK; - - /* update counters */ - z->avail_out -= n; - z->total_out += n; - - /* update check information */ - if (s->checkfn != Z_NULL) - z->adler = s->check = (*s->checkfn)(s->check, q, n); - - /* copy */ - zmemcpy(p, q, n); - p += n; - q += n; - } - - /* update pointers */ - z->next_out = p; - s->read = q; - - /* done */ - return r; -} diff --git a/contrib/vmap_extractor_v2/stormlib/zlib/zutil.h b/contrib/vmap_extractor_v2/stormlib/zlib/zutil.h deleted file mode 100644 index 718ebc15be1..00000000000 --- a/contrib/vmap_extractor_v2/stormlib/zlib/zutil.h +++ /dev/null @@ -1,220 +0,0 @@ -/* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-2002 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 _Z_UTIL_H -#define _Z_UTIL_H - -#include "zlib.h" - -#ifdef STDC -# include -# include -# include -#endif -#ifdef NO_ERRNO_H - extern int errno; -#else -# include -#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 const char *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 = (char*)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 */ - -#ifdef MSDOS -# define OS_CODE 0x00 -# 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 -# endif -# else /* MSC or DJGPP */ -# include -# endif -#endif - -#ifdef OS2 -# define OS_CODE 0x06 -#endif - -#ifdef WIN32 /* Window 95 & Windows NT */ -# define OS_CODE 0x0b -#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 - -#ifdef AMIGA -# define OS_CODE 0x01 -#endif - -#if defined(ATARI) || defined(atarist) -# define OS_CODE 0x05 -#endif - -#if defined(MACOS) || defined(TARGET_OS_MAC) -# define OS_CODE 0x07 -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include /* for fdopen */ -# else -# ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ -# endif -# endif -#endif - -#ifdef __50SERIES /* Prime/PRIMOS */ -# define OS_CODE 0x0F -#endif - -#ifdef TOPS20 -# define OS_CODE 0x0a -#endif - -#if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ -#endif - -#if (defined(_MSC_VER) && (_MSC_VER > 600)) -# define fdopen(fd,type) _fdopen(fd,type) -#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 */ - -#ifdef HAVE_STRERROR - extern char *strerror OF((int)); -# define zstrerror(errnum) strerror(errnum) -#else -# define zstrerror(errnum) "" -#endif - -#if defined(pyr) -# 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 - extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); - extern void zmemzero OF((Bytef* dest, uInt len)); -#endif - -/* Diagnostic functions */ -#ifdef DEBUG -# include - extern int z_verbose; - extern void 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 - - -typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf, - uInt len)); -voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); -void zcfree OF((voidpf opaque, voidpf ptr)); - -#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);} - -#endif /* _Z_UTIL_H */ diff --git a/contrib/vmap_extractor_v2/stormlibdll/DllMain.c b/contrib/vmap_extractor_v2/stormlibdll/DllMain.c deleted file mode 100644 index cbfa84a08a8..00000000000 --- a/contrib/vmap_extractor_v2/stormlibdll/DllMain.c +++ /dev/null @@ -1,24 +0,0 @@ -/*****************************************************************************/ -/* DllMain.c Copyright (c) Ladislav Zezula 2006 */ -/*---------------------------------------------------------------------------*/ -/* Description: DllMain for the StormLib.dll library */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 23.11.06 1.00 Lad The first version of DllMain.c */ -/*****************************************************************************/ - -#define WIN32_LEAN_AND_MEAN -#include - -//----------------------------------------------------------------------------- -// DllMain - -DWORD WINAPI DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID lpReserved) -{ - UNREFERENCED_PARAMETER(hInst); - UNREFERENCED_PARAMETER(dwReason); - UNREFERENCED_PARAMETER(lpReserved); - - return TRUE; -} diff --git a/contrib/vmap_extractor_v2/stormlibdll/StormLib.def b/contrib/vmap_extractor_v2/stormlibdll/StormLib.def deleted file mode 100644 index c220b6dcca4..00000000000 --- a/contrib/vmap_extractor_v2/stormlibdll/StormLib.def +++ /dev/null @@ -1,47 +0,0 @@ -LIBRARY StormLib.dll - -EXPORTS - - SFileSetLocale - SFileGetLocale - SFileOpenArchive - SFileCloseArchive - - SFileOpenFileEx - SFileCloseFile - SFileGetFilePos - SFileGetFileSize - SFileSetFilePointer - SFileReadFile - SFileExtractFile - - SFileAddListFile - - SFileCreateArchiveEx - - SFileAddFile - SFileAddWave - SFileRemoveFile - SFileRenameFile - SFileSetFileLocale - - SFileHasFile - SFileGetFileName - SFileGetFileInfo - - SFileFindFirstFile - SFileFindNextFile - SFileFindClose - - SListFileFindFirstFile - SListFileFindNextFile - SListFileFindClose - - SFileSetCompactCallback - SFileCompactArchive - - SFileEnumLocales - - SCompCompress - SCompDecompress - SCompSetDataCompression diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 3f3413b1b1e..f3db3dc64eb 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10165" + #define REVISION_NR "10166" #endif // __REVISION_NR_H__