├── .qmake.conf ├── LICENSE.FDL ├── LICENSE.GPL ├── LICENSE.LGPL ├── LICENSE.PREVIEW.COMMERCIAL ├── README ├── examples └── examples.pro ├── qtcompress.pro ├── qtcompress.pro.user ├── src ├── 3rdparty │ ├── zlib.pri │ └── zlib │ │ ├── CMakeLists.txt │ │ ├── ChangeLog │ │ ├── FAQ │ │ ├── INDEX │ │ ├── README │ │ ├── adler32.c │ │ ├── compress.c │ │ ├── crc32.c │ │ ├── crc32.h │ │ ├── deflate.c │ │ ├── deflate.h │ │ ├── doc │ │ ├── algorithm.txt │ │ ├── rfc1950.txt │ │ ├── rfc1951.txt │ │ ├── rfc1952.txt │ │ └── txtvsbin.txt │ │ ├── example.c │ │ ├── gzclose.c │ │ ├── gzguts.h │ │ ├── gzlib.c │ │ ├── gzread.c │ │ ├── gzwrite.c │ │ ├── infback.c │ │ ├── inffast.c │ │ ├── inffast.h │ │ ├── inffixed.h │ │ ├── inflate.c │ │ ├── inflate.h │ │ ├── inftrees.c │ │ ├── inftrees.h │ │ ├── minigzip.c │ │ ├── treebuild.xml │ │ ├── trees.c │ │ ├── trees.h │ │ ├── uncompr.c │ │ ├── zconf.h │ │ ├── zconf.h.cmakein │ │ ├── zconf.h.in │ │ ├── zlib.3 │ │ ├── zlib.3.pdf │ │ ├── zlib.h │ │ ├── zlib.pc.in │ │ ├── zutil.c │ │ └── zutil.h ├── compress │ ├── compress.pro │ ├── compress.pro.user │ ├── qtcompressglobal.h │ ├── qzip.cpp │ ├── qzipreader.h │ └── qzipwriter.h └── src.pro ├── sync.profile └── tests ├── auto ├── .gitignore ├── auto.pro ├── cmake │ ├── CMakeLists.txt │ └── cmake.pro └── unit │ ├── qzip │ ├── qzip.pro │ ├── testdata │ │ ├── symlink.zip │ │ ├── test.zip │ │ └── test │ │ │ └── test.txt │ └── tst_qzip.cpp │ └── unit.pro └── tests.pro /.qmake.conf: -------------------------------------------------------------------------------- 1 | load(qt_build_config) 2 | MODULE_VERSION = 5.11.0 -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | QtCompress module for Qt 5 2 | 3 | A public API for QZipReader and QZipWriter in an easy to use module 4 | 5 | Just run qmake and the make to build and install 6 | 7 | Then when you want to use QZip in your project, just add the following line to your .pro file 8 | QT += compress -------------------------------------------------------------------------------- /examples/examples.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS += -------------------------------------------------------------------------------- /qtcompress.pro: -------------------------------------------------------------------------------- 1 | load(qt_parts) -------------------------------------------------------------------------------- /src/3rdparty/zlib.pri: -------------------------------------------------------------------------------- 1 | wince*: DEFINES += NO_ERRNO_H 2 | INCLUDEPATH += $$PWD/zlib 3 | SOURCES+= \ 4 | $$PWD/zlib/adler32.c \ 5 | $$PWD/zlib/compress.c \ 6 | $$PWD/zlib/crc32.c \ 7 | $$PWD/zlib/deflate.c \ 8 | $$PWD/zlib/gzclose.c \ 9 | $$PWD/zlib/gzlib.c \ 10 | $$PWD/zlib/gzread.c \ 11 | $$PWD/zlib/gzwrite.c \ 12 | $$PWD/zlib/infback.c \ 13 | $$PWD/zlib/inffast.c \ 14 | $$PWD/zlib/inflate.c \ 15 | $$PWD/zlib/inftrees.c \ 16 | $$PWD/zlib/trees.c \ 17 | $$PWD/zlib/uncompr.c \ 18 | $$PWD/zlib/zutil.c 19 | 20 | TR_EXCLUDE += $$PWD/* 21 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.4.4) 2 | set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) 3 | 4 | project(zlib C) 5 | 6 | if(NOT DEFINED BUILD_SHARED_LIBS) 7 | option(BUILD_SHARED_LIBS "Build a shared library form of zlib" ON) 8 | endif() 9 | 10 | include(CheckTypeSize) 11 | include(CheckFunctionExists) 12 | include(CheckIncludeFile) 13 | include(CheckCSourceCompiles) 14 | enable_testing() 15 | 16 | check_include_file(sys/types.h HAVE_SYS_TYPES_H) 17 | check_include_file(stdint.h HAVE_STDINT_H) 18 | check_include_file(stddef.h HAVE_STDDEF_H) 19 | 20 | # 21 | # Check to see if we have large file support 22 | # 23 | set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1) 24 | # We add these other definitions here because CheckTypeSize.cmake 25 | # in CMake 2.4.x does not automatically do so and we want 26 | # compatibility with CMake 2.4.x. 27 | if(HAVE_SYS_TYPES_H) 28 | list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H) 29 | endif() 30 | if(HAVE_STDINT_H) 31 | list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H) 32 | endif() 33 | if(HAVE_STDDEF_H) 34 | list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H) 35 | endif() 36 | check_type_size(off64_t OFF64_T) 37 | if(HAVE_OFF64_T) 38 | add_definitions(-D_LARGEFILE64_SOURCE=1) 39 | endif() 40 | set(CMAKE_REQUIRED_DEFINITIONS) # clear variable 41 | 42 | # 43 | # Check for fseeko 44 | # 45 | check_function_exists(fseeko HAVE_FSEEKO) 46 | if(NOT HAVE_FSEEKO) 47 | add_definitions(-DNO_FSEEKO) 48 | endif() 49 | 50 | # 51 | # Check for unistd.h 52 | # 53 | check_include_file(unistd.h Z_HAVE_UNISTD_H) 54 | 55 | if(MSVC) 56 | set(CMAKE_DEBUG_POSTFIX "d") 57 | add_definitions(-D_CRT_SECURE_NO_DEPRECATE) 58 | add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) 59 | endif() 60 | 61 | if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) 62 | # If we're doing an out of source build and the user has a zconf.h 63 | # in their source tree... 64 | if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h) 65 | message(FATAL_ERROR 66 | "You must remove ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h " 67 | "from the source tree. This file is included with zlib " 68 | "but CMake generates this file for you automatically " 69 | "in the build directory.") 70 | endif() 71 | endif() 72 | 73 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein 74 | ${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY) 75 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) 76 | 77 | 78 | #============================================================================ 79 | # zlib 80 | #============================================================================ 81 | 82 | set(ZLIB_PUBLIC_HDRS 83 | ${CMAKE_CURRENT_BINARY_DIR}/zconf.h 84 | zlib.h 85 | ) 86 | set(ZLIB_PRIVATE_HDRS 87 | crc32.h 88 | deflate.h 89 | gzguts.h 90 | inffast.h 91 | inffixed.h 92 | inflate.h 93 | inftrees.h 94 | trees.h 95 | zutil.h 96 | ) 97 | set(ZLIB_SRCS 98 | adler32.c 99 | compress.c 100 | crc32.c 101 | deflate.c 102 | gzclose.c 103 | gzlib.c 104 | gzread.c 105 | gzwrite.c 106 | inflate.c 107 | infback.c 108 | inftrees.c 109 | inffast.c 110 | trees.c 111 | uncompr.c 112 | zutil.c 113 | win32/zlib1.rc 114 | ) 115 | 116 | # parse the full version number from zlib.h and include in ZLIB_FULL_VERSION 117 | file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents) 118 | string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([0-9A-Za-z.]+)\".*" 119 | "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) 120 | 121 | if(MINGW) 122 | # This gets us DLL resource information when compiling on MinGW. 123 | add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj 124 | COMMAND windres.exe 125 | -D GCC_WINDRES 126 | -I ${CMAKE_CURRENT_SOURCE_DIR} 127 | -I ${CMAKE_CURRENT_BINARY_DIR} 128 | -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj 129 | -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc) 130 | set(ZLIB_SRCS ${ZLIB_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) 131 | endif(MINGW) 132 | 133 | add_library(zlib ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) 134 | set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) 135 | 136 | set_target_properties(zlib PROPERTIES SOVERSION 1) 137 | 138 | if(NOT CYGWIN) 139 | # This property causes shared libraries on Linux to have the full version 140 | # encoded into their final filename. We disable this on Cygwin because 141 | # it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll 142 | # seems to be the default. 143 | # 144 | # This has no effect with MSVC, on that platform the version info for 145 | # the DLL comes from the resource file win32/zlib1.rc 146 | set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION}) 147 | endif() 148 | 149 | if(UNIX) 150 | # On unix-like platforms the library is almost always called libz 151 | set_target_properties(zlib PROPERTIES OUTPUT_NAME z) 152 | elseif(BUILD_SHARED_LIBS AND WIN32) 153 | # Creates zlib1.dll when building shared library version 154 | set_target_properties(zlib PROPERTIES SUFFIX "1.dll") 155 | endif() 156 | 157 | if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) 158 | install(TARGETS zlib 159 | RUNTIME DESTINATION bin 160 | ARCHIVE DESTINATION lib 161 | LIBRARY DESTINATION lib ) 162 | endif() 163 | if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL ) 164 | install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION include) 165 | endif() 166 | if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) 167 | install(FILES zlib.3 DESTINATION share/man/man3) 168 | endif() 169 | 170 | #============================================================================ 171 | # Example binaries 172 | #============================================================================ 173 | 174 | add_executable(example example.c) 175 | target_link_libraries(example zlib) 176 | add_test(example example) 177 | 178 | add_executable(minigzip minigzip.c) 179 | target_link_libraries(minigzip zlib) 180 | 181 | if(HAVE_OFF64_T) 182 | add_executable(example64 example.c) 183 | target_link_libraries(example64 zlib) 184 | set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") 185 | add_test(example64 example64) 186 | 187 | add_executable(minigzip64 minigzip.c) 188 | target_link_libraries(minigzip64 zlib) 189 | set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") 190 | endif() 191 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nezticle/qtcompress/23f8831826cd72aedf99fc3699148b6c994fd677/src/3rdparty/zlib/ChangeLog -------------------------------------------------------------------------------- /src/3rdparty/zlib/INDEX: -------------------------------------------------------------------------------- 1 | CMakeLists.txt cmake build file 2 | ChangeLog history of changes 3 | FAQ Frequently Asked Questions about zlib 4 | INDEX this file 5 | Makefile dummy Makefile that tells you to ./configure 6 | Makefile.in template for Unix Makefile 7 | README guess what 8 | configure configure script for Unix 9 | make_vms.com makefile for VMS 10 | treebuild.xml XML description of source file dependencies 11 | zconf.h.cmakein zconf.h template for cmake 12 | zconf.h.in zconf.h template for configure 13 | zlib.3 Man page for zlib 14 | zlib.3.pdf Man page in PDF format 15 | zlib.map Linux symbol information 16 | zlib.pc.in Template for pkg-config descriptor 17 | zlib2ansi perl script to convert source files for C++ compilation 18 | 19 | amiga/ makefiles for Amiga SAS C 20 | doc/ documentation for formats and algorithms 21 | msdos/ makefiles for MSDOS 22 | nintendods/ makefile for Nintendo DS 23 | old/ makefiles for various architectures and zlib documentation 24 | files that have not yet been updated for zlib 1.2.x 25 | qnx/ makefiles for QNX 26 | watcom/ makefiles for OpenWatcom 27 | win32/ makefiles for Windows 28 | 29 | zlib public header files (required for library use): 30 | zconf.h 31 | zlib.h 32 | 33 | private source files used to build the zlib library: 34 | adler32.c 35 | compress.c 36 | crc32.c 37 | crc32.h 38 | deflate.c 39 | deflate.h 40 | gzclose.c 41 | gzguts.h 42 | gzlib.c 43 | gzread.c 44 | gzwrite.c 45 | infback.c 46 | inffast.c 47 | inffast.h 48 | inffixed.h 49 | inflate.c 50 | inflate.h 51 | inftrees.c 52 | inftrees.h 53 | trees.c 54 | trees.h 55 | uncompr.c 56 | zutil.c 57 | zutil.h 58 | 59 | source files for sample programs: 60 | example.c 61 | minigzip.c 62 | See examples/README.examples for more 63 | 64 | unsupported contribution by third parties 65 | See contrib/README.contrib 66 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/README: -------------------------------------------------------------------------------- 1 | ZLIB DATA COMPRESSION LIBRARY 2 | 3 | zlib 1.2.5 is a general purpose data compression library. All the code is 4 | thread safe. The data format used by the zlib library is described by RFCs 5 | (Request for Comments) 1950 to 1952 in the files 6 | http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) 7 | and rfc1952.txt (gzip format). 8 | 9 | All functions of the compression library are documented in the file zlib.h 10 | (volunteer to write man pages welcome, contact zlib@gzip.org). A usage example 11 | of the library is given in the file example.c which also tests that the library 12 | is working correctly. Another example is given in the file minigzip.c. The 13 | compression library itself is composed of all source files except example.c and 14 | minigzip.c. 15 | 16 | To compile all files and run the test program, follow the instructions given at 17 | the top of Makefile.in. In short "./configure; make test", and if that goes 18 | well, "make install" should work for most flavors of Unix. For Windows, use one 19 | of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use 20 | make_vms.com. 21 | 22 | Questions about zlib should be sent to , or to Gilles Vollant 23 | for the Windows DLL version. The zlib home page is 24 | http://zlib.net/ . Before reporting a problem, please check this site to 25 | verify that you have the latest version of zlib; otherwise get the latest 26 | version and check whether the problem still exists or not. 27 | 28 | PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help. 29 | 30 | Mark Nelson wrote an article about zlib for the Jan. 1997 31 | issue of Dr. Dobb's Journal; a copy of the article is available at 32 | http://marknelson.us/1997/01/01/zlib-engine/ . 33 | 34 | The changes made in version 1.2.5 are documented in the file ChangeLog. 35 | 36 | Unsupported third party contributions are provided in directory contrib/ . 37 | 38 | zlib is available in Java using the java.util.zip package, documented at 39 | http://java.sun.com/developer/technicalArticles/Programming/compression/ . 40 | 41 | A Perl interface to zlib written by Paul Marquess is available 42 | at CPAN (Comprehensive Perl Archive Network) sites, including 43 | http://search.cpan.org/~pmqs/IO-Compress-Zlib/ . 44 | 45 | A Python interface to zlib written by A.M. Kuchling is 46 | available in Python 1.5 and later versions, see 47 | http://www.python.org/doc/lib/module-zlib.html . 48 | 49 | zlib is built into tcl: http://wiki.tcl.tk/4610 . 50 | 51 | An experimental package to read and write files in .zip format, written on top 52 | of zlib by Gilles Vollant , is available in the 53 | contrib/minizip directory of zlib. 54 | 55 | 56 | Notes for some targets: 57 | 58 | - For Windows DLL versions, please see win32/DLL_FAQ.txt 59 | 60 | - For 64-bit Irix, deflate.c must be compiled without any optimization. With 61 | -O, one libpng test fails. The test works in 32 bit mode (with the -n32 62 | compiler flag). The compiler bug has been reported to SGI. 63 | 64 | - zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works 65 | when compiled with cc. 66 | 67 | - On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is 68 | necessary to get gzprintf working correctly. This is done by configure. 69 | 70 | - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with 71 | other compilers. Use "make test" to check your compiler. 72 | 73 | - gzdopen is not supported on RISCOS or BEOS. 74 | 75 | - For PalmOs, see http://palmzlib.sourceforge.net/ 76 | 77 | 78 | Acknowledgments: 79 | 80 | The deflate format used by zlib was defined by Phil Katz. The deflate and 81 | zlib specifications were written by L. Peter Deutsch. Thanks to all the 82 | people who reported problems and suggested various improvements in zlib; they 83 | are too numerous to cite here. 84 | 85 | Copyright notice: 86 | 87 | (C) 1995-2010 Jean-loup Gailly and Mark Adler 88 | 89 | This software is provided 'as-is', without any express or implied 90 | warranty. In no event will the authors be held liable for any damages 91 | arising from the use of this software. 92 | 93 | Permission is granted to anyone to use this software for any purpose, 94 | including commercial applications, and to alter it and redistribute it 95 | freely, subject to the following restrictions: 96 | 97 | 1. The origin of this software must not be misrepresented; you must not 98 | claim that you wrote the original software. If you use this software 99 | in a product, an acknowledgment in the product documentation would be 100 | appreciated but is not required. 101 | 2. Altered source versions must be plainly marked as such, and must not be 102 | misrepresented as being the original software. 103 | 3. This notice may not be removed or altered from any source distribution. 104 | 105 | Jean-loup Gailly Mark Adler 106 | jloup@gzip.org madler@alumni.caltech.edu 107 | 108 | If you use the zlib library in a product, we would appreciate *not* receiving 109 | lengthy legal documents to sign. The sources are provided for free but without 110 | warranty of any kind. The library has been entirely written by Jean-loup 111 | Gailly and Mark Adler; it does not include third-party code. 112 | 113 | If you redistribute modified sources, we would appreciate that you include in 114 | the file ChangeLog history information documenting your changes. Please read 115 | the FAQ for more information on the distribution of modified source versions. 116 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/adler32.c: -------------------------------------------------------------------------------- 1 | /* adler32.c -- compute the Adler-32 checksum of a data stream 2 | * Copyright (C) 1995-2007 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #include "zutil.h" 9 | 10 | #define local static 11 | 12 | local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2); 13 | 14 | #define BASE 65521UL /* largest prime smaller than 65536 */ 15 | #define NMAX 5552 16 | /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ 17 | 18 | #define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} 19 | #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); 20 | #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); 21 | #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); 22 | #define DO16(buf) DO8(buf,0); DO8(buf,8); 23 | 24 | /* use NO_DIVIDE if your processor does not do division in hardware */ 25 | #ifdef NO_DIVIDE 26 | # define MOD(a) \ 27 | do { \ 28 | if (a >= (BASE << 16)) a -= (BASE << 16); \ 29 | if (a >= (BASE << 15)) a -= (BASE << 15); \ 30 | if (a >= (BASE << 14)) a -= (BASE << 14); \ 31 | if (a >= (BASE << 13)) a -= (BASE << 13); \ 32 | if (a >= (BASE << 12)) a -= (BASE << 12); \ 33 | if (a >= (BASE << 11)) a -= (BASE << 11); \ 34 | if (a >= (BASE << 10)) a -= (BASE << 10); \ 35 | if (a >= (BASE << 9)) a -= (BASE << 9); \ 36 | if (a >= (BASE << 8)) a -= (BASE << 8); \ 37 | if (a >= (BASE << 7)) a -= (BASE << 7); \ 38 | if (a >= (BASE << 6)) a -= (BASE << 6); \ 39 | if (a >= (BASE << 5)) a -= (BASE << 5); \ 40 | if (a >= (BASE << 4)) a -= (BASE << 4); \ 41 | if (a >= (BASE << 3)) a -= (BASE << 3); \ 42 | if (a >= (BASE << 2)) a -= (BASE << 2); \ 43 | if (a >= (BASE << 1)) a -= (BASE << 1); \ 44 | if (a >= BASE) a -= BASE; \ 45 | } while (0) 46 | # define MOD4(a) \ 47 | do { \ 48 | if (a >= (BASE << 4)) a -= (BASE << 4); \ 49 | if (a >= (BASE << 3)) a -= (BASE << 3); \ 50 | if (a >= (BASE << 2)) a -= (BASE << 2); \ 51 | if (a >= (BASE << 1)) a -= (BASE << 1); \ 52 | if (a >= BASE) a -= BASE; \ 53 | } while (0) 54 | #else 55 | # define MOD(a) a %= BASE 56 | # define MOD4(a) a %= BASE 57 | #endif 58 | 59 | /* ========================================================================= */ 60 | uLong ZEXPORT adler32(adler, buf, len) 61 | uLong adler; 62 | const Bytef *buf; 63 | uInt len; 64 | { 65 | unsigned long sum2; 66 | unsigned n; 67 | 68 | /* split Adler-32 into component sums */ 69 | sum2 = (adler >> 16) & 0xffff; 70 | adler &= 0xffff; 71 | 72 | /* in case user likes doing a byte at a time, keep it fast */ 73 | if (len == 1) { 74 | adler += buf[0]; 75 | if (adler >= BASE) 76 | adler -= BASE; 77 | sum2 += adler; 78 | if (sum2 >= BASE) 79 | sum2 -= BASE; 80 | return adler | (sum2 << 16); 81 | } 82 | 83 | /* initial Adler-32 value (deferred check for len == 1 speed) */ 84 | if (buf == Z_NULL) 85 | return 1L; 86 | 87 | /* in case short lengths are provided, keep it somewhat fast */ 88 | if (len < 16) { 89 | while (len--) { 90 | adler += *buf++; 91 | sum2 += adler; 92 | } 93 | if (adler >= BASE) 94 | adler -= BASE; 95 | MOD4(sum2); /* only added so many BASE's */ 96 | return adler | (sum2 << 16); 97 | } 98 | 99 | /* do length NMAX blocks -- requires just one modulo operation */ 100 | while (len >= NMAX) { 101 | len -= NMAX; 102 | n = NMAX / 16; /* NMAX is divisible by 16 */ 103 | do { 104 | DO16(buf); /* 16 sums unrolled */ 105 | buf += 16; 106 | } while (--n); 107 | MOD(adler); 108 | MOD(sum2); 109 | } 110 | 111 | /* do remaining bytes (less than NMAX, still just one modulo) */ 112 | if (len) { /* avoid modulos if none remaining */ 113 | while (len >= 16) { 114 | len -= 16; 115 | DO16(buf); 116 | buf += 16; 117 | } 118 | while (len--) { 119 | adler += *buf++; 120 | sum2 += adler; 121 | } 122 | MOD(adler); 123 | MOD(sum2); 124 | } 125 | 126 | /* return recombined sums */ 127 | return adler | (sum2 << 16); 128 | } 129 | 130 | /* ========================================================================= */ 131 | local uLong adler32_combine_(adler1, adler2, len2) 132 | uLong adler1; 133 | uLong adler2; 134 | z_off64_t len2; 135 | { 136 | unsigned long sum1; 137 | unsigned long sum2; 138 | unsigned rem; 139 | 140 | /* the derivation of this formula is left as an exercise for the reader */ 141 | rem = (unsigned)(len2 % BASE); 142 | sum1 = adler1 & 0xffff; 143 | sum2 = rem * sum1; 144 | MOD(sum2); 145 | sum1 += (adler2 & 0xffff) + BASE - 1; 146 | sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; 147 | if (sum1 >= BASE) sum1 -= BASE; 148 | if (sum1 >= BASE) sum1 -= BASE; 149 | if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1); 150 | if (sum2 >= BASE) sum2 -= BASE; 151 | return sum1 | (sum2 << 16); 152 | } 153 | 154 | /* ========================================================================= */ 155 | uLong ZEXPORT adler32_combine(adler1, adler2, len2) 156 | uLong adler1; 157 | uLong adler2; 158 | z_off_t len2; 159 | { 160 | return adler32_combine_(adler1, adler2, len2); 161 | } 162 | 163 | uLong ZEXPORT adler32_combine64(adler1, adler2, len2) 164 | uLong adler1; 165 | uLong adler2; 166 | z_off64_t len2; 167 | { 168 | return adler32_combine_(adler1, adler2, len2); 169 | } 170 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/compress.c: -------------------------------------------------------------------------------- 1 | /* compress.c -- compress a memory buffer 2 | * Copyright (C) 1995-2005 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Compresses the source buffer into the destination buffer. The level 13 | parameter has the same meaning as in deflateInit. sourceLen is the byte 14 | length of the source buffer. Upon entry, destLen is the total size of the 15 | destination buffer, which must be at least 0.1% larger than sourceLen plus 16 | 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. 17 | 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, 20 | Z_STREAM_ERROR if the level parameter is invalid. 21 | */ 22 | int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) 23 | Bytef *dest; 24 | uLongf *destLen; 25 | const Bytef *source; 26 | uLong sourceLen; 27 | int level; 28 | { 29 | z_stream stream; 30 | int err; 31 | 32 | stream.next_in = (Bytef*)source; 33 | stream.avail_in = (uInt)sourceLen; 34 | #ifdef MAXSEG_64K 35 | /* Check for source > 64K on 16-bit machine: */ 36 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 37 | #endif 38 | stream.next_out = dest; 39 | stream.avail_out = (uInt)*destLen; 40 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 41 | 42 | stream.zalloc = (alloc_func)0; 43 | stream.zfree = (free_func)0; 44 | stream.opaque = (voidpf)0; 45 | 46 | err = deflateInit(&stream, level); 47 | if (err != Z_OK) return err; 48 | 49 | err = deflate(&stream, Z_FINISH); 50 | if (err != Z_STREAM_END) { 51 | deflateEnd(&stream); 52 | return err == Z_OK ? Z_BUF_ERROR : err; 53 | } 54 | *destLen = stream.total_out; 55 | 56 | err = deflateEnd(&stream); 57 | return err; 58 | } 59 | 60 | /* =========================================================================== 61 | */ 62 | int ZEXPORT compress (dest, destLen, source, sourceLen) 63 | Bytef *dest; 64 | uLongf *destLen; 65 | const Bytef *source; 66 | uLong sourceLen; 67 | { 68 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); 69 | } 70 | 71 | /* =========================================================================== 72 | If the default memLevel or windowBits for deflateInit() is changed, then 73 | this function needs to be updated. 74 | */ 75 | uLong ZEXPORT compressBound (sourceLen) 76 | uLong sourceLen; 77 | { 78 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 79 | (sourceLen >> 25) + 13; 80 | } 81 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/deflate.h: -------------------------------------------------------------------------------- 1 | /* deflate.h -- internal compression state 2 | * Copyright (C) 1995-2010 Jean-loup Gailly 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* @(#) $Id$ */ 12 | 13 | #ifndef DEFLATE_H 14 | #define DEFLATE_H 15 | 16 | #include "zutil.h" 17 | 18 | /* define NO_GZIP when compiling if you want to disable gzip header and 19 | trailer creation by deflate(). NO_GZIP would be used to avoid linking in 20 | the crc code when it is not needed. For shared libraries, gzip encoding 21 | should be left enabled. */ 22 | #ifndef NO_GZIP 23 | # define GZIP 24 | #endif 25 | 26 | /* =========================================================================== 27 | * Internal compression state. 28 | */ 29 | 30 | #define LENGTH_CODES 29 31 | /* number of length codes, not counting the special END_BLOCK code */ 32 | 33 | #define LITERALS 256 34 | /* number of literal bytes 0..255 */ 35 | 36 | #define L_CODES (LITERALS+1+LENGTH_CODES) 37 | /* number of Literal or Length codes, including the END_BLOCK code */ 38 | 39 | #define D_CODES 30 40 | /* number of distance codes */ 41 | 42 | #define BL_CODES 19 43 | /* number of codes used to transfer the bit lengths */ 44 | 45 | #define HEAP_SIZE (2*L_CODES+1) 46 | /* maximum heap size */ 47 | 48 | #define MAX_BITS 15 49 | /* All codes must not exceed MAX_BITS bits */ 50 | 51 | #define INIT_STATE 42 52 | #define EXTRA_STATE 69 53 | #define NAME_STATE 73 54 | #define COMMENT_STATE 91 55 | #define HCRC_STATE 103 56 | #define BUSY_STATE 113 57 | #define FINISH_STATE 666 58 | /* Stream status */ 59 | 60 | 61 | /* Data structure describing a single value and its code string. */ 62 | typedef struct ct_data_s { 63 | union { 64 | ush freq; /* frequency count */ 65 | ush code; /* bit string */ 66 | } fc; 67 | union { 68 | ush dad; /* father node in Huffman tree */ 69 | ush len; /* length of bit string */ 70 | } dl; 71 | } FAR ct_data; 72 | 73 | #define Freq fc.freq 74 | #define Code fc.code 75 | #define Dad dl.dad 76 | #define Len dl.len 77 | 78 | typedef struct static_tree_desc_s static_tree_desc; 79 | 80 | typedef struct tree_desc_s { 81 | ct_data *dyn_tree; /* the dynamic tree */ 82 | int max_code; /* largest code with non zero frequency */ 83 | static_tree_desc *stat_desc; /* the corresponding static tree */ 84 | } FAR tree_desc; 85 | 86 | typedef ush Pos; 87 | typedef Pos FAR Posf; 88 | typedef unsigned IPos; 89 | 90 | /* A Pos is an index in the character window. We use short instead of int to 91 | * save space in the various tables. IPos is used only for parameter passing. 92 | */ 93 | 94 | typedef struct internal_state { 95 | z_streamp strm; /* pointer back to this zlib stream */ 96 | int status; /* as the name implies */ 97 | Bytef *pending_buf; /* output still pending */ 98 | ulg pending_buf_size; /* size of pending_buf */ 99 | Bytef *pending_out; /* next pending byte to output to the stream */ 100 | uInt pending; /* nb of bytes in the pending buffer */ 101 | int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ 102 | gz_headerp gzhead; /* gzip header information to write */ 103 | uInt gzindex; /* where in extra, name, or comment */ 104 | Byte method; /* STORED (for zip only) or DEFLATED */ 105 | int last_flush; /* value of flush param for previous deflate call */ 106 | 107 | /* used by deflate.c: */ 108 | 109 | uInt w_size; /* LZ77 window size (32K by default) */ 110 | uInt w_bits; /* log2(w_size) (8..16) */ 111 | uInt w_mask; /* w_size - 1 */ 112 | 113 | Bytef *window; 114 | /* Sliding window. Input bytes are read into the second half of the window, 115 | * and move to the first half later to keep a dictionary of at least wSize 116 | * bytes. With this organization, matches are limited to a distance of 117 | * wSize-MAX_MATCH bytes, but this ensures that IO is always 118 | * performed with a length multiple of the block size. Also, it limits 119 | * the window size to 64K, which is quite useful on MSDOS. 120 | * To do: use the user input buffer as sliding window. 121 | */ 122 | 123 | ulg window_size; 124 | /* Actual size of window: 2*wSize, except when the user input buffer 125 | * is directly used as sliding window. 126 | */ 127 | 128 | Posf *prev; 129 | /* Link to older string with same hash index. To limit the size of this 130 | * array to 64K, this link is maintained only for the last 32K strings. 131 | * An index in this array is thus a window index modulo 32K. 132 | */ 133 | 134 | Posf *head; /* Heads of the hash chains or NIL. */ 135 | 136 | uInt ins_h; /* hash index of string to be inserted */ 137 | uInt hash_size; /* number of elements in hash table */ 138 | uInt hash_bits; /* log2(hash_size) */ 139 | uInt hash_mask; /* hash_size-1 */ 140 | 141 | uInt hash_shift; 142 | /* Number of bits by which ins_h must be shifted at each input 143 | * step. It must be such that after MIN_MATCH steps, the oldest 144 | * byte no longer takes part in the hash key, that is: 145 | * hash_shift * MIN_MATCH >= hash_bits 146 | */ 147 | 148 | long block_start; 149 | /* Window position at the beginning of the current output block. Gets 150 | * negative when the window is moved backwards. 151 | */ 152 | 153 | uInt match_length; /* length of best match */ 154 | IPos prev_match; /* previous match */ 155 | int match_available; /* set if previous match exists */ 156 | uInt strstart; /* start of string to insert */ 157 | uInt match_start; /* start of matching string */ 158 | uInt lookahead; /* number of valid bytes ahead in window */ 159 | 160 | uInt prev_length; 161 | /* Length of the best match at previous step. Matches not greater than this 162 | * are discarded. This is used in the lazy match evaluation. 163 | */ 164 | 165 | uInt max_chain_length; 166 | /* To speed up deflation, hash chains are never searched beyond this 167 | * length. A higher limit improves compression ratio but degrades the 168 | * speed. 169 | */ 170 | 171 | uInt max_lazy_match; 172 | /* Attempt to find a better match only when the current match is strictly 173 | * smaller than this value. This mechanism is used only for compression 174 | * levels >= 4. 175 | */ 176 | # define max_insert_length max_lazy_match 177 | /* Insert new strings in the hash table only if the match length is not 178 | * greater than this length. This saves time but degrades compression. 179 | * max_insert_length is used only for compression levels <= 3. 180 | */ 181 | 182 | int level; /* compression level (1..9) */ 183 | int strategy; /* favor or force Huffman coding*/ 184 | 185 | uInt good_match; 186 | /* Use a faster search when the previous match is longer than this */ 187 | 188 | int nice_match; /* Stop searching when current match exceeds this */ 189 | 190 | /* used by trees.c: */ 191 | /* Didn't use ct_data typedef below to supress compiler warning */ 192 | struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ 193 | struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ 194 | struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ 195 | 196 | struct tree_desc_s l_desc; /* desc. for literal tree */ 197 | struct tree_desc_s d_desc; /* desc. for distance tree */ 198 | struct tree_desc_s bl_desc; /* desc. for bit length tree */ 199 | 200 | ush bl_count[MAX_BITS+1]; 201 | /* number of codes at each bit length for an optimal tree */ 202 | 203 | int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ 204 | int heap_len; /* number of elements in the heap */ 205 | int heap_max; /* element of largest frequency */ 206 | /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. 207 | * The same heap array is used to build all trees. 208 | */ 209 | 210 | uch depth[2*L_CODES+1]; 211 | /* Depth of each subtree used as tie breaker for trees of equal frequency 212 | */ 213 | 214 | uchf *l_buf; /* buffer for literals or lengths */ 215 | 216 | uInt lit_bufsize; 217 | /* Size of match buffer for literals/lengths. There are 4 reasons for 218 | * limiting lit_bufsize to 64K: 219 | * - frequencies can be kept in 16 bit counters 220 | * - if compression is not successful for the first block, all input 221 | * data is still in the window so we can still emit a stored block even 222 | * when input comes from standard input. (This can also be done for 223 | * all blocks if lit_bufsize is not greater than 32K.) 224 | * - if compression is not successful for a file smaller than 64K, we can 225 | * even emit a stored file instead of a stored block (saving 5 bytes). 226 | * This is applicable only for zip (not gzip or zlib). 227 | * - creating new Huffman trees less frequently may not provide fast 228 | * adaptation to changes in the input data statistics. (Take for 229 | * example a binary file with poorly compressible code followed by 230 | * a highly compressible string table.) Smaller buffer sizes give 231 | * fast adaptation but have of course the overhead of transmitting 232 | * trees more frequently. 233 | * - I can't count above 4 234 | */ 235 | 236 | uInt last_lit; /* running index in l_buf */ 237 | 238 | ushf *d_buf; 239 | /* Buffer for distances. To simplify the code, d_buf and l_buf have 240 | * the same number of elements. To use different lengths, an extra flag 241 | * array would be necessary. 242 | */ 243 | 244 | ulg opt_len; /* bit length of current block with optimal trees */ 245 | ulg static_len; /* bit length of current block with static trees */ 246 | uInt matches; /* number of string matches in current block */ 247 | int last_eob_len; /* bit length of EOB code for last block */ 248 | 249 | #ifdef DEBUG 250 | ulg compressed_len; /* total bit length of compressed file mod 2^32 */ 251 | ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ 252 | #endif 253 | 254 | ush bi_buf; 255 | /* Output buffer. bits are inserted starting at the bottom (least 256 | * significant bits). 257 | */ 258 | int bi_valid; 259 | /* Number of valid bits in bi_buf. All bits above the last valid bit 260 | * are always zero. 261 | */ 262 | 263 | ulg high_water; 264 | /* High water mark offset in window for initialized bytes -- bytes above 265 | * this are set to zero in order to avoid memory check warnings when 266 | * longest match routines access bytes past the input. This is then 267 | * updated to the new high water mark. 268 | */ 269 | 270 | } FAR deflate_state; 271 | 272 | /* Output a byte on the stream. 273 | * IN assertion: there is enough room in pending_buf. 274 | */ 275 | #define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} 276 | 277 | 278 | #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) 279 | /* Minimum amount of lookahead, except at the end of the input file. 280 | * See deflate.c for comments about the MIN_MATCH+1. 281 | */ 282 | 283 | #define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) 284 | /* In order to simplify the code, particularly on 16 bit machines, match 285 | * distances are limited to MAX_DIST instead of WSIZE. 286 | */ 287 | 288 | #define WIN_INIT MAX_MATCH 289 | /* Number of bytes after end of data in window to initialize in order to avoid 290 | memory checker errors from longest match routines */ 291 | 292 | /* in trees.c */ 293 | void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); 294 | int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); 295 | void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, 296 | ulg stored_len, int last)); 297 | void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); 298 | void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, 299 | ulg stored_len, int last)); 300 | 301 | #define d_code(dist) \ 302 | ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) 303 | /* Mapping from a distance to a distance code. dist is the distance - 1 and 304 | * must not have side effects. _dist_code[256] and _dist_code[257] are never 305 | * used. 306 | */ 307 | 308 | #ifndef DEBUG 309 | /* Inline versions of _tr_tally for speed: */ 310 | 311 | #if defined(GEN_TREES_H) || !defined(STDC) 312 | extern uch ZLIB_INTERNAL _length_code[]; 313 | extern uch ZLIB_INTERNAL _dist_code[]; 314 | #else 315 | extern const uch ZLIB_INTERNAL _length_code[]; 316 | extern const uch ZLIB_INTERNAL _dist_code[]; 317 | #endif 318 | 319 | # define _tr_tally_lit(s, c, flush) \ 320 | { uch cc = (c); \ 321 | s->d_buf[s->last_lit] = 0; \ 322 | s->l_buf[s->last_lit++] = cc; \ 323 | s->dyn_ltree[cc].Freq++; \ 324 | flush = (s->last_lit == s->lit_bufsize-1); \ 325 | } 326 | # define _tr_tally_dist(s, distance, length, flush) \ 327 | { uch len = (length); \ 328 | ush dist = (distance); \ 329 | s->d_buf[s->last_lit] = dist; \ 330 | s->l_buf[s->last_lit++] = len; \ 331 | dist--; \ 332 | s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ 333 | s->dyn_dtree[d_code(dist)].Freq++; \ 334 | flush = (s->last_lit == s->lit_bufsize-1); \ 335 | } 336 | #else 337 | # define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) 338 | # define _tr_tally_dist(s, distance, length, flush) \ 339 | flush = _tr_tally(s, distance, length) 340 | #endif 341 | 342 | #endif /* DEFLATE_H */ 343 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/doc/algorithm.txt: -------------------------------------------------------------------------------- 1 | 1. Compression algorithm (deflate) 2 | 3 | The deflation algorithm used by gzip (also zip and zlib) is a variation of 4 | LZ77 (Lempel-Ziv 1977, see reference below). It finds duplicated strings in 5 | the input data. The second occurrence of a string is replaced by a 6 | pointer to the previous string, in the form of a pair (distance, 7 | length). Distances are limited to 32K bytes, and lengths are limited 8 | to 258 bytes. When a string does not occur anywhere in the previous 9 | 32K bytes, it is emitted as a sequence of literal bytes. (In this 10 | description, `string' must be taken as an arbitrary sequence of bytes, 11 | and is not restricted to printable characters.) 12 | 13 | Literals or match lengths are compressed with one Huffman tree, and 14 | match distances are compressed with another tree. The trees are stored 15 | in a compact form at the start of each block. The blocks can have any 16 | size (except that the compressed data for one block must fit in 17 | available memory). A block is terminated when deflate() determines that 18 | it would be useful to start another block with fresh trees. (This is 19 | somewhat similar to the behavior of LZW-based _compress_.) 20 | 21 | Duplicated strings are found using a hash table. All input strings of 22 | length 3 are inserted in the hash table. A hash index is computed for 23 | the next 3 bytes. If the hash chain for this index is not empty, all 24 | strings in the chain are compared with the current input string, and 25 | the longest match is selected. 26 | 27 | The hash chains are searched starting with the most recent strings, to 28 | favor small distances and thus take advantage of the Huffman encoding. 29 | The hash chains are singly linked. There are no deletions from the 30 | hash chains, the algorithm simply discards matches that are too old. 31 | 32 | To avoid a worst-case situation, very long hash chains are arbitrarily 33 | truncated at a certain length, determined by a runtime option (level 34 | parameter of deflateInit). So deflate() does not always find the longest 35 | possible match but generally finds a match which is long enough. 36 | 37 | deflate() also defers the selection of matches with a lazy evaluation 38 | mechanism. After a match of length N has been found, deflate() searches for 39 | a longer match at the next input byte. If a longer match is found, the 40 | previous match is truncated to a length of one (thus producing a single 41 | literal byte) and the process of lazy evaluation begins again. Otherwise, 42 | the original match is kept, and the next match search is attempted only N 43 | steps later. 44 | 45 | The lazy match evaluation is also subject to a runtime parameter. If 46 | the current match is long enough, deflate() reduces the search for a longer 47 | match, thus speeding up the whole process. If compression ratio is more 48 | important than speed, deflate() attempts a complete second search even if 49 | the first match is already long enough. 50 | 51 | The lazy match evaluation is not performed for the fastest compression 52 | modes (level parameter 1 to 3). For these fast modes, new strings 53 | are inserted in the hash table only when no match was found, or 54 | when the match is not too long. This degrades the compression ratio 55 | but saves time since there are both fewer insertions and fewer searches. 56 | 57 | 58 | 2. Decompression algorithm (inflate) 59 | 60 | 2.1 Introduction 61 | 62 | The key question is how to represent a Huffman code (or any prefix code) so 63 | that you can decode fast. The most important characteristic is that shorter 64 | codes are much more common than longer codes, so pay attention to decoding the 65 | short codes fast, and let the long codes take longer to decode. 66 | 67 | inflate() sets up a first level table that covers some number of bits of 68 | input less than the length of longest code. It gets that many bits from the 69 | stream, and looks it up in the table. The table will tell if the next 70 | code is that many bits or less and how many, and if it is, it will tell 71 | the value, else it will point to the next level table for which inflate() 72 | grabs more bits and tries to decode a longer code. 73 | 74 | How many bits to make the first lookup is a tradeoff between the time it 75 | takes to decode and the time it takes to build the table. If building the 76 | table took no time (and if you had infinite memory), then there would only 77 | be a first level table to cover all the way to the longest code. However, 78 | building the table ends up taking a lot longer for more bits since short 79 | codes are replicated many times in such a table. What inflate() does is 80 | simply to make the number of bits in the first table a variable, and then 81 | to set that variable for the maximum speed. 82 | 83 | For inflate, which has 286 possible codes for the literal/length tree, the size 84 | of the first table is nine bits. Also the distance trees have 30 possible 85 | values, and the size of the first table is six bits. Note that for each of 86 | those cases, the table ended up one bit longer than the ``average'' code 87 | length, i.e. the code length of an approximately flat code which would be a 88 | little more than eight bits for 286 symbols and a little less than five bits 89 | for 30 symbols. 90 | 91 | 92 | 2.2 More details on the inflate table lookup 93 | 94 | Ok, you want to know what this cleverly obfuscated inflate tree actually 95 | looks like. You are correct that it's not a Huffman tree. It is simply a 96 | lookup table for the first, let's say, nine bits of a Huffman symbol. The 97 | symbol could be as short as one bit or as long as 15 bits. If a particular 98 | symbol is shorter than nine bits, then that symbol's translation is duplicated 99 | in all those entries that start with that symbol's bits. For example, if the 100 | symbol is four bits, then it's duplicated 32 times in a nine-bit table. If a 101 | symbol is nine bits long, it appears in the table once. 102 | 103 | If the symbol is longer than nine bits, then that entry in the table points 104 | to another similar table for the remaining bits. Again, there are duplicated 105 | entries as needed. The idea is that most of the time the symbol will be short 106 | and there will only be one table look up. (That's whole idea behind data 107 | compression in the first place.) For the less frequent long symbols, there 108 | will be two lookups. If you had a compression method with really long 109 | symbols, you could have as many levels of lookups as is efficient. For 110 | inflate, two is enough. 111 | 112 | So a table entry either points to another table (in which case nine bits in 113 | the above example are gobbled), or it contains the translation for the symbol 114 | and the number of bits to gobble. Then you start again with the next 115 | ungobbled bit. 116 | 117 | You may wonder: why not just have one lookup table for how ever many bits the 118 | longest symbol is? The reason is that if you do that, you end up spending 119 | more time filling in duplicate symbol entries than you do actually decoding. 120 | At least for deflate's output that generates new trees every several 10's of 121 | kbytes. You can imagine that filling in a 2^15 entry table for a 15-bit code 122 | would take too long if you're only decoding several thousand symbols. At the 123 | other extreme, you could make a new table for every bit in the code. In fact, 124 | that's essentially a Huffman tree. But then you spend too much time 125 | traversing the tree while decoding, even for short symbols. 126 | 127 | So the number of bits for the first lookup table is a trade of the time to 128 | fill out the table vs. the time spent looking at the second level and above of 129 | the table. 130 | 131 | Here is an example, scaled down: 132 | 133 | The code being decoded, with 10 symbols, from 1 to 6 bits long: 134 | 135 | A: 0 136 | B: 10 137 | C: 1100 138 | D: 11010 139 | E: 11011 140 | F: 11100 141 | G: 11101 142 | H: 11110 143 | I: 111110 144 | J: 111111 145 | 146 | Let's make the first table three bits long (eight entries): 147 | 148 | 000: A,1 149 | 001: A,1 150 | 010: A,1 151 | 011: A,1 152 | 100: B,2 153 | 101: B,2 154 | 110: -> table X (gobble 3 bits) 155 | 111: -> table Y (gobble 3 bits) 156 | 157 | Each entry is what the bits decode as and how many bits that is, i.e. how 158 | many bits to gobble. Or the entry points to another table, with the number of 159 | bits to gobble implicit in the size of the table. 160 | 161 | Table X is two bits long since the longest code starting with 110 is five bits 162 | long: 163 | 164 | 00: C,1 165 | 01: C,1 166 | 10: D,2 167 | 11: E,2 168 | 169 | Table Y is three bits long since the longest code starting with 111 is six 170 | bits long: 171 | 172 | 000: F,2 173 | 001: F,2 174 | 010: G,2 175 | 011: G,2 176 | 100: H,2 177 | 101: H,2 178 | 110: I,3 179 | 111: J,3 180 | 181 | So what we have here are three tables with a total of 20 entries that had to 182 | be constructed. That's compared to 64 entries for a single table. Or 183 | compared to 16 entries for a Huffman tree (six two entry tables and one four 184 | entry table). Assuming that the code ideally represents the probability of 185 | the symbols, it takes on the average 1.25 lookups per symbol. That's compared 186 | to one lookup for the single table, or 1.66 lookups per symbol for the 187 | Huffman tree. 188 | 189 | There, I think that gives you a picture of what's going on. For inflate, the 190 | meaning of a particular symbol is often more than just a letter. It can be a 191 | byte (a "literal"), or it can be either a length or a distance which 192 | indicates a base value and a number of bits to fetch after the code that is 193 | added to the base value. Or it might be the special end-of-block code. The 194 | data structures created in inftrees.c try to encode all that information 195 | compactly in the tables. 196 | 197 | 198 | Jean-loup Gailly Mark Adler 199 | jloup@gzip.org madler@alumni.caltech.edu 200 | 201 | 202 | References: 203 | 204 | [LZ77] Ziv J., Lempel A., ``A Universal Algorithm for Sequential Data 205 | Compression,'' IEEE Transactions on Information Theory, Vol. 23, No. 3, 206 | pp. 337-343. 207 | 208 | ``DEFLATE Compressed Data Format Specification'' available in 209 | http://www.ietf.org/rfc/rfc1951.txt 210 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/doc/txtvsbin.txt: -------------------------------------------------------------------------------- 1 | A Fast Method for Identifying Plain Text Files 2 | ============================================== 3 | 4 | 5 | Introduction 6 | ------------ 7 | 8 | Given a file coming from an unknown source, it is sometimes desirable 9 | to find out whether the format of that file is plain text. Although 10 | this may appear like a simple task, a fully accurate detection of the 11 | file type requires heavy-duty semantic analysis on the file contents. 12 | It is, however, possible to obtain satisfactory results by employing 13 | various heuristics. 14 | 15 | Previous versions of PKZip and other zip-compatible compression tools 16 | were using a crude detection scheme: if more than 80% (4/5) of the bytes 17 | found in a certain buffer are within the range [7..127], the file is 18 | labeled as plain text, otherwise it is labeled as binary. A prominent 19 | limitation of this scheme is the restriction to Latin-based alphabets. 20 | Other alphabets, like Greek, Cyrillic or Asian, make extensive use of 21 | the bytes within the range [128..255], and texts using these alphabets 22 | are most often misidentified by this scheme; in other words, the rate 23 | of false negatives is sometimes too high, which means that the recall 24 | is low. Another weakness of this scheme is a reduced precision, due to 25 | the false positives that may occur when binary files containing large 26 | amounts of textual characters are misidentified as plain text. 27 | 28 | In this article we propose a new, simple detection scheme that features 29 | a much increased precision and a near-100% recall. This scheme is 30 | designed to work on ASCII, Unicode and other ASCII-derived alphabets, 31 | and it handles single-byte encodings (ISO-8859, MacRoman, KOI8, etc.) 32 | and variable-sized encodings (ISO-2022, UTF-8, etc.). Wider encodings 33 | (UCS-2/UTF-16 and UCS-4/UTF-32) are not handled, however. 34 | 35 | 36 | The Algorithm 37 | ------------- 38 | 39 | The algorithm works by dividing the set of bytecodes [0..255] into three 40 | categories: 41 | - The white list of textual bytecodes: 42 | 9 (TAB), 10 (LF), 13 (CR), 32 (SPACE) to 255. 43 | - The gray list of tolerated bytecodes: 44 | 7 (BEL), 8 (BS), 11 (VT), 12 (FF), 26 (SUB), 27 (ESC). 45 | - The black list of undesired, non-textual bytecodes: 46 | 0 (NUL) to 6, 14 to 31. 47 | 48 | If a file contains at least one byte that belongs to the white list and 49 | no byte that belongs to the black list, then the file is categorized as 50 | plain text; otherwise, it is categorized as binary. (The boundary case, 51 | when the file is empty, automatically falls into the latter category.) 52 | 53 | 54 | Rationale 55 | --------- 56 | 57 | The idea behind this algorithm relies on two observations. 58 | 59 | The first observation is that, although the full range of 7-bit codes 60 | [0..127] is properly specified by the ASCII standard, most control 61 | characters in the range [0..31] are not used in practice. The only 62 | widely-used, almost universally-portable control codes are 9 (TAB), 63 | 10 (LF) and 13 (CR). There are a few more control codes that are 64 | recognized on a reduced range of platforms and text viewers/editors: 65 | 7 (BEL), 8 (BS), 11 (VT), 12 (FF), 26 (SUB) and 27 (ESC); but these 66 | codes are rarely (if ever) used alone, without being accompanied by 67 | some printable text. Even the newer, portable text formats such as 68 | XML avoid using control characters outside the list mentioned here. 69 | 70 | The second observation is that most of the binary files tend to contain 71 | control characters, especially 0 (NUL). Even though the older text 72 | detection schemes observe the presence of non-ASCII codes from the range 73 | [128..255], the precision rarely has to suffer if this upper range is 74 | labeled as textual, because the files that are genuinely binary tend to 75 | contain both control characters and codes from the upper range. On the 76 | other hand, the upper range needs to be labeled as textual, because it 77 | is used by virtually all ASCII extensions. In particular, this range is 78 | used for encoding non-Latin scripts. 79 | 80 | Since there is no counting involved, other than simply observing the 81 | presence or the absence of some byte values, the algorithm produces 82 | consistent results, regardless what alphabet encoding is being used. 83 | (If counting were involved, it could be possible to obtain different 84 | results on a text encoded, say, using ISO-8859-16 versus UTF-8.) 85 | 86 | There is an extra category of plain text files that are "polluted" with 87 | one or more black-listed codes, either by mistake or by peculiar design 88 | considerations. In such cases, a scheme that tolerates a small fraction 89 | of black-listed codes would provide an increased recall (i.e. more true 90 | positives). This, however, incurs a reduced precision overall, since 91 | false positives are more likely to appear in binary files that contain 92 | large chunks of textual data. Furthermore, "polluted" plain text should 93 | be regarded as binary by general-purpose text detection schemes, because 94 | general-purpose text processing algorithms might not be applicable. 95 | Under this premise, it is safe to say that our detection method provides 96 | a near-100% recall. 97 | 98 | Experiments have been run on many files coming from various platforms 99 | and applications. We tried plain text files, system logs, source code, 100 | formatted office documents, compiled object code, etc. The results 101 | confirm the optimistic assumptions about the capabilities of this 102 | algorithm. 103 | 104 | 105 | -- 106 | Cosmin Truta 107 | Last updated: 2006-May-28 108 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/gzclose.c: -------------------------------------------------------------------------------- 1 | /* gzclose.c -- zlib gzclose() function 2 | * Copyright (C) 2004, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "gzguts.h" 7 | 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. 9 | That way the other gzclose functions can be used instead to avoid linking in 10 | unneeded compression or decompression routines. */ 11 | int ZEXPORT gzclose(file) 12 | gzFile file; 13 | { 14 | #ifndef NO_GZCOMPRESS 15 | gz_statep state; 16 | 17 | if (file == NULL) 18 | return Z_STREAM_ERROR; 19 | state = (gz_statep)file; 20 | 21 | return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); 22 | #else 23 | return gzclose_r(file); 24 | #endif 25 | } 26 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/gzguts.h: -------------------------------------------------------------------------------- 1 | /* gzguts.h -- zlib internal header definitions for gz* operations 2 | * Copyright (C) 2004, 2005, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #ifdef _MSC_VER 7 | # ifndef _CRT_SECURE_NO_DEPRECATE 8 | # define _CRT_SECURE_NO_DEPRECATE 9 | # endif 10 | # ifndef _CRT_NONSTDC_NO_DEPRECATE 11 | # define _CRT_NONSTDC_NO_DEPRECATE 12 | # endif 13 | #endif 14 | 15 | #ifdef _LARGEFILE64_SOURCE 16 | # ifndef _LARGEFILE_SOURCE 17 | # define _LARGEFILE_SOURCE 1 18 | # endif 19 | # ifdef _FILE_OFFSET_BITS 20 | # undef _FILE_OFFSET_BITS 21 | # endif 22 | #endif 23 | 24 | #include "qconfig.h" 25 | #if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) && defined(QT_VISIBILITY_AVAILABLE) 26 | # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) 27 | #else 28 | # define ZLIB_INTERNAL 29 | #endif 30 | 31 | #include 32 | #include "zlib.h" 33 | #ifdef STDC 34 | # include 35 | # include 36 | # include 37 | #endif 38 | #if !defined(_WIN32_WCE) 39 | # include 40 | #else 41 | # include 42 | # include 43 | #endif 44 | 45 | #ifdef NO_DEFLATE /* for compatibility with old definition */ 46 | # define NO_GZCOMPRESS 47 | #endif 48 | 49 | #ifdef _MSC_VER 50 | # if !defined(_WIN32_WCE) 51 | # include 52 | # endif 53 | # define vsnprintf _vsnprintf 54 | #endif 55 | 56 | #ifndef local 57 | # define local static 58 | #endif 59 | /* compile with -Dlocal if your debugger can't find static symbols */ 60 | 61 | /* gz* functions always use library allocation functions */ 62 | #ifndef STDC 63 | extern voidp malloc OF((uInt size)); 64 | extern void free OF((voidpf ptr)); 65 | #endif 66 | 67 | /* get errno and strerror definition */ 68 | #if defined UNDER_CE 69 | # include 70 | # define zstrerror() gz_strwinerror((DWORD)GetLastError()) 71 | #else 72 | # ifdef STDC 73 | # include 74 | # define zstrerror() strerror(errno) 75 | # else 76 | # define zstrerror() "stdio error (consult errno)" 77 | # endif 78 | #endif 79 | 80 | /* provide prototypes for these when building zlib without LFS */ 81 | #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 82 | ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); 83 | ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); 84 | ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); 85 | ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); 86 | #endif 87 | 88 | /* default i/o buffer size -- double this for output when reading */ 89 | #define GZBUFSIZE 8192 90 | 91 | /* gzip modes, also provide a little integrity check on the passed structure */ 92 | #define GZ_NONE 0 93 | #define GZ_READ 7247 94 | #define GZ_WRITE 31153 95 | #define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */ 96 | 97 | /* values for gz_state how */ 98 | #define LOOK 0 /* look for a gzip header */ 99 | #define COPY 1 /* copy input directly */ 100 | #define GZIP 2 /* decompress a gzip stream */ 101 | 102 | /* internal gzip file state data structure */ 103 | typedef struct { 104 | /* used for both reading and writing */ 105 | int mode; /* see gzip modes above */ 106 | int fd; /* file descriptor */ 107 | char *path; /* path or fd for error messages */ 108 | z_off64_t pos; /* current position in uncompressed data */ 109 | unsigned size; /* buffer size, zero if not allocated yet */ 110 | unsigned want; /* requested buffer size, default is GZBUFSIZE */ 111 | unsigned char *in; /* input buffer */ 112 | unsigned char *out; /* output buffer (double-sized when reading) */ 113 | unsigned char *next; /* next output data to deliver or write */ 114 | /* just for reading */ 115 | unsigned have; /* amount of output data unused at next */ 116 | int eof; /* true if end of input file reached */ 117 | z_off64_t start; /* where the gzip data started, for rewinding */ 118 | z_off64_t raw; /* where the raw data started, for seeking */ 119 | int how; /* 0: get header, 1: copy, 2: decompress */ 120 | int direct; /* true if last read direct, false if gzip */ 121 | /* just for writing */ 122 | int level; /* compression level */ 123 | int strategy; /* compression strategy */ 124 | /* seek request */ 125 | z_off64_t skip; /* amount to skip (already rewound if backwards) */ 126 | int seek; /* true if seek request pending */ 127 | /* error information */ 128 | int err; /* error code */ 129 | char *msg; /* error message */ 130 | /* zlib inflate or deflate stream */ 131 | z_stream strm; /* stream structure in-place (not a pointer) */ 132 | } gz_state; 133 | typedef gz_state FAR *gz_statep; 134 | 135 | /* shared functions */ 136 | void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); 137 | #if defined UNDER_CE 138 | char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); 139 | #endif 140 | 141 | /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t 142 | value -- needed when comparing unsigned to z_off64_t, which is signed 143 | (possible z_off64_t types off_t, off64_t, and long are all signed) */ 144 | #ifdef INT_MAX 145 | # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) 146 | #else 147 | unsigned ZLIB_INTERNAL gz_intmax OF((void)); 148 | # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) 149 | #endif 150 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/inffast.c: -------------------------------------------------------------------------------- 1 | /* inffast.c -- fast decoding 2 | * Copyright (C) 1995-2008, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "zutil.h" 7 | #include "inftrees.h" 8 | #include "inflate.h" 9 | #include "inffast.h" 10 | 11 | #ifndef ASMINF 12 | 13 | /* Allow machine dependent optimization for post-increment or pre-increment. 14 | Based on testing to date, 15 | Pre-increment preferred for: 16 | - PowerPC G3 (Adler) 17 | - MIPS R5000 (Randers-Pehrson) 18 | Post-increment preferred for: 19 | - none 20 | No measurable difference: 21 | - Pentium III (Anderson) 22 | - M68060 (Nikl) 23 | */ 24 | #ifdef POSTINC 25 | # define OFF 0 26 | # define PUP(a) *(a)++ 27 | #else 28 | # define OFF 1 29 | # define PUP(a) *++(a) 30 | #endif 31 | 32 | /* 33 | Decode literal, length, and distance codes and write out the resulting 34 | literal and match bytes until either not enough input or output is 35 | available, an end-of-block is encountered, or a data error is encountered. 36 | When large enough input and output buffers are supplied to inflate(), for 37 | example, a 16K input buffer and a 64K output buffer, more than 95% of the 38 | inflate execution time is spent in this routine. 39 | 40 | Entry assumptions: 41 | 42 | state->mode == LEN 43 | strm->avail_in >= 6 44 | strm->avail_out >= 258 45 | start >= strm->avail_out 46 | state->bits < 8 47 | 48 | On return, state->mode is one of: 49 | 50 | LEN -- ran out of enough output space or enough available input 51 | TYPE -- reached end of block code, inflate() to interpret next block 52 | BAD -- error in block data 53 | 54 | Notes: 55 | 56 | - The maximum input bits used by a length/distance pair is 15 bits for the 57 | length code, 5 bits for the length extra, 15 bits for the distance code, 58 | and 13 bits for the distance extra. This totals 48 bits, or six bytes. 59 | Therefore if strm->avail_in >= 6, then there is enough input to avoid 60 | checking for available input while decoding. 61 | 62 | - The maximum bytes that a single length/distance pair can output is 258 63 | bytes, which is the maximum length that can be coded. inflate_fast() 64 | requires strm->avail_out >= 258 for each loop to avoid checking for 65 | output space. 66 | */ 67 | void ZLIB_INTERNAL inflate_fast(strm, start) 68 | z_streamp strm; 69 | unsigned start; /* inflate()'s starting value for strm->avail_out */ 70 | { 71 | struct inflate_state FAR *state; 72 | unsigned char FAR *in; /* local strm->next_in */ 73 | unsigned char FAR *last; /* while in < last, enough input available */ 74 | unsigned char FAR *out; /* local strm->next_out */ 75 | unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ 76 | unsigned char FAR *end; /* while out < end, enough space available */ 77 | #ifdef INFLATE_STRICT 78 | unsigned dmax; /* maximum distance from zlib header */ 79 | #endif 80 | unsigned wsize; /* window size or zero if not using window */ 81 | unsigned whave; /* valid bytes in the window */ 82 | unsigned wnext; /* window write index */ 83 | unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ 84 | unsigned long hold; /* local strm->hold */ 85 | unsigned bits; /* local strm->bits */ 86 | code const FAR *lcode; /* local strm->lencode */ 87 | code const FAR *dcode; /* local strm->distcode */ 88 | unsigned lmask; /* mask for first level of length codes */ 89 | unsigned dmask; /* mask for first level of distance codes */ 90 | code here; /* retrieved table entry */ 91 | unsigned op; /* code bits, operation, extra bits, or */ 92 | /* window position, window bytes to copy */ 93 | unsigned len; /* match length, unused bytes */ 94 | unsigned dist; /* match distance */ 95 | unsigned char FAR *from; /* where to copy match from */ 96 | 97 | /* copy state to local variables */ 98 | state = (struct inflate_state FAR *)strm->state; 99 | in = strm->next_in - OFF; 100 | last = in + (strm->avail_in - 5); 101 | out = strm->next_out - OFF; 102 | beg = out - (start - strm->avail_out); 103 | end = out + (strm->avail_out - 257); 104 | #ifdef INFLATE_STRICT 105 | dmax = state->dmax; 106 | #endif 107 | wsize = state->wsize; 108 | whave = state->whave; 109 | wnext = state->wnext; 110 | window = state->window; 111 | hold = state->hold; 112 | bits = state->bits; 113 | lcode = state->lencode; 114 | dcode = state->distcode; 115 | lmask = (1U << state->lenbits) - 1; 116 | dmask = (1U << state->distbits) - 1; 117 | 118 | /* decode literals and length/distances until end-of-block or not enough 119 | input data or output space */ 120 | do { 121 | if (bits < 15) { 122 | hold += (unsigned long)(PUP(in)) << bits; 123 | bits += 8; 124 | hold += (unsigned long)(PUP(in)) << bits; 125 | bits += 8; 126 | } 127 | here = lcode[hold & lmask]; 128 | dolen: 129 | op = (unsigned)(here.bits); 130 | hold >>= op; 131 | bits -= op; 132 | op = (unsigned)(here.op); 133 | if (op == 0) { /* literal */ 134 | Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? 135 | "inflate: literal '%c'\n" : 136 | "inflate: literal 0x%02x\n", here.val)); 137 | PUP(out) = (unsigned char)(here.val); 138 | } 139 | else if (op & 16) { /* length base */ 140 | len = (unsigned)(here.val); 141 | op &= 15; /* number of extra bits */ 142 | if (op) { 143 | if (bits < op) { 144 | hold += (unsigned long)(PUP(in)) << bits; 145 | bits += 8; 146 | } 147 | len += (unsigned)hold & ((1U << op) - 1); 148 | hold >>= op; 149 | bits -= op; 150 | } 151 | Tracevv((stderr, "inflate: length %u\n", len)); 152 | if (bits < 15) { 153 | hold += (unsigned long)(PUP(in)) << bits; 154 | bits += 8; 155 | hold += (unsigned long)(PUP(in)) << bits; 156 | bits += 8; 157 | } 158 | here = dcode[hold & dmask]; 159 | dodist: 160 | op = (unsigned)(here.bits); 161 | hold >>= op; 162 | bits -= op; 163 | op = (unsigned)(here.op); 164 | if (op & 16) { /* distance base */ 165 | dist = (unsigned)(here.val); 166 | op &= 15; /* number of extra bits */ 167 | if (bits < op) { 168 | hold += (unsigned long)(PUP(in)) << bits; 169 | bits += 8; 170 | if (bits < op) { 171 | hold += (unsigned long)(PUP(in)) << bits; 172 | bits += 8; 173 | } 174 | } 175 | dist += (unsigned)hold & ((1U << op) - 1); 176 | #ifdef INFLATE_STRICT 177 | if (dist > dmax) { 178 | strm->msg = (char *)"invalid distance too far back"; 179 | state->mode = BAD; 180 | break; 181 | } 182 | #endif 183 | hold >>= op; 184 | bits -= op; 185 | Tracevv((stderr, "inflate: distance %u\n", dist)); 186 | op = (unsigned)(out - beg); /* max distance in output */ 187 | if (dist > op) { /* see if copy from window */ 188 | op = dist - op; /* distance back in window */ 189 | if (op > whave) { 190 | if (state->sane) { 191 | strm->msg = 192 | (char *)"invalid distance too far back"; 193 | state->mode = BAD; 194 | break; 195 | } 196 | #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR 197 | if (len <= op - whave) { 198 | do { 199 | PUP(out) = 0; 200 | } while (--len); 201 | continue; 202 | } 203 | len -= op - whave; 204 | do { 205 | PUP(out) = 0; 206 | } while (--op > whave); 207 | if (op == 0) { 208 | from = out - dist; 209 | do { 210 | PUP(out) = PUP(from); 211 | } while (--len); 212 | continue; 213 | } 214 | #endif 215 | } 216 | from = window - OFF; 217 | if (wnext == 0) { /* very common case */ 218 | from += wsize - op; 219 | if (op < len) { /* some from window */ 220 | len -= op; 221 | do { 222 | PUP(out) = PUP(from); 223 | } while (--op); 224 | from = out - dist; /* rest from output */ 225 | } 226 | } 227 | else if (wnext < op) { /* wrap around window */ 228 | from += wsize + wnext - op; 229 | op -= wnext; 230 | if (op < len) { /* some from end of window */ 231 | len -= op; 232 | do { 233 | PUP(out) = PUP(from); 234 | } while (--op); 235 | from = window - OFF; 236 | if (wnext < len) { /* some from start of window */ 237 | op = wnext; 238 | len -= op; 239 | do { 240 | PUP(out) = PUP(from); 241 | } while (--op); 242 | from = out - dist; /* rest from output */ 243 | } 244 | } 245 | } 246 | else { /* contiguous in window */ 247 | from += wnext - op; 248 | if (op < len) { /* some from window */ 249 | len -= op; 250 | do { 251 | PUP(out) = PUP(from); 252 | } while (--op); 253 | from = out - dist; /* rest from output */ 254 | } 255 | } 256 | while (len > 2) { 257 | PUP(out) = PUP(from); 258 | PUP(out) = PUP(from); 259 | PUP(out) = PUP(from); 260 | len -= 3; 261 | } 262 | if (len) { 263 | PUP(out) = PUP(from); 264 | if (len > 1) 265 | PUP(out) = PUP(from); 266 | } 267 | } 268 | else { 269 | from = out - dist; /* copy direct from output */ 270 | do { /* minimum length is three */ 271 | PUP(out) = PUP(from); 272 | PUP(out) = PUP(from); 273 | PUP(out) = PUP(from); 274 | len -= 3; 275 | } while (len > 2); 276 | if (len) { 277 | PUP(out) = PUP(from); 278 | if (len > 1) 279 | PUP(out) = PUP(from); 280 | } 281 | } 282 | } 283 | else if ((op & 64) == 0) { /* 2nd level distance code */ 284 | here = dcode[here.val + (hold & ((1U << op) - 1))]; 285 | goto dodist; 286 | } 287 | else { 288 | strm->msg = (char *)"invalid distance code"; 289 | state->mode = BAD; 290 | break; 291 | } 292 | } 293 | else if ((op & 64) == 0) { /* 2nd level length code */ 294 | here = lcode[here.val + (hold & ((1U << op) - 1))]; 295 | goto dolen; 296 | } 297 | else if (op & 32) { /* end-of-block */ 298 | Tracevv((stderr, "inflate: end of block\n")); 299 | state->mode = TYPE; 300 | break; 301 | } 302 | else { 303 | strm->msg = (char *)"invalid literal/length code"; 304 | state->mode = BAD; 305 | break; 306 | } 307 | } while (in < last && out < end); 308 | 309 | /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ 310 | len = bits >> 3; 311 | in -= len; 312 | bits -= len << 3; 313 | hold &= (1U << bits) - 1; 314 | 315 | /* update state and return */ 316 | strm->next_in = in + OFF; 317 | strm->next_out = out + OFF; 318 | strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); 319 | strm->avail_out = (unsigned)(out < end ? 320 | 257 + (end - out) : 257 - (out - end)); 321 | state->hold = hold; 322 | state->bits = bits; 323 | return; 324 | } 325 | 326 | /* 327 | inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe): 328 | - Using bit fields for code structure 329 | - Different op definition to avoid & for extra bits (do & for table bits) 330 | - Three separate decoding do-loops for direct, window, and wnext == 0 331 | - Special case for distance > 1 copies to do overlapped load and store copy 332 | - Explicit branch predictions (based on measured branch probabilities) 333 | - Deferring match copy and interspersed it with decoding subsequent codes 334 | - Swapping literal/length else 335 | - Swapping window/direct else 336 | - Larger unrolled copy loops (three is about right) 337 | - Moving len -= 3 statement into middle of loop 338 | */ 339 | 340 | #endif /* !ASMINF */ 341 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/inffixed.h: -------------------------------------------------------------------------------- 1 | /* inffixed.h -- table for decoding fixed codes 2 | * Generated automatically by makefixed(). 3 | */ 4 | 5 | /* WARNING: this file should *not* be used by applications. It 6 | is part of the implementation of the compression library and 7 | is subject to change. Applications should only use zlib.h. 8 | */ 9 | 10 | static const code lenfix[512] = { 11 | {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, 12 | {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, 13 | {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, 14 | {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, 15 | {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, 16 | {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, 17 | {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, 18 | {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, 19 | {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, 20 | {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, 21 | {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, 22 | {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, 23 | {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, 24 | {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, 25 | {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, 26 | {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, 27 | {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, 28 | {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, 29 | {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, 30 | {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, 31 | {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, 32 | {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, 33 | {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, 34 | {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, 35 | {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, 36 | {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, 37 | {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, 38 | {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, 39 | {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, 40 | {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, 41 | {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, 42 | {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, 43 | {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, 44 | {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, 45 | {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, 46 | {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, 47 | {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, 48 | {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, 49 | {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, 50 | {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, 51 | {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, 52 | {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, 53 | {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, 54 | {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, 55 | {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, 56 | {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, 57 | {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, 58 | {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, 59 | {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, 60 | {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, 61 | {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, 62 | {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, 63 | {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, 64 | {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, 65 | {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, 66 | {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, 67 | {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, 68 | {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, 69 | {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, 70 | {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, 71 | {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, 72 | {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, 73 | {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, 74 | {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, 75 | {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, 76 | {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, 77 | {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, 78 | {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, 79 | {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, 80 | {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, 81 | {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, 82 | {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, 83 | {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, 84 | {0,9,255} 85 | }; 86 | 87 | static const code distfix[32] = { 88 | {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, 89 | {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, 90 | {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, 91 | {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, 92 | {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, 93 | {22,5,193},{64,5,0} 94 | }; 95 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/inflate.h: -------------------------------------------------------------------------------- 1 | /* inflate.h -- internal inflate state definition 2 | * Copyright (C) 1995-2009 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* define NO_GZIP when compiling if you want to disable gzip header and 12 | trailer decoding by inflate(). NO_GZIP would be used to avoid linking in 13 | the crc code when it is not needed. For shared libraries, gzip decoding 14 | should be left enabled. */ 15 | #ifndef NO_GZIP 16 | # define GUNZIP 17 | #endif 18 | 19 | /* Possible inflate modes between inflate() calls */ 20 | typedef enum { 21 | HEAD, /* i: waiting for magic header */ 22 | FLAGS, /* i: waiting for method and flags (gzip) */ 23 | TIME, /* i: waiting for modification time (gzip) */ 24 | OS, /* i: waiting for extra flags and operating system (gzip) */ 25 | EXLEN, /* i: waiting for extra length (gzip) */ 26 | EXTRA, /* i: waiting for extra bytes (gzip) */ 27 | NAME, /* i: waiting for end of file name (gzip) */ 28 | COMMENT, /* i: waiting for end of comment (gzip) */ 29 | HCRC, /* i: waiting for header crc (gzip) */ 30 | DICTID, /* i: waiting for dictionary check value */ 31 | DICT, /* waiting for inflateSetDictionary() call */ 32 | TYPE, /* i: waiting for type bits, including last-flag bit */ 33 | TYPEDO, /* i: same, but skip check to exit inflate on new block */ 34 | STORED, /* i: waiting for stored size (length and complement) */ 35 | COPY_, /* i/o: same as COPY below, but only first time in */ 36 | COPY, /* i/o: waiting for input or output to copy stored block */ 37 | TABLE, /* i: waiting for dynamic block table lengths */ 38 | LENLENS, /* i: waiting for code length code lengths */ 39 | CODELENS, /* i: waiting for length/lit and distance code lengths */ 40 | LEN_, /* i: same as LEN below, but only first time in */ 41 | LEN, /* i: waiting for length/lit/eob code */ 42 | LENEXT, /* i: waiting for length extra bits */ 43 | DIST, /* i: waiting for distance code */ 44 | DISTEXT, /* i: waiting for distance extra bits */ 45 | MATCH, /* o: waiting for output space to copy string */ 46 | LIT, /* o: waiting for output space to write literal */ 47 | CHECK, /* i: waiting for 32-bit check value */ 48 | LENGTH, /* i: waiting for 32-bit length (gzip) */ 49 | DONE, /* finished check, done -- remain here until reset */ 50 | BAD, /* got a data error -- remain here until reset */ 51 | MEM, /* got an inflate() memory error -- remain here until reset */ 52 | SYNC /* looking for synchronization bytes to restart inflate() */ 53 | } inflate_mode; 54 | 55 | /* 56 | State transitions between above modes - 57 | 58 | (most modes can go to BAD or MEM on error -- not shown for clarity) 59 | 60 | Process header: 61 | HEAD -> (gzip) or (zlib) or (raw) 62 | (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT -> 63 | HCRC -> TYPE 64 | (zlib) -> DICTID or TYPE 65 | DICTID -> DICT -> TYPE 66 | (raw) -> TYPEDO 67 | Read deflate blocks: 68 | TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK 69 | STORED -> COPY_ -> COPY -> TYPE 70 | TABLE -> LENLENS -> CODELENS -> LEN_ 71 | LEN_ -> LEN 72 | Read deflate codes in fixed or dynamic block: 73 | LEN -> LENEXT or LIT or TYPE 74 | LENEXT -> DIST -> DISTEXT -> MATCH -> LEN 75 | LIT -> LEN 76 | Process trailer: 77 | CHECK -> LENGTH -> DONE 78 | */ 79 | 80 | /* state maintained between inflate() calls. Approximately 10K bytes. */ 81 | struct inflate_state { 82 | inflate_mode mode; /* current inflate mode */ 83 | int last; /* true if processing last block */ 84 | int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ 85 | int havedict; /* true if dictionary provided */ 86 | int flags; /* gzip header method and flags (0 if zlib) */ 87 | unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ 88 | unsigned long check; /* protected copy of check value */ 89 | unsigned long total; /* protected copy of output count */ 90 | gz_headerp head; /* where to save gzip header information */ 91 | /* sliding window */ 92 | unsigned wbits; /* log base 2 of requested window size */ 93 | unsigned wsize; /* window size or zero if not using window */ 94 | unsigned whave; /* valid bytes in the window */ 95 | unsigned wnext; /* window write index */ 96 | unsigned char FAR *window; /* allocated sliding window, if needed */ 97 | /* bit accumulator */ 98 | unsigned long hold; /* input bit accumulator */ 99 | unsigned bits; /* number of bits in "in" */ 100 | /* for string and stored block copying */ 101 | unsigned length; /* literal or length of data to copy */ 102 | unsigned offset; /* distance back to copy string from */ 103 | /* for table and code decoding */ 104 | unsigned extra; /* extra bits needed */ 105 | /* fixed and dynamic code tables */ 106 | code const FAR *lencode; /* starting table for length/literal codes */ 107 | code const FAR *distcode; /* starting table for distance codes */ 108 | unsigned lenbits; /* index bits for lencode */ 109 | unsigned distbits; /* index bits for distcode */ 110 | /* dynamic table building */ 111 | unsigned ncode; /* number of code length code lengths */ 112 | unsigned nlen; /* number of length code lengths */ 113 | unsigned ndist; /* number of distance code lengths */ 114 | unsigned have; /* number of code lengths in lens[] */ 115 | code FAR *next; /* next available space in codes[] */ 116 | unsigned short lens[320]; /* temporary storage for code lengths */ 117 | unsigned short work[288]; /* work area for code table building */ 118 | code codes[ENOUGH]; /* space for code tables */ 119 | int sane; /* if false, allow invalid distance too far */ 120 | int back; /* bits back of last unprocessed length/lit */ 121 | unsigned was; /* initial length of match */ 122 | }; 123 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/inftrees.c: -------------------------------------------------------------------------------- 1 | /* inftrees.c -- generate Huffman trees for efficient decoding 2 | * Copyright (C) 1995-2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "zutil.h" 7 | #include "inftrees.h" 8 | 9 | #define MAXBITS 15 10 | 11 | const char inflate_copyright[] = 12 | " inflate 1.2.5 Copyright 1995-2010 Mark Adler "; 13 | /* 14 | If you use the zlib library in a product, an acknowledgment is welcome 15 | in the documentation of your product. If for some reason you cannot 16 | include such an acknowledgment, I would appreciate that you keep this 17 | copyright string in the executable of your product. 18 | */ 19 | 20 | /* 21 | Build a set of tables to decode the provided canonical Huffman code. 22 | The code lengths are lens[0..codes-1]. The result starts at *table, 23 | whose indices are 0..2^bits-1. work is a writable array of at least 24 | lens shorts, which is used as a work area. type is the type of code 25 | to be generated, CODES, LENS, or DISTS. On return, zero is success, 26 | -1 is an invalid code, and +1 means that ENOUGH isn't enough. table 27 | on return points to the next available entry's address. bits is the 28 | requested root table index bits, and on return it is the actual root 29 | table index bits. It will differ if the request is greater than the 30 | longest code or if it is less than the shortest code. 31 | */ 32 | int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work) 33 | codetype type; 34 | unsigned short FAR *lens; 35 | unsigned codes; 36 | code FAR * FAR *table; 37 | unsigned FAR *bits; 38 | unsigned short FAR *work; 39 | { 40 | unsigned len; /* a code's length in bits */ 41 | unsigned sym; /* index of code symbols */ 42 | unsigned min, max; /* minimum and maximum code lengths */ 43 | unsigned root; /* number of index bits for root table */ 44 | unsigned curr; /* number of index bits for current table */ 45 | unsigned drop; /* code bits to drop for sub-table */ 46 | int left; /* number of prefix codes available */ 47 | unsigned used; /* code entries in table used */ 48 | unsigned huff; /* Huffman code */ 49 | unsigned incr; /* for incrementing code, index */ 50 | unsigned fill; /* index for replicating entries */ 51 | unsigned low; /* low bits for current root entry */ 52 | unsigned mask; /* mask for low root bits */ 53 | code here; /* table entry for duplication */ 54 | code FAR *next; /* next available space in table */ 55 | const unsigned short FAR *base; /* base value table to use */ 56 | const unsigned short FAR *extra; /* extra bits table to use */ 57 | int end; /* use base and extra for symbol > end */ 58 | unsigned short count[MAXBITS+1]; /* number of codes of each length */ 59 | unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ 60 | static const unsigned short lbase[31] = { /* Length codes 257..285 base */ 61 | 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 62 | 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; 63 | static const unsigned short lext[31] = { /* Length codes 257..285 extra */ 64 | 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 65 | 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 73, 195}; 66 | static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ 67 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 68 | 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 69 | 8193, 12289, 16385, 24577, 0, 0}; 70 | static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ 71 | 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 72 | 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 73 | 28, 28, 29, 29, 64, 64}; 74 | 75 | /* 76 | Process a set of code lengths to create a canonical Huffman code. The 77 | code lengths are lens[0..codes-1]. Each length corresponds to the 78 | symbols 0..codes-1. The Huffman code is generated by first sorting the 79 | symbols by length from short to long, and retaining the symbol order 80 | for codes with equal lengths. Then the code starts with all zero bits 81 | for the first code of the shortest length, and the codes are integer 82 | increments for the same length, and zeros are appended as the length 83 | increases. For the deflate format, these bits are stored backwards 84 | from their more natural integer increment ordering, and so when the 85 | decoding tables are built in the large loop below, the integer codes 86 | are incremented backwards. 87 | 88 | This routine assumes, but does not check, that all of the entries in 89 | lens[] are in the range 0..MAXBITS. The caller must assure this. 90 | 1..MAXBITS is interpreted as that code length. zero means that that 91 | symbol does not occur in this code. 92 | 93 | The codes are sorted by computing a count of codes for each length, 94 | creating from that a table of starting indices for each length in the 95 | sorted table, and then entering the symbols in order in the sorted 96 | table. The sorted table is work[], with that space being provided by 97 | the caller. 98 | 99 | The length counts are used for other purposes as well, i.e. finding 100 | the minimum and maximum length codes, determining if there are any 101 | codes at all, checking for a valid set of lengths, and looking ahead 102 | at length counts to determine sub-table sizes when building the 103 | decoding tables. 104 | */ 105 | 106 | /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ 107 | for (len = 0; len <= MAXBITS; len++) 108 | count[len] = 0; 109 | for (sym = 0; sym < codes; sym++) 110 | count[lens[sym]]++; 111 | 112 | /* bound code lengths, force root to be within code lengths */ 113 | root = *bits; 114 | for (max = MAXBITS; max >= 1; max--) 115 | if (count[max] != 0) break; 116 | if (root > max) root = max; 117 | if (max == 0) { /* no symbols to code at all */ 118 | here.op = (unsigned char)64; /* invalid code marker */ 119 | here.bits = (unsigned char)1; 120 | here.val = (unsigned short)0; 121 | *(*table)++ = here; /* make a table to force an error */ 122 | *(*table)++ = here; 123 | *bits = 1; 124 | return 0; /* no symbols, but wait for decoding to report error */ 125 | } 126 | for (min = 1; min < max; min++) 127 | if (count[min] != 0) break; 128 | if (root < min) root = min; 129 | 130 | /* check for an over-subscribed or incomplete set of lengths */ 131 | left = 1; 132 | for (len = 1; len <= MAXBITS; len++) { 133 | left <<= 1; 134 | left -= count[len]; 135 | if (left < 0) return -1; /* over-subscribed */ 136 | } 137 | if (left > 0 && (type == CODES || max != 1)) 138 | return -1; /* incomplete set */ 139 | 140 | /* generate offsets into symbol table for each length for sorting */ 141 | offs[1] = 0; 142 | for (len = 1; len < MAXBITS; len++) 143 | offs[len + 1] = offs[len] + count[len]; 144 | 145 | /* sort symbols by length, by symbol order within each length */ 146 | for (sym = 0; sym < codes; sym++) 147 | if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; 148 | 149 | /* 150 | Create and fill in decoding tables. In this loop, the table being 151 | filled is at next and has curr index bits. The code being used is huff 152 | with length len. That code is converted to an index by dropping drop 153 | bits off of the bottom. For codes where len is less than drop + curr, 154 | those top drop + curr - len bits are incremented through all values to 155 | fill the table with replicated entries. 156 | 157 | root is the number of index bits for the root table. When len exceeds 158 | root, sub-tables are created pointed to by the root entry with an index 159 | of the low root bits of huff. This is saved in low to check for when a 160 | new sub-table should be started. drop is zero when the root table is 161 | being filled, and drop is root when sub-tables are being filled. 162 | 163 | When a new sub-table is needed, it is necessary to look ahead in the 164 | code lengths to determine what size sub-table is needed. The length 165 | counts are used for this, and so count[] is decremented as codes are 166 | entered in the tables. 167 | 168 | used keeps track of how many table entries have been allocated from the 169 | provided *table space. It is checked for LENS and DIST tables against 170 | the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in 171 | the initial root table size constants. See the comments in inftrees.h 172 | for more information. 173 | 174 | sym increments through all symbols, and the loop terminates when 175 | all codes of length max, i.e. all codes, have been processed. This 176 | routine permits incomplete codes, so another loop after this one fills 177 | in the rest of the decoding tables with invalid code markers. 178 | */ 179 | 180 | /* set up for code type */ 181 | switch (type) { 182 | case CODES: 183 | base = extra = work; /* dummy value--not used */ 184 | end = 19; 185 | break; 186 | case LENS: 187 | base = lbase; 188 | base -= 257; 189 | extra = lext; 190 | extra -= 257; 191 | end = 256; 192 | break; 193 | default: /* DISTS */ 194 | base = dbase; 195 | extra = dext; 196 | end = -1; 197 | } 198 | 199 | /* initialize state for loop */ 200 | huff = 0; /* starting code */ 201 | sym = 0; /* starting code symbol */ 202 | len = min; /* starting code length */ 203 | next = *table; /* current table to fill in */ 204 | curr = root; /* current table index bits */ 205 | drop = 0; /* current bits to drop from code for index */ 206 | low = (unsigned)(-1); /* trigger new sub-table when len > root */ 207 | used = 1U << root; /* use root table entries */ 208 | mask = used - 1; /* mask for comparing low */ 209 | 210 | /* check available table space */ 211 | if ((type == LENS && used >= ENOUGH_LENS) || 212 | (type == DISTS && used >= ENOUGH_DISTS)) 213 | return 1; 214 | 215 | /* process all codes and make table entries */ 216 | for (;;) { 217 | /* create table entry */ 218 | here.bits = (unsigned char)(len - drop); 219 | if ((int)(work[sym]) < end) { 220 | here.op = (unsigned char)0; 221 | here.val = work[sym]; 222 | } 223 | else if ((int)(work[sym]) > end) { 224 | here.op = (unsigned char)(extra[work[sym]]); 225 | here.val = base[work[sym]]; 226 | } 227 | else { 228 | here.op = (unsigned char)(32 + 64); /* end of block */ 229 | here.val = 0; 230 | } 231 | 232 | /* replicate for those indices with low len bits equal to huff */ 233 | incr = 1U << (len - drop); 234 | fill = 1U << curr; 235 | min = fill; /* save offset to next table */ 236 | do { 237 | fill -= incr; 238 | next[(huff >> drop) + fill] = here; 239 | } while (fill != 0); 240 | 241 | /* backwards increment the len-bit code huff */ 242 | incr = 1U << (len - 1); 243 | while (huff & incr) 244 | incr >>= 1; 245 | if (incr != 0) { 246 | huff &= incr - 1; 247 | huff += incr; 248 | } 249 | else 250 | huff = 0; 251 | 252 | /* go to next symbol, update count, len */ 253 | sym++; 254 | if (--(count[len]) == 0) { 255 | if (len == max) break; 256 | len = lens[work[sym]]; 257 | } 258 | 259 | /* create new sub-table if needed */ 260 | if (len > root && (huff & mask) != low) { 261 | /* if first time, transition to sub-tables */ 262 | if (drop == 0) 263 | drop = root; 264 | 265 | /* increment past last table */ 266 | next += min; /* here min is 1 << curr */ 267 | 268 | /* determine length of next table */ 269 | curr = len - drop; 270 | left = (int)(1 << curr); 271 | while (curr + drop < max) { 272 | left -= count[curr + drop]; 273 | if (left <= 0) break; 274 | curr++; 275 | left <<= 1; 276 | } 277 | 278 | /* check for enough space */ 279 | used += 1U << curr; 280 | if ((type == LENS && used >= ENOUGH_LENS) || 281 | (type == DISTS && used >= ENOUGH_DISTS)) 282 | return 1; 283 | 284 | /* point entry in root table to sub-table */ 285 | low = huff & mask; 286 | (*table)[low].op = (unsigned char)curr; 287 | (*table)[low].bits = (unsigned char)root; 288 | (*table)[low].val = (unsigned short)(next - *table); 289 | } 290 | } 291 | 292 | /* 293 | Fill in rest of table for incomplete codes. This loop is similar to the 294 | loop above in incrementing huff for table indices. It is assumed that 295 | len is equal to curr + drop, so there is no loop needed to increment 296 | through high index bits. When the current sub-table is filled, the loop 297 | drops back to the root table to fill in any remaining entries there. 298 | */ 299 | here.op = (unsigned char)64; /* invalid code marker */ 300 | here.bits = (unsigned char)(len - drop); 301 | here.val = (unsigned short)0; 302 | while (huff != 0) { 303 | /* when done with sub-table, drop back to root table */ 304 | if (drop != 0 && (huff & mask) != low) { 305 | drop = 0; 306 | len = root; 307 | next = *table; 308 | here.bits = (unsigned char)len; 309 | } 310 | 311 | /* put invalid code marker in table */ 312 | next[huff >> drop] = here; 313 | 314 | /* backwards increment the len-bit code huff */ 315 | incr = 1U << (len - 1); 316 | while (huff & incr) 317 | incr >>= 1; 318 | if (incr != 0) { 319 | huff &= incr - 1; 320 | huff += incr; 321 | } 322 | else 323 | huff = 0; 324 | } 325 | 326 | /* set return parameters */ 327 | *table += used; 328 | *bits = root; 329 | return 0; 330 | } 331 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/inftrees.h: -------------------------------------------------------------------------------- 1 | /* inftrees.h -- header to use inftrees.c 2 | * Copyright (C) 1995-2005, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Structure for decoding tables. Each entry provides either the 12 | information needed to do the operation requested by the code that 13 | indexed that table entry, or it provides a pointer to another 14 | table that indexes more bits of the code. op indicates whether 15 | the entry is a pointer to another table, a literal, a length or 16 | distance, an end-of-block, or an invalid code. For a table 17 | pointer, the low four bits of op is the number of index bits of 18 | that table. For a length or distance, the low four bits of op 19 | is the number of extra bits to get after the code. bits is 20 | the number of bits in this code or part of the code to drop off 21 | of the bit buffer. val is the actual byte to output in the case 22 | of a literal, the base length or distance, or the offset from 23 | the current table to the next table. Each entry is four bytes. */ 24 | typedef struct { 25 | unsigned char op; /* operation, extra bits, table bits */ 26 | unsigned char bits; /* bits in this part of the code */ 27 | unsigned short val; /* offset in table or code value */ 28 | } code; 29 | 30 | /* op values as set by inflate_table(): 31 | 00000000 - literal 32 | 0000tttt - table link, tttt != 0 is the number of table index bits 33 | 0001eeee - length or distance, eeee is the number of extra bits 34 | 01100000 - end of block 35 | 01000000 - invalid code 36 | */ 37 | 38 | /* Maximum size of the dynamic table. The maximum number of code structures is 39 | 1444, which is the sum of 852 for literal/length codes and 592 for distance 40 | codes. These values were found by exhaustive searches using the program 41 | examples/enough.c found in the zlib distribtution. The arguments to that 42 | program are the number of symbols, the initial root table size, and the 43 | maximum bit length of a code. "enough 286 9 15" for literal/length codes 44 | returns returns 852, and "enough 30 6 15" for distance codes returns 592. 45 | The initial root table size (9 or 6) is found in the fifth argument of the 46 | inflate_table() calls in inflate.c and infback.c. If the root table size is 47 | changed, then these maximum sizes would be need to be recalculated and 48 | updated. */ 49 | #define ENOUGH_LENS 852 50 | #define ENOUGH_DISTS 592 51 | #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) 52 | 53 | /* Type of code to build for inflate_table() */ 54 | typedef enum { 55 | CODES, 56 | LENS, 57 | DISTS 58 | } codetype; 59 | 60 | int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, 61 | unsigned codes, code FAR * FAR *table, 62 | unsigned FAR *bits, unsigned short FAR *work)); 63 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/minigzip.c: -------------------------------------------------------------------------------- 1 | /* minigzip.c -- simulate gzip using the zlib compression library 2 | * Copyright (C) 1995-2006, 2010 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* 7 | * minigzip is a minimal implementation of the gzip utility. This is 8 | * only an example of using zlib and isn't meant to replace the 9 | * full-featured gzip. No attempt is made to deal with file systems 10 | * limiting names to 14 or 8+3 characters, etc... Error checking is 11 | * very limited. So use minigzip only for testing; use gzip for the 12 | * real thing. On MSDOS, use only on file names without extension 13 | * or in pipe mode. 14 | */ 15 | 16 | /* @(#) $Id$ */ 17 | 18 | #include "zlib.h" 19 | #include 20 | 21 | #ifdef STDC 22 | # include 23 | # include 24 | #endif 25 | 26 | #ifdef USE_MMAP 27 | # include 28 | # include 29 | # include 30 | #endif 31 | 32 | #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__) 33 | # include 34 | # include 35 | # ifdef UNDER_CE 36 | # include 37 | # endif 38 | # define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) 39 | #else 40 | # define SET_BINARY_MODE(file) 41 | #endif 42 | 43 | #ifdef VMS 44 | # define unlink delete 45 | # define GZ_SUFFIX "-gz" 46 | #endif 47 | #ifdef RISCOS 48 | # define unlink remove 49 | # define GZ_SUFFIX "-gz" 50 | # define fileno(file) file->__file 51 | #endif 52 | #if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os 53 | # include /* for fileno */ 54 | #endif 55 | 56 | #if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE) 57 | #ifndef WIN32 /* unlink already in stdio.h for WIN32 */ 58 | extern int unlink OF((const char *)); 59 | #endif 60 | #endif 61 | 62 | #if defined(UNDER_CE) 63 | # include 64 | # define perror(s) pwinerror(s) 65 | 66 | /* Map the Windows error number in ERROR to a locale-dependent error 67 | message string and return a pointer to it. Typically, the values 68 | for ERROR come from GetLastError. 69 | 70 | The string pointed to shall not be modified by the application, 71 | but may be overwritten by a subsequent call to strwinerror 72 | 73 | The strwinerror function does not change the current setting 74 | of GetLastError. */ 75 | 76 | static char *strwinerror (error) 77 | DWORD error; 78 | { 79 | static char buf[1024]; 80 | 81 | wchar_t *msgbuf; 82 | DWORD lasterr = GetLastError(); 83 | DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM 84 | | FORMAT_MESSAGE_ALLOCATE_BUFFER, 85 | NULL, 86 | error, 87 | 0, /* Default language */ 88 | (LPVOID)&msgbuf, 89 | 0, 90 | NULL); 91 | if (chars != 0) { 92 | /* If there is an \r\n appended, zap it. */ 93 | if (chars >= 2 94 | && msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n') { 95 | chars -= 2; 96 | msgbuf[chars] = 0; 97 | } 98 | 99 | if (chars > sizeof (buf) - 1) { 100 | chars = sizeof (buf) - 1; 101 | msgbuf[chars] = 0; 102 | } 103 | 104 | wcstombs(buf, msgbuf, chars + 1); 105 | LocalFree(msgbuf); 106 | } 107 | else { 108 | sprintf(buf, "unknown win32 error (%ld)", error); 109 | } 110 | 111 | SetLastError(lasterr); 112 | return buf; 113 | } 114 | 115 | static void pwinerror (s) 116 | const char *s; 117 | { 118 | if (s && *s) 119 | fprintf(stderr, "%s: %s\n", s, strwinerror(GetLastError ())); 120 | else 121 | fprintf(stderr, "%s\n", strwinerror(GetLastError ())); 122 | } 123 | 124 | #endif /* UNDER_CE */ 125 | 126 | #ifndef GZ_SUFFIX 127 | # define GZ_SUFFIX ".gz" 128 | #endif 129 | #define SUFFIX_LEN (sizeof(GZ_SUFFIX)-1) 130 | 131 | #define BUFLEN 16384 132 | #define MAX_NAME_LEN 1024 133 | 134 | #ifdef MAXSEG_64K 135 | # define local static 136 | /* Needed for systems with limitation on stack size. */ 137 | #else 138 | # define local 139 | #endif 140 | 141 | char *prog; 142 | 143 | void error OF((const char *msg)); 144 | void gz_compress OF((FILE *in, gzFile out)); 145 | #ifdef USE_MMAP 146 | int gz_compress_mmap OF((FILE *in, gzFile out)); 147 | #endif 148 | void gz_uncompress OF((gzFile in, FILE *out)); 149 | void file_compress OF((char *file, char *mode)); 150 | void file_uncompress OF((char *file)); 151 | int main OF((int argc, char *argv[])); 152 | 153 | /* =========================================================================== 154 | * Display error message and exit 155 | */ 156 | void error(msg) 157 | const char *msg; 158 | { 159 | fprintf(stderr, "%s: %s\n", prog, msg); 160 | exit(1); 161 | } 162 | 163 | /* =========================================================================== 164 | * Compress input to output then close both files. 165 | */ 166 | 167 | void gz_compress(in, out) 168 | FILE *in; 169 | gzFile out; 170 | { 171 | local char buf[BUFLEN]; 172 | int len; 173 | int err; 174 | 175 | #ifdef USE_MMAP 176 | /* Try first compressing with mmap. If mmap fails (minigzip used in a 177 | * pipe), use the normal fread loop. 178 | */ 179 | if (gz_compress_mmap(in, out) == Z_OK) return; 180 | #endif 181 | for (;;) { 182 | len = (int)fread(buf, 1, sizeof(buf), in); 183 | if (ferror(in)) { 184 | perror("fread"); 185 | exit(1); 186 | } 187 | if (len == 0) break; 188 | 189 | if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err)); 190 | } 191 | fclose(in); 192 | if (gzclose(out) != Z_OK) error("failed gzclose"); 193 | } 194 | 195 | #ifdef USE_MMAP /* MMAP version, Miguel Albrecht */ 196 | 197 | /* Try compressing the input file at once using mmap. Return Z_OK if 198 | * if success, Z_ERRNO otherwise. 199 | */ 200 | int gz_compress_mmap(in, out) 201 | FILE *in; 202 | gzFile out; 203 | { 204 | int len; 205 | int err; 206 | int ifd = fileno(in); 207 | caddr_t buf; /* mmap'ed buffer for the entire input file */ 208 | off_t buf_len; /* length of the input file */ 209 | struct stat sb; 210 | 211 | /* Determine the size of the file, needed for mmap: */ 212 | if (fstat(ifd, &sb) < 0) return Z_ERRNO; 213 | buf_len = sb.st_size; 214 | if (buf_len <= 0) return Z_ERRNO; 215 | 216 | /* Now do the actual mmap: */ 217 | buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0); 218 | if (buf == (caddr_t)(-1)) return Z_ERRNO; 219 | 220 | /* Compress the whole file at once: */ 221 | len = gzwrite(out, (char *)buf, (unsigned)buf_len); 222 | 223 | if (len != (int)buf_len) error(gzerror(out, &err)); 224 | 225 | munmap(buf, buf_len); 226 | fclose(in); 227 | if (gzclose(out) != Z_OK) error("failed gzclose"); 228 | return Z_OK; 229 | } 230 | #endif /* USE_MMAP */ 231 | 232 | /* =========================================================================== 233 | * Uncompress input to output then close both files. 234 | */ 235 | void gz_uncompress(in, out) 236 | gzFile in; 237 | FILE *out; 238 | { 239 | local char buf[BUFLEN]; 240 | int len; 241 | int err; 242 | 243 | for (;;) { 244 | len = gzread(in, buf, sizeof(buf)); 245 | if (len < 0) error (gzerror(in, &err)); 246 | if (len == 0) break; 247 | 248 | if ((int)fwrite(buf, 1, (unsigned)len, out) != len) { 249 | error("failed fwrite"); 250 | } 251 | } 252 | if (fclose(out)) error("failed fclose"); 253 | 254 | if (gzclose(in) != Z_OK) error("failed gzclose"); 255 | } 256 | 257 | 258 | /* =========================================================================== 259 | * Compress the given file: create a corresponding .gz file and remove the 260 | * original. 261 | */ 262 | void file_compress(file, mode) 263 | char *file; 264 | char *mode; 265 | { 266 | local char outfile[MAX_NAME_LEN]; 267 | FILE *in; 268 | gzFile out; 269 | 270 | if (strlen(file) + strlen(GZ_SUFFIX) >= sizeof(outfile)) { 271 | fprintf(stderr, "%s: filename too long\n", prog); 272 | exit(1); 273 | } 274 | 275 | strcpy(outfile, file); 276 | strcat(outfile, GZ_SUFFIX); 277 | 278 | in = fopen(file, "rb"); 279 | if (in == NULL) { 280 | perror(file); 281 | exit(1); 282 | } 283 | out = gzopen(outfile, mode); 284 | if (out == NULL) { 285 | fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile); 286 | exit(1); 287 | } 288 | gz_compress(in, out); 289 | 290 | unlink(file); 291 | } 292 | 293 | 294 | /* =========================================================================== 295 | * Uncompress the given file and remove the original. 296 | */ 297 | void file_uncompress(file) 298 | char *file; 299 | { 300 | local char buf[MAX_NAME_LEN]; 301 | char *infile, *outfile; 302 | FILE *out; 303 | gzFile in; 304 | size_t len = strlen(file); 305 | 306 | if (len + strlen(GZ_SUFFIX) >= sizeof(buf)) { 307 | fprintf(stderr, "%s: filename too long\n", prog); 308 | exit(1); 309 | } 310 | 311 | strcpy(buf, file); 312 | 313 | if (len > SUFFIX_LEN && strcmp(file+len-SUFFIX_LEN, GZ_SUFFIX) == 0) { 314 | infile = file; 315 | outfile = buf; 316 | outfile[len-3] = '\0'; 317 | } else { 318 | outfile = file; 319 | infile = buf; 320 | strcat(infile, GZ_SUFFIX); 321 | } 322 | in = gzopen(infile, "rb"); 323 | if (in == NULL) { 324 | fprintf(stderr, "%s: can't gzopen %s\n", prog, infile); 325 | exit(1); 326 | } 327 | out = fopen(outfile, "wb"); 328 | if (out == NULL) { 329 | perror(file); 330 | exit(1); 331 | } 332 | 333 | gz_uncompress(in, out); 334 | 335 | unlink(infile); 336 | } 337 | 338 | 339 | /* =========================================================================== 340 | * Usage: minigzip [-c] [-d] [-f] [-h] [-r] [-1 to -9] [files...] 341 | * -c : write to standard output 342 | * -d : decompress 343 | * -f : compress with Z_FILTERED 344 | * -h : compress with Z_HUFFMAN_ONLY 345 | * -r : compress with Z_RLE 346 | * -1 to -9 : compression level 347 | */ 348 | 349 | int main(argc, argv) 350 | int argc; 351 | char *argv[]; 352 | { 353 | int copyout = 0; 354 | int uncompr = 0; 355 | gzFile file; 356 | char *bname, outmode[20]; 357 | 358 | strcpy(outmode, "wb6 "); 359 | 360 | prog = argv[0]; 361 | bname = strrchr(argv[0], '/'); 362 | if (bname) 363 | bname++; 364 | else 365 | bname = argv[0]; 366 | argc--, argv++; 367 | 368 | if (!strcmp(bname, "gunzip")) 369 | uncompr = 1; 370 | else if (!strcmp(bname, "zcat")) 371 | copyout = uncompr = 1; 372 | 373 | while (argc > 0) { 374 | if (strcmp(*argv, "-c") == 0) 375 | copyout = 1; 376 | else if (strcmp(*argv, "-d") == 0) 377 | uncompr = 1; 378 | else if (strcmp(*argv, "-f") == 0) 379 | outmode[3] = 'f'; 380 | else if (strcmp(*argv, "-h") == 0) 381 | outmode[3] = 'h'; 382 | else if (strcmp(*argv, "-r") == 0) 383 | outmode[3] = 'R'; 384 | else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' && 385 | (*argv)[2] == 0) 386 | outmode[2] = (*argv)[1]; 387 | else 388 | break; 389 | argc--, argv++; 390 | } 391 | if (outmode[3] == ' ') 392 | outmode[3] = 0; 393 | if (argc == 0) { 394 | SET_BINARY_MODE(stdin); 395 | SET_BINARY_MODE(stdout); 396 | if (uncompr) { 397 | file = gzdopen(fileno(stdin), "rb"); 398 | if (file == NULL) error("can't gzdopen stdin"); 399 | gz_uncompress(file, stdout); 400 | } else { 401 | file = gzdopen(fileno(stdout), outmode); 402 | if (file == NULL) error("can't gzdopen stdout"); 403 | gz_compress(stdin, file); 404 | } 405 | } else { 406 | if (copyout) { 407 | SET_BINARY_MODE(stdout); 408 | } 409 | do { 410 | if (uncompr) { 411 | if (copyout) { 412 | file = gzopen(*argv, "rb"); 413 | if (file == NULL) 414 | fprintf(stderr, "%s: can't gzopen %s\n", prog, *argv); 415 | else 416 | gz_uncompress(file, stdout); 417 | } else { 418 | file_uncompress(*argv); 419 | } 420 | } else { 421 | if (copyout) { 422 | FILE * in = fopen(*argv, "rb"); 423 | 424 | if (in == NULL) { 425 | perror(*argv); 426 | } else { 427 | file = gzdopen(fileno(stdout), outmode); 428 | if (file == NULL) error("can't gzdopen stdout"); 429 | 430 | gz_compress(in, file); 431 | } 432 | 433 | } else { 434 | file_compress(*argv, outmode); 435 | } 436 | } 437 | } while (argv++, --argc); 438 | } 439 | return 0; 440 | } 441 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/treebuild.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | zip compression library 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 117 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/trees.h: -------------------------------------------------------------------------------- 1 | /* header created automatically with -DGEN_TREES_H */ 2 | 3 | local const ct_data static_ltree[L_CODES+2] = { 4 | {{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, 5 | {{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, 6 | {{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, 7 | {{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, 8 | {{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, 9 | {{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, 10 | {{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, 11 | {{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, 12 | {{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, 13 | {{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, 14 | {{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, 15 | {{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, 16 | {{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, 17 | {{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, 18 | {{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, 19 | {{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, 20 | {{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, 21 | {{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, 22 | {{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, 23 | {{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, 24 | {{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, 25 | {{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, 26 | {{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, 27 | {{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, 28 | {{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, 29 | {{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, 30 | {{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, 31 | {{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, 32 | {{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, 33 | {{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, 34 | {{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, 35 | {{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, 36 | {{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, 37 | {{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, 38 | {{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, 39 | {{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, 40 | {{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, 41 | {{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, 42 | {{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, 43 | {{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, 44 | {{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, 45 | {{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, 46 | {{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, 47 | {{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, 48 | {{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, 49 | {{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, 50 | {{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, 51 | {{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, 52 | {{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, 53 | {{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, 54 | {{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, 55 | {{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, 56 | {{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, 57 | {{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, 58 | {{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, 59 | {{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, 60 | {{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, 61 | {{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} 62 | }; 63 | 64 | local const ct_data static_dtree[D_CODES] = { 65 | {{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, 66 | {{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, 67 | {{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, 68 | {{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, 69 | {{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, 70 | {{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} 71 | }; 72 | 73 | const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = { 74 | 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 75 | 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 76 | 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 77 | 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 78 | 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 79 | 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 80 | 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 81 | 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 82 | 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 83 | 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 84 | 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 85 | 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 86 | 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, 87 | 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 88 | 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 89 | 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 90 | 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 91 | 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 92 | 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 93 | 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 94 | 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 95 | 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 96 | 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 97 | 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 98 | 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 99 | 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 100 | }; 101 | 102 | const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= { 103 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, 104 | 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 105 | 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 106 | 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 107 | 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 108 | 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 109 | 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 110 | 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 111 | 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 112 | 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 113 | 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 114 | 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 115 | 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 116 | }; 117 | 118 | local const int base_length[LENGTH_CODES] = { 119 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, 120 | 64, 80, 96, 112, 128, 160, 192, 224, 0 121 | }; 122 | 123 | local const int base_dist[D_CODES] = { 124 | 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 125 | 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 126 | 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 127 | }; 128 | 129 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/uncompr.c: -------------------------------------------------------------------------------- 1 | /* uncompr.c -- decompress a memory buffer 2 | * Copyright (C) 1995-2003, 2010 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Decompresses the source buffer into the destination buffer. sourceLen is 13 | the byte length of the source buffer. Upon entry, destLen is the total 14 | size of the destination buffer, which must be large enough to hold the 15 | entire uncompressed data. (The size of the uncompressed data must have 16 | been saved previously by the compressor and transmitted to the decompressor 17 | by some mechanism outside the scope of this compression library.) 18 | Upon exit, destLen is the actual size of the compressed buffer. 19 | 20 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not 21 | enough memory, Z_BUF_ERROR if there was not enough room in the output 22 | buffer, or Z_DATA_ERROR if the input data was corrupted. 23 | */ 24 | int ZEXPORT uncompress (dest, destLen, source, sourceLen) 25 | Bytef *dest; 26 | uLongf *destLen; 27 | const Bytef *source; 28 | uLong sourceLen; 29 | { 30 | z_stream stream; 31 | int err; 32 | 33 | stream.next_in = (Bytef*)source; 34 | stream.avail_in = (uInt)sourceLen; 35 | /* Check for source > 64K on 16-bit machine: */ 36 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 37 | 38 | stream.next_out = dest; 39 | stream.avail_out = (uInt)*destLen; 40 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 41 | 42 | stream.zalloc = (alloc_func)0; 43 | stream.zfree = (free_func)0; 44 | 45 | err = inflateInit(&stream); 46 | if (err != Z_OK) return err; 47 | 48 | err = inflate(&stream, Z_FINISH); 49 | if (err != Z_STREAM_END) { 50 | inflateEnd(&stream); 51 | if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) 52 | return Z_DATA_ERROR; 53 | return err; 54 | } 55 | *destLen = stream.total_out; 56 | 57 | err = inflateEnd(&stream); 58 | return err; 59 | } 60 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/zconf.h: -------------------------------------------------------------------------------- 1 | /* zconf.h -- configuration of the zlib compression library 2 | * Copyright (C) 1995-2010 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #ifndef ZCONF_H 9 | #define ZCONF_H 10 | 11 | /* Since Qt Core must export these symbols, define Z_PREFIX to avoid clashes system zlib */ 12 | #define Z_PREFIX 13 | 14 | /* 15 | * If you *really* need a unique prefix for all types and library functions, 16 | * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. 17 | * Even better than compiling with -DZ_PREFIX would be to use configure to set 18 | * this permanently in zconf.h using "./configure --zprefix". 19 | */ 20 | #ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ 21 | 22 | /* all linked symbols */ 23 | # define _dist_code z__dist_code 24 | # define _length_code z__length_code 25 | # define _tr_align z__tr_align 26 | # define _tr_flush_block z__tr_flush_block 27 | # define _tr_init z__tr_init 28 | # define _tr_stored_block z__tr_stored_block 29 | # define _tr_tally z__tr_tally 30 | # define adler32 z_adler32 31 | # define adler32_combine z_adler32_combine 32 | # define adler32_combine64 z_adler32_combine64 33 | # define compress z_compress 34 | # define compress2 z_compress2 35 | # define compressBound z_compressBound 36 | # define crc32 z_crc32 37 | # define crc32_combine z_crc32_combine 38 | # define crc32_combine64 z_crc32_combine64 39 | # define deflate z_deflate 40 | # define deflateBound z_deflateBound 41 | # define deflateCopy z_deflateCopy 42 | # define deflateEnd z_deflateEnd 43 | # define deflateInit2_ z_deflateInit2_ 44 | # define deflateInit_ z_deflateInit_ 45 | # define deflateParams z_deflateParams 46 | # define deflatePrime z_deflatePrime 47 | # define deflateReset z_deflateReset 48 | # define deflateSetDictionary z_deflateSetDictionary 49 | # define deflateSetHeader z_deflateSetHeader 50 | # define deflateTune z_deflateTune 51 | # define deflate_copyright z_deflate_copyright 52 | # define get_crc_table z_get_crc_table 53 | # define gz_error z_gz_error 54 | # define gz_intmax z_gz_intmax 55 | # define gz_strwinerror z_gz_strwinerror 56 | # define gzbuffer z_gzbuffer 57 | # define gzclearerr z_gzclearerr 58 | # define gzclose z_gzclose 59 | # define gzclose_r z_gzclose_r 60 | # define gzclose_w z_gzclose_w 61 | # define gzdirect z_gzdirect 62 | # define gzdopen z_gzdopen 63 | # define gzeof z_gzeof 64 | # define gzerror z_gzerror 65 | # define gzflush z_gzflush 66 | # define gzgetc z_gzgetc 67 | # define gzgets z_gzgets 68 | # define gzoffset z_gzoffset 69 | # define gzoffset64 z_gzoffset64 70 | # define gzopen z_gzopen 71 | # define gzopen64 z_gzopen64 72 | # define gzprintf z_gzprintf 73 | # define gzputc z_gzputc 74 | # define gzputs z_gzputs 75 | # define gzread z_gzread 76 | # define gzrewind z_gzrewind 77 | # define gzseek z_gzseek 78 | # define gzseek64 z_gzseek64 79 | # define gzsetparams z_gzsetparams 80 | # define gztell z_gztell 81 | # define gztell64 z_gztell64 82 | # define gzungetc z_gzungetc 83 | # define gzwrite z_gzwrite 84 | # define inflate z_inflate 85 | # define inflateBack z_inflateBack 86 | # define inflateBackEnd z_inflateBackEnd 87 | # define inflateBackInit_ z_inflateBackInit_ 88 | # define inflateCopy z_inflateCopy 89 | # define inflateEnd z_inflateEnd 90 | # define inflateGetHeader z_inflateGetHeader 91 | # define inflateInit2_ z_inflateInit2_ 92 | # define inflateInit_ z_inflateInit_ 93 | # define inflateMark z_inflateMark 94 | # define inflatePrime z_inflatePrime 95 | # define inflateReset z_inflateReset 96 | # define inflateReset2 z_inflateReset2 97 | # define inflateSetDictionary z_inflateSetDictionary 98 | # define inflateSync z_inflateSync 99 | # define inflateSyncPoint z_inflateSyncPoint 100 | # define inflateUndermine z_inflateUndermine 101 | # define inflate_copyright z_inflate_copyright 102 | # define inflate_fast z_inflate_fast 103 | # define inflate_table z_inflate_table 104 | # define uncompress z_uncompress 105 | # define zError z_zError 106 | # define zcalloc z_zcalloc 107 | # define zcfree z_zcfree 108 | # define zlibCompileFlags z_zlibCompileFlags 109 | # define zlibVersion z_zlibVersion 110 | # define z_errmsg z_z_errmsg 111 | 112 | /* all zlib typedefs in zlib.h and zconf.h */ 113 | # define Byte z_Byte 114 | # define Bytef z_Bytef 115 | # define alloc_func z_alloc_func 116 | # define charf z_charf 117 | # define free_func z_free_func 118 | # define gzFile z_gzFile 119 | # define gz_header z_gz_header 120 | # define gz_headerp z_gz_headerp 121 | # define in_func z_in_func 122 | # define intf z_intf 123 | # define out_func z_out_func 124 | # define uInt z_uInt 125 | # define uIntf z_uIntf 126 | # define uLong z_uLong 127 | # define uLongf z_uLongf 128 | # define voidp z_voidp 129 | # define voidpc z_voidpc 130 | # define voidpf z_voidpf 131 | 132 | /* all zlib structs in zlib.h and zconf.h */ 133 | # define gz_header_s z_gz_header_s 134 | # define internal_state z_internal_state 135 | 136 | #endif 137 | 138 | #if defined(__MSDOS__) && !defined(MSDOS) 139 | # define MSDOS 140 | #endif 141 | #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) 142 | # define OS2 143 | #endif 144 | #if defined(_WINDOWS) && !defined(WINDOWS) 145 | # define WINDOWS 146 | #endif 147 | #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) 148 | # ifndef WIN32 149 | # define WIN32 150 | # endif 151 | #endif 152 | #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) 153 | # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) 154 | # ifndef SYS16BIT 155 | # define SYS16BIT 156 | # endif 157 | # endif 158 | #endif 159 | 160 | /* 161 | * Compile with -DMAXSEG_64K if the alloc function cannot allocate more 162 | * than 64k bytes at a time (needed on systems with 16-bit int). 163 | */ 164 | #ifdef SYS16BIT 165 | # define MAXSEG_64K 166 | #endif 167 | #ifdef MSDOS 168 | # define UNALIGNED_OK 169 | #endif 170 | 171 | #ifdef __STDC_VERSION__ 172 | # ifndef STDC 173 | # define STDC 174 | # endif 175 | # if __STDC_VERSION__ >= 199901L 176 | # ifndef STDC99 177 | # define STDC99 178 | # endif 179 | # endif 180 | #endif 181 | #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) 182 | # define STDC 183 | #endif 184 | #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) 185 | # define STDC 186 | #endif 187 | #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) 188 | # define STDC 189 | #endif 190 | #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) 191 | # define STDC 192 | #endif 193 | 194 | #if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ 195 | # define STDC 196 | #endif 197 | 198 | #ifndef STDC 199 | # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ 200 | # define const /* note: need a more gentle solution here */ 201 | # endif 202 | #endif 203 | 204 | /* Some Mac compilers merge all .h files incorrectly: */ 205 | #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) 206 | # define NO_DUMMY_DECL 207 | #endif 208 | 209 | /* Maximum value for memLevel in deflateInit2 */ 210 | #ifndef MAX_MEM_LEVEL 211 | # ifdef MAXSEG_64K 212 | # define MAX_MEM_LEVEL 8 213 | # else 214 | # define MAX_MEM_LEVEL 9 215 | # endif 216 | #endif 217 | 218 | /* Maximum value for windowBits in deflateInit2 and inflateInit2. 219 | * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files 220 | * created by gzip. (Files created by minigzip can still be extracted by 221 | * gzip.) 222 | */ 223 | #ifndef MAX_WBITS 224 | # define MAX_WBITS 15 /* 32K LZ77 window */ 225 | #endif 226 | 227 | /* The memory requirements for deflate are (in bytes): 228 | (1 << (windowBits+2)) + (1 << (memLevel+9)) 229 | that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) 230 | plus a few kilobytes for small objects. For example, if you want to reduce 231 | the default memory requirements from 256K to 128K, compile with 232 | make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" 233 | Of course this will generally degrade compression (there's no free lunch). 234 | 235 | The memory requirements for inflate are (in bytes) 1 << windowBits 236 | that is, 32K for windowBits=15 (default value) plus a few kilobytes 237 | for small objects. 238 | */ 239 | 240 | /* Type declarations */ 241 | 242 | #ifndef OF /* function prototypes */ 243 | # ifdef STDC 244 | # define OF(args) args 245 | # else 246 | # define OF(args) () 247 | # endif 248 | #endif 249 | 250 | /* The following definitions for FAR are needed only for MSDOS mixed 251 | * model programming (small or medium model with some far allocations). 252 | * This was tested only with MSC; for other MSDOS compilers you may have 253 | * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, 254 | * just define FAR to be empty. 255 | */ 256 | #ifdef SYS16BIT 257 | # if defined(M_I86SM) || defined(M_I86MM) 258 | /* MSC small or medium model */ 259 | # define SMALL_MEDIUM 260 | # ifdef _MSC_VER 261 | # define FAR _far 262 | # else 263 | # define FAR far 264 | # endif 265 | # endif 266 | # if (defined(__SMALL__) || defined(__MEDIUM__)) 267 | /* Turbo C small or medium model */ 268 | # define SMALL_MEDIUM 269 | # ifdef __BORLANDC__ 270 | # define FAR _far 271 | # else 272 | # define FAR far 273 | # endif 274 | # endif 275 | #endif 276 | 277 | #if defined(WINDOWS) || defined(WIN32) 278 | /* If building or using zlib as a DLL, define ZLIB_DLL. 279 | * This is not mandatory, but it offers a little performance increase. 280 | */ 281 | # ifdef ZLIB_DLL 282 | # if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) 283 | # ifdef ZLIB_INTERNAL 284 | # define ZEXTERN extern __declspec(dllexport) 285 | # else 286 | # define ZEXTERN extern __declspec(dllimport) 287 | # endif 288 | # endif 289 | # endif /* ZLIB_DLL */ 290 | /* If building or using zlib with the WINAPI/WINAPIV calling convention, 291 | * define ZLIB_WINAPI. 292 | * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. 293 | */ 294 | # ifdef ZLIB_WINAPI 295 | # ifdef FAR 296 | # undef FAR 297 | # endif 298 | # include 299 | /* No need for _export, use ZLIB.DEF instead. */ 300 | /* For complete Windows compatibility, use WINAPI, not __stdcall. */ 301 | # define ZEXPORT WINAPI 302 | # ifdef WIN32 303 | # define ZEXPORTVA WINAPIV 304 | # else 305 | # define ZEXPORTVA FAR CDECL 306 | # endif 307 | # endif 308 | #endif 309 | 310 | #if defined (__BEOS__) 311 | # ifdef ZLIB_DLL 312 | # ifdef ZLIB_INTERNAL 313 | # define ZEXPORT __declspec(dllexport) 314 | # define ZEXPORTVA __declspec(dllexport) 315 | # else 316 | # define ZEXPORT __declspec(dllimport) 317 | # define ZEXPORTVA __declspec(dllimport) 318 | # endif 319 | # endif 320 | #endif 321 | 322 | #ifndef ZEXTERN 323 | # define ZEXTERN extern 324 | #endif 325 | #ifndef ZEXPORT 326 | # define ZEXPORT 327 | #endif 328 | #ifndef ZEXPORTVA 329 | # define ZEXPORTVA 330 | #endif 331 | 332 | #ifndef FAR 333 | # define FAR 334 | #endif 335 | 336 | #if !defined(__MACTYPES__) 337 | typedef unsigned char Byte; /* 8 bits */ 338 | #endif 339 | typedef unsigned int uInt; /* 16 bits or more */ 340 | typedef unsigned long uLong; /* 32 bits or more */ 341 | 342 | #ifdef SMALL_MEDIUM 343 | /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ 344 | # define Bytef Byte FAR 345 | #else 346 | typedef Byte FAR Bytef; 347 | #endif 348 | typedef char FAR charf; 349 | typedef int FAR intf; 350 | typedef uInt FAR uIntf; 351 | typedef uLong FAR uLongf; 352 | 353 | #ifdef STDC 354 | typedef void const *voidpc; 355 | typedef void FAR *voidpf; 356 | typedef void *voidp; 357 | #else 358 | typedef Byte const *voidpc; 359 | typedef Byte FAR *voidpf; 360 | typedef Byte *voidp; 361 | #endif 362 | 363 | #if defined(HAVE_UNISTD_H) || !defined(WIN32) 364 | # define Z_HAVE_UNISTD_H 365 | #endif 366 | 367 | #if defined(STDC) && !defined(_WIN32_WCE) 368 | # include /* for off_t */ 369 | #endif 370 | 371 | /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and 372 | * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even 373 | * though the former does not conform to the LFS document), but considering 374 | * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as 375 | * equivalently requesting no 64-bit operations 376 | */ 377 | #if -_LARGEFILE64_SOURCE - -1 == 1 378 | # undef _LARGEFILE64_SOURCE 379 | #endif 380 | 381 | #if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) 382 | # include /* for SEEK_* and off_t */ 383 | # ifdef VMS 384 | # include /* for off_t */ 385 | # endif 386 | # ifndef z_off_t 387 | # define z_off_t off_t 388 | # endif 389 | #endif 390 | 391 | #ifndef SEEK_SET 392 | # define SEEK_SET 0 /* Seek from beginning of file. */ 393 | # define SEEK_CUR 1 /* Seek from current position. */ 394 | # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ 395 | #endif 396 | 397 | #ifndef z_off_t 398 | # define z_off_t long 399 | #endif 400 | 401 | #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 402 | # define z_off64_t off64_t 403 | #else 404 | # define z_off64_t z_off_t 405 | #endif 406 | 407 | #if defined(__OS400__) 408 | # define NO_vsnprintf 409 | #endif 410 | 411 | #if defined(__MVS__) 412 | # define NO_vsnprintf 413 | #endif 414 | 415 | /* MVS linker does not support external names larger than 8 bytes */ 416 | #if defined(__MVS__) 417 | #pragma map(deflateInit_,"DEIN") 418 | #pragma map(deflateInit2_,"DEIN2") 419 | #pragma map(deflateEnd,"DEEND") 420 | #pragma map(deflateBound,"DEBND") 421 | #pragma map(inflateInit_,"ININ") 422 | #pragma map(inflateInit2_,"ININ2") 423 | #pragma map(inflateEnd,"INEND") 424 | #pragma map(inflateSync,"INSY") 425 | #pragma map(inflateSetDictionary,"INSEDI") 426 | #pragma map(compressBound,"CMBND") 427 | #pragma map(inflate_table,"INTABL") 428 | #pragma map(inflate_fast,"INFA") 429 | #pragma map(inflate_copyright,"INCOPY") 430 | #endif 431 | 432 | #endif /* ZCONF_H */ 433 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/zconf.h.cmakein: -------------------------------------------------------------------------------- 1 | /* zconf.h -- configuration of the zlib compression library 2 | * Copyright (C) 1995-2010 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #ifndef ZCONF_H 9 | #define ZCONF_H 10 | #cmakedefine Z_PREFIX 11 | #cmakedefine Z_HAVE_UNISTD_H 12 | 13 | /* 14 | * If you *really* need a unique prefix for all types and library functions, 15 | * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. 16 | * Even better than compiling with -DZ_PREFIX would be to use configure to set 17 | * this permanently in zconf.h using "./configure --zprefix". 18 | */ 19 | #ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ 20 | 21 | /* all linked symbols */ 22 | # define _dist_code z__dist_code 23 | # define _length_code z__length_code 24 | # define _tr_align z__tr_align 25 | # define _tr_flush_block z__tr_flush_block 26 | # define _tr_init z__tr_init 27 | # define _tr_stored_block z__tr_stored_block 28 | # define _tr_tally z__tr_tally 29 | # define adler32 z_adler32 30 | # define adler32_combine z_adler32_combine 31 | # define adler32_combine64 z_adler32_combine64 32 | # define compress z_compress 33 | # define compress2 z_compress2 34 | # define compressBound z_compressBound 35 | # define crc32 z_crc32 36 | # define crc32_combine z_crc32_combine 37 | # define crc32_combine64 z_crc32_combine64 38 | # define deflate z_deflate 39 | # define deflateBound z_deflateBound 40 | # define deflateCopy z_deflateCopy 41 | # define deflateEnd z_deflateEnd 42 | # define deflateInit2_ z_deflateInit2_ 43 | # define deflateInit_ z_deflateInit_ 44 | # define deflateParams z_deflateParams 45 | # define deflatePrime z_deflatePrime 46 | # define deflateReset z_deflateReset 47 | # define deflateSetDictionary z_deflateSetDictionary 48 | # define deflateSetHeader z_deflateSetHeader 49 | # define deflateTune z_deflateTune 50 | # define deflate_copyright z_deflate_copyright 51 | # define get_crc_table z_get_crc_table 52 | # define gz_error z_gz_error 53 | # define gz_intmax z_gz_intmax 54 | # define gz_strwinerror z_gz_strwinerror 55 | # define gzbuffer z_gzbuffer 56 | # define gzclearerr z_gzclearerr 57 | # define gzclose z_gzclose 58 | # define gzclose_r z_gzclose_r 59 | # define gzclose_w z_gzclose_w 60 | # define gzdirect z_gzdirect 61 | # define gzdopen z_gzdopen 62 | # define gzeof z_gzeof 63 | # define gzerror z_gzerror 64 | # define gzflush z_gzflush 65 | # define gzgetc z_gzgetc 66 | # define gzgets z_gzgets 67 | # define gzoffset z_gzoffset 68 | # define gzoffset64 z_gzoffset64 69 | # define gzopen z_gzopen 70 | # define gzopen64 z_gzopen64 71 | # define gzprintf z_gzprintf 72 | # define gzputc z_gzputc 73 | # define gzputs z_gzputs 74 | # define gzread z_gzread 75 | # define gzrewind z_gzrewind 76 | # define gzseek z_gzseek 77 | # define gzseek64 z_gzseek64 78 | # define gzsetparams z_gzsetparams 79 | # define gztell z_gztell 80 | # define gztell64 z_gztell64 81 | # define gzungetc z_gzungetc 82 | # define gzwrite z_gzwrite 83 | # define inflate z_inflate 84 | # define inflateBack z_inflateBack 85 | # define inflateBackEnd z_inflateBackEnd 86 | # define inflateBackInit_ z_inflateBackInit_ 87 | # define inflateCopy z_inflateCopy 88 | # define inflateEnd z_inflateEnd 89 | # define inflateGetHeader z_inflateGetHeader 90 | # define inflateInit2_ z_inflateInit2_ 91 | # define inflateInit_ z_inflateInit_ 92 | # define inflateMark z_inflateMark 93 | # define inflatePrime z_inflatePrime 94 | # define inflateReset z_inflateReset 95 | # define inflateReset2 z_inflateReset2 96 | # define inflateSetDictionary z_inflateSetDictionary 97 | # define inflateSync z_inflateSync 98 | # define inflateSyncPoint z_inflateSyncPoint 99 | # define inflateUndermine z_inflateUndermine 100 | # define inflate_copyright z_inflate_copyright 101 | # define inflate_fast z_inflate_fast 102 | # define inflate_table z_inflate_table 103 | # define uncompress z_uncompress 104 | # define zError z_zError 105 | # define zcalloc z_zcalloc 106 | # define zcfree z_zcfree 107 | # define zlibCompileFlags z_zlibCompileFlags 108 | # define zlibVersion z_zlibVersion 109 | 110 | /* all zlib typedefs in zlib.h and zconf.h */ 111 | # define Byte z_Byte 112 | # define Bytef z_Bytef 113 | # define alloc_func z_alloc_func 114 | # define charf z_charf 115 | # define free_func z_free_func 116 | # define gzFile z_gzFile 117 | # define gz_header z_gz_header 118 | # define gz_headerp z_gz_headerp 119 | # define in_func z_in_func 120 | # define intf z_intf 121 | # define out_func z_out_func 122 | # define uInt z_uInt 123 | # define uIntf z_uIntf 124 | # define uLong z_uLong 125 | # define uLongf z_uLongf 126 | # define voidp z_voidp 127 | # define voidpc z_voidpc 128 | # define voidpf z_voidpf 129 | 130 | /* all zlib structs in zlib.h and zconf.h */ 131 | # define gz_header_s z_gz_header_s 132 | # define internal_state z_internal_state 133 | 134 | #endif 135 | 136 | #if defined(__MSDOS__) && !defined(MSDOS) 137 | # define MSDOS 138 | #endif 139 | #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) 140 | # define OS2 141 | #endif 142 | #if defined(_WINDOWS) && !defined(WINDOWS) 143 | # define WINDOWS 144 | #endif 145 | #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) 146 | # ifndef WIN32 147 | # define WIN32 148 | # endif 149 | #endif 150 | #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) 151 | # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) 152 | # ifndef SYS16BIT 153 | # define SYS16BIT 154 | # endif 155 | # endif 156 | #endif 157 | 158 | /* 159 | * Compile with -DMAXSEG_64K if the alloc function cannot allocate more 160 | * than 64k bytes at a time (needed on systems with 16-bit int). 161 | */ 162 | #ifdef SYS16BIT 163 | # define MAXSEG_64K 164 | #endif 165 | #ifdef MSDOS 166 | # define UNALIGNED_OK 167 | #endif 168 | 169 | #ifdef __STDC_VERSION__ 170 | # ifndef STDC 171 | # define STDC 172 | # endif 173 | # if __STDC_VERSION__ >= 199901L 174 | # ifndef STDC99 175 | # define STDC99 176 | # endif 177 | # endif 178 | #endif 179 | #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) 180 | # define STDC 181 | #endif 182 | #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) 183 | # define STDC 184 | #endif 185 | #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) 186 | # define STDC 187 | #endif 188 | #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) 189 | # define STDC 190 | #endif 191 | 192 | #if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ 193 | # define STDC 194 | #endif 195 | 196 | #ifndef STDC 197 | # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ 198 | # define const /* note: need a more gentle solution here */ 199 | # endif 200 | #endif 201 | 202 | /* Some Mac compilers merge all .h files incorrectly: */ 203 | #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) 204 | # define NO_DUMMY_DECL 205 | #endif 206 | 207 | /* Maximum value for memLevel in deflateInit2 */ 208 | #ifndef MAX_MEM_LEVEL 209 | # ifdef MAXSEG_64K 210 | # define MAX_MEM_LEVEL 8 211 | # else 212 | # define MAX_MEM_LEVEL 9 213 | # endif 214 | #endif 215 | 216 | /* Maximum value for windowBits in deflateInit2 and inflateInit2. 217 | * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files 218 | * created by gzip. (Files created by minigzip can still be extracted by 219 | * gzip.) 220 | */ 221 | #ifndef MAX_WBITS 222 | # define MAX_WBITS 15 /* 32K LZ77 window */ 223 | #endif 224 | 225 | /* The memory requirements for deflate are (in bytes): 226 | (1 << (windowBits+2)) + (1 << (memLevel+9)) 227 | that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) 228 | plus a few kilobytes for small objects. For example, if you want to reduce 229 | the default memory requirements from 256K to 128K, compile with 230 | make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" 231 | Of course this will generally degrade compression (there's no free lunch). 232 | 233 | The memory requirements for inflate are (in bytes) 1 << windowBits 234 | that is, 32K for windowBits=15 (default value) plus a few kilobytes 235 | for small objects. 236 | */ 237 | 238 | /* Type declarations */ 239 | 240 | #ifndef OF /* function prototypes */ 241 | # ifdef STDC 242 | # define OF(args) args 243 | # else 244 | # define OF(args) () 245 | # endif 246 | #endif 247 | 248 | /* The following definitions for FAR are needed only for MSDOS mixed 249 | * model programming (small or medium model with some far allocations). 250 | * This was tested only with MSC; for other MSDOS compilers you may have 251 | * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, 252 | * just define FAR to be empty. 253 | */ 254 | #ifdef SYS16BIT 255 | # if defined(M_I86SM) || defined(M_I86MM) 256 | /* MSC small or medium model */ 257 | # define SMALL_MEDIUM 258 | # ifdef _MSC_VER 259 | # define FAR _far 260 | # else 261 | # define FAR far 262 | # endif 263 | # endif 264 | # if (defined(__SMALL__) || defined(__MEDIUM__)) 265 | /* Turbo C small or medium model */ 266 | # define SMALL_MEDIUM 267 | # ifdef __BORLANDC__ 268 | # define FAR _far 269 | # else 270 | # define FAR far 271 | # endif 272 | # endif 273 | #endif 274 | 275 | #if defined(WINDOWS) || defined(WIN32) 276 | /* If building or using zlib as a DLL, define ZLIB_DLL. 277 | * This is not mandatory, but it offers a little performance increase. 278 | */ 279 | # ifdef ZLIB_DLL 280 | # if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) 281 | # ifdef ZLIB_INTERNAL 282 | # define ZEXTERN extern __declspec(dllexport) 283 | # else 284 | # define ZEXTERN extern __declspec(dllimport) 285 | # endif 286 | # endif 287 | # endif /* ZLIB_DLL */ 288 | /* If building or using zlib with the WINAPI/WINAPIV calling convention, 289 | * define ZLIB_WINAPI. 290 | * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. 291 | */ 292 | # ifdef ZLIB_WINAPI 293 | # ifdef FAR 294 | # undef FAR 295 | # endif 296 | # include 297 | /* No need for _export, use ZLIB.DEF instead. */ 298 | /* For complete Windows compatibility, use WINAPI, not __stdcall. */ 299 | # define ZEXPORT WINAPI 300 | # ifdef WIN32 301 | # define ZEXPORTVA WINAPIV 302 | # else 303 | # define ZEXPORTVA FAR CDECL 304 | # endif 305 | # endif 306 | #endif 307 | 308 | #if defined (__BEOS__) 309 | # ifdef ZLIB_DLL 310 | # ifdef ZLIB_INTERNAL 311 | # define ZEXPORT __declspec(dllexport) 312 | # define ZEXPORTVA __declspec(dllexport) 313 | # else 314 | # define ZEXPORT __declspec(dllimport) 315 | # define ZEXPORTVA __declspec(dllimport) 316 | # endif 317 | # endif 318 | #endif 319 | 320 | #ifndef ZEXTERN 321 | # define ZEXTERN extern 322 | #endif 323 | #ifndef ZEXPORT 324 | # define ZEXPORT 325 | #endif 326 | #ifndef ZEXPORTVA 327 | # define ZEXPORTVA 328 | #endif 329 | 330 | #ifndef FAR 331 | # define FAR 332 | #endif 333 | 334 | #if !defined(__MACTYPES__) 335 | typedef unsigned char Byte; /* 8 bits */ 336 | #endif 337 | typedef unsigned int uInt; /* 16 bits or more */ 338 | typedef unsigned long uLong; /* 32 bits or more */ 339 | 340 | #ifdef SMALL_MEDIUM 341 | /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ 342 | # define Bytef Byte FAR 343 | #else 344 | typedef Byte FAR Bytef; 345 | #endif 346 | typedef char FAR charf; 347 | typedef int FAR intf; 348 | typedef uInt FAR uIntf; 349 | typedef uLong FAR uLongf; 350 | 351 | #ifdef STDC 352 | typedef void const *voidpc; 353 | typedef void FAR *voidpf; 354 | typedef void *voidp; 355 | #else 356 | typedef Byte const *voidpc; 357 | typedef Byte FAR *voidpf; 358 | typedef Byte *voidp; 359 | #endif 360 | 361 | #ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ 362 | # define Z_HAVE_UNISTD_H 363 | #endif 364 | 365 | #ifdef STDC 366 | # include /* for off_t */ 367 | #endif 368 | 369 | /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and 370 | * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even 371 | * though the former does not conform to the LFS document), but considering 372 | * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as 373 | * equivalently requesting no 64-bit operations 374 | */ 375 | #if -_LARGEFILE64_SOURCE - -1 == 1 376 | # undef _LARGEFILE64_SOURCE 377 | #endif 378 | 379 | #if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) 380 | # include /* for SEEK_* and off_t */ 381 | # ifdef VMS 382 | # include /* for off_t */ 383 | # endif 384 | # ifndef z_off_t 385 | # define z_off_t off_t 386 | # endif 387 | #endif 388 | 389 | #ifndef SEEK_SET 390 | # define SEEK_SET 0 /* Seek from beginning of file. */ 391 | # define SEEK_CUR 1 /* Seek from current position. */ 392 | # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ 393 | #endif 394 | 395 | #ifndef z_off_t 396 | # define z_off_t long 397 | #endif 398 | 399 | #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 400 | # define z_off64_t off64_t 401 | #else 402 | # define z_off64_t z_off_t 403 | #endif 404 | 405 | #if defined(__OS400__) 406 | # define NO_vsnprintf 407 | #endif 408 | 409 | #if defined(__MVS__) 410 | # define NO_vsnprintf 411 | #endif 412 | 413 | /* MVS linker does not support external names larger than 8 bytes */ 414 | #if defined(__MVS__) 415 | #pragma map(deflateInit_,"DEIN") 416 | #pragma map(deflateInit2_,"DEIN2") 417 | #pragma map(deflateEnd,"DEEND") 418 | #pragma map(deflateBound,"DEBND") 419 | #pragma map(inflateInit_,"ININ") 420 | #pragma map(inflateInit2_,"ININ2") 421 | #pragma map(inflateEnd,"INEND") 422 | #pragma map(inflateSync,"INSY") 423 | #pragma map(inflateSetDictionary,"INSEDI") 424 | #pragma map(compressBound,"CMBND") 425 | #pragma map(inflate_table,"INTABL") 426 | #pragma map(inflate_fast,"INFA") 427 | #pragma map(inflate_copyright,"INCOPY") 428 | #endif 429 | 430 | #endif /* ZCONF_H */ 431 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/zconf.h.in: -------------------------------------------------------------------------------- 1 | /* zconf.h -- configuration of the zlib compression library 2 | * Copyright (C) 1995-2010 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #ifndef ZCONF_H 9 | #define ZCONF_H 10 | 11 | /* 12 | * If you *really* need a unique prefix for all types and library functions, 13 | * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. 14 | * Even better than compiling with -DZ_PREFIX would be to use configure to set 15 | * this permanently in zconf.h using "./configure --zprefix". 16 | */ 17 | #ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ 18 | 19 | /* all linked symbols */ 20 | # define _dist_code z__dist_code 21 | # define _length_code z__length_code 22 | # define _tr_align z__tr_align 23 | # define _tr_flush_block z__tr_flush_block 24 | # define _tr_init z__tr_init 25 | # define _tr_stored_block z__tr_stored_block 26 | # define _tr_tally z__tr_tally 27 | # define adler32 z_adler32 28 | # define adler32_combine z_adler32_combine 29 | # define adler32_combine64 z_adler32_combine64 30 | # define compress z_compress 31 | # define compress2 z_compress2 32 | # define compressBound z_compressBound 33 | # define crc32 z_crc32 34 | # define crc32_combine z_crc32_combine 35 | # define crc32_combine64 z_crc32_combine64 36 | # define deflate z_deflate 37 | # define deflateBound z_deflateBound 38 | # define deflateCopy z_deflateCopy 39 | # define deflateEnd z_deflateEnd 40 | # define deflateInit2_ z_deflateInit2_ 41 | # define deflateInit_ z_deflateInit_ 42 | # define deflateParams z_deflateParams 43 | # define deflatePrime z_deflatePrime 44 | # define deflateReset z_deflateReset 45 | # define deflateSetDictionary z_deflateSetDictionary 46 | # define deflateSetHeader z_deflateSetHeader 47 | # define deflateTune z_deflateTune 48 | # define deflate_copyright z_deflate_copyright 49 | # define get_crc_table z_get_crc_table 50 | # define gz_error z_gz_error 51 | # define gz_intmax z_gz_intmax 52 | # define gz_strwinerror z_gz_strwinerror 53 | # define gzbuffer z_gzbuffer 54 | # define gzclearerr z_gzclearerr 55 | # define gzclose z_gzclose 56 | # define gzclose_r z_gzclose_r 57 | # define gzclose_w z_gzclose_w 58 | # define gzdirect z_gzdirect 59 | # define gzdopen z_gzdopen 60 | # define gzeof z_gzeof 61 | # define gzerror z_gzerror 62 | # define gzflush z_gzflush 63 | # define gzgetc z_gzgetc 64 | # define gzgets z_gzgets 65 | # define gzoffset z_gzoffset 66 | # define gzoffset64 z_gzoffset64 67 | # define gzopen z_gzopen 68 | # define gzopen64 z_gzopen64 69 | # define gzprintf z_gzprintf 70 | # define gzputc z_gzputc 71 | # define gzputs z_gzputs 72 | # define gzread z_gzread 73 | # define gzrewind z_gzrewind 74 | # define gzseek z_gzseek 75 | # define gzseek64 z_gzseek64 76 | # define gzsetparams z_gzsetparams 77 | # define gztell z_gztell 78 | # define gztell64 z_gztell64 79 | # define gzungetc z_gzungetc 80 | # define gzwrite z_gzwrite 81 | # define inflate z_inflate 82 | # define inflateBack z_inflateBack 83 | # define inflateBackEnd z_inflateBackEnd 84 | # define inflateBackInit_ z_inflateBackInit_ 85 | # define inflateCopy z_inflateCopy 86 | # define inflateEnd z_inflateEnd 87 | # define inflateGetHeader z_inflateGetHeader 88 | # define inflateInit2_ z_inflateInit2_ 89 | # define inflateInit_ z_inflateInit_ 90 | # define inflateMark z_inflateMark 91 | # define inflatePrime z_inflatePrime 92 | # define inflateReset z_inflateReset 93 | # define inflateReset2 z_inflateReset2 94 | # define inflateSetDictionary z_inflateSetDictionary 95 | # define inflateSync z_inflateSync 96 | # define inflateSyncPoint z_inflateSyncPoint 97 | # define inflateUndermine z_inflateUndermine 98 | # define inflate_copyright z_inflate_copyright 99 | # define inflate_fast z_inflate_fast 100 | # define inflate_table z_inflate_table 101 | # define uncompress z_uncompress 102 | # define zError z_zError 103 | # define zcalloc z_zcalloc 104 | # define zcfree z_zcfree 105 | # define zlibCompileFlags z_zlibCompileFlags 106 | # define zlibVersion z_zlibVersion 107 | 108 | /* all zlib typedefs in zlib.h and zconf.h */ 109 | # define Byte z_Byte 110 | # define Bytef z_Bytef 111 | # define alloc_func z_alloc_func 112 | # define charf z_charf 113 | # define free_func z_free_func 114 | # define gzFile z_gzFile 115 | # define gz_header z_gz_header 116 | # define gz_headerp z_gz_headerp 117 | # define in_func z_in_func 118 | # define intf z_intf 119 | # define out_func z_out_func 120 | # define uInt z_uInt 121 | # define uIntf z_uIntf 122 | # define uLong z_uLong 123 | # define uLongf z_uLongf 124 | # define voidp z_voidp 125 | # define voidpc z_voidpc 126 | # define voidpf z_voidpf 127 | 128 | /* all zlib structs in zlib.h and zconf.h */ 129 | # define gz_header_s z_gz_header_s 130 | # define internal_state z_internal_state 131 | 132 | #endif 133 | 134 | #if defined(__MSDOS__) && !defined(MSDOS) 135 | # define MSDOS 136 | #endif 137 | #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) 138 | # define OS2 139 | #endif 140 | #if defined(_WINDOWS) && !defined(WINDOWS) 141 | # define WINDOWS 142 | #endif 143 | #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) 144 | # ifndef WIN32 145 | # define WIN32 146 | # endif 147 | #endif 148 | #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) 149 | # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) 150 | # ifndef SYS16BIT 151 | # define SYS16BIT 152 | # endif 153 | # endif 154 | #endif 155 | 156 | /* 157 | * Compile with -DMAXSEG_64K if the alloc function cannot allocate more 158 | * than 64k bytes at a time (needed on systems with 16-bit int). 159 | */ 160 | #ifdef SYS16BIT 161 | # define MAXSEG_64K 162 | #endif 163 | #ifdef MSDOS 164 | # define UNALIGNED_OK 165 | #endif 166 | 167 | #ifdef __STDC_VERSION__ 168 | # ifndef STDC 169 | # define STDC 170 | # endif 171 | # if __STDC_VERSION__ >= 199901L 172 | # ifndef STDC99 173 | # define STDC99 174 | # endif 175 | # endif 176 | #endif 177 | #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) 178 | # define STDC 179 | #endif 180 | #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) 181 | # define STDC 182 | #endif 183 | #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) 184 | # define STDC 185 | #endif 186 | #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) 187 | # define STDC 188 | #endif 189 | 190 | #if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ 191 | # define STDC 192 | #endif 193 | 194 | #ifndef STDC 195 | # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ 196 | # define const /* note: need a more gentle solution here */ 197 | # endif 198 | #endif 199 | 200 | /* Some Mac compilers merge all .h files incorrectly: */ 201 | #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) 202 | # define NO_DUMMY_DECL 203 | #endif 204 | 205 | /* Maximum value for memLevel in deflateInit2 */ 206 | #ifndef MAX_MEM_LEVEL 207 | # ifdef MAXSEG_64K 208 | # define MAX_MEM_LEVEL 8 209 | # else 210 | # define MAX_MEM_LEVEL 9 211 | # endif 212 | #endif 213 | 214 | /* Maximum value for windowBits in deflateInit2 and inflateInit2. 215 | * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files 216 | * created by gzip. (Files created by minigzip can still be extracted by 217 | * gzip.) 218 | */ 219 | #ifndef MAX_WBITS 220 | # define MAX_WBITS 15 /* 32K LZ77 window */ 221 | #endif 222 | 223 | /* The memory requirements for deflate are (in bytes): 224 | (1 << (windowBits+2)) + (1 << (memLevel+9)) 225 | that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) 226 | plus a few kilobytes for small objects. For example, if you want to reduce 227 | the default memory requirements from 256K to 128K, compile with 228 | make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" 229 | Of course this will generally degrade compression (there's no free lunch). 230 | 231 | The memory requirements for inflate are (in bytes) 1 << windowBits 232 | that is, 32K for windowBits=15 (default value) plus a few kilobytes 233 | for small objects. 234 | */ 235 | 236 | /* Type declarations */ 237 | 238 | #ifndef OF /* function prototypes */ 239 | # ifdef STDC 240 | # define OF(args) args 241 | # else 242 | # define OF(args) () 243 | # endif 244 | #endif 245 | 246 | /* The following definitions for FAR are needed only for MSDOS mixed 247 | * model programming (small or medium model with some far allocations). 248 | * This was tested only with MSC; for other MSDOS compilers you may have 249 | * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, 250 | * just define FAR to be empty. 251 | */ 252 | #ifdef SYS16BIT 253 | # if defined(M_I86SM) || defined(M_I86MM) 254 | /* MSC small or medium model */ 255 | # define SMALL_MEDIUM 256 | # ifdef _MSC_VER 257 | # define FAR _far 258 | # else 259 | # define FAR far 260 | # endif 261 | # endif 262 | # if (defined(__SMALL__) || defined(__MEDIUM__)) 263 | /* Turbo C small or medium model */ 264 | # define SMALL_MEDIUM 265 | # ifdef __BORLANDC__ 266 | # define FAR _far 267 | # else 268 | # define FAR far 269 | # endif 270 | # endif 271 | #endif 272 | 273 | #if defined(WINDOWS) || defined(WIN32) 274 | /* If building or using zlib as a DLL, define ZLIB_DLL. 275 | * This is not mandatory, but it offers a little performance increase. 276 | */ 277 | # ifdef ZLIB_DLL 278 | # if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) 279 | # ifdef ZLIB_INTERNAL 280 | # define ZEXTERN extern __declspec(dllexport) 281 | # else 282 | # define ZEXTERN extern __declspec(dllimport) 283 | # endif 284 | # endif 285 | # endif /* ZLIB_DLL */ 286 | /* If building or using zlib with the WINAPI/WINAPIV calling convention, 287 | * define ZLIB_WINAPI. 288 | * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. 289 | */ 290 | # ifdef ZLIB_WINAPI 291 | # ifdef FAR 292 | # undef FAR 293 | # endif 294 | # include 295 | /* No need for _export, use ZLIB.DEF instead. */ 296 | /* For complete Windows compatibility, use WINAPI, not __stdcall. */ 297 | # define ZEXPORT WINAPI 298 | # ifdef WIN32 299 | # define ZEXPORTVA WINAPIV 300 | # else 301 | # define ZEXPORTVA FAR CDECL 302 | # endif 303 | # endif 304 | #endif 305 | 306 | #if defined (__BEOS__) 307 | # ifdef ZLIB_DLL 308 | # ifdef ZLIB_INTERNAL 309 | # define ZEXPORT __declspec(dllexport) 310 | # define ZEXPORTVA __declspec(dllexport) 311 | # else 312 | # define ZEXPORT __declspec(dllimport) 313 | # define ZEXPORTVA __declspec(dllimport) 314 | # endif 315 | # endif 316 | #endif 317 | 318 | #ifndef ZEXTERN 319 | # define ZEXTERN extern 320 | #endif 321 | #ifndef ZEXPORT 322 | # define ZEXPORT 323 | #endif 324 | #ifndef ZEXPORTVA 325 | # define ZEXPORTVA 326 | #endif 327 | 328 | #ifndef FAR 329 | # define FAR 330 | #endif 331 | 332 | #if !defined(__MACTYPES__) 333 | typedef unsigned char Byte; /* 8 bits */ 334 | #endif 335 | typedef unsigned int uInt; /* 16 bits or more */ 336 | typedef unsigned long uLong; /* 32 bits or more */ 337 | 338 | #ifdef SMALL_MEDIUM 339 | /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ 340 | # define Bytef Byte FAR 341 | #else 342 | typedef Byte FAR Bytef; 343 | #endif 344 | typedef char FAR charf; 345 | typedef int FAR intf; 346 | typedef uInt FAR uIntf; 347 | typedef uLong FAR uLongf; 348 | 349 | #ifdef STDC 350 | typedef void const *voidpc; 351 | typedef void FAR *voidpf; 352 | typedef void *voidp; 353 | #else 354 | typedef Byte const *voidpc; 355 | typedef Byte FAR *voidpf; 356 | typedef Byte *voidp; 357 | #endif 358 | 359 | #ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ 360 | # define Z_HAVE_UNISTD_H 361 | #endif 362 | 363 | #ifdef STDC 364 | # include /* for off_t */ 365 | #endif 366 | 367 | /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and 368 | * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even 369 | * though the former does not conform to the LFS document), but considering 370 | * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as 371 | * equivalently requesting no 64-bit operations 372 | */ 373 | #if -_LARGEFILE64_SOURCE - -1 == 1 374 | # undef _LARGEFILE64_SOURCE 375 | #endif 376 | 377 | #if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) 378 | # include /* for SEEK_* and off_t */ 379 | # ifdef VMS 380 | # include /* for off_t */ 381 | # endif 382 | # ifndef z_off_t 383 | # define z_off_t off_t 384 | # endif 385 | #endif 386 | 387 | #ifndef SEEK_SET 388 | # define SEEK_SET 0 /* Seek from beginning of file. */ 389 | # define SEEK_CUR 1 /* Seek from current position. */ 390 | # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ 391 | #endif 392 | 393 | #ifndef z_off_t 394 | # define z_off_t long 395 | #endif 396 | 397 | #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 398 | # define z_off64_t off64_t 399 | #else 400 | # define z_off64_t z_off_t 401 | #endif 402 | 403 | #if defined(__OS400__) 404 | # define NO_vsnprintf 405 | #endif 406 | 407 | #if defined(__MVS__) 408 | # define NO_vsnprintf 409 | #endif 410 | 411 | /* MVS linker does not support external names larger than 8 bytes */ 412 | #if defined(__MVS__) 413 | #pragma map(deflateInit_,"DEIN") 414 | #pragma map(deflateInit2_,"DEIN2") 415 | #pragma map(deflateEnd,"DEEND") 416 | #pragma map(deflateBound,"DEBND") 417 | #pragma map(inflateInit_,"ININ") 418 | #pragma map(inflateInit2_,"ININ2") 419 | #pragma map(inflateEnd,"INEND") 420 | #pragma map(inflateSync,"INSY") 421 | #pragma map(inflateSetDictionary,"INSEDI") 422 | #pragma map(compressBound,"CMBND") 423 | #pragma map(inflate_table,"INTABL") 424 | #pragma map(inflate_fast,"INFA") 425 | #pragma map(inflate_copyright,"INCOPY") 426 | #endif 427 | 428 | #endif /* ZCONF_H */ 429 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/zlib.3: -------------------------------------------------------------------------------- 1 | .TH ZLIB 3 "19 Apr 2010" 2 | .SH NAME 3 | zlib \- compression/decompression library 4 | .SH SYNOPSIS 5 | [see 6 | .I zlib.h 7 | for full description] 8 | .SH DESCRIPTION 9 | The 10 | .I zlib 11 | library is a general purpose data compression library. 12 | The code is thread safe, assuming that the standard library functions 13 | used are thread safe, such as memory allocation routines. 14 | It provides in-memory compression and decompression functions, 15 | including integrity checks of the uncompressed data. 16 | This version of the library supports only one compression method (deflation) 17 | but other algorithms may be added later 18 | with the same stream interface. 19 | .LP 20 | Compression can be done in a single step if the buffers are large enough 21 | or can be done by repeated calls of the compression function. 22 | In the latter case, 23 | the application must provide more input and/or consume the output 24 | (providing more output space) before each call. 25 | .LP 26 | The library also supports reading and writing files in 27 | .IR gzip (1) 28 | (.gz) format 29 | with an interface similar to that of stdio. 30 | .LP 31 | The library does not install any signal handler. 32 | The decoder checks the consistency of the compressed data, 33 | so the library should never crash even in the case of corrupted input. 34 | .LP 35 | All functions of the compression library are documented in the file 36 | .IR zlib.h . 37 | The distribution source includes examples of use of the library 38 | in the files 39 | .I example.c 40 | and 41 | .IR minigzip.c, 42 | as well as other examples in the 43 | .IR examples/ 44 | directory. 45 | .LP 46 | Changes to this version are documented in the file 47 | .I ChangeLog 48 | that accompanies the source. 49 | .LP 50 | .I zlib 51 | is available in Java using the java.util.zip package: 52 | .IP 53 | http://java.sun.com/developer/technicalArticles/Programming/compression/ 54 | .LP 55 | A Perl interface to 56 | .IR zlib , 57 | written by Paul Marquess (pmqs@cpan.org), 58 | is available at CPAN (Comprehensive Perl Archive Network) sites, 59 | including: 60 | .IP 61 | http://search.cpan.org/~pmqs/IO-Compress-Zlib/ 62 | .LP 63 | A Python interface to 64 | .IR zlib , 65 | written by A.M. Kuchling (amk@magnet.com), 66 | is available in Python 1.5 and later versions: 67 | .IP 68 | http://www.python.org/doc/lib/module-zlib.html 69 | .LP 70 | .I zlib 71 | is built into 72 | .IR tcl: 73 | .IP 74 | http://wiki.tcl.tk/4610 75 | .LP 76 | An experimental package to read and write files in .zip format, 77 | written on top of 78 | .I zlib 79 | by Gilles Vollant (info@winimage.com), 80 | is available at: 81 | .IP 82 | http://www.winimage.com/zLibDll/minizip.html 83 | and also in the 84 | .I contrib/minizip 85 | directory of the main 86 | .I zlib 87 | source distribution. 88 | .SH "SEE ALSO" 89 | The 90 | .I zlib 91 | web site can be found at: 92 | .IP 93 | http://zlib.net/ 94 | .LP 95 | The data format used by the zlib library is described by RFC 96 | (Request for Comments) 1950 to 1952 in the files: 97 | .IP 98 | http://www.ietf.org/rfc/rfc1950.txt (for the zlib header and trailer format) 99 | .br 100 | http://www.ietf.org/rfc/rfc1951.txt (for the deflate compressed data format) 101 | .br 102 | http://www.ietf.org/rfc/rfc1952.txt (for the gzip header and trailer format) 103 | .LP 104 | Mark Nelson wrote an article about 105 | .I zlib 106 | for the Jan. 1997 issue of Dr. Dobb's Journal; 107 | a copy of the article is available at: 108 | .IP 109 | http://marknelson.us/1997/01/01/zlib-engine/ 110 | .SH "REPORTING PROBLEMS" 111 | Before reporting a problem, 112 | please check the 113 | .I zlib 114 | web site to verify that you have the latest version of 115 | .IR zlib ; 116 | otherwise, 117 | obtain the latest version and see if the problem still exists. 118 | Please read the 119 | .I zlib 120 | FAQ at: 121 | .IP 122 | http://zlib.net/zlib_faq.html 123 | .LP 124 | before asking for help. 125 | Send questions and/or comments to zlib@gzip.org, 126 | or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). 127 | .SH AUTHORS 128 | Version 1.2.5 129 | Copyright (C) 1995-2010 Jean-loup Gailly (jloup@gzip.org) 130 | and Mark Adler (madler@alumni.caltech.edu). 131 | .LP 132 | This software is provided "as-is," 133 | without any express or implied warranty. 134 | In no event will the authors be held liable for any damages 135 | arising from the use of this software. 136 | See the distribution directory with respect to requirements 137 | governing redistribution. 138 | The deflate format used by 139 | .I zlib 140 | was defined by Phil Katz. 141 | The deflate and 142 | .I zlib 143 | specifications were written by L. Peter Deutsch. 144 | Thanks to all the people who reported problems and suggested various 145 | improvements in 146 | .IR zlib ; 147 | who are too numerous to cite here. 148 | .LP 149 | UNIX manual page by R. P. C. Rodgers, 150 | U.S. National Library of Medicine (rodgers@nlm.nih.gov). 151 | .\" end of man page 152 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/zlib.3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nezticle/qtcompress/23f8831826cd72aedf99fc3699148b6c994fd677/src/3rdparty/zlib/zlib.3.pdf -------------------------------------------------------------------------------- /src/3rdparty/zlib/zlib.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | sharedlibdir=@sharedlibdir@ 5 | includedir=@includedir@ 6 | 7 | Name: zlib 8 | Description: zlib compression library 9 | Version: @VERSION@ 10 | 11 | Requires: 12 | Libs: -L${libdir} -L${sharedlibdir} -lz 13 | Cflags: -I${includedir} 14 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/zutil.c: -------------------------------------------------------------------------------- 1 | /* zutil.c -- target dependent utility functions for the compression library 2 | * Copyright (C) 1995-2005, 2010 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #include "zutil.h" 9 | 10 | #ifndef NO_DUMMY_DECL 11 | struct internal_state {int dummy;}; /* for buggy compilers */ 12 | #endif 13 | 14 | const char * const z_errmsg[10] = { 15 | "need dictionary", /* Z_NEED_DICT 2 */ 16 | "stream end", /* Z_STREAM_END 1 */ 17 | "", /* Z_OK 0 */ 18 | "file error", /* Z_ERRNO (-1) */ 19 | "stream error", /* Z_STREAM_ERROR (-2) */ 20 | "data error", /* Z_DATA_ERROR (-3) */ 21 | "insufficient memory", /* Z_MEM_ERROR (-4) */ 22 | "buffer error", /* Z_BUF_ERROR (-5) */ 23 | "incompatible version",/* Z_VERSION_ERROR (-6) */ 24 | ""}; 25 | 26 | 27 | const char * ZEXPORT zlibVersion() 28 | { 29 | return ZLIB_VERSION; 30 | } 31 | 32 | uLong ZEXPORT zlibCompileFlags() 33 | { 34 | uLong flags; 35 | 36 | flags = 0; 37 | switch ((int)(sizeof(uInt))) { 38 | case 2: break; 39 | case 4: flags += 1; break; 40 | case 8: flags += 2; break; 41 | default: flags += 3; 42 | } 43 | switch ((int)(sizeof(uLong))) { 44 | case 2: break; 45 | case 4: flags += 1 << 2; break; 46 | case 8: flags += 2 << 2; break; 47 | default: flags += 3 << 2; 48 | } 49 | switch ((int)(sizeof(voidpf))) { 50 | case 2: break; 51 | case 4: flags += 1 << 4; break; 52 | case 8: flags += 2 << 4; break; 53 | default: flags += 3 << 4; 54 | } 55 | switch ((int)(sizeof(z_off_t))) { 56 | case 2: break; 57 | case 4: flags += 1 << 6; break; 58 | case 8: flags += 2 << 6; break; 59 | default: flags += 3 << 6; 60 | } 61 | #ifdef DEBUG 62 | flags += 1 << 8; 63 | #endif 64 | #if defined(ASMV) || defined(ASMINF) 65 | flags += 1 << 9; 66 | #endif 67 | #ifdef ZLIB_WINAPI 68 | flags += 1 << 10; 69 | #endif 70 | #ifdef BUILDFIXED 71 | flags += 1 << 12; 72 | #endif 73 | #ifdef DYNAMIC_CRC_TABLE 74 | flags += 1 << 13; 75 | #endif 76 | #ifdef NO_GZCOMPRESS 77 | flags += 1L << 16; 78 | #endif 79 | #ifdef NO_GZIP 80 | flags += 1L << 17; 81 | #endif 82 | #ifdef PKZIP_BUG_WORKAROUND 83 | flags += 1L << 20; 84 | #endif 85 | #ifdef FASTEST 86 | flags += 1L << 21; 87 | #endif 88 | #ifdef STDC 89 | # ifdef NO_vsnprintf 90 | flags += 1L << 25; 91 | # ifdef HAS_vsprintf_void 92 | flags += 1L << 26; 93 | # endif 94 | # else 95 | # ifdef HAS_vsnprintf_void 96 | flags += 1L << 26; 97 | # endif 98 | # endif 99 | #else 100 | flags += 1L << 24; 101 | # ifdef NO_snprintf 102 | flags += 1L << 25; 103 | # ifdef HAS_sprintf_void 104 | flags += 1L << 26; 105 | # endif 106 | # else 107 | # ifdef HAS_snprintf_void 108 | flags += 1L << 26; 109 | # endif 110 | # endif 111 | #endif 112 | return flags; 113 | } 114 | 115 | #ifdef DEBUG 116 | 117 | # ifndef verbose 118 | # define verbose 0 119 | # endif 120 | int ZLIB_INTERNAL z_verbose = verbose; 121 | 122 | void ZLIB_INTERNAL z_error (m) 123 | char *m; 124 | { 125 | fprintf(stderr, "%s\n", m); 126 | exit(1); 127 | } 128 | #endif 129 | 130 | /* exported to allow conversion of error code to string for compress() and 131 | * uncompress() 132 | */ 133 | const char * ZEXPORT zError(err) 134 | int err; 135 | { 136 | return ERR_MSG(err); 137 | } 138 | 139 | #ifndef HAVE_MEMCPY 140 | 141 | void ZLIB_INTERNAL zmemcpy(dest, source, len) 142 | Bytef* dest; 143 | const Bytef* source; 144 | uInt len; 145 | { 146 | if (len == 0) return; 147 | do { 148 | *dest++ = *source++; /* ??? to be unrolled */ 149 | } while (--len != 0); 150 | } 151 | 152 | int ZLIB_INTERNAL zmemcmp(s1, s2, len) 153 | const Bytef* s1; 154 | const Bytef* s2; 155 | uInt len; 156 | { 157 | uInt j; 158 | 159 | for (j = 0; j < len; j++) { 160 | if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; 161 | } 162 | return 0; 163 | } 164 | 165 | void ZLIB_INTERNAL zmemzero(dest, len) 166 | Bytef* dest; 167 | uInt len; 168 | { 169 | if (len == 0) return; 170 | do { 171 | *dest++ = 0; /* ??? to be unrolled */ 172 | } while (--len != 0); 173 | } 174 | #endif 175 | 176 | 177 | #ifdef SYS16BIT 178 | 179 | #ifdef __TURBOC__ 180 | /* Turbo C in 16-bit mode */ 181 | 182 | # define MY_ZCALLOC 183 | 184 | /* Turbo C malloc() does not allow dynamic allocation of 64K bytes 185 | * and farmalloc(64K) returns a pointer with an offset of 8, so we 186 | * must fix the pointer. Warning: the pointer must be put back to its 187 | * original form in order to free it, use zcfree(). 188 | */ 189 | 190 | #define MAX_PTR 10 191 | /* 10*64K = 640K */ 192 | 193 | local int next_ptr = 0; 194 | 195 | typedef struct ptr_table_s { 196 | voidpf org_ptr; 197 | voidpf new_ptr; 198 | } ptr_table; 199 | 200 | local ptr_table table[MAX_PTR]; 201 | /* This table is used to remember the original form of pointers 202 | * to large buffers (64K). Such pointers are normalized with a zero offset. 203 | * Since MSDOS is not a preemptive multitasking OS, this table is not 204 | * protected from concurrent access. This hack doesn't work anyway on 205 | * a protected system like OS/2. Use Microsoft C instead. 206 | */ 207 | 208 | voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) 209 | { 210 | voidpf buf = opaque; /* just to make some compilers happy */ 211 | ulg bsize = (ulg)items*size; 212 | 213 | /* If we allocate less than 65520 bytes, we assume that farmalloc 214 | * will return a usable pointer which doesn't have to be normalized. 215 | */ 216 | if (bsize < 65520L) { 217 | buf = farmalloc(bsize); 218 | if (*(ush*)&buf != 0) return buf; 219 | } else { 220 | buf = farmalloc(bsize + 16L); 221 | } 222 | if (buf == NULL || next_ptr >= MAX_PTR) return NULL; 223 | table[next_ptr].org_ptr = buf; 224 | 225 | /* Normalize the pointer to seg:0 */ 226 | *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; 227 | *(ush*)&buf = 0; 228 | table[next_ptr++].new_ptr = buf; 229 | return buf; 230 | } 231 | 232 | void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) 233 | { 234 | int n; 235 | if (*(ush*)&ptr != 0) { /* object < 64K */ 236 | farfree(ptr); 237 | return; 238 | } 239 | /* Find the original pointer */ 240 | for (n = 0; n < next_ptr; n++) { 241 | if (ptr != table[n].new_ptr) continue; 242 | 243 | farfree(table[n].org_ptr); 244 | while (++n < next_ptr) { 245 | table[n-1] = table[n]; 246 | } 247 | next_ptr--; 248 | return; 249 | } 250 | ptr = opaque; /* just to make some compilers happy */ 251 | Assert(0, "zcfree: ptr not found"); 252 | } 253 | 254 | #endif /* __TURBOC__ */ 255 | 256 | 257 | #ifdef M_I86 258 | /* Microsoft C in 16-bit mode */ 259 | 260 | # define MY_ZCALLOC 261 | 262 | #if (!defined(_MSC_VER) || (_MSC_VER <= 600)) 263 | # define _halloc halloc 264 | # define _hfree hfree 265 | #endif 266 | 267 | voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size) 268 | { 269 | if (opaque) opaque = 0; /* to make compiler happy */ 270 | return _halloc((long)items, size); 271 | } 272 | 273 | void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) 274 | { 275 | if (opaque) opaque = 0; /* to make compiler happy */ 276 | _hfree(ptr); 277 | } 278 | 279 | #endif /* M_I86 */ 280 | 281 | #endif /* SYS16BIT */ 282 | 283 | 284 | #ifndef MY_ZCALLOC /* Any system without a special alloc function */ 285 | 286 | #ifndef STDC 287 | extern voidp malloc OF((uInt size)); 288 | extern voidp calloc OF((uInt items, uInt size)); 289 | extern void free OF((voidpf ptr)); 290 | #endif 291 | 292 | voidpf ZLIB_INTERNAL zcalloc (opaque, items, size) 293 | voidpf opaque; 294 | unsigned items; 295 | unsigned size; 296 | { 297 | if (opaque) items += size - size; /* make compiler happy */ 298 | return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : 299 | (voidpf)calloc(items, size); 300 | } 301 | 302 | void ZLIB_INTERNAL zcfree (opaque, ptr) 303 | voidpf opaque; 304 | voidpf ptr; 305 | { 306 | free(ptr); 307 | if (opaque) return; /* make compiler happy */ 308 | } 309 | 310 | #endif /* MY_ZCALLOC */ 311 | -------------------------------------------------------------------------------- /src/3rdparty/zlib/zutil.h: -------------------------------------------------------------------------------- 1 | /* zutil.h -- internal interface and configuration of the compression library 2 | * Copyright (C) 1995-2010 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* @(#) $Id$ */ 12 | 13 | #ifndef ZUTIL_H 14 | #define ZUTIL_H 15 | 16 | #include "qconfig.h" 17 | #if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) && defined(QT_VISIBILITY_AVAILABLE) 18 | # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) 19 | #else 20 | # define ZLIB_INTERNAL 21 | #endif 22 | 23 | #include "zlib.h" 24 | 25 | #ifdef STDC 26 | # if !(defined(_WIN32_WCE) && defined(_MSC_VER)) 27 | # include 28 | # endif 29 | # include 30 | # include 31 | #endif 32 | 33 | #ifndef local 34 | # define local static 35 | #endif 36 | /* compile with -Dlocal if your debugger can't find static symbols */ 37 | 38 | typedef unsigned char uch; 39 | typedef uch FAR uchf; 40 | typedef unsigned short ush; 41 | typedef ush FAR ushf; 42 | typedef unsigned long ulg; 43 | 44 | extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ 45 | /* (size given to avoid silly warnings with Visual C++) */ 46 | 47 | #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] 48 | 49 | #define ERR_RETURN(strm,err) \ 50 | return (strm->msg = (char*)ERR_MSG(err), (err)) 51 | /* To be used only when the state is known to be valid */ 52 | 53 | /* common constants */ 54 | 55 | #ifndef DEF_WBITS 56 | # define DEF_WBITS MAX_WBITS 57 | #endif 58 | /* default windowBits for decompression. MAX_WBITS is for compression only */ 59 | 60 | #if MAX_MEM_LEVEL >= 8 61 | # define DEF_MEM_LEVEL 8 62 | #else 63 | # define DEF_MEM_LEVEL MAX_MEM_LEVEL 64 | #endif 65 | /* default memLevel */ 66 | 67 | #define STORED_BLOCK 0 68 | #define STATIC_TREES 1 69 | #define DYN_TREES 2 70 | /* The three kinds of block type */ 71 | 72 | #define MIN_MATCH 3 73 | #define MAX_MATCH 258 74 | /* The minimum and maximum match lengths */ 75 | 76 | #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ 77 | 78 | /* target dependencies */ 79 | 80 | #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) 81 | # define OS_CODE 0x00 82 | # if defined(__TURBOC__) || defined(__BORLANDC__) 83 | # if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) 84 | /* Allow compilation with ANSI keywords only enabled */ 85 | void _Cdecl farfree( void *block ); 86 | void *_Cdecl farmalloc( unsigned long nbytes ); 87 | # else 88 | # include 89 | # endif 90 | # else /* MSC or DJGPP */ 91 | # include 92 | # endif 93 | #endif 94 | 95 | #ifdef AMIGA 96 | # define OS_CODE 0x01 97 | #endif 98 | 99 | #if defined(VAXC) || defined(VMS) 100 | # define OS_CODE 0x02 101 | # define F_OPEN(name, mode) \ 102 | fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") 103 | #endif 104 | 105 | #if defined(ATARI) || defined(atarist) 106 | # define OS_CODE 0x05 107 | #endif 108 | 109 | #ifdef OS2 110 | # define OS_CODE 0x06 111 | # ifdef M_I86 112 | # include 113 | # endif 114 | #endif 115 | 116 | #if defined(MACOS) || defined(TARGET_OS_MAC) 117 | # define OS_CODE 0x07 118 | # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os 119 | # include /* for fdopen */ 120 | # else 121 | # ifndef fdopen 122 | # define fdopen(fd,mode) NULL /* No fdopen() */ 123 | # endif 124 | # endif 125 | #endif 126 | 127 | #ifdef TOPS20 128 | # define OS_CODE 0x0a 129 | #endif 130 | 131 | #ifdef WIN32 132 | # ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ 133 | # define OS_CODE 0x0b 134 | # endif 135 | #endif 136 | 137 | #ifdef __50SERIES /* Prime/PRIMOS */ 138 | # define OS_CODE 0x0f 139 | #endif 140 | 141 | #if defined(_BEOS_) || defined(RISCOS) 142 | # define fdopen(fd,mode) NULL /* No fdopen() */ 143 | #endif 144 | 145 | #if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX 146 | # if defined(_WIN32_WCE) 147 | # define fdopen(fd,mode) NULL /* No fdopen() */ 148 | # ifndef _PTRDIFF_T_DEFINED 149 | typedef int ptrdiff_t; 150 | # define _PTRDIFF_T_DEFINED 151 | # endif 152 | # else 153 | # define fdopen(fd,type) _fdopen(fd,type) 154 | # endif 155 | #endif 156 | 157 | #if defined(__BORLANDC__) 158 | #pragma warn -8004 159 | #pragma warn -8008 160 | #pragma warn -8066 161 | #endif 162 | 163 | /* provide prototypes for these when building zlib without LFS */ 164 | #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 165 | ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); 166 | ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); 167 | #endif 168 | 169 | /* common defaults */ 170 | 171 | #ifndef OS_CODE 172 | # define OS_CODE 0x03 /* assume Unix */ 173 | #endif 174 | 175 | #ifndef F_OPEN 176 | # define F_OPEN(name, mode) fopen((name), (mode)) 177 | #endif 178 | 179 | /* functions */ 180 | 181 | #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) 182 | # ifndef HAVE_VSNPRINTF 183 | # define HAVE_VSNPRINTF 184 | # endif 185 | #endif 186 | #if defined(__CYGWIN__) 187 | # ifndef HAVE_VSNPRINTF 188 | # define HAVE_VSNPRINTF 189 | # endif 190 | #endif 191 | #ifndef HAVE_VSNPRINTF 192 | # ifdef MSDOS 193 | /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), 194 | but for now we just assume it doesn't. */ 195 | # define NO_vsnprintf 196 | # endif 197 | # ifdef __TURBOC__ 198 | # define NO_vsnprintf 199 | # endif 200 | # ifdef WIN32 201 | /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ 202 | # if !defined(vsnprintf) && !defined(NO_vsnprintf) 203 | # if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) 204 | # define vsnprintf _vsnprintf 205 | # endif 206 | # endif 207 | # endif 208 | # ifdef __SASC 209 | # define NO_vsnprintf 210 | # endif 211 | #endif 212 | #ifdef VMS 213 | # define NO_vsnprintf 214 | #endif 215 | 216 | #if defined(pyr) 217 | # define NO_MEMCPY 218 | #endif 219 | #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) 220 | /* Use our own functions for small and medium model with MSC <= 5.0. 221 | * You may have to use the same strategy for Borland C (untested). 222 | * The __SC__ check is for Symantec. 223 | */ 224 | # define NO_MEMCPY 225 | #endif 226 | #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) 227 | # define HAVE_MEMCPY 228 | #endif 229 | #ifdef HAVE_MEMCPY 230 | # ifdef SMALL_MEDIUM /* MSDOS small or medium model */ 231 | # define zmemcpy _fmemcpy 232 | # define zmemcmp _fmemcmp 233 | # define zmemzero(dest, len) _fmemset(dest, 0, len) 234 | # else 235 | # define zmemcpy memcpy 236 | # define zmemcmp memcmp 237 | # define zmemzero(dest, len) memset(dest, 0, len) 238 | # endif 239 | #else 240 | void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); 241 | int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); 242 | void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); 243 | #endif 244 | 245 | /* Diagnostic functions */ 246 | #ifdef DEBUG 247 | # include 248 | extern int ZLIB_INTERNAL z_verbose; 249 | extern void ZLIB_INTERNAL z_error OF((char *m)); 250 | # define Assert(cond,msg) {if(!(cond)) z_error(msg);} 251 | # define Trace(x) {if (z_verbose>=0) fprintf x ;} 252 | # define Tracev(x) {if (z_verbose>0) fprintf x ;} 253 | # define Tracevv(x) {if (z_verbose>1) fprintf x ;} 254 | # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} 255 | # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} 256 | #else 257 | # define Assert(cond,msg) 258 | # define Trace(x) 259 | # define Tracev(x) 260 | # define Tracevv(x) 261 | # define Tracec(c,x) 262 | # define Tracecv(c,x) 263 | #endif 264 | 265 | 266 | voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, 267 | unsigned size)); 268 | void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); 269 | 270 | #define ZALLOC(strm, items, size) \ 271 | (*((strm)->zalloc))((strm)->opaque, (items), (size)) 272 | #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) 273 | #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} 274 | 275 | #endif /* ZUTIL_H */ 276 | -------------------------------------------------------------------------------- /src/compress/compress.pro: -------------------------------------------------------------------------------- 1 | TARGET = QtCompress 2 | QT = core 3 | 4 | load(qt_module) 5 | 6 | DEFINES += QT_BUILD_QTCOMPRESS_LIB 7 | 8 | HEADERS += \ 9 | qzipreader.h \ 10 | qzipwriter.h \ 11 | qtcompressglobal.h 12 | 13 | SOURCES += qzip.cpp 14 | 15 | include(../3rdparty/zlib.pri) 16 | -------------------------------------------------------------------------------- /src/compress/compress.pro.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ProjectExplorer.Project.ActiveTarget 7 | -1 8 | 9 | 10 | ProjectExplorer.Project.EditorSettings 11 | 12 | true 13 | false 14 | true 15 | 16 | Cpp 17 | 18 | CppGlobal 19 | 20 | 21 | 22 | QmlJS 23 | 24 | QmlJSGlobal 25 | 26 | 27 | 2 28 | UTF-8 29 | false 30 | 4 31 | false 32 | true 33 | 1 34 | true 35 | 0 36 | true 37 | 0 38 | 8 39 | true 40 | 1 41 | true 42 | true 43 | true 44 | false 45 | 46 | 47 | 48 | ProjectExplorer.Project.PluginSettings 49 | 50 | 51 | 52 | ProjectExplorer.Project.TargetCount 53 | 0 54 | 55 | 56 | ProjectExplorer.Project.Updater.EnvironmentId 57 | {fbd162e8-4ee8-4396-afba-3c71cc1eda70} 58 | 59 | 60 | ProjectExplorer.Project.Updater.FileVersion 61 | 15 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/compress/qtcompressglobal.h: -------------------------------------------------------------------------------- 1 | #ifndef QTCOMPRESSGLOBAL_H 2 | #define QTCOMPRESSGLOBAL_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | 8 | #if defined(QT_BUILD_QTCOMPRESS_LIB) 9 | #define QTCOMPRESS_EXPORT Q_DECL_EXPORT 10 | #else 11 | #define QTCOMPRESS_EXPORT Q_DECL_IMPORT 12 | #endif 13 | 14 | QT_END_NAMESPACE 15 | 16 | #endif // QTCOMPRESSGLOBAL_H 17 | -------------------------------------------------------------------------------- /src/compress/qzipreader.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the QtGui module of the Qt Toolkit. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef QZIPREADER_H 43 | #define QZIPREADER_H 44 | 45 | #include 46 | 47 | #include 48 | #include 49 | #include 50 | 51 | QT_BEGIN_NAMESPACE 52 | 53 | class QZipReaderPrivate; 54 | 55 | class QTCOMPRESS_EXPORT QZipReader 56 | { 57 | public: 58 | explicit QZipReader(const QString &fileName, QIODevice::OpenMode mode = QIODevice::ReadOnly ); 59 | 60 | explicit QZipReader(QIODevice *device); 61 | ~QZipReader(); 62 | 63 | QIODevice* device() const; 64 | 65 | bool isReadable() const; 66 | bool exists() const; 67 | 68 | struct QTCOMPRESS_EXPORT FileInfo 69 | { 70 | FileInfo(); 71 | FileInfo(const FileInfo &other); 72 | ~FileInfo(); 73 | FileInfo &operator=(const FileInfo &other); 74 | bool isValid() const; 75 | QString filePath; 76 | uint isDir : 1; 77 | uint isFile : 1; 78 | uint isSymLink : 1; 79 | QFile::Permissions permissions; 80 | uint crc; 81 | qint64 size; 82 | QDateTime lastModified; 83 | void *d; 84 | }; 85 | 86 | QList fileInfoList() const; 87 | int count() const; 88 | 89 | FileInfo entryInfoAt(int index) const; 90 | QByteArray fileData(const QString &fileName) const; 91 | bool extractAll(const QString &destinationDir) const; 92 | 93 | enum Status { 94 | NoError, 95 | FileReadError, 96 | FileOpenError, 97 | FilePermissionsError, 98 | FileError 99 | }; 100 | 101 | Status status() const; 102 | 103 | void close(); 104 | 105 | private: 106 | QZipReaderPrivate *d; 107 | Q_DISABLE_COPY(QZipReader) 108 | }; 109 | 110 | QT_END_NAMESPACE 111 | 112 | #endif // QZIPREADER_H 113 | -------------------------------------------------------------------------------- /src/compress/qzipwriter.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the QtGui module of the Qt Toolkit. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | #ifndef QZIPWRITER_H 42 | #define QZIPWRITER_H 43 | 44 | #include 45 | #include 46 | #include 47 | 48 | QT_BEGIN_NAMESPACE 49 | 50 | class QZipWriterPrivate; 51 | 52 | class QTCOMPRESS_EXPORT QZipWriter 53 | { 54 | public: 55 | explicit QZipWriter(const QString &fileName, QIODevice::OpenMode mode = (QIODevice::WriteOnly | QIODevice::Truncate) ); 56 | 57 | explicit QZipWriter(QIODevice *device); 58 | ~QZipWriter(); 59 | 60 | QIODevice* device() const; 61 | 62 | bool isWritable() const; 63 | bool exists() const; 64 | 65 | enum Status { 66 | NoError, 67 | FileWriteError, 68 | FileOpenError, 69 | FilePermissionsError, 70 | FileError 71 | }; 72 | 73 | Status status() const; 74 | 75 | enum CompressionPolicy { 76 | AlwaysCompress, 77 | NeverCompress, 78 | AutoCompress 79 | }; 80 | 81 | void setCompressionPolicy(CompressionPolicy policy); 82 | CompressionPolicy compressionPolicy() const; 83 | 84 | void setCreationPermissions(QFile::Permissions permissions); 85 | QFile::Permissions creationPermissions() const; 86 | 87 | void addFile(const QString &fileName, const QByteArray &data); 88 | 89 | void addFile(const QString &fileName, QIODevice *device); 90 | 91 | void addDirectory(const QString &dirName); 92 | 93 | void addSymLink(const QString &fileName, const QString &destination); 94 | 95 | void close(); 96 | private: 97 | QZipWriterPrivate *d; 98 | Q_DISABLE_COPY(QZipWriter) 99 | }; 100 | 101 | QT_END_NAMESPACE 102 | 103 | #endif // QZIPWRITER_H 104 | -------------------------------------------------------------------------------- /src/src.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS += compress 3 | -------------------------------------------------------------------------------- /sync.profile: -------------------------------------------------------------------------------- 1 | %modules = ( # path to module name map 2 | "QtCompress" => "$basedir/src/compress", 3 | ); 4 | 5 | %moduleheaders = ( # restrict the module headers to those found in relative path 6 | ); 7 | 8 | %classnames = ( 9 | ); 10 | 11 | # Module dependencies. 12 | # Every module that is required to build this module should have one entry. 13 | # Each of the module version specifiers can take one of the following values: 14 | # - A specific Git revision. 15 | # - any git symbolic ref resolvable from the module's repository (e.g. "refs/heads/master" to track master branch) 16 | # - an empty string to use the same branch under test (dependencies will become "refs/heads/master" if we are in the master branch) 17 | # 18 | my @internal_zlib_headers = ( "crc32.h", "deflate.h", "gzguts.h", "inffast.h", "inffixed.h", "inflate.h", "inftrees.h", "trees.h", "zutil.h" ); 19 | my @zlib_headers = ( "zconf.h", "zlib.h" ); 20 | @ignore_headers = ( @internal_zlib_headers ); 21 | @ignore_for_include_check = ( @zlib_headers); 22 | @ignore_for_qt_begin_namespace_check = ( @zlib_headers); 23 | 24 | 25 | %dependencies = ( 26 | "qtbase" => "", 27 | ); 28 | -------------------------------------------------------------------------------- /tests/auto/.gitignore: -------------------------------------------------------------------------------- 1 | tst_qzip 2 | -------------------------------------------------------------------------------- /tests/auto/auto.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS += unit -------------------------------------------------------------------------------- /tests/auto/cmake/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | project(qmake_cmake_files) 4 | 5 | enable_testing() 6 | 7 | find_package(Qt5Core REQUIRED) 8 | 9 | include("${_Qt5CTestMacros}") 10 | 11 | test_module_includes( 12 | ) 13 | -------------------------------------------------------------------------------- /tests/auto/cmake/cmake.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | CMAKE_QT_MODULES_UNDER_TEST = qtcompress 4 | 5 | CONFIG += ctest_testcase 6 | -------------------------------------------------------------------------------- /tests/auto/unit/qzip/qzip.pro: -------------------------------------------------------------------------------- 1 | CONFIG += testcase 2 | TARGET = tst_qzip 3 | QT += compress testlib 4 | SOURCES += tst_qzip.cpp 5 | 6 | wince* { 7 | addFiles.files = testdata 8 | addFiles.path = . 9 | DEPLOYMENT += addFiles 10 | DEFINES += SRCDIR=\\\".\\\" 11 | } else { 12 | DEFINES += SRCDIR=\\\"$$PWD\\\" 13 | } 14 | -------------------------------------------------------------------------------- /tests/auto/unit/qzip/testdata/symlink.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nezticle/qtcompress/23f8831826cd72aedf99fc3699148b6c994fd677/tests/auto/unit/qzip/testdata/symlink.zip -------------------------------------------------------------------------------- /tests/auto/unit/qzip/testdata/test.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nezticle/qtcompress/23f8831826cd72aedf99fc3699148b6c994fd677/tests/auto/unit/qzip/testdata/test.zip -------------------------------------------------------------------------------- /tests/auto/unit/qzip/testdata/test/test.txt: -------------------------------------------------------------------------------- 1 | content 2 | -------------------------------------------------------------------------------- /tests/auto/unit/qzip/tst_qzip.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the test suite of the Qt Toolkit. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and Digia. For licensing terms and 14 | ** conditions see http://qt.digia.com/licensing. For further information 15 | ** use the contact form at http://qt.digia.com/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 as published by the Free Software 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the 21 | ** packaging of this file. Please review the following information to 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 24 | ** 25 | ** In addition, as a special exception, Digia gives you certain additional 26 | ** rights. These rights are described in the Digia Qt LGPL Exception 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 28 | ** 29 | ** GNU General Public License Usage 30 | ** Alternatively, this file may be used under the terms of the GNU 31 | ** General Public License version 3.0 as published by the Free Software 32 | ** Foundation and appearing in the file LICENSE.GPL included in the 33 | ** packaging of this file. Please review the following information to 34 | ** ensure the GNU General Public License version 3.0 requirements will be 35 | ** met: http://www.gnu.org/copyleft/gpl.html. 36 | ** 37 | ** 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | class tst_QZip : public QObject 48 | { 49 | Q_OBJECT 50 | public slots: 51 | void init(); 52 | void cleanup(); 53 | 54 | private slots: 55 | void basicUnpack(); 56 | void symlinks(); 57 | void readTest(); 58 | void createArchive(); 59 | }; 60 | 61 | void tst_QZip::init() 62 | { 63 | } 64 | 65 | void tst_QZip::cleanup() 66 | { 67 | } 68 | 69 | void tst_QZip::basicUnpack() 70 | { 71 | QZipReader zip(QString(SRCDIR) + "/testdata/test.zip", QIODevice::ReadOnly); 72 | QList files = zip.fileInfoList(); 73 | QCOMPARE(files.count(), 2); 74 | 75 | QZipReader::FileInfo fi = files.at(0); 76 | QVERIFY(fi.isValid()); 77 | QCOMPARE(fi.filePath, QString("test")); 78 | QCOMPARE(uint(fi.isDir), (uint) 1); 79 | QCOMPARE(uint(fi.isFile), (uint) 0); 80 | QCOMPARE(uint(fi.isSymLink), (uint) 0); 81 | 82 | QCOMPARE(fi.permissions,QFile::Permissions( QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner 83 | | QFile::ReadUser | QFile::WriteUser | QFile::ExeUser )); 84 | 85 | QCOMPARE(fi.lastModified, QDateTime::fromString("2005.11.11 13:08:02", "yyyy.MM.dd HH:mm:ss")); 86 | 87 | fi = files.at(1); 88 | QVERIFY(fi.isValid()); 89 | QCOMPARE(fi.filePath, QString("test/test.txt")); 90 | QCOMPARE(uint(fi.isDir), (uint) 0); 91 | QCOMPARE(uint(fi.isFile), (uint) 1); 92 | QCOMPARE(uint(fi.isSymLink), (uint) 0); 93 | 94 | QVERIFY(fi.permissions == QFile::Permissions( QFile::ReadOwner | QFile::WriteOwner 95 | | QFile::ReadUser | QFile::WriteUser )); 96 | 97 | QCOMPARE(fi.lastModified, QDateTime::fromString("2005.11.11 13:08:02", "yyyy.MM.dd HH:mm:ss")); 98 | 99 | QCOMPARE(zip.fileData("test/test.txt"), QByteArray("content\n")); 100 | 101 | fi = zip.entryInfoAt(-1); 102 | QVERIFY(!fi.isValid()); 103 | } 104 | 105 | void tst_QZip::symlinks() 106 | { 107 | QZipReader zip(QString(SRCDIR) + "/testdata/symlink.zip", QIODevice::ReadOnly); 108 | QList files = zip.fileInfoList(); 109 | QCOMPARE(files.count(), 2); 110 | 111 | QZipReader::FileInfo fi = files.at(0); 112 | QVERIFY(fi.isValid()); 113 | QCOMPARE(fi.filePath, QString("symlink")); 114 | QVERIFY(!fi.isDir); 115 | QVERIFY(!fi.isFile); 116 | QVERIFY(fi.isSymLink); 117 | 118 | QCOMPARE(zip.fileData("symlink"), QByteArray("destination")); 119 | 120 | fi = files.at(1); 121 | QVERIFY(fi.isValid()); 122 | QCOMPARE(fi.filePath, QString("destination")); 123 | QVERIFY(!fi.isDir); 124 | QVERIFY(fi.isFile); 125 | QVERIFY(!fi.isSymLink); 126 | } 127 | 128 | void tst_QZip::readTest() 129 | { 130 | QZipReader zip("foobar.zip", QIODevice::ReadOnly); // non existing file. 131 | QList files = zip.fileInfoList(); 132 | QCOMPARE(files.count(), 0); 133 | QByteArray b = zip.fileData("foobar"); 134 | QCOMPARE(b.size(), 0); 135 | } 136 | 137 | void tst_QZip::createArchive() 138 | { 139 | QBuffer buffer; 140 | QZipWriter zip(&buffer); 141 | QByteArray fileContents("simple file contents\nline2\n"); 142 | zip.addFile("My Filename", fileContents); 143 | zip.close(); 144 | QByteArray zipFile = buffer.buffer(); 145 | 146 | // QFile f("createArchiveTest.zip"); f.open(QIODevice::WriteOnly); f.write(zipFile); f.close(); 147 | 148 | QBuffer buffer2(&zipFile); 149 | QZipReader zip2(&buffer2); 150 | QList files = zip2.fileInfoList(); 151 | QCOMPARE(files.count(), 1); 152 | QZipReader::FileInfo file = files.at(0); 153 | QCOMPARE(file.filePath, QString("My Filename")); 154 | QCOMPARE(uint(file.isDir), (uint) 0); 155 | QCOMPARE(uint(file.isFile), (uint) 1); 156 | QCOMPARE(uint(file.isSymLink), (uint) 0); 157 | QCOMPARE(file.permissions, QFile::Permissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ReadUser | QFile::WriteUser) ); 158 | QCOMPARE(file.size, (long long) 27); 159 | QCOMPARE(zip2.fileData("My Filename"), fileContents); 160 | } 161 | 162 | QTEST_MAIN(tst_QZip) 163 | #include "tst_qzip.moc" 164 | -------------------------------------------------------------------------------- /tests/auto/unit/unit.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS += qzip -------------------------------------------------------------------------------- /tests/tests.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS += auto --------------------------------------------------------------------------------