Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch zlib-update Excluding Merge-Ins
This is equivalent to a diff from b10ff3809e to d658634bba
|
2026-03-12
| ||
| 12:52 | Merge the updates to zlib to version 1.3.2, released on February 17, 2026. ... (check-in: 6ea30fb3cd user: florian tags: trunk) | |
|
2026-02-19
| ||
| 14:36 | Update the built-in SQLite to the latest beta for testing. ... (check-in: 065736a20c user: drh tags: trunk) | |
|
2026-02-17
| ||
| 16:47 | Merge the latest trunk enhancements into the timestamp-vfs branch. ... (Leaf check-in: 99aa77d96e user: drh tags: timestamp-vfs) | |
| 15:06 | Carry forward [368d97869b] to the zlib 1.3.2 update. ... (Closed-Leaf check-in: d658634bba user: florian tags: zlib-update) | |
| 15:04 | Carry forward [0f8bae079e] to the zlib 1.3.2 update. ... (check-in: 235b210387 user: florian tags: zlib-update) | |
| 15:02 | Update the built-in zlib to version 1.3.2, released on February 17, 2026. According to check-ins [eea86cee3a] and [511ad59ae3], all files from the doc/ and contrib/ada/ subdirectories are excluded. ... (check-in: 04f74fdff7 user: florian tags: zlib-update) | |
| 12:08 | Update the built-in SQLite to include the latest enhancements and optimizations. ... (check-in: b10ff3809e user: drh tags: trunk) | |
| 12:06 | Provide a link to the rcvfrom entry on the artifact page. ... (check-in: 2e2932f6f3 user: drh tags: trunk) | |
Added compat/zlib/.cmake-format.yaml.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
_help_parse: Options affecting listfile parsing
parse:
_help_additional_commands:
- Specify structure for custom cmake functions
additional_commands:
foo:
flags:
- BAR
- BAZ
kwargs:
HEADERS: '*'
SOURCES: '*'
DEPENDS: '*'
_help_override_spec:
- Override configurations per-command where available
override_spec: {}
_help_vartags:
- Specify variable tags.
vartags: []
_help_proptags:
- Specify property tags.
proptags: []
_help_format: Options affecting formatting.
format:
_help_disable:
- Disable formatting entirely, making cmake-format a no-op
disable: false
_help_line_width:
- How wide to allow formatted cmake files
line_width: 80
_help_tab_size:
- How many spaces to tab for indent
tab_size: 4
_help_use_tabchars:
- If true, lines are indented using tab characters (utf-8
- 0x09) instead of <tab_size> space characters (utf-8 0x20).
- In cases where the layout would require a fractional tab
- character, the behavior of the fractional indentation is
- governed by <fractional_tab_policy>
use_tabchars: false
_help_fractional_tab_policy:
- If <use_tabchars> is True, then the value of this variable
- indicates how fractional indentions are handled during
- whitespace replacement. If set to 'use-space', fractional
- indentation is left as spaces (utf-8 0x20). If set to
- '`round-up` fractional indentation is replaced with a single'
- tab character (utf-8 0x09) effectively shifting the column
- to the next tabstop
fractional_tab_policy: use-space
_help_max_subgroups_hwrap:
- If an argument group contains more than this many sub-groups
- (parg or kwarg groups) then force it to a vertical layout.
max_subgroups_hwrap: 2
_help_max_pargs_hwrap:
- If a positional argument group contains more than this many
- arguments, then force it to a vertical layout.
max_pargs_hwrap: 6
_help_max_rows_cmdline:
- If a cmdline positional group consumes more than this many
- lines without nesting, then invalidate the layout (and nest)
max_rows_cmdline: 2
_help_separate_ctrl_name_with_space:
- If true, separate flow control names from their parentheses
- with a space
separate_ctrl_name_with_space: false
_help_separate_fn_name_with_space:
- If true, separate function names from parentheses with a
- space
separate_fn_name_with_space: false
_help_dangle_parens:
- If a statement is wrapped to more than one line, than dangle
- the closing parenthesis on its own line.
dangle_parens: false
_help_dangle_align:
- If the trailing parenthesis must be 'dangled' on its on
- 'line, then align it to this reference: `prefix`: the start'
- 'of the statement, `prefix-indent`: the start of the'
- 'statement, plus one indentation level, `child`: align to'
- the column of the arguments
dangle_align: prefix
_help_min_prefix_chars:
- If the statement spelling length (including space and
- parenthesis) is smaller than this amount, then force reject
- nested layouts.
min_prefix_chars: 4
_help_max_prefix_chars:
- If the statement spelling length (including space and
- parenthesis) is larger than the tab width by more than this
- amount, then force reject un-nested layouts.
max_prefix_chars: 10
_help_max_lines_hwrap:
- If a candidate layout is wrapped horizontally but it exceeds
- this many lines, then reject the layout.
max_lines_hwrap: 2
_help_line_ending:
- What style line endings to use in the output.
line_ending: unix
_help_command_case:
- Format command names consistently as 'lower' or 'upper' case
command_case: canonical
_help_keyword_case:
- Format keywords consistently as 'lower' or 'upper' case
keyword_case: unchanged
_help_always_wrap:
- A list of command names which should always be wrapped
always_wrap: []
_help_enable_sort:
- If true, the argument lists which are known to be sortable
- will be sorted lexicographicall
enable_sort: true
_help_autosort:
- If true, the parsers may infer whether or not an argument
- list is sortable (without annotation).
autosort: false
_help_require_valid_layout:
- By default, if cmake-format cannot successfully fit
- everything into the desired linewidth it will apply the
- last, most aggressive attempt that it made. If this flag is
- True, however, cmake-format will print error, exit with non-
- zero status code, and write-out nothing
require_valid_layout: false
_help_layout_passes:
- A dictionary mapping layout nodes to a list of wrap
- decisions. See the documentation for more information.
layout_passes: {}
_help_markup: Options affecting comment reflow and formatting.
markup:
_help_bullet_char:
- What character to use for bulleted lists
bullet_char: '*'
_help_enum_char:
- What character to use as punctuation after numerals in an
- enumerated list
enum_char: .
_help_first_comment_is_literal:
- If comment markup is enabled, don't reflow the first comment
- block in each listfile. Use this to preserve formatting of
- your copyright/license statements.
first_comment_is_literal: false
_help_literal_comment_pattern:
- If comment markup is enabled, don't reflow any comment block
- which matches this (regex) pattern. Default is `None`
- (disabled).
literal_comment_pattern: null
_help_fence_pattern:
- Regular expression to match preformat fences in comments
- default= ``r'^\s*([`~]{3}[`~]*)(.*)$'``
fence_pattern: ^\s*([`~]{3}[`~]*)(.*)$
_help_ruler_pattern:
- Regular expression to match rulers in comments default=
- '``r''^\s*[^\w\s]{3}.*[^\w\s]{3}$''``'
ruler_pattern: ^\s*[^\w\s]{3}.*[^\w\s]{3}$
_help_explicit_trailing_pattern:
- If a comment line matches starts with this pattern then it
- is explicitly a trailing comment for the preceding argument.
- Default is '#<'
explicit_trailing_pattern: '#<'
_help_hashruler_min_length:
- If a comment line starts with at least this many consecutive
- hash characters, then don't lstrip() them off. This allows
- for lazy hash rulers where the first hash char is not
- separated by space
hashruler_min_length: 10
_help_canonicalize_hashrulers:
- If true, then insert a space between the first hash char and
- remaining hash chars in a hash ruler, and normalize its
- length to fill the column
canonicalize_hashrulers: true
_help_enable_markup:
- enable comment markup parsing and reflow
enable_markup: true
_help_lint: Options affecting the linter
lint:
_help_disabled_codes:
- a list of lint codes to disable
disabled_codes: []
_help_function_pattern:
- regular expression pattern describing valid function names
function_pattern: '[0-9a-z_]+'
_help_macro_pattern:
- regular expression pattern describing valid macro names
macro_pattern: '[0-9A-Z_]+'
_help_global_var_pattern:
- regular expression pattern describing valid names for
- variables with global (cache) scope
global_var_pattern: '[A-Z][0-9A-Z_]+'
_help_internal_var_pattern:
- regular expression pattern describing valid names for
- variables with global scope (but internal semantic)
internal_var_pattern: _[A-Z][0-9A-Z_]+
_help_local_var_pattern:
- regular expression pattern describing valid names for
- variables with local scope
local_var_pattern: '[a-z][a-z0-9_]+'
_help_private_var_pattern:
- regular expression pattern describing valid names for
- privatedirectory variables
private_var_pattern: _[0-9a-z_]+
_help_public_var_pattern:
- regular expression pattern describing valid names for public
- directory variables
public_var_pattern: '[A-Z][0-9A-Z_]+'
_help_argument_var_pattern:
- regular expression pattern describing valid names for
- function/macro arguments and loop variables.
argument_var_pattern: '[a-z][a-z0-9_]+'
_help_keyword_pattern:
- regular expression pattern describing valid names for
- keywords used in functions or macros
keyword_pattern: '[A-Z][0-9A-Z_]+'
_help_max_conditionals_custom_parser:
- In the heuristic for C0201, how many conditionals to match
- within a loop in before considering the loop a parser.
max_conditionals_custom_parser: 2
_help_min_statement_spacing:
- Require at least this many newlines between statements
min_statement_spacing: 1
_help_max_statement_spacing:
- Require no more than this many newlines between statements
max_statement_spacing: 2
max_returns: 6
max_branches: 12
max_arguments: 5
max_localvars: 15
max_statements: 50
_help_encode: Options affecting file encoding
encode:
_help_emit_byteorder_mark:
- If true, emit the unicode byte-order mark (BOM) at the start
- of the file
emit_byteorder_mark: false
_help_input_encoding:
- Specify the encoding of the input file. Defaults to utf-8
input_encoding: utf-8
_help_output_encoding:
- Specify the encoding of the output file. Defaults to utf-8.
- Note that cmake only claims to support utf-8 so be careful
- when using anything else
output_encoding: utf-8
_help_misc: Miscellaneous configurations options.
misc:
_help_per_command:
- A dictionary containing any per-command configuration
- overrides. Currently only `command_case` is supported.
per_command: {}
|
Added compat/zlib/BUILD.bazel.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# Copied from https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/zlib/1.3.1.bcr.4/patches
# Adapted from https://github.com/protocolbuffers/protobuf/blob/master/third_party/zlib.BUILD
# Copyright 2008 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Code generated by the Protocol Buffer compiler is owned by the owner
# of the input file used when generating it. This code is not
# standalone and requires a support library to be linked with it. This
# support library is itself covered by the above license.
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_license//rules:license.bzl", "license")
package(
default_applicable_licenses = [":license"],
)
license(
name = "license",
license_kinds = ["@rules_license//licenses/spdx:Zlib"],
license_text = "LICENSE",
)
exports_files([
"LICENSE",
])
_ZLIB_HEADERS = [
"crc32.h",
"deflate.h",
"gzguts.h",
"inffast.h",
"inffixed.h",
"inflate.h",
"inftrees.h",
"trees.h",
"zconf.h",
"zlib.h",
"zutil.h",
]
_ZLIB_PREFIXED_HEADERS = ["zlib/include/" + hdr for hdr in _ZLIB_HEADERS]
# In order to limit the damage from the `includes` propagation
# via `:zlib`, copy the public headers to a subdirectory and
# expose those.
genrule(
name = "copy_public_headers",
srcs = _ZLIB_HEADERS,
outs = _ZLIB_PREFIXED_HEADERS,
cmd_bash = "cp $(SRCS) $(@D)/zlib/include/",
cmd_bat = " && ".join(
["@copy /Y \"$(location %s)\" \"$(@D)\\zlib\\include\\\" >NUL" %
s for s in _ZLIB_HEADERS],
),
)
config_setting(
name = "mingw_gcc_compiler",
flag_values = {
"@bazel_tools//tools/cpp:compiler": "mingw-gcc",
},
visibility = [":__subpackages__"],
)
cc_library(
name = "z",
srcs = [
"adler32.c",
"compress.c",
"crc32.c",
"deflate.c",
"gzclose.c",
"gzlib.c",
"gzread.c",
"gzwrite.c",
"infback.c",
"inffast.c",
"inflate.c",
"inftrees.c",
"trees.c",
"uncompr.c",
"zutil.c",
# Include the un-prefixed headers in srcs to work
# around the fact that zlib isn't consistent in its
# choice of <> or "" delimiter when including itself.
] + _ZLIB_HEADERS,
hdrs = _ZLIB_PREFIXED_HEADERS,
copts = select({
":mingw_gcc_compiler": [
"-fpermissive",
],
"@platforms//os:windows": [],
"//conditions:default": [
"-Wno-deprecated-non-prototype",
"-Wno-unused-variable",
"-Wno-implicit-function-declaration",
],
}),
includes = ["zlib/include/"],
visibility = ["//visibility:public"],
)
alias(
name = "zlib",
actual = ":z",
visibility = ["//visibility:public"],
)
|
Changes to compat/zlib/CMakeLists.txt.
|
| | < | > > > > > > > > | > > > > | > > > > | < > > | | > | > > > > | > | | > > | > > > > > > > > > > | > > > > > > > > | > > > > > > < < < < < < < < < < < < < < < | | < > | > > | > > > | < < > | | < < | < > | | | < < < < | > | > | | < < < | | | | < < | | | | | > > > > < | > > | > > > > > > > > > > > > > > > | > > > | < > | < > | | | < | | < | > > | < | | < < < < | > > > > > < < > | > > | > > > > | > > > > > > > | | > | < < < < | < < | | > > > > > > > > > > > > | < < > > > | < > > | < < < | < > | > > > | | | < < | < > | > | | | > > > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | < < | | < < | < < < < < | < < < < | 1 2 3 4 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
zlib
LANGUAGES C
VERSION 1.3.2
HOMEPAGE_URL "https://zlib.net/"
DESCRIPTION "a general-purpose lossless data-compression library")
# ============================================================================
# CPack
# ============================================================================
set(CPACK_PACKAGE_VENDOR "zlib-Project")
set(CPACK_PACKAGE_DESCRIPTION_FILE ${zlib_SOURCE_DIR}/README)
set(CPACK_RESOURCE_FILE_LICENSE ${zlib_SOURCE_DIR}/LICENSE)
set(CPACK_RESOURCE_FILE_README ${zlib_SOURCE_DIR}/README)
# ============================================================================
# configuration
# ============================================================================
option(ZLIB_BUILD_TESTING "Enable Zlib Examples as tests" ON)
option(ZLIB_BUILD_SHARED "Enable building zlib shared library" ON)
option(ZLIB_BUILD_STATIC "Enable building zlib static library" ON)
option(ZLIB_INSTALL "Enable installation of zlib" ON)
option(ZLIB_PREFIX "prefix for all types and library functions, see zconf.h.in"
OFF)
mark_as_advanced(ZLIB_PREFIX)
get_property(IS_MULTI GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT DEFINED CMAKE_BUILD_TYPE AND NOT IS_MULTI)
message(STATUS "No CMAKE_BUILD_TYPE set -- using Release")
set(CMAKE_BUILD_TYPE Release)
endif(NOT DEFINED CMAKE_BUILD_TYPE AND NOT IS_MULTI)
include(CheckCSourceCompiles)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CMakePackageConfigHelpers)
include(CheckTypeSize)
include(CPack)
include(GNUInstallDirs)
set(CPACK_INCLUDED TRUE)
if(NOT ZLIB_CONF_WRITTEN)
set(Z_PREFIX ${ZLIB_PREFIX})
set(CONF_OUT_FILE ${zlib_BINARY_DIR}/zconf.h.cmakein)
file(READ ${zlib_SOURCE_DIR}/zconf.h ZCONF_CONTENT LIMIT 245)
file(WRITE ${CONF_OUT_FILE} ${ZCONF_CONTENT})
file(APPEND ${CONF_OUT_FILE} "#cmakedefine Z_PREFIX 1\n")
file(APPEND ${CONF_OUT_FILE} "#cmakedefine HAVE_STDARG_H 1\n")
file(APPEND ${CONF_OUT_FILE} "#cmakedefine HAVE_UNISTD_H 1\n")
file(READ ${zlib_SOURCE_DIR}/zconf.h ZCONF_CONTENT OFFSET 244)
set(FIRST_ITEM TRUE)
foreach(item IN LISTS ZCONF_CONTENT)
if(FIRST_ITEM)
string(APPEND OUT_CONTENT ${item})
set(FIRST_ITEM FALSE)
else(FIRST_ITEM)
string(APPEND OUT_CONTENT "\;" ${item})
endif(FIRST_ITEM)
endforeach(item IN LISTS ${ZCONF_CONTENT})
file(APPEND ${CONF_OUT_FILE} ${OUT_CONTENT})
set(ZLIB_CONF_WRITTEN
TRUE
CACHE BOOL "zconf.h.cmakein was created")
mark_as_advanced(ZLIB_CONF_WRITTEN)
endif(NOT ZLIB_CONF_WRITTEN)
#
# Check to see if we have large file support
#
set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
check_type_size(off64_t OFF64_T)
unset(CMAKE_REQUIRED_DEFINITIONS) # clear variable
#
# Check for fseeko
#
check_function_exists(fseeko HAVE_FSEEKO)
#
# Check for stdarg.h
#
check_include_file(stdarg.h HAVE_STDARG_H)
#
# Check for unistd.h
#
check_include_file(unistd.h HAVE_UNISTD_H)
#
# Check visibility attribute is supported
#
if(MSVC)
set(CMAKE_REQUIRED_FLAGS "-WX")
else(MSVC)
set(CMAKE_REQUIRED_FLAGS "-Werror")
endif(MSVC)
check_c_source_compiles(
"
#include <stdlib.h>
static void f(void) __attribute__ ((visibility(\"hidden\")));
int main(void) {return 0;}
"
HAVE___ATTR__VIS_HIDDEN)
unset(CMAKE_COMPILE_FLAGS)
set(ZLIB_PC ${zlib_BINARY_DIR}/zlib.pc)
configure_file(${zlib_SOURCE_DIR}/zlib.pc.cmakein ${ZLIB_PC} @ONLY)
configure_file(${zlib_BINARY_DIR}/zconf.h.cmakein ${zlib_BINARY_DIR}/zconf.h)
# ============================================================================
# zlib
# ============================================================================
set(ZLIB_PUBLIC_HDRS ${zlib_BINARY_DIR}/zconf.h zlib.h)
set(ZLIB_PRIVATE_HDRS
crc32.h
deflate.h
gzguts.h
inffast.h
inffixed.h
inflate.h
inftrees.h
trees.h
zutil.h)
set(ZLIB_SRCS
adler32.c
compress.c
crc32.c
deflate.c
gzclose.c
gzlib.c
gzread.c
gzwrite.c
inflate.c
infback.c
inftrees.c
inffast.c
trees.c
uncompr.c
zutil.c)
if(WIN32)
set(zlib_static_suffix "s")
set(CMAKE_DEBUG_POSTFIX "d")
endif(WIN32)
if(ZLIB_BUILD_SHARED)
add_library(
zlib SHARED ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}
$<$<OR:$<BOOL:${WIN32}>,$<BOOL:${CYGWIN}>>:win32/zlib1.rc>)
add_library(ZLIB::ZLIB ALIAS zlib)
target_include_directories(
zlib
PUBLIC $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
$<BUILD_INTERFACE:${zlib_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_definitions(
zlib
PRIVATE ZLIB_BUILD
$<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
$<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
set(INSTALL_VERSION ${zlib_VERSION})
if(NOT CYGWIN)
set_target_properties(zlib PROPERTIES SOVERSION ${zlib_VERSION_MAJOR}
VERSION ${INSTALL_VERSION})
endif(NOT CYGWIN)
set_target_properties(
zlib
PROPERTIES DEFINE_SYMBOL ZLIB_DLL
EXPORT_NAME ZLIB
OUTPUT_NAME z)
if(UNIX
AND NOT APPLE
AND NOT (CMAKE_SYSTEM_NAME STREQUAL AIX)
AND NOT (CMAKE_SYSTEM_NAME STREQUAL SunOS))
# On unix-like platforms the library is almost always called libz
set_target_properties(
zlib
PROPERTIES LINK_FLAGS
"-Wl,--version-script,\"${zlib_SOURCE_DIR}/zlib.map\"")
endif(
UNIX
AND NOT APPLE
AND NOT (CMAKE_SYSTEM_NAME STREQUAL AIX)
AND NOT (CMAKE_SYSTEM_NAME STREQUAL SunOS))
endif(ZLIB_BUILD_SHARED)
if(ZLIB_BUILD_STATIC)
add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS}
${ZLIB_PRIVATE_HDRS})
add_library(ZLIB::ZLIBSTATIC ALIAS zlibstatic)
target_include_directories(
zlibstatic
PUBLIC $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
$<BUILD_INTERFACE:${zlib_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_definitions(
zlibstatic
PRIVATE ZLIB_BUILD
$<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
$<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
set_target_properties(
zlibstatic PROPERTIES EXPORT_NAME ZLIBSTATIC OUTPUT_NAME
z${zlib_static_suffix})
endif(ZLIB_BUILD_STATIC)
if(ZLIB_INSTALL)
if(ZLIB_BUILD_SHARED)
install(
TARGETS zlib
COMPONENT Runtime
EXPORT zlibSharedExport
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(
EXPORT zlibSharedExport
FILE ZLIB-shared.cmake
NAMESPACE ZLIB::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
if(MSVC)
install(
FILES $<TARGET_PDB_FILE:zlib>
COMPONENT Runtime
DESTINATION ${CMAKE_INSTALL_BINDIR}
CONFIGURATIONS Debug OR RelWithDebInfo
OPTIONAL)
endif(MSVC)
endif(ZLIB_BUILD_SHARED)
if(ZLIB_BUILD_STATIC)
install(
TARGETS zlibstatic
COMPONENT Development
EXPORT zlibStaticExport
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(
EXPORT zlibStaticExport
FILE ZLIB-static.cmake
NAMESPACE ZLIB::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
endif(ZLIB_BUILD_STATIC)
configure_package_config_file(
${zlib_SOURCE_DIR}/zlibConfig.cmake.in
${zlib_BINARY_DIR}/ZLIBConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
write_basic_package_version_file(
"${zlib_BINARY_DIR}/ZLIBConfigVersion.cmake"
VERSION "${zlib_VERSION}"
COMPATIBILITY AnyNewerVersion)
install(FILES ${zlib_BINARY_DIR}/ZLIBConfig.cmake
${zlib_BINARY_DIR}/ZLIBConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
install(
FILES ${ZLIB_PUBLIC_HDRS}
COMPONENT Development
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(
FILES zlib.3
COMPONENT Docs
DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
install(
FILES LICENSE
doc/algorithm.txt
doc/crc-doc.1.0.pdf
doc/rfc1950.txt
doc/rfc1951.txt
doc/rfc1952.txt
doc/txtvsbin.txt
COMPONENT Docs
DESTINATION "${CMAKE_INSTALL_DOCDIR}/zlib")
install(
FILES ${ZLIB_PC}
COMPONENT Development
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
endif(ZLIB_INSTALL)
# ============================================================================
# Tests
# ============================================================================
if(ZLIB_BUILD_TESTING)
enable_testing()
add_subdirectory(test)
endif(ZLIB_BUILD_TESTING)
add_subdirectory(contrib)
|
Changes to compat/zlib/ChangeLog.
1 2 3 4 5 6 7 8 9 10 |
ChangeLog file for zlib
Changes in 1.3.1 (22 Jan 2024)
- Reject overflows of zip header fields in minizip
- Fix bug in inflateSync() for data held in bit buffer
- Add LIT_MEM define to use more memory for a small deflate speedup
- Fix decision on the emission of Zip64 end records in minizip
- Add bounds checking to ERR_MSG() macro, used by zError()
- Neutralize zip file traversal attacks in miniunz
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 |
ChangeLog file for zlib
Changes in 1.3.2 (17 Feb 2026)
- Continued rewrite of CMake build [Vollstrecker]
- Various portability improvements
- Various github workflow additions and improvements
- Check for negative lengths in crc32_combine functions
- Copy only the initialized window contents in inflateCopy
- Prevent the use of insecure functions without an explicit request
- Add compressBound_z and deflateBound_z functions for large values
- Use atomics to build inflate fixed tables once
- Add definition of ZLIB_INSECURE to build tests with c89 and c94
- Add --undefined option to ./configure for UBSan checker
- Copy only the initialized deflate state in deflateCopy
- Zero inflate state on allocation
- Remove untgz from contrib
- Add _z versions of the compress and uncompress functions
- Vectorize the CRC-32 calculation on the s390x
- Set bit 11 of the zip header flags in minizip if UTF-8
- Update OS/400 support
- Add a test to configure to check for a working compiler
- Check for invalid NULL pointer inputs to zlib operations
- Add --mandir to ./configure to specify manual directory
- Add LICENSE.Info-Zip to contrib/minizip
- Remove vstudio projects in lieu of cmake-generated projects
- Replace strcpy() with memcpy() in contrib/minizip
Changes in 1.3.1.2 (8 Dec 2025)
- Improve portability to RISC OS
- Permit compiling contrib/minizip/unzip.c with decryption
- Enable build of shared library on AIX
- Make deflateBound() more conservative and handle Z_STREAM_END
- Add zipAlreadyThere() to minizip zip.c to help avoid duplicates
- Make z_off_t 64 bits by default
- Add deflateUsed() function to get the used bits in the last byte
- Avoid out-of-bounds pointer arithmetic in inflateCopy()
- Add Haiku to configure for proper LDSHARED settings
- Add Bazel targets
- Complete rewrite of CMake build [Vollstrecker]
- Clarify the use of errnum in gzerror()
- Note that gzseek() requests are deferred until the next operation
- Note the use of gzungetc() to run a deferred seek while reading
- Fix bug in inflatePrime() for 16-bit ints
- Add a "G" option to force gzip, disabling transparency in gzread()
- Improve the discrimination between trailing garbage and bad gzip
- Allow gzflush() to write empty gzip members
- Remove redundant frees of point list on error in examples/zran.c
- Clarify the use of inflateGetHeader()
- Update links to the RFCs
- Return all available uncompressed data on error in gzread.c
- Support non-blocking devices in the gz* routines
- Various other small improvements
Changes in 1.3.1 (22 Jan 2024)
- Reject overflows of zip header fields in minizip
- Fix bug in inflateSync() for data held in bit buffer
- Add LIT_MEM define to use more memory for a small deflate speedup
- Fix decision on the emission of Zip64 end records in minizip
- Add bounds checking to ERR_MSG() macro, used by zError()
- Neutralize zip file traversal attacks in miniunz
|
| ︙ | ︙ |
Changes to compat/zlib/FAQ.
1 2 3 4 5 |
Frequently Asked Questions about zlib
If your question is not there, please check the zlib home page
| | | | | | 1 2 3 4 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 |
Frequently Asked Questions about zlib
If your question is not there, please check the zlib home page
https://zlib.net/ which may have more recent information.
The latest zlib FAQ is at https://zlib.net/zlib_faq.html
1. Is zlib Y2K-compliant?
Yes. zlib doesn't handle dates.
2. Where can I get a Windows DLL version?
The zlib sources can be compiled without change to produce a DLL. See the
file win32/DLL_FAQ.txt in the zlib distribution.
3. Where can I get a Visual Basic interface to zlib?
See
* https://zlib.net/nelson/
* win32/DLL_FAQ.txt in the zlib distribution
4. compress() returns Z_BUF_ERROR.
Make sure that before the call of compress(), the length of the compressed
buffer is equal to the available size of the compressed buffer and not
zero. For Visual Basic, check that this parameter is passed by reference
("as any"), not by value ("as long").
5. deflate() or inflate() returns Z_BUF_ERROR.
Before making the call, make sure that avail_in and avail_out are not zero.
When setting the parameter flush equal to Z_FINISH, also make sure that
avail_out is big enough to allow processing all pending input. Note that a
Z_BUF_ERROR is not fatal--another call to deflate() or inflate() can be
made with more input or output space. A Z_BUF_ERROR may in fact be
unavoidable depending on how the functions are used, since it is not
possible to tell whether or not there is more output pending when
strm.avail_out returns with zero. See https://zlib.net/zlib_how.html for a
heavily annotated example.
6. Where's the zlib documentation (man pages, etc.)?
It's in zlib.h . Examples of zlib usage are in the files test/example.c
and test/minigzip.c, with more in examples/ .
|
| ︙ | ︙ | |||
105 106 107 108 109 110 111 |
15. I have a question about OttoPDF.
We are not the authors of OttoPDF. The real author is on the OttoPDF web
site: Joel Hainley, jhainley@myndkryme.com.
16. Can zlib decode Flate data in an Adobe PDF file?
| | | | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
15. I have a question about OttoPDF.
We are not the authors of OttoPDF. The real author is on the OttoPDF web
site: Joel Hainley, jhainley@myndkryme.com.
16. Can zlib decode Flate data in an Adobe PDF file?
Yes. See https://www.pdflib.com/ . To modify PDF forms, see
https://sourceforge.net/projects/acroformtool/ .
17. Why am I getting this "register_frame_info not found" error on Solaris?
After installing zlib 1.1.4 on Solaris 2.6, running applications using zlib
generates an error such as:
ld.so.1: rpm: fatal: relocation error: file /usr/local/lib/libz.so:
|
| ︙ | ︙ | |||
151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
21. Is zlib thread-safe?
Yes. However any library routines that zlib uses and any application-
provided memory allocation routines must also be thread-safe. zlib's gz*
functions use stdio library routines, and most of zlib's functions use the
library memory allocation routines by default. zlib's *Init* functions
allow for the application to provide custom memory allocation routines.
Of course, you should only operate on any given zlib or gzip stream from a
single thread at a time.
22. Can I use zlib in my commercial application?
Yes. Please read the license in zlib.h.
| > > > > | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
21. Is zlib thread-safe?
Yes. However any library routines that zlib uses and any application-
provided memory allocation routines must also be thread-safe. zlib's gz*
functions use stdio library routines, and most of zlib's functions use the
library memory allocation routines by default. zlib's *Init* functions
allow for the application to provide custom memory allocation routines.
If the non-default BUILDFIXED or DYNAMIC_CRC_TABLE defines are used on a
system without atomics (e.g. pre-C11), then inflate() and crc32() will not
be thread safe.
Of course, you should only operate on any given zlib or gzip stream from a
single thread at a time.
22. Can I use zlib in my commercial application?
Yes. Please read the license in zlib.h.
|
| ︙ | ︙ | |||
231 232 233 234 235 236 237 |
contrib/puff directory.
31. Does zlib infringe on any patents?
As far as we know, no. In fact, that was originally the whole point behind
zlib. Look here for some more information:
| | | 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
contrib/puff directory.
31. Does zlib infringe on any patents?
As far as we know, no. In fact, that was originally the whole point behind
zlib. Look here for some more information:
https://web.archive.org/web/20180729212847/http://www.gzip.org/#faq11
32. Can zlib work with greater than 4 GB of data?
Yes. inflate() and deflate() will process any amount of data correctly.
Each call of inflate() or deflate() is limited to input and output chunks
of the maximum value that can be stored in the compiler's "unsigned int"
type, but there is no limit to the number of chunks. Note however that the
|
| ︙ | ︙ | |||
254 255 256 257 258 259 260 |
The word "may" appears several times above since there is a 4 GB limit only
if the compiler's "long" type is 32 bits. If the compiler's "long" type is
64 bits, then the limit is 16 exabytes.
33. Does zlib have any security vulnerabilities?
The only one that we are aware of is potentially in gzprintf(). If zlib is
| | | | | | | | | | | | | | 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
The word "may" appears several times above since there is a 4 GB limit only
if the compiler's "long" type is 32 bits. If the compiler's "long" type is
64 bits, then the limit is 16 exabytes.
33. Does zlib have any security vulnerabilities?
The only one that we are aware of is potentially in gzprintf(). If zlib is
compiled to use sprintf() or vsprintf(), which requires that ZLIB_INSECURE
be defined, then there is no protection against a buffer overflow of an 8K
string space (or other value as set by gzbuffer()), other than the caller
of gzprintf() assuring that the output will not exceed 8K. On the other
hand, if zlib is compiled to use snprintf() or vsnprintf(), which should
normally be the case, then there is no vulnerability. The ./configure
script will display warnings if an insecure variation of sprintf() will be
used by gzprintf(). Also the zlibCompileFlags() function will return
information on what variant of sprintf() is used by gzprintf().
If you don't have snprintf() or vsnprintf() and would like one, you can
find a good portable implementation in stb_sprintf.h here:
https://github.com/nothings/stb
Note that you should be using the most recent version of zlib. Versions
1.1.3 and before were subject to a double-free vulnerability, and versions
1.2.1 and 1.2.2 were subject to an access exception when decompressing
invalid compressed data.
34. Is there a Java version of zlib?
Probably what you want is to use zlib in Java. zlib is already included
as part of the Java SDK in the java.util.zip package. If you really want
a version of zlib written in the Java language, look on the zlib home
page for links: https://zlib.net/ .
35. I get this or that compiler or source-code scanner warning when I crank it
up to maximally-pedantic. Can't you guys write proper code?
Many years ago, we gave up attempting to avoid warnings on every compiler
in the universe. It just got to be a waste of time, and some compilers
were downright silly as well as contradicted each other. So now, we simply
|
| ︙ | ︙ | |||
310 311 312 313 314 315 316 |
Probably not. Look in the comp.compression FAQ for pointers to various
formats and associated software.
38. How can I encrypt/decrypt zip files with zlib?
zlib doesn't support encryption. The original PKZIP encryption is very
weak and can be broken with freely available programs. To get strong
| | | | 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
Probably not. Look in the comp.compression FAQ for pointers to various
formats and associated software.
38. How can I encrypt/decrypt zip files with zlib?
zlib doesn't support encryption. The original PKZIP encryption is very
weak and can be broken with freely available programs. To get strong
encryption, use GnuPG, https://www.gnupg.org/ , which already includes zlib
compression. For PKZIP compatible "encryption", look at
https://infozip.sourceforge.net/
39. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
"gzip" is the gzip format, and "deflate" is the zlib format. They should
probably have called the second one "zlib" instead to avoid confusion with
the raw deflate compressed data format. While the HTTP 1.1 RFC 2616
correctly points to the zlib specification in RFC 1950 for the "deflate"
|
| ︙ | ︙ |
Changes to compat/zlib/INDEX.
| ︙ | ︙ | |||
17 18 19 20 21 22 23 | zlib.3.pdf Man page in PDF format zlib.map Linux symbol information zlib.pc.in Template for pkg-config descriptor zlib.pc.cmakein zlib.pc template for cmake zlib2ansi perl script to convert source files for C++ compilation amiga/ makefiles for Amiga SAS C | < < > | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
zlib.3.pdf Man page in PDF format
zlib.map Linux symbol information
zlib.pc.in Template for pkg-config descriptor
zlib.pc.cmakein zlib.pc template for cmake
zlib2ansi perl script to convert source files for C++ compilation
amiga/ makefiles for Amiga SAS C
doc/ documentation for formats and algorithms
msdos/ makefiles for MSDOS
old/ makefiles for various architectures and zlib documentation
files that have not yet been updated for zlib 1.2.x
os400/ makefiles for OS/400
qnx/ makefiles for QNX
watcom/ makefiles for OpenWatcom
win32/ makefiles for Windows
zlib public header files (required for library use):
zconf.h
zlib.h
|
| ︙ | ︙ |
Changes to compat/zlib/LICENSE.
1 2 | Copyright notice: | | | 1 2 3 4 5 6 7 8 9 10 | Copyright notice: (C) 1995-2026 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it |
| ︙ | ︙ |
Added compat/zlib/MODULE.bazel.
> > > > > > > > > | 1 2 3 4 5 6 7 8 9 |
module(
name = "zlib",
version = "0.0.0",
compatibility_level = 1,
)
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "rules_cc", version = "0.0.16")
bazel_dep(name = "rules_license", version = "1.0.0")
|
Changes to compat/zlib/Makefile.in.
1 | # Makefile for zlib | | > > > | | 1 2 3 4 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 | # Makefile for zlib # Copyright (C) 1995-2026 Jean-loup Gailly, Mark Adler # For conditions of distribution and use, see copyright notice in zlib.h # To compile and test, type: # ./configure; make test # Normally configure builds both a static and a shared library. # If you want to build just a static library, use: ./configure --static # To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type: # make install # To install in $HOME instead of /usr/local, use: # make install prefix=$HOME CC=cc GCOV=GCOV LLVM_GCOV_FLAG=LLMV_GCOV_FLAG CFLAGS=-O #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 #CFLAGS=-g -DZLIB_DEBUG #CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ # -Wstrict-prototypes -Wmissing-prototypes SFLAGS=-O LDFLAGS= TEST_LIBS=-L. libz.a LDSHARED=$(CC) CPP=$(CC) -E VGFMAFLAG= STATICLIB=libz.a SHAREDLIB=libz.so SHAREDLIBV=libz.so.1.3.2 SHAREDLIBM=libz.so.1 LIBS=$(STATICLIB) $(SHAREDLIBV) AR=ar ARFLAGS=rc RANLIB=ranlib LDCONFIG=ldconfig |
| ︙ | ︙ | |||
108 109 110 111 112 113 114 |
if echo hello world | ${QEMU_RUN} ./minigzip64 | ${QEMU_RUN} ./minigzip64 -d && ${QEMU_RUN} ./example64 $$TMP64; then \
echo ' *** zlib 64-bit test OK ***'; \
else \
echo ' *** zlib 64-bit test FAILED ***'; false; \
fi
@rm -f tmp64_$$
| | | | | | 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
if echo hello world | ${QEMU_RUN} ./minigzip64 | ${QEMU_RUN} ./minigzip64 -d && ${QEMU_RUN} ./example64 $$TMP64; then \
echo ' *** zlib 64-bit test OK ***'; \
else \
echo ' *** zlib 64-bit test FAILED ***'; false; \
fi
@rm -f tmp64_$$
infcover.o: $(SRCDIR)test/infcover.c $(SRCDIR)zlib.h zconf.h $(SRCDIR)inflate.h $(SRCDIR)inftrees.h
$(CC) $(CFLAGS) $(ZINCOUT) -c -coverage -o $@ $(SRCDIR)test/infcover.c
infcover: infcover.o libz.a
$(CC) $(CFLAGS) -coverage -o $@ infcover.o libz.a
cover: infcover
rm -f *.gcda
${QEMU_RUN} ./infcover
${GCOV} ${LLVM_GCOV_FLAG} inf*.c -o ./infcover.gcda
libz.a: $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
match.o: match.S
$(CPP) match.S > _match.s
|
| ︙ | ︙ | |||
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | adler32.o: $(SRCDIR)adler32.c $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)adler32.c crc32.o: $(SRCDIR)crc32.c $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)crc32.c deflate.o: $(SRCDIR)deflate.c $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)deflate.c infback.o: $(SRCDIR)infback.c $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)infback.c inffast.o: $(SRCDIR)inffast.c $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inffast.c inflate.o: $(SRCDIR)inflate.c $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inflate.c inftrees.o: $(SRCDIR)inftrees.c $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inftrees.c trees.o: $(SRCDIR)trees.c $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)trees.c | > > > | | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | adler32.o: $(SRCDIR)adler32.c $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)adler32.c crc32.o: $(SRCDIR)crc32.c $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)crc32.c crc32_vx.o: $(SRCDIR)contrib/crc32vx/crc32_vx.c $(CC) $(CFLAGS) $(VGFMAFLAG) $(ZINC) -c -o $@ $(SRCDIR)contrib/crc32vx/crc32_vx.c deflate.o: $(SRCDIR)deflate.c $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)deflate.c infback.o: $(SRCDIR)infback.c $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)infback.c inffast.o: $(SRCDIR)inffast.c $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inffast.c inflate.o: $(SRCDIR)inflate.c $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inflate.c inftrees.o: $(SRCDIR)inftrees.c $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inftrees.c trees.o: $(SRCDIR)trees.c $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)trees.c zutil.o: $(SRCDIR)zutil.c $(SRCDIR)gzguts.h $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)zutil.c compress.o: $(SRCDIR)compress.c $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)compress.c uncompr.o: $(SRCDIR)uncompr.c $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)uncompr.c |
| ︙ | ︙ | |||
203 204 205 206 207 208 209 210 211 212 213 214 215 216 | $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/adler32.o $(SRCDIR)adler32.c -@mv objs/adler32.o $@ crc32.lo: $(SRCDIR)crc32.c -@mkdir objs 2>/dev/null || test -d objs $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/crc32.o $(SRCDIR)crc32.c -@mv objs/crc32.o $@ deflate.lo: $(SRCDIR)deflate.c -@mkdir objs 2>/dev/null || test -d objs $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/deflate.o $(SRCDIR)deflate.c -@mv objs/deflate.o $@ infback.lo: $(SRCDIR)infback.c | > > > > > | 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/adler32.o $(SRCDIR)adler32.c -@mv objs/adler32.o $@ crc32.lo: $(SRCDIR)crc32.c -@mkdir objs 2>/dev/null || test -d objs $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/crc32.o $(SRCDIR)crc32.c -@mv objs/crc32.o $@ crc32_vx.lo: $(SRCDIR)contrib/crc32vx/crc32_vx.c -@mkdir objs 2>/dev/null || test -d objs $(CC) $(SFLAGS) $(VGFMAFLAG) $(ZINC) -fPIC -c -o objs/crc32_vx.o $(SRCDIR)contrib/crc32vx/crc32_vx.c -@mv objs/crc32_vx.o $@ deflate.lo: $(SRCDIR)deflate.c -@mkdir objs 2>/dev/null || test -d objs $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/deflate.o $(SRCDIR)deflate.c -@mv objs/deflate.o $@ infback.lo: $(SRCDIR)infback.c |
| ︙ | ︙ | |||
234 235 236 237 238 239 240 | -@mv objs/inftrees.o $@ trees.lo: $(SRCDIR)trees.c -@mkdir objs 2>/dev/null || test -d objs $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/trees.o $(SRCDIR)trees.c -@mv objs/trees.o $@ | | | 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | -@mv objs/inftrees.o $@ trees.lo: $(SRCDIR)trees.c -@mkdir objs 2>/dev/null || test -d objs $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/trees.o $(SRCDIR)trees.c -@mv objs/trees.o $@ zutil.lo: $(SRCDIR)zutil.c $(SRCDIR)gzguts.h -@mkdir objs 2>/dev/null || test -d objs $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/zutil.o $(SRCDIR)zutil.c -@mv objs/zutil.o $@ compress.lo: $(SRCDIR)compress.c -@mkdir objs 2>/dev/null || test -d objs $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/compress.o $(SRCDIR)compress.c |
| ︙ | ︙ | |||
270 271 272 273 274 275 276 | gzwrite.lo: $(SRCDIR)gzwrite.c -@mkdir objs 2>/dev/null || test -d objs $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/gzwrite.o $(SRCDIR)gzwrite.c -@mv objs/gzwrite.o $@ | | | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | gzwrite.lo: $(SRCDIR)gzwrite.c -@mkdir objs 2>/dev/null || test -d objs $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/gzwrite.o $(SRCDIR)gzwrite.c -@mv objs/gzwrite.o $@ placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a $(SRCDIR)zlib.map $(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS) rm -f $(SHAREDLIB) $(SHAREDLIBM) ln -s $@ $(SHAREDLIB) ln -s $@ $(SHAREDLIBM) -@rmdir objs example$(EXE): example.o $(STATICLIB) |
| ︙ | ︙ | |||
345 346 347 348 349 350 351 | cd $(DESTDIR)$(pkgconfigdir) && rm -f zlib.pc docs: zlib.3.pdf zlib.3.pdf: $(SRCDIR)zlib.3 groff -mandoc -f H -T ps $(SRCDIR)zlib.3 | ps2pdf - $@ | | | | | | | > | 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
cd $(DESTDIR)$(pkgconfigdir) && rm -f zlib.pc
docs: zlib.3.pdf
zlib.3.pdf: $(SRCDIR)zlib.3
groff -mandoc -f H -T ps $(SRCDIR)zlib.3 | ps2pdf - $@
# zconf.h.cmakein: $(SRCDIR)zconf.h.in
# -@ TEMPFILE=zconfh_$$; \
# echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" >> $$TEMPFILE &&\
# sed -f $$TEMPFILE $(SRCDIR)zconf.h.in > $@ &&\
# touch -r $(SRCDIR)zconf.h.in $@ &&\
# rm $$TEMPFILE
#
zconf: $(SRCDIR)zconf.h.in
cp -p $(SRCDIR)zconf.h.in zconf.h
minizip-test: static
cd contrib/minizip && { CC="$(CC)" CFLAGS="$(CFLAGS)" $(MAKE) test ; cd ../.. ; }
|
| ︙ | ︙ | |||
374 375 376 377 378 379 380 | libz.* foo.gz so_locations \ _match.s maketree contrib/infback9/*.o rm -rf objs rm -f *.gcda *.gcno *.gcov rm -f contrib/infback9/*.gcda contrib/infback9/*.gcno contrib/infback9/*.gcov maintainer-clean: distclean | | | > > | > > | 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | libz.* foo.gz so_locations \ _match.s maketree contrib/infback9/*.o rm -rf objs rm -f *.gcda *.gcno *.gcov rm -f contrib/infback9/*.gcda contrib/infback9/*.gcno contrib/infback9/*.gcov maintainer-clean: distclean distclean: clean zconf # zconf.h.cmakein rm -f Makefile zlib.pc configure.log -@rm -f .DS_Store @if [ -f Makefile.in ]; then \ printf 'all:\n\t-@echo "Please use ./configure first. Thank you."\n' > Makefile ; \ printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile ; \ touch -r $(SRCDIR)Makefile.in Makefile ; fi tags: etags $(SRCDIR)*.[ch] adler32.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h zutil.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h gzclose.o gzlib.o gzread.o gzwrite.o: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h compress.o example.o minigzip.o uncompr.o: $(SRCDIR)zlib.h zconf.h crc32.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h deflate.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h infback.o inflate.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h $(SRCDIR)inffixed.h inffast.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h inftrees.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h trees.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h crc32_vx.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)contrib/crc32vx/crc32_vx_hooks.h adler32.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h gzclose.lo gzlib.lo gzread.lo gzwrite.lo: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h compress.lo example.lo minigzip.lo uncompr.lo: $(SRCDIR)zlib.h zconf.h crc32.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h deflate.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h infback.lo inflate.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h $(SRCDIR)inffixed.h inffast.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h inftrees.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h trees.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h crc32_vx.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)contrib/crc32vx/crc32_vx_hooks.h |
Changes to compat/zlib/README.
1 2 | ZLIB DATA COMPRESSION LIBRARY | | | | | | | | | | | | | 1 2 3 4 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 | ZLIB DATA COMPRESSION LIBRARY zlib 1.3.2 is a general purpose data compression library. All the code is thread safe (though see the FAQ for caveats). The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 at https://datatracker.ietf.org/doc/html/rfc1950 (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). All functions of the compression library are documented in the file zlib.h (volunteer to write man pages welcome, contact zlib@gzip.org). A usage example of the library is given in the file test/example.c which also tests that the library is working correctly. Another example is given in the file test/minigzip.c. The compression library itself is composed of all source files in the root directory. To compile all files and run the test program, follow the instructions given at the top of Makefile.in. In short "./configure; make test", and if that goes well, "make install" should work for most flavors of Unix. For Windows, use one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use make_vms.com. Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant <info@winimage.com> for the Windows DLL version. The zlib home page is https://zlib.net/ . Before reporting a problem, please check this site to verify that you have the latest version of zlib; otherwise get the latest version and check whether the problem still exists or not. PLEASE read the zlib FAQ https://zlib.net/zlib_faq.html before asking for help. Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997 issue of Dr. Dobb's Journal; a copy of the article is available at https://zlib.net/nelson/ . The changes made in version 1.3.2 are documented in the file ChangeLog. Unsupported third party contributions are provided in directory contrib/ . zlib is available in Java using the java.util.zip package. Follow the API Documentation link at: https://docs.oracle.com/search/?q=java.util.zip . A Perl interface to zlib and bzip2 written by Paul Marquess <pmqs@cpan.org> can be found at https://github.com/pmqs/IO-Compress . A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is available in Python 1.5 and later versions, see https://docs.python.org/3/library/zlib.html . zlib is built into tcl: https://wiki.tcl-lang.org/page/zlib . An experimental package to read and write files in .zip format, written on top of zlib by Gilles Vollant <info@winimage.com>, is available in the contrib/minizip directory of zlib. Notes for some targets: |
| ︙ | ︙ | |||
65 66 67 68 69 70 71 | - On Digital Unix 4.0D (formerly OSF/1) on AlphaServer, the cc option -std1 is necessary to get gzprintf working correctly. This is done by configure. - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with other compilers. Use "make test" to check your compiler. | < < | | | 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 | - On Digital Unix 4.0D (formerly OSF/1) on AlphaServer, the cc option -std1 is necessary to get gzprintf working correctly. This is done by configure. - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with other compilers. Use "make test" to check your compiler. - For PalmOs, see https://palmzlib.sourceforge.net/ Acknowledgments: The deflate format used by zlib was defined by Phil Katz. The deflate and zlib specifications were written by L. Peter Deutsch. Thanks to all the people who reported problems and suggested various improvements in zlib; they are too numerous to cite here. Copyright notice: (C) 1995-2026 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it |
| ︙ | ︙ |
Added compat/zlib/README-cmake.md.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 |
# For building with cmake at least version 3.12 (minizip 3.12) is needed
In most cases the usual
cmake -S . -B build -D CMAKE_BUILD_TYPE=Release
will create everything you need, however if you want something off default you can adjust several options fit your needs.
Every option is list below (excluding the cmake-standard options), they can be set via cmake-gui or on cmdline with
-D<option>=ON/OFF
## ZLIB-options with defaults ##
ZLIB_BUILD_TESTING=ON -- Enable Zlib Examples as tests
ZLIB_BUILD_SHARED=ON -- Enable building zlib shared library
ZLIB_BUILD_STATIC=ON -- Enable building zlib static library
ZLIB_BUILD_MINIZIP=ON -- Enable building libminizip contrib library
If this option is turned on, additional options are available from minizip (see below)
ZLIB_INSTALL=ON -- Enable installation of zlib
ZLIB_PREFIX=OFF -- prefix for all types and library functions, see zconf.h.in
This option is only on windows available and may/will be turned off and removed somewhen in the future.
If you rely cmake for finding and using zlib, this can be turned off, as `zlib1.dll` will never be used.
## minizip-options with defaults ##
MINIZIP_BUILD_SHARED=ON -- Enable building minizip shared library
MINIZIP_BUILD_STATIC=ON -- Enable building minizip static library
MINIZIP_BUILD_TESTING=ON -- Enable testing of minizip
MINIZIP_ENABLE_BZIP2=ON -- Build minizip withj bzip2 support
A usable installation of bzip2 is needed or config will fail. Turn this option of in this case.
MINIZIP_INSTALL=ON -- Enable installation of minizip
This option is only available on mingw as they tend to name this lib different. Maybe this will also be
removed in the future as. If you rely cmake for finding and using zlib, this can be turned off, as
the other file will never be used.
## Using the libs ##
To pull in what you need it's enough to just write
find_package(ZLIB CONFIG)
or
find_package(minizip CONFIG)
in your CMakeLists.txt, however it is advised to specify what you really want via:
find_package(ZLIB CONFIG COMPONENTS shared static REQUIRED)
or
find_package(minizip CONFIG COMPONENTS shared static REQUIRED)
As it's possible to only build the shared or the static lib, you can make sure that everything you need
is found. If no COMPONENTS are requested, everything needs to be found to satisfy your request. If the
libraries are optional in you project, you can omit the REQUIRED and check yourself if the targets you
want to link against are created.
When you search for minizip, it will search zlib for you, so only one of both is needed.
## Imported targets ##
When found the following targets are created for you:
ZLIB::ZLIB and ZLIB::ZLIBSTATIC -- for zlib
MINIZIP::minizip and MINIZIP::minizipstatic -- for minizip
|
Changes to compat/zlib/compress.c.
1 | /* compress.c -- compress a memory buffer | | > > | | | > > > > | | > | > > > > > > > | > > > > > | | | > > > > > | 1 2 3 4 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 |
/* compress.c -- compress a memory buffer
* Copyright (C) 1995-2026 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
#define ZLIB_INTERNAL
#include "zlib.h"
/* ===========================================================================
Compresses the source buffer into the destination buffer. The level
parameter has the same meaning as in deflateInit. sourceLen is the byte
length of the source buffer. Upon entry, destLen is the total size of the
destination buffer, which must be at least 0.1% larger than sourceLen plus
12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
Z_STREAM_ERROR if the level parameter is invalid.
The _z versions of the functions take size_t length arguments.
*/
int ZEXPORT compress2_z(Bytef *dest, z_size_t *destLen, const Bytef *source,
z_size_t sourceLen, int level) {
z_stream stream;
int err;
const uInt max = (uInt)-1;
z_size_t left;
if ((sourceLen > 0 && source == NULL) ||
destLen == NULL || (*destLen > 0 && dest == NULL))
return Z_STREAM_ERROR;
left = *destLen;
*destLen = 0;
stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0;
stream.opaque = (voidpf)0;
err = deflateInit(&stream, level);
if (err != Z_OK) return err;
stream.next_out = dest;
stream.avail_out = 0;
stream.next_in = (z_const Bytef *)source;
stream.avail_in = 0;
do {
if (stream.avail_out == 0) {
stream.avail_out = left > (z_size_t)max ? max : (uInt)left;
left -= stream.avail_out;
}
if (stream.avail_in == 0) {
stream.avail_in = sourceLen > (z_size_t)max ? max :
(uInt)sourceLen;
sourceLen -= stream.avail_in;
}
err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH);
} while (err == Z_OK);
*destLen = (z_size_t)(stream.next_out - dest);
deflateEnd(&stream);
return err == Z_STREAM_END ? Z_OK : err;
}
int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
uLong sourceLen, int level) {
int ret;
z_size_t got = *destLen;
ret = compress2_z(dest, &got, source, sourceLen, level);
*destLen = (uLong)got;
return ret;
}
/* ===========================================================================
*/
int ZEXPORT compress_z(Bytef *dest, z_size_t *destLen, const Bytef *source,
z_size_t sourceLen) {
return compress2_z(dest, destLen, source, sourceLen,
Z_DEFAULT_COMPRESSION);
}
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source,
uLong sourceLen) {
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
}
/* ===========================================================================
If the default memLevel or windowBits for deflateInit() is changed, then
this function needs to be updated.
*/
z_size_t ZEXPORT compressBound_z(z_size_t sourceLen) {
z_size_t bound = sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
(sourceLen >> 25) + 13;
return bound < sourceLen ? (z_size_t)-1 : bound;
}
uLong ZEXPORT compressBound(uLong sourceLen) {
z_size_t bound = compressBound_z(sourceLen);
return (uLong)bound != bound ? (uLong)-1 : (uLong)bound;
}
|
Changes to compat/zlib/configure.
| ︙ | ︙ | |||
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | shared=1 solo=0 cover=0 zprefix=0 zconst=0 build64=0 gcc=0 warn=0 debug=0 address=0 memory=0 old_cc="$CC" old_cflags="$CFLAGS" OBJC='$(OBJZ) $(OBJG)' PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)' # leave this script, optionally in a bad way leave() | > > > > > | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | shared=1 solo=0 cover=0 zprefix=0 zconst=0 build64=0 gcc=0 clang=0 warn=0 debug=0 address=0 memory=0 undefined=0 insecure=0 unknown=0 enable_crcvx=1 old_cc="$CC" old_cflags="$CFLAGS" OBJC='$(OBJZ) $(OBJG)' PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)' # leave this script, optionally in a bad way leave() |
| ︙ | ︙ | |||
112 113 114 115 116 117 118 |
# process command line options
while test $# -ge 1
do
case "$1" in
-h* | --help)
echo 'usage:' | tee -a configure.log
echo ' configure [--const] [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log
| | | > | | | | | > | > > > | | > | | > > | < < > > > | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# process command line options
while test $# -ge 1
do
case "$1" in
-h* | --help)
echo 'usage:' | tee -a configure.log
echo ' configure [--const] [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log
echo ' [--insecure] [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log
echo ' [--includedir=INCLUDEDIR] [--mandir=MANDIR]' | tee -a configure.log
echo ' [--archs="-arch i386 -arch x86_64"] [--disable-crcvx]' | tee -a configure.log
exit 0 ;;
-p*=* | --prefix=*) prefix=`echo $1 | sed 's/[^=]*=//'`; shift ;;
-e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/[^=]*=//'`; shift ;;
-l*=* | --libdir=*) libdir=`echo $1 | sed 's/[^=]*=//'`; shift ;;
--sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/[^=]*=//'`; shift ;;
-i*=* | --includedir=*) includedir=`echo $1 | sed 's/[^=]*=//'`;shift ;;
-m*=* | --mandir=*) mandir=`echo $1 | sed 's/[^=]*=//'`;shift ;;
-u*=* | --uname=*) uname=`echo $1 | sed 's/[^=]*=//'`;shift ;;
-p* | --prefix) prefix="$2"; shift; shift ;;
-e* | --eprefix) exec_prefix="$2"; shift; shift ;;
-l* | --libdir) libdir="$2"; shift; shift ;;
--sharedlibdir) sharedlibdir="$2"; shift; shift ;;
-i* | --includedir) includedir="$2"; shift; shift ;;
-m* | --mandir) mandir="$2"; shift; shift ;;
-u* | --uname) uname="$2"; shift; shift ;;
-s* | --shared | --enable-shared) shared=1; shift ;;
-t | --static | --disable-shared) shared=0; shift ;;
--solo) solo=1; shift ;;
--cover) cover=1; shift ;;
-z* | --zprefix) zprefix=1; shift ;;
-6* | --64) build64=1; shift ;;
-a*=* | --archs=*) ARCHS=`echo $1 | sed 's/[^=]*=//'`; shift ;;
-a* | --archs) ARCHS="$2"; shift; shift ;;
--sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;;
--localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;;
-c* | --const) zconst=1; shift ;;
-w* | --warn) warn=$((warn + 1)); shift ;;
-d* | --debug) debug=1; shift ;;
--sanitize) address=1; shift ;;
--address) address=1; shift ;;
--memory) memory=1; shift ;;
--undefined) undefined=1; shift ;;
--insecure) insecure=1; shift ;;
--disable-crcvx) enable_crcvx=0; shift ;;
*) unknown=1; echo "unknown option ignored: $1" | tee -a configure.log; shift;;
esac
done
if test $unknown -eq 1; then
echo "$0 --help for help" | tee -a configure.log
fi
# temporary file name
test=ztest$$
# put arguments in log, also put test file in log if used in arguments
show()
{
|
| ︙ | ︙ | |||
180 181 182 183 184 185 186 |
cc=${CROSS_PREFIX}cc
fi
else
cc=${CC}
fi
case "$cc" in
| | > | > | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > | > > > > > | < < > | > > > > > > > > | | 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
cc=${CROSS_PREFIX}cc
fi
else
cc=${CC}
fi
case "$cc" in
*gcc*) gcc=1
GCOV="gcov" ;;
*clang*) gcc=1
clang=1 ;;
esac
case `$cc -v 2>&1` in
*gcc*) gcc=1
GCOV="gcov" ;;
*clang*) gcc=1
clang=1 ;;
esac
if test $cover -eq 1; then
if test "$clang" -eq 1; then
if test "$cc" = "clang"; then
if command -v llvm-cov >/dev/null 2>&1; then
GCOV="llvm-cov"
LLVM_GCOV_FLAG="gcov"
GCOV="llvm-cov"
LLVM_GCOV_FLAG="gcov"
echo "Using ${GCOV} for coverage"
else
cover=0
GCOV=""
LLVM_GCOV_FLAG=""
echo "Deactivating cover as no suitable gcov can be found"
fi
else
clangV=`echo "$cc" | sed -e 's/^.*-//'`
if command -v llvm-cov-${clangV} >/dev/null 2>&1; then
GCOV="llvm-cov-${clangV}"
LLVM_GCOV_FLAG="gcov"
echo "Using ${GCOV} for coverage"
else
cover=0
GCOV=""
LLVM_GCOV_FLAG=""
echo "Deactivating cover as no suitable gcov can be found"
fi
fi
fi
fi
show $cc -c $test.c
if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
echo ... using gcc >> configure.log
CC="$cc"
CFLAGS="${CFLAGS--O3} -fPIC"
SFLAGS="${CFLAGS--O3}"
if test "$ARCHS"; then
CFLAGS="${CFLAGS} ${ARCHS}"
SFLAGS="${SFLAGS} ${ARCHS}"
LDFLAGS="${LDFLAGS} ${ARCHS}"
fi
if test $build64 -eq 1; then
CFLAGS="${CFLAGS} -m64"
SFLAGS="${SFLAGS} -m64"
fi
if test "$warn" -ge 1; then
CFLAGS="${CFLAGS} -Wall -Wextra"
if test "$warn" -ge 2; then
CFLAGS="${CFLAGS} -Wconversion -Wshadow -Wundef"
fi
fi
if test "$zconst" -eq 1; then
if test "$warn" -ge 1; then
CFLAGS="${CFLAGS} -Wcast-qual"
fi
CFLAGS="${CFLAGS} -DZLIB_CONST"
fi
if test $address -eq 1; then
CFLAGS="${CFLAGS} -g -fsanitize=address -fno-omit-frame-pointer"
fi
if test $memory -eq 1; then
CFLAGS="${CFLAGS} -g -fsanitize=memory -fno-omit-frame-pointer"
fi
if test $undefined -eq 1; then
CFLAGS="${CFLAGS} -g -fsanitize=undefined -fno-omit-frame-pointer"
fi
if test $insecure -eq 1; then
CFLAGS="${CFLAGS} -DZLIB_INSECURE"
SFLAGS="${SFLAGS} -DZLIB_INSECURE"
fi
if test $debug -eq 1; then
CFLAGS="${CFLAGS} -DZLIB_DEBUG"
SFLAGS="${SFLAGS} -DZLIB_DEBUG"
fi
if test -z "$uname"; then
uname=`(uname -s || echo unknown) 2>/dev/null`
fi
case "$uname" in
Linux* | linux* | *-linux* | GNU | GNU/* | solaris* | Haiku)
case "$mname" in
*sparc*)
LDFLAGS="${LDFLAGS} -Wl,--no-warn-rwx-segments" ;;
esac
LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;;
*BSD | *bsd* | DragonFly)
LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"}
|
| ︙ | ︙ | |||
254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
shared_ext='.so'
SHAREDLIB='libz.so' ;;
*)
shared_ext='.sl'
SHAREDLIB='libz.sl' ;;
esac ;;
AIX*)
LDFLAGS="${LDFLAGS} -Wl,-brtl" ;;
Darwin* | darwin* | *-darwin*)
shared_ext='.dylib'
SHAREDLIB=libz$shared_ext
SHAREDLIBV=libz.$VER$shared_ext
SHAREDLIBM=libz.$VER1$shared_ext
LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
| > | 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
shared_ext='.so'
SHAREDLIB='libz.so' ;;
*)
shared_ext='.sl'
SHAREDLIB='libz.sl' ;;
esac ;;
AIX*)
LDSHARED=${LDSHARED-"$cc -shared"}
LDFLAGS="${LDFLAGS} -Wl,-brtl" ;;
Darwin* | darwin* | *-darwin*)
shared_ext='.dylib'
SHAREDLIB=libz$shared_ext
SHAREDLIBV=libz.$VER$shared_ext
SHAREDLIBM=libz.$VER1$shared_ext
LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
|
| ︙ | ︙ | |||
359 360 361 362 363 364 365 |
OpenUNIX\ 5)
SFLAGS=${CFLAGS-"-KPIC -O"}
CFLAGS=${CFLAGS-"-O"}
LDSHARED=${LDSHARED-"cc -G"} ;;
AIX*) # Courtesy of dbakker@arrayasolutions.com
SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
| | > > > > > | 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 |
OpenUNIX\ 5)
SFLAGS=${CFLAGS-"-KPIC -O"}
CFLAGS=${CFLAGS-"-O"}
LDSHARED=${LDSHARED-"cc -G"} ;;
AIX*) # Courtesy of dbakker@arrayasolutions.com
SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
LDSHARED=${LDSHARED-"xlc -G"}
if test $build64 -eq 1; then
CFLAGS="${CFLAGS} -q64"
SFLAGS="${SFLAGS} -q64"
ARFLAGS="-X64 ${ARFLAGS}"
fi ;;
# send working options for other systems to zlib@gzip.org
*) SFLAGS=${CFLAGS-"-O"}
CFLAGS=${CFLAGS-"-O"}
LDSHARED=${LDSHARED-"cc -shared"} ;;
esac
fi
|
| ︙ | ︙ | |||
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 |
fi
test "$got" = ""
}
cat > $test.c << EOF
int foo() { return 0; }
EOF
echo "Checking for obsessive-compulsive compiler options..." >> configure.log
if try $CC -c $CFLAGS $test.c; then
:
else
echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log
leave 1
fi
echo >> configure.log
# see if shared library build supported
cat > $test.c <<EOF
extern int getchar();
int hello() {return getchar();}
EOF
if test $shared -eq 1; then
echo Checking for shared library support... | tee -a configure.log
# we must test in two steps (cc then ld), required at least on SunOS 4.x
if try $CC -c $SFLAGS $test.c &&
| > > > > > > > | | 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 |
fi
test "$got" = ""
}
cat > $test.c << EOF
int foo() { return 0; }
EOF
echo "Checking for compiler..." >> configure.log
if try $CC -c $test.c; then
:
else
echo "Missing or broken C compiler." | tee -a configure.log
leave 1
fi
echo "Checking for obsessive-compulsive compiler options..." >> configure.log
if try $CC -c $CFLAGS $test.c; then
:
else
echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log
leave 1
fi
echo >> configure.log
# see if shared library build supported
cat > $test.c <<EOF
extern int getchar();
int hello() {return getchar();}
EOF
if test $shared -eq 1; then
echo Checking for shared library support... | tee -a configure.log
# we must test in two steps (cc then ld), required at least on SunOS 4.x
if try $CC -c $SFLAGS $test.c &&
try $LDSHARED $SFLAGS $LDFLAGS -o $test$shared_ext $test.o; then
echo Building shared library $SHAREDLIBV with $CC. | tee -a configure.log
elif test -z "$old_cc" -a -z "$old_cflags"; then
echo No shared library support. | tee -a configure.log
shared=0;
else
echo 'No shared library support; try without defining CC and CFLAGS' | tee -a configure.log
shared=0;
|
| ︙ | ︙ | |||
501 502 503 504 505 506 507 |
int main(void) {
if (sizeof(void *) <= sizeof(int)) puts("int");
else puts("long");
return 0;
}
EOF
fi
| | | 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 |
int main(void) {
if (sizeof(void *) <= sizeof(int)) puts("int");
else puts("long");
return 0;
}
EOF
fi
if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then
sizet=`./$test`
echo "Checking for a pointer-size integer type..." $sizet"." | tee -a configure.log
CFLAGS="${CFLAGS} -DNO_SIZE_T=${sizet}"
SFLAGS="${SFLAGS} -DNO_SIZE_T=${sizet}"
else
echo "Checking for a pointer-size integer type... not found." | tee -a configure.log
fi
|
| ︙ | ︙ | |||
535 536 537 538 539 540 541 |
cat > $test.c <<EOF
#include <stdio.h>
int main(void) {
fseeko(NULL, 0, 0);
return 0;
}
EOF
| | | | | | 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 |
cat > $test.c <<EOF
#include <stdio.h>
int main(void) {
fseeko(NULL, 0, 0);
return 0;
}
EOF
if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then
echo "Checking for fseeko... Yes." | tee -a configure.log
else
CFLAGS="${CFLAGS} -DNO_FSEEKO"
SFLAGS="${SFLAGS} -DNO_FSEEKO"
echo "Checking for fseeko... No." | tee -a configure.log
fi
fi
echo >> configure.log
# check for strerror() for use by gz* functions
cat > $test.c <<EOF
#include <string.h>
#include <errno.h>
int main() { return strlen(strerror(errno)); }
EOF
if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then
echo "Checking for strerror... Yes." | tee -a configure.log
else
CFLAGS="${CFLAGS} -DNO_STRERROR"
SFLAGS="${SFLAGS} -DNO_STRERROR"
echo "Checking for strerror... No." | tee -a configure.log
fi
# copy clean zconf.h for subsequent edits
cp -p ${SRCDIR}zconf.h.in zconf.h
echo >> configure.log
# check for unistd.h and save result in zconf.h
cat > $test.c <<EOF
#include <unistd.h>
int main() { return 0; }
EOF
if try $CC -c $CFLAGS $test.c; then
sed < zconf.h "/^#if HAVE_UNISTD_H-0.* may be/s/ HAVE_UNISTD_H-0\(.*\) may be/ 1\1 was/" > zconf.temp.h
mv zconf.temp.h zconf.h
echo "Checking for unistd.h... Yes." | tee -a configure.log
else
echo "Checking for unistd.h... No." | tee -a configure.log
fi
echo >> configure.log
# check for stdarg.h and save result in zconf.h
cat > $test.c <<EOF
#include <stdarg.h>
int main() { return 0; }
EOF
if try $CC -c $CFLAGS $test.c; then
sed < zconf.h "/^#if HAVE_STDARG_H-0.* may be/s/ HAVE_STDARG_H-0\(.*\) may be/ 1\1 was/" > zconf.temp.h
mv zconf.temp.h zconf.h
echo "Checking for stdarg.h... Yes." | tee -a configure.log
else
echo "Checking for stdarg.h... No." | tee -a configure.log
fi
# if the z_ prefix was requested, save that in zconf.h
|
| ︙ | ︙ | |||
614 615 616 617 618 619 620 | mv zconf.temp.h zconf.h OBJC='$(OBJZ)' PIC_OBJC='$(PIC_OBJZ)' fi # if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X if test $cover -eq 1; then | < | 689 690 691 692 693 694 695 696 697 698 699 700 701 702 |
mv zconf.temp.h zconf.h
OBJC='$(OBJZ)'
PIC_OBJC='$(PIC_OBJZ)'
fi
# if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
if test $cover -eq 1; then
if test -n "$GCC_CLASSIC"; then
CC=$GCC_CLASSIC
fi
fi
echo >> configure.log
|
| ︙ | ︙ | |||
659 660 661 662 663 664 665 |
return 0;
}
int main()
{
return (mytest("Hello%d\n", 1));
}
EOF
| | | 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 |
return 0;
}
int main()
{
return (mytest("Hello%d\n", 1));
}
EOF
if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then
echo "Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log
echo >> configure.log
cat >$test.c <<EOF
#include <stdio.h>
#include <stdarg.h>
int mytest(const char *fmt, ...)
|
| ︙ | ︙ | |||
699 700 701 702 703 704 705 |
else
CFLAGS="$CFLAGS -DNO_vsnprintf"
SFLAGS="$SFLAGS -DNO_vsnprintf"
echo "Checking for vsnprintf() in stdio.h... No." | tee -a configure.log
echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log
echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
echo " vulnerabilities." | tee -a configure.log
| | > > > | 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 |
else
CFLAGS="$CFLAGS -DNO_vsnprintf"
SFLAGS="$SFLAGS -DNO_vsnprintf"
echo "Checking for vsnprintf() in stdio.h... No." | tee -a configure.log
echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log
echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
echo " vulnerabilities." | tee -a configure.log
if test $insecure -ne 1; then
echo " The --insecure option must be provided to ./configure in order to" | tee -a configure.log
echo " compile using the insecure vsprintf() function." | tee -a configure.log
fi
echo >> configure.log
cat >$test.c <<EOF
#include <stdio.h>
#include <stdarg.h>
int mytest(const char *fmt, ...)
{
int n;
|
| ︙ | ︙ | |||
749 750 751 752 753 754 755 |
}
int main()
{
return (mytest());
}
EOF
| | | 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 |
}
int main()
{
return (mytest());
}
EOF
if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then
echo "Checking for snprintf() in stdio.h... Yes." | tee -a configure.log
echo >> configure.log
cat >$test.c <<EOF
#include <stdio.h>
int mytest()
{
|
| ︙ | ︙ | |||
783 784 785 786 787 788 789 |
else
CFLAGS="$CFLAGS -DNO_snprintf"
SFLAGS="$SFLAGS -DNO_snprintf"
echo "Checking for snprintf() in stdio.h... No." | tee -a configure.log
echo " WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log
echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
echo " vulnerabilities." | tee -a configure.log
| | > > > | 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 |
else
CFLAGS="$CFLAGS -DNO_snprintf"
SFLAGS="$SFLAGS -DNO_snprintf"
echo "Checking for snprintf() in stdio.h... No." | tee -a configure.log
echo " WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log
echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
echo " vulnerabilities." | tee -a configure.log
if test $insecure -ne 1; then
echo " The --insecure option must be provided to ./configure in order to" | tee -a configure.log
echo " compile using the insecure sprintf() function." | tee -a configure.log
fi
echo >> configure.log
cat >$test.c <<EOF
#include <stdio.h>
int mytest()
{
char buf[20];
return sprintf(buf, "%s", "foo");
|
| ︙ | ︙ | |||
830 831 832 833 834 835 836 837 838 839 840 841 842 843 |
CFLAGS="$CFLAGS -DHAVE_HIDDEN"
SFLAGS="$SFLAGS -DHAVE_HIDDEN"
echo "Checking for attribute(visibility) support... Yes." | tee -a configure.log
else
echo "Checking for attribute(visibility) support... No." | tee -a configure.log
fi
fi
# show the results in the log
echo >> configure.log
echo ALL = $ALL >> configure.log
echo AR = $AR >> configure.log
echo ARFLAGS = $ARFLAGS >> configure.log
echo CC = $CC >> configure.log
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 |
CFLAGS="$CFLAGS -DHAVE_HIDDEN"
SFLAGS="$SFLAGS -DHAVE_HIDDEN"
echo "Checking for attribute(visibility) support... Yes." | tee -a configure.log
else
echo "Checking for attribute(visibility) support... No." | tee -a configure.log
fi
fi
# check for ibm s390x build
HAVE_S390X=0
cat > $test.c << EOF
#ifndef __s390x__
#error
#endif
EOF
if try $CC -c $CFLAGS $test.c; then
echo "Checking for s390x build ... Yes." | tee -a configure.log
HAVE_S390X=1
else
echo "Checking for s390x build ... No." | tee -a configure.log
fi
# check for ibm s390x vx vector extensions
HAVE_S390X_VX=0
if test $HAVE_S390X -eq 1 && test $enable_crcvx -eq 1 ; then
# preset the compiler specific flags
if test $clang -eq 1; then
VGFMAFLAG=-fzvector
else
VGFMAFLAG=-mzarch
fi
cat > $test.c <<EOF
#ifndef __s390x__
#error
#endif
#include <vecintrin.h>
int main(void) {
unsigned long long a __attribute__((vector_size(16))) = { 0 };
unsigned long long b __attribute__((vector_size(16))) = { 0 };
unsigned char c __attribute__((vector_size(16))) = { 0 };
c = vec_gfmsum_accum_128(a, b, c);
return c[0];
}
EOF
# cflags already contains a valid march
if try $CC -c $CFLAGS $VGFMAFLAG $test.c; then
echo "Checking for s390x vx vector extension ... Yes." | tee -a configure.log
HAVE_S390X_VX=1
# or set march for our compile units
elif try $CC -c $CFLAGS $VGFMAFLAG -march=z13 $test.c; then
echo "Checking for s390x vx vector extension (march=z13) ... Yes." | tee -a configure.log
HAVE_S390X_VX=1
VGFMAFLAG="$VGFMAFLAG -march=z13"
# else we are not on s390x
else
echo "Checking for s390x vx vector extension ... No." | tee -a configure.log
fi
# prepare compiling for s390x
if test $HAVE_S390X_VX -eq 1; then
CFLAGS="$CFLAGS -DHAVE_S390X_VX"
SFLAGS="$SFLAGS -DHAVE_S390X_VX"
OBJC="$OBJC crc32_vx.o"
PIC_OBJC="$PIC_OBJC crc32_vx.lo"
else
# target has no vx extension
VGFMAFLAG=""
fi
fi
# show the results in the log
echo >> configure.log
echo ALL = $ALL >> configure.log
echo AR = $AR >> configure.log
echo ARFLAGS = $ARFLAGS >> configure.log
echo CC = $CC >> configure.log
|
| ︙ | ︙ | |||
862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 |
echo exec_prefix = $exec_prefix >> configure.log
echo includedir = $includedir >> configure.log
echo libdir = $libdir >> configure.log
echo mandir = $mandir >> configure.log
echo prefix = $prefix >> configure.log
echo sharedlibdir = $sharedlibdir >> configure.log
echo uname = $uname >> configure.log
# update Makefile with the configure results
sed < ${SRCDIR}Makefile.in "
/^CC *=/s#=.*#=$CC#
/^CFLAGS *=/s#=.*#=$CFLAGS#
/^SFLAGS *=/s#=.*#=$SFLAGS#
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
/^LDSHARED *=/s#=.*#=$LDSHARED#
/^CPP *=/s#=.*#=$CPP#
/^STATICLIB *=/s#=.*#=$STATICLIB#
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
| > > > > > | 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 |
echo exec_prefix = $exec_prefix >> configure.log
echo includedir = $includedir >> configure.log
echo libdir = $libdir >> configure.log
echo mandir = $mandir >> configure.log
echo prefix = $prefix >> configure.log
echo sharedlibdir = $sharedlibdir >> configure.log
echo uname = $uname >> configure.log
echo HAVE_S390X = $HAVE_S390X >> configure.log
echo HAVE_S390X_VX = $HAVE_S390X_VX >> configure.log
echo VGFMAFLAG = $VGFMAFLAG >> configure.log
# update Makefile with the configure results
sed < ${SRCDIR}Makefile.in "
/^CC *=/s#=.*#=$CC#
/^GCOV *=/s#=.*#=$GCOV#
/^LLVM_GCOV_FLAG *=/s#=.*#=$LLVM_GCOV_FLAG#
/^CFLAGS *=/s#=.*#=$CFLAGS#
/^SFLAGS *=/s#=.*#=$SFLAGS#
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
/^LDSHARED *=/s#=.*#=$LDSHARED#
/^CPP *=/s#=.*#=$CPP#
/^STATICLIB *=/s#=.*#=$STATICLIB#
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
|
| ︙ | ︙ |
Added compat/zlib/contrib/CMakeLists.txt.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 |
function(zlib_add_contrib_lib name description dir)
option(ZLIB_BUILD_${name} "Enable building of ${description}" OFF)
if(ZLIB_BUILD_${name})
if(NOT DEFINED ZLIB_${name}_BUILD_SHARED)
set(ZLIB_${name}_BUILD_SHARED ${ZLIB_BUILD_SHARED} CACHE BOOL "")
endif(NOT DEFINED ZLIB_${name}_BUILD_SHARED)
if(NOT DEFINED ZLIB_${name}_BUILD_STATIC)
set(ZLIB_${name}_BUILD_STATIC ${ZLIB_BUILD_STATIC} CACHE BOOL "")
endif(NOT DEFINED ZLIB_${name}_BUILD_STATIC)
if(NOT DEFINED ZLIB_${name}_BUILD_TESTING)
set(ZLIB_${name}_BUILD_TESTING ${ZLIB_BUILD_TESTING} CACHE BOOL "")
endif(NOT DEFINED ZLIB_${name}_BUILD_TESTING)
if(NOT DEFINED ZLIB_${name}_INSTALL)
set(ZLIB_${name}_INSTALL ${ZLIB_INSTALL} CACHE BOOL "")
endif(NOT DEFINED ZLIB_${name}_INSTALL)
add_subdirectory(${dir}/)
endif(ZLIB_BUILD_${name})
endfunction(zlib_add_contrib_lib name description dir)
function(zlib_add_contrib_feature name description dir)
if(ARGC EQUAL 4)
set(default_on ${ARGV3})
else()
set(default_on Off)
endif()
option(ZLIB_WITH_${name}
"Enable build ${description}"
${default_on})
if(ZLIB_WITH_${name})
add_subdirectory(${dir}/)
endif(ZLIB_WITH_${name})
endfunction(zlib_add_contrib_feature name description dir)
zlib_add_contrib_feature("GVMAT64"
"of an optimized longest_match for 32 bits x86_64"
gcc_gvmat64)
zlib_add_contrib_feature(INFBACK9 "with support for method 9 deflate" infback9)
zlib_add_contrib_feature(CRC32VX "with S390X-CRC32VX implementation" crc32vx)
zlib_add_contrib_lib(ADA "Ada bindings" ada)
zlib_add_contrib_lib(BLAST "blast binary" blast)
zlib_add_contrib_lib(IOSTREAM3 "IOStream C++ bindings V3" iostream3)
zlib_add_contrib_lib(MINIZIP "minizip library" minizip)
zlib_add_contrib_lib(PUFF "puff decompress library" puff)
if(WIN32)
zlib_add_contrib_lib(TESTZLIB "testzlib binary" testzlib)
if (ZLIB_BUILD_ZLIB1_DLL)
add_subdirectory(zlib1-dll/)
endif (ZLIB_BUILD_ZLIB1_DLL)
option(ZLIB_BUILD_ZLIB1_DLL "Build the legacy zlib + minizip DLL" OFF)
endif(WIN32)
|
Changes to compat/zlib/contrib/README.contrib.
1 2 3 4 5 6 7 8 |
All files under this contrib directory are UNSUPPORTED. They were
provided by users of zlib and were not tested by the authors of zlib.
Use at your own risk. Please contact the authors of the contributions
for help about these, not the zlib authors. Thanks.
ada/ by Dmitriy Anisimkov <anisimkov@yahoo.com>
Support for Ada
| | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
All files under this contrib directory are UNSUPPORTED. They were
provided by users of zlib and were not tested by the authors of zlib.
Use at your own risk. Please contact the authors of the contributions
for help about these, not the zlib authors. Thanks.
ada/ by Dmitriy Anisimkov <anisimkov@yahoo.com>
Support for Ada
See https://zlib-ada.sourceforge.net/
blast/ by Mark Adler <madler@alumni.caltech.edu>
Decompressor for output of PKWare Data Compression Library (DCL)
delphi/ by Cosmin Truta <cosmint@cs.ubbcluj.ro>
Support for Delphi and C++ Builder
|
| ︙ | ︙ | |||
33 34 35 36 37 38 39 |
iostream3/ by Ludwig Schwardt <schwardt@sun.ac.za>
and Kevin Ruland <kevin@rodin.wustl.edu>
Yet another C++ I/O streams interface
minizip/ by Gilles Vollant <info@winimage.com>
Mini zip and unzip based on zlib
Includes Zip64 support by Mathias Svensson <mathias@result42.com>
| | > > > < | | < | < | 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 |
iostream3/ by Ludwig Schwardt <schwardt@sun.ac.za>
and Kevin Ruland <kevin@rodin.wustl.edu>
Yet another C++ I/O streams interface
minizip/ by Gilles Vollant <info@winimage.com>
Mini zip and unzip based on zlib
Includes Zip64 support by Mathias Svensson <mathias@result42.com>
See https://www.winimage.com/zLibDll/minizip.html
pascal/ by Bob Dellaca <bobdl@xtra.co.nz> et al.
Support for Pascal
puff/ by Mark Adler <madler@alumni.caltech.edu>
Small, low memory usage inflate. Also serves to provide an
unambiguous description of the deflate format.
crc32vx/ by Ilya Leoshkevich <iii@linux.ibm.com>
Hardware-accelerated CRC32 on IBM Z with Z13 VX extension.
testzlib/ by Gilles Vollant <info@winimage.com>
Example of the use of zlib
zlib1-dll/
by @Vollstrecker on github.com
Build the legacy zlib1.dll with zlib and minizip.
|
Added compat/zlib/contrib/blast/CMakeLists.txt.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
blast
VERSION 1.3.0
LANGUAGES C
DESCRIPTION "A library for creating zipfiles based in zlib"
HOMEPAGE_URL "https://www.zlib.net")
option(ZLIB_BLAST_BUILD_SHARED "Enable building blast shared library" ON)
option(ZLIB_BLAST_BUILD_STATIC "Enable building blast static library" ON)
option(ZLIB_BLAST_BUILD_TESTING "Enable building tests for blast" ON)
option(ZLIB_BLAST_INSTALL "Enable installation of blast" ON)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
if(WIN32 OR CYGWIN)
set(zlibblast_static_suffix "s")
set(CMAKE_DEBUG_POSTFIX "d")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif(WIN32 OR CYGWIN)
function(blast_findTestEnv testName)
set(testEnv "PATH=")
if(MSVC OR MINGW)
set(separator "\\\;")
else()
set(separator ":")
endif()
string(APPEND testEnv "$<TARGET_FILE_DIR:BLAST::BLAST>${separator}")
string(APPEND testEnv "$ENV{PATH}")
set_tests_properties(${testName} PROPERTIES ENVIRONMENT "${testEnv}")
endfunction(blast_findTestEnv testName)
if(ZLIB_BLAST_BUILD_SHARED)
add_library(zlib_blast_blast SHARED
blast.c
blast.h)
add_library(BLAST::BLAST ALIAS zlib_blast_blast)
if(NOT CYGWIN)
set_target_properties(zlib_blast_blast
PROPERTIES
SOVERSION ${blast_VERSION_MAJOR}
VERSION ${blast_VERSION})
endif(NOT CYGWIN)
set_target_properties(zlib_blast_blast
PROPERTIES
EXPORT_NAME BLAST
OUTPUT_NAME blast)
if(ZLIB_BLAST_BUILD_TESTING)
enable_testing()
add_executable(zlib_blast_blast-test blast-test.c)
target_link_libraries(zlib_blast_blast-test PRIVATE zlib_blast_blast)
add_test(NAME zlib_blast_blast-test
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/tester.cmake
"$<TARGET_FILE:zlib_blast_blast-test>"
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}")
if(MSVC
OR MSYS
OR MINGW
OR CYGWIN)
blast_findtestenv(zlib_blast_blast-test)
endif(
MSVC
OR MSYS
OR MINGW
OR CYGWIN)
endif(ZLIB_BLAST_BUILD_TESTING)
endif(ZLIB_BLAST_BUILD_SHARED)
if(ZLIB_BLAST_BUILD_STATIC)
add_library(zlib_blast_blastStatic STATIC
blast.c
blast.h)
add_library(BLAST::BLASTSTATIC ALIAS zlib_blast_blastStatic)
set_target_properties(zlib_blast_blastStatic
PROPERTIES
EXPORT_NAME BLASTSTATIC
OUTPUT_NAME blast${zlibblast_static_suffix})
if(ZLIB_BLAST_BUILD_TESTING)
enable_testing()
add_executable(zlib_blast_testStatic blast-test.c)
target_link_libraries(zlib_blast_testStatic
PRIVATE zlib_blast_blastStatic)
add_test(NAME zlib_blast_testStatic
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/tester.cmake
"$<TARGET_FILE:zlib_blast_testStatic>"
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}")
endif(ZLIB_BLAST_BUILD_TESTING)
endif(ZLIB_BLAST_BUILD_STATIC)
if(ZLIB_BLAST_BUILD_TESTING)
add_subdirectory(test)
endif(ZLIB_BLAST_BUILD_TESTING)
if(ZLIB_BLAST_INSTALL)
if(ZLIB_BLAST_BUILD_SHARED)
install(
TARGETS zlib_blast_blast
COMPONENT Runtime
EXPORT zlibBlastSharedExport
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(
EXPORT zlibBlastSharedExport
FILE blast-shared.cmake
NAMESPACE BLAST::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/blast)
if(MSVC)
install(
FILES $<TARGET_PDB_FILE:zlib_blast_blast>
COMPONENT Development
DESTINATION ${CMAKE_INSTALL_BINDIR}
CONFIGURATIONS Debug OR RelWithDebInfo
OPTIONAL)
endif(MSVC)
endif(ZLIB_BLAST_BUILD_SHARED)
if(ZLIB_BLAST_BUILD_STATIC)
install(
TARGETS zlib_blast_blastStatic
COMPONENT Development
EXPORT zlibBlastStaticExport
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(
EXPORT zlibBlastStaticExport
FILE blast-static.cmake
NAMESPACE BLAST::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/blast)
endif(ZLIB_BLAST_BUILD_STATIC)
configure_package_config_file(
${blast_SOURCE_DIR}/blastConfig.cmake.in
${blast_BINARY_DIR}/blastConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/blast)
write_basic_package_version_file(
"${blast_BINARY_DIR}/blastConfigVersion.cmake"
VERSION "${blast_VERSION}"
COMPATIBILITY AnyNewerVersion)
install(FILES ${blast_BINARY_DIR}/blastConfig.cmake
${blast_BINARY_DIR}/blastConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/blast)
install(
FILES blast.h
COMPONENT Development
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
endif(ZLIB_BLAST_INSTALL)
|
Changes to compat/zlib/contrib/blast/Makefile.
|
| > > | > | > > > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | all: test libblast.so: blast.c blast.h cc -o libblast.so -shared blast.c blast-test: libblast.so cc -o blast-test.o -c blast-test.c cc -o blast-test blast-test.o libblast.so test: blast-test LD_LIBRARY_PATH=./ ./blast-test < test.pk | cmp - test.txt clean: rm -f libblast.so blast-test blast-test.o |
Added compat/zlib/contrib/blast/blast-test.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 |
#include "blast.h" /* prototype for blast() */
/* Example of how to use blast() */
#include <stdio.h>
#include <stdlib.h>
#define CHUNK 16384
local unsigned inf(void *how, unsigned char **buf)
{
static unsigned char hold[CHUNK];
*buf = hold;
return fread(hold, 1, CHUNK, (FILE *)how);
}
local int outf(void *how, unsigned char *buf, unsigned len)
{
return fwrite(buf, 1, len, (FILE *)how) != len;
}
/* Decompress a PKWare Compression Library stream from stdin to stdout */
int main(void)
{
int ret;
unsigned left;
/* decompress to stdout */
left = 0;
ret = blast(inf, stdin, outf, stdout, &left, NULL);
if (ret != 0)
fprintf(stderr, "blast error: %d\n", ret);
/* count any leftover bytes */
while (getchar() != EOF)
left++;
if (left)
fprintf(stderr, "blast warning: %u unused bytes of input\n", left);
/* return blast() error code */
return ret;
}
|
Changes to compat/zlib/contrib/blast/blast.c.
| ︙ | ︙ | |||
29 30 31 32 33 34 35 | * - Enable the provision of initial input to blast() */ #include <stddef.h> /* for NULL */ #include <setjmp.h> /* for setjmp(), longjmp(), and jmp_buf */ #include "blast.h" /* prototype for blast() */ | < | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
* - Enable the provision of initial input to blast()
*/
#include <stddef.h> /* for NULL */
#include <setjmp.h> /* for setjmp(), longjmp(), and jmp_buf */
#include "blast.h" /* prototype for blast() */
#define MAXBITS 13 /* maximum code length */
#define MAXWIN 4096 /* maximum window size */
/* input and output state */
struct state {
/* input state */
blast_in infun; /* input function provided by user */
|
| ︙ | ︙ | |||
417 418 419 420 421 422 423 |
*in = s.left ? s.in : NULL;
/* write any leftover output and update the error code if needed */
if (err != 1 && s.next && s.outfun(s.outhow, s.out, s.next) && err == 0)
err = 1;
return err;
}
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 416 417 418 419 420 421 422 |
*in = s.left ? s.in : NULL;
/* write any leftover output and update the error code if needed */
if (err != 1 && s.next && s.outfun(s.outhow, s.out, s.next) && err == 0)
err = 1;
return err;
}
|
Changes to compat/zlib/contrib/blast/blast.h.
| ︙ | ︙ | |||
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Mark Adler madler@alumni.caltech.edu
*/
/*
* blast() decompresses the PKWare Data Compression Library (DCL) compressed
* format. It provides the same functionality as the explode() function in
* that library. (Note: PKWare overused the "implode" verb, and the format
* used by their library implode() function is completely different and
* incompatible with the implode compression method supported by PKZIP.)
| > | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Mark Adler madler@alumni.caltech.edu
*/
#define local static /* for local function definitions */
/*
* blast() decompresses the PKWare Data Compression Library (DCL) compressed
* format. It provides the same functionality as the explode() function in
* that library. (Note: PKWare overused the "implode" verb, and the format
* used by their library implode() function is completely different and
* incompatible with the implode compression method supported by PKZIP.)
|
| ︙ | ︙ |
Added compat/zlib/contrib/blast/blastConfig.cmake.in.
> > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
@PACKAGE_INIT@
set(_blast_supported_components "shared" "static")
if(blast_FIND_COMPONENTS)
foreach(_comp ${blast_FIND_COMPONENTS})
if(NOT _comp IN_LIST _blast_supported_components)
set(blast_FOUND False)
set(blast_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
endif(NOT _comp IN_LIST _blast_supported_components)
include("${CMAKE_CURRENT_LIST_DIR}/blast-${_comp}.cmake")
endforeach(_comp ${blast_FIND_COMPONENTS})
else(blast_FIND_COMPONENTS)
foreach(_component_config IN LISTS _blast_supported_components)
include("${CMAKE_CURRENT_LIST_DIR}/blast-${_component_config}.cmake")
endforeach(_component_config IN LISTS _blast_supported_components)
endif(blast_FIND_COMPONENTS)
|
Added compat/zlib/contrib/blast/test/CMakeLists.txt.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# if we are built from with zlib, use this path's)
if(DEFINED ZLIB_BUILD_BLAST)
set(WORK_DIR ${zlib_BINARY_DIR})
set(inst_setup zlib_install)
else(DEFINED ZLIB_BUILD_BLAST)
set(WORK_DIR ${blast_BINARY_DIR})
set(inst_setup zlib_blast_install)
set(ZLIB_ARG "-DZLIB_DIR=${ZLIB_DIR}")
add_test(
NAME zlib_blast_install
COMMAND ${CMAKE_COMMAND} --install ${blast_BINARY_DIR} --prefix
${CMAKE_CURRENT_BINARY_DIR}/test_install --config $<CONFIG>
WORKING_DIRECTORY ${blast_BINARY_DIR})
set_tests_properties(zlib_blast_install
PROPERTIES
FIXTURES_SETUP zlib_blast_install)
endif(DEFINED ZLIB_BUILD_BLAST)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/find_package_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/findpackage_test/CMakeLists.txt @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test/CMakeLists.txt @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_exclude_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test/CMakeLists.txt
@ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/find_package_no_components_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/findpackage_no_components_test/CMakeLists.txt
@ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/find_package_wrong_components_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/findpackage_wrong_components_test/CMakeLists.txt
@ONLY)
# CMAKE_GENERATOR_PLATFORM doesn't work in the if
set(GENERATOR ${CMAKE_GENERATOR_PLATFORM})
if(GENERATOR)
set(PLATFORM "-A ${GENERATOR}")
endif(GENERATOR)
#
# findpackage_test
#
add_test(
NAME zlib_blast_find_package_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG>
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
add_test(
NAME zlib_blast_find_package_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
set_tests_properties(
zlib_blast_find_package_configure
PROPERTIES
FIXTURES_REQUIRED ${inst_setup}
FIXTURES_SETUP blast_fp_config)
set_tests_properties(zlib_blast_find_package_build
PROPERTIES
FIXTURES_REQUIRED blast_fp_config)
#
# add_subdirectory_test
#
add_test(
NAME zlib_blast_add_subdirectory_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG>
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test)
add_test(
NAME zlib_blast_add_subdirectory_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
set_tests_properties(
zlib_blast_add_subdirectory_configure
PROPERTIES
FIXTURES_REQUIRED ${inst_setup}
FIXTURES_SETUP blast_as_config)
set_tests_properties(zlib_blast_add_subdirectory_build
PROPERTIES
FIXTURES_REQUIRED blast_as_config)
#
# add_subdirectory_exclude_test
#
add_test(
NAME zlib_blast_add_subdirectory_exclude_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG>
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test)
add_test(
NAME zlib_blast_add_subdirectory_exclude_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
set_tests_properties(zlib_blast_add_subdirectory_exclude_configure
PROPERTIES
FIXTURES_REQUIRED ${inst_setup}
FIXTURES_SETUP blast_asx_config)
set_tests_properties(zlib_blast_add_subdirectory_exclude_build
PROPERTIES
FIXTURES_REQUIRED blast_asx_config)
#
# findpackage_no_components_test
#
add_test(
NAME zlib_blast_find_package_no_components_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/findpackage_no_components_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_no_components_test)
set_tests_properties(
zlib_blast_find_package_no_components_configure
PROPERTIES
FIXTURES_REQUIRED ${inst_setup})
if(NOT ZLIB_BLAST_BUILD_SHARED OR NOT ZLIB_BLAST_BUILD_STATIC)
set_tests_properties(zlib_blast_find_package_no_components_configure
PROPERTIES
WILL_FAIL TRUE)
endif(NOT ZLIB_BLAST_BUILD_SHARED OR NOT ZLIB_BLAST_BUILD_STATIC)
#
# findpackage_wrong_components_test
#
add_test(
NAME zlib_blast_find_package_wrong_components_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/findpackage_wrong_components_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_wrong_components_test)
set_tests_properties(zlib_blast_find_package_wrong_components_configure
PROPERTIES
FIXTURES_REQUIRED ${inst_setup}
WILL_FAIL TRUE)
|
Added compat/zlib/contrib/blast/test/add_subdirectory_exclude_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
blast_find_package
LANGUAGES C
VERSION @blast_VERSION@)
option(ZLIB_BLAST_BUILD_SHARED "" @ZLIB_BLAST_BUILD_SHARED@)
option(ZLIB_BLAST_BUILD_STATIC "" @ZLIB_BLAST_BUILD_STATIC@)
option(ZLIB_BLAST_BUILD_TESTING "" @ZLIB_BLAST_BUILD_TESTING@)
add_subdirectory(@blast_SOURCE_DIR@
${CMAKE_CURRENT_BINARY_DIR}/blast
EXCLUDE_FROM_ALL)
set(BLAST_SRCS
@blast_SOURCE_DIR@/blast-test.c)
if(ZLIB_BLAST_BUILD_SHARED)
add_executable(test_example ${BLAST_SRCS})
target_link_libraries(test_example BLAST::BLAST)
endif(ZLIB_BLAST_BUILD_SHARED)
if(ZLIB_BLAST_BUILD_STATIC)
add_executable(test_example_static ${BLAST_SRCS})
target_link_libraries(test_example_static BLAST::BLASTSTATIC)
endif(ZLIB_BLAST_BUILD_STATIC)
|
Added compat/zlib/contrib/blast/test/add_subdirectory_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
blast_find_package
LANGUAGES C
VERSION @blast_VERSION@)
option(ZLIB_BLAST_BUILD_SHARED "" @ZLIB_BLAST_BUILD_SHARED@)
option(ZLIB_BLAST_BUILD_STATIC "" @ZLIB_BLAST_BUILD_STATIC@)
option(ZLIB_BLAST_BUILD_TESTING "" @ZLIB_BLAST_BUILD_TESTING@)
add_subdirectory(@blast_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/blast)
set(BLAST_SRCS
@blast_SOURCE_DIR@/blast-test.c)
if(ZLIB_BLAST_BUILD_SHARED)
add_executable(test_example ${BLAST_SRCS})
target_link_libraries(test_example BLAST::BLAST)
endif(ZLIB_BLAST_BUILD_SHARED)
if(ZLIB_BLAST_BUILD_STATIC)
add_executable(test_example_static ${BLAST_SRCS})
target_link_libraries(test_example_static BLAST::BLASTSTATIC)
endif(ZLIB_BLAST_BUILD_STATIC)
|
Added compat/zlib/contrib/blast/test/find_package_no_components_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
blast_find_package
LANGUAGES C
VERSION @blast_VERSION@)
option(ZLIB_BLAST_BUILD_SHARED "" @ZLIB_BLAST_BUILD_SHARED@)
option(ZLIB_BLAST_BUILD_STATIC "" @ZLIB_BLAST_BUILD_STATIC@)
find_package(blast REQUIRED CONFIG)
set(BLAST_SRCS
@blast_SOURCE_DIR@/blast-test.c)
if(ZLIB_BLAST_BUILD_SHARED)
add_executable(test_example ${BLAST_SRCS})
target_link_libraries(test_example BLAST::BLAST)
endif(ZLIB_BLAST_BUILD_SHARED)
if(ZLIB_BLAST_BUILD_STATIC)
add_executable(test_example_static ${BLAST_SRCS})
target_link_libraries(test_example_static BLAST::BLASTSTATIC)
endif(ZLIB_BLAST_BUILD_STATIC)
|
Added compat/zlib/contrib/blast/test/find_package_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
blast_find_package
LANGUAGES C
VERSION @blast_VERSION@)
option(ZLIB_BLAST_BUILD_SHARED "" @ZLIB_BLAST_BUILD_SHARED@)
option(ZLIB_BLAST_BUILD_STATIC "" @ZLIB_BLAST_BUILD_STATIC@)
set(BLAST_SRCS
@blast_SOURCE_DIR@/blast-test.c)
if(ZLIB_BLAST_BUILD_SHARED)
find_package(blast REQUIRED COMPONENTS shared CONFIG)
add_executable(test_example ${BLAST_SRCS})
target_link_libraries(test_example BLAST::BLAST)
endif(ZLIB_BLAST_BUILD_SHARED)
if(ZLIB_BLAST_BUILD_STATIC)
find_package(blast REQUIRED COMPONENTS static CONFIG)
add_executable(test_example_static ${BLAST_SRCS})
target_link_libraries(test_example_static BLAST::BLASTSTATIC)
endif(ZLIB_BLAST_BUILD_STATIC)
|
Added compat/zlib/contrib/blast/test/find_package_wrong_components_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
blast_find_package
LANGUAGES C
VERSION @blast_VERSION@)
option(ZLIB_BLAST_BUILD_SHARED "" @ZLIB_BLAST_BUILD_SHARED@)
option(ZLIB_BLAST_BUILD_STATIC "" @ZLIB_BLAST_BUILD_STATIC@)
find_package(blast REQUIRED COMPONENTS wrong CONFIG)
set(BLAST_SRCS
@blast_SOURCE_DIR@/blast-test.c)
if(ZLIB_BLAST_BUILD_SHARED)
add_executable(test_example ${BLAST_SRCS})
target_link_libraries(test_example BLAST::BLAST)
endif(ZLIB_BLAST_BUILD_SHARED)
if(ZLIB_BLAST_BUILD_STATIC)
add_executable(test_example_static ${BLAST_SRCS})
target_link_libraries(test_example_static BLAST::BLASTSTATIC)
endif(ZLIB_BLAST_BUILD_STATIC)
|
Added compat/zlib/contrib/blast/tester.cmake.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
cmake_minimum_required(VERSION 3.12...3.31)
#CMAKE_ARGV0 = ${CMAKE_COMMAND}
#CMAKE_ARGV1 = -P
#CMAKE_ARGV2 = ${CMAKE_CURRENT_SOURCE_DIR}/tester.cmake
#CMAKE_ARGV3 = "$<TARGET_FILE:blast-test>"
#CMAKE_ARGV4 = "${CMAKE_CURRENT_SOURCE_DIR}"
#CMAKE_ARGV5 = "${CMAKE_CURRENT_BINARY_DIR}")
execute_process(COMMAND ${CMAKE_ARGV3}
INPUT_FILE "${CMAKE_ARGV4}/test.pk"
OUTPUT_FILE "${CMAKE_ARGV5}/output.txt"
RESULT_VARIABLE RESULT)
if(RESULT)
message(FATAL_ERROR "Command exitited with: ${RESULT}")
endif(RESULT)
execute_process(COMMAND ${CMAKE_ARGV0} -E compare_files
"${CMAKE_ARGV4}/test.txt"
"${CMAKE_ARGV5}/output.txt"
RESULT_VARIABLE RESULT)
file(REMOVE "${CMAKE_ARGV5}/output.txt")
if(RESULT)
message(FATAL_ERROR "Files differ")
endif(RESULT)
|
Added compat/zlib/contrib/crc32vx/CMakeLists.txt.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 |
# check if we compile for IBM s390x
#
CHECK_C_SOURCE_COMPILES("
#ifndef __s390x__
#error
#endif
int main() {return 0;}
" HAS_S390X_SUPPORT)
#
# Check for IBM S390X - VX extensions
#
if(ZLIB_WITH_CRC32VX AND HAS_S390X_SUPPORT)
# preset the compiler specific flags
if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(VGFMAFLAG "-fzvector")
else()
set(VGFMAFLAG "-mzarch")
endif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(S390X_VX_TEST
"#ifndef __s390x__ \n\
#error \n\
#endif \n\
#include <vecintrin.h> \n\
int main(void) { \
unsigned long long a __attribute__((vector_size(16))) = { 0 }; \
unsigned long long b __attribute__((vector_size(16))) = { 0 }; \
unsigned char c __attribute__((vector_size(16))) = { 0 }; \
c = vec_gfmsum_accum_128(a, b, c); \
return c[0]; \
}")
# cflags already contains a valid march
set(CMAKE_REQUIRED_FLAGS "${VGFMAFLAG}")
check_c_source_compiles("${S390X_VX_TEST}" HAS_S390X_VX_SUPPORT)
unset(CMAKE_REQUIRED_FLAGS)
# or set march for our compile units
if(NOT HAS_S390X_VX_SUPPORT)
set(CMAKE_REQUIRED_FLAGS "${VGFMAFLAG} -march=z13")
check_c_source_compiles("${S390X_VX_TEST}" HAS_Z13_S390X_VX_SUPPORT)
unset(CMAKE_REQUIRED_FLAGS )
list(APPEND VGFMAFLAG "-march=z13")
endif(NOT HAS_S390X_VX_SUPPORT)
# prepare compiling for s390x
if(HAS_S390X_VX_SUPPORT OR HAS_Z13_S390X_VX_SUPPORT)
if(ZLIB_BUILD_SHARED)
target_sources(zlib
PRIVATE
crc32_vx.c
crc32_vx_hooks.h)
target_compile_definitions(zlib PUBLIC -DHAVE_S390X_VX=1)
endif(ZLIB_BUILD_SHARED)
if(ZLIB_BUILD_STATIC)
target_sources(zlibstatic
PRIVATE
crc32_vx.c
crc32_vx_hooks.h)
target_compile_definitions(zlibstatic PUBLIC -DHAVE_S390X_VX=1)
endif(ZLIB_BUILD_STATIC)
set_source_files_properties(
crc32_vx.c
PROPERTIES COMPILE_OPTIONS "${VGFMAFLAG}")
endif(HAS_S390X_VX_SUPPORT OR HAS_Z13_S390X_VX_SUPPORT)
endif(ZLIB_WITH_CRC32VX AND HAS_S390X_SUPPORT)
|
Added compat/zlib/contrib/crc32vx/README.
> > > > > > > > > | 1 2 3 4 5 6 7 8 9 |
IBM Z mainframes starting from version z13 provide vector instructions, which
allows vectorization of crc32. This extension is build by default when targeting
ibm s390x. However this extension can disabled if desired:
# for configure build
$ ./configure --disable-crcvx
# for cmake build
$ cmake .. -DZLIB_CRC32VX=off
|
Added compat/zlib/contrib/crc32vx/crc32_vx.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
/*
* Hardware-accelerated CRC-32 variants for Linux on z Systems
*
* Use the z/Architecture Vector Extension Facility to accelerate the
* computing of bitreflected CRC-32 checksums.
*
* This CRC-32 implementation algorithm is bitreflected and processes
* the least-significant bit first (Little-Endian).
*
* This code was originally written by Hendrik Brueckner
* <brueckner@linux.vnet.ibm.com> for use in the Linux kernel and has been
* relicensed under the zlib license.
*/
#define Z_ONCE
#include "../../zutil.h"
#include "crc32_vx_hooks.h"
#include <stdint.h>
#include <stdio.h>
#include <vecintrin.h>
#include <sys/auxv.h>
#ifdef __clang__
# if ((__clang_major__ == 18) || (__clang_major__ == 19 && (__clang_minor__ < 1 || (__clang_minor__ == 1 && __clang_patchlevel__ < 2))))
# error crc32_vx optimizations are broken due to compiler bug in Clang versions: 18.0.0 <= clang_version < 19.1.2. \
Either disable the zlib crc32_vx optimization, or switch to another compiler/compiler version.
# endif
#endif
#define VX_MIN_LEN 64
#define VX_ALIGNMENT 16L
#define VX_ALIGN_MASK (VX_ALIGNMENT - 1)
typedef unsigned char uv16qi __attribute__((vector_size(16)));
typedef unsigned int uv4si __attribute__((vector_size(16)));
typedef unsigned long long uv2di __attribute__((vector_size(16)));
local uint32_t crc32_le_vgfm_16(uint32_t crc, const unsigned char *buf, size_t len) {
/*
* The CRC-32 constant block contains reduction constants to fold and
* process particular chunks of the input data stream in parallel.
*
* For the CRC-32 variants, the constants are precomputed according to
* these definitions:
*
* R1 = [(x4*128+32 mod P'(x) << 32)]' << 1
* R2 = [(x4*128-32 mod P'(x) << 32)]' << 1
* R3 = [(x128+32 mod P'(x) << 32)]' << 1
* R4 = [(x128-32 mod P'(x) << 32)]' << 1
* R5 = [(x64 mod P'(x) << 32)]' << 1
* R6 = [(x32 mod P'(x) << 32)]' << 1
*
* The bitreflected Barret reduction constant, u', is defined as
* the bit reversal of floor(x**64 / P(x)).
*
* where P(x) is the polynomial in the normal domain and the P'(x) is the
* polynomial in the reversed (bitreflected) domain.
*
* CRC-32 (IEEE 802.3 Ethernet, ...) polynomials:
*
* P(x) = 0x04C11DB7
* P'(x) = 0xEDB88320
*/
const uv16qi perm_le2be = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; /* BE->LE mask */
const uv2di r2r1 = {0x1C6E41596, 0x154442BD4}; /* R2, R1 */
const uv2di r4r3 = {0x0CCAA009E, 0x1751997D0}; /* R4, R3 */
const uv2di r5 = {0, 0x163CD6124}; /* R5 */
const uv2di ru_poly = {0, 0x1F7011641}; /* u' */
const uv2di crc_poly = {0, 0x1DB710641}; /* P'(x) << 1 */
/*
* Load the initial CRC value.
*
* The CRC value is loaded into the rightmost word of the
* vector register and is later XORed with the LSB portion
* of the loaded input data.
*/
uv2di v0 = {0, 0};
v0 = (uv2di)vec_insert(crc, (uv4si)v0, 3);
/* Load a 64-byte data chunk and XOR with CRC */
uv2di v1 = vec_perm(((uv2di *)buf)[0], ((uv2di *)buf)[0], perm_le2be);
uv2di v2 = vec_perm(((uv2di *)buf)[1], ((uv2di *)buf)[1], perm_le2be);
uv2di v3 = vec_perm(((uv2di *)buf)[2], ((uv2di *)buf)[2], perm_le2be);
uv2di v4 = vec_perm(((uv2di *)buf)[3], ((uv2di *)buf)[3], perm_le2be);
v1 ^= v0;
buf += 64;
len -= 64;
while (len >= 64) {
/* Load the next 64-byte data chunk */
uv16qi part1 = vec_perm(((uv16qi *)buf)[0], ((uv16qi *)buf)[0], perm_le2be);
uv16qi part2 = vec_perm(((uv16qi *)buf)[1], ((uv16qi *)buf)[1], perm_le2be);
uv16qi part3 = vec_perm(((uv16qi *)buf)[2], ((uv16qi *)buf)[2], perm_le2be);
uv16qi part4 = vec_perm(((uv16qi *)buf)[3], ((uv16qi *)buf)[3], perm_le2be);
/*
* Perform a GF(2) multiplication of the doublewords in V1 with
* the R1 and R2 reduction constants in V0. The intermediate result
* is then folded (accumulated) with the next data chunk in PART1 and
* stored in V1. Repeat this step for the register contents
* in V2, V3, and V4 respectively.
*/
v1 = (uv2di)vec_gfmsum_accum_128(r2r1, v1, part1);
v2 = (uv2di)vec_gfmsum_accum_128(r2r1, v2, part2);
v3 = (uv2di)vec_gfmsum_accum_128(r2r1, v3, part3);
v4 = (uv2di)vec_gfmsum_accum_128(r2r1, v4, part4);
buf += 64;
len -= 64;
}
/*
* Fold V1 to V4 into a single 128-bit value in V1. Multiply V1 with R3
* and R4 and accumulating the next 128-bit chunk until a single 128-bit
* value remains.
*/
v1 = (uv2di)vec_gfmsum_accum_128(r4r3, v1, (uv16qi)v2);
v1 = (uv2di)vec_gfmsum_accum_128(r4r3, v1, (uv16qi)v3);
v1 = (uv2di)vec_gfmsum_accum_128(r4r3, v1, (uv16qi)v4);
while (len >= 16) {
/* Load next data chunk */
v2 = vec_perm(*(uv2di *)buf, *(uv2di *)buf, perm_le2be);
/* Fold next data chunk */
v1 = (uv2di)vec_gfmsum_accum_128(r4r3, v1, (uv16qi)v2);
buf += 16;
len -= 16;
}
/*
* Set up a vector register for byte shifts. The shift value must
* be loaded in bits 1-4 in byte element 7 of a vector register.
* Shift by 8 bytes: 0x40
* Shift by 4 bytes: 0x20
*/
uv16qi v9 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
v9 = vec_insert((unsigned char)0x40, v9, 7);
/*
* Prepare V0 for the next GF(2) multiplication: shift V0 by 8 bytes
* to move R4 into the rightmost doubleword and set the leftmost
* doubleword to 0x1.
*/
v0 = vec_srb(r4r3, (uv2di)v9);
v0[0] = 1;
/*
* Compute GF(2) product of V1 and V0. The rightmost doubleword
* of V1 is multiplied with R4. The leftmost doubleword of V1 is
* multiplied by 0x1 and is then XORed with rightmost product.
* Implicitly, the intermediate leftmost product becomes padded
*/
v1 = (uv2di)vec_gfmsum_128(v0, v1);
/*
* Now do the final 32-bit fold by multiplying the rightmost word
* in V1 with R5 and XOR the result with the remaining bits in V1.
*
* To achieve this by a single VGFMAG, right shift V1 by a word
* and store the result in V2 which is then accumulated. Use the
* vector unpack instruction to load the rightmost half of the
* doubleword into the rightmost doubleword element of V1; the other
* half is loaded in the leftmost doubleword.
* The vector register with CONST_R5 contains the R5 constant in the
* rightmost doubleword and the leftmost doubleword is zero to ignore
* the leftmost product of V1.
*/
v9 = vec_insert((unsigned char)0x20, v9, 7);
v2 = vec_srb(v1, (uv2di)v9);
v1 = vec_unpackl((uv4si)v1); /* Split rightmost doubleword */
v1 = (uv2di)vec_gfmsum_accum_128(r5, v1, (uv16qi)v2);
/*
* Apply a Barret reduction to compute the final 32-bit CRC value.
*
* The input values to the Barret reduction are the degree-63 polynomial
* in V1 (R(x)), degree-32 generator polynomial, and the reduction
* constant u. The Barret reduction result is the CRC value of R(x) mod
* P(x).
*
* The Barret reduction algorithm is defined as:
*
* 1. T1(x) = floor( R(x) / x^32 ) GF2MUL u
* 2. T2(x) = floor( T1(x) / x^32 ) GF2MUL P(x)
* 3. C(x) = R(x) XOR T2(x) mod x^32
*
* Note: The leftmost doubleword of vector register containing
* CONST_RU_POLY is zero and, thus, the intermediate GF(2) product
* is zero and does not contribute to the final result.
*/
/* T1(x) = floor( R(x) / x^32 ) GF2MUL u */
v2 = vec_unpackl((uv4si)v1);
v2 = (uv2di)vec_gfmsum_128(ru_poly, v2);
/*
* Compute the GF(2) product of the CRC polynomial with T1(x) in
* V2 and XOR the intermediate result, T2(x), with the value in V1.
* The final result is stored in word element 2 of V2.
*/
v2 = vec_unpackl((uv4si)v2);
v2 = (uv2di)vec_gfmsum_accum_128(crc_poly, v2, (uv16qi)v1);
return ((uv4si)v2)[2];
}
local unsigned long s390_crc32_vx(unsigned long crc, const unsigned char FAR *buf, z_size_t len)
{
uintptr_t prealign, aligned, remaining;
if (buf == Z_NULL) return 0UL;
if (len < VX_MIN_LEN + VX_ALIGN_MASK)
return crc32_z(crc, buf, len);
if ((uintptr_t)buf & VX_ALIGN_MASK) {
prealign = VX_ALIGNMENT - ((uintptr_t)buf & VX_ALIGN_MASK);
len -= prealign;
crc = crc32_z(crc, buf, prealign);
buf += prealign;
}
aligned = len & ~VX_ALIGN_MASK;
remaining = len & VX_ALIGN_MASK;
crc = crc32_le_vgfm_16(crc ^ 0xffffffff, buf, (size_t)aligned) ^ 0xffffffff;
if (remaining)
crc = crc32_z(crc, buf + aligned, remaining);
return crc;
}
local z_once_t s390_crc32_made = Z_ONCE_INIT;
local void s390_crc32_setup() {
unsigned long hwcap = getauxval(AT_HWCAP);
if (hwcap & HWCAP_S390_VX)
crc32_z_hook = s390_crc32_vx;
else
crc32_z_hook = crc32_z;
}
local unsigned long s390_crc32_init(unsigned long crc, const unsigned char FAR *buf, z_size_t len)
{
z_once(&s390_crc32_made,s390_crc32_setup);
return crc32_z_hook(crc, buf, len);
}
ZLIB_INTERNAL unsigned long (*crc32_z_hook)(unsigned long crc, const unsigned char FAR *buf, z_size_t len) = s390_crc32_init;
|
Added compat/zlib/contrib/crc32vx/crc32_vx_hooks.h.
> > > > > > > > > | 1 2 3 4 5 6 7 8 9 | #ifndef CRC32_VX_HOOKS_H #define CRC32_VX_HOOKS_H /** * CRC HOOKS */ ZLIB_INTERNAL extern unsigned long (*crc32_z_hook)(unsigned long crc, const unsigned char FAR *buf, z_size_t len); #endif /* CRC32_VX_HOOKS_H */ |
Changes to compat/zlib/contrib/delphi/ZLib.pas.
| ︙ | ︙ | |||
148 149 150 151 152 153 154 |
InBytes = number of bytes in InBuf
Out: OutBuf = ptr to user-allocated buffer to contain decompressed data
BufSize = number of bytes in OutBuf }
procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer;
const OutBuf: Pointer; BufSize: Integer);
const
| | | 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
InBytes = number of bytes in InBuf
Out: OutBuf = ptr to user-allocated buffer to contain decompressed data
BufSize = number of bytes in OutBuf }
procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer;
const OutBuf: Pointer; BufSize: Integer);
const
zlib_version = '1.3.2';
type
EZlibError = class(Exception);
ECompressionError = class(EZlibError);
EDecompressionError = class(EZlibError);
implementation
|
| ︙ | ︙ |
Changes to compat/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs.
1 2 3 4 | // // © Copyright Henrik Ravn 2004 // // Use, modification and distribution are subject to the Boost Software License, Version 1.0. | | | 1 2 3 4 5 6 7 8 9 10 11 12 | // // © Copyright Henrik Ravn 2004 // // Use, modification and distribution are subject to the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) // using System; using System.Runtime.InteropServices; using System.Text; |
| ︙ | ︙ |
Changes to compat/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs.
1 2 3 4 | // // © Copyright Henrik Ravn 2004 // // Use, modification and distribution are subject to the Boost Software License, Version 1.0. | | | 1 2 3 4 5 6 7 8 9 10 11 12 |
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Diagnostics;
namespace DotZLib
{
|
| ︙ | ︙ |
Changes to compat/zlib/contrib/dotzlib/DotZLib/CodecBase.cs.
1 2 3 4 | // // © Copyright Henrik Ravn 2004 // // Use, modification and distribution are subject to the Boost Software License, Version 1.0. | | | 1 2 3 4 5 6 7 8 9 10 11 12 |
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Runtime.InteropServices;
namespace DotZLib
{
|
| ︙ | ︙ |
Changes to compat/zlib/contrib/dotzlib/DotZLib/Deflater.cs.
1 2 3 4 | // // © Copyright Henrik Ravn 2004 // // Use, modification and distribution are subject to the Boost Software License, Version 1.0. | | | 1 2 3 4 5 6 7 8 9 10 11 12 | // // © Copyright Henrik Ravn 2004 // // Use, modification and distribution are subject to the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) // using System; using System.Diagnostics; using System.Runtime.InteropServices; namespace DotZLib |
| ︙ | ︙ |
Changes to compat/zlib/contrib/dotzlib/DotZLib/DotZLib.cs.
1 2 3 4 | // // © Copyright Henrik Ravn 2004 // // Use, modification and distribution are subject to the Boost Software License, Version 1.0. | | | 1 2 3 4 5 6 7 8 9 10 11 12 | // // © Copyright Henrik Ravn 2004 // // Use, modification and distribution are subject to the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) // using System; using System.IO; using System.Runtime.InteropServices; using System.Text; |
| ︙ | ︙ |
Changes to compat/zlib/contrib/dotzlib/DotZLib/GZipStream.cs.
1 2 3 4 | // // © Copyright Henrik Ravn 2004 // // Use, modification and distribution are subject to the Boost Software License, Version 1.0. | | | 1 2 3 4 5 6 7 8 9 10 11 12 | // // © Copyright Henrik Ravn 2004 // // Use, modification and distribution are subject to the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) // using System; using System.IO; using System.Runtime.InteropServices; namespace DotZLib |
| ︙ | ︙ |
Changes to compat/zlib/contrib/dotzlib/DotZLib/Inflater.cs.
1 2 3 4 | // // © Copyright Henrik Ravn 2004 // // Use, modification and distribution are subject to the Boost Software License, Version 1.0. | | | 1 2 3 4 5 6 7 8 9 10 11 12 | // // © Copyright Henrik Ravn 2004 // // Use, modification and distribution are subject to the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) // using System; using System.Diagnostics; using System.Runtime.InteropServices; namespace DotZLib |
| ︙ | ︙ |
Changes to compat/zlib/contrib/dotzlib/DotZLib/UnitTests.cs.
1 2 3 4 | // // © Copyright Henrik Ravn 2004 // // Use, modification and distribution are subject to the Boost Software License, Version 1.0. | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Collections;
using System.IO;
// uncomment the define below to include unit tests
//#define nunit
#if nunit
using NUnit.Framework;
// Unit tests for the DotZLib class library
// ----------------------------------------
//
// Use this with NUnit 2 from https://www.nunit.org
//
namespace DotZLibTests
{
using DotZLib;
// helper methods
|
| ︙ | ︙ | |||
152 153 154 155 156 157 158 |
public class InfoTests
{
#region Info tests
[Test]
public void Info_Version()
{
Info info = new Info();
| | | 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
public class InfoTests
{
#region Info tests
[Test]
public void Info_Version()
{
Info info = new Info();
Assert.AreEqual("1.3.2", Info.Version);
Assert.AreEqual(32, info.SizeOfUInt);
Assert.AreEqual(32, info.SizeOfULong);
Assert.AreEqual(32, info.SizeOfPointer);
Assert.AreEqual(32, info.SizeOfOffset);
}
#endregion
}
|
| ︙ | ︙ |
Changes to compat/zlib/contrib/dotzlib/readme.txt.
| ︙ | ︙ | |||
51 52 53 54 55 56 57 |
will remove all previously built files.
---------------------------------
Copyright (c) Henrik Ravn 2004
Use, modification and distribution are subject to the Boost Software License, Version 1.0.
| | | 51 52 53 54 55 56 57 58 |
will remove all previously built files.
---------------------------------
Copyright (c) Henrik Ravn 2004
Use, modification and distribution are subject to the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
|
Added compat/zlib/contrib/gcc_gvmat64/CMakeLists.txt.
> > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
enable_language(ASM)
# Need to push CMAKE_ASM_COMPILE_OBJECT to cache as otherwise it's not
# available in top-level
set(CMAKE_ASM_COMPILE_OBJECT ${CMAKE_ASM_COMPILE_OBJECT} CACHE INTERNAL "" FORCE)
if(MSVC)
#cmake 4.1 doesn't consider cl an asm compiler
cmake_policy(SET CMP0194 NEW)
endif(MSVC)
if(ZLIB_BUILD_SHARED)
target_sources(zlib PRIVATE gvmat64.S)
endif(ZLIB_BUILD_SHARED)
if(ZLIB_BUILD_STATIC)
target_sources(zlibstatic PRIVATE gvmat64.S)
endif(ZLIB_BUILD_STATIC)
|
Changes to compat/zlib/contrib/gcc_gvmat64/gvmat64.S.
| ︙ | ︙ | |||
26 27 28 29 30 31 32 | ; claim that you wrote the original software. If you use this software ; in a product, an acknowledgment in the product documentation would be ; appreciated but is not required. ; 2. Altered source versions must be plainly marked as such, and must not be ; misrepresented as being the original software ; 3. This notice may not be removed or altered from any source distribution. ; | | < | | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | ; claim that you wrote the original software. If you use this software ; in a product, an acknowledgment in the product documentation would be ; appreciated but is not required. ; 2. Altered source versions must be plainly marked as such, and must not be ; misrepresented as being the original software ; 3. This notice may not be removed or altered from any source distribution. ; ; https://www.zlib.net ; https://www.muppetlabs.com/~breadbox/software/assembly.html ; ; to compile this file for zLib, I use option: ; gcc -c -arch x86_64 gvmat64.S ;uInt longest_match(s, cur_match) ; deflate_state *s; |
| ︙ | ︙ | |||
165 166 167 168 169 170 171 | #define good_match [ rcx + dsGoodMatch] #define nice_match [ rcx + dsNiceMatch] /* ; windows: ; parameter 1 in rcx(deflate state s), param 2 in rdx (cur match) | < < < | | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | #define good_match [ rcx + dsGoodMatch] #define nice_match [ rcx + dsNiceMatch] /* ; windows: ; parameter 1 in rcx(deflate state s), param 2 in rdx (cur match) ; All registers must be preserved across the call, except for ; rax, rcx, rdx, r8, r9, r10, and r11, which are scratch. ; ; gcc on macosx-linux: ; see https://refspecs.linuxbase.org/elf/x86_64-abi-0.99.pdf ; param 1 in rdi, param 2 in rsi ; rbx, rsp, rbp, r12 to r15 must be preserved ;;; Save registers that the compiler may be using, and adjust esp to ;;; make room for our stack frame. |
| ︙ | ︙ |
Added compat/zlib/contrib/infback9/CMakeLists.txt.
> > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
if(ZLIB_BUILD_SHARED)
target_sources(zlib
PRIVATE
infback9.c
inftree9.c
infback9.h
inffix9.h
inftree9.h)
endif(ZLIB_BUILD_SHARED)
if(ZLIB_BUILD_STATIC)
target_sources(zlibstatic
PRIVATE
infback9.c
inftree9.c
infback9.h
inffix9.h
inftree9.h)
endif(ZLIB_BUILD_STATIC)
|
Changes to compat/zlib/contrib/infback9/infback9.c.
| ︙ | ︙ | |||
289 290 291 292 293 294 295 |
break;
case 2: /* dynamic block */
Tracev((stderr, "inflate: dynamic codes block%s\n",
lastblock ? " (last)" : ""));
mode = TABLE;
break;
case 3:
| | | | 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
break;
case 2: /* dynamic block */
Tracev((stderr, "inflate: dynamic codes block%s\n",
lastblock ? " (last)" : ""));
mode = TABLE;
break;
case 3:
strm->msg = (z_const char *)"invalid block type";
mode = BAD;
}
DROPBITS(2);
break;
case STORED:
/* get and verify stored block length */
BYTEBITS(); /* go to byte boundary */
NEEDBITS(32);
if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
strm->msg = (z_const char *)"invalid stored block lengths";
mode = BAD;
break;
}
length = (unsigned)hold & 0xffff;
Tracev((stderr, "inflate: stored length %lu\n",
length));
INITBITS();
|
| ︙ | ︙ | |||
337 338 339 340 341 342 343 |
state->nlen = BITS(5) + 257;
DROPBITS(5);
state->ndist = BITS(5) + 1;
DROPBITS(5);
state->ncode = BITS(4) + 4;
DROPBITS(4);
if (state->nlen > 286) {
| | | | 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
state->nlen = BITS(5) + 257;
DROPBITS(5);
state->ndist = BITS(5) + 1;
DROPBITS(5);
state->ncode = BITS(4) + 4;
DROPBITS(4);
if (state->nlen > 286) {
strm->msg = (z_const char *)"too many length symbols";
mode = BAD;
break;
}
Tracev((stderr, "inflate: table sizes ok\n"));
/* get code length code lengths (not a typo) */
state->have = 0;
while (state->have < state->ncode) {
NEEDBITS(3);
state->lens[order[state->have++]] = (unsigned short)BITS(3);
DROPBITS(3);
}
while (state->have < 19)
state->lens[order[state->have++]] = 0;
state->next = state->codes;
lencode = (code const FAR *)(state->next);
lenbits = 7;
ret = inflate_table9(CODES, state->lens, 19, &(state->next),
&(lenbits), state->work);
if (ret) {
strm->msg = (z_const char *)"invalid code lengths set";
mode = BAD;
break;
}
Tracev((stderr, "inflate: code lengths ok\n"));
/* get length and distance code code lengths */
state->have = 0;
|
| ︙ | ︙ | |||
382 383 384 385 386 387 388 |
state->lens[state->have++] = here.val;
}
else {
if (here.val == 16) {
NEEDBITS(here.bits + 2);
DROPBITS(here.bits);
if (state->have == 0) {
| | | 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 |
state->lens[state->have++] = here.val;
}
else {
if (here.val == 16) {
NEEDBITS(here.bits + 2);
DROPBITS(here.bits);
if (state->have == 0) {
strm->msg = (z_const char *)"invalid bit length repeat";
mode = BAD;
break;
}
len = (unsigned)(state->lens[state->have - 1]);
copy = 3 + BITS(2);
DROPBITS(2);
}
|
| ︙ | ︙ | |||
405 406 407 408 409 410 411 |
NEEDBITS(here.bits + 7);
DROPBITS(here.bits);
len = 0;
copy = 11 + BITS(7);
DROPBITS(7);
}
if (state->have + copy > state->nlen + state->ndist) {
| | | | | | 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 |
NEEDBITS(here.bits + 7);
DROPBITS(here.bits);
len = 0;
copy = 11 + BITS(7);
DROPBITS(7);
}
if (state->have + copy > state->nlen + state->ndist) {
strm->msg = (z_const char *)"invalid bit length repeat";
mode = BAD;
break;
}
while (copy--)
state->lens[state->have++] = (unsigned short)len;
}
}
/* handle error breaks in while */
if (mode == BAD) break;
/* check for end-of-block code (better have one) */
if (state->lens[256] == 0) {
strm->msg = (z_const char *)"invalid code -- missing end-of-block";
mode = BAD;
break;
}
/* build code tables -- note: do not change the lenbits or distbits
values here (9 and 6) without reading the comments in inftree9.h
concerning the ENOUGH constants, which depend on those values */
state->next = state->codes;
lencode = (code const FAR *)(state->next);
lenbits = 9;
ret = inflate_table9(LENS, state->lens, state->nlen,
&(state->next), &(lenbits), state->work);
if (ret) {
strm->msg = (z_const char *)"invalid literal/lengths set";
mode = BAD;
break;
}
distcode = (code const FAR *)(state->next);
distbits = 6;
ret = inflate_table9(DISTS, state->lens + state->nlen,
state->ndist, &(state->next), &(distbits),
state->work);
if (ret) {
strm->msg = (z_const char *)"invalid distances set";
mode = BAD;
break;
}
Tracev((stderr, "inflate: codes ok\n"));
mode = LEN;
case LEN:
|
| ︙ | ︙ | |||
491 492 493 494 495 496 497 |
Tracevv((stderr, "inflate: end of block\n"));
mode = TYPE;
break;
}
/* invalid code */
if (here.op & 64) {
| | | 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
Tracevv((stderr, "inflate: end of block\n"));
mode = TYPE;
break;
}
/* invalid code */
if (here.op & 64) {
strm->msg = (z_const char *)"invalid literal/length code";
mode = BAD;
break;
}
/* length code -- get extra bits, if any */
extra = (unsigned)(here.op) & 31;
if (extra != 0) {
|
| ︙ | ︙ | |||
523 524 525 526 527 528 529 |
if ((unsigned)(last.bits + here.bits) <= bits) break;
PULLBYTE();
}
DROPBITS(last.bits);
}
DROPBITS(here.bits);
if (here.op & 64) {
| | | | 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 |
if ((unsigned)(last.bits + here.bits) <= bits) break;
PULLBYTE();
}
DROPBITS(last.bits);
}
DROPBITS(here.bits);
if (here.op & 64) {
strm->msg = (z_const char *)"invalid distance code";
mode = BAD;
break;
}
offset = (unsigned)here.val;
/* get distance extra bits, if any */
extra = (unsigned)(here.op) & 15;
if (extra != 0) {
NEEDBITS(extra);
offset += BITS(extra);
DROPBITS(extra);
}
if (offset > WSIZE - (wrap ? 0: left)) {
strm->msg = (z_const char *)"invalid distance too far back";
mode = BAD;
break;
}
Tracevv((stderr, "inflate: distance %lu\n", offset));
/* copy match from window to output */
do {
|
| ︙ | ︙ |
Changes to compat/zlib/contrib/infback9/inftree9.c.
1 | /* inftree9.c -- generate Huffman trees for efficient decoding | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /* inftree9.c -- generate Huffman trees for efficient decoding * Copyright (C) 1995-2026 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #include "zutil.h" #include "inftree9.h" #define MAXBITS 15 const char inflate9_copyright[] = " inflate9 1.3.2 Copyright 1995-2026 Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot include such an acknowledgment, I would appreciate that you keep this copyright string in the executable of your product. */ |
| ︙ | ︙ | |||
55 56 57 58 59 60 61 |
static const unsigned short lbase[31] = { /* Length codes 257..285 base */
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17,
19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115,
131, 163, 195, 227, 3, 0, 0};
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129,
130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132,
| | | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
static const unsigned short lbase[31] = { /* Length codes 257..285 base */
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17,
19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115,
131, 163, 195, 227, 3, 0, 0};
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129,
130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132,
133, 133, 133, 133, 144, 199, 75};
static const unsigned short dbase[32] = { /* Distance codes 0..31 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49,
65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073,
4097, 6145, 8193, 12289, 16385, 24577, 32769, 49153};
static const unsigned short dext[32] = { /* Distance codes 0..31 extra */
128, 128, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132,
133, 133, 134, 134, 135, 135, 136, 136, 137, 137, 138, 138,
|
| ︙ | ︙ |
Changes to compat/zlib/contrib/iostream2/zstream.h.
1 2 3 4 5 6 | /* * * Copyright (c) 1997 * Christian Michelsen Research AS * Advanced Computing * Fantoftvegen 38, 5036 BERGEN, Norway | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 | /* * * Copyright (c) 1997 * Christian Michelsen Research AS * Advanced Computing * Fantoftvegen 38, 5036 BERGEN, Norway * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Christian Michelsen Research AS makes no * representations about the suitability of this software for any |
| ︙ | ︙ |
Added compat/zlib/contrib/iostream3/CMakeLists.txt.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
iostreamV3
VERSION 1.0.0
LANGUAGES CXX
DESCRIPTION "A library for using C++ IOStreams with zlib V3"
HOMEPAGE_URL "https://www.zlib.net")
option(ZLIB_IOSTREAM3_BUILD_SHARED "Enable building blast shared library" ON)
option(ZLIB_IOSTREAM3_BUILD_STATIC "Enable building blast static library" ON)
option(ZLIB_IOSTREAM3_BUILD_TESTING "Enable building tests for blast" ON)
option(ZLIB_IOSTREAM3_INSTALL "Enable installation of iostream" ON)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
if(NOT DEFINED ZLIB_BUILD_IOSTREAM3)
if(ZLIB_IOSTREAM3_BUILD_SHARED)
list(APPEND REQUIRED_COMPONENTS "shared")
endif(ZLIB_IOSTREAM3_BUILD_SHARED)
if(ZLIB_IOSTREAM3_BUILD_STATIC)
list(APPEND REQUIRED_COMPONENTS "static")
endif(ZLIB_IOSTREAM3_BUILD_STATIC)
find_package(ZLIB REQUIRED COMPONENTS ${REQUIRED_COMPONENTS} CONFIG)
endif(NOT DEFINED ZLIB_BUILD_IOSTREAM3)
if(WIN32 OR CYGWIN)
set(zlibIOStream3_static_suffix "s")
set(CMAKE_DEBUG_POSTFIX "d")
endif(WIN32 OR CYGWIN)
function(iostreamv3_findTestEnv testName)
set(testEnv "PATH=")
if(MSVC OR MINGW)
set(separator "\\\;")
else()
set(separator ":")
endif()
string(APPEND testEnv "$<TARGET_FILE_DIR:zlib_iostream3_iostreamv3>${separator}")
string(APPEND testEnv "$<TARGET_FILE_DIR:ZLIB::ZLIB>${separator}")
string(APPEND testEnv "$ENV{PATH}")
set_tests_properties(${testName} PROPERTIES ENVIRONMENT "${testEnv}")
endfunction(iostreamv3_findTestEnv testName)
if(ZLIB_IOSTREAM3_BUILD_SHARED)
add_library(zlib_iostream3_iostreamv3 SHARED
zfstream.cc
zfstream.h)
add_library(IOSTREAMV3::IOSTREAMV3 ALIAS zlib_iostream3_iostreamv3)
if(NOT CYGWIN)
set_target_properties(zlib_iostream3_iostreamv3
PROPERTIES
SOVERSION ${iostreamV3_VERSION_MAJOR}
VERSION ${iostreamV3_VERSION})
endif(NOT CYGWIN)
set_target_properties(zlib_iostream3_iostreamv3
PROPERTIES
EXPORT_NAME IOSTREAMV3
OUTPUT_NAME iostream3)
target_link_libraries(zlib_iostream3_iostreamv3
PUBLIC ZLIB::ZLIB)
if(ZLIB_IOSTREAM3_BUILD_TESTING)
enable_testing()
add_executable(zlib_iostream3_test test.cc zfstream.h)
target_link_libraries(zlib_iostream3_test
PRIVATE zlib_iostream3_iostreamv3)
add_test(NAME zlib_iostream3_test COMMAND zlib_iostream3_test)
set_tests_properties(zlib_iostream3_test
PROPERTIES
FIXTURES_REQUIRED zlib_iostream3_cleanup)
if(MSVC
OR MSYS
OR MINGW
OR CYGWIN)
iostreamv3_findtestenv(zlib_iostream3_test)
endif(
MSVC
OR MSYS
OR MINGW
OR CYGWIN)
endif(ZLIB_IOSTREAM3_BUILD_TESTING)
endif(ZLIB_IOSTREAM3_BUILD_SHARED)
if(ZLIB_IOSTREAM3_BUILD_STATIC)
add_library(zlib_iostream3_iostreamv3Static STATIC
zfstream.cc
zfstream.h)
add_library(IOSTREAMV3::IOSTREAMV3STATIC
ALIAS zlib_iostream3_iostreamv3Static)
target_link_libraries(zlib_iostream3_iostreamv3Static
PUBLIC ZLIB::ZLIBSTATIC)
set_target_properties(zlib_iostream3_iostreamv3Static
PROPERTIES
EXPORT_NAME IOSTREAMV3STATIC
OUTPUT_NAME iostream3${zlib_IOStream3_static_suffix})
if(ZLIB_IOSTREAM3_BUILD_TESTING)
enable_testing()
add_executable(zlib_iostream3_testStatic test.cc zfstream.h)
target_link_libraries(zlib_iostream3_testStatic
PRIVATE zlib_iostream3_iostreamv3Static)
add_test(NAME zlib_iostream3_testStatic
COMMAND zlib_iostream3_testStatic)
set_tests_properties(zlib_iostream3_testStatic
PROPERTIES
FIXTURES_REQUIRED zlib_iostream3_cleanup)
endif(ZLIB_IOSTREAM3_BUILD_TESTING)
endif(ZLIB_IOSTREAM3_BUILD_STATIC)
if(ZLIB_IOSTREAM3_BUILD_TESTING)
add_test(NAME zlib_iostream3_cleanup COMMAND ${CMAKE_COMMAND} -E rm
${CMAKE_CURRENT_BINARY_DIR}/test1.txt.gz
${CMAKE_CURRENT_BINARY_DIR}/test2.txt.gz)
set_tests_properties(zlib_iostream3_cleanup
PROPERTIES
FIXTURES_CLEANUP zlib_iostream3_cleanup)
add_subdirectory(test)
endif(ZLIB_IOSTREAM3_BUILD_TESTING)
if(ZLIB_IOSTREAM3_INSTALL)
if(ZLIB_IOSTREAM3_BUILD_SHARED)
install(
TARGETS zlib_iostream3_iostreamv3
COMPONENT Runtime
EXPORT zlibiostream3SharedExport
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(
EXPORT zlibiostream3SharedExport
FILE iostreamv3-shared.cmake
NAMESPACE IOSTREAMV3::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/iostreamv3)
if(MSVC)
install(
FILES $<TARGET_PDB_FILE:zlib_iostream3_iostreamv3>
COMPONENT Development
DESTINATION ${CMAKE_INSTALL_BINDIR}
CONFIGURATIONS Debug OR RelWithDebInfo
OPTIONAL)
endif(MSVC)
endif(ZLIB_IOSTREAM3_BUILD_SHARED)
if(ZLIB_IOSTREAM3_BUILD_STATIC)
install(
TARGETS zlib_iostream3_iostreamv3Static
COMPONENT Development
EXPORT iostream3StaticExport
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(
EXPORT iostream3StaticExport
FILE iostreamv3-static.cmake
NAMESPACE IOSTREAMV3::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/iostreamv3)
endif(ZLIB_IOSTREAM3_BUILD_STATIC)
configure_package_config_file(
${iostreamV3_SOURCE_DIR}/iostream3Config.cmake.in
${iostreamV3_BINARY_DIR}/iostreamv3Config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/iostreamv3)
write_basic_package_version_file(
"${iostreamV3_BINARY_DIR}/iostreamv3ConfigVersion.cmake"
VERSION "${iostream3_VERSION}"
COMPATIBILITY AnyNewerVersion)
install(FILES ${iostreamV3_BINARY_DIR}/iostreamv3Config.cmake
${iostreamV3_BINARY_DIR}/iostreamv3ConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/iostreamv3)
install(
FILES zfstream.h
COMPONENT Development
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
endif(ZLIB_IOSTREAM3_INSTALL)
|
Added compat/zlib/contrib/iostream3/iostream3Config.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
@PACKAGE_INIT@
set(_iostreamv3_supported_components "shared" "static")
include(CMakeFindDependencyMacro)
if(iostreamv3_FIND_COMPONENTS)
find_dependency(ZLIB CONFIG COMPONENTS ${iostreamv3_FIND_COMPONENTS})
foreach(_comp ${iostreamv3_FIND_COMPONENTS})
if(NOT _comp IN_LIST _iostreamv3_supported_components)
set(iostreamv3_FOUND False)
set(iostreamv3_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
endif(NOT _comp IN_LIST _iostreamv3_supported_components)
include("${CMAKE_CURRENT_LIST_DIR}/iostreamv3-${_comp}.cmake")
endforeach(_comp ${iostreamv3_FIND_COMPONENTS})
else(iostream3_FIND_COMPONENTS)
find_dependency(ZLIB CONFIG)
foreach(_component_config IN LISTS _iostreamv3_supported_components)
include("${CMAKE_CURRENT_LIST_DIR}/iostreamv3-${_component_config}.cmake")
endforeach(_component_config IN LISTS _iostreamv3_supported_components)
endif(iostreamv3_FIND_COMPONENTS)
|
Added compat/zlib/contrib/iostream3/test/CMakeLists.txt.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# if we are built from with zlib, use this path's)
if(DEFINED ZLIB_BUILD_IOSTREAM3)
set(WORK_DIR ${zlib_BINARY_DIR})
set(inst_setup zlib_install)
else(DEFINED ZLIB_BUILD_IOSTREAM3)
set(WORK_DIR ${iostreamV3_BINARY_DIR})
set(inst_setup zlib_iostream3_install)
set(ZLIB_ARG "-DZLIB_DIR=${ZLIB_DIR}")
add_test(
NAME zlib_iostream3_install
COMMAND ${CMAKE_COMMAND} --install ${iostreamV3_BINARY_DIR} --prefix
${CMAKE_CURRENT_BINARY_DIR}/test_install --config $<CONFIG>
WORKING_DIRECTORY ${iostreamV3_BINARY_DIR})
set_tests_properties(zlib_iostream3_install
PROPERTIES
FIXTURES_SETUP zlib_iostream3_install)
endif(DEFINED ZLIB_BUILD_IOSTREAM3)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/find_package_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/findpackage_test/CMakeLists.txt @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test/CMakeLists.txt @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_exclude_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test/CMakeLists.txt
@ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/find_package_no_components_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/findpackage_no_components_test/CMakeLists.txt
@ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/find_package_wrong_components_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/findpackage_wrong_components_test/CMakeLists.txt
@ONLY)
# CMAKE_GENERATOR_PLATFORM doesn't work in the if
set(GENERATOR ${CMAKE_GENERATOR_PLATFORM})
if(GENERATOR)
set(PLATFORM "-A ${GENERATOR}")
endif(GENERATOR)
#
# findpackage_test
#
add_test(
NAME zlib_iostream3_find_package_configure
COMMAND
${CMAKE_COMMAND}
${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG>
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
add_test(
NAME zlib_iostream3_find_package_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
set_tests_properties(zlib_iostream3_find_package_configure
PROPERTIES
FIXTURES_REQUIRED ${inst_setup}
FIXTURES_SETUP iostream3_fp_config)
set_tests_properties(zlib_iostream3_find_package_build
PROPERTIES
FIXTURES_REQUIRED iostream3_fp_config)
#
# add_subdirectory_test
#
add_test(
NAME zlib_iostream3_add_subdirectory_configure
COMMAND
${CMAKE_COMMAND}
${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG>
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install
${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test)
add_test(
NAME zlib_iostream3_add_subdirectory_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
set_tests_properties(zlib_iostream3_add_subdirectory_configure
PROPERTIES
FIXTURES_REQUIRED ${inst_setup}
FIXTURES_SETUP iostream3as_config)
set_tests_properties(zlib_iostream3_add_subdirectory_build
PROPERTIES
FIXTURES_REQUIRED iostream3_as_config)
#
# add_subdirectory_exclude_test
#
add_test(
NAME zlib_iostream3_add_subdirectory_exclude_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test)
add_test(
NAME zlib_iostream3_add_subdirectory_exclude_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
set_tests_properties(zlib_iostream3_add_subdirectory_exclude_configure
PROPERTIES
FIXTURES_REQUIRED ${inst_setup}
FIXTURES_SETUP iostream3_asx_config)
set_tests_properties(zlib_iostream3_add_subdirectory_exclude_build
PROPERTIES
FIXTURES_REQUIRED iostream3_asx_config)
#
# findpackage_no_components_test
#
add_test(
NAME zlib_iostream3_find_package_no_components_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/findpackage_no_components_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_no_components_test)
set_tests_properties(zlib_iostream3_find_package_no_components_configure
PROPERTIES
FIXTURES_REQUIRED ${inst_setup})
if(NOT ZLIB_IOSTREAM3_BUILD_SHARED OR NOT ZLIB_IOSTREAM3_BUILD_STATIC)
set_tests_properties(zlib_iostream3_find_package_no_components_configure
PROPERTIES
WILL_FAIL TRUE)
endif(NOT ZLIB_IOSTREAM3_BUILD_SHARED OR NOT ZLIB_IOSTREAM3_BUILD_STATIC)
#
# findpackage_no_components_test
#
add_test(
NAME zlib_iostream3_find_package_wrong_components_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/findpackage_wrong_components_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_wrong_components_test)
set_tests_properties(zlib_iostream3_find_package_wrong_components_configure
PROPERTIES
FIXTURES_REQUIRED ${inst_setup}
WILL_FAIL TRUE)
|
Added compat/zlib/contrib/iostream3/test/add_subdirectory_exclude_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
iostream_add_subdirectory_exclude
LANGUAGES CXX
VERSION @iostreamV3_VERSION@)
option(ZLIB_IOSTREAM3_BUILD_SHARED "" @ZLIB_IOSTREAM3_BUILD_SHARED@)
option(ZLIB_IOSTREAM3_BUILD_STATIC "" @ZLIB_IOSTREAM3_BUILD_STATIC@)
option(ZLIB_IOSTREAM3_BUILD_TESTING "" OFF)
add_subdirectory(@iostreamV3_SOURCE_DIR@
${CMAKE_CURRENT_BINARY_DIR}/iostream3
EXCLUDE_FROM_ALL)
set(IOSTREAM_SRCS
@iostreamV3_SOURCE_DIR@/test.cc)
if(ZLIB_IOSTREAM3_BUILD_SHARED)
add_executable(test_example ${IOSTREAM_SRCS})
target_link_libraries(test_example IOSTREAMV3::IOSTREAMV3)
endif(ZLIB_IOSTREAM3_BUILD_SHARED)
if(ZLIB_IOSTREAM3_BUILD_STATIC)
add_executable(test_example_static ${IOSTREAM_SRCS})
target_link_libraries(test_example_static IOSTREAMV3::IOSTREAMV3STATIC)
endif(ZLIB_IOSTREAM3_BUILD_STATIC)
|
Added compat/zlib/contrib/iostream3/test/add_subdirectory_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
iostream_add_subdirectory
LANGUAGES CXX
VERSION @iostreamV3_VERSION@)
option(ZLIB_IOSTREAM3_BUILD_SHARED "" @ZLIB_IOSTREAM3_BUILD_SHARED@)
option(ZLIB_IOSTREAM3_BUILD_STATIC "" @ZLIB_IOSTREAM3_BUILD_STATIC@)
option(ZLIB_IOSTREAM3_BUILD_TESTING "" OFF)
add_subdirectory(@iostreamV3_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/iostream3)
set(IOSTREAM_SRCS
@iostreamV3_SOURCE_DIR@/test.cc)
if(ZLIB_IOSTREAM3_BUILD_SHARED)
add_executable(test_example ${IOSTREAM_SRCS})
target_link_libraries(test_example IOSTREAMV3::IOSTREAMV3)
endif(ZLIB_IOSTREAM3_BUILD_SHARED)
if(ZLIB_IOSTREAM3_BUILD_STATIC)
add_executable(test_example_static ${IOSTREAM_SRCS})
target_link_libraries(test_example_static IOSTREAMV3::IOSTREAMV3STATIC)
endif(ZLIB_IOSTREAM3_BUILD_STATIC)
|
Added compat/zlib/contrib/iostream3/test/find_package_no_components_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
iostream_find_package_no_components
LANGUAGES CXX
VERSION @iostreamV3_VERSION@)
option(ZLIB_IOSTREAM3_BUILD_SHARED "" @ZLIB_IOSTREAM3_BUILD_SHARED@)
option(ZLIB_IOSTREAM3_BUILD_STATIC "" @ZLIB_IOSTREAM3_BUILD_STATIC@)
find_package(iostreamv3 REQUIRED CONFIG)
set(IOSTREAM_SRCS
@iostreamV3_SOURCE_DIR@/test.cc)
if(ZLIB_IOSTREAM3_BUILD_SHARED)
add_executable(test_example ${IOSTREAM_SRCS})
target_link_libraries(test_example IOSTREAMV3::IOSTREAMV3)
endif(ZLIB_IOSTREAM3_BUILD_SHARED)
if(ZLIB_IOSTREAM3_BUILD_STATIC)
add_executable(test_example_static ${IOSTREAM_SRCS})
target_link_libraries(test_example_static IOSTREAMV3::IOSTREAMV3STATIC)
endif(ZLIB_IOSTREAM3_BUILD_STATIC)
|
Added compat/zlib/contrib/iostream3/test/find_package_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
iostream_find_package
LANGUAGES CXX
VERSION @iostreamV3_VERSION@)
option(ZLIB_IOSTREAM_BUILD_SHARED "" @ZLIB_IOSTREAM_BUILD_SHARED@)
option(ZLIB_IOSTREAM_BUILD_STATIC "" @ZLIB_IOSTREAM_BUILD_STATIC@)
set(IOSTREAM_SRCS
@iostreamV3_SOURCE_DIR@/test.cc)
if(ZLIB_IOSTREAM_BUILD_SHARED)
find_package(iostreamv3 REQUIRED COMPONENTS shared CONFIG)
add_executable(test_example ${IOSTREAM_SRCS})
target_link_libraries(test_example IOSTREAMV3::IOSTREAMV3)
endif(ZLIB_IOSTREAM_BUILD_SHARED)
if(ZLIB_IOSTREAM_BUILD_STATIC)
find_package(iostreamv3 REQUIRED COMPONENTS static CONFIG)
add_executable(test_example_static ${IOSTREAM_SRCS})
target_link_libraries(test_example_static IOSTREAMV3::IOSTREAMV3STATIC)
endif(ZLIB_IOSTREAM_BUILD_STATIC)
|
Added compat/zlib/contrib/iostream3/test/find_package_wrong_components_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
iostream_find_package
LANGUAGES CXX
VERSION @iostreamV3_VERSION@)
option(ZLIB_IOSTREAM_BUILD_SHARED "" @ZLIB_IOSTREAM_BUILD_SHARED@)
option(ZLIB_IOSTREAM_BUILD_STATIC "" @ZLIB_IOSTREAM_BUILD_STATIC@)
find_package(iostreamv3 REQUIRED COMPONENTS wrongCONFIG)
set(IOSTREAM_SRCS
@iostreamV3_SOURCE_DIR@/test.cc)
if(ZLIB_IOSTREAM_BUILD_SHARED)
add_executable(test_example ${IOSTREAM_SRCS})
target_link_libraries(test_example IOSTREAMV3::IOSTREAMV3)
endif(ZLIB_IOSTREAM_BUILD_SHARED)
if(ZLIB_IOSTREAM_BUILD_STATIC)
add_executable(test_example_static ${PUFF_SRCS})
target_link_libraries(test_example_static IOSTREAMV3::IOSTREAMV3STATIC)
endif(ZLIB_IOSTREAM_BUILD_STATIC)
|
Added compat/zlib/contrib/minizip/CMakeLists.txt.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
minizip
VERSION 1.0.0
LANGUAGES C
DESCRIPTION "A library for creating zipfiles based in zlib"
HOMEPAGE_URL "https://www.winimage.com/zLibDll/minizip.html")
if(CMAKE_SIZEOF_VOID_P LESS 8 AND NOT MINGW)
message(WARNING "libminizip needs 64bit - stopping here")
return()
endif(CMAKE_SIZEOF_VOID_P LESS 8 AND NOT MINGW)
# ============================================================================
# CPack
# ============================================================================
set(CPACK_PACKAGE_VENDOR "zlib-Project")
set(CPACK_PACKAGE_DESCRIPTION_FILE ${minizip_SOURCE_DIR}/MiniZip64_info.txt)
set(CPACK_RESOURCE_FILE_LICENSE ${minizip_SOURCE_DIR}/../../LICENSE)
set(CPACK_RESOURCE_FILE_README ${minizip_SOURCE_DIR}/MiniZip64_info.txt)
# ============================================================================
# set options if build from zlib
# ============================================================================
if(ZLIB_BUILD_MINIZIP)
set(MINIZIP_BUILD_SHARED ${ZLIB_MINIZIP_BUILD_SHARED} CACHE BOOL "")
set(MINIZIP_BUILD_STATIC ${ZLIB_MINIZIP_BUILD_STATIC} CACHE BOOL "")
set(MINIZIP_BUILD_TESTING ${ZLIB_MINIZIP_INSTALL} CACHE BOOL "")
set(MINIZIP_INSTALL ${ZLIB_MINIZIP_INSTALL} CACHE BOOL "")
endif(ZLIB_BUILD_MINIZIP)
# ============================================================================
# configuration
# ============================================================================
option(MINIZIP_BUILD_SHARED "Enable building minizip shared library" ON)
option(MINIZIP_BUILD_STATIC "Enable building minizip static library" ON)
option(MINIZIP_BUILD_TESTING "Enable testing of minizip" ON)
option(MINIZIP_ENABLE_BZIP2 "Build minizip with bzip2 support" OFF)
option(MINIZIP_INSTALL "Enable installation of minizip" ON)
include(CheckCSourceCompiles)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CMakePackageConfigHelpers)
include(CheckTypeSize)
include(GNUInstallDirs)
if(NOT CPACK_INCLUDED)
include(CPack)
endif(NOT CPACK_INCLUDED)
if(NOT DEFINED ZLIB_BUILD_MINIZIP)
if(MINIZIP_BUILD_SHARED)
list(APPEND REQUIRED_COMPONENTS "shared")
endif(MINIZIP_BUILD_SHARED)
if(MINIZIP_BUILD_STATIC)
list(APPEND REQUIRED_COMPONENTS "static")
endif(MINIZIP_BUILD_STATIC)
find_package(ZLIB REQUIRED COMPONENTS ${REQUIRED_COMPONENTS} CONFIG)
endif(NOT DEFINED ZLIB_BUILD_MINIZIP)
if(MINIZIP_ENABLE_BZIP2)
find_package(BZip2 REQUIRED)
endif(MINIZIP_ENABLE_BZIP2)
#
# Check for fopen64
#
check_function_exists(fopen64 HAVE_FOPEN64)
#
# Check for fseeko
#
check_function_exists(fseeko HAVE_FSEEKO)
#
# Check for unistd.h
#
check_include_file(unistd.h HAVE_UNISTD_H)
#
# Check to see if we have large file support
#
set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
check_type_size(off64_t OFF64_T)
unset(CMAKE_REQUIRED_DEFINITIONS) # clear variable
#
# Check visibility attribute is supported
#
if(MSVC)
set(CMAKE_REQUIRED_FLAGS "-WX")
else(MSVC)
set(CMAKE_REQUIRED_FLAGS "-WError")
endif(MSVC)
check_c_source_compiles(
"
#include <stdlib.h>
static void f(void) __attribute__ ((visibility(\"hidden\")));
int main(void) {return 0;}
"
HAVE___ATTR__VIS_HIDDEN)
unset(CMAKE_REQUIRED_FLAGS)
set(LIBMINIZIP_SRCS ioapi.c mztools.c unzip.c zip.c)
set(LIBMINIZIP_HDRS crypt.h ints.h ioapi.h mztools.h unzip.h zip.h)
set(MINIZIP_SRCS ioapi.c $<$<BOOL:${WIN32}>:iowin32.c> minizip.c zip.c)
set(MINIZIP_HDRS crypt.h ints.h ioapi.h $<$<BOOL:${WIN32}>:iowin32.h> skipset.h
zip.h)
set(MINIUNZIP_SRCS ioapi.c $<$<BOOL:${WIN32}>:iowin32.c> miniunz.c unzip.c
zip.c)
set(MINIUNZIP_HDRS
crypt.h
ints.h
ioapi.h
$<$<BOOL:${WIN32}>:iowin32.h>
skipset.h
unzip.h
zip.h)
if(WIN32 OR CYGWIN)
set(minizip_static_suffix "s")
set(CMAKE_DEBUG_POSTFIX "d")
endif(WIN32 OR CYGWIN)
if(MINIZIP_BUILD_SHARED)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
add_library(libminizip SHARED ${LIBMINIZIP_SRCS} ${LIBMINIZIP_HDRS})
add_library(MINIZIP::minizip ALIAS libminizip)
target_include_directories(
libminizip PUBLIC $<BUILD_INTERFACE:${minizip_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_definitions(
libminizip
PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
$<$<BOOL:${HAVE_UNISTD_H}>:HAVE_UNISTD_H=1>
PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>
$<$<BOOL:${BZIP2_FOUND}>:HAVE_BZIP2=1>
$<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
if(NOT CYGWIN)
set_target_properties(libminizip PROPERTIES SOVERSION
${minizip_VERSION_MAJOR})
endif(NOT CYGWIN)
set_target_properties(
libminizip
PROPERTIES EXPORT_NAME minizip
OUTPUT_NAME minizip
VERSION ${minizip_VERSION}
SOVERSION ${minizip_VERSION_MAJOR})
target_link_libraries(libminizip
PUBLIC ZLIB::ZLIB
$<$<BOOL:${BZIP2_FOUND}>:BZip2::BZip2>)
add_executable(minizip ${MINIZIP_SRCS} ${MINIZIP_HDRS})
set_target_properties(minizip PROPERTIES EXPORT_NAME minizip_executable)
target_compile_definitions(
minizip PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>)
target_link_libraries(minizip PRIVATE MINIZIP::minizip)
add_executable(miniunzip ${MINIUNZIP_SRCS} ${MINIUNZIP_HDRS})
set_target_properties(miniunzip PROPERTIES EXPORT_NAME miniunzip_executable)
target_compile_definitions(
miniunzip PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>)
target_link_libraries(miniunzip PRIVATE MINIZIP::minizip)
endif(MINIZIP_BUILD_SHARED)
if(MINIZIP_BUILD_STATIC)
add_library(libminizipstatic STATIC ${LIBMINIZIP_SRCS} ${LIBMINIZIP_HDRS})
add_library(MINIZIP::minizipstatic ALIAS libminizipstatic)
target_include_directories(
libminizipstatic
PUBLIC $<BUILD_INTERFACE:${minizip_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_definitions(
libminizipstatic
PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
$<$<BOOL:${HAVE_UNISTD_H}>:HAVE_UNISTD_H=1>
PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>
$<$<BOOL:${BZIP2_FOUND}>:HAVE_BZIP2=1>
$<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
set_target_properties(
libminizipstatic PROPERTIES EXPORT_NAME minizipstatic
OUTPUT_NAME minizip${minizip_static_suffix})
if(CYGWIN)
set_target_properties(libminizipstatic PROPERTIES SUFFIX ".dll.a")
endif(CYGWIN)
target_link_libraries(libminizipstatic PUBLIC ZLIB::ZLIBSTATIC
$<$<BOOL:${BZIP2_FOUND}>:BZip2::BZip2>)
add_executable(minizipstatic ${MINIZIP_SRCS} ${MINIZIP_HDRS})
set_target_properties(minizipstatic PROPERTIES EXPORT_NAME
minizip_static_executable)
target_compile_definitions(
minizipstatic PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>)
target_link_libraries(minizipstatic PRIVATE MINIZIP::minizipstatic)
add_executable(miniunzipstatic ${MINIUNZIP_SRCS} ${MINIUNZIP_HDRS})
set_target_properties(miniunzipstatic
PROPERTIES EXPORT_NAME miniunzip_static_executable)
target_compile_definitions(
miniunzipstatic PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>)
target_link_libraries(miniunzipstatic PRIVATE MINIZIP::minizipstatic)
endif(MINIZIP_BUILD_STATIC)
if(MINIZIP_INSTALL)
if(MINIZIP_BUILD_SHARED)
install(
TARGETS libminizip minizip miniunzip
COMPONENT Runtime
EXPORT minizipSharedExport
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(
EXPORT minizipSharedExport
FILE minizip-shared.cmake
NAMESPACE MINIZIP::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/minizip)
if(MSVC)
install(
FILES $<TARGET_PDB_FILE:libminizip>
COMPONENT Runtime
DESTINATION ${CMAKE_INSTALL_BINDIR}
CONFIGURATIONS Debug OR RelWithDebInfo
OPTIONAL)
endif(MSVC)
endif(MINIZIP_BUILD_SHARED)
if(MINIZIP_BUILD_STATIC)
install(
TARGETS libminizipstatic
COMPONENT Development
TARGETS minizipstatic miniunzipstatic
COMPONENT Runtime
EXPORT minizipStaticExport
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(
EXPORT minizipStaticExport
FILE minizip-static.cmake
NAMESPACE MINIZIP::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/minizip)
endif(MINIZIP_BUILD_STATIC)
configure_package_config_file(
${minizip_SOURCE_DIR}/minizipConfig.cmake.in
${minizip_BINARY_DIR}/minizipConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/minizip)
write_basic_package_version_file(
"${minizip_BINARY_DIR}/minizipConfigVersion.cmake"
VERSION "${minizip_VERSION}"
COMPATIBILITY AnyNewerVersion)
install(FILES ${minizip_BINARY_DIR}/minizipConfig.cmake
${minizip_BINARY_DIR}/minizipConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/minizip)
install(
FILES ${LIBMINIZIP_HDRS}
COMPONENT Development
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
endif(MINIZIP_INSTALL)
if(MINIZIP_BUILD_TESTING)
enable_testing()
if(MINIZIP_BUILD_SHARED AND NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL
".dll")
add_test(
NAME minizip_prepare_shared_zip
COMMAND ${CMAKE_COMMAND} -DCREATE_SHARED=ON -P
${CMAKE_CURRENT_SOURCE_DIR}/test/test_helper.cm
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
add_test(
NAME minizip_zipping_test_file_shared
COMMAND minizip test_file_shared.zip test_file_shared.txt
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
add_test(
NAME minizip_prepare_shared_unzip
COMMAND ${CMAKE_COMMAND} -DMOVE_SHARED=ON -P
${CMAKE_CURRENT_SOURCE_DIR}/test/test_helper.cm
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
add_test(
NAME minizip_miniunzipping_test_file_shared.zip
COMMAND miniunzip test_file_shared.zip
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
add_test(
NAME minizip_compare_shared
COMMAND ${CMAKE_COMMAND} -E compare_files test_file_shared.txt
test_file_shared.orig
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
add_test(
NAME minizip_clean_shared_zip
COMMAND ${CMAKE_COMMAND} -DDELETE_SHARED=ON -P
${CMAKE_CURRENT_SOURCE_DIR}/test/test_helper.cm
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
set_tests_properties(minizip_prepare_shared_zip
PROPERTIES FIXTURES_SETUP prepare_shared)
set_tests_properties(
minizip_zipping_test_file_shared
PROPERTIES FIXTURES_REQUIRED prepare_shared FIXTURES_SETUP
zip_shared)
set_tests_properties(
minizip_prepare_shared_unzip
PROPERTIES FIXTURES_REQUIRED zip_shared FIXTURES_SETUP
prepare_unzip_shared)
set_tests_properties(
minizip_miniunzipping_test_file_shared.zip
PROPERTIES FIXTURES_REQUIRED prepare_unzip_shared FIXTURES_SETUP
prepare_compare_shared)
set_tests_properties(
minizip_compare_shared
PROPERTIES FIXTURES_REQUIRED prepare_compare_shared FIXTURES_SETUP
compared_shared)
set_tests_properties(minizip_clean_shared_zip
PROPERTIES FIXTURES_CLEANUP compared_shared)
endif(MINIZIP_BUILD_SHARED AND NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL
".dll")
if(MINIZIP_BUILD_STATIC)
add_test(
NAME minizip_prepare_static_zip
COMMAND ${CMAKE_COMMAND} -DCREATE_STATIC=ON -P
${CMAKE_CURRENT_SOURCE_DIR}/test/test_helper.cm
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
add_test(
NAME minizip_zipping_test_file_static
COMMAND minizipstatic test_file_static.zip test_file_static.txt
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
add_test(
NAME minizip_prepare_static_unzip
COMMAND ${CMAKE_COMMAND} -DMOVE_STATIC=ON -P
${CMAKE_CURRENT_SOURCE_DIR}/test/test_helper.cm
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
add_test(
NAME minizip_miniunzipping_test_file_static.zip
COMMAND miniunzipstatic test_file_static.zip
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
add_test(
NAME minizip_compare_static
COMMAND ${CMAKE_COMMAND} -E compare_files test_file_static.txt
test_file_static.orig
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
add_test(
NAME minizip_clean_static_zip
COMMAND ${CMAKE_COMMAND} -DDELETE_STATIC=ON -P
${CMAKE_CURRENT_SOURCE_DIR}/test/test_helper.cm
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
set_tests_properties(minizip_prepare_static_zip
PROPERTIES FIXTURES_SETUP prepare_static)
set_tests_properties(
minizip_zipping_test_file_static
PROPERTIES FIXTURES_REQUIRED prepare_static FIXTURES_SETUP
zip_static)
set_tests_properties(
minizip_prepare_static_unzip
PROPERTIES FIXTURES_REQUIRED zip_static FIXTURES_SETUP
prepare_unzip_static)
set_tests_properties(
minizip_miniunzipping_test_file_static.zip
PROPERTIES FIXTURES_REQUIRED prepare_unzip_static FIXTURES_SETUP
prepare_compare_static)
set_tests_properties(
minizip_compare_static
PROPERTIES FIXTURES_REQUIRED prepare_compare_static FIXTURES_SETUP
compared_static)
set_tests_properties(minizip_clean_static_zip
PROPERTIES FIXTURES_CLEANUP compared_static)
endif(MINIZIP_BUILD_STATIC)
add_subdirectory(test)
endif(MINIZIP_BUILD_TESTING)
|
Added compat/zlib/contrib/minizip/LICENSE.Info-Zip.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 |
This is version 2009-Jan-02 of the Info-ZIP license. The definitive version of
this document should be available at ftp://ftp.info-
zip.org/pub/infozip/license.html indefinitely and a copy at http://www.info-
zip.org/pub/infozip/license.html.
Copyright (c) 1990-2009 Info-ZIP. All rights reserved.
For the purposes of this copyright and license, "Info-ZIP" is defined as the
following set of individuals:
Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois, Jean-
loup Gailly, Hunter Goatley, Ed Gordon, Ian Gorman, Chris Herborth, Dirk
Haase, Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz, David
Kirschbaum, Johnny Lee, Onno van der Linden, Igor Mandrichenko, Steve P.
Miller, Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs, Kai Uwe
Rommel, Steve Salisbury, Dave Smith, Steven M. Schweda, Christian Spieler,
Cosmin Truta, Antoine Verheijen, Paul von Behren, Rich Wales, Mike White.
This software is provided "as is," without warranty of any kind, express or
implied. In no event shall Info-ZIP or its contributors be held liable for any
direct, indirect, incidental, special or consequential damages arising out of
the use of or inability to use this software.
Permission is granted to anyone to use this software for any purpose, including
commercial applications, and to alter it and redistribute it freely, subject to
the above disclaimer and the following restrictions:
Redistributions of source code (in whole or in part) must retain the above
copyright notice, definition, disclaimer, and this list of conditions.
Redistributions in binary form (compiled executables and libraries) must
reproduce the above copyright notice, definition, disclaimer, and this list
of conditions in documentation and/or other materials provided with the
distribution. Additional documentation is not needed for executables where a
command line license option provides these and a note regarding this option
is in the executable's startup banner. The sole exception to this condition
is redistribution of a standard UnZipSFX binary (including SFXWiz) as part
of a self-extracting archive; that is permitted without inclusion of this
license, as long as the normal SFX banner has not been removed from the
binary or disabled.
Altered versions--including, but not limited to, ports to new operating
systems, existing ports with new graphical interfaces, versions with
modified or added functionality, and dynamic, shared, or static library
versions not from Info-ZIP--must be plainly marked as such and must not be
misrepresented as being the original source or, if binaries, compiled from
the original source. Such altered versions also must not be misrepresented
as being Info-ZIP releases--including, but not limited to, labeling of the
altered versions with the names "Info-ZIP" (or any variation thereof,
including, but not limited to, different capitalizations), "Pocket UnZip,"
"WiZ" or "MacZip" without the explicit permission of Info-ZIP. Such altered
versions are further prohibited from misrepresentative use of the Zip-Bugs
or Info-ZIP e-mail addresses or the Info-ZIP URL(s), such as to imply Info-
ZIP will provide support for the altered versions.
Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip,"
"UnZipSFX," "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its own
source and binary releases.
|
Changes to compat/zlib/contrib/minizip/Makefile.
|
| < | | < | > > > > > > | | | | | | 1 2 3 4 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 |
CPPFLAGS = -I../..
UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a
ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a
all: miniunz minizip
miniunz.o: miniunz.c unzip.h iowin32.h
minizip.o: minizip.c zip.h iowin32.h ints.h
unzip.o: unzip.c unzip.h crypt.h
zip.o: zip.c zip.h crypt.h skipset.h ints.h
ioapi.o: ioapi.c ioapi.h ints.h
iowin32.o: iowin32.c iowin32.h ioapi.h
mztools.o: mztools.c unzip.h
miniunz: $(UNZ_OBJS)
${CC} ${LDFLAGS} -o $@ $(UNZ_OBJS)
minizip: $(ZIP_OBJS)
${CC} ${LDFLAGS} -o $@ $(ZIP_OBJS)
test: miniunz minizip
@rm -f test.*
@echo hello hello hello > test.txt
./minizip test test.txt
./miniunz -l test.zip
@mv test.txt test.old
./miniunz test.zip
@cmp test.txt test.old
|
| ︙ | ︙ |
Changes to compat/zlib/contrib/minizip/MiniZip64_info.txt.
|
| | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | MiniZip - Copyright (c) 1998-2026 - by Gilles Vollant - version 1.1 64 bits from Mathias Svensson Introduction --------------------- MiniZip 1.1 is built from MiniZip 1.0 by Gilles Vollant ( https://www.winimage.com/zLibDll/minizip.html ) When adding ZIP64 support into minizip it would result into risk of breaking compatibility with minizip 1.0. All possible work was done for compatibility. Background --------------------- When adding ZIP64 support Mathias Svensson found that Even Rouault have added ZIP64 support for unzip.c into minizip for a open source project called gdal ( https://www.gdal.org/ ) That was used as a starting point. And after that ZIP64 support was added to zip.c some refactoring and code cleanup was also done. Changed from MiniZip 1.0 to MiniZip 1.1 --------------------------------------- |
| ︙ | ︙ | |||
32 33 34 35 36 37 38 | Gilles Vollant - Original MiniZip author Even Rouault - ZIP64 unzip Support Daniel Borca - BZip Compression method support in unzip Mathias Svensson - ZIP64 zip support Mathias Svensson - BZip Compression method support in zip | | < < < < < | | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
Gilles Vollant - Original MiniZip author
Even Rouault - ZIP64 unzip Support
Daniel Borca - BZip Compression method support in unzip
Mathias Svensson - ZIP64 zip support
Mathias Svensson - BZip Compression method support in zip
Resource
ZIP App Note https://www.pkware.com/documents/casestudies/APPNOTE.TXT
Zip File specification
Notes.
* To be able to use BZip compression method in zip64.c or unzip64.c the BZIP2 lib is needed and HAVE_BZIP2 need to be defined.
License
|
| ︙ | ︙ |
Changes to compat/zlib/contrib/minizip/configure.ac.
1 2 3 | # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_INIT([minizip], [1.3.2], [bugzilla.redhat.com]) AC_CONFIG_SRCDIR([minizip.c]) AM_INIT_AUTOMAKE([foreign]) LT_INIT AC_MSG_CHECKING([whether to build example programs]) AC_ARG_ENABLE([demos], AS_HELP_STRING([--enable-demos], [build example programs])) AM_CONDITIONAL([COND_DEMOS], [test "$enable_demos" = yes]) if test "$enable_demos" = yes then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi |
| ︙ | ︙ |
Changes to compat/zlib/contrib/minizip/crypt.h.
1 2 | /* crypt.h -- base code for crypt/uncrypt ZIPfile | < < < | | | 1 2 3 4 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 | /* crypt.h -- base code for crypt/uncrypt ZIPfile Copyright (C) 1998-2026 Gilles Vollant This code is a modified version of crypting code in Infozip distribution The encryption/decryption parts of this source code (as opposed to the non-echoing password parts) were originally written in Europe. The whole source package can be freely distributed, including from the USA. (Prior to January 2000, re-export from the US was a violation of US law.) This encryption code is a direct transcription of the algorithm from Roger Schlafly, described by Phil Katz in the file appnote.txt. This file (appnote.txt) is distributed with the PKZIP program (even in the version without encryption capabilities). If you don't need crypting in your application, just define symbols NOCRYPT and NOUNCRYPT. This code support the "Traditional PKWARE Encryption". The new AES encryption added on Zip format by Winzip (see the page https://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong Encryption is not supported. */ #define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) /*********************************************************************** * Return the next byte in the pseudo-random sequence |
| ︙ | ︙ | |||
46 47 48 49 50 51 52 |
* Update the encryption keys with the next byte of plain text
*/
static int update_keys(unsigned long* pkeys, const z_crc_t* pcrc_32_tab, int c) {
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
{
| | | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
* Update the encryption keys with the next byte of plain text
*/
static int update_keys(unsigned long* pkeys, const z_crc_t* pcrc_32_tab, int c) {
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
{
int keyshift = (int)((*(pkeys+1)) >> 24);
(*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
}
return c;
}
/***********************************************************************
|
| ︙ | ︙ | |||
102 103 104 105 106 107 108 |
/* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
* output of rand() to get less predictability, since rand() is
* often poorly implemented.
*/
if (++calls == 1)
{
| | | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
/* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
* output of rand() to get less predictability, since rand() is
* often poorly implemented.
*/
if (++calls == 1)
{
srand((unsigned)time(NULL) ^ ZCR_SEED2);
}
init_keys(passwd, pkeys, pcrc_32_tab);
for (n = 0; n < RAND_HEAD_LEN-2; n++)
{
c = (rand() >> 7) & 0xff;
header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
}
|
| ︙ | ︙ |
Added compat/zlib/contrib/minizip/ints.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 |
/* ints.h -- create integer types for 8, 16, 32, and 64 bits
* Copyright (C) 2024 Mark Adler
* For conditions of distribution and use, see the copyright notice in zlib.h
*
* There exist compilers with limits.h, but not stdint.h or inttypes.h.
*/
#ifndef INTS_H
#define INTS_H
#include <limits.h>
#if defined(UCHAR_MAX) && UCHAR_MAX == 0xff
typedef signed char i8_t;
typedef unsigned char ui8_t;
#else
# error "no 8-bit integer"
#endif
#if defined(USHRT_MAX) && USHRT_MAX == 0xffff
typedef short i16_t;
typedef unsigned short ui16_t;
#elif defined(UINT_MAX) && UINT_MAX == 0xffff
typedef int i16_t;
typedef unsigned ui16_t;
#else
# error "no 16-bit integer"
#endif
#if defined(UINT_MAX) && UINT_MAX == 0xffffffff
typedef int i32_t;
typedef unsigned ui32_t;
# define PI32 "d"
# define PUI32 "u"
#elif defined(ULONG_MAX) && ULONG_MAX == 0xffffffff
typedef long i32_t;
typedef unsigned long ui32_t;
# define PI32 "ld"
# define PUI32 "lu"
#else
# error "no 32-bit integer"
#endif
#if defined(ULONG_MAX) && ULONG_MAX == 0xffffffffffffffff
typedef long i64_t;
typedef unsigned long ui64_t;
# define PI64 "ld"
# define PUI64 "lu"
#elif defined(ULLONG_MAX) && ULLONG_MAX == 0xffffffffffffffff
typedef long long i64_t;
typedef unsigned long long ui64_t;
# define PI64 "lld"
# define PUI64 "llu"
#elif defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 0xffffffffffffffff
typedef long long i64_t;
typedef unsigned long long ui64_t;
# define PI64 "lld"
# define PUI64 "llu"
#else
# error "no 64-bit integer"
#endif
#endif
|
Changes to compat/zlib/contrib/minizip/ioapi.c.
1 | /* ioapi.h -- IO base function header for compress/uncompress .zip | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
/* ioapi.h -- IO base function header for compress/uncompress .zip
part of the MiniZip project - ( https://www.winimage.com/zLibDll/minizip.html )
Copyright (C) 1998-2026 Gilles Vollant (minizip) ( https://www.winimage.com/zLibDll/minizip.html )
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson ( https://result42.com )
For more info read MiniZip_info.txt
*/
#if defined(_WIN32) && (!(defined(_CRT_SECURE_NO_WARNINGS)))
#define _CRT_SECURE_NO_WARNINGS
#endif
#if defined(__APPLE__) || defined(IOAPI_NO_64) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) || (defined(__ANDROID_API__) && __ANDROID_API__ < 24)
/* In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions */
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
#define FTELLO_FUNC(stream) ftello(stream)
#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)
#else
#define FOPEN_FUNC(filename, mode) fopen64(filename, mode)
#define FTELLO_FUNC(stream) ftello64(stream)
#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)
|
| ︙ | ︙ |
Changes to compat/zlib/contrib/minizip/ioapi.h.
1 | /* ioapi.h -- IO base function header for compress/uncompress .zip | | | | | | | | | | 1 2 3 4 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 |
/* ioapi.h -- IO base function header for compress/uncompress .zip
part of the MiniZip project - ( https://www.winimage.com/zLibDll/minizip.html )
Copyright (C) 1998-2026 Gilles Vollant (minizip) ( https://www.winimage.com/zLibDll/minizip.html )
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson ( https://result42.com )
For more info read MiniZip_info.txt
Changes
Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this)
Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux.
More if/def section may be needed to support other platforms
Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows.
(but you should use iowin32.c for windows instead)
*/
#ifndef ZLIBIOAPI64_H
#define ZLIBIOAPI64_H
#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) && (!(defined(__ANDROID_API__) || __ANDROID_API__ >= 24))
/* Linux needs this to support file operation on files larger then 4+GB */
/* But might need better if/def to select just the platforms that needs them.*/
#ifndef __USE_FILE_OFFSET64
#define __USE_FILE_OFFSET64
#endif
#ifndef __USE_LARGEFILE64
#define __USE_LARGEFILE64
#endif
|
| ︙ | ︙ | |||
63 64 65 66 67 68 69 | #else // old MSC #define ftello64 ftell #define fseeko64 fseek #endif #endif #endif | < < < < < < < < < < < < < < < < | | < < < < < < < < < < < | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | #else // old MSC #define ftello64 ftell #define fseeko64 fseek #endif #endif #endif #ifdef HAVE_MINIZIP64_CONF_H #include "mz64conf.h" #endif #include "ints.h" typedef ui64_t ZPOS64_T; /* Maximum unsigned 32-bit value used as placeholder for zip64 */ #ifndef MAXU32 #define MAXU32 (0xffffffff) #endif #ifdef __cplusplus |
| ︙ | ︙ | |||
184 185 186 187 188 189 190 |
tell_file_func ztell32_file;
seek_file_func zseek32_file;
} zlib_filefunc64_32_def;
#define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
#define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
| | | | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
tell_file_func ztell32_file;
seek_file_func zseek32_file;
} zlib_filefunc64_32_def;
#define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
#define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
/*#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) */
/*#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) */
#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream))
#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream))
voidpf call_zopen64(const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode);
long call_zseek64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin);
ZPOS64_T call_ztell64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream);
|
| ︙ | ︙ |
Changes to compat/zlib/contrib/minizip/iowin32.c.
1 | /* iowin32.c -- IO base function header for compress/uncompress .zip | < | | | | | 1 2 3 4 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 |
/* iowin32.c -- IO base function header for compress/uncompress .zip
part of the MiniZip project - ( https://www.winimage.com/zLibDll/minizip.html )
Copyright (C) 1998-2026 Gilles Vollant (minizip) ( https://www.winimage.com/zLibDll/minizip.html )
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson ( https://result42.com )
For more info read MiniZip_info.txt
*/
#include <stdlib.h>
#include "zlib.h"
#include "ioapi.h"
#include "iowin32.h"
#ifndef INVALID_HANDLE_VALUE
#define INVALID_HANDLE_VALUE (0xFFFFFFFF)
#endif
#ifndef INVALID_SET_FILE_POINTER
#define INVALID_SET_FILE_POINTER ((DWORD)-1)
#endif
/* see Include/shared/winapifamily.h in the Windows Kit */
#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API)))
#if !defined(WINAPI_FAMILY_ONE_PARTITION)
#define WINAPI_FAMILY_ONE_PARTITION(PartitionSet, Partition) ((WINAPI_FAMILY & PartitionSet) == Partition)
#endif
#if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY, WINAPI_PARTITION_APP)
|
| ︙ | ︙ | |||
85 86 87 88 89 90 91 |
else
*((WIN32FILE_IOWIN*)ret) = w32fiow;
}
return ret;
}
voidpf ZCALLBACK win32_open64_file_func(voidpf opaque, const void* filename, int mode) {
| | | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
else
*((WIN32FILE_IOWIN*)ret) = w32fiow;
}
return ret;
}
voidpf ZCALLBACK win32_open64_file_func(voidpf opaque, const void* filename, int mode) {
(void)opaque;
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
HANDLE hFile = NULL;
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
#ifdef IOWIN32_USING_WINRT_API
#ifdef UNICODE
|
| ︙ | ︙ | |||
113 114 115 116 117 118 119 |
#endif
return win32_build_iowin(hFile);
}
voidpf ZCALLBACK win32_open64_file_funcA(voidpf opaque, const void* filename, int mode) {
| | | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
#endif
return win32_build_iowin(hFile);
}
voidpf ZCALLBACK win32_open64_file_funcA(voidpf opaque, const void* filename, int mode) {
(void)opaque;
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
HANDLE hFile = NULL;
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
#ifdef IOWIN32_USING_WINRT_API
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
| ︙ | ︙ | |||
136 137 138 139 140 141 142 |
#endif
return win32_build_iowin(hFile);
}
voidpf ZCALLBACK win32_open64_file_funcW(voidpf opaque, const void* filename, int mode) {
| | | | 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
#endif
return win32_build_iowin(hFile);
}
voidpf ZCALLBACK win32_open64_file_funcW(voidpf opaque, const void* filename, int mode) {
(void)opaque;
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
HANDLE hFile = NULL;
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
#ifdef IOWIN32_USING_WINRT_API
if ((filename!=NULL) && (dwDesiredAccess != 0))
hFile = CreateFile2((LPCWSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition,NULL);
#else
if ((filename!=NULL) && (dwDesiredAccess != 0))
hFile = CreateFileW((LPCWSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
#endif
return win32_build_iowin(hFile);
}
voidpf ZCALLBACK win32_open_file_func(voidpf opaque, const char* filename, int mode) {
(void)opaque;
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
HANDLE hFile = NULL;
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
#ifdef IOWIN32_USING_WINRT_API
#ifdef UNICODE
|
| ︙ | ︙ | |||
183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
#endif
return win32_build_iowin(hFile);
}
uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void* buf,uLong size) {
uLong ret=0;
HANDLE hFile = NULL;
if (stream!=NULL)
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
if (hFile != NULL)
{
| > | 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
#endif
return win32_build_iowin(hFile);
}
uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void* buf,uLong size) {
(void)opaque;
uLong ret=0;
HANDLE hFile = NULL;
if (stream!=NULL)
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
if (hFile != NULL)
{
|
| ︙ | ︙ | |||
204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
}
return ret;
}
uLong ZCALLBACK win32_write_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) {
uLong ret=0;
HANDLE hFile = NULL;
if (stream!=NULL)
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
if (hFile != NULL)
{
| > | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
}
return ret;
}
uLong ZCALLBACK win32_write_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) {
(void)opaque;
uLong ret=0;
HANDLE hFile = NULL;
if (stream!=NULL)
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
if (hFile != NULL)
{
|
| ︙ | ︙ | |||
243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
newPos->HighPart = lHigh;
}
return fOk;
#endif
}
long ZCALLBACK win32_tell_file_func(voidpf opaque, voidpf stream) {
long ret=-1;
HANDLE hFile = NULL;
if (stream!=NULL)
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
if (hFile != NULL)
{
LARGE_INTEGER pos;
| > | 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
newPos->HighPart = lHigh;
}
return fOk;
#endif
}
long ZCALLBACK win32_tell_file_func(voidpf opaque, voidpf stream) {
(void)opaque;
long ret=-1;
HANDLE hFile = NULL;
if (stream!=NULL)
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
if (hFile != NULL)
{
LARGE_INTEGER pos;
|
| ︙ | ︙ | |||
265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
else
ret=(long)pos.LowPart;
}
return ret;
}
ZPOS64_T ZCALLBACK win32_tell64_file_func(voidpf opaque, voidpf stream) {
ZPOS64_T ret= (ZPOS64_T)-1;
HANDLE hFile = NULL;
if (stream!=NULL)
hFile = ((WIN32FILE_IOWIN*)stream)->hf;
if (hFile)
{
| > | 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
else
ret=(long)pos.LowPart;
}
return ret;
}
ZPOS64_T ZCALLBACK win32_tell64_file_func(voidpf opaque, voidpf stream) {
(void)opaque;
ZPOS64_T ret= (ZPOS64_T)-1;
HANDLE hFile = NULL;
if (stream!=NULL)
hFile = ((WIN32FILE_IOWIN*)stream)->hf;
if (hFile)
{
|
| ︙ | ︙ | |||
289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
ret=pos.QuadPart;
}
return ret;
}
long ZCALLBACK win32_seek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) {
DWORD dwMoveMethod=0xFFFFFFFF;
HANDLE hFile = NULL;
long ret=-1;
if (stream!=NULL)
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
switch (origin)
| > | 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
ret=pos.QuadPart;
}
return ret;
}
long ZCALLBACK win32_seek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) {
(void)opaque;
DWORD dwMoveMethod=0xFFFFFFFF;
HANDLE hFile = NULL;
long ret=-1;
if (stream!=NULL)
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
switch (origin)
|
| ︙ | ︙ | |||
326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
else
ret=0;
}
return ret;
}
long ZCALLBACK win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) {
DWORD dwMoveMethod=0xFFFFFFFF;
HANDLE hFile = NULL;
long ret=-1;
if (stream!=NULL)
hFile = ((WIN32FILE_IOWIN*)stream)->hf;
| > | 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
else
ret=0;
}
return ret;
}
long ZCALLBACK win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) {
(void)opaque;
DWORD dwMoveMethod=0xFFFFFFFF;
HANDLE hFile = NULL;
long ret=-1;
if (stream!=NULL)
hFile = ((WIN32FILE_IOWIN*)stream)->hf;
|
| ︙ | ︙ | |||
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
else
ret=0;
}
return ret;
}
int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream) {
int ret=-1;
if (stream!=NULL)
{
HANDLE hFile;
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
if (hFile != NULL)
{
CloseHandle(hFile);
ret=0;
}
free(stream);
}
return ret;
}
int ZCALLBACK win32_error_file_func(voidpf opaque, voidpf stream) {
int ret=-1;
if (stream!=NULL)
{
ret = ((WIN32FILE_IOWIN*)stream) -> error;
}
return ret;
}
| > > | 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
else
ret=0;
}
return ret;
}
int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream) {
(void)opaque;
int ret=-1;
if (stream!=NULL)
{
HANDLE hFile;
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
if (hFile != NULL)
{
CloseHandle(hFile);
ret=0;
}
free(stream);
}
return ret;
}
int ZCALLBACK win32_error_file_func(voidpf opaque, voidpf stream) {
(void)opaque;
int ret=-1;
if (stream!=NULL)
{
ret = ((WIN32FILE_IOWIN*)stream) -> error;
}
return ret;
}
|
| ︙ | ︙ |
Changes to compat/zlib/contrib/minizip/iowin32.h.
1 | /* iowin32.h -- IO base function header for compress/uncompress .zip | < | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
/* iowin32.h -- IO base function header for compress/uncompress .zip
part of the MiniZip project - ( https://www.winimage.com/zLibDll/minizip.html )
Copyright (C) 1998-2026 Gilles Vollant (minizip) ( https://www.winimage.com/zLibDll/minizip.html )
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson ( https://result42.com )
For more info read MiniZip_info.txt
*/
#include <windows.h>
|
| ︙ | ︙ |
Changes to compat/zlib/contrib/minizip/make_vms.com.
1 2 3 4 |
$ if f$search("ioapi.h_orig") .eqs. "" then copy ioapi.h ioapi.h_orig
$ open/write zdef vmsdefs.h
$ copy sys$input: zdef
$ deck
| | | 1 2 3 4 5 6 7 8 9 10 11 12 |
$ if f$search("ioapi.h_orig") .eqs. "" then copy ioapi.h ioapi.h_orig
$ open/write zdef vmsdefs.h
$ copy sys$input: zdef
$ deck
#define __unix__
#define fill_zlib_filefunc64_32_def_from_filefunc32 fillzffunc64from
#define Write_Zip64EndOfCentralDirectoryLocator Write_Zip64EoDLocator
#define Write_Zip64EndOfCentralDirectoryRecord Write_Zip64EoDRecord
#define Write_EndOfCentralDirectoryRecord Write_EoDRecord
$ eod
$ close zdef
$ copy vmsdefs.h,ioapi.h_orig ioapi.h
|
| ︙ | ︙ |
Changes to compat/zlib/contrib/minizip/miniunz.c.
1 2 | /* miniunz.c | < | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
/*
miniunz.c
sample part of the MiniZip project - ( https://www.winimage.com/zLibDll/minizip.html )
Copyright (C) 1998-2026 Gilles Vollant (minizip) ( https://www.winimage.com/zLibDll/minizip.html )
Modifications of Unzip for Zip64
Copyright (C) 2007-2008 Even Rouault
Modifications for Zip64 support on both zip and unzip
Copyright (C) 2009-2010 Mathias Svensson ( https://result42.com )
*/
#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
#ifndef __USE_FILE_OFFSET64
#define __USE_FILE_OFFSET64
#endif
#ifndef __USE_LARGEFILE64
|
| ︙ | ︙ | |||
35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #else #define FOPEN_FUNC(filename, mode) fopen64(filename, mode) #define FTELLO_FUNC(stream) ftello64(stream) #define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin) #endif #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <errno.h> #include <fcntl.h> #include <sys/stat.h> | > > > | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | #else #define FOPEN_FUNC(filename, mode) fopen64(filename, mode) #define FTELLO_FUNC(stream) ftello64(stream) #define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin) #endif #ifndef _CRT_SECURE_NO_WARNINGS # define _CRT_SECURE_NO_WARNINGS #endif #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <errno.h> #include <fcntl.h> #include <sys/stat.h> |
| ︙ | ︙ | |||
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
/* change_file_date : change the date/time of a file
filename : the filename of the file where date/time must be modified
dosdate : the new date at the MSDOS format (4 bytes)
tmu_date : the SAME new date at the tm_unz format */
static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_date) {
#ifdef _WIN32
HANDLE hFile;
FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
hFile = CreateFileA(filename,GENERIC_READ | GENERIC_WRITE,
0,NULL,OPEN_EXISTING,0,NULL);
GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite);
DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal);
LocalFileTimeToFileTime(&ftLocal,&ftm);
SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
CloseHandle(hFile);
| > < | | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
/* change_file_date : change the date/time of a file
filename : the filename of the file where date/time must be modified
dosdate : the new date at the MSDOS format (4 bytes)
tmu_date : the SAME new date at the tm_unz format */
static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_date) {
#ifdef _WIN32
(void)tmu_date;
HANDLE hFile;
FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
hFile = CreateFileA(filename,GENERIC_READ | GENERIC_WRITE,
0,NULL,OPEN_EXISTING,0,NULL);
GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite);
DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal);
LocalFileTimeToFileTime(&ftLocal,&ftm);
SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
CloseHandle(hFile);
#elif defined(__unix__) || defined(__unix) || defined(__APPLE__)
(void)dosdate;
struct utimbuf ut;
struct tm newdate;
newdate.tm_sec = tmu_date.tm_sec;
newdate.tm_min=tmu_date.tm_min;
newdate.tm_hour=tmu_date.tm_hour;
newdate.tm_mday=tmu_date.tm_mday;
|
| ︙ | ︙ | |||
112 113 114 115 116 117 118 | ut.actime=ut.modtime=mktime(&newdate); utime(filename,&ut); #else (void)filename; (void)dosdate; (void)tmu_date; #endif | < | < < | 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
ut.actime=ut.modtime=mktime(&newdate);
utime(filename,&ut);
#else
(void)filename;
(void)dosdate;
(void)tmu_date;
#endif
}
/* mymkdir and change_file_date are not 100 % portable
As I don't know well Unix, I wait feedback for the unix portion */
static int mymkdir(const char* dirname) {
int ret=0;
#ifdef _WIN32
ret = _mkdir(dirname);
#elif defined(__unix__) || defined(__unix) || defined(__APPLE__)
ret = mkdir (dirname,0775);
#else
(void)dirname;
#endif
return ret;
}
|
| ︙ | ︙ | |||
147 148 149 150 151 152 153 |
buffer = (char*)malloc(len+1);
if (buffer==NULL)
{
printf("Error allocating memory\n");
return UNZ_INTERNALERROR;
}
| | | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
buffer = (char*)malloc(len+1);
if (buffer==NULL)
{
printf("Error allocating memory\n");
return UNZ_INTERNALERROR;
}
memcpy(buffer,newdir,len+1);
if (buffer[len-1] == '/') {
buffer[len-1] = '\0';
}
if (mymkdir(buffer) == 0)
{
free(buffer);
|
| ︙ | ︙ | |||
183 184 185 186 187 188 189 |
}
free(buffer);
return 1;
}
static void do_banner(void) {
printf("MiniUnz 1.1, demo of zLib + Unz package written by Gilles Vollant\n");
| | | 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
}
free(buffer);
return 1;
}
static void do_banner(void) {
printf("MiniUnz 1.1, demo of zLib + Unz package written by Gilles Vollant\n");
printf("more info at https://www.winimage.com/zLibDll/unzip.html\n\n");
}
static void do_help(void) {
printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \
" -e Extract without pathname (junk paths)\n" \
" -x Extract with pathname\n" \
" -v list files\n" \
|
| ︙ | ︙ | |||
231 232 233 234 235 236 237 |
static int do_list(unzFile uf) {
uLong i;
unz_global_info64 gi;
int err;
err = unzGetGlobalInfo64(uf,&gi);
if (err!=UNZ_OK)
| | | | 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
static int do_list(unzFile uf) {
uLong i;
unz_global_info64 gi;
int err;
err = unzGetGlobalInfo64(uf,&gi);
if (err!=UNZ_OK)
printf("error %d with zipfile in unzGetGlobalInfo\n",err);
printf(" Length Method Size Ratio Date Time CRC-32 Name\n");
printf(" ------ ------ ---- ----- ---- ---- ------ ----\n");
for (i=0;i<gi.number_entry;i++)
{
char filename_inzip[65536+1];
unz_file_info64 file_info;
uLong ratio=0;
const char *string_method = "";
char charCrypt=' ';
err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
if (err!=UNZ_OK)
{
|
| ︙ | ︙ | |||
301 302 303 304 305 306 307 |
}
return 0;
}
static int do_extract_currentfile(unzFile uf, const int* popt_extract_without_path, int* popt_overwrite, const char* password) {
| | | 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
}
return 0;
}
static int do_extract_currentfile(unzFile uf, const int* popt_extract_without_path, int* popt_overwrite, const char* password) {
char filename_inzip[65536+1];
char* filename_withoutpath;
char* p;
int err=UNZ_OK;
FILE *fout=NULL;
void* buf;
uInt size_buf;
|
| ︙ | ︙ | |||
478 479 480 481 482 483 484 |
static int do_extract(unzFile uf, int opt_extract_without_path, int opt_overwrite, const char* password) {
uLong i;
unz_global_info64 gi;
int err;
err = unzGetGlobalInfo64(uf,&gi);
if (err!=UNZ_OK)
| > | > > | | > | | | < < < | 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
static int do_extract(unzFile uf, int opt_extract_without_path, int opt_overwrite, const char* password) {
uLong i;
unz_global_info64 gi;
int err;
err = unzGetGlobalInfo64(uf,&gi);
if (err!=UNZ_OK)
{
printf("error %d with zipfile in unzGetGlobalInfo\n",err);
return err;
}
for (i=0;i<gi.number_entry;i++)
{
err = do_extract_currentfile(uf,&opt_extract_without_path,
&opt_overwrite,
password);
if (err != UNZ_OK)
break;
if ((i+1)<gi.number_entry)
{
err = unzGoToNextFile(uf);
if (err!=UNZ_OK)
{
printf("error %d with zipfile in unzGoToNextFile\n",err);
break;
}
}
}
return err;
}
static int do_extract_onefile(unzFile uf, const char* filename, int opt_extract_without_path, int opt_overwrite, const char* password) {
if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK)
{
printf("file %s not found in the zipfile\n",filename);
return 2;
}
return do_extract_currentfile(uf,&opt_extract_without_path,
&opt_overwrite,
password);
}
int main(int argc, char *argv[]) {
const char *zipfilename=NULL;
const char *filename_to_extract=NULL;
const char *password=NULL;
|
| ︙ | ︙ |
Changes to compat/zlib/contrib/minizip/minizip.c.
1 2 | /* minizip.c | < | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
/*
minizip.c
sample part of the MiniZip project - ( https://www.winimage.com/zLibDll/minizip.html )
Copyright (C) 1998-2026 Gilles Vollant (minizip) ( https://www.winimage.com/zLibDll/minizip.html )
Modifications of Unzip for Zip64
Copyright (C) 2007-2008 Even Rouault
Modifications for Zip64 support on both zip and unzip
Copyright (C) 2009-2010 Mathias Svensson ( https://result42.com )
*/
#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
#ifndef __USE_FILE_OFFSET64
#define __USE_FILE_OFFSET64
#endif
|
| ︙ | ︙ | |||
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 |
#define FOPEN_FUNC(filename, mode) fopen64(filename, mode)
#define FTELLO_FUNC(stream) ftello64(stream)
#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include <fcntl.h>
#ifdef _WIN32
# include <direct.h>
# include <io.h>
#else
# include <unistd.h>
# include <utime.h>
# include <sys/types.h>
# include <sys/stat.h>
#endif
#include "zip.h"
#ifdef _WIN32
#define USEWIN32IOAPI
#include "iowin32.h"
#endif
#define WRITEBUFFERSIZE (16384)
#define MAXFILENAME (256)
#ifdef _WIN32
/* f: name of file to get info on, tmzip: return value: access,
modification and creation times, dt: dostime */
static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
int ret = 0;
{
FILETIME ftLocal;
HANDLE hFind;
WIN32_FIND_DATAA ff32;
hFind = FindFirstFileA(f,&ff32);
if (hFind != INVALID_HANDLE_VALUE)
{
FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal);
FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0);
FindClose(hFind);
ret = 1;
}
}
return ret;
}
| > > > > > < | | 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 102 103 104 105 |
#define FOPEN_FUNC(filename, mode) fopen64(filename, mode)
#define FTELLO_FUNC(stream) ftello64(stream)
#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)
#endif
#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include <fcntl.h>
#ifdef _WIN32
# include <direct.h>
# include <io.h>
#else
# include <unistd.h>
# include <utime.h>
# include <sys/types.h>
# include <sys/stat.h>
#endif
#include "zip.h"
#include "ints.h"
#ifdef _WIN32
#define USEWIN32IOAPI
#include "iowin32.h"
#endif
#define WRITEBUFFERSIZE (16384)
#define MAXFILENAME (256)
#ifdef _WIN32
/* f: name of file to get info on, tmzip: return value: access,
modification and creation times, dt: dostime */
static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
(void)tmzip;
int ret = 0;
{
FILETIME ftLocal;
HANDLE hFind;
WIN32_FIND_DATAA ff32;
hFind = FindFirstFileA(f,&ff32);
if (hFind != INVALID_HANDLE_VALUE)
{
FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal);
FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0);
FindClose(hFind);
ret = 1;
}
}
return ret;
}
#elif defined(__unix__) || defined(__unix) || defined(__APPLE__)
/* f: name of file to get info on, tmzip: return value: access,
modification and creation times, dt: dostime */
static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
(void)dt;
int ret=0;
struct stat s; /* results of stat() */
struct tm* filedate;
|
| ︙ | ︙ | |||
139 140 141 142 143 144 145 |
static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
(void)f;
(void)tmzip;
(void)dt;
return 0;
}
#endif
| < | | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
(void)f;
(void)tmzip;
(void)dt;
return 0;
}
#endif
static int check_exist_file(const char* filename) {
FILE* ftestexist;
int ret = 1;
ftestexist = FOPEN_FUNC(filename,"rb");
if (ftestexist==NULL)
ret = 0;
else
fclose(ftestexist);
return ret;
}
static void do_banner(void) {
printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vollant\n");
printf("more info on MiniZip at https://www.winimage.com/zLibDll/minizip.html\n\n");
}
static void do_help(void) {
printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add]\n\n" \
" -o Overwrite existing file.zip\n" \
" -a Append to existing file.zip\n" \
" -0 Store only\n" \
|
| ︙ | ︙ | |||
188 189 190 191 192 193 194 |
err = ZIP_ERRNO;
}
if (err == ZIP_OK)
do
{
err = ZIP_OK;
| | | 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
err = ZIP_ERRNO;
}
if (err == ZIP_OK)
do
{
err = ZIP_OK;
size_read = (unsigned long)fread(buf,1,size_buf,fin);
if (size_read < size_buf)
if (feof(fin)==0)
{
printf("error in reading %s\n",filenameinzip);
err = ZIP_ERRNO;
}
|
| ︙ | ︙ | |||
220 221 222 223 224 225 226 |
FILE* pFile = FOPEN_FUNC(filename, "rb");
if(pFile != NULL)
{
FSEEKO_FUNC(pFile, 0, SEEK_END);
pos = (ZPOS64_T)FTELLO_FUNC(pFile);
| | | | 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
FILE* pFile = FOPEN_FUNC(filename, "rb");
if(pFile != NULL)
{
FSEEKO_FUNC(pFile, 0, SEEK_END);
pos = (ZPOS64_T)FTELLO_FUNC(pFile);
printf("File : %s is %"PUI64" bytes\n", filename, pos);
if(pos >= 0xffffffff)
largeFile = 1;
fclose(pFile);
}
return largeFile;
}
int main(int argc, char *argv[]) {
int i;
int opt_overwrite=0;
int opt_compress_level=Z_DEFAULT_COMPRESSION;
int opt_exclude_path=0;
int zipfilenamearg = 0;
char filename_try[MAXFILENAME+16];
int zipok;
int err=0;
unsigned long size_buf=0;
void* buf=NULL;
const char* password=NULL;
do_banner();
if (argc==1)
{
|
| ︙ | ︙ | |||
302 303 304 305 306 307 308 |
if (zipfilenamearg==0)
{
zipok=0;
}
else
{
| | | 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
if (zipfilenamearg==0)
{
zipok=0;
}
else
{
int len;
int dot_found=0;
zipok = 1 ;
strncpy(filename_try, argv[zipfilenamearg],MAXFILENAME-1);
/* strncpy doesn't append the trailing NULL, of the string is too long. */
filename_try[ MAXFILENAME ] = '\0';
|
| ︙ | ︙ | |||
428 429 430 431 432 433 434 |
if( *tmpptr == '\\' || *tmpptr == '/')
{
lastslash = tmpptr;
}
}
if( lastslash != NULL )
{
| | | 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 |
if( *tmpptr == '\\' || *tmpptr == '/')
{
lastslash = tmpptr;
}
}
if( lastslash != NULL )
{
savefilenameinzip = lastslash+1; /* base filename follows last slash. */
}
}
/**/
err = zipOpenNewFileInZip3_64(zf,savefilenameinzip,&zi,
NULL,0,NULL,0,NULL /* comment*/,
(opt_compress_level != 0) ? Z_DEFLATED : 0,
|
| ︙ | ︙ | |||
501 502 503 504 505 506 507 |
}
else
{
do_help();
}
free(buf);
| | | 503 504 505 506 507 508 509 510 511 |
}
else
{
do_help();
}
free(buf);
return err;
}
|
Changes to compat/zlib/contrib/minizip/minizip.pc.in.
1 2 3 | prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 |
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: minizip
Description: Minizip zip file manipulation library
Requires:
Version: @PACKAGE_VERSION@
License: Zlib
Libs: -L${libdir} -lminizip
Libs.private: -lz
Cflags: -I${includedir}
|
Added compat/zlib/contrib/minizip/minizip.pc.txt.
> > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 |
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
sharedlibdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${exec_prefix}/@CMAKE_INSTALL_INCLUDEDIR@
Name: minizip
Description: minizip compression library
Version: @minizip_VERSION@
Requires:
Libs: -L${libdir} -L${sharedlibdir} -lz -lminizip
Cflags: -I${includedir}
|
Added compat/zlib/contrib/minizip/minizipConfig.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
@PACKAGE_INIT@
set(_MINIZIP_supported_components "shared" "static")
include(CMakeFindDependencyMacro)
if(@MINIZIP_ENABLE_BZIP2@)
find_dependency(BZip2)
endif(@MINIZIP_ENABLE_BZIP2@)
if(minizip_FIND_COMPONENTS)
find_dependency(ZLIB CONFIG COMPONENTS ${minizip_FIND_COMPONENTS})
foreach(_comp ${minizip_FIND_COMPONENTS})
if(NOT _comp IN_LIST _MINIZIP_supported_components)
set(minizip_FOUND False)
set(minizip_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
endif(NOT _comp IN_LIST _MINIZIP_supported_components)
include("${CMAKE_CURRENT_LIST_DIR}/minizip-${_comp}.cmake")
endforeach(_comp ${ZLIB_FIND_COMPONENTS})
else(minizip_FIND_COMPONENTS)
find_dependency(ZLIB CONFIG)
foreach(_component_config IN LISTS _MINIZIP_supported_components)
include("${CMAKE_CURRENT_LIST_DIR}/minizip-${_component_config}.cmake")
endforeach(_component_config IN LISTS _MINIZIP_supported_components)
endif(minizip_FIND_COMPONENTS)
|
Changes to compat/zlib/contrib/minizip/mztools.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* Additional tools for Minizip Code: Xavier Roche '2004 License: Same as ZLIB (www.gzip.org) */ /* Code */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "zlib.h" #include "unzip.h" #define READ_8(adr) ((unsigned char)*(adr)) | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* Additional tools for Minizip Code: Xavier Roche '2004 License: Same as ZLIB (www.gzip.org) */ /* Code */ #ifndef _CRT_SECURE_NO_WARNINGS # define _CRT_SECURE_NO_WARNINGS #endif #include <stdio.h> #include <stdlib.h> #include <string.h> #include "zlib.h" #include "unzip.h" #define READ_8(adr) ((unsigned char)*(adr)) |
| ︙ | ︙ | |||
28 29 30 31 32 33 34 |
} while(0)
extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char* fileOutTmp, uLong* nRecovered, uLong* bytesRecovered) {
int err = Z_OK;
FILE* fpZip = fopen(file, "rb");
FILE* fpOut = fopen(fileOut, "wb");
FILE* fpOutCD = fopen(fileOutTmp, "wb");
| | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
} while(0)
extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char* fileOutTmp, uLong* nRecovered, uLong* bytesRecovered) {
int err = Z_OK;
FILE* fpZip = fopen(file, "rb");
FILE* fpOut = fopen(fileOut, "wb");
FILE* fpOutCD = fopen(fileOutTmp, "wb");
if (fpZip != NULL && fpOut != NULL && fpOutCD != NULL ) {
int entries = 0;
uLong totalBytes = 0;
char header[30];
char filename[1024];
char extra[1024];
int offset = 0;
int offsetCD = 0;
|
| ︙ | ︙ | |||
136 137 138 139 140 141 142 |
break;
}
}
}
/* Central directory entry */
{
| | | | | | | | | | | | | | | | | | | | | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
break;
}
}
}
/* Central directory entry */
{
char central[46];
char* comment = "";
int comsize = (int) strlen(comment);
WRITE_32(central, 0x02014b50);
WRITE_16(central + 4, version);
WRITE_16(central + 6, version);
WRITE_16(central + 8, gpflag);
WRITE_16(central + 10, method);
WRITE_16(central + 12, filetime);
WRITE_16(central + 14, filedate);
WRITE_32(central + 16, crc);
WRITE_32(central + 20, cpsize);
WRITE_32(central + 24, uncpsize);
WRITE_16(central + 28, fnsize);
WRITE_16(central + 30, extsize);
WRITE_16(central + 32, comsize);
WRITE_16(central + 34, 0); /* disk # */
WRITE_16(central + 36, 0); /* int attrb */
WRITE_32(central + 38, 0); /* ext attrb */
WRITE_32(central + 42, currentOffset);
/* Header */
if (fwrite(central, 1, 46, fpOutCD) == 46) {
offsetCD += 46;
/* Filename */
if (fnsize > 0) {
if (fwrite(filename, 1, fnsize, fpOutCD) == fnsize) {
offsetCD += fnsize;
} else {
|
| ︙ | ︙ | |||
211 212 213 214 215 216 217 |
break;
}
}
/* Final central directory */
{
int entriesZip = entries;
| | | | | | | | | | | | | 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
break;
}
}
/* Final central directory */
{
int entriesZip = entries;
char end[22];
char* comment = ""; /* "ZIP File recovered by zlib/minizip/mztools"; */
int comsize = (int) strlen(comment);
if (entriesZip > 0xffff) {
entriesZip = 0xffff;
}
WRITE_32(end, 0x06054b50);
WRITE_16(end + 4, 0); /* disk # */
WRITE_16(end + 6, 0); /* disk # */
WRITE_16(end + 8, entriesZip); /* hack */
WRITE_16(end + 10, entriesZip); /* hack */
WRITE_32(end + 12, offsetCD); /* size of CD */
WRITE_32(end + 16, offset); /* offset to CD */
WRITE_16(end + 20, comsize); /* comment */
/* Header */
if (fwrite(end, 1, 22, fpOutCD) == 22) {
/* Comment field */
if (comsize > 0) {
if ((int)fwrite(comment, 1, comsize, fpOutCD) != comsize) {
err = Z_ERRNO;
}
}
|
| ︙ | ︙ | |||
275 276 277 278 279 280 281 282 283 284 285 |
*nRecovered = entries;
}
if (bytesRecovered != NULL) {
*bytesRecovered = totalBytes;
}
}
} else {
err = Z_STREAM_ERROR;
}
return err;
}
| > > > > > > | 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
*nRecovered = entries;
}
if (bytesRecovered != NULL) {
*bytesRecovered = totalBytes;
}
}
} else {
if (fpOutCD != NULL)
fclose(fpOutCD);
if (fpZip != NULL)
fclose(fpZip);
if (fpOut != NULL)
fclose(fpOut);
err = Z_STREAM_ERROR;
}
return err;
}
|
Added compat/zlib/contrib/minizip/skipset.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
/* skipset.h -- set operations using a skiplist
// Copyright (C) 2024-2026 Mark Adler
// See MiniZip_info.txt for the license.
// This implements a skiplist set, i.e. just keys, no data, with ~O(log n) time
// insert and search operations. The application defines the type of a key, and
// provides a function to compare two keys.
// This header is not definitions of functions found in another source file --
// it creates the set functions, with the application's key type, right where
// the #include is. Before this header is #included, these must be defined:
//
// 1. A macro or typedef for set_key_t, the type of a key.
// 2. A macro or function set_cmp(a, b) to compare two keys. The return values
// are < 0 for a < b, 0 for a == b, and > 0 for a > b.
// 3. A macro or function set_drop(s, k) to release the key k's resources, if
// any, when doing a set_end() or set_clear(). s is a pointer to the set
// that key is in, for use with set_free() if desired.
//
// Example usage:
//
// typedef int set_key_t;
// #define set_cmp(a, b) ((a) < (b) ? -1 : (a) == (b) ? 0 : 1)
// #define set_drop(s, k)
// #include "skipset.h"
//
// int test(void) { // return 0: good, 1: bad, -1: out of memory
// set_t set;
// if (setjmp(set.env))
// return -1;
// set_start(&set);
// set_insert(&set, 2);
// set_insert(&set, 1);
// set_insert(&set, 7);
// int bad = !set_found(&set, 2);
// bad = bad || set_found(&set, 5);
// set_end(&set);
// return bad;
// }
//
// Interface summary (see more details below):
// - set_t is the type of the set being operated on (a set_t pointer is passed)
// - set_start() initializes a new, empty set (initialize set.env first)
// - set_insert() inserts a new key into the set, or not if it's already there
// - set_found() determines whether or not a key is in the set
// - set_end() ends the use of the set, freeing all memory
// - set_clear() empties the set, equivalent to set_end() and then set_start()
// - set_ok() checks if set appears to be usable, i.e. started and not ended
//
// Auxiliary functions available to the application:
// - set_alloc() allocates memory with optional tracking (#define SET_TRACK)
// - set_free() deallocates memory allocated by set_alloc()
// - set_rand() returns 32 random bits (seeded by set_start()) */
#ifndef SKIPSET_H
#define SKIPSET_H
#include <stdlib.h> /* realloc(), free(), NULL, size_t */
#include <stddef.h> /* ptrdiff_t */
#include <setjmp.h> /* jmp_buf, longjmp() */
#include <errno.h> /* ENOMEM */
#include <time.h> /* time(), clock() */
#include <assert.h> /* assert.h */
#include "ints.h" /* i16_t, ui32_t, ui64_t */
/* Structures and functions below noted as "--private--" should not be used by
// the application. set_t is partially private and partially public -- see the
// comments there.
// There is no POSIX random() in MSVC, and rand() is awful. For portability, we
// cannot rely on a library function for random numbers. Instead we use the
// fast and effective algorithm below, invented by Melissa O'Neill.
// *Really* minimal PCG32 code / (c) 2014 M.E. O'Neill / www.pcg-random.org
// Licensed under Apache License 2.0 (NO WARRANTY, etc. see website)
// --private-- Random number generator state. */
typedef struct {
ui64_t state; /* 64-bit generator state */
ui64_t inc; /* 63-bit sequence id */
} set_rand_t;
/* --private-- Initialize the state *gen using seed and seq. seed seeds the
// advancing 64-bit state. seq is a sequence selection constant. */
void set_seed(set_rand_t *gen, ui64_t seed, ui64_t seq) {
gen->inc = (seq << 1) | 1;
gen->state = (seed + gen->inc) * 6364136223846793005ULL + gen->inc;
}
/* Start a unique random number sequence using bits from noise sources. */
void set_uniq(set_rand_t *gen, const void *ptr) {
set_seed(gen, ((ui64_t)(ptrdiff_t)ptr << 32) ^
((ui64_t)time(NULL) << 12) ^ clock(), 0);
}
/* Return 32 random bits, advancing the state *gen. */
ui32_t set_rand(set_rand_t *gen) {
ui64_t state = gen->state;
gen->state = state * 6364136223846793005ULL + gen->inc;
ui32_t mix = (ui32_t)(((state >> 18) ^ state) >> 27);
int rot = state >> 59;
return (mix >> rot) | (mix << ((-rot) & 31));
}
/* End of PCG32 code. */
/* --private-- Linked-list node. */
typedef struct set_node_s set_node_t;
struct set_node_s {
set_key_t key; /* the key (not used for head or path) */
i16_t size; /* number of allocated pointers in right[] */
i16_t fill; /* number of pointers in right[] filled in */
set_node_t **right; /* pointer for each level, each to the right */
};
/* A set. The application sets env, may use gen with set_rand(), and may read
// allocs and memory. The remaining variables are --private-- . */
typedef struct set_s {
set_node_t *head; /* skiplist head -- no key, just links */
set_node_t *path; /* right[] is path to key from set_found() */
set_node_t *node; /* node under construction, in case of longjmp() */
i16_t depth; /* maximum depth of the skiplist */
ui64_t ran; /* a precious trove of random bits */
set_rand_t gen; /* random number generator state */
jmp_buf env; /* setjmp() environment for allocation errors */
#ifdef SET_TRACK
size_t allocs; /* number of allocations */
size_t memory; /* total amount of allocated memory (>= requests) */
#endif
} set_t;
/* Memory allocation and deallocation. set_alloc(set, ptr, size) returns a
// pointer to an allocation of size bytes if ptr is NULL, or the previous
// allocation ptr resized to size bytes. set_alloc() will never return NULL.
// set_free(set, ptr) frees an allocation created by set_alloc(). These may be
// used by the application. e.g. if allocation tracking is desired. */
#ifdef SET_TRACK
/* Track the number of allocations and the total backing memory size. */
# if defined(_WIN32)
# include <malloc.h>
# define SET_ALLOC_SIZE(ptr) _msize(ptr)
# elif defined(__MACH__)
# include <malloc/malloc.h>
# define SET_ALLOC_SIZE(ptr) malloc_size(ptr)
# elif defined(__linux__)
# include <malloc.h>
# define SET_ALLOC_SIZE(ptr) malloc_usable_size(ptr)
# elif defined(__FreeBSD__)
# include <malloc_np.h>
# define SET_ALLOC_SIZE(ptr) malloc_usable_size(ptr)
# elif defined(__NetBSD__)
# include <jemalloc/jemalloc.h>
# define SET_ALLOC_SIZE(ptr) malloc_usable_size(ptr)
# else // e.g. OpenBSD
# define SET_ALLOC_SIZE(ptr) 0
# endif
// With tracking.
void *set_alloc(set_t *set, void *ptr, size_t size) {
size_t had = ptr == NULL ? 0 : SET_ALLOC_SIZE(ptr);
void *mem = realloc(ptr, size);
if (mem == NULL)
longjmp(set->env, ENOMEM);
set->allocs += ptr == NULL;
set->memory += SET_ALLOC_SIZE(mem) - had;
return mem;
}
void set_free(set_t *set, void *ptr) {
if (ptr != NULL) {
set->allocs--;
set->memory -= SET_ALLOC_SIZE(ptr);
free(ptr);
}
}
#else
/* Without tracking. */
void *set_alloc(set_t *set, void *ptr, size_t size) {
void *mem = realloc(ptr, size);
if (mem == NULL)
longjmp(set->env, ENOMEM);
return mem;
}
void set_free(set_t *set, void *ptr) {
(void)set;
free(ptr);
}
#endif
/* --private-- Grow node's array right[] as needed to be able to hold at least
// want links. If fill is true, assure that the first want links are filled in,
// setting them to set->head if not previously filled in. Otherwise it is
// assumed that the first want links are about to be filled in. */
void set_grow(set_t *set, set_node_t *node, int want, int fill) {
if (node->size < want) {
int more = node->size ? node->size : 1;
while (more < want)
more <<= 1;
node->right = set_alloc(set, node->right,
(size_t)more * sizeof(set_node_t *));
node->size = (i16_t)more;
}
int i;
if (fill)
for (i = node->fill; i < want; i++)
node->right[i] = set->head;
node->fill = (i16_t)want;
}
/* --private-- Return a new node. key is left uninitialized. */
set_node_t *set_node(set_t *set) {
set_node_t *node = set_alloc(set, NULL, sizeof(set_node_t));
node->size = 0;
node->fill = 0;
node->right = NULL;
return node;
}
/* --private-- Free the list linked from head, along with the keys. */
void set_sweep(set_t *set) {
set_node_t *step = set->head->right[0];
while (step != set->head) {
set_node_t *next = step->right[0]; /* save link to next node */
set_drop(set, step->key);
set_free(set, step->right);
set_free(set, step);
step = next;
}
}
/* Initialize a new set. set->env must be initialized using setjmp() before
// set_start() is called. A longjmp(set->env, ENOMEM) will be used to handle a
// memory allocation failure during any of the operations. (See setjmp.h and
// errno.h.) The set can still be used if this happens, assuming that it didn't
// happen during set_start(). Whether set_start() completed or not, set_end()
// can be used to free the set's memory after a longjmp(). */
void set_start(set_t *set) {
#ifdef SET_TRACK
set->allocs = 0;
set->memory = 0;
#endif
set->head = set->path = set->node = NULL; /* in case set_node() fails */
set->path = set_node(set);
set->head = set_node(set);
set_grow(set, set->head, 1, 1); /* one link back to head for an empty set */
*(unsigned char *)&set->head->key = 137; /* set id */
set->depth = 0;
set_uniq(&set->gen, set);
set->ran = 1;
}
/* Return true if *set appears to be in a usable state. If *set has been zeroed
// out, then set_ok(set) will be false and set_end(set) will be safe. */
int set_ok(set_t *set) {
return set->head != NULL &&
set->head->right != NULL &&
*(unsigned char *)&set->head->key == 137;
}
/* Empty the set. This frees the memory used for the previous set contents.
// After set_clear(), *set is ready for use, as if after a set_start(). */
void set_clear(set_t *set) {
assert(set_ok(set) && "improper use");
/* Free all the keys and their nodes. */
set_sweep(set);
/* Leave the head and path allocations as is. Clear their contents, with
// head pointing to itself and setting depth to zero, for an empty set. */
set->head->right[0] = set->head;
set->head->fill = 1;
set->path->fill = 0;
set->depth = 0;
}
/* Done using the set -- free all allocations. The only operation on *set
// permitted after this is set_start(). Though another set_end() would do no
// harm. This can be done at any time after a set_start(), or after a longjmp()
// on any allocation failure, including during a set_start(). */
void set_end(set_t *set) {
if (set->head != NULL) {
/* Empty the set and free the head node. */
if (set->head->right != NULL) {
set_sweep(set);
set_free(set, set->head->right);
}
set_free(set, set->head);
set->head = NULL;
}
if (set->path != NULL) {
/* Free the path work area. */
set_free(set, set->path->right);
set_free(set, set->path);
set->path = NULL;
}
if (set->node != NULL) {
/* Free the node that was under construction when longjmp() hit. */
set_drop(set, set->node->key);
set_free(set, set->node->right);
set_free(set, set->node);
set->node = NULL;
}
}
/* Look for key. Return 1 if found or 0 if not. This also puts the path to get
// there in set->path, for use by set_insert(). */
int set_found(set_t *set, set_key_t key) {
assert(set_ok(set) && "improper use");
/* Start at depth and work down and right as determined by key comparisons. */
set_node_t *head = set->head, *here = head;
int i = set->depth;
set_grow(set, set->path, i + 1, 0);
do {
while (here->right[i] != head &&
set_cmp(here->right[i]->key, key) < 0)
here = here->right[i];
set->path->right[i] = here;
} while (i--);
/* See if the key matches. */
here = here->right[0];
return here != head && set_cmp(here->key, key) == 0;
}
/* Insert the key key. Return 0 on success, or 1 if key is already in the set. */
int set_insert(set_t *set, set_key_t key) {
assert(set_ok(set) && "improper use");
if (set_found(set, key))
/* That key is already in the set. */
return 1;
/* Randomly generate a new level-- level 0 with probability 1/2, 1 with
// probability 1/4, 2 with probability 1/8, etc. */
int level = 0;
for (;;) {
if (set->ran == 1)
/* Ran out. Get another 32 random bits. */
set->ran = set_rand(&set->gen) | (1ULL << 32);
int bit = set->ran & 1;
set->ran >>= 1;
if (bit)
break;
assert(level < 32767 &&
"Overhead, without any fuss, the stars were going out.");
level++;
}
if (level > set->depth) {
/* The maximum depth is now deeper. Update the structures. */
set_grow(set, set->path, level + 1, 1);
set_grow(set, set->head, level + 1, 1);
set->depth = (i16_t)level;
}
/* Make a new node for the provided key, and insert it in the lists up to
// and including level. */
set->node = set_node(set);
set->node->key = key;
set_grow(set, set->node, level + 1, 0);
int i;
for (i = 0; i <= level; i++) {
set->node->right[i] = set->path->right[i]->right[i];
set->path->right[i]->right[i] = set->node;
}
set->node = NULL;
return 0;
}
#else
#error ** another skiplist set already created here
/* Would need to implement a prefix in order to support multiple sets. */
#endif
|
Added compat/zlib/contrib/minizip/test/CMakeLists.txt.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# if we are built from with zlib, use this path's)
if(DEFINED ZLIB_BUILD_MINIZIP)
set(WORK_DIR ${zlib_BINARY_DIR})
set(inst_setup zlib_install)
else(DEFINED ZLIB_BUILD_MINIZIP)
set(WORK_DIR ${minizip_BINARY_DIR})
set(inst_setup minizip_install)
set(ZLIB_ARG "-DZLIB_DIR=${ZLIB_DIR}")
add_test(
NAME minizip_install
COMMAND ${CMAKE_COMMAND} --install ${minizip_BINARY_DIR} --prefix
${CMAKE_CURRENT_BINARY_DIR}/test_install --config $<CONFIG>
WORKING_DIRECTORY ${minizip_BINARY_DIR})
set_tests_properties(minizip_install
PROPERTIES
FIXTURES_SETUP minizip_install)
endif(DEFINED ZLIB_BUILD_MINIZIP)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_no_componentstest)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_wrong_components_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/find_package_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/findpackage_test/CMakeLists.txt @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/find_package_no_components_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/findpackage_no_components_test/CMakeLists.txt
@ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/find_package_wrong_components_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/findpackage_wrong_components_test/CMakeLists.txt
@ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test/CMakeLists.txt @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_exclude_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test/CMakeLists.txt
@ONLY)
# CMAKE_GENERATOR_PLATFORM doesn't work in the if
set(GENERATOR ${CMAKE_GENERATOR_PLATFORM})
if(GENERATOR)
set(PLATFORM "-A ${GENERATOR}")
endif(GENERATOR)
#
# findpackage_test
#
add_test(
NAME minizip_find_package_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh -G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
add_test(
NAME minizip_find_package_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
set_tests_properties(
minizip_find_package_configure PROPERTIES FIXTURES_REQUIRED ${inst_setup}
FIXTURES_SETUP mzfp_config)
set_tests_properties(minizip_find_package_build PROPERTIES FIXTURES_REQUIRED
mzfp_config)
#
# findpackage_no_components_test
#
add_test(
NAME minizip_find_package_no_components_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/findpackage_no_components_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh -G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_no_components_test)
set_tests_properties(
minizip_find_package_no_components_configure PROPERTIES FIXTURES_REQUIRED ${inst_setup})
if(NOT MINIZIP_BUILD_SHARED OR NOT MINIZIP_BUILD_STATIC)
set_tests_properties(
minizip_find_package_no_components_configure PROPERTIES WILL_FAIL TRUE)
endif(NOT MINIZIP_BUILD_SHARED OR NOT MINIZIP_BUILD_STATIC)
#
# findpackage_no_components_test
#
add_test(
NAME minizip_find_package_wrong_components_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/findpackage_wrong_components_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh -G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_wrong_components_test)
set_tests_properties(
minizip_find_package_wrong_components_configure
PROPERTIES
FIXTURES_REQUIRED ${inst_setup}
WILL_FAIL TRUE)
#
# add_subdirectory_test
#
add_test(
NAME minizip_add_subdirectory_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh -G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test)
add_test(
NAME minizip_add_subdirectory_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
set_tests_properties(
minizip_add_subdirectory_configure
PROPERTIES FIXTURES_REQUIRED ${inst_setup} FIXTURES_SETUP mzas_config)
set_tests_properties(minizip_add_subdirectory_build PROPERTIES FIXTURES_REQUIRED
mzas_config)
#
# add_subdirectory_exclude_test
#
add_test(
NAME minizip_add_subdirectory_exclude_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh -G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test)
add_test(
NAME minizip_add_subdirectory_exclude_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
set_tests_properties(
minizip_add_subdirectory_exclude_configure
PROPERTIES FIXTURES_REQUIRED ${inst_setup} FIXTURES_SETUP mzasx_config)
set_tests_properties(minizip_add_subdirectory_exclude_build
PROPERTIES FIXTURES_REQUIRED mzasx_config)
|
Added compat/zlib/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
minizip_add_subdirectory_exclude_from_all
LANGUAGES C
VERSION @minizip_VERSION@)
option(MINIZIP_BUILD_TESTING "" OFF)
option(MINIZIP_BUILD_SHARED "" @MINIZIP_BUILD_SHARED@)
option(MINIZIP_BUILD_STATIC "" @MINIZIP_BUILD_STATIC@)
option(MINIZIP_ENABLE_BZIP2 "" @MINIZIP_ENABLE_BZIP2@)
add_subdirectory(@minizip_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/minizip
EXCLUDE_FROM_ALL)
set(MINIZIP_SRCS
@minizip_SOURCE_DIR@/ioapi.c
$<$<BOOL:${WIN32}>:@minizip_SOURCE_DIR@/iowin32.c>
@minizip_SOURCE_DIR@/minizip.c @minizip_SOURCE_DIR@/zip.c)
if(MINIZIP_BUILD_SHARED)
add_executable(test_example ${MINIZIP_SRCS})
target_link_libraries(test_example MINIZIP::minizip)
endif(MINIZIP_BUILD_SHARED)
if(MINIZIP_BUILD_STATIC)
add_executable(test_example_static ${MINIZIP_SRCS})
target_link_libraries(test_example_static MINIZIP::minizipstatic)
endif(MINIZIP_BUILD_STATIC)
|
Added compat/zlib/contrib/minizip/test/add_subdirectory_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
minizip_add_subdirectory_exclude_from_all
LANGUAGES C
VERSION @minizip_VERSION@)
option(MINIZIP_BUILD_TESTING "" OFF)
option(MINIZIP_BUILD_SHARED "" @MINIZIP_BUILD_SHARED@)
option(MINIZIP_BUILD_STATIC "" @MINIZIP_BUILD_STATIC@)
option(MINIZIP_ENABLE_BZIP2 "" @MINIZIP_ENABLE_BZIP2@)
add_subdirectory(@minizip_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/minizip)
set(MINIZIP_SRCS
@minizip_SOURCE_DIR@/ioapi.c
$<$<BOOL:${WIN32}>:@minizip_SOURCE_DIR@/iowin32.c>
@minizip_SOURCE_DIR@/minizip.c @minizip_SOURCE_DIR@/zip.c)
if(MINIZIP_BUILD_SHARED)
add_executable(test_example ${MINIZIP_SRCS})
target_link_libraries(test_example MINIZIP::minizip)
endif(MINIZIP_BUILD_SHARED)
if(MINIZIP_BUILD_STATIC)
add_executable(test_example_static ${MINIZIP_SRCS})
target_link_libraries(test_example_static MINIZIP::minizipstatic)
endif(MINIZIP_BUILD_STATIC)
|
Added compat/zlib/contrib/minizip/test/find_package_no_components_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
minizip_find_package
LANGUAGES C
VERSION @minizip_VERSION@)
option(MINIZIP_BUILD_SHARED "" @MINIZIP_BUILD_SHARED@)
option(MINIZIP_BUILD_STATIC "" @MINIZIP_BUILD_STATIC@)
find_package(minizip ${minizip_VERSION} CONFIG REQUIRED)
set(MINIZIP_SRCS
@minizip_SOURCE_DIR@/ioapi.c
$<$<BOOL:${WIN32}>:@minizip_SOURCE_DIR@/iowin32.c>
@minizip_SOURCE_DIR@/minizip.c @minizip_SOURCE_DIR@/zip.c)
if(MINIZIP_BUILD_SHARED)
add_executable(test_example ${MINIZIP_SRCS})
target_link_libraries(test_example MINIZIP::minizip)
endif(MINIZIP_BUILD_SHARED)
if(MINIZIP_BUILD_STATIC)
add_executable(test_example_static ${MINIZIP_SRCS})
target_link_libraries(test_example_static MINIZIP::minizipstatic)
endif(MINIZIP_BUILD_STATIC)
|
Added compat/zlib/contrib/minizip/test/find_package_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
minizip_find_package
LANGUAGES C
VERSION @minizip_VERSION@)
option(MINIZIP_BUILD_SHARED "" @MINIZIP_BUILD_SHARED@)
option(MINIZIP_BUILD_STATIC "" @MINIZIP_BUILD_STATIC@)
set(MINIZIP_SRCS
@minizip_SOURCE_DIR@/ioapi.c
$<$<BOOL:${WIN32}>:@minizip_SOURCE_DIR@/iowin32.c>
@minizip_SOURCE_DIR@/minizip.c @minizip_SOURCE_DIR@/zip.c)
if(MINIZIP_BUILD_SHARED)
find_package(minizip ${minizip_VERSION} CONFIG COMPONENTS shared REQUIRED)
add_executable(test_example ${MINIZIP_SRCS})
target_link_libraries(test_example MINIZIP::minizip)
endif(MINIZIP_BUILD_SHARED)
if(MINIZIP_BUILD_STATIC)
find_package(minizip ${minizip_VERSION} CONFIG COMPONENTS static REQUIRED)
add_executable(test_example_static ${MINIZIP_SRCS})
target_link_libraries(test_example_static MINIZIP::minizipstatic)
endif(MINIZIP_BUILD_STATIC)
|
Added compat/zlib/contrib/minizip/test/find_package_wrong_components_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
minizip_find_package
LANGUAGES C
VERSION @minizip_VERSION@)
option(MINIZIP_BUILD_SHARED "" @MINIZIP_BUILD_SHARED@)
option(MINIZIP_BUILD_STATIC "" @MINIZIP_BUILD_STATIC@)
find_package(minizip ${minizip_VERSION} CONFIG COMPONENTS wrong REQUIRED)
set(MINIZIP_SRCS
@minizip_SOURCE_DIR@/ioapi.c
$<$<BOOL:${WIN32}>:@minizip_SOURCE_DIR@/iowin32.c>
@minizip_SOURCE_DIR@/minizip.c @minizip_SOURCE_DIR@/zip.c)
if(MINIZIP_BUILD_SHARED)
add_executable(test_example ${MINIZIP_SRCS})
target_link_libraries(test_example MINIZIP::minizip)
endif(MINIZIP_BUILD_SHARED)
if(MINIZIP_BUILD_STATIC)
add_executable(test_example_static ${MINIZIP_SRCS})
target_link_libraries(test_example_static MINIZIP::minizipstatic)
endif(MINIZIP_BUILD_STATIC)
|
Added compat/zlib/contrib/minizip/test/test_helper.cm.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 |
if(CREATE_SHARED)
file(REMOVE ./test_file_shared.orig ./test_file_shared.zip)
file(WRITE ./test_file_shared.txt "Hello Hello Hello")
endif(CREATE_SHARED)
if(MOVE_SHARED)
file(RENAME ./test_file_shared.txt ./test_file_shared.orig)
endif(MOVE_SHARED)
if(DELETE_SHARED)
file(REMOVE
./test_file_shared.txt
./test_file_shared.orig
./test_file_shared.zip)
endif(DELETE_SHARED)
if(CREATE_STATIC)
file(REMOVE ./test_file_static.orig ./test_file_static.zip)
file(WRITE ./test_file_static.txt "Hello Hello Hello")
endif(CREATE_STATIC)
if(MOVE_STATIC)
file(RENAME ./test_file_static.txt ./test_file_static.orig)
endif(MOVE_STATIC)
if(DELETE_STATIC)
file(REMOVE
./test_file_static.txt
./test_file_static.orig
./test_file_static.zip)
endif(DELETE_STATIC)
|
Changes to compat/zlib/contrib/minizip/unzip.c.
1 | /* unzip.c -- IO for uncompress .zip files using zlib | < | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
/* unzip.c -- IO for uncompress .zip files using zlib
part of the MiniZip project - ( https://www.winimage.com/zLibDll/minizip.html )
Copyright (C) 1998-2026 Gilles Vollant (minizip) ( https://www.winimage.com/zLibDll/minizip.html )
Modifications of Unzip for Zip64
Copyright (C) 2007-2008 Even Rouault
Modifications for Zip64 support on both zip and unzip
Copyright (C) 2009-2010 Mathias Svensson ( https://result42.com )
For more info read MiniZip_info.txt
------------------------------------------------------------------------------------
Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of
compatibility with older software. The following is from the original crypt.c.
|
| ︙ | ︙ | |||
64 65 66 67 68 69 70 | */ #include <stdio.h> #include <stdlib.h> #include <string.h> | | | < | | 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 |
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef ZLIB_DLL
# undef ZLIB_DLL
#endif
#include "zlib.h"
#include "unzip.h"
#ifdef STDC
# include <stddef.h>
#endif
#ifdef NO_ERRNO_H
extern int errno;
#else
# include <errno.h>
#endif
#ifndef local
# define local static
#endif
/* compile with -Dlocal if your debugger can't find static symbols */
#ifndef CASESENSITIVITYDEFAULT_NO
# if (!defined(__unix__) && !defined(__unix) || defined(__CYGWIN__)) && !defined(CASESENSITIVITYDEFAULT_YES)
# define CASESENSITIVITYDEFAULT_NO
# endif
#endif
#ifndef UNZ_BUFSIZE
#define UNZ_BUFSIZE (16384)
|
| ︙ | ︙ | |||
111 112 113 114 115 116 117 | #endif #define SIZECENTRALDIRITEM (0x2e) #define SIZEZIPLOCALHEADER (0x1e) const char unz_copyright[] = | | | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
#endif
#define SIZECENTRALDIRITEM (0x2e)
#define SIZEZIPLOCALHEADER (0x1e)
const char unz_copyright[] =
" unzip 1.01 Copyright 1998-2004 Gilles Vollant - https://www.winimage.com/zLibDll/minizip.html";
/* unz_file_info64_internal contain internal info about a file in zipfile*/
typedef struct unz_file_info64_internal_s
{
ZPOS64_T offset_curfile;/* relative offset of local header 8 bytes */
} unz_file_info64_internal;
|
| ︙ | ︙ | |||
683 684 685 686 687 688 689 690 691 692 693 694 695 696 |
extern unzFile ZEXPORT unzOpen2_64(const void *path,
zlib_filefunc64_def* pzlib_filefunc_def) {
if (pzlib_filefunc_def != NULL)
{
zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def;
zlib_filefunc64_32_def_fill.ztell32_file = NULL;
zlib_filefunc64_32_def_fill.zseek32_file = NULL;
return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 1);
}
else
return unzOpenInternal(path, NULL, 1);
}
| > | 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 |
extern unzFile ZEXPORT unzOpen2_64(const void *path,
zlib_filefunc64_def* pzlib_filefunc_def) {
if (pzlib_filefunc_def != NULL)
{
zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def;
zlib_filefunc64_32_def_fill.zopen32_file = NULL;
zlib_filefunc64_32_def_fill.ztell32_file = NULL;
zlib_filefunc64_32_def_fill.zseek32_file = NULL;
return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 1);
}
else
return unzOpenInternal(path, NULL, 1);
}
|
| ︙ | ︙ | |||
842 843 844 845 846 847 848 |
if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK)
err=UNZ_ERRNO;
if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK)
err=UNZ_ERRNO;
| | | 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 |
if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK)
err=UNZ_ERRNO;
if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK)
err=UNZ_ERRNO;
/* relative offset of local header */
if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
err=UNZ_ERRNO;
file_info_internal.offset_curfile = uL;
lSeek+=file_info.size_filename;
if ((err==UNZ_OK) && (szFileName!=NULL))
{
|
| ︙ | ︙ | |||
865 866 867 868 869 870 871 |
if ((file_info.size_filename>0) && (fileNameBufferSize>0))
if (ZREAD64(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead)
err=UNZ_ERRNO;
lSeek -= uSizeRead;
}
| | | 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 |
if ((file_info.size_filename>0) && (fileNameBufferSize>0))
if (ZREAD64(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead)
err=UNZ_ERRNO;
lSeek -= uSizeRead;
}
/* Read extrafield */
if ((err==UNZ_OK) && (extraField!=NULL))
{
ZPOS64_T uSizeRead ;
if (file_info.size_file_extra<extraFieldBufferSize)
uSizeRead = file_info.size_file_extra;
else
uSizeRead = extraFieldBufferSize;
|
| ︙ | ︙ | |||
896 897 898 899 900 901 902 |
lSeek += file_info.size_file_extra;
if ((err==UNZ_OK) && (file_info.size_file_extra != 0))
{
uLong acc = 0;
| | | 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 |
lSeek += file_info.size_file_extra;
if ((err==UNZ_OK) && (file_info.size_file_extra != 0))
{
uLong acc = 0;
/* since lSeek now points to after the extra field we need to move back */
lSeek -= file_info.size_file_extra;
if (lSeek!=0)
{
if (ZSEEK64(s->z_filefunc, s->filestream,(ZPOS64_T)lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
lSeek=0;
else
|
| ︙ | ︙ | |||
1525 1526 1527 1528 1529 1530 1531 |
/** Addition for GDAL : START */
extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file) {
unz64_s* s;
file_in_zip64_read_info_s* pfile_in_zip_read_info;
s=(unz64_s*)file;
if (file==NULL)
| | | | 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 |
/** Addition for GDAL : START */
extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file) {
unz64_s* s;
file_in_zip64_read_info_s* pfile_in_zip_read_info;
s=(unz64_s*)file;
if (file==NULL)
return 0; /* UNZ_PARAMERROR; */
pfile_in_zip_read_info=s->pfile_in_zip_read;
if (pfile_in_zip_read_info==NULL)
return 0; /* UNZ_PARAMERROR; */
return pfile_in_zip_read_info->pos_in_zipfile +
pfile_in_zip_read_info->byte_before_the_zipfile;
}
/** Addition for GDAL : END */
/*
|
| ︙ | ︙ | |||
1609 1610 1611 1612 1613 1614 1615 |
# ifndef NOUNCRYPT
if(s->encrypted)
{
uInt i;
for(i=0;i<uReadThis;i++)
pfile_in_zip_read_info->read_buffer[i] =
| | | 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 |
# ifndef NOUNCRYPT
if(s->encrypted)
{
uInt i;
for(i=0;i<uReadThis;i++)
pfile_in_zip_read_info->read_buffer[i] =
(char)zdecode(s->keys,s->pcrc_32_tab,
pfile_in_zip_read_info->read_buffer[i]);
}
# endif
pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
|
| ︙ | ︙ | |||
1697 1698 1699 1700 1701 1702 1703 |
pfile_in_zip_read_info->stream.total_out = pfile_in_zip_read_info->bstream.total_out_lo32;
if (err==BZ_STREAM_END)
return (iRead==0) ? UNZ_EOF : iRead;
if (err!=BZ_OK)
break;
#endif
| | | 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 |
pfile_in_zip_read_info->stream.total_out = pfile_in_zip_read_info->bstream.total_out_lo32;
if (err==BZ_STREAM_END)
return (iRead==0) ? UNZ_EOF : iRead;
if (err!=BZ_OK)
break;
#endif
} /* end Z_BZIP2ED */
else
{
ZPOS64_T uTotalOutBefore,uTotalOutAfter;
const Bytef *bufBefore;
ZPOS64_T uOutThis;
int flush=Z_SYNC_FLUSH;
|
| ︙ | ︙ | |||
1940 1941 1942 1943 1944 1945 1946 |
}
/* Additions by RX '2004 */
extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file) {
unz64_s* s;
if (file==NULL)
| | | | 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 |
}
/* Additions by RX '2004 */
extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file) {
unz64_s* s;
if (file==NULL)
return 0; /* UNZ_PARAMERROR; */
s=(unz64_s*)file;
if (!s->current_file_ok)
return 0;
if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff)
if (s->num_file==s->gi.number_entry)
return 0;
return s->pos_in_central_dir;
}
extern uLong ZEXPORT unzGetOffset(unzFile file) {
ZPOS64_T offset64;
if (file==NULL)
return 0; /* UNZ_PARAMERROR; */
offset64 = unzGetOffset64(file);
return (uLong)offset64;
}
extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos) {
unz64_s* s;
int err;
|
| ︙ | ︙ |
Changes to compat/zlib/contrib/minizip/unzip.h.
1 | /* unzip.h -- IO for uncompress .zip files using zlib | < | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
/* unzip.h -- IO for uncompress .zip files using zlib
part of the MiniZip project - ( https://www.winimage.com/zLibDll/minizip.html )
Copyright (C) 1998-2026 Gilles Vollant (minizip) ( https://www.winimage.com/zLibDll/minizip.html )
Modifications of Unzip for Zip64
Copyright (C) 2007-2008 Even Rouault
Modifications for Zip64 support on both zip and unzip
Copyright (C) 2009-2010 Mathias Svensson ( https://result42.com )
For more info read MiniZip_info.txt
---------------------------------------------------------------------------------
Condition of use and distribution are the same than zlib :
|
| ︙ | ︙ | |||
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
/* like the STRICT of WIN32, we define a pointer that cannot be converted
from (void*) without cast */
typedef struct TagunzFile__ { int unused; } unzFile__;
typedef unzFile__ *unzFile;
#else
typedef voidp unzFile;
#endif
#define UNZ_OK (0)
#define UNZ_END_OF_LIST_OF_FILE (-100)
#define UNZ_ERRNO (Z_ERRNO)
#define UNZ_EOF (0)
#define UNZ_PARAMERROR (-102)
| > > | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
/* like the STRICT of WIN32, we define a pointer that cannot be converted
from (void*) without cast */
typedef struct TagunzFile__ { int unused; } unzFile__;
typedef unzFile__ *unzFile;
#else
typedef voidp unzFile;
#endif
extern const char unz_copyright[];
#define UNZ_OK (0)
#define UNZ_END_OF_LIST_OF_FILE (-100)
#define UNZ_ERRNO (Z_ERRNO)
#define UNZ_EOF (0)
#define UNZ_PARAMERROR (-102)
|
| ︙ | ︙ | |||
309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
if szFileName!=NULL, the filename string will be copied in szFileName
(fileNameBufferSize is the size of the buffer)
if extraField!=NULL, the extra field information will be copied in extraField
(extraFieldBufferSize is the size of the buffer).
This is the Central-header version of the extra field
if szComment!=NULL, the comment string of the file will be copied in szComment
(commentBufferSize is the size of the buffer)
*/
/** Addition for GDAL : START */
extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file);
| > > > > | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
if szFileName!=NULL, the filename string will be copied in szFileName
(fileNameBufferSize is the size of the buffer)
if extraField!=NULL, the extra field information will be copied in extraField
(extraFieldBufferSize is the size of the buffer).
This is the Central-header version of the extra field
if szComment!=NULL, the comment string of the file will be copied in szComment
(commentBufferSize is the size of the buffer)
The file name and comment will be zero-terminated if there is room in the
provided buffer. Otherwise the buffer will contain as much as will fit. If at
least 65537 bytes of room is provided, then the result will always be
complete and zero-terminated.
*/
/** Addition for GDAL : START */
extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file);
|
| ︙ | ︙ |
Changes to compat/zlib/contrib/minizip/zip.c.
1 | /* zip.c -- IO on .zip files using zlib | < | | | < > > > > > > | 1 2 3 4 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 |
/* zip.c -- IO on .zip files using zlib
part of the MiniZip project - ( https://www.winimage.com/zLibDll/minizip.html )
Copyright (C) 1998-2026 Gilles Vollant (minizip) ( https://www.winimage.com/zLibDll/minizip.html )
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson ( https://result42.com )
For more info read MiniZip_info.txt
Changes
Oct-2009 - Mathias Svensson - Remove old C style function prototypes
Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file archives
Oct-2009 - Mathias Svensson - Did some code cleanup and refactoring to get better overview of some functions.
Oct-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra field data from its ZIP64 data
It is used when recreating zip archive with RAW when deleting items from a zip.
ZIP64 data is automatically added to items that needs it, and existing ZIP64 data need to be removed.
Oct-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bzip2 lib is required)
Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#ifndef ZLIB_CONST
# define ZLIB_CONST
#endif
#ifdef ZLIB_DLL
# undef ZLIB_DLL
#endif
#include "zlib.h"
#include "zip.h"
#ifdef STDC
# include <stddef.h>
#endif
#ifdef NO_ERRNO_H
|
| ︙ | ︙ | |||
46 47 48 49 50 51 52 | /* compile with -Dlocal if your debugger can't find static symbols */ #ifndef VERSIONMADEBY # define VERSIONMADEBY (0x0) /* platform dependent */ #endif #ifndef Z_BUFSIZE | | | | 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 | /* compile with -Dlocal if your debugger can't find static symbols */ #ifndef VERSIONMADEBY # define VERSIONMADEBY (0x0) /* platform dependent */ #endif #ifndef Z_BUFSIZE #define Z_BUFSIZE (64*1024) /* (16384) */ #endif #ifndef Z_MAXFILENAMEINZIP #define Z_MAXFILENAMEINZIP (256) #endif #ifndef ALLOC # define ALLOC(size) (malloc(size)) #endif /* #define SIZECENTRALDIRITEM (0x2e) #define SIZEZIPLOCALHEADER (0x1e) */ /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ /* NOT sure that this work on ALL platform */ #define MAKEULONG64(a, b) ((ZPOS64_T)(((unsigned long)(a)) | ((ZPOS64_T)((unsigned long)(b))) << 32)) #ifndef SEEK_CUR #define SEEK_CUR 1 #endif #ifndef SEEK_END |
| ︙ | ︙ | |||
87 88 89 90 91 92 93 | #ifndef DEF_MEM_LEVEL #if MAX_MEM_LEVEL >= 8 # define DEF_MEM_LEVEL 8 #else # define DEF_MEM_LEVEL MAX_MEM_LEVEL #endif #endif | | | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | #ifndef DEF_MEM_LEVEL #if MAX_MEM_LEVEL >= 8 # define DEF_MEM_LEVEL 8 #else # define DEF_MEM_LEVEL MAX_MEM_LEVEL #endif #endif const char zip_copyright[] =" zip 1.01 Copyright 1998-2004 Gilles Vollant - https://www.winimage.com/zLibDll/minizip.html"; #define SIZEDATA_INDATABLOCK (4096-(4*4)) #define LOCALHEADERMAGIC (0x04034b50) #define CENTRALHEADERMAGIC (0x02014b50) #define ENDHEADERMAGIC (0x06054b50) |
| ︙ | ︙ | |||
118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
typedef struct linkedlist_data_s
{
linkedlist_datablock_internal* first_block;
linkedlist_datablock_internal* last_block;
} linkedlist_data;
typedef struct
{
z_stream stream; /* zLib stream structure for inflate */
#ifdef HAVE_BZIP2
bz_stream bstream; /* bzLib stream structure for bziped */
#endif
| > > > > > > > > > > > > > | 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
typedef struct linkedlist_data_s
{
linkedlist_datablock_internal* first_block;
linkedlist_datablock_internal* last_block;
} linkedlist_data;
/* zipAlreadyThere() set functions for a set of zero-terminated strings, and
// a block_t type for reading the central directory datablocks. */
typedef char *set_key_t;
#define set_cmp(a, b) strcmp(a, b)
#define set_drop(s, k) set_free(s, k)
#include "skipset.h"
typedef struct {
unsigned char *next; /* next byte in datablock data */
size_t left; /* number of bytes left in data (at least) */
linkedlist_datablock_internal *node; /* current datablock */
} block_t;
typedef struct
{
z_stream stream; /* zLib stream structure for inflate */
#ifdef HAVE_BZIP2
bz_stream bstream; /* bzLib stream structure for bziped */
#endif
|
| ︙ | ︙ | |||
170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
ZPOS64_T add_position_when_writing_offset;
ZPOS64_T number_entry;
#ifndef NO_ADDFILEINEXISTINGZIP
char *globalcomment;
#endif
} zip64_internal;
#ifndef NOCRYPT
#define INCLUDECRYPTINGCODE_IFCRYPTALLOWED
#include "crypt.h"
#endif
| > > > > | 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
ZPOS64_T add_position_when_writing_offset;
ZPOS64_T number_entry;
#ifndef NO_ADDFILEINEXISTINGZIP
char *globalcomment;
#endif
/* Support for zipAlreadyThere(). */
set_t set; /* set for detecting name collisions */
block_t block; /* block for reading the central directory */
} zip64_internal;
#ifndef NOCRYPT
#define INCLUDECRYPTINGCODE_IFCRYPTALLOWED
#include "crypt.h"
#endif
|
| ︙ | ︙ | |||
260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
ldi->avail_in_this_block -= copy_this;
from_copy += copy_this ;
len -= copy_this;
}
return ZIP_OK;
}
/****************************************************************************/
#ifndef NO_ADDFILEINEXISTINGZIP
/* ===========================================================================
Inputs a long in LSB order to the given file
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 |
ldi->avail_in_this_block -= copy_this;
from_copy += copy_this ;
len -= copy_this;
}
return ZIP_OK;
}
/* zipAlreadyThere() operations. "set" in the zip internal structure keeps the
// set of names that are in the under-construction central directory so far. A
// skipset provides ~O(log n) time insertion and searching. Central directory
// records, stored in a linked list of allocated memory datablocks, is read
// through "block" in the zip internal structure.
// The block_*() functions support extracting the central directory file names
// from the datablocks. They are designed to support a growing directory by
// automatically continuing once more data has been appended to the linked
// datablocks.
// Initialize *block to the head of list. This should only be called once the
// list has at least some data in it, i.e. list->first_block is not NULL. */
local void block_init(block_t *block, linkedlist_data *list) {
block->node = list->first_block;
block->next = block->node->data;
block->left = block->node->filled_in_this_block;
}
/* Mark *block as bad, with all subsequent reads returning end, even if more
// data is added to the datablocks. This is invoked if the central directory is
// invalid, so there is no longer any point in attempting to interpret it. */
local void block_stop(block_t *block) {
block->left = 0;
block->next = NULL;
}
/* Return true if *block has reached the end of the data in the datablocks. */
local int block_end(block_t *block) {
linkedlist_datablock_internal *node = block->node;
if (node == NULL)
/* This block was previously terminated with extreme prejudice. */
return 1;
if (block->next < node->data + node->filled_in_this_block)
/* There are more bytes to read in the current datablock. */
return 0;
while (node->next_datablock != NULL) {
if (node->filled_in_this_block != 0)
/* There are some bytes in a later datablock. */
return 0;
node = node->next_datablock;
}
/* Reached the end of the list of datablocks. There's nothing. */
return 1;
}
/* Return one byte from *block, or -1 if the end is reached. */
local int block_get(block_t *block) {
while (block->left == 0) {
if (block->node == NULL)
/* We've been marked bad. Return end. */
return -1;
/* Update left in case more was filled in since we were last here. */
block->left = block->node->filled_in_this_block -
(size_t)(block->next - block->node->data);
if (block->left != 0)
/* There was indeed more data appended in the current datablock. */
break;
if (block->node->next_datablock == NULL)
/* No more data here, and there is no next datablock. At the end. */
return -1;
/* Try the next datablock for more data. */
block->node = block->node->next_datablock;
block->next = block->node->data;
block->left = block->node->filled_in_this_block;
}
/* We have a byte to return. */
block->left--;
return *block->next++;
}
/* Return a 16-bit unsigned little-endian value from block, or a negative value
// if the end is reached. */
local long block_get2(block_t *block) {
int low = block_get(block);
int high = block_get(block);
return low < 0 || high < 0 ? -1 : low | ((long)high << 8);
}
/* Read up to len bytes from block into buf. Return the number of bytes read. */
local size_t block_read(block_t *block, unsigned char *buf, size_t len) {
size_t need = len;
while (need) {
if (block->left == 0) {
/* Get a byte to update and step through the linked list as needed. */
int got = block_get(block);
if (got == -1)
/* Reached the end. */
break;
*buf++ = (unsigned char)got;
need--;
continue;
}
size_t take = need > block->left ? block->left : need;
memcpy(buf, block->next, take);
block->next += take;
block->left -= take;
buf += take;
need -= take;
}
return len - need; /* return the number of bytes copied */
}
/* Skip n bytes in block. Return 0 on success or -1 if there are less than n
// bytes to the end. */
local int block_skip(block_t *block, size_t n) {
while (n > block->left) {
n -= block->left;
block->next += block->left;
block->left = 0;
if (block_get(block) == -1)
return -1;
n--;
}
block->next += n;
block->left -= n;
return 0;
}
/* Process the next central directory record at *block. Return the allocated,
// zero-terminated file name, or NULL for end of input or invalid data. If
// invalid, *block is marked bad. This uses *set for the allocation of memory. */
local char *block_central_name(block_t *block, set_t *set) {
char *name = NULL;
for (;;) {
if (block_end(block))
/* At the end of the central directory (so far). */
return NULL;
/* Check for a central directory record signature. */
if (block_get2(block) != (CENTRALHEADERMAGIC & 0xffff) ||
block_get2(block) != (CENTRALHEADERMAGIC >> 16))
/* Incorrect signature. */
break;
/* Go through the remaining fixed-length portion of the record,
// extracting the lengths of the three variable-length fields. */
block_skip(block, 24);
unsigned flen = (unsigned)block_get2(block); /* file name length */
unsigned xlen = (unsigned)block_get2(block); /* extra length */
unsigned clen = (unsigned)block_get2(block); /* comment length */
if (block_skip(block, 12) == -1)
/* Premature end of the record. */
break;
/* Extract the name and skip over the extra and comment fields. */
name = set_alloc(set, NULL, flen + 1);
if (block_read(block, (unsigned char *)name, flen) < flen ||
block_skip(block, xlen + clen) == -1)
/* Premature end of the record. */
break;
/* Check for embedded nuls in the name. */
if (memchr(name, 0, flen) != NULL) {
/* This name can never match the zero-terminated name provided to
// zipAlreadyThere(), so we discard it and go back to get another
// name. (Who the heck is putting nuls inside their zip file entry
// names anyway?) */
set_free(set, name);
continue;
}
/* All good. Return the zero-terminated file name. */
name[flen] = 0;
return name;
}
/* Invalid signature or premature end of the central directory record.
// Abandon trying to process the central directory. */
set_free(set, name);
block_stop(block);
return NULL;
}
/* Return 0 if name is not in the central directory so far, 1 if it is, -1 if
// the central directory is invalid, -2 if out of memory, or ZIP_PARAMERROR if
// file is NULL. */
extern int ZEXPORT zipAlreadyThere(zipFile file, char const *name) {
zip64_internal *zip = file;
if (zip == NULL)
return ZIP_PARAMERROR;
if (zip->central_dir.first_block == NULL)
/* No central directory yet, so no, name isn't there. */
return 0;
if (setjmp(zip->set.env)) {
/* Memory allocation failure. */
set_end(&zip->set);
return -2;
}
if (!set_ok(&zip->set)) {
/* This is the first time here with some central directory content. We
// construct this set of names only on demand. Prepare set and block. */
set_start(&zip->set);
block_init(&zip->block, &zip->central_dir);
}
/* Update the set of names from the current central directory contents.
// This reads any new central directory records since the last time we were
// here. */
for (;;) {
char *there = block_central_name(&zip->block, &zip->set);
if (there == NULL) {
if (zip->block.next == NULL)
/* The central directory is invalid. */
return -1;
break;
}
/* Add there to the set. */
if (set_insert(&zip->set, there))
/* There's already a duplicate in the central directory! We'll just
// let this be and carry on. */
set_free(&zip->set, there);
}
/* Return true if name is in the central directory. */
size_t len = strlen(name);
char *copy = set_alloc(&zip->set, NULL, len + 1);
memcpy(copy, name, len + 1);
int found = set_found(&zip->set, copy);
set_free(&zip->set, copy);
return found;
}
/****************************************************************************/
#ifndef NO_ADDFILEINEXISTINGZIP
/* ===========================================================================
Inputs a long in LSB order to the given file
|
| ︙ | ︙ | |||
547 548 549 550 551 552 553 |
break;
if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
break;
for (i=(int)uReadSize-3; (i--)>0;)
{
| | | 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 |
break;
if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
break;
for (i=(int)uReadSize-3; (i--)>0;)
{
/* Signature "0x07064b50" Zip64 end of central directory locator */
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
{
uPosFound = uReadPos+(unsigned)i;
break;
}
}
|
| ︙ | ︙ | |||
595 596 597 598 599 600 601 |
if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0)
return 0;
/* the signature */
if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK)
return 0;
| | | 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 |
if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0)
return 0;
/* the signature */
if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK)
return 0;
if (uL != 0x06064b50) /* signature of 'Zip64 end of central directory' */
return 0;
return relativeOffset;
}
local int LoadCentralDirectoryRecord(zip64_internal* pziinit) {
int err=ZIP_OK;
|
| ︙ | ︙ | |||
624 625 626 627 628 629 630 |
(same than number_entry on nospan) */
uLong VersionMadeBy;
uLong VersionNeeded;
uLong size_comment;
int hasZIP64Record = 0;
| | | 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 |
(same than number_entry on nospan) */
uLong VersionMadeBy;
uLong VersionNeeded;
uLong size_comment;
int hasZIP64Record = 0;
/* check first if we find a ZIP64 record */
central_pos = zip64local_SearchCentralDir64(&pziinit->z_filefunc,pziinit->filestream);
if(central_pos > 0)
{
hasZIP64Record = 1;
}
else if(central_pos == 0)
{
|
| ︙ | ︙ | |||
690 691 692 693 694 695 696 |
err=ZIP_ERRNO;
/* offset of start of central directory with respect to the
starting disk number */
if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream,&offset_central_dir)!=ZIP_OK)
err=ZIP_ERRNO;
| | | | | 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 |
err=ZIP_ERRNO;
/* offset of start of central directory with respect to the
starting disk number */
if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream,&offset_central_dir)!=ZIP_OK)
err=ZIP_ERRNO;
/* TODO..
// read the comment from the standard central header. */
size_comment = 0;
}
else
{
/* Read End of central Directory info */
if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
err=ZIP_ERRNO;
/* the signature, already checked */
if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream,&uL)!=ZIP_OK)
err=ZIP_ERRNO;
|
| ︙ | ︙ | |||
839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 |
ziinit.begin_pos = ZTELL64(ziinit.z_filefunc,ziinit.filestream);
ziinit.in_opened_file_inzip = 0;
ziinit.ci.stream_initialised = 0;
ziinit.number_entry = 0;
ziinit.add_position_when_writing_offset = 0;
init_linkedlist(&(ziinit.central_dir));
zi = (zip64_internal*)ALLOC(sizeof(zip64_internal));
if (zi==NULL)
{
ZCLOSE64(ziinit.z_filefunc,ziinit.filestream);
return NULL;
}
/* now we add file in a zipfile */
# ifndef NO_ADDFILEINEXISTINGZIP
ziinit.globalcomment = NULL;
if (append == APPEND_STATUS_ADDINZIP)
{
| > | | 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 |
ziinit.begin_pos = ZTELL64(ziinit.z_filefunc,ziinit.filestream);
ziinit.in_opened_file_inzip = 0;
ziinit.ci.stream_initialised = 0;
ziinit.number_entry = 0;
ziinit.add_position_when_writing_offset = 0;
init_linkedlist(&(ziinit.central_dir));
memset(&ziinit.set, 0, sizeof(set_t)); /* make sure set appears dormant */
zi = (zip64_internal*)ALLOC(sizeof(zip64_internal));
if (zi==NULL)
{
ZCLOSE64(ziinit.z_filefunc,ziinit.filestream);
return NULL;
}
/* now we add file in a zipfile */
# ifndef NO_ADDFILEINEXISTINGZIP
ziinit.globalcomment = NULL;
if (append == APPEND_STATUS_ADDINZIP)
{
/* Read and Cache Central Directory Records */
err = LoadCentralDirectoryRecord(&ziinit);
}
if (globalcomment)
{
*globalcomment = ziinit.globalcomment;
}
|
| ︙ | ︙ | |||
895 896 897 898 899 900 901 902 903 904 905 906 907 908 |
}
extern zipFile ZEXPORT zipOpen2_64(const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def) {
if (pzlib_filefunc_def != NULL)
{
zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def;
zlib_filefunc64_32_def_fill.ztell32_file = NULL;
zlib_filefunc64_32_def_fill.zseek32_file = NULL;
return zipOpen3(pathname, append, globalcomment, &zlib_filefunc64_32_def_fill);
}
else
return zipOpen3(pathname, append, globalcomment, NULL);
}
| > | 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 |
}
extern zipFile ZEXPORT zipOpen2_64(const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def) {
if (pzlib_filefunc_def != NULL)
{
zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def;
zlib_filefunc64_32_def_fill.zopen32_file = NULL;
zlib_filefunc64_32_def_fill.ztell32_file = NULL;
zlib_filefunc64_32_def_fill.zseek32_file = NULL;
return zipOpen3(pathname, append, globalcomment, &zlib_filefunc64_32_def_fill);
}
else
return zipOpen3(pathname, append, globalcomment, NULL);
}
|
| ︙ | ︙ | |||
938 939 940 941 942 943 944 |
if (err==ZIP_OK)
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.method,2);
if (err==ZIP_OK)
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4);
| | | 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 |
if (err==ZIP_OK)
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.method,2);
if (err==ZIP_OK)
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4);
/* CRC / Compressed size / Uncompressed size will be filled in later and rewritten later */
if (err==ZIP_OK)
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */
if (err==ZIP_OK)
{
if(zi->ci.zip64)
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xFFFFFFFF,4); /* compressed size, unknown */
else
|
| ︙ | ︙ | |||
982 983 984 985 986 987 988 |
if (ZWRITE64(zi->z_filefunc, zi->filestream, extrafield_local, size_extrafield_local) != size_extrafield_local)
err = ZIP_ERRNO;
}
if ((err==ZIP_OK) && (zi->ci.zip64))
{
| | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 |
if (ZWRITE64(zi->z_filefunc, zi->filestream, extrafield_local, size_extrafield_local) != size_extrafield_local)
err = ZIP_ERRNO;
}
if ((err==ZIP_OK) && (zi->ci.zip64))
{
/* write the Zip64 extended info */
short HeaderID = 1;
short DataSize = 16;
ZPOS64_T CompressedSize = 0;
ZPOS64_T UncompressedSize = 0;
/* Remember position of Zip64 extended info for the local file header. (needed when we update size after done with file) */
zi->ci.pos_zip64extrainfo = ZTELL64(zi->z_filefunc,zi->filestream);
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)HeaderID,2);
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)DataSize,2);
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)UncompressedSize,8);
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)CompressedSize,8);
}
return err;
}
/* Return the length of the UTF-8 code at str[0..len-1] in [1..4], or negative
if there is no valid UTF-8 code there. If negative, it is minus the number
of bytes examined in order to determine it was bad. Or if minus the return
code is one less than len, then at least one more byte than provided would
be needed to complete the code. */
local int utf8len(unsigned char const *str, size_t len) {
return
len == 0 ? -1 : /* empty input */
str[0] < 0x80 ? 1 : /* good one-byte */
str[0] < 0xc0 ? -1 : /* bad first byte */
len < 2 || (str[1] >> 6) != 2 ? -2 : /* missing or bad 2nd byte */
str[0] < 0xc2 ? -2 : /* overlong code */
str[0] < 0xe0 ? 2 : /* good two-byte */
len < 3 || (str[2] >> 6) != 2 ? -3 : /* missing or bad 3rd byte */
str[0] == 0xe0 && str[1] < 0xa0 ? -3 : /* overlong code */
str[0] < 0xf0 ? 3 : /* good three-byte */
len < 4 || (str[3] >> 6) != 2 ? -4 : /* missing or bad 4th byte */
str[0] == 0xf0 && str[1] < 0x90 ? -4 : /* overlong code */
str[0] < 0xf4 ||
(str[0] == 0xf4 && str[1] < 0x90) ? 4 : /* good four-byte */
-4; /* code > 0x10ffff */
}
/* Return true if str[0..len-1] is valid UTF-8 *and* it contains at least one
code of two or more bytes. This is used to determine whether or not to set
bit 11 in the zip header flags. */
local int isutf8(char const *str, size_t len) {
int utf8 = 0;
while (len) {
int code = utf8len((unsigned char const *)str, len);
if (code < 0)
return 0;
if (code > 1)
utf8 = 1;
str += code;
len -= (unsigned)code;
}
return utf8;
}
/*
NOTE.
When writing RAW the ZIP64 extended information in extrafield_local and extrafield_global needs to be stripped
before calling this function it can be done with zipRemoveExtraInfoBlock
It is not done here because then we need to realloc a new buffer since parameters are 'const' and I want to minimize
|
| ︙ | ︙ | |||
1023 1024 1025 1026 1027 1028 1029 |
zip64_internal* zi;
uInt size_filename;
uInt size_comment;
uInt i;
int err = ZIP_OK;
# ifdef NOCRYPT
| < | | | | 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 |
zip64_internal* zi;
uInt size_filename;
uInt size_comment;
uInt i;
int err = ZIP_OK;
# ifdef NOCRYPT
if (password != NULL)
return ZIP_PARAMERROR;
# endif
if (file == NULL)
return ZIP_PARAMERROR;
#ifdef HAVE_BZIP2
if ((method!=0) && (method!=Z_DEFLATED) && (method!=Z_BZIP2ED))
return ZIP_PARAMERROR;
#else
if ((method!=0) && (method!=Z_DEFLATED))
return ZIP_PARAMERROR;
#endif
/* The filename and comment length must fit in 16 bits. */
if ((filename!=NULL) && (strlen(filename)>0xffff))
return ZIP_PARAMERROR;
if ((comment!=NULL) && (strlen(comment)>0xffff))
return ZIP_PARAMERROR;
/* The extra field length must fit in 16 bits. If the member also requires
// a Zip64 extra block, that will also need to fit within that 16-bit
// length, but that will be checked for later. */
if ((size_extrafield_local>0xffff) || (size_extrafield_global>0xffff))
return ZIP_PARAMERROR;
zi = (zip64_internal*)file;
if (zi->in_opened_file_inzip == 1)
{
|
| ︙ | ︙ | |||
1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 |
zi->ci.flag |= 2;
if (level==2)
zi->ci.flag |= 4;
if (level==1)
zi->ci.flag |= 6;
if (password != NULL)
zi->ci.flag |= 1;
zi->ci.crc32 = 0;
zi->ci.method = method;
zi->ci.encrypt = 0;
zi->ci.stream_initialised = 0;
zi->ci.pos_in_buffered_data = 0;
zi->ci.raw = raw;
zi->ci.pos_local_header = ZTELL64(zi->z_filefunc,zi->filestream);
zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + size_extrafield_global + size_comment;
| > > > | | 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 |
zi->ci.flag |= 2;
if (level==2)
zi->ci.flag |= 4;
if (level==1)
zi->ci.flag |= 6;
if (password != NULL)
zi->ci.flag |= 1;
if (isutf8(filename, size_filename) &&
(size_comment == 0 || isutf8(comment, size_comment)))
zi->ci.flag |= (1 << 11);
zi->ci.crc32 = 0;
zi->ci.method = method;
zi->ci.encrypt = 0;
zi->ci.stream_initialised = 0;
zi->ci.pos_in_buffered_data = 0;
zi->ci.raw = raw;
zi->ci.pos_local_header = ZTELL64(zi->z_filefunc,zi->filestream);
zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + size_extrafield_global + size_comment;
zi->ci.size_centralExtraFree = 32; /* Extra space we have reserved in case we need to add ZIP64 extra info data */
zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader + zi->ci.size_centralExtraFree);
zi->ci.size_centralExtra = size_extrafield_global;
zip64local_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4);
/* version info */
zip64local_putValue_inmemory(zi->ci.central_header+4,(uLong)versionMadeBy,2);
|
| ︙ | ︙ | |||
1193 1194 1195 1196 1197 1198 1199 |
if (err==Z_OK)
zi->ci.stream_initialised = Z_DEFLATED;
}
else if(zi->ci.method == Z_BZIP2ED)
{
#ifdef HAVE_BZIP2
| | | 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 |
if (err==Z_OK)
zi->ci.stream_initialised = Z_DEFLATED;
}
else if(zi->ci.method == Z_BZIP2ED)
{
#ifdef HAVE_BZIP2
/* Init BZip stuff here */
zi->ci.bstream.bzalloc = 0;
zi->ci.bstream.bzfree = 0;
zi->ci.bstream.opaque = (voidpf)0;
err = BZ2_bzCompressInit(&zi->ci.bstream, level, 0,35);
if(err == BZ_OK)
zi->ci.stream_initialised = Z_BZIP2ED;
|
| ︙ | ︙ | |||
1395 1396 1397 1398 1399 1400 1401 |
if(err != BZ_RUN_OK)
break;
if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw))
{
uLong uTotalOutBefore_lo = zi->ci.bstream.total_out_lo32;
| | | | 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 |
if(err != BZ_RUN_OK)
break;
if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw))
{
uLong uTotalOutBefore_lo = zi->ci.bstream.total_out_lo32;
/* uLong uTotalOutBefore_hi = zi->ci.bstream.total_out_hi32; */
err=BZ2_bzCompress(&zi->ci.bstream, BZ_RUN);
zi->ci.pos_in_buffered_data += (uInt)(zi->ci.bstream.total_out_lo32 - uTotalOutBefore_lo) ;
}
}
if(err == BZ_RUN_OK)
err = ZIP_OK;
}
else
#endif
{
zi->ci.stream.next_in = buf;
zi->ci.stream.avail_in = len;
while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0))
{
if (zi->ci.stream.avail_out == 0)
{
if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO)
|
| ︙ | ︙ | |||
1453 1454 1455 1456 1457 1458 1459 |
zi->ci.stream.next_in+= copy_this;
zi->ci.stream.next_out+= copy_this;
zi->ci.stream.total_in+= copy_this;
zi->ci.stream.total_out+= copy_this;
zi->ci.pos_in_buffered_data += copy_this;
}
}
| | | 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 |
zi->ci.stream.next_in+= copy_this;
zi->ci.stream.next_out+= copy_this;
zi->ci.stream.total_in+= copy_this;
zi->ci.stream.total_out+= copy_this;
zi->ci.pos_in_buffered_data += copy_this;
}
}
}/* while(...) */
}
return err;
}
extern int ZEXPORT zipCloseFileInZipRaw(zipFile file, uLong uncompressed_size, uLong crc32) {
return zipCloseFileInZipRaw64 (file, uncompressed_size, crc32);
|
| ︙ | ︙ | |||
1559 1560 1561 1562 1563 1564 1565 |
}
compressed_size = zi->ci.totalCompressedData;
# ifndef NOCRYPT
compressed_size += zi->ci.crypt_header_size;
# endif
| | | | | | | | | | | | | | | | | 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 |
}
compressed_size = zi->ci.totalCompressedData;
# ifndef NOCRYPT
compressed_size += zi->ci.crypt_header_size;
# endif
/* update Current Item crc and sizes, */
if(compressed_size >= 0xffffffff || uncompressed_size >= 0xffffffff || zi->ci.pos_local_header >= 0xffffffff)
{
/*version Made by*/
zip64local_putValue_inmemory(zi->ci.central_header+4,(uLong)45,2);
/*version needed*/
zip64local_putValue_inmemory(zi->ci.central_header+6,(uLong)45,2);
}
zip64local_putValue_inmemory(zi->ci.central_header+16,crc32,4); /*crc*/
if(compressed_size >= 0xffffffff)
zip64local_putValue_inmemory(zi->ci.central_header+20, invalidValue,4); /*compr size*/
else
zip64local_putValue_inmemory(zi->ci.central_header+20, compressed_size,4); /*compr size*/
/* set internal file attributes field */
if (zi->ci.stream.data_type == Z_ASCII)
zip64local_putValue_inmemory(zi->ci.central_header+36,(uLong)Z_ASCII,2);
if(uncompressed_size >= 0xffffffff)
zip64local_putValue_inmemory(zi->ci.central_header+24, invalidValue,4); /*uncompr size*/
else
zip64local_putValue_inmemory(zi->ci.central_header+24, uncompressed_size,4); /*uncompr size*/
/* Add ZIP64 extra info field for uncompressed size */
if(uncompressed_size >= 0xffffffff)
datasize += 8;
/* Add ZIP64 extra info field for compressed size */
if(compressed_size >= 0xffffffff)
datasize += 8;
/* Add ZIP64 extra info field for relative offset to local file header of current file */
if(zi->ci.pos_local_header >= 0xffffffff)
datasize += 8;
if(datasize > 0)
{
char* p = NULL;
if((uLong)(datasize + 4) > zi->ci.size_centralExtraFree)
{
/* we cannot write more data to the buffer that we have room for. */
return ZIP_BADZIPFILE;
}
p = zi->ci.central_header + zi->ci.size_centralheader;
/* Add Extra Information Header for 'ZIP64 information' */
zip64local_putValue_inmemory(p, 0x0001, 2); /* HeaderID */
p += 2;
zip64local_putValue_inmemory(p, datasize, 2); /* DataSize */
p += 2;
if(uncompressed_size >= 0xffffffff)
{
zip64local_putValue_inmemory(p, uncompressed_size, 8);
p += 8;
}
if(compressed_size >= 0xffffffff)
{
zip64local_putValue_inmemory(p, compressed_size, 8);
p += 8;
}
if(zi->ci.pos_local_header >= 0xffffffff)
{
zip64local_putValue_inmemory(p, zi->ci.pos_local_header, 8);
p += 8;
}
/* Update how much extra free space we got in the memory buffer
// and increase the centralheader size so the new ZIP64 fields are included
// ( 4 below is the size of HeaderID and DataSize field ) */
zi->ci.size_centralExtraFree -= datasize + 4;
zi->ci.size_centralheader += datasize + 4;
/* Update the extra info size field */
zi->ci.size_centralExtra += datasize + 4;
zip64local_putValue_inmemory(zi->ci.central_header+30,(uLong)zi->ci.size_centralExtra,2);
}
if (err==ZIP_OK)
err = add_data_in_datablock(&zi->central_dir, zi->ci.central_header, (uLong)zi->ci.size_centralheader);
free(zi->ci.central_header);
if (err==ZIP_OK)
{
/* Update the LocalFileHeader with the new values. */
ZPOS64_T cur_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream);
if (ZSEEK64(zi->z_filefunc,zi->filestream, zi->ci.pos_local_header + 14,ZLIB_FILEFUNC_SEEK_SET)!=0)
err = ZIP_ERRNO;
if (err==ZIP_OK)
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,crc32,4); /* crc 32, unknown */
if(uncompressed_size >= 0xffffffff || compressed_size >= 0xffffffff )
{
if(zi->ci.pos_zip64extrainfo > 0)
{
/* Update the size in the ZIP64 extended field. */
if (ZSEEK64(zi->z_filefunc,zi->filestream, zi->ci.pos_zip64extrainfo + 4,ZLIB_FILEFUNC_SEEK_SET)!=0)
err = ZIP_ERRNO;
if (err==ZIP_OK) /* compressed size, unknown */
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, uncompressed_size, 8);
if (err==ZIP_OK) /* uncompressed size, unknown */
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, compressed_size, 8);
}
else
err = ZIP_BADZIPFILE; /* Caller passed zip64 = 0, so no room for zip64 info -> fatal */
}
else
{
if (err==ZIP_OK) /* compressed size, unknown */
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,compressed_size,4);
if (err==ZIP_OK) /* uncompressed size, unknown */
|
| ︙ | ︙ | |||
1731 1732 1733 1734 1735 1736 1737 | int err = ZIP_OK; uLong Zip64DataSize = 44; err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDHEADERMAGIC,4); if (err==ZIP_OK) /* size of this 'zip64 end of central directory' */ | | | 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 |
int err = ZIP_OK;
uLong Zip64DataSize = 44;
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDHEADERMAGIC,4);
if (err==ZIP_OK) /* size of this 'zip64 end of central directory' */
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(ZPOS64_T)Zip64DataSize,8); /* why ZPOS64_T of this ? */
if (err==ZIP_OK) /* version made by */
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2);
if (err==ZIP_OK) /* version needed */
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2);
|
| ︙ | ︙ | |||
1778 1779 1780 1781 1782 1783 1784 |
if (err==ZIP_OK) /* number of the disk with the start of the central directory */
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2);
if (err==ZIP_OK) /* total number of entries in the central dir on this disk */
{
{
if(zi->number_entry >= 0xFFFF)
| | | | 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 |
if (err==ZIP_OK) /* number of the disk with the start of the central directory */
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2);
if (err==ZIP_OK) /* total number of entries in the central dir on this disk */
{
{
if(zi->number_entry >= 0xFFFF)
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); /* use value in ZIP64 record */
else
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2);
}
}
if (err==ZIP_OK) /* total number of entries in the central dir */
{
if(zi->number_entry >= 0xFFFF)
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); /* use value in ZIP64 record */
else
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2);
}
if (err==ZIP_OK) /* size of the central directory */
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_centraldir,4);
|
| ︙ | ︙ | |||
1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 |
}
size_centraldir += ldi->filled_in_this_block;
ldi = ldi->next_datablock;
}
}
free_linkedlist(&(zi->central_dir));
pos = centraldir_pos_inzip - zi->add_position_when_writing_offset;
if(pos >= 0xffffffff || zi->number_entry >= 0xFFFF)
{
ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream);
Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip);
| > > | 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 |
}
size_centraldir += ldi->filled_in_this_block;
ldi = ldi->next_datablock;
}
}
free_linkedlist(&(zi->central_dir));
set_end(&zi->set); /* set was zeroed, so this is safe */
pos = centraldir_pos_inzip - zi->add_position_when_writing_offset;
if(pos >= 0xffffffff || zi->number_entry >= 0xFFFF)
{
ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream);
Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip);
|
| ︙ | ︙ | |||
1915 1916 1917 1918 1919 1920 1921 |
pTmp = pNewHeader;
while(p < (pData + *dataLen))
{
header = *(short*)p;
dataSize = *(((short*)p)+1);
| | | | | | | | 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 |
pTmp = pNewHeader;
while(p < (pData + *dataLen))
{
header = *(short*)p;
dataSize = *(((short*)p)+1);
if( header == sHeader ) /* Header found. */
{
p += dataSize + 4; /* skip it. do not copy to temp buffer */
}
else
{
/* Extra Info block should not be removed, So copy it to the temp buffer. */
memcpy(pTmp, p, dataSize + 4);
p += dataSize + 4;
size += dataSize + 4;
}
}
if(size < *dataLen)
{
/* clean old extra info block. */
memset(pData,0, *dataLen);
/* copy the new extra info block over the old */
if(size > 0)
memcpy(pData, pNewHeader, size);
/* set the new extra info size */
*dataLen = size;
retVal = ZIP_OK;
}
else
retVal = ZIP_ERRNO;
free(pNewHeader);
return retVal;
}
|
Changes to compat/zlib/contrib/minizip/zip.h.
1 | /* zip.h -- IO on .zip files using zlib | < | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
/* zip.h -- IO on .zip files using zlib
part of the MiniZip project - ( https://www.winimage.com/zLibDll/minizip.html )
Copyright (C) 1998-2026 Gilles Vollant (minizip) ( https://www.winimage.com/zLibDll/minizip.html )
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson ( https://result42.com )
For more info read MiniZip_info.txt
---------------------------------------------------------------------------
Condition of use and distribution are the same than zlib :
|
| ︙ | ︙ | |||
31 32 33 34 35 36 37 |
---------------------------------------------------------------------------
Changes
See header of zip.h
| | | | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
---------------------------------------------------------------------------
Changes
See header of zip.h
*/
#ifndef _zip12_H
#define _zip12_H
#ifdef __cplusplus
extern "C" {
#endif
/* #define HAVE_BZIP2 */
#ifndef _ZLIB_H
#include "zlib.h"
#endif
#ifndef _ZLIBIOAPI_H
#include "ioapi.h"
|
| ︙ | ︙ | |||
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
/* like the STRICT of WIN32, we define a pointer that cannot be converted
from (void*) without cast */
typedef struct TagzipFile__ { int unused; } zipFile__;
typedef zipFile__ *zipFile;
#else
typedef voidp zipFile;
#endif
#define ZIP_OK (0)
#define ZIP_EOF (0)
#define ZIP_ERRNO (Z_ERRNO)
#define ZIP_PARAMERROR (-102)
#define ZIP_BADZIPFILE (-103)
#define ZIP_INTERNALERROR (-104)
| > > | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
/* like the STRICT of WIN32, we define a pointer that cannot be converted
from (void*) without cast */
typedef struct TagzipFile__ { int unused; } zipFile__;
typedef zipFile__ *zipFile;
#else
typedef voidp zipFile;
#endif
extern const char zip_copyright[];
#define ZIP_OK (0)
#define ZIP_EOF (0)
#define ZIP_ERRNO (Z_ERRNO)
#define ZIP_PARAMERROR (-102)
#define ZIP_BADZIPFILE (-103)
#define ZIP_INTERNALERROR (-104)
|
| ︙ | ︙ | |||
123 124 125 126 127 128 129 |
will be created at the end of the file.
(useful if the file contain a self extractor code)
if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will
add files in existing zip (be sure you don't add file that doesn't exist)
If the zipfile cannot be opened, the return value is NULL.
Else, the return value is a zipFile Handle, usable with other function
of this zip package.
| | | | 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
will be created at the end of the file.
(useful if the file contain a self extractor code)
if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will
add files in existing zip (be sure you don't add file that doesn't exist)
If the zipfile cannot be opened, the return value is NULL.
Else, the return value is a zipFile Handle, usable with other function
of this zip package.
*/
/* Note : there is no delete function into a zipfile.
If you want delete file into a zipfile, you must open a zipfile, and create another
Of course, you can use RAW reading and writing to copy the file you did not want delete
*/
extern zipFile ZEXPORT zipOpen2(const char *pathname,
int append,
zipcharpc* globalcomment,
zlib_filefunc_def* pzlib_filefunc_def);
extern zipFile ZEXPORT zipOpen2_64(const void *pathname,
|
| ︙ | ︙ | |||
182 183 184 185 186 187 188 |
contains the extrafield data for the global header
if comment != NULL, comment contain the comment string
method contain the compression method (0 for store, Z_DEFLATED for deflate)
level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
zip64 is set to 1 if a zip64 extended information block should be added to the local file header.
this MUST be '1' if the uncompressed size is >= 0xffffffff.
| | | 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
contains the extrafield data for the global header
if comment != NULL, comment contain the comment string
method contain the compression method (0 for store, Z_DEFLATED for deflate)
level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
zip64 is set to 1 if a zip64 extended information block should be added to the local file header.
this MUST be '1' if the uncompressed size is >= 0xffffffff.
*/
extern int ZEXPORT zipOpenNewFileInZip2(zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
|
| ︙ | ︙ | |||
307 308 309 310 311 312 313 |
extern int ZEXPORT zipWriteInFileInZip(zipFile file,
const void* buf,
unsigned len);
/*
Write data in the zipfile
| | | > > > > > > | | | | 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
extern int ZEXPORT zipWriteInFileInZip(zipFile file,
const void* buf,
unsigned len);
/*
Write data in the zipfile
*/
extern int ZEXPORT zipCloseFileInZip(zipFile file);
/*
Close the current file in the zipfile
*/
extern int ZEXPORT zipCloseFileInZipRaw(zipFile file,
uLong uncompressed_size,
uLong crc32);
extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file,
ZPOS64_T uncompressed_size,
uLong crc32);
extern int ZEXPORT zipAlreadyThere(zipFile file,
char const* name);
/*
See if name is already in file's central directory.
*/
/*
Close the current file in the zipfile, for file opened with
parameter raw=1 in zipOpenNewFileInZip2
uncompressed_size and crc32 are value for the uncompressed size
*/
extern int ZEXPORT zipClose(zipFile file,
const char* global_comment);
/*
Close the zipfile
*/
extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHeader);
/*
zipRemoveExtraInfoBlock - Added by Mathias Svensson
Remove extra information block from a extra information data for the local file header or central directory header
It is needed to remove ZIP64 extra information blocks when before data is written if using RAW mode.
0x0001 is the signature header for the ZIP64 extra information blocks
usage.
Remove ZIP64 Extra information from a central director extra field data
zipRemoveExtraInfoBlock(pCenDirExtraFieldData, &nCenDirExtraFieldDataLen, 0x0001);
Remove ZIP64 Extra information from a Local File Header extra field data
zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001);
*/
#ifdef __cplusplus
}
#endif
#endif /* _zip64_H */
|
Added compat/zlib/contrib/nuget/nuget.csproj.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 |
<Project Sdk="Microsoft.Build.NoTargets/3.5.6">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<PackageId>madler.zlib.redist</PackageId>
<PackageId Condition="$([MSBuild]::IsOSPlatform('Windows'))">$(PackageId).win</PackageId>
<PackageId Condition="$([MSBuild]::IsOSPlatform('Linux'))">$(PackageId).linux</PackageId>
<PackageId Condition="$([MSBuild]::IsOSPlatform('OSX'))">$(PackageId).osx</PackageId>
<Copyright>(C) 1995-2026 Jean-loup Gailly and Mark Adler</Copyright>
<version>1.3.2</version>
<PackageDescription>NuGet Package for consuming native builds of zlib into .NET without complexity.</PackageDescription>
<PackageReadmeFile>README</PackageReadmeFile>
<!--
Warns about not having any lib or ref assemblies (.NET Assemblies) in those directories.
Native only packages that is to be consumed in .NET should not require these.
-->
<NoWarn>NU5128</NoWarn>
<PackageOutputPath>$(MSBuildProjectDirectory)</PackageOutputPath>
<Authors>Jean-loup Gailly and Mark Adler</Authors>
</PropertyGroup>
<ItemGroup>
<None Include="../../LICENSE" Pack="true" PackagePath="" />
<None Include="../../README" Pack="true" PackagePath="" />
<!-- Package up Windows builds. -->
<None Condition="$([MSBuild]::IsOSPlatform('Windows'))" Include="../vstudio/vc17/x86/ZlibDll$(Configuration)/zlibwapi.dll" Pack="true" PackagePath="runtimes/win-x86/native" />
<None Condition="$([MSBuild]::IsOSPlatform('Windows'))" Include="../vstudio/vc17/x64/ZlibDll$(Configuration)/zlibwapi.dll" Pack="true" PackagePath="runtimes/win-x64/native" />
<None Condition="$([MSBuild]::IsOSPlatform('Windows'))" Include="../vstudio/vc17/arm/ZlibDll$(Configuration)/zlibwapi.dll" Pack="true" PackagePath="runtimes/win-arm/native" />
<None Condition="$([MSBuild]::IsOSPlatform('Windows'))" Include="../vstudio/vc17/arm64/ZlibDll$(Configuration)/zlibwapi.dll" Pack="true" PackagePath="runtimes/win-arm64/native" />
<!-- Include debug symbols as well as we never know if they might actually be needed in the future. -->
<None Condition="$([MSBuild]::IsOSPlatform('Windows'))" Include="../vstudio/vc17/x86/ZlibDll$(Configuration)/zlibwapi.pdb" Pack="true" PackagePath="runtimes/win-x86/native" />
<None Condition="$([MSBuild]::IsOSPlatform('Windows'))" Include="../vstudio/vc17/x64/ZlibDll$(Configuration)/zlibwapi.pdb" Pack="true" PackagePath="runtimes/win-x64/native" />
<None Condition="$([MSBuild]::IsOSPlatform('Windows'))" Include="../vstudio/vc17/arm/ZlibDll$(Configuration)/zlibwapi.pdb" Pack="true" PackagePath="runtimes/win-arm/native" />
<None Condition="$([MSBuild]::IsOSPlatform('Windows'))" Include="../vstudio/vc17/arm64/ZlibDll$(Configuration)/zlibwapi.pdb" Pack="true" PackagePath="runtimes/win-arm64/native" />
<!-- Package up Linux builds. -->
<None Condition="$([MSBuild]::IsOSPlatform('Linux'))" Include="./linux-x86/libz.so" Pack="true" PackagePath="runtimes/linux-x86/native" />
<None Condition="$([MSBuild]::IsOSPlatform('Linux'))" Include="./linux-x64/libz.so" Pack="true" PackagePath="runtimes/linux-x64/native" />
<None Condition="$([MSBuild]::IsOSPlatform('Linux'))" Include="./linux-arm/libz.so" Pack="true" PackagePath="runtimes/linux-arm/native" />
<None Condition="$([MSBuild]::IsOSPlatform('Linux'))" Include="./linux-arm64/libz.so" Pack="true" PackagePath="runtimes/linux-arm64/native" />
<!-- Package up MacOS builds. -->
<None Condition="$([MSBuild]::IsOSPlatform('OSX'))" Include="./osx-x64/libz.dylib" Pack="true" PackagePath="runtimes/osx-x64/native" />
<None Condition="$([MSBuild]::IsOSPlatform('OSX'))" Include="./osx-arm64/libz.dylib" Pack="true" PackagePath="runtimes/osx-arm64/native" />
</ItemGroup>
</Project>
|
Added compat/zlib/contrib/nuget/nuget.sln.
> > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nuget", "nuget.csproj", "{B1BD3984-EF8F-4E9D-9A94-EB784E5EB1E8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B1BD3984-EF8F-4E9D-9A94-EB784E5EB1E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B1BD3984-EF8F-4E9D-9A94-EB784E5EB1E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1BD3984-EF8F-4E9D-9A94-EB784E5EB1E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B1BD3984-EF8F-4E9D-9A94-EB784E5EB1E8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
|
Changes to compat/zlib/contrib/pascal/zlibpas.pas.
1 2 3 4 5 6 7 8 9 10 11 12 | (* zlibpas -- Pascal interface to the zlib data compression library * * Copyright (C) 2003 Cosmin Truta. * Derived from original sources by Bob Dellaca. * For conditions of distribution and use, see copyright notice in readme.txt *) unit zlibpas; interface const | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
(* zlibpas -- Pascal interface to the zlib data compression library
*
* Copyright (C) 2003 Cosmin Truta.
* Derived from original sources by Bob Dellaca.
* For conditions of distribution and use, see copyright notice in readme.txt
*)
unit zlibpas;
interface
const
ZLIB_VERSION = '1.3.2';
ZLIB_VERNUM = $12a0;
type
alloc_func = function(opaque: Pointer; items, size: Integer): Pointer;
cdecl;
free_func = procedure(opaque, address: Pointer);
cdecl;
|
| ︙ | ︙ |
Added compat/zlib/contrib/puff/CMakeLists.txt.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
puff
VERSION 2.3.0
LANGUAGES C
DESCRIPTION "A library for decompressing deflate with very little footprint"
HOMEPAGE_URL "https://www.zlib.net")
option(ZLIB_PUFF_BUILD_SHARED "Enable building blast shared library" ON)
option(ZLIB_PUFF_BUILD_STATIC "Enable building blast static library" ON)
option(ZLIB_PUFF_BUILD_TESTING "Enable building tests for blast" ON)
option(ZLIB_PUFF_INSTALL "Enable installation of puff" ON)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
if(NOT DEFINED ZLIB_BUILD_PUFF)
if(ZLIB_PUFF_BUILD_SHARED)
list(APPEND REQUIRED_COMPONENTS "shared")
endif(ZLIB_PUFF_BUILD_SHARED)
if(ZLIB_PUFF_BUILD_STATIC)
list(APPEND REQUIRED_COMPONENTS "static")
endif(ZLIB_PUFF_BUILD_STATIC)
find_package(ZLIB REQUIRED COMPONENTS ${REQUIRED_COMPONENTS} CONFIG)
endif(NOT DEFINED ZLIB_BUILD_PUFF)
if(WIN32 OR CYGWIN)
set(zlibpuff_static_suffix "s")
set(CMAKE_DEBUG_POSTFIX "d")
endif(WIN32 OR CYGWIN)
if(ZLIB_PUFF_BUILD_TESTING)
add_executable(zlib_puff_bin-writer bin-writer.c)
if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR
${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
set(CFLAGS_OLD ${CMAKE_C_FLAGS})
set(CMAKE_C_FLAGS
""
CACHE STRING "" FORCE)
if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
find_program(GCOV_EXECUTABLE gcov)
endif(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
if(${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
set(llvm_names llvm_cov)
list(APPEND llvm_names llvm-cov)
foreach(ver RANGE 11 99)
list(APPEND llvm_names llvm-cov-${ver})
endforeach(ver RANGE 11 99)
find_program(GCOV_EXECUTABLE NAMES ${llvm_names})
set(llvm_option "gcov")
endif(${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
endif(${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR
${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
add_subdirectory(test)
endif(ZLIB_PUFF_BUILD_TESTING)
if(ZLIB_PUFF_BUILD_SHARED)
add_library(zlib_puff_puff SHARED
puff.c
puff.h)
add_library(PUFF::PUFF ALIAS zlib_puff_puff)
if(NOT CYGWIN)
set_target_properties(zlib_puff_puff
PROPERTIES
SOVERSION ${puff_VERSION_MAJOR}
VERSION ${puff_VERSION})
endif(NOT CYGWIN)
set_target_properties(
zlib_puff_puff
PROPERTIES
EXPORT_NAME PUFF
OUTPUT_NAME puff)
endif(ZLIB_PUFF_BUILD_SHARED)
if(ZLIB_PUFF_BUILD_STATIC)
add_library(zlib_puff_puffStatic STATIC
puff.c
puff.h)
add_library(PUFF::PUFFSTATIC ALIAS zlib_puff_puffStatic)
set_target_properties(zlib_puff_puffStatic
PROPERTIES
EXPORT_NAME PUFFSTATIC
OUTPUT_NAME puff${zlib_puff_static_suffix})
endif(ZLIB_PUFF_BUILD_STATIC)
if(ZLIB_PUFF_INSTALL)
if(ZLIB_PUFF_BUILD_SHARED)
install(
TARGETS zlib_puff_puff
COMPONENT Runtime
EXPORT puffSharedExport
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(
EXPORT puffSharedExport
FILE puff-shared.cmake
NAMESPACE PUFF::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/puff)
if(MSVC)
install(
FILES $<TARGET_PDB_FILE:zlib_puff_puff>
COMPONENT Development
DESTINATION ${CMAKE_INSTALL_BINDIR}
CONFIGURATIONS Debug OR RelWithDebInfo
OPTIONAL)
endif(MSVC)
endif(ZLIB_PUFF_BUILD_SHARED)
if(ZLIB_PUFF_BUILD_STATIC)
install(
TARGETS zlib_puff_puffStatic
COMPONENT Development
EXPORT puffStaticExport
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(
EXPORT puffStaticExport
FILE puff-static.cmake
NAMESPACE PUFF::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/puff)
endif(ZLIB_PUFF_BUILD_STATIC)
configure_package_config_file(
${puff_SOURCE_DIR}/puffConfig.cmake.in
${puff_BINARY_DIR}/puffConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/puff)
write_basic_package_version_file(
"${puff_BINARY_DIR}/puffConfigVersion.cmake"
VERSION "${puff_VERSION}"
COMPATIBILITY AnyNewerVersion)
install(FILES ${puff_BINARY_DIR}/puffConfig.cmake
${puff_BINARY_DIR}/puffConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/puff)
install(
FILES puff.h
COMPONENT Development
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
endif(ZLIB_PUFF_INSTALL)
|
Added compat/zlib/contrib/puff/bin-writer.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
#include "stdio.h"
#include "stdlib.h"
/**
* Reads hexadecimal values from stdin and writes binary bytes to stdout.
* Accepts hex values separated by spaces, newlines, commas, etc.
* Handles both uppercase and lowercase hex digits.
*/
int main(void) {
char hexStr[3]; // Two hex digits + null terminator
int ch;
// Read characters until EOF
while((ch = getchar()) != EOF) {
hexStr[0] = (char)ch;
hexStr[1] = (char)getchar();
hexStr[2] = '\0'; // Null-terminate string
char *endptr;
unsigned char byte = (unsigned char)strtol(hexStr, &endptr, 16);
fwrite(&byte, 1, 1, stdout);
if((ch = getchar()) == EOF) // Read seaparating space
break;
}
return 0;
}
|
Changes to compat/zlib/contrib/puff/puff.c.
| ︙ | ︙ | |||
21 22 23 24 25 26 27 | * works whether integers are stored big endian or little endian. * * In the comments below are "Format notes" that describe the inflate process * and document some of the less obvious aspects of the format. This source * code is meant to supplement RFC 1951, which formally describes the deflate * format: * | | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | * works whether integers are stored big endian or little endian. * * In the comments below are "Format notes" that describe the inflate process * and document some of the less obvious aspects of the format. This source * code is meant to supplement RFC 1951, which formally describes the deflate * format: * * https://datatracker.ietf.org/doc/html/rfc1951 */ /* * Change history: * * 1.0 10 Feb 2002 - First version * 1.1 17 Feb 2002 - Clarifications of some comments and notes |
| ︙ | ︙ |
Added compat/zlib/contrib/puff/puffConfig.cmake.in.
> > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
@PACKAGE_INIT@
set(_puff_supported_components "shared" "static")
if(puff_FIND_COMPONENTS)
foreach(_comp ${puff_FIND_COMPONENTS})
if(NOT _comp IN_LIST _puff_supported_components)
set(puff_FOUND False)
set(puff_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
endif(NOT _comp IN_LIST _puff_supported_components)
include("${CMAKE_CURRENT_LIST_DIR}/puff-${_comp}.cmake")
endforeach(_comp ${puff_FIND_COMPONENTS})
else(puff_FIND_COMPONENTS)
foreach(_component_config IN LISTS _puff_supported_components)
include("${CMAKE_CURRENT_LIST_DIR}/puff-${_component_config}.cmake")
endforeach(_component_config IN LISTS _puff_supported_components)
endif(puff_FIND_COMPONENTS)
|
Changes to compat/zlib/contrib/puff/pufftest.c.
1 2 | /* * pufftest.c | | < > > > > | | 1 2 3 4 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 |
/*
* pufftest.c
* Copyright (C) 2002-2026 Mark Adler
* For conditions of distribution and use, see copyright notice in puff.h
*/
/* Example of how to use puff().
Usage: puff [-w] [-f] [-nnn] file
... | puff [-w] [-f] [-nnn]
where file is the input file with deflate data, nnn is the number of bytes
of input to skip before inflating (e.g. to skip a zlib or gzip header), and
-w is used to write the decompressed data to stdout. -f is for coverage
testing, and causes pufftest to fail with not enough output space (-f does
a write like -w, so -w is not required). */
#if defined(_WIN32) && !defined(_CRT_NONSTDC_NO_DEPRECATE)
# define _CRT_NONSTDC_NO_DEPRECATE
#endif
#include <stdio.h>
#include <stdlib.h>
#include "puff.h"
#if defined(MSDOS) || defined(OS2) || defined(_WIN32) || defined(__CYGWIN__)
# include <fcntl.h>
# include <io.h>
# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
#else
# define SET_BINARY_MODE(file)
#endif
|
| ︙ | ︙ |
Added compat/zlib/contrib/puff/test/CMakeLists.txt.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
# if we are built from with zlib, use this path's)
if(DEFINED ZLIB_BUILD_PUFF)
set(WORK_DIR ${zlib_BINARY_DIR})
set(inst_setup zlib_install)
else(DEFINED ZLIB_BUILD_PUFF)
set(WORK_DIR ${puff_BINARY_DIR})
set(inst_setup zlib_puff_install)
set(ZLIB_ARG "-DZLIB_DIR=${ZLIB_DIR}")
add_test(
NAME zlib_puff_install
COMMAND ${CMAKE_COMMAND} --install ${puff_BINARY_DIR} --prefix
${CMAKE_CURRENT_BINARY_DIR}/test_install --config $<CONFIG>
WORKING_DIRECTORY ${puff_BINARY_DIR})
set_tests_properties(zlib_puff_install
PROPERTIES
FIXTURES_SETUP zlib_puff_install)
endif(DEFINED ZLIB_BUILD_PUFF)
if(ZLIB_PUFF_BUILD_SHARED AND NOT WIN32)
add_executable(zlib_puff_test
${puff_SOURCE_DIR}/pufftest.c
${puff_SOURCE_DIR}/puff.h)
target_link_libraries(zlib_puff_test
PRIVATE zlib_puff_puff)
add_test(NAME zlib_puff_test
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_SOURCE_DIR}/tester.cmake
"$<TARGET_FILE:zlib_puff_test>"
"${puff_SOURCE_DIR}")
if(GCOV_EXECUTABLE)
add_executable(zlib_puff_test-coverage
${puff_SOURCE_DIR}/pufftest.c
${puff_SOURCE_DIR}/puff.c
${puff_SOURCE_DIR}/puff.h)
target_compile_options(zlib_puff_test-coverage PRIVATE -coverage)
target_link_options(zlib_puff_test-coverage PRIVATE -coverage)
add_test(NAME zlib_puff_test-coverage
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_SOURCE_DIR}/tester-cov.cmake
"$<TARGET_FILE:zlib_puff_test-coverage>"
"${puff_SOURCE_DIR}"
"$<TARGET_FILE:zlib_puff_bin-writer>"
${GCOV_EXECUTABLE}
${llvm_option})
endif(GCOV_EXECUTABLE)
endif(ZLIB_PUFF_BUILD_SHARED AND NOT WIN32)
if(ZLIB_PUFF_BUILD_STATIC AND NOT WIN32)
add_executable(zlib_puff_testStatic
${puff_SOURCE_DIR}/pufftest.c
${puff_SOURCE_DIR}/puff.h)
target_link_libraries(zlib_puff_testStatic
PRIVATE zlib_puff_puffStatic)
add_test(NAME zlib_puff_testStatic
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_SOURCE_DIR}/tester.cmake
"$<TARGET_FILE:zlib_puff_testStatic>"
"${puff_SOURCE_DIR}")
if(GCOV_EXECUTABLE)
add_executable(zlib_puff_testStatic-coverage
${puff_SOURCE_DIR}/pufftest.c
${puff_SOURCE_DIR}/puff.c
${puff_SOURCE_DIR}/puff.h)
target_compile_options(zlib_puff_testStatic-coverage
PRIVATE -coverage)
target_link_options(zlib_puff_testStatic-coverage
PRIVATE -coverage)
add_test(NAME zlib_puff_testStatic-coverage
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_SOURCE_DIR}/tester-cov.cmake
"$<TARGET_FILE:zlib_puff_testStatic-coverage>"
"${puff_SOURCE_DIR}"
"$<TARGET_FILE:zlib_puff_bin-writer>"
${GCOV_EXECUTABLE}
${llvm_option})
endif(GCOV_EXECUTABLE)
endif(ZLIB_PUFF_BUILD_STATIC AND NOT WIN32)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/find_package_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/findpackage_test/CMakeLists.txt @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test/CMakeLists.txt @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_exclude_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test/CMakeLists.txt
@ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/find_package_no_components_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/findpackage_no_components_test/CMakeLists.txt
@ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/find_package_wrong_components_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/findpackage_wrong_components_test/CMakeLists.txt
@ONLY)
# CMAKE_GENERATOR_PLATFORM doesn't work in the if
set(GENERATOR ${CMAKE_GENERATOR_PLATFORM})
if(GENERATOR)
set(PLATFORM "-A ${GENERATOR}")
endif(GENERATOR)
#
# findpackage_test
#
add_test(
NAME zlib_puff_find_package_configure
COMMAND
${CMAKE_COMMAND}
${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG>
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install
${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
add_test(
NAME zlib_puff_find_package_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
set_tests_properties(zlib_puff_find_package_configure
PROPERTIES
FIXTURES_REQUIRED ${inst_setup}
FIXTURES_SETUP puff_fp_config)
set_tests_properties(zlib_puff_find_package_build
PROPERTIES
FIXTURES_REQUIRED puff_fp_config)
#
# add_subdirectory_test
#
add_test(
NAME zlib_puff_add_subdirectory_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG>
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test)
add_test(
NAME zlib_puff_add_subdirectory_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
set_tests_properties(zlib_puff_add_subdirectory_configure
PROPERTIES
FIXTURES_REQUIRED ${inst_setup}
FIXTURES_SETUP puiff_as_config)
set_tests_properties(zlib_puff_add_subdirectory_build
PROPERTIES
FIXTURES_REQUIRED puff_as_config)
#
# add_subdirectory_exclude_test
#
add_test(
NAME zlib_puff_add_subdirectory_exclude_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test)
add_test(
NAME zlib_puff_add_subdirectory_exclude_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
set_tests_properties(zlib_puff_add_subdirectory_exclude_configure
PROPERTIES
FIXTURES_REQUIRED ${inst_setup}
FIXTURES_SETUP puff_asx_config)
set_tests_properties(zlib_puff_add_subdirectory_exclude_build
PROPERTIES
FIXTURES_REQUIRED puff_asx_config)
#
# findpackage_no_components_test
#
add_test(
NAME zlib_puff_find_package_no_components_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/findpackage_no_components_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_no_components_test)
set_tests_properties(
zlib_puff_find_package_no_components_configure
PROPERTIES
FIXTURES_REQUIRED ${inst_setup})
if(NOT ZLIB_PUFF_BUILD_SHARED OR NOT ZLIB_PUFF_BUILD_STATIC)
set_tests_properties(zlib_puff_find_package_no_components_configure
PROPERTIES
WILL_FAIL TRUE)
endif(NOT ZLIB_PUFF_BUILD_SHARED OR NOT ZLIB_PUFF_BUILD_STATIC)
#
# findpackage_no_components_test
#
add_test(
NAME zlib_puff_find_package_wrong_components_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/findpackage_wrong_components_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_wrong_components_test)
set_tests_properties(zlib_puff_find_package_wrong_components_configure
PROPERTIES
FIXTURES_REQUIRED ${inst_setup}
WILL_FAIL TRUE)
|
Added compat/zlib/contrib/puff/test/add_subdirectory_exclude_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
zlib_puff_add_subdirectory_exclude_from_all
LANGUAGES C
VERSION @puff_VERSION@)
option(ZLIB_PUFF_BUILD_TESTING "" OFF)
option(ZLIB_PUFF_BUILD_SHARED "" @ZLIB_PUFF_BUILD_SHARED@)
option(ZLIB_PUFF_BUILD_STATIC "" @ZLIB_PUFF_BUILD_STATIC@)
add_subdirectory(@puff_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/puff
EXCLUDE_FROM_ALL)
set(PUFF_SRCS
@puff_SOURCE_DIR@/pufftest.c)
if(ZLIB_PUFF_BUILD_SHARED)
add_executable(test_example ${PUFF_SRCS})
target_link_libraries(test_example PUFF::PUFF)
endif(ZLIB_PUFF_BUILD_SHARED)
if(ZLIB_PUFF_BUILD_STATIC)
add_executable(test_example_static ${PUFF_SRCS})
target_link_libraries(test_example_static PUFF::PUFFSTATIC)
endif(ZLIB_PUFF_BUILD_STATIC)
|
Added compat/zlib/contrib/puff/test/add_subdirectory_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
zlib_puff_add_subdirectory
LANGUAGES C
VERSION @puff_VERSION@)
option(ZLIB_PUFF_BUILD_TESTING "" OFF)
option(ZLIB_PUFF_BUILD_SHARED "" @ZLIB_PUFF_BUILD_SHARED@)
option(ZLIB_PUFF_BUILD_STATIC "" @ZLIB_PUFF_BUILD_STATIC@)
add_subdirectory(@puff_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/puff)
set(PUFF_SRCS
@puff_SOURCE_DIR@/pufftest.c)
if(ZLIB_PUFF_BUILD_SHARED)
add_executable(test_example ${PUFF_SRCS})
target_link_libraries(test_example PUFF::PUFF)
endif(ZLIB_PUFF_BUILD_SHARED)
if(ZLIB_PUFF_BUILD_STATIC)
add_executable(test_example_static ${PUFF_SRCS})
target_link_libraries(test_example_static PUFF::PUFFSTATIC)
endif(ZLIB_PUFF_BUILD_STATIC)
|
Added compat/zlib/contrib/puff/test/find_package_no_components_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
puff_find_package
LANGUAGES C
VERSION @puff_VERSION@)
option(ZLIB_PUFF_BUILD_SHARED "" @ZLIB_PUFF_BUILD_SHARED@)
option(ZLIB_PUFF_BUILD_STATIC "" @ZLIB_PUFF_BUILD_STATIC@)
find_package(puff REQUIRED CONFIG)
set(PUFF_SRCS
@puff_SOURCE_DIR@/pufftest.c)
if(ZLIB_PUFF_BUILD_SHARED)
add_executable(test_example ${PUFF_SRCS})
target_link_libraries(test_example PUFF::PUFF)
endif(ZLIB_PUFF_BUILD_SHARED)
if(ZLIB_PUFF_BUILD_STATIC)
add_executable(test_example_static ${PUFF_SRCS})
target_link_libraries(test_example_static PUFF::PUFFSTATIC)
endif(ZLIB_PUFF_BUILD_STATIC)
|
Added compat/zlib/contrib/puff/test/find_package_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
puff_find_package
LANGUAGES C
VERSION @puff_VERSION@)
option(ZLIB_PUFF_BUILD_SHARED "" @ZLIB_PUFF_BUILD_SHARED@)
option(ZLIB_PUFF_BUILD_STATIC "" @ZLIB_PUFF_BUILD_STATIC@)
set(PUFF_SRCS
@puff_SOURCE_DIR@/pufftest.c)
if(ZLIB_PUFF_BUILD_SHARED)
find_package(puff REQUIRED COMPONENTS shared CONFIG)
add_executable(test_example ${PUFF_SRCS})
target_link_libraries(test_example PUFF::PUFF)
endif(ZLIB_PUFF_BUILD_SHARED)
if(ZLIB_PUFF_BUILD_STATIC)
find_package(puff REQUIRED COMPONENTS static CONFIG)
add_executable(test_example_static ${PUFF_SRCS})
target_link_libraries(test_example_static PUFF::PUFFSTATIC)
endif(ZLIB_PUFF_BUILD_STATIC)
|
Added compat/zlib/contrib/puff/test/find_package_wrong_components_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
puff_find_package
LANGUAGES C
VERSION @puff_VERSION@)
option(ZLIB_PUFF_BUILD_SHARED "" @ZLIB_PUFF_BUILD_SHARED@)
option(ZLIB_PUFF_BUILD_STATIC "" @ZLIB_PUFF_BUILD_STATIC@)
find_package(puff REQUIRED COMPONENTS wrong CONFIG)
set(PUFF_SRCS
@puff_SOURCE_DIR@/pufftest.c)
if(ZLIB_PUFF_BUILD_SHARED)
add_executable(test_example ${PUFF_SRCS})
target_link_libraries(test_example PUFF::PUFF)
endif(ZLIB_PUFF_BUILD_SHARED)
if(ZLIB_PUFF_BUILD_STATIC)
add_executable(test_example_static ${PUFF_SRCS})
target_link_libraries(test_example_static PUFF::PUFFSTATIC)
endif(ZLIB_PUFF_BUILD_STATIC)
|
Added compat/zlib/contrib/puff/test/tester-cov.cmake.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 |
cmake_minimum_required(VERSION 3.12...3.31)
#CMAKE_ARGV0 = ${CMAKE_COMMAND}
#CMAKE_ARGV1 = -P
#CMAKE_ARGV2 = ${CMAKE_CURRENT_SOURCE_DIR}/tester-cov.cmake
#CMAKE_ARGV3 = "$<TARGET_FILE:puff-test-cov>"
#CMAKE_ARGV4 = "${CMAKE_CURRENT_SOURCE_DIR}"
#CMAKE_ARGV5 = "${CMAKE_CURRENT_BINARY_DIR}"
#CMAKE_ARGV6 = GCOV_EXECUTABLE
#CMAKE_ARGV7 = GCOV_EXECUTABLE
function(puff_cov_test test_string expected_result)
execute_process(COMMAND ${CMAKE_ARGV0} -E echo_append ${test_string}
COMMAND ${CMAKE_ARGV5}
COMMAND ${CMAKE_ARGV3}
RESULT_VARIABLE RESULT)
if(NOT RESULT EQUAL expected_result)
message(FATAL_ERROR "Received Exit-Code: ${RESULT}\n"
"Expected Exit-Code: ${expected_result}\n"
"Test-String: ${test_string}")
endif(NOT RESULT EQUAL expected_result)
endfunction(puff_cov_test test_string expected_result)
execute_process(COMMAND ${CMAKE_ARGV3} -w ${CMAKE_ARGV4}/zeros.raw)
puff_cov_test("04" "2")
puff_cov_test("00" "2")
puff_cov_test("00 00 00 00 00" "254")
puff_cov_test("00 01 00 fe ff" "2")
execute_process(COMMAND ${CMAKE_ARGV0} -E echo_append "01 01 00 fe ff 0a"
COMMAND ${CMAKE_ARGV5}
COMMAND ${CMAKE_ARGV3})
puff_cov_test("02 7e ff ff" "246")
puff_cov_test("02" "2")
puff_cov_test("04 80 49 92 24 49 92 24 0f b4 ff ff c3 04" "2")
puff_cov_test("04 80 49 92 24 49 92 24 71 ff ff 93 11 00" "249")
puff_cov_test("04 c0 81 08 00 00 00 00 20 7f eb 0b 00 00" "246")
execute_process(COMMAND ${CMAKE_ARGV0} -E echo_append "0b 00 00"
COMMAND ${CMAKE_ARGV5}
COMMAND ${CMAKE_ARGV3})
puff_cov_test("1a 07" "246")
puff_cov_test("0c c0 81 00 00 00 00 00 90 ff 6b 04" "245")
execute_process(COMMAND ${CMAKE_ARGV3} -f ${CMAKE_ARGV4}/zeros.raw)
puff_cov_test("fc 00 00" "253")
puff_cov_test("04 00 fe ff" "252")
puff_cov_test("04 00 24 49" "251")
puff_cov_test("04 80 49 92 24 49 92 24 0f b4 ff ff c3 84" "248")
puff_cov_test("04 00 24 e9 ff ff" "250")
puff_cov_test("04 00 24 e9 ff 6d" "247")
execute_process(COMMAND ${CMAKE_ARGV6} ${CMAKE_ARGV7} -n puff.c.gcno)
|
Added compat/zlib/contrib/puff/test/tester.cmake.
> > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
cmake_minimum_required(VERSION 3.12...3.31)
#CMAKE_ARGV0 = ${CMAKE_COMMAND}
#CMAKE_ARGV1 = -P
#CMAKE_ARGV2 = ${CMAKE_CURRENT_SOURCE_DIR}/tester.cmake
#CMAKE_ARGV3 = "$<TARGET_FILE:puff-test>"
#CMAKE_ARGV4 = "${CMAKE_CURRENT_SOURCE_DIR}"
execute_process(COMMAND ${CMAKE_ARGV3}
INPUT_FILE "${CMAKE_ARGV4}/zeros.raw"
RESULT_VARIABLE RESULT
COMMAND_ECHO STDERR)
if(RESULT)
message(FATAL_ERROR "Command exitited with: ${RESULT}")
endif(RESULT)
|
Added compat/zlib/contrib/testzlib/CMakeLists.txt.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
testzlib
VERSION 1.0.0
LANGUAGES C
DESCRIPTION "A little program to test zlib"
HOMEPAGE_URL "https://www.zlib.net")
option(ZLIB_TESTZLIB_BUILD_SHARED "Enable building testzlib" ON)
option(ZLIB_TESTZLIB_BUILD_STATIC "Enable building static linked testzlib" ON)
option(ZLIB_TESTZLIB_INSTALL "Enable installation of testzlib" ON)
if(ZLIB_TESTZLIB_BUILD_SHARED)
add_executable(zlib_testzlib testzlib.c)
target_link_libraries(zlib_testzlib PRIVATE ZLIB::ZLIB)
set_target_properties(zlib_testzlib
PROPERTIES
OUTPUT_NAME testzlib)
if(ZLIB_TESTZLIB_INSTALL)
install(
TARGETS zlib_testzlib
COMPONENT Runtime
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif(ZLIB_TESTZLIB_INSTALL)
endif(ZLIB_TESTZLIB_BUILD_SHARED)
if(ZLIB_TESTZLIB_BUILD_STATIC)
add_executable(zlib_testzlibStatic testzlib.c)
target_link_libraries(zlib_testzlibStatic PRIVATE ZLIB::ZLIBSTATIC)
set_target_properties(zlib_testzlibStatic
PROPERTIES
OUTPUT_NAME testzlibStatic)
if(ZLIB_TESTZLIB_INSTALL)
install(
TARGETS zlib_testzlibStatic
COMPONENT Runtime
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif(ZLIB_TESTZLIB_INSTALL)
endif(ZLIB_TESTZLIB_BUILD_STATIC)
|
Changes to compat/zlib/contrib/testzlib/testzlib.c.
| ︙ | ︙ | |||
14 15 16 17 18 19 20 |
{
R->LowPart = A.LowPart - B.LowPart;
R->HighPart --;
}
}
#ifdef _M_X64
| | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
{
R->LowPart = A.LowPart - B.LowPart;
R->HighPart --;
}
}
#ifdef _M_X64
// see https://learn.microsoft.com/en-us/cpp/intrinsics/rdtsc?view=msvc-170 for __rdtsc
unsigned __int64 __rdtsc(void);
void BeginCountRdtsc(LARGE_INTEGER * pbeginTime64)
{
// printf("rdtsc = %I64x\n",__rdtsc());
pbeginTime64->QuadPart=__rdtsc();
}
|
| ︙ | ︙ |
Changes to compat/zlib/contrib/testzlib/testzlib.txt.
| ︙ | ︙ |
Deleted compat/zlib/contrib/untgz/Makefile.
|
| < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/untgz/Makefile.msc.
|
| < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/untgz/untgz.c.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to compat/zlib/contrib/vstudio/readme.txt.
|
| < < | < < | < < < < | < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | < < < < | | < < | < < < < < | < < | | < < | < < | > < < < < > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | The pre-made Visual Studio projects have been removed in lieu of the ability to use cmake to build such projects on demand. To create a Visual Studio project --------------------------------- 1. Start cmake-gui. 2. Point source-dir to the source. 3. Point build-dir to the dir where you want to build. 4. Hit configure -- there you can select details. 5. Select the options you want, which are shown with descriptions after the configure run is complete. 6. Hit configure again to assure that everything that is needed is found. 7. For those not found, deactivate the option or install the dependency, e.g. bzip2 for minizip, and go back to step 6 until there is no red. 8. Hit generate. 9. Hit open project. Now you can Build > Build solution. See contrib/zlib1-dll/readme.txt for how to build the legacy zlib1.dll. |
Deleted compat/zlib/contrib/vstudio/vc10/miniunz.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc10/miniunz.vcxproj.filters.
|
| < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc10/minizip.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc10/minizip.vcxproj.filters.
|
| < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc10/testzlib.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc10/testzlib.vcxproj.filters.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj.filters.
|
| < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc10/zlib.rc.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc10/zlibstat.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc10/zlibstat.vcxproj.filters.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc10/zlibvc.def.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc10/zlibvc.sln.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc10/zlibvc.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc10/zlibvc.vcxproj.filters.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc11/miniunz.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc11/minizip.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc11/testzlib.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc11/testzlibdll.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc11/zlib.rc.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc11/zlibstat.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc11/zlibvc.def.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc11/zlibvc.sln.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc11/zlibvc.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc12/miniunz.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc12/minizip.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc12/testzlib.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc12/testzlibdll.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc12/zlib.rc.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc12/zlibstat.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc12/zlibvc.def.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc12/zlibvc.sln.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc12/zlibvc.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc14/miniunz.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc14/minizip.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc14/testzlib.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc14/testzlibdll.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc14/zlib.rc.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc14/zlibstat.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc14/zlibvc.def.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc14/zlibvc.sln.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc14/zlibvc.vcxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc9/miniunz.vcproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc9/minizip.vcproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc9/testzlib.vcproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc9/testzlibdll.vcproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc9/zlib.rc.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc9/zlibstat.vcproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc9/zlibvc.def.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc9/zlibvc.sln.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/contrib/vstudio/vc9/zlibvc.vcproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Added compat/zlib/contrib/zlib1-dll/CMakeLists.txt.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
zlib1-dll
LANGUAGES C
VERSION 1.3.2
HOMEPAGE_URL "https://zlib.net/"
DESCRIPTION "zlib1.dll is the legacy DLL with zlib and minizip")
# ============================================================================
# configuration
# ============================================================================
if(NOT WIN32)
message(FATAL_ERROR "This creates zlib1.<DLL>, Nothing else")
endif(NOT WIN32)
option(ENABLE_BZIP2 "Build with bzip2 support" OFF)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
include(CheckCSourceCompiles)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CMakePackageConfigHelpers)
include(CheckTypeSize)
include(CPack)
include(GNUInstallDirs)
if(NOT ZLIB_CONF_WRITTEN)
set(CONF_OUT_FILE ${zlib1-dll_BINARY_DIR}/zconf.h.cmakein)
file(READ ../../zconf.h ZCONF_CONTENT LIMIT 245)
file(WRITE ${CONF_OUT_FILE} ${ZCONF_CONTENT})
file(APPEND ${CONF_OUT_FILE} "#cmakedefine Z_PREFIX 1\n")
file(APPEND ${CONF_OUT_FILE} "#cmakedefine HAVE_STDARG_H 1\n")
file(APPEND ${CONF_OUT_FILE} "#cmakedefine HAVE_UNISTD_H 1\n")
file(READ ../../zconf.h ZCONF_CONTENT OFFSET 244)
set(FIRST_ITEM TRUE)
foreach(item IN LISTS ZCONF_CONTENT)
if(FIRST_ITEM)
string(APPEND OUT_CONTENT ${item})
set(FIRST_ITEM FALSE)
else(FIRST_ITEM)
string(APPEND OUT_CONTENT "\;" ${item})
endif(FIRST_ITEM)
endforeach(item IN LISTS ${ZCONF_CONTENT})
file(APPEND ${CONF_OUT_FILE} ${OUT_CONTENT})
set(ZLIB_CONF_WRITTEN
TRUE
CACHE BOOL "zconf.h.cmakein was created")
mark_as_advanced(ZLIB_CONF_WRITTEN)
endif(NOT ZLIB_CONF_WRITTEN)
if(ENABLE_BZIP2)
find_package(BZip2 REQUIRED)
endif(ENABLE_BZIP2)
#
# Check for fopen64
#
check_function_exists(fopen64 HAVE_FOPEN64)
#
# Check to see if we have large file support
#
set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
check_type_size(off64_t OFF64_T)
unset(CMAKE_REQUIRED_DEFINITIONS) # clear variable
#
# Check for fseeko
#
check_function_exists(fseeko HAVE_FSEEKO)
#
# Check for stdarg.h
#
check_include_file(stdarg.h HAVE_STDARG_H)
#
# Check for unistd.h
#
check_include_file(unistd.h HAVE_UNISTD_H)
#
# Check visibility attribute is supported
#
if(MSVC)
set(CMAKE_REQUIRED_FLAGS "-WX")
else(MSVC)
set(CMAKE_REQUIRED_FLAGS "-Werror")
endif(MSVC)
check_c_source_compiles(
"
#include <stdlib.h>
static void f(void) __attribute__ ((visibility(\"hidden\")));
int main(void) {return 0;}
"
HAVE___ATTR__VIS_HIDDEN)
unset(CMAKE_COMPILE_FLAGS)
configure_file(${zlib1-dll_BINARY_DIR}/zconf.h.cmakein ${zlib1-dll_BINARY_DIR}/zconf.h)
# ============================================================================
# zlib1-dll
# ============================================================================
set(ZLIB1-DLL_PUBLIC_HDRS
${zlib1-dll_BINARY_DIR}/zconf.h
../../zlib.h
../minizip/crypt.h
../minizip/ints.h
../minizip/ioapi.h
../minizip/mztools.h
../minizip/unzip.h
../minizip/zip.h)
set(ZLIB1-DLL_PRIVATE_HDRS
../../crc32.h
../../deflate.h
../../gzguts.h
../../inffast.h
../../inffixed.h
../../inflate.h
../../inftrees.h
../../trees.h
../../zutil.h)
set(ZLIB1-DLL_SRCS
../../adler32.c
../../compress.c
../../crc32.c
../../deflate.c
../../gzclose.c
../../gzlib.c
../../gzread.c
../../gzwrite.c
../../inflate.c
../../infback.c
../../inftrees.c
../../inffast.c
../../trees.c
../../uncompr.c
../../win32/zlib1.rc
../../zutil.c
../minizip/ioapi.c
../minizip/mztools.c
../minizip/unzip.c
../minizip/zip.c)
add_library(zlib1 SHARED ${ZLIB1-DLL_SRCS}
${ZLIB1-DLL_PUBLIC_HDRS}
${ZLIB1-DLL_PRIVATE_HDRS})
#taget_include_directories doesn't like relative paths
include_directories(../../
../minizip
${CMAKE_CURRENT_BINARY_DIR})
target_compile_definitions(zlib1
PRIVATE ZLIB_BUILD
$<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
$<$<BOOL:${HAVE_UNISTD_H}>:HAVE_UNISTD_H=1>
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
$<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>
$<$<BOOL:${BZIP2_FOUND}>:HAVE_BZIP2=1>
$<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
target_link_libraries(zlib1
PUBLIC $<$<BOOL:${BZIP2_FOUND}>:BZip2::BZip2>)
if(NOT CYGWIN)
set_target_properties(zlib1 PROPERTIES
SOVERSION ${zlib1-dll_VERSION_MAJOR}
VERSION ${zlib1-dll_VERSION})
endif(NOT CYGWIN)
set_target_properties(zlib1 PROPERTIES
DEFINE_SYMBOL ZLIB_DLL)
install(
TARGETS zlib1
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(
FILES ${ZLIB1-DLL_PUBLIC_HDRS}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(
FILES ../../LICENSE
DESTINATION "${CMAKE_INSTALL_DOCDIR}/zlib1-dll")
|
Added compat/zlib/contrib/zlib1-dll/readme.txt.
> > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | Use this directory to build the legacy zlib1.dll for Windows, which contains both zlib and minizip. Use cmake either at the command prompt, or with Visual Studio as outlined below. To create a Visual Studio project --------------------------------- 1. Start cmake-gui. 2. Point source-dir to the source. 3. Point build-dir to the dir where you want to build. 4. Hit configure -- there you can select details. 5. Select the options you want, which are shown with descriptions after the configure run is complete. 6. Hit configure again to assure that everything that is needed is found. 7. For those not found, deactivate the option or install the dependency, e.g. bzip2 for minizip, and go back to step 6 until there is no red. 8. Hit generate. 9. Hit open project. Now you can Build > Build solution. |
Changes to compat/zlib/crc32.c.
1 | /* crc32.c -- compute the CRC-32 of a data stream | | | 1 2 3 4 5 6 7 8 9 | /* crc32.c -- compute the CRC-32 of a data stream * Copyright (C) 1995-2026 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h * * This interleaved implementation of a CRC makes use of pipelined multiple * arithmetic-logic units, commonly found in modern CPU cores. It is due to * Kadatch and Jenkins (2010). See doc/crc-doc.1.0.pdf in this distribution. */ |
| ︙ | ︙ | |||
20 21 22 23 24 25 26 | produced, so that this one source file can be compiled to an executable. */ #ifdef MAKECRCH # include <stdio.h> # ifndef DYNAMIC_CRC_TABLE # define DYNAMIC_CRC_TABLE | > > | > | > > > > | 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 | produced, so that this one source file can be compiled to an executable. */ #ifdef MAKECRCH # include <stdio.h> # ifndef DYNAMIC_CRC_TABLE # define DYNAMIC_CRC_TABLE # endif #endif #ifdef DYNAMIC_CRC_TABLE # define Z_ONCE #endif #include "zutil.h" /* for Z_U4, Z_U8, z_crc_t, and FAR definitions */ #ifdef HAVE_S390X_VX # include "contrib/crc32vx/crc32_vx_hooks.h" #endif /* A CRC of a message is computed on N braids of words in the message, where each word consists of W bytes (4 or 8). If N is 3, for example, then three running sparse CRCs are calculated respectively on each braid, at these indices in the array of words: 0, 3, 6, ..., 1, 4, 7, ..., and 2, 5, 8, ... This is done starting at a word boundary, and continues until as many blocks |
| ︙ | ︙ | |||
95 96 97 98 99 100 101 |
typedef Z_U4 z_word_t;
# else
# undef W
# endif
#endif
/* If available, use the ARM processor CRC32 instruction. */
| | > | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
typedef Z_U4 z_word_t;
# else
# undef W
# endif
#endif
/* If available, use the ARM processor CRC32 instruction. */
#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) && \
defined(W) && W == 8
# define ARMCRC32
#endif
#if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE))
/*
Swap the bytes in a z_word_t to convert between little and big endian. Any
self-respecting compiler will optimize this to a single machine byte-swap
|
| ︙ | ︙ | |||
148 149 150 151 152 153 154 | /* CRC polynomial. */ #define POLY 0xedb88320 /* p(x) reflected, with x^32 implied */ /* Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial, reflected. For speed, this requires that a not be zero. */ | | | | | | | | | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
/* CRC polynomial. */
#define POLY 0xedb88320 /* p(x) reflected, with x^32 implied */
/*
Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial,
reflected. For speed, this requires that a not be zero.
*/
local uLong multmodp(uLong a, uLong b) {
uLong m, p;
m = (uLong)1 << 31;
p = 0;
for (;;) {
if (a & m) {
p ^= b;
if ((a & (m - 1)) == 0)
break;
}
m >>= 1;
b = b & 1 ? (b >> 1) ^ POLY : b >> 1;
}
return p;
}
/*
Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been
initialized. n must not be negative.
*/
local uLong x2nmodp(z_off64_t n, unsigned k) {
uLong p;
p = (uLong)1 << 31; /* x^0 == 1 */
while (n) {
if (n & 1)
p = multmodp(x2n_table[k & 31], p);
n >>= 1;
k++;
}
return p;
|
| ︙ | ︙ | |||
200 201 202 203 204 205 206 | #endif #ifdef MAKECRCH local void write_table(FILE *, const z_crc_t FAR *, int); local void write_table32hi(FILE *, const z_word_t FAR *, int); local void write_table64(FILE *, const z_word_t FAR *, int); #endif /* MAKECRCH */ | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | #endif #ifdef MAKECRCH local void write_table(FILE *, const z_crc_t FAR *, int); local void write_table32hi(FILE *, const z_word_t FAR *, int); local void write_table64(FILE *, const z_word_t FAR *, int); #endif /* MAKECRCH */ /* State for once(). */ local z_once_t made = Z_ONCE_INIT; /* Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. Polynomials over GF(2) are represented in binary, one bit per coefficient, with the lowest powers in the most significant bit. Then adding polynomials |
| ︙ | ︙ | |||
322 323 324 325 326 327 328 |
#endif
}
/* initialize the x^2^n mod p(x) table */
p = (z_crc_t)1 << 30; /* x^1 */
x2n_table[0] = p;
for (n = 1; n < 32; n++)
| | | 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
#endif
}
/* initialize the x^2^n mod p(x) table */
p = (z_crc_t)1 << 30; /* x^1 */
x2n_table[0] = p;
for (n = 1; n < 32; n++)
x2n_table[n] = p = (z_crc_t)multmodp(p, p);
#ifdef W
/* initialize the braiding tables -- needs x2n_table[] */
braid(crc_braid_table, crc_braid_big_table, N, W);
#endif
#ifdef MAKECRCH
|
| ︙ | ︙ | |||
525 526 527 528 529 530 531 |
Generate the little and big-endian braid tables for the given n and z_word_t
size w. Each array must have room for w blocks of 256 elements.
*/
local void braid(z_crc_t ltl[][256], z_word_t big[][256], int n, int w) {
int k;
z_crc_t i, p, q;
for (k = 0; k < w; k++) {
| | | | | 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
Generate the little and big-endian braid tables for the given n and z_word_t
size w. Each array must have room for w blocks of 256 elements.
*/
local void braid(z_crc_t ltl[][256], z_word_t big[][256], int n, int w) {
int k;
z_crc_t i, p, q;
for (k = 0; k < w; k++) {
p = (z_crc_t)x2nmodp((n * w + 3 - k) << 3, 0);
ltl[k][0] = 0;
big[w - 1 - k][0] = 0;
for (i = 1; i < 256; i++) {
ltl[k][i] = q = (z_crc_t)multmodp(i << 24, p);
big[w - 1 - k][i] = byte_swap(q);
}
}
}
#endif
#endif /* DYNAMIC_CRC_TABLE */
/* =========================================================================
* This function can be used by asm versions of crc32(), and to force the
* generation of the CRC tables in a threaded application.
*/
const z_crc_t FAR * ZEXPORT get_crc_table(void) {
#ifdef DYNAMIC_CRC_TABLE
z_once(&made, make_crc_table);
#endif /* DYNAMIC_CRC_TABLE */
return (const z_crc_t FAR *)crc_table;
}
/* =========================================================================
* Use ARM machine instructions if available. This will compute the CRC about
* ten times faster than the braided calculation. This code does not check for
|
| ︙ | ︙ | |||
568 569 570 571 572 573 574 | Constants empirically determined to maximize speed. These values are from measurements on a Cortex-A57. Your mileage may vary. */ #define Z_BATCH 3990 /* number of words in a batch */ #define Z_BATCH_ZEROS 0xa10d3d0c /* computed from Z_BATCH = 3990 */ #define Z_BATCH_MIN 800 /* fewest words in a final batch */ | | < | | | 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
Constants empirically determined to maximize speed. These values are from
measurements on a Cortex-A57. Your mileage may vary.
*/
#define Z_BATCH 3990 /* number of words in a batch */
#define Z_BATCH_ZEROS 0xa10d3d0c /* computed from Z_BATCH = 3990 */
#define Z_BATCH_MIN 800 /* fewest words in a final batch */
uLong ZEXPORT crc32_z(uLong crc, const unsigned char FAR *buf, z_size_t len) {
uLong val;
z_word_t crc1, crc2;
const z_word_t *word;
z_word_t val0, val1, val2;
z_size_t last, last2, i;
z_size_t num;
/* Return initial CRC, if requested. */
if (buf == Z_NULL) return 0;
#ifdef DYNAMIC_CRC_TABLE
z_once(&made, make_crc_table);
#endif /* DYNAMIC_CRC_TABLE */
/* Pre-condition the CRC */
crc = (~crc) & 0xffffffff;
/* Compute the CRC up to a word boundary. */
while (len && ((z_size_t)buf & 7) != 0) {
|
| ︙ | ︙ | |||
636 637 638 639 640 641 642 |
val2 = word[i + last2];
__asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc) : "r"(val0));
__asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc1) : "r"(val1));
__asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc2) : "r"(val2));
}
word += 3 * last;
num -= 3 * last;
| | | 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 |
val2 = word[i + last2];
__asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc) : "r"(val0));
__asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc1) : "r"(val1));
__asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc2) : "r"(val2));
}
word += 3 * last;
num -= 3 * last;
val = x2nmodp((int)last, 6);
crc = multmodp(val, crc) ^ crc1;
crc = multmodp(val, crc) ^ crc2;
}
/* Compute the CRC on any remaining words. */
for (i = 0; i < num; i++) {
val0 = word[i];
|
| ︙ | ︙ | |||
687 688 689 690 691 692 693 |
crc_big_table[(data >> ((W - 1) << 3)) & 0xff];
return data;
}
#endif
/* ========================================================================= */
| | < | | 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 |
crc_big_table[(data >> ((W - 1) << 3)) & 0xff];
return data;
}
#endif
/* ========================================================================= */
uLong ZEXPORT crc32_z(uLong crc, const unsigned char FAR *buf, z_size_t len) {
/* Return initial CRC, if requested. */
if (buf == Z_NULL) return 0;
#ifdef DYNAMIC_CRC_TABLE
z_once(&made, make_crc_table);
#endif /* DYNAMIC_CRC_TABLE */
/* Pre-condition the CRC */
crc = (~crc) & 0xffffffff;
#ifdef W
|
| ︙ | ︙ | |||
1008 1009 1010 1011 1012 1013 1014 |
/* Return the CRC, post-conditioned. */
return crc ^ 0xffffffff;
}
#endif
/* ========================================================================= */
| | > > | | < < < < < | < < | < < < < | > > | > > > > > > > > > > | 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 |
/* Return the CRC, post-conditioned. */
return crc ^ 0xffffffff;
}
#endif
/* ========================================================================= */
uLong ZEXPORT crc32(uLong crc, const unsigned char FAR *buf, uInt len) {
#ifdef HAVE_S390X_VX
return crc32_z_hook(crc, buf, len);
#endif
return crc32_z(crc, buf, len);
}
/* ========================================================================= */
uLong ZEXPORT crc32_combine_gen64(z_off64_t len2) {
if (len2 < 0)
return 0;
#ifdef DYNAMIC_CRC_TABLE
z_once(&made, make_crc_table);
#endif /* DYNAMIC_CRC_TABLE */
return x2nmodp(len2, 3);
}
/* ========================================================================= */
uLong ZEXPORT crc32_combine_gen(z_off_t len2) {
return crc32_combine_gen64((z_off64_t)len2);
}
/* ========================================================================= */
uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op) {
if (op == 0)
return 0;
return multmodp(op, crc1 & 0xffffffff) ^ (crc2 & 0xffffffff);
}
/* ========================================================================= */
uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2) {
return crc32_combine_op(crc1, crc2, crc32_combine_gen64(len2));
}
/* ========================================================================= */
uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2) {
return crc32_combine64(crc1, crc2, (z_off64_t)len2);
}
|
Changes to compat/zlib/deflate.c.
1 | /* deflate.c -- compress data using the deflation algorithm | | | 1 2 3 4 5 6 7 8 9 | /* deflate.c -- compress data using the deflation algorithm * Copyright (C) 1995-2026 Jean-loup Gailly and Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* * ALGORITHM * * The "deflation" process depends on being able to identify portions |
| ︙ | ︙ | |||
33 34 35 36 37 38 39 | * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and * I found it in 'freeze' written by Leonid Broukhis. * Thanks to many people for bug reports and testing. * * REFERENCES * * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". | | | | 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 | * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and * I found it in 'freeze' written by Leonid Broukhis. * Thanks to many people for bug reports and testing. * * REFERENCES * * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". * Available at https://datatracker.ietf.org/doc/html/rfc1951 * * A description of the Rabin and Karp algorithm is given in the book * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. * * Fiala,E.R., and Greene,D.H. * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 * */ /* @(#) $Id$ */ #include "deflate.h" const char deflate_copyright[] = " deflate 1.3.2 Copyright 1995-2026 Jean-loup Gailly and Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot include such an acknowledgment, I would appreciate that you keep this copyright string in the executable of your product. */ |
| ︙ | ︙ | |||
166 167 168 169 170 171 172 |
/* ===========================================================================
* Initialize the hash table (avoiding 64K overflow for 16 bit systems).
* prev[] will be initialized on the fly.
*/
#define CLEAR_HASH(s) \
do { \
s->head[s->hash_size - 1] = NIL; \
| < | > | 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
/* ===========================================================================
* Initialize the hash table (avoiding 64K overflow for 16 bit systems).
* prev[] will be initialized on the fly.
*/
#define CLEAR_HASH(s) \
do { \
s->head[s->hash_size - 1] = NIL; \
zmemzero(s->head, (unsigned)(s->hash_size - 1)*sizeof(*s->head)); \
s->slid = 0; \
} while (0)
/* ===========================================================================
* Slide the hash table when sliding the window down (could be avoided with 32
* bit values at the expense of memory usage). We slide even when level == 0 to
* keep the hash table consistent if we switch back to level > 0 later.
*/
|
| ︙ | ︙ | |||
191 192 193 194 195 196 197 |
n = s->hash_size;
p = &s->head[n];
do {
m = *--p;
*p = (Pos)(m >= wsize ? m - wsize : NIL);
} while (--n);
| < > > | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
n = s->hash_size;
p = &s->head[n];
do {
m = *--p;
*p = (Pos)(m >= wsize ? m - wsize : NIL);
} while (--n);
#ifndef FASTEST
n = wsize;
p = &s->prev[n];
do {
m = *--p;
*p = (Pos)(m >= wsize ? m - wsize : NIL);
/* If n is not on any hash chain, prev[n] is garbage but
* its value will never be used.
*/
} while (--n);
#endif
s->slid = 1;
}
/* ===========================================================================
* Read a new buffer from the current input stream, update the adler32
* and total number of bytes read. All deflate() input goes through
* this function so some applications may wish to modify it to avoid
* allocating a large strm->next_in buffer and copying from it.
|
| ︙ | ︙ | |||
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
do {
more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
/* Deal with !@#$% 64K limit: */
if (sizeof(int) <= 2) {
if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
more = wsize;
} else if (more == (unsigned)(-1)) {
/* Very unlikely, but possible on 16 bit machine if
* strstart == 0 && lookahead == 1 (input done a byte at time)
*/
| > > > > > > > | 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
do {
more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
/* Deal with !@#$% 64K limit: */
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4127)
#endif
if (sizeof(int) <= 2) {
#ifdef _MSC_VER
#pragma warning(pop)
#endif
if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
more = wsize;
} else if (more == (unsigned)(-1)) {
/* Very unlikely, but possible on 16 bit machine if
* strstart == 0 && lookahead == 1 (input done a byte at time)
*/
|
| ︙ | ︙ | |||
427 428 429 430 431 432 433 434 435 436 437 438 439 440 |
windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
strategy < 0 || strategy > Z_FIXED || (windowBits == 8 && wrap != 1)) {
return Z_STREAM_ERROR;
}
if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */
s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
if (s == Z_NULL) return Z_MEM_ERROR;
strm->state = (struct internal_state FAR *)s;
s->strm = strm;
s->status = INIT_STATE; /* to pass state test in deflateReset() */
s->wrap = wrap;
s->gzhead = Z_NULL;
s->w_bits = (uInt)windowBits;
| > | 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 |
windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
strategy < 0 || strategy > Z_FIXED || (windowBits == 8 && wrap != 1)) {
return Z_STREAM_ERROR;
}
if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */
s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
if (s == Z_NULL) return Z_MEM_ERROR;
zmemzero(s, sizeof(deflate_state));
strm->state = (struct internal_state FAR *)s;
s->strm = strm;
s->status = INIT_STATE; /* to pass state test in deflateReset() */
s->wrap = wrap;
s->gzhead = Z_NULL;
s->w_bits = (uInt)windowBits;
|
| ︙ | ︙ | |||
708 709 710 711 712 713 714 |
strm->state->gzhead = head;
return Z_OK;
}
/* ========================================================================= */
int ZEXPORT deflatePending(z_streamp strm, unsigned *pending, int *bits) {
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
| > > | > | > > > > > > > > > > | | 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 |
strm->state->gzhead = head;
return Z_OK;
}
/* ========================================================================= */
int ZEXPORT deflatePending(z_streamp strm, unsigned *pending, int *bits) {
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
if (bits != Z_NULL)
*bits = strm->state->bi_valid;
if (pending != Z_NULL) {
*pending = (unsigned)strm->state->pending;
if (*pending != strm->state->pending) {
*pending = (unsigned)-1;
return Z_BUF_ERROR;
}
}
return Z_OK;
}
/* ========================================================================= */
int ZEXPORT deflateUsed(z_streamp strm, int *bits) {
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
if (bits != Z_NULL)
*bits = strm->state->bi_used;
return Z_OK;
}
/* ========================================================================= */
int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) {
deflate_state *s;
int put;
|
| ︙ | ︙ | |||
827 828 829 830 831 832 833 | * a stored block from being emitted. Then the only choice is a fixed or * dynamic block, where a fixed block limits the maximum expansion to 9 bits * per 8-bit byte, plus 10 bits for every block. The smallest block size for * which this can occur is 255 (memLevel == 2). * * Shifts are used to approximate divisions, for speed. */ | | | > > > > | | | > > | | 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 |
* a stored block from being emitted. Then the only choice is a fixed or
* dynamic block, where a fixed block limits the maximum expansion to 9 bits
* per 8-bit byte, plus 10 bits for every block. The smallest block size for
* which this can occur is 255 (memLevel == 2).
*
* Shifts are used to approximate divisions, for speed.
*/
z_size_t ZEXPORT deflateBound_z(z_streamp strm, z_size_t sourceLen) {
deflate_state *s;
z_size_t fixedlen, storelen, wraplen, bound;
/* upper bound for fixed blocks with 9-bit literals and length 255
(memLevel == 2, which is the lowest that may not use stored blocks) --
~13% overhead plus a small constant */
fixedlen = sourceLen + (sourceLen >> 3) + (sourceLen >> 8) +
(sourceLen >> 9) + 4;
if (fixedlen < sourceLen)
fixedlen = (z_size_t)-1;
/* upper bound for stored blocks with length 127 (memLevel == 1) --
~4% overhead plus a small constant */
storelen = sourceLen + (sourceLen >> 5) + (sourceLen >> 7) +
(sourceLen >> 11) + 7;
if (storelen < sourceLen)
storelen = (z_size_t)-1;
/* if can't get parameters, return larger bound plus a wrapper */
if (deflateStateCheck(strm)) {
bound = fixedlen > storelen ? fixedlen : storelen;
return bound + 18 < bound ? (z_size_t)-1 : bound + 18;
}
/* compute wrapper length */
s = strm->state;
switch (s->wrap < 0 ? -s->wrap : s->wrap) {
case 0: /* raw deflate */
wraplen = 0;
break;
case 1: /* zlib wrapper */
wraplen = 6 + (s->strstart ? 4 : 0);
break;
#ifdef GZIP
|
| ︙ | ︙ | |||
878 879 880 881 882 883 884 |
} while (*str++);
if (s->gzhead->hcrc)
wraplen += 2;
}
break;
#endif
default: /* for compiler happiness */
| | | | | > > | | > > > > > | 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 |
} while (*str++);
if (s->gzhead->hcrc)
wraplen += 2;
}
break;
#endif
default: /* for compiler happiness */
wraplen = 18;
}
/* if not default parameters, return one of the conservative bounds */
if (s->w_bits != 15 || s->hash_bits != 8 + 7) {
bound = s->w_bits <= s->hash_bits && s->level ? fixedlen :
storelen;
return bound + wraplen < bound ? (z_size_t)-1 : bound + wraplen;
}
/* default settings: return tight bound for that case -- ~0.03% overhead
plus a small constant */
bound = sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
(sourceLen >> 25) + 13 - 6 + wraplen;
return bound < sourceLen ? (z_size_t)-1 : bound;
}
uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) {
z_size_t bound = deflateBound_z(strm, sourceLen);
return (uLong)bound != bound ? (uLong)-1 : (uLong)bound;
}
/* =========================================================================
* Put a short in the pending buffer. The 16-bit value is put in MSB order.
* IN assertion: the stream state is correct and there is enough room in
* pending_buf.
*/
|
| ︙ | ︙ | |||
913 914 915 916 917 918 919 |
* strm->next_out buffer and copying into it. (See also read_buf()).
*/
local void flush_pending(z_streamp strm) {
unsigned len;
deflate_state *s = strm->state;
_tr_flush_bits(s);
| | | | | | 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 |
* strm->next_out buffer and copying into it. (See also read_buf()).
*/
local void flush_pending(z_streamp strm) {
unsigned len;
deflate_state *s = strm->state;
_tr_flush_bits(s);
len = s->pending > strm->avail_out ? strm->avail_out :
(unsigned)s->pending;
if (len == 0) return;
zmemcpy(strm->next_out, s->pending_out, len);
strm->next_out += len;
s->pending_out += len;
strm->total_out += len;
strm->avail_out -= len;
s->pending -= len;
if (s->pending == 0) {
s->pending_out = s->pending_buf;
}
}
/* ===========================================================================
* Update the header CRC with the bytes s->pending_buf[beg..s->pending - 1].
*/
#define HCRC_UPDATE(beg) \
do { \
if (s->gzhead->hcrc && s->pending > (beg)) \
strm->adler = crc32_z(strm->adler, s->pending_buf + (beg), \
s->pending - (beg)); \
} while (0)
/* ========================================================================= */
int ZEXPORT deflate(z_streamp strm, int flush) {
int old_flush; /* value of flush param for previous deflate call */
deflate_state *s;
|
| ︙ | ︙ | |||
1069 1070 1071 1072 1073 1074 1075 |
4 : 0));
put_byte(s, s->gzhead->os & 0xff);
if (s->gzhead->extra != Z_NULL) {
put_byte(s, s->gzhead->extra_len & 0xff);
put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
}
if (s->gzhead->hcrc)
| | | | | | 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 |
4 : 0));
put_byte(s, s->gzhead->os & 0xff);
if (s->gzhead->extra != Z_NULL) {
put_byte(s, s->gzhead->extra_len & 0xff);
put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
}
if (s->gzhead->hcrc)
strm->adler = crc32_z(strm->adler, s->pending_buf,
s->pending);
s->gzindex = 0;
s->status = EXTRA_STATE;
}
}
if (s->status == EXTRA_STATE) {
if (s->gzhead->extra != Z_NULL) {
ulg beg = s->pending; /* start of bytes to update crc */
ulg left = (s->gzhead->extra_len & 0xffff) - s->gzindex;
while (s->pending + left > s->pending_buf_size) {
ulg copy = s->pending_buf_size - s->pending;
zmemcpy(s->pending_buf + s->pending,
s->gzhead->extra + s->gzindex, copy);
s->pending = s->pending_buf_size;
HCRC_UPDATE(beg);
s->gzindex += copy;
flush_pending(strm);
if (s->pending != 0) {
|
| ︙ | ︙ | |||
1291 1292 1293 1294 1295 1296 1297 |
if (deflateStateCheck(source) || dest == Z_NULL) {
return Z_STREAM_ERROR;
}
ss = source->state;
| | > | | | | > | | > > > > | 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 |
if (deflateStateCheck(source) || dest == Z_NULL) {
return Z_STREAM_ERROR;
}
ss = source->state;
zmemcpy(dest, source, sizeof(z_stream));
ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
if (ds == Z_NULL) return Z_MEM_ERROR;
zmemzero(ds, sizeof(deflate_state));
dest->state = (struct internal_state FAR *) ds;
zmemcpy(ds, ss, sizeof(deflate_state));
ds->strm = dest;
ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, LIT_BUFS);
if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
ds->pending_buf == Z_NULL) {
deflateEnd (dest);
return Z_MEM_ERROR;
}
/* following zmemcpy's do not work for 16-bit MSDOS */
zmemcpy(ds->window, ss->window, ss->high_water);
zmemcpy(ds->prev, ss->prev,
(ss->slid || ss->strstart - ss->insert > ds->w_size ? ds->w_size :
ss->strstart - ss->insert) * sizeof(Pos));
zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos));
ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
zmemcpy(ds->pending_out, ss->pending_out, ss->pending);
#ifdef LIT_MEM
ds->d_buf = (ushf *)(ds->pending_buf + (ds->lit_bufsize << 1));
ds->l_buf = ds->pending_buf + (ds->lit_bufsize << 2);
zmemcpy(ds->d_buf, ss->d_buf, ss->sym_next * sizeof(ush));
zmemcpy(ds->l_buf, ss->l_buf, ss->sym_next);
#else
ds->sym_buf = ds->pending_buf + ds->lit_bufsize;
zmemcpy(ds->sym_buf, ss->sym_buf, ss->sym_next);
#endif
ds->l_desc.dyn_tree = ds->dyn_ltree;
ds->d_desc.dyn_tree = ds->dyn_dtree;
ds->bl_desc.dyn_tree = ds->bl_tree;
return Z_OK;
|
| ︙ | ︙ | |||
1343 1344 1345 1346 1347 1348 1349 |
* garbage.
* IN assertions: cur_match is the head of the hash chain for the current
* string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
* OUT assertion: the match length is not greater than s->lookahead.
*/
local uInt longest_match(deflate_state *s, IPos cur_match) {
unsigned chain_length = s->max_chain_length;/* max hash chain length */
| | | | | | | | | | | 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 |
* garbage.
* IN assertions: cur_match is the head of the hash chain for the current
* string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
* OUT assertion: the match length is not greater than s->lookahead.
*/
local uInt longest_match(deflate_state *s, IPos cur_match) {
unsigned chain_length = s->max_chain_length;/* max hash chain length */
Bytef *scan = s->window + s->strstart; /* current string */
Bytef *match; /* matched string */
int len; /* length of current match */
int best_len = (int)s->prev_length; /* best match length so far */
int nice_match = s->nice_match; /* stop if match long enough */
IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
s->strstart - (IPos)MAX_DIST(s) : NIL;
/* Stop when cur_match becomes <= limit. To simplify the code,
* we prevent matches with the string of window index 0.
*/
Posf *prev = s->prev;
uInt wmask = s->w_mask;
#ifdef UNALIGNED_OK
/* Compare two bytes at a time. Note: this is not always beneficial.
* Try with and without -DUNALIGNED_OK to check.
*/
Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
ush scan_start = *(ushf*)scan;
ush scan_end = *(ushf*)(scan + best_len - 1);
#else
Bytef *strend = s->window + s->strstart + MAX_MATCH;
Byte scan_end1 = scan[best_len - 1];
Byte scan_end = scan[best_len];
#endif
/* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
* It is easy to get rid of this optimization if necessary.
*/
Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
|
| ︙ | ︙ | |||
1490 1491 1492 1493 1494 1495 1496 |
#else /* FASTEST */
/* ---------------------------------------------------------------------------
* Optimized version for FASTEST only
*/
local uInt longest_match(deflate_state *s, IPos cur_match) {
| | | | | | 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 |
#else /* FASTEST */
/* ---------------------------------------------------------------------------
* Optimized version for FASTEST only
*/
local uInt longest_match(deflate_state *s, IPos cur_match) {
Bytef *scan = s->window + s->strstart; /* current string */
Bytef *match; /* matched string */
int len; /* length of current match */
Bytef *strend = s->window + s->strstart + MAX_MATCH;
/* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
* It is easy to get rid of this optimization if necessary.
*/
Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
|
| ︙ | ︙ | |||
1553 1554 1555 1556 1557 1558 1559 |
/* ===========================================================================
* Check that the match at match_start is indeed a match.
*/
local void check_match(deflate_state *s, IPos start, IPos match, int length) {
/* check that the match is indeed a match */
Bytef *back = s->window + (int)match, *here = s->window + start;
| | | 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 |
/* ===========================================================================
* Check that the match at match_start is indeed a match.
*/
local void check_match(deflate_state *s, IPos start, IPos match, int length) {
/* check that the match is indeed a match */
Bytef *back = s->window + (int)match, *here = s->window + start;
IPos len = (IPos)length;
if (match == (IPos)-1) {
/* match starts one byte before the current window -- just compare the
subsequent length-1 bytes */
back++;
here++;
len--;
}
|
| ︙ | ︙ | |||
1625 1626 1627 1628 1629 1630 1631 |
* maximizes the opportunities to have a single copy from next_in to next_out.
*/
local block_state deflate_stored(deflate_state *s, int flush) {
/* Smallest worthy block size when not flushing or finishing. By default
* this is 32K. This can be as small as 507 bytes for memLevel == 1. For
* large input and output buffers, the stored block size will be larger.
*/
| | > | | | | 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 |
* maximizes the opportunities to have a single copy from next_in to next_out.
*/
local block_state deflate_stored(deflate_state *s, int flush) {
/* Smallest worthy block size when not flushing or finishing. By default
* this is 32K. This can be as small as 507 bytes for memLevel == 1. For
* large input and output buffers, the stored block size will be larger.
*/
unsigned min_block = (unsigned)(MIN(s->pending_buf_size - 5, s->w_size));
/* Copy as many min_block or larger stored blocks directly to next_out as
* possible. If flushing, copy the remaining available input to next_out as
* stored blocks, if there is enough space.
*/
int last = 0;
unsigned len, left, have;
unsigned used = s->strm->avail_in;
do {
/* Set len to the maximum size block that we can copy directly with the
* available input data and output space. Set left to how much of that
* would be copied from what's left in the window.
*/
len = MAX_STORED; /* maximum deflate stored block length */
have = ((unsigned)s->bi_valid + 42) >> 3; /* bytes in header */
if (s->strm->avail_out < have) /* need room for header */
break;
/* maximum stored block length that will fit in avail_out: */
have = s->strm->avail_out - have;
left = (unsigned)(s->strstart - s->block_start); /* window bytes */
if (len > (ulg)left + s->strm->avail_in)
len = left + s->strm->avail_in; /* limit len to the input */
if (len > have)
len = have; /* limit len to the output */
/* If the stored block would be less than min_block in length, or if
* unable to copy all of the available input when flushing, then try
|
| ︙ | ︙ | |||
1667 1668 1669 1670 1671 1672 1673 |
/* Make a dummy stored block in pending to get the header bytes,
* including any pending bits. This also updates the debugging counts.
*/
last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0;
_tr_stored_block(s, (char *)0, 0L, last);
/* Replace the lengths in the dummy stored block with len. */
| | | | | | 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 |
/* Make a dummy stored block in pending to get the header bytes,
* including any pending bits. This also updates the debugging counts.
*/
last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0;
_tr_stored_block(s, (char *)0, 0L, last);
/* Replace the lengths in the dummy stored block with len. */
s->pending_buf[s->pending - 4] = (Bytef)len;
s->pending_buf[s->pending - 3] = (Bytef)(len >> 8);
s->pending_buf[s->pending - 2] = (Bytef)~len;
s->pending_buf[s->pending - 1] = (Bytef)(~len >> 8);
/* Write the stored block header bytes. */
flush_pending(s->strm);
#ifdef ZLIB_DEBUG
/* Update debugging counts for the data about to be copied. */
s->compressed_len += len << 3;
|
| ︙ | ︙ | |||
1741 1742 1743 1744 1745 1746 1747 |
}
s->block_start = s->strstart;
}
if (s->high_water < s->strstart)
s->high_water = s->strstart;
/* If the last block was written to next_out, then done. */
| | > > | | 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 |
}
s->block_start = s->strstart;
}
if (s->high_water < s->strstart)
s->high_water = s->strstart;
/* If the last block was written to next_out, then done. */
if (last) {
s->bi_used = 8;
return finish_done;
}
/* If flushing and all input has been consumed, then done. */
if (flush != Z_NO_FLUSH && flush != Z_FINISH &&
s->strm->avail_in == 0 && (long)s->strstart == s->block_start)
return block_done;
/* Fill the window with any remaining input. */
have = (unsigned)(s->window_size - s->strstart);
if (s->strm->avail_in > have && s->block_start >= (long)s->w_size) {
/* Slide the window down. */
s->block_start -= s->w_size;
s->strstart -= s->w_size;
zmemcpy(s->window, s->window + s->w_size, s->strstart);
if (s->matches < 2)
s->matches++; /* add a pending slide_hash() */
|
| ︙ | ︙ | |||
1777 1778 1779 1780 1781 1782 1783 |
s->high_water = s->strstart;
/* There was not enough avail_out to write a complete worthy or flushed
* stored block to next_out. Write a stored block to pending instead, if we
* have enough input for a worthy block, or if flushing and there is enough
* room for the remaining input as a stored block in the pending buffer.
*/
| | | | > > | 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 |
s->high_water = s->strstart;
/* There was not enough avail_out to write a complete worthy or flushed
* stored block to next_out. Write a stored block to pending instead, if we
* have enough input for a worthy block, or if flushing and there is enough
* room for the remaining input as a stored block in the pending buffer.
*/
have = ((unsigned)s->bi_valid + 42) >> 3; /* bytes in header */
/* maximum stored block length that will fit in pending: */
have = (unsigned)MIN(s->pending_buf_size - have, MAX_STORED);
min_block = MIN(have, s->w_size);
left = (unsigned)(s->strstart - s->block_start);
if (left >= min_block ||
((left || flush == Z_FINISH) && flush != Z_NO_FLUSH &&
s->strm->avail_in == 0 && left <= have)) {
len = MIN(left, have);
last = flush == Z_FINISH && s->strm->avail_in == 0 &&
len == left ? 1 : 0;
_tr_stored_block(s, (charf *)s->window + s->block_start, len, last);
s->block_start += len;
flush_pending(s->strm);
}
/* We've done all we can with the available input and output. */
if (last)
s->bi_used = 8;
return last ? finish_started : need_more;
}
/* ===========================================================================
* Compress as much as possible from the input stream, return the current
* block state.
* This function does not perform lazy evaluation of matches and inserts
|
| ︙ | ︙ | |||
1842 1843 1844 1845 1846 1847 1848 |
* of window index 0 (in particular we have to avoid a match
* of the string with itself at the start of the input file).
*/
s->match_length = longest_match (s, hash_head);
/* longest_match() sets match_start */
}
if (s->match_length >= MIN_MATCH) {
| | | 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 |
* of window index 0 (in particular we have to avoid a match
* of the string with itself at the start of the input file).
*/
s->match_length = longest_match (s, hash_head);
/* longest_match() sets match_start */
}
if (s->match_length >= MIN_MATCH) {
check_match(s, s->strstart, s->match_start, (int)s->match_length);
_tr_tally_dist(s, s->strstart - s->match_start,
s->match_length - MIN_MATCH, bflush);
s->lookahead -= s->match_length;
/* Insert new strings in the hash table only if the match length
|
| ︙ | ︙ | |||
1964 1965 1966 1967 1968 1969 1970 |
/* If there was a match at the previous step and the current
* match is not better, output the previous match:
*/
if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
/* Do not insert strings in hash table beyond this. */
| | | 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 |
/* If there was a match at the previous step and the current
* match is not better, output the previous match:
*/
if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
/* Do not insert strings in hash table beyond this. */
check_match(s, s->strstart - 1, s->prev_match, (int)s->prev_length);
_tr_tally_dist(s, s->strstart - 1 - s->prev_match,
s->prev_length - MIN_MATCH, bflush);
/* Insert in hash table all strings up to the end of the match.
* strstart - 1 and strstart are already inserted. If there is not
* enough lookahead, the last two strings are not inserted in
|
| ︙ | ︙ | |||
2072 2073 2074 2075 2076 2077 2078 |
}
Assert(scan <= s->window + (uInt)(s->window_size - 1),
"wild scan");
}
/* Emit match if have run of MIN_MATCH or longer, else emit literal */
if (s->match_length >= MIN_MATCH) {
| | | 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 |
}
Assert(scan <= s->window + (uInt)(s->window_size - 1),
"wild scan");
}
/* Emit match if have run of MIN_MATCH or longer, else emit literal */
if (s->match_length >= MIN_MATCH) {
check_match(s, s->strstart, s->strstart - 1, (int)s->match_length);
_tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush);
s->lookahead -= s->match_length;
s->strstart += s->match_length;
s->match_length = 0;
} else {
|
| ︙ | ︙ |
Changes to compat/zlib/deflate.h.
1 | /* deflate.h -- internal compression state | | | 1 2 3 4 5 6 7 8 9 | /* deflate.h -- internal compression state * Copyright (C) 1995-2026 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ |
| ︙ | ︙ | |||
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
/* Output buffer. bits are inserted starting at the bottom (least
* significant bits).
*/
int bi_valid;
/* Number of valid bits in bi_buf. All bits above the last valid bit
* are always zero.
*/
ulg high_water;
/* High water mark offset in window for initialized bytes -- bytes above
* this are set to zero in order to avoid memory check warnings when
* longest match routines access bytes past the input. This is then
* updated to the new high water mark.
*/
} FAR deflate_state;
/* Output a byte on the stream.
* IN assertion: there is enough room in pending_buf.
*/
#define put_byte(s, c) {s->pending_buf[s->pending++] = (Bytef)(c);}
| > > > > > > | 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
/* Output buffer. bits are inserted starting at the bottom (least
* significant bits).
*/
int bi_valid;
/* Number of valid bits in bi_buf. All bits above the last valid bit
* are always zero.
*/
int bi_used;
/* Last number of used bits when going to a byte boundary.
*/
ulg high_water;
/* High water mark offset in window for initialized bytes -- bytes above
* this are set to zero in order to avoid memory check warnings when
* longest match routines access bytes past the input. This is then
* updated to the new high water mark.
*/
int slid;
/* True if the hash table has been slid since it was cleared. */
} FAR deflate_state;
/* Output a byte on the stream.
* IN assertion: there is enough room in pending_buf.
*/
#define put_byte(s, c) {s->pending_buf[s->pending++] = (Bytef)(c);}
|
| ︙ | ︙ |
Changes to compat/zlib/examples/enough.c.
1 2 | /* enough.c -- determine the maximum size of inflate's Huffman code tables over * all possible valid and complete prefix codes, subject to a length limit. | | | > | 1 2 3 4 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 |
/* enough.c -- determine the maximum size of inflate's Huffman code tables over
* all possible valid and complete prefix codes, subject to a length limit.
* Copyright (C) 2007, 2008, 2012, 2018, 2024 Mark Adler
* Version 1.6 29 July 2024 Mark Adler
*/
/* Version history:
1.0 3 Jan 2007 First version (derived from codecount.c version 1.4)
1.1 4 Jan 2007 Use faster incremental table usage computation
Prune examine() search on previously visited states
1.2 5 Jan 2007 Comments clean up
As inflate does, decrease root for short codes
Refuse cases where inflate would increase root
1.3 17 Feb 2008 Add argument for initial root table size
Fix bug for initial root table size == max - 1
Use a macro to compute the history index
1.4 18 Aug 2012 Avoid shifts more than bits in type (caused endless loop!)
Clean up comparisons of different types
Clean up code indentation
1.5 5 Aug 2018 Clean up code style, formatting, and comments
Show all the codes for the maximum, and only the maximum
1.6 29 Jul 2024 Avoid use of uintmax_t
*/
/*
Examine all possible prefix codes for a given number of symbols and a
maximum code length in bits to determine the maximum table size for zlib's
inflate. Only complete prefix codes are counted.
|
| ︙ | ︙ | |||
84 85 86 87 88 89 90 | identifying the reachable nodes, accounts for about six of the orders of magnitude of improvement for the default arguments. About another four orders of magnitude come from not revisiting previous states. Out of approximately 2x10^16 possible prefix codes, only about 2x10^6 sub-codes need to be examined to cover all of the possible table memory usage cases for the default arguments of 286 symbols limited to 15-bit codes. | | | | | | | < | | | | 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
identifying the reachable nodes, accounts for about six of the orders of
magnitude of improvement for the default arguments. About another four
orders of magnitude come from not revisiting previous states. Out of
approximately 2x10^16 possible prefix codes, only about 2x10^6 sub-codes
need to be examined to cover all of the possible table memory usage cases
for the default arguments of 286 symbols limited to 15-bit codes.
Note that unsigned long long is used for counting. It is quite easy to
exceed the capacity of an eight-byte integer with a large number of symbols
and a large maximum code length, so multiple-precision arithmetic would need
to replace the integer arithmetic in that case. This program will abort if
an overflow occurs. The big_t type identifies where the counting takes
place.
The unsigned long long type is also used for calculating the number of
possible codes remaining at the maximum length. This limits the maximum code
length to the number of bits in a long long minus the number of bits needed
to represent the symbols in a flat code. The code_t type identifies where
the bit-pattern counting takes place.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <assert.h>
#define local static
// Special data types.
typedef unsigned long long big_t; // type for code counting
#define PRIbig "llu" // printf format for big_t
typedef big_t code_t; // type for bit pattern counting
struct tab { // type for been-here check
size_t len; // allocated length of bit vector in octets
char *vec; // allocated bit vector
};
/* The array for saving results, num[], is indexed with this triplet:
|
| ︙ | ︙ |
Changes to compat/zlib/examples/gun.c.
| ︙ | ︙ | |||
223 224 225 226 227 228 229 |
outd.check = 0;
/* process remainder of compress header -- a flags byte */
flags = NEXT();
if (last == -1)
return Z_BUF_ERROR;
if (flags & 0x60) {
| | | | | 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
outd.check = 0;
/* process remainder of compress header -- a flags byte */
flags = NEXT();
if (last == -1)
return Z_BUF_ERROR;
if (flags & 0x60) {
strm->msg = (z_const char *)"unknown lzw flags set";
return Z_DATA_ERROR;
}
max = flags & 0x1f;
if (max < 9 || max > 16) {
strm->msg = (z_const char *)"lzw bits out of range";
return Z_DATA_ERROR;
}
if (max == 9) /* 9 doesn't really mean 9 */
max = 10;
flags &= 0x80; /* true if block compress */
/* clear table */
bits = 9;
mask = 0x1ff;
end = flags ? 256 : 255;
/* set up: get first 9-bit code, which is the first decompressed byte, but
don't create a table entry until the next code */
if (NEXT() == -1) /* no compressed data is ok */
return Z_OK;
final = prev = (unsigned)last; /* low 8 bits of code */
if (NEXT() == -1) /* missing a bit */
return Z_BUF_ERROR;
if (last & 1) { /* code must be < 256 */
strm->msg = (z_const char *)"invalid lzw code";
return Z_DATA_ERROR;
}
rem = (unsigned)last >> 1; /* remaining 7 bits */
left = 7;
chunk = bits - 2; /* 7 bytes left in this chunk */
outbuf[0] = (unsigned char)final; /* write first decompressed byte */
outcnt = 1;
|
| ︙ | ︙ | |||
315 316 317 318 319 320 321 |
input does not cause an exception. The code != end + 1 check is
empirically derived, and not checked in the original uncompress
code. If this ever causes a problem, that check could be safely
removed. Leaving this check in greatly improves gun's ability
to detect random or corrupted input after a compress header.
In any case, the prev > end check must be retained. */
if (code != end + 1 || prev > end) {
| | | 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
input does not cause an exception. The code != end + 1 check is
empirically derived, and not checked in the original uncompress
code. If this ever causes a problem, that check could be safely
removed. Leaving this check in greatly improves gun's ability
to detect random or corrupted input after a compress header.
In any case, the prev > end check must be retained. */
if (code != end + 1 || prev > end) {
strm->msg = (z_const char *)"invalid lzw code";
return Z_DATA_ERROR;
}
match[stack++] = (unsigned char)final;
code = prev;
}
/* walk through linked list to generate output in reverse order */
|
| ︙ | ︙ | |||
400 401 402 403 404 405 406 |
for (;;) {
/* look for the two magic header bytes for a gzip stream */
if (NEXT() == -1) {
ret = Z_OK;
break; /* empty gzip stream is ok */
}
if (last != 31 || (NEXT() != 139 && last != 157)) {
| | | | | 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 |
for (;;) {
/* look for the two magic header bytes for a gzip stream */
if (NEXT() == -1) {
ret = Z_OK;
break; /* empty gzip stream is ok */
}
if (last != 31 || (NEXT() != 139 && last != 157)) {
strm->msg = (z_const char *)"incorrect header check";
ret = first ? Z_DATA_ERROR : Z_ERRNO;
break; /* not a gzip or compress header */
}
first = 0; /* next non-header is junk */
/* process a compress (LZW) file -- can't be concatenated after this */
if (last == 157) {
ret = lunpipe(have, next, indp, outfile, strm);
break;
}
/* process remainder of gzip header */
ret = Z_BUF_ERROR;
if (NEXT() != 8) { /* only deflate method allowed */
if (last == -1) break;
strm->msg = (z_const char *)"unknown compression method";
ret = Z_DATA_ERROR;
break;
}
flags = NEXT(); /* header flags */
NEXT(); /* discard mod time, xflgs, os */
NEXT();
NEXT();
NEXT();
NEXT();
NEXT();
if (last == -1) break;
if (flags & 0xe0) {
strm->msg = (z_const char *)"unknown header flags set";
ret = Z_DATA_ERROR;
break;
}
if (flags & 4) { /* extra field */
len = NEXT();
len += (unsigned)(NEXT()) << 8;
if (last == -1) break;
|
| ︙ | ︙ | |||
482 483 484 485 486 487 488 |
ret = Z_BUF_ERROR;
if (NEXT() != (int)(outd.crc & 0xff) ||
NEXT() != (int)((outd.crc >> 8) & 0xff) ||
NEXT() != (int)((outd.crc >> 16) & 0xff) ||
NEXT() != (int)((outd.crc >> 24) & 0xff)) {
/* crc error */
if (last != -1) {
| | | | 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
ret = Z_BUF_ERROR;
if (NEXT() != (int)(outd.crc & 0xff) ||
NEXT() != (int)((outd.crc >> 8) & 0xff) ||
NEXT() != (int)((outd.crc >> 16) & 0xff) ||
NEXT() != (int)((outd.crc >> 24) & 0xff)) {
/* crc error */
if (last != -1) {
strm->msg = (z_const char *)"incorrect data check";
ret = Z_DATA_ERROR;
}
break;
}
if (NEXT() != (int)(outd.total & 0xff) ||
NEXT() != (int)((outd.total >> 8) & 0xff) ||
NEXT() != (int)((outd.total >> 16) & 0xff) ||
NEXT() != (int)((outd.total >> 24) & 0xff)) {
/* length error */
if (last != -1) {
strm->msg = (z_const char *)"incorrect length check";
ret = Z_DATA_ERROR;
}
break;
}
/* go back and look for another gzip stream */
}
|
| ︙ | ︙ |
Changes to compat/zlib/examples/gznorm.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
/* gznorm.c -- normalize a gzip stream
* Copyright (C) 2018 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
* Version 1.0 7 Oct 2018 Mark Adler */
// gznorm takes a gzip stream, potentially containing multiple members, and
// converts it to a gzip stream with a single member. In addition the gzip
// header is normalized, removing the file name and time stamp, and setting the
// other header contents (XFL, OS) to fixed values. gznorm does not recompress
// the data, so it is fast, but no advantage is gained from the history that
// could be available across member boundaries.
#include <stdio.h> // fread, fwrite, putc, fflush, ferror, fprintf,
// vsnprintf, stdout, stderr, NULL, FILE
#include <stdlib.h> // malloc, free
#include <string.h> // strerror
#include <errno.h> // errno
#include <stdarg.h> // va_list, va_start, va_end
| > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
/* gznorm.c -- normalize a gzip stream
* Copyright (C) 2018 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
* Version 1.0 7 Oct 2018 Mark Adler */
// gznorm takes a gzip stream, potentially containing multiple members, and
// converts it to a gzip stream with a single member. In addition the gzip
// header is normalized, removing the file name and time stamp, and setting the
// other header contents (XFL, OS) to fixed values. gznorm does not recompress
// the data, so it is fast, but no advantage is gained from the history that
// could be available across member boundaries.
#if defined(_WIN32) && !defined(_CRT_NONSTDC_NO_DEPRECATE)
# define _CRT_NONSTDC_NO_DEPRECATE
#endif
#include <stdio.h> // fread, fwrite, putc, fflush, ferror, fprintf,
// vsnprintf, stdout, stderr, NULL, FILE
#include <stdlib.h> // malloc, free
#include <string.h> // strerror
#include <errno.h> // errno
#include <stdarg.h> // va_list, va_start, va_end
|
| ︙ | ︙ |
Changes to compat/zlib/examples/zlib_how.html.
1 2 3 4 5 6 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>zlib Usage Example</title> | | | > | 1 2 3 4 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 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>zlib Usage Example</title>
<!-- Copyright (c) 2004-2026 Mark Adler. -->
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#00A000">
<h2 align="center"> zlib Usage Example </h2>
We often get questions about how the <tt>deflate()</tt> and <tt>inflate()</tt> functions should be used.
Users wonder when they should provide more input, when they should use more output,
what to do with a <tt>Z_BUF_ERROR</tt>, how to make sure the process terminates properly, and
so on. So for those who have read <tt>zlib.h</tt> (a few times), and
would like further edification, below is an annotated example in C of simple routines to compress and decompress
from an input file to an output file using <tt>deflate()</tt> and <tt>inflate()</tt> respectively. The
annotations are interspersed between lines of the code. So please read between the lines.
We hope this helps explain some of the intricacies of <em>zlib</em>.
<p>
Without further ado, here is the program <a href="zpipe.c"><tt>zpipe.c</tt></a>:
<pre><b>
/* zpipe.c: example of proper use of zlib's inflate() and deflate()
Not copyrighted -- provided to the public domain
Version 1.5 11 February 2026 Mark Adler */
/* Version history:
1.0 30 Oct 2004 First version
1.1 8 Nov 2004 Add void casting for unused return values
Use switch statement for inflate() return values
1.2 9 Nov 2004 Add assertions to document zlib guarantees
1.3 6 Apr 2005 Remove incorrect assertion in inf()
1.4 11 Dec 2005 Add hack to avoid MSDOS end-of-line conversions
Avoid some compiler warnings for input and output buffers
1.5 11 Feb 2026 Use underscores for Windows POSIX names
*/
</b></pre><!-- -->
We now include the header files for the required definitions. From
<tt>stdio.h</tt> we use <tt>fopen()</tt>, <tt>fread()</tt>, <tt>fwrite()</tt>,
<tt>feof()</tt>, <tt>ferror()</tt>, and <tt>fclose()</tt> for file i/o, and
<tt>fputs()</tt> for error messages. From <tt>string.h</tt> we use
<tt>strcmp()</tt> for command line argument processing.
|
| ︙ | ︙ | |||
56 57 58 59 60 61 62 | another. That would corrupt binary data, and in particular would render the compressed data unusable. This sets the input and output to binary which suppresses the end-of-line conversions. <tt>SET_BINARY_MODE()</tt> will be used later on <tt>stdin</tt> and <tt>stdout</tt>, at the beginning of <tt>main()</tt>. <pre><b> #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__) # include <fcntl.h> # include <io.h> | | | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | another. That would corrupt binary data, and in particular would render the compressed data unusable. This sets the input and output to binary which suppresses the end-of-line conversions. <tt>SET_BINARY_MODE()</tt> will be used later on <tt>stdin</tt> and <tt>stdout</tt>, at the beginning of <tt>main()</tt>. <pre><b> #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__) # include <fcntl.h> # include <io.h> # define SET_BINARY_MODE(file) _setmode(_fileno(file), _O_BINARY) #else # define SET_BINARY_MODE(file) #endif </b></pre><!-- --> <tt>CHUNK</tt> is simply the buffer size for feeding data to and pulling data from the <em>zlib</em> routines. Larger buffer sizes would be more efficient, especially for <tt>inflate()</tt>. If the memory is available, buffers sizes |
| ︙ | ︙ | |||
534 535 536 537 538 539 540 |
else {
fputs("zpipe usage: zpipe [-d] < source > dest\n", stderr);
return 1;
}
}
</b></pre>
<hr>
| | | | | | 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 |
else {
fputs("zpipe usage: zpipe [-d] < source > dest\n", stderr);
return 1;
}
}
</b></pre>
<hr>
<i>Last modified 12 February 2026<br>
Copyright © 2004-2026 Mark Adler</i><br>
<a rel="license" href="https://creativecommons.org/licenses/by-nd/4.0/">
<img alt="Creative Commons License" style="border-width:0"
src="https://i.creativecommons.org/l/by-nd/4.0/88x31.png"></a>
<a rel="license" href="https://creativecommons.org/licenses/by-nd/4.0/">
Creative Commons Attribution-NoDerivatives 4.0 International License</a>.
</body>
</html>
|
Changes to compat/zlib/examples/zpipe.c.
1 2 | /* zpipe.c: example of proper use of zlib's inflate() and deflate() Not copyrighted -- provided to the public domain | | > | | 1 2 3 4 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 |
/* zpipe.c: example of proper use of zlib's inflate() and deflate()
Not copyrighted -- provided to the public domain
Version 1.5 11 February 2026 Mark Adler */
/* Version history:
1.0 30 Oct 2004 First version
1.1 8 Nov 2004 Add void casting for unused return values
Use switch statement for inflate() return values
1.2 9 Nov 2004 Add assertions to document zlib guarantees
1.3 6 Apr 2005 Remove incorrect assertion in inf()
1.4 11 Dec 2005 Add hack to avoid MSDOS end-of-line conversions
Avoid some compiler warnings for input and output buffers
1.5 11 Feb 2026 Use underscores for Windows POSIX names
*/
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "zlib.h"
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
# include <fcntl.h>
# include <io.h>
# define SET_BINARY_MODE(file) _setmode(_fileno(file), _O_BINARY)
#else
# define SET_BINARY_MODE(file)
#endif
#define CHUNK 16384
/* Compress from file source to file dest until EOF on source.
|
| ︙ | ︙ |
Changes to compat/zlib/examples/zran.c.
1 | /* zran.c -- example of deflate stream indexing and random access | | | > > > > > > > | 1 2 3 4 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 |
/* zran.c -- example of deflate stream indexing and random access
* Copyright (C) 2005, 2012, 2018, 2023, 2024, 2025 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
* Version 1.7 16 May 2025 Mark Adler */
/* Version History:
1.0 29 May 2005 First version
1.1 29 Sep 2012 Fix memory reallocation error
1.2 14 Oct 2018 Handle gzip streams with multiple members
Add a header file to facilitate usage in applications
1.3 18 Feb 2023 Permit raw deflate streams as well as zlib and gzip
Permit crossing gzip member boundaries when extracting
Support a size_t size when extracting (was an int)
Do a binary search over the index for an access point
Expose the access point type to enable save and load
1.4 13 Apr 2023 Add a NOPRIME define to not use inflatePrime()
1.5 4 Feb 2024 Set returned index to NULL on an index build error
Stop decoding once request is satisfied
Provide a reusable inflate engine in the index
Allocate the dictionaries to reduce memory usage
1.6 2 Aug 2024 Remove unneeded dependency on limits.h
1.7 16 May 2025 Remove redundant frees of point list on error
Clean out point list structure when freed
*/
// Illustrate the use of Z_BLOCK, inflatePrime(), and inflateSetDictionary()
// for random access of a compressed file. A file containing a raw deflate
// stream is provided on the command line. The compressed stream is decoded in
// its entirety, and an index built with access points about every SPAN bytes
// in the uncompressed output. The compressed file is left open, and can then
|
| ︙ | ︙ | |||
53 54 55 56 57 58 59 | // more memory per access point, and could not be saved to a file due to the // use of pointers in the state. The approach here allows for storage of the // index in a file. #include <stdio.h> #include <stdlib.h> #include <string.h> | < > > > > | | | | | | < < < < < < < < < < < < < < | | | < < | < < | > > | > > > > > | < < > > > | > > > > > > > > | > > > > < | | | | | | | | > > > | | | | | | | | | | | | | | | > > < | < < < < < < < < | 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
// more memory per access point, and could not be saved to a file due to the
// use of pointers in the state. The approach here allows for storage of the
// index in a file.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "zlib.h"
#include "zran.h"
#define WINSIZE 32768U // sliding window size
#define CHUNK 16384 // file input buffer size
// See comments in zran.h.
void deflate_index_free(struct deflate_index *index) {
if (index != NULL) {
while (index->have)
free(index->list[--index->have].window);
free(index->list);
index->list = NULL;
inflateEnd(&index->strm);
free(index);
}
}
// Add an access point to the list. If out of memory, return NULL. index->mode
// is temporarily the allocated number of access points, until it is time for
// deflate_index_build() to return. Then index->mode is set to the mode of
// inflation.
static struct deflate_index *add_point(struct deflate_index *index, off_t in,
off_t out, off_t beg,
unsigned char *window) {
if (index->have == index->mode) {
// The list is full. Make it bigger.
index->mode = index->mode ? index->mode << 1 : 8;
point_t *next = realloc(index->list, sizeof(point_t) * index->mode);
if (next == NULL)
return NULL;
index->list = next;
}
// Fill in the access point and increment how many we have.
point_t *next = (point_t *)(index->list) + index->have++;
if (index->have < 0)
// Overflowed the int!
return NULL;
next->out = out;
next->in = in;
next->bits = index->strm.data_type & 7;
next->dict = out - beg > WINSIZE ? WINSIZE : (unsigned)(out - beg);
next->window = malloc(next->dict);
if (next->window == NULL)
return NULL;
unsigned recent = WINSIZE - index->strm.avail_out;
unsigned copy = recent > next->dict ? next->dict : recent;
memcpy(next->window + next->dict - copy, window + recent - copy, copy);
copy = next->dict - copy;
memcpy(next->window, window + WINSIZE - copy, copy);
// Return the index, which may have been newly allocated or destroyed.
return index;
}
// Decompression modes. These are the inflateInit2() windowBits parameter.
#define RAW -15
#define ZLIB 15
#define GZIP 31
// See comments in zran.h.
int deflate_index_build(FILE *in, off_t span, struct deflate_index **built) {
// If this returns with an error, any attempt to use the index will cleanly
// return an error.
*built = NULL;
// Create and initialize the index list.
struct deflate_index *index = malloc(sizeof(struct deflate_index));
if (index == NULL)
return Z_MEM_ERROR;
index->have = 0;
index->mode = 0; // entries in index->list allocation
index->list = NULL;
index->strm.state = Z_NULL; // so inflateEnd() can work
// Set up the inflation state.
index->strm.avail_in = 0;
index->strm.avail_out = 0;
unsigned char buf[CHUNK]; // input buffer
unsigned char win[WINSIZE] = {0}; // output sliding window
off_t totin = 0; // total bytes read from input
off_t totout = 0; // total bytes uncompressed
off_t beg = 0; // starting offset of last history reset
int mode = 0; // mode: RAW, ZLIB, or GZIP (0 => not set yet)
// Decompress from in, generating access points along the way.
int ret; // the return value from zlib, or Z_ERRNO
off_t last; // last access point uncompressed offset
do {
// Assure available input, at least until reaching EOF.
if (index->strm.avail_in == 0) {
index->strm.avail_in = fread(buf, 1, sizeof(buf), in);
totin += index->strm.avail_in;
index->strm.next_in = buf;
if (index->strm.avail_in < sizeof(buf) && ferror(in)) {
ret = Z_ERRNO;
break;
}
if (mode == 0) {
// At the start of the input -- determine the type. Assume raw
// if it is neither zlib nor gzip. This could in theory result
// in a false positive for zlib, but in practice the fill bits
// after a stored block are always zeros, so a raw stream won't
// start with an 8 in the low nybble.
mode = index->strm.avail_in == 0 ? RAW : // will fail
(index->strm.next_in[0] & 0xf) == 8 ? ZLIB :
index->strm.next_in[0] == 0x1f ? GZIP :
/* else */ RAW;
index->strm.zalloc = Z_NULL;
index->strm.zfree = Z_NULL;
index->strm.opaque = Z_NULL;
ret = inflateInit2(&index->strm, mode);
if (ret != Z_OK)
break;
}
}
// Assure available output. This rotates the output through, for use as
// a sliding window on the uncompressed data.
if (index->strm.avail_out == 0) {
index->strm.avail_out = sizeof(win);
index->strm.next_out = win;
}
if (mode == RAW && index->have == 0)
// We skip the inflate() call at the start of raw deflate data in
// order generate an access point there. Set data_type to imitate
// the end of a header.
index->strm.data_type = 0x80;
else {
// Inflate and update the number of uncompressed bytes.
unsigned before = index->strm.avail_out;
ret = inflate(&index->strm, Z_BLOCK);
totout += before - index->strm.avail_out;
}
if ((index->strm.data_type & 0xc0) == 0x80 &&
(index->have == 0 || totout - last >= span)) {
// We are at the end of a header or a non-last deflate block, so we
// can add an access point here. Furthermore, we are either at the
// very start for the first access point, or there has been span or
// more uncompressed bytes since the last access point, so we want
// to add an access point here.
index = add_point(index, totin - index->strm.avail_in, totout, beg,
win);
if (index == NULL) {
ret = Z_MEM_ERROR;
break;
}
last = totout;
}
if (ret == Z_STREAM_END && mode == GZIP &&
(index->strm.avail_in || ungetc(getc(in), in) != EOF)) {
// There is more input after the end of a gzip member. Reset the
// inflate state to read another gzip member. On success, this will
// set ret to Z_OK to continue decompressing.
ret = inflateReset2(&index->strm, GZIP);
beg = totout; // reset history
}
// Keep going until Z_STREAM_END or error. If the compressed data ends
// prematurely without a file read error, Z_BUF_ERROR is returned.
} while (ret == Z_OK);
if (ret != Z_STREAM_END) {
// An error was encountered. Discard the index and return a negative
// error code.
deflate_index_free(index);
return ret == Z_NEED_DICT ? Z_DATA_ERROR : ret;
}
// Return the index.
index->mode = mode;
index->length = totout;
*built = index;
return index->have;
}
#ifdef NOPRIME
// Support zlib versions before 1.2.3 (July 2005), or incomplete zlib clones
// that do not have inflatePrime().
|
| ︙ | ︙ | |||
326 327 328 329 330 331 332 |
# define INFLATEPRIME inflatePrime
#endif
// See comments in zran.h.
ptrdiff_t deflate_index_extract(FILE *in, struct deflate_index *index,
off_t offset, unsigned char *buf, size_t len) {
// Do a quick sanity check on the index.
| | > | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
# define INFLATEPRIME inflatePrime
#endif
// See comments in zran.h.
ptrdiff_t deflate_index_extract(FILE *in, struct deflate_index *index,
off_t offset, unsigned char *buf, size_t len) {
// Do a quick sanity check on the index.
if (index == NULL || index->have < 1 || index->list[0].out != 0 ||
index->strm.state == Z_NULL)
return Z_STREAM_ERROR;
// If nothing to extract, return zero bytes extracted.
if (len == 0 || offset < 0 || offset >= index->length)
return 0;
// Find the access point closest to but not after offset.
|
| ︙ | ︙ | |||
352 353 354 355 356 357 358 |
// Initialize the input file and prime the inflate engine to start there.
int ret = fseeko(in, point->in - (point->bits ? 1 : 0), SEEK_SET);
if (ret == -1)
return Z_ERRNO;
int ch = 0;
if (point->bits && (ch = getc(in)) == EOF)
return ferror(in) ? Z_ERRNO : Z_BUF_ERROR;
| | | | | | > | | > | | | | | | | | | > > > > | | | | | | | | | | | | | | | | | < | 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 |
// Initialize the input file and prime the inflate engine to start there.
int ret = fseeko(in, point->in - (point->bits ? 1 : 0), SEEK_SET);
if (ret == -1)
return Z_ERRNO;
int ch = 0;
if (point->bits && (ch = getc(in)) == EOF)
return ferror(in) ? Z_ERRNO : Z_BUF_ERROR;
index->strm.avail_in = 0;
ret = inflateReset2(&index->strm, RAW);
if (ret != Z_OK)
return ret;
if (point->bits)
INFLATEPRIME(&index->strm, point->bits, ch >> (8 - point->bits));
inflateSetDictionary(&index->strm, point->window, point->dict);
// Skip uncompressed bytes until offset reached, then satisfy request.
unsigned char input[CHUNK];
unsigned char discard[WINSIZE];
offset -= point->out; // number of bytes to skip to get to offset
size_t left = len; // number of bytes left to read after offset
do {
if (offset) {
// Discard up to offset uncompressed bytes.
index->strm.avail_out = offset < WINSIZE ? (unsigned)offset :
WINSIZE;
index->strm.next_out = discard;
}
else {
// Uncompress up to left bytes into buf.
index->strm.avail_out = left < (unsigned)-1 ? (unsigned)left :
(unsigned)-1;
index->strm.next_out = buf + len - left;
}
// Uncompress, setting got to the number of bytes uncompressed.
if (index->strm.avail_in == 0) {
// Assure available input.
index->strm.avail_in = fread(input, 1, CHUNK, in);
if (index->strm.avail_in < CHUNK && ferror(in)) {
ret = Z_ERRNO;
break;
}
index->strm.next_in = input;
}
unsigned got = index->strm.avail_out;
ret = inflate(&index->strm, Z_NO_FLUSH);
got -= index->strm.avail_out;
// Update the appropriate count.
if (offset)
offset -= got;
else {
left -= got;
if (left == 0)
// Request satisfied.
break;
}
// If we're at the end of a gzip member and there's more to read,
// continue to the next gzip member.
if (ret == Z_STREAM_END && index->mode == GZIP) {
// Discard the gzip trailer.
unsigned drop = 8; // length of gzip trailer
if (index->strm.avail_in >= drop) {
index->strm.avail_in -= drop;
index->strm.next_in += drop;
}
else {
// Read and discard the remainder of the gzip trailer.
drop -= index->strm.avail_in;
index->strm.avail_in = 0;
do {
if (getc(in) == EOF)
// The input does not have a complete trailer.
return ferror(in) ? Z_ERRNO : Z_BUF_ERROR;
} while (--drop);
}
if (index->strm.avail_in || ungetc(getc(in), in) != EOF) {
// There's more after the gzip trailer. Use inflate to skip the
// gzip header and resume the raw inflate there.
inflateReset2(&index->strm, GZIP);
do {
if (index->strm.avail_in == 0) {
index->strm.avail_in = fread(input, 1, CHUNK, in);
if (index->strm.avail_in < CHUNK && ferror(in)) {
ret = Z_ERRNO;
break;
}
index->strm.next_in = input;
}
index->strm.avail_out = WINSIZE;
index->strm.next_out = discard;
ret = inflate(&index->strm, Z_BLOCK); // stop after header
} while (ret == Z_OK && (index->strm.data_type & 0x80) == 0);
if (ret != Z_OK)
break;
inflateReset2(&index->strm, RAW);
}
}
// Continue until we have the requested data, the deflate data has
// ended, or an error is encountered.
} while (ret == Z_OK);
// Return the number of uncompressed bytes read into buf, or the error.
return ret == Z_OK || ret == Z_STREAM_END ? len - left : ret;
}
#ifdef TEST
|
| ︙ | ︙ |
Changes to compat/zlib/examples/zran.h.
|
| | | | > | > | | 1 2 3 4 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 |
/* zran.h -- example of deflate stream indexing and random access
* Copyright (C) 2005, 2012, 2018, 2023, 2024, 2025 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
* Version 1.7 16 May 2025 Mark Adler */
#include <stdio.h>
#include "zlib.h"
// Access point.
typedef struct point {
off_t out; // offset in uncompressed data
off_t in; // offset in compressed file of first full byte
int bits; // 0, or number of bits (1-7) from byte at in-1
unsigned dict; // number of bytes in window to use as a dictionary
unsigned char *window; // preceding 32K (or less) of uncompressed data
} point_t;
// Access point list.
struct deflate_index {
int have; // number of access points in list
int mode; // -15 for raw, 15 for zlib, or 31 for gzip
off_t length; // total length of uncompressed data
point_t *list; // allocated list of access points
z_stream strm; // re-usable inflate engine for extraction
};
// Make one pass through a zlib, gzip, or raw deflate compressed stream and
// build an index, with access points about every span bytes of uncompressed
// output. gzip files with multiple members are fully indexed. span should be
// chosen to balance the speed of random access against the memory requirements
// of the list, which is about 32K bytes per access point. The return value is
// the number of access points on success (>= 1), Z_MEM_ERROR for out of
// memory, Z_BUF_ERROR for a premature end of input, Z_DATA_ERROR for a format
// or verification error in the input file, or Z_ERRNO for a file read error.
// On success, *built points to the resulting index, otherwise it's NULL.
int deflate_index_build(FILE *in, off_t span, struct deflate_index **built);
// Use the index to read len bytes from offset into buf. Return the number of
// bytes read or a negative error code. If data is requested past the end of
// the uncompressed data, then deflate_index_extract() will return a value less
// than len, indicating how much was actually read into buf. If given a valid
// index, this function should not return an error unless the file was modified
|
| ︙ | ︙ |
Changes to compat/zlib/gzguts.h.
1 | /* gzguts.h -- zlib internal header definitions for gz* operations | | > > > > > > > > > > > > | | > | < < < < < < < | 1 2 3 4 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 |
/* gzguts.h -- zlib internal header definitions for gz* operations
* Copyright (C) 2004-2026 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#ifdef _LARGEFILE64_SOURCE
# ifndef _LARGEFILE_SOURCE
# define _LARGEFILE_SOURCE 1
# endif
# undef _FILE_OFFSET_BITS
# undef _TIME_BITS
#endif
#ifdef HAVE_HIDDEN
# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
#else
# define ZLIB_INTERNAL
#endif
#if defined(_WIN32)
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
# endif
# ifndef _CRT_NONSTDC_NO_DEPRECATE
# define _CRT_NONSTDC_NO_DEPRECATE
# endif
#endif
#include <stdio.h>
#include "zlib.h"
#ifdef STDC
# include <string.h>
# include <stdlib.h>
# include <limits.h>
#endif
#ifndef _POSIX_C_SOURCE
# define _POSIX_C_SOURCE 200112L
#endif
#include <fcntl.h>
#ifdef _WIN32
# include <stddef.h>
#endif
#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)
# include <io.h>
# include <sys/stat.h>
#endif
#if defined(_WIN32) && !defined(WIDECHAR)
# define WIDECHAR
#endif
#ifdef NO_DEFLATE /* for compatibility with old definition */
# define NO_GZCOMPRESS
#endif
#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
|
| ︙ | ︙ | |||
68 69 70 71 72 73 74 | #if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410) # ifndef HAVE_VSNPRINTF # define HAVE_VSNPRINTF # endif #endif #ifndef HAVE_VSNPRINTF | | > > < < < < | > | | > | | | < | < < | | < < | 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 102 103 104 105 106 107 108 109 |
#if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410)
# ifndef HAVE_VSNPRINTF
# define HAVE_VSNPRINTF
# endif
#endif
#ifndef HAVE_VSNPRINTF
# if !defined(NO_vsnprintf) && \
(defined(MSDOS) || defined(__TURBOC__) || defined(__SASC) || \
defined(VMS) || defined(__OS400) || defined(__MVS__))
/* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
but for now we just assume it doesn't. */
# define NO_vsnprintf
# endif
# ifdef WIN32
/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
# ifndef vsnprintf
# define vsnprintf _vsnprintf
# endif
# endif
# elif !defined(__STDC_VERSION__) || __STDC_VERSION__-0 < 199901L
/* Otherwise if C89/90, assume no C99 snprintf() or vsnprintf() */
# ifndef NO_snprintf
# define NO_snprintf
# endif
# ifndef NO_vsnprintf
# define NO_vsnprintf
# endif
# endif
#endif
/* unlike snprintf (which is required in C99), _snprintf does not guarantee
null termination of the result -- however this is only used in gzlib.c where
the result is assured to fit in the space provided */
#if defined(_MSC_VER) && _MSC_VER < 1900
|
| ︙ | ︙ | |||
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
char *path; /* path or fd for error messages */
unsigned size; /* buffer size, zero if not allocated yet */
unsigned want; /* requested buffer size, default is GZBUFSIZE */
unsigned char *in; /* input buffer (double-sized when writing) */
unsigned char *out; /* output buffer (double-sized when reading) */
int direct; /* 0 if processing gzip, 1 if transparent */
/* just for reading */
int how; /* 0: get header, 1: copy, 2: decompress */
z_off64_t start; /* where the gzip data started, for rewinding */
int eof; /* true if end of input file reached */
int past; /* true if read requested past end */
/* just for writing */
int level; /* compression level */
int strategy; /* compression strategy */
int reset; /* true if a reset is pending after a Z_FINISH */
/* seek request */
z_off64_t skip; /* amount to skip (already rewound if backwards) */
| > > < | 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
char *path; /* path or fd for error messages */
unsigned size; /* buffer size, zero if not allocated yet */
unsigned want; /* requested buffer size, default is GZBUFSIZE */
unsigned char *in; /* input buffer (double-sized when writing) */
unsigned char *out; /* output buffer (double-sized when reading) */
int direct; /* 0 if processing gzip, 1 if transparent */
/* just for reading */
int junk; /* -1 = start, 1 = junk candidate, 0 = in gzip */
int how; /* 0: get header, 1: copy, 2: decompress */
int again; /* true if EAGAIN or EWOULDBLOCK on last i/o */
z_off64_t start; /* where the gzip data started, for rewinding */
int eof; /* true if end of input file reached */
int past; /* true if read requested past end */
/* just for writing */
int level; /* compression level */
int strategy; /* compression strategy */
int reset; /* true if a reset is pending after a Z_FINISH */
/* seek request */
z_off64_t skip; /* amount to skip (already rewound if backwards) */
/* error information */
int err; /* error code */
char *msg; /* error message */
/* zlib inflate or deflate stream */
z_stream strm; /* stream structure in-place (not a pointer) */
} gz_state;
typedef gz_state FAR *gz_statep;
|
| ︙ | ︙ |
Changes to compat/zlib/gzlib.c.
1 | /* gzlib.c -- zlib functions common to reading and writing gzip files | | > > | < | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | /* gzlib.c -- zlib functions common to reading and writing gzip files * Copyright (C) 2004-2026 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #include "gzguts.h" #if defined(__DJGPP__) # define LSEEK llseek #elif defined(_WIN32) && !defined(__BORLANDC__) && !defined(UNDER_CE) # define LSEEK _lseeki64 #elif defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 # define LSEEK lseek64 #else # define LSEEK lseek #endif #if defined UNDER_CE /* Map the Windows error number in ERROR to a locale-dependent error message string and return a pointer to it. Typically, the values for ERROR come from GetLastError. |
| ︙ | ︙ | |||
48 49 50 51 52 53 54 |
}
if (chars > sizeof (buf) - 1) {
chars = sizeof (buf) - 1;
msgbuf[chars] = 0;
}
| | > > | | < < < | > | 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 102 103 104 105 106 107 108 109 110 111 112 |
}
if (chars > sizeof (buf) - 1) {
chars = sizeof (buf) - 1;
msgbuf[chars] = 0;
}
wcstombs(buf, msgbuf, chars + 1); /* assumes buf is big enough */
LocalFree(msgbuf);
}
else {
sprintf(buf, "unknown win32 error (%ld)", error);
}
SetLastError(lasterr);
return buf;
}
#endif /* UNDER_CE */
/* Reset gzip file state */
local void gz_reset(gz_statep state) {
state->x.have = 0; /* no output data available */
if (state->mode == GZ_READ) { /* for reading ... */
state->eof = 0; /* not at end of file */
state->past = 0; /* have not read past end yet */
state->how = LOOK; /* look for gzip header */
state->junk = -1; /* mark first member */
}
else /* for writing ... */
state->reset = 0; /* no deflateReset pending */
state->again = 0; /* no stalled i/o yet */
state->skip = 0; /* no seek request pending */
gz_error(state, Z_OK, NULL); /* clear error */
state->x.pos = 0; /* no uncompressed data yet */
state->strm.avail_in = 0; /* no input data yet */
}
/* Open a gzip file either by name or file descriptor. */
local gzFile gz_open(const void *path, int fd, const char *mode) {
gz_statep state;
z_size_t len;
int oflag = 0;
#ifdef O_EXCL
int exclusive = 0;
#endif
/* check input */
if (path == NULL || mode == NULL)
return NULL;
/* allocate gzFile structure to return */
state = (gz_statep)malloc(sizeof(gz_state));
if (state == NULL)
return NULL;
state->size = 0; /* no buffers allocated yet */
state->want = GZBUFSIZE; /* requested buffer size */
state->err = Z_OK; /* no error yet */
state->msg = NULL; /* no error message yet */
/* interpret mode */
state->mode = GZ_NONE;
state->level = Z_DEFAULT_COMPRESSION;
state->strategy = Z_DEFAULT_STRATEGY;
state->direct = 0;
|
| ︙ | ︙ | |||
129 130 131 132 133 134 135 |
case '+': /* can't read and write at the same time */
free(state);
return NULL;
case 'b': /* ignore -- will request binary anyway */
break;
#ifdef O_CLOEXEC
case 'e':
| | > > > > > > > > | | > > > > | > > > > > > > | < < < | > > | > | < < < > | > | > > | > > > > > > > > | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
case '+': /* can't read and write at the same time */
free(state);
return NULL;
case 'b': /* ignore -- will request binary anyway */
break;
#ifdef O_CLOEXEC
case 'e':
oflag |= O_CLOEXEC;
break;
#endif
#ifdef O_EXCL
case 'x':
exclusive = 1;
break;
#endif
case 'f':
state->strategy = Z_FILTERED;
break;
case 'h':
state->strategy = Z_HUFFMAN_ONLY;
break;
case 'R':
state->strategy = Z_RLE;
break;
case 'F':
state->strategy = Z_FIXED;
break;
case 'G':
state->direct = -1;
break;
#ifdef O_NONBLOCK
case 'N':
oflag |= O_NONBLOCK;
break;
#endif
case 'T':
state->direct = 1;
break;
default: /* could consider as an error, but just ignore */
;
}
mode++;
}
/* must provide an "r", "w", or "a" */
if (state->mode == GZ_NONE) {
free(state);
return NULL;
}
/* direct is 0, 1 if "T", or -1 if "G" (last "G" or "T" wins) */
if (state->mode == GZ_READ) {
if (state->direct == 1) {
/* can't force a transparent read */
free(state);
return NULL;
}
if (state->direct == 0)
/* default when reading is auto-detect of gzip vs. transparent --
start with a transparent assumption in case of an empty file */
state->direct = 1;
}
else if (state->direct == -1) {
/* "G" has no meaning when writing -- disallow it */
free(state);
return NULL;
}
/* if reading, direct == 1 for auto-detect, -1 for gzip only; if writing or
appending, direct == 0 for gzip, 1 for transparent (copy in to out) */
/* save the path name for error messages */
#ifdef WIDECHAR
if (fd == -2)
len = wcstombs(NULL, path, 0);
else
#endif
len = strlen((const char *)path);
state->path = (char *)malloc(len + 1);
if (state->path == NULL) {
free(state);
return NULL;
}
#ifdef WIDECHAR
if (fd == -2) {
if (len)
wcstombs(state->path, path, len + 1);
else
*(state->path) = 0;
}
else
#endif
{
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
(void)snprintf(state->path, len + 1, "%s", (const char *)path);
#else
strcpy(state->path, path);
#endif
}
/* compute the flags for open() */
oflag |=
#ifdef O_LARGEFILE
O_LARGEFILE |
#endif
#ifdef O_BINARY
O_BINARY |
#endif
(state->mode == GZ_READ ?
O_RDONLY :
(O_WRONLY | O_CREAT |
#ifdef O_EXCL
(exclusive ? O_EXCL : 0) |
#endif
(state->mode == GZ_WRITE ?
O_TRUNC :
O_APPEND)));
/* open the file with the appropriate flags (or just use fd) */
if (fd == -1)
state->fd = open((const char *)path, oflag, 0666);
#ifdef WIDECHAR
else if (fd == -2)
state->fd = _wopen(path, oflag, _S_IREAD | _S_IWRITE);
#endif
else {
#ifdef O_NONBLOCK
if (oflag & O_NONBLOCK)
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
#endif
#ifdef O_CLOEXEC
if (oflag & O_CLOEXEC)
fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | O_CLOEXEC);
#endif
state->fd = fd;
}
if (state->fd == -1) {
free(state->path);
free(state);
return NULL;
}
if (state->mode == GZ_APPEND) {
LSEEK(state->fd, 0, SEEK_END); /* so gzoffset() is correct */
|
| ︙ | ︙ | |||
355 356 357 358 359 360 361 |
/* can only seek from start or relative to current position */
if (whence != SEEK_SET && whence != SEEK_CUR)
return -1;
/* normalize offset to a SEEK_CUR specification */
if (whence == SEEK_SET)
offset -= state->x.pos;
| | | | > | | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 |
/* can only seek from start or relative to current position */
if (whence != SEEK_SET && whence != SEEK_CUR)
return -1;
/* normalize offset to a SEEK_CUR specification */
if (whence == SEEK_SET)
offset -= state->x.pos;
else {
offset += state->past ? 0 : state->skip;
state->skip = 0;
}
/* if within raw area while reading, just go there */
if (state->mode == GZ_READ && state->how == COPY &&
state->x.pos + offset >= 0) {
ret = LSEEK(state->fd, offset - (z_off64_t)state->x.have, SEEK_CUR);
if (ret == -1)
return -1;
state->x.have = 0;
state->eof = 0;
state->past = 0;
state->skip = 0;
gz_error(state, Z_OK, NULL);
state->strm.avail_in = 0;
state->x.pos += offset;
return state->x.pos;
}
/* calculate skip amount, rewinding if needed for back seek when reading */
|
| ︙ | ︙ | |||
397 398 399 400 401 402 403 |
state->x.have -= n;
state->x.next += n;
state->x.pos += n;
offset -= n;
}
/* request skip (if not zero) */
| < < | < | 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 |
state->x.have -= n;
state->x.next += n;
state->x.pos += n;
offset -= n;
}
/* request skip (if not zero) */
state->skip = offset;
return state->x.pos + offset;
}
/* -- see zlib.h -- */
z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) {
z_off64_t ret;
|
| ︙ | ︙ | |||
424 425 426 427 428 429 430 |
if (file == NULL)
return -1;
state = (gz_statep)file;
if (state->mode != GZ_READ && state->mode != GZ_WRITE)
return -1;
/* return position */
| | | 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 |
if (file == NULL)
return -1;
state = (gz_statep)file;
if (state->mode != GZ_READ && state->mode != GZ_WRITE)
return -1;
/* return position */
return state->x.pos + (state->past ? 0 : state->skip);
}
/* -- see zlib.h -- */
z_off_t ZEXPORT gztell(gzFile file) {
z_off64_t ret;
ret = gztell64(file);
|
| ︙ | ︙ | |||
531 532 533 534 535 536 537 |
if (state->msg != NULL) {
if (state->err != Z_MEM_ERROR)
free(state->msg);
state->msg = NULL;
}
/* if fatal, set state->x.have to 0 so that the gzgetc() macro fails */
| | | 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 |
if (state->msg != NULL) {
if (state->err != Z_MEM_ERROR)
free(state->msg);
state->msg = NULL;
}
/* if fatal, set state->x.have to 0 so that the gzgetc() macro fails */
if (err != Z_OK && err != Z_BUF_ERROR && !state->again)
state->x.have = 0;
/* set error code, and if no message, then done */
state->err = err;
if (msg == NULL)
return;
|
| ︙ | ︙ | |||
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 |
used, since C standard permits 1's complement and sign-bit representations,
otherwise we could just use ((unsigned)-1) >> 1 */
unsigned ZLIB_INTERNAL gz_intmax(void) {
#ifdef INT_MAX
return INT_MAX;
#else
unsigned p = 1, q;
do {
q = p;
p <<= 1;
p++;
} while (p > q);
return q >> 1;
#endif
}
| > | 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 |
used, since C standard permits 1's complement and sign-bit representations,
otherwise we could just use ((unsigned)-1) >> 1 */
unsigned ZLIB_INTERNAL gz_intmax(void) {
#ifdef INT_MAX
return INT_MAX;
#else
unsigned p = 1, q;
do {
q = p;
p <<= 1;
p++;
} while (p > q);
return q >> 1;
#endif
}
|
Changes to compat/zlib/gzread.c.
1 | /* gzread.c -- zlib functions for reading gzip files | | | > > > > > > > > | > > > > > | 1 2 3 4 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 |
/* gzread.c -- zlib functions for reading gzip files
* Copyright (C) 2004-2026 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include "gzguts.h"
/* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from
state->fd, and update state->eof, state->err, and state->msg as appropriate.
This function needs to loop on read(), since read() is not guaranteed to
read the number of bytes requested, depending on the type of descriptor. It
also needs to loop to manage the fact that read() returns an int. If the
descriptor is non-blocking and read() returns with no data in order to avoid
blocking, then gz_load() will return 0 if some data has been read, or -1 if
no data has been read. Either way, state->again is set true to indicate a
non-blocking event. If errno is non-zero on return, then there was an error
signaled from read(). *have is set to the number of bytes read. */
local int gz_load(gz_statep state, unsigned char *buf, unsigned len,
unsigned *have) {
int ret;
unsigned get, max = ((unsigned)-1 >> 2) + 1;
state->again = 0;
errno = 0;
*have = 0;
do {
get = len - *have;
if (get > max)
get = max;
ret = (int)read(state->fd, buf + *have, get);
if (ret <= 0)
break;
*have += (unsigned)ret;
} while (*have < len);
if (ret < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
state->again = 1;
if (*have != 0)
return 0;
}
gz_error(state, Z_ERRNO, zstrerror());
return -1;
}
if (ret == 0)
state->eof = 1;
return 0;
}
|
| ︙ | ︙ | |||
46 47 48 49 50 51 52 |
if (state->err != Z_OK && state->err != Z_BUF_ERROR)
return -1;
if (state->eof == 0) {
if (strm->avail_in) { /* copy what's there to the start */
unsigned char *p = state->in;
unsigned const char *q = strm->next_in;
| > > | > | | | > | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
if (state->err != Z_OK && state->err != Z_BUF_ERROR)
return -1;
if (state->eof == 0) {
if (strm->avail_in) { /* copy what's there to the start */
unsigned char *p = state->in;
unsigned const char *q = strm->next_in;
if (q != p) {
unsigned n = strm->avail_in;
do {
*p++ = *q++;
} while (--n);
}
}
if (gz_load(state, state->in + strm->avail_in,
state->size - strm->avail_in, &got) == -1)
return -1;
strm->avail_in += got;
strm->next_in = state->in;
}
|
| ︙ | ︙ | |||
100 101 102 103 104 105 106 |
free(state->in);
state->size = 0;
gz_error(state, Z_MEM_ERROR, "out of memory");
return -1;
}
}
| > > > > > > > > > > | > > > | > > | | | > > | | | | < < < < < < > | | > > < < < < < < < < < | < | | | > > > | > | > > | > > > | | > > > > > > > | | > > | > | | | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
free(state->in);
state->size = 0;
gz_error(state, Z_MEM_ERROR, "out of memory");
return -1;
}
}
/* if transparent reading is disabled, which would only be at the start, or
if we're looking for a gzip member after the first one, which is not at
the start, then proceed directly to look for a gzip member next */
if (state->direct == -1 || state->junk == 0) {
inflateReset(strm);
state->how = GZIP;
state->junk = state->junk != -1;
state->direct = 0;
return 0;
}
/* otherwise we're at the start with auto-detect -- we check to see if the
first four bytes could be gzip header in order to decide whether or not
this will be a transparent read */
/* load any header bytes into the input buffer -- if the input is empty,
then it's not an error as this is a transparent read of zero bytes */
if (gz_avail(state) == -1)
return -1;
if (strm->avail_in == 0 || (state->again && strm->avail_in < 4))
/* if non-blocking input stalled before getting four bytes, then
return and wait until a later call has accumulated enough */
return 0;
/* see if this is (likely) gzip input -- if the first four bytes are
consistent with a gzip header, then go look for the first gzip member,
otherwise proceed to copy the input transparently */
if (strm->avail_in > 3 &&
strm->next_in[0] == 31 && strm->next_in[1] == 139 &&
strm->next_in[2] == 8 && strm->next_in[3] < 32) {
inflateReset(strm);
state->how = GZIP;
state->junk = 1;
state->direct = 0;
return 0;
}
/* doing raw i/o: copy any leftover input to output -- this assumes that
the output buffer is larger than the input buffer, which also assures
space for gzungetc() */
state->x.next = state->out;
memcpy(state->x.next, strm->next_in, strm->avail_in);
state->x.have = strm->avail_in;
strm->avail_in = 0;
state->how = COPY;
return 0;
}
/* Decompress from input to the provided next_out and avail_out in the state.
On return, state->x.have and state->x.next point to the just decompressed
data. If the gzip stream completes, state->how is reset to LOOK to look for
the next gzip stream or raw data, once state->x.have is depleted. Returns 0
on success, -1 on failure. If EOF is reached when looking for more input to
complete the gzip member, then an unexpected end of file error is raised.
If there is no more input, but state->again is true, then EOF has not been
reached, and no error is raised. */
local int gz_decomp(gz_statep state) {
int ret = Z_OK;
unsigned had;
z_streamp strm = &(state->strm);
/* fill output buffer up to end of deflate stream */
had = strm->avail_out;
do {
/* get more input for inflate() */
if (strm->avail_in == 0 && gz_avail(state) == -1) {
ret = state->err;
break;
}
if (strm->avail_in == 0) {
if (!state->again)
gz_error(state, Z_BUF_ERROR, "unexpected end of file");
break;
}
/* decompress and handle errors */
ret = inflate(strm, Z_NO_FLUSH);
if (strm->avail_out < had)
/* any decompressed data marks this as a real gzip stream */
state->junk = 0;
if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) {
gz_error(state, Z_STREAM_ERROR,
"internal error: inflate stream corrupt");
break;
}
if (ret == Z_MEM_ERROR) {
gz_error(state, Z_MEM_ERROR, "out of memory");
break;
}
if (ret == Z_DATA_ERROR) { /* deflate stream invalid */
if (state->junk == 1) { /* trailing garbage is ok */
strm->avail_in = 0;
state->eof = 1;
state->how = LOOK;
ret = Z_OK;
break;
}
gz_error(state, Z_DATA_ERROR,
strm->msg == NULL ? "compressed data error" : strm->msg);
break;
}
} while (strm->avail_out && ret != Z_STREAM_END);
/* update available output */
state->x.have = had - strm->avail_out;
state->x.next = strm->next_out - state->x.have;
/* if the gzip stream completed successfully, look for another */
if (ret == Z_STREAM_END) {
state->junk = 0;
state->how = LOOK;
return 0;
}
/* return decompression status */
return ret != Z_OK ? -1 : 0;
}
/* Fetch data and put it in the output buffer. Assumes state->x.have is 0.
Data is either copied from the input file or decompressed from the input
file depending on state->how. If state->how is LOOK, then a gzip header is
looked for to determine whether to copy or decompress. Returns -1 on error,
otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the
|
| ︙ | ︙ | |||
223 224 225 226 227 228 229 230 231 232 233 234 |
state->x.next = state->out;
return 0;
case GZIP: /* -> GZIP or LOOK (if end of gzip stream) */
strm->avail_out = state->size << 1;
strm->next_out = state->out;
if (gz_decomp(state) == -1)
return -1;
}
} while (state->x.have == 0 && (!state->eof || strm->avail_in));
return 0;
}
| > > > > | > | | | > | | > | | | > > > | < < | < > > > > | < | < | | > | | | < < | < | > > > > | > > | < | > > | | > > > > > > | > > | | > | > > | < | > | 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 |
state->x.next = state->out;
return 0;
case GZIP: /* -> GZIP or LOOK (if end of gzip stream) */
strm->avail_out = state->size << 1;
strm->next_out = state->out;
if (gz_decomp(state) == -1)
return -1;
break;
default:
gz_error(state, Z_STREAM_ERROR, "state corrupt");
return -1;
}
} while (state->x.have == 0 && (!state->eof || strm->avail_in));
return 0;
}
/* Skip state->skip (> 0) uncompressed bytes of output. Return -1 on error, 0
on success. */
local int gz_skip(gz_statep state) {
unsigned n;
/* skip over len bytes or reach end-of-file, whichever comes first */
do {
/* skip over whatever is in output buffer */
if (state->x.have) {
n = GT_OFF(state->x.have) ||
(z_off64_t)state->x.have > state->skip ?
(unsigned)state->skip : state->x.have;
state->x.have -= n;
state->x.next += n;
state->x.pos += n;
state->skip -= n;
}
/* output buffer empty -- return if we're at the end of the input */
else if (state->eof && state->strm.avail_in == 0)
break;
/* need more data to skip -- load up output buffer */
else {
/* get more output, looking for header if required */
if (gz_fetch(state) == -1)
return -1;
}
} while (state->skip);
return 0;
}
/* Read len bytes into buf from file, or less than len up to the end of the
input. Return the number of bytes read. If zero is returned, either the end
of file was reached, or there was an error. state->err must be consulted in
that case to determine which. If there was an error, but some uncompressed
bytes were read before the error, then that count is returned. The error is
still recorded, and so is deferred until the next call. */
local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) {
z_size_t got;
unsigned n;
int err;
/* if len is zero, avoid unnecessary operations */
if (len == 0)
return 0;
/* process a skip request */
if (state->skip && gz_skip(state) == -1)
return 0;
/* get len bytes to buf, or less than len if at the end */
got = 0;
err = 0;
do {
/* set n to the maximum amount of len that fits in an unsigned int */
n = (unsigned)-1;
if (n > len)
n = (unsigned)len;
/* first just try copying data from the output buffer */
if (state->x.have) {
if (state->x.have < n)
n = state->x.have;
memcpy(buf, state->x.next, n);
state->x.next += n;
state->x.have -= n;
if (state->err != Z_OK)
/* caught deferred error from gz_fetch() */
err = -1;
}
/* output buffer empty -- return if we're at the end of the input */
else if (state->eof && state->strm.avail_in == 0)
break;
/* need output data -- for small len or new stream load up our output
buffer, so that gzgetc() can be fast */
else if (state->how == LOOK || n < (state->size << 1)) {
/* get more output, looking for header if required */
if (gz_fetch(state) == -1 && state->x.have == 0)
/* if state->x.have != 0, error will be caught after copy */
err = -1;
continue; /* no progress yet -- go back to copy above */
/* the copy above assures that we will leave with space in the
output buffer, allowing at least one gzungetc() to succeed */
}
/* large len -- read directly into user buffer */
else if (state->how == COPY) /* read directly */
err = gz_load(state, (unsigned char *)buf, n, &n);
/* large len -- decompress directly into user buffer */
else { /* state->how == GZIP */
state->strm.avail_out = n;
state->strm.next_out = (unsigned char *)buf;
err = gz_decomp(state);
n = state->x.have;
state->x.have = 0;
}
/* update progress */
len -= n;
buf = (char *)buf + n;
got += n;
state->x.pos += n;
} while (len && !err);
/* note read past eof */
if (len && state->eof)
state->past = 1;
/* return number of bytes read into user buffer */
return got;
}
/* -- see zlib.h -- */
int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) {
gz_statep state;
/* get internal structure and check that it's for reading */
if (file == NULL)
return -1;
state = (gz_statep)file;
if (state->mode != GZ_READ)
return -1;
/* check that there was no (serious) error */
if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again)
return -1;
gz_error(state, Z_OK, NULL);
/* since an int is returned, make sure len fits in one, otherwise return
with an error (this avoids a flaw in the interface) */
if ((int)len < 0) {
gz_error(state, Z_STREAM_ERROR, "request does not fit in an int");
return -1;
}
/* read len or fewer bytes to buf */
len = (unsigned)gz_read(state, buf, len);
/* check for an error */
if (len == 0) {
if (state->err != Z_OK && state->err != Z_BUF_ERROR)
return -1;
if (state->again) {
/* non-blocking input stalled after some input was read, but no
uncompressed bytes were produced -- let the application know
this isn't EOF */
gz_error(state, Z_ERRNO, zstrerror());
return -1;
}
}
/* return the number of bytes read */
return (int)len;
}
/* -- see zlib.h -- */
z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems,
gzFile file) {
z_size_t len;
gz_statep state;
/* get internal structure and check that it's for reading */
if (file == NULL)
return 0;
state = (gz_statep)file;
if (state->mode != GZ_READ)
return 0;
/* check that there was no (serious) error */
if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again)
return 0;
gz_error(state, Z_OK, NULL);
/* compute bytes to read -- error on overflow */
len = nitems * size;
if (size && len / size != nitems) {
gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t");
return 0;
}
|
| ︙ | ︙ | |||
405 406 407 408 409 410 411 |
#else
# undef gzgetc
#endif
int ZEXPORT gzgetc(gzFile file) {
unsigned char buf[1];
gz_statep state;
| | > > | < | > | > > | | < | > | < < | < | 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 |
#else
# undef gzgetc
#endif
int ZEXPORT gzgetc(gzFile file) {
unsigned char buf[1];
gz_statep state;
/* get internal structure and check that it's for reading */
if (file == NULL)
return -1;
state = (gz_statep)file;
if (state->mode != GZ_READ)
return -1;
/* check that there was no (serious) error */
if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again)
return -1;
gz_error(state, Z_OK, NULL);
/* try output buffer (no need to check for skip request) */
if (state->x.have) {
state->x.have--;
state->x.pos++;
return *(state->x.next)++;
}
/* nothing there -- try gz_read() */
return gz_read(state, buf, 1) < 1 ? -1 : buf[0];
}
int ZEXPORT gzgetc_(gzFile file) {
return gzgetc(file);
}
/* -- see zlib.h -- */
int ZEXPORT gzungetc(int c, gzFile file) {
gz_statep state;
/* get internal structure and check that it's for reading */
if (file == NULL)
return -1;
state = (gz_statep)file;
if (state->mode != GZ_READ)
return -1;
/* in case this was just opened, set up the input buffer */
if (state->how == LOOK && state->x.have == 0)
(void)gz_look(state);
/* check that there was no (serious) error */
if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again)
return -1;
gz_error(state, Z_OK, NULL);
/* process a skip request */
if (state->skip && gz_skip(state) == -1)
return -1;
/* can't push EOF */
if (c < 0)
return -1;
/* if output buffer empty, put byte at end (allows more pushing) */
if (state->x.have == 0) {
|
| ︙ | ︙ | |||
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 |
return -1;
}
/* slide output data if needed and insert byte before existing data */
if (state->x.next == state->out) {
unsigned char *src = state->out + state->x.have;
unsigned char *dest = state->out + (state->size << 1);
while (src > state->out)
*--dest = *--src;
state->x.next = dest;
}
state->x.have++;
state->x.next--;
state->x.next[0] = (unsigned char)c;
state->x.pos--;
state->past = 0;
return c;
}
/* -- see zlib.h -- */
char * ZEXPORT gzgets(gzFile file, char *buf, int len) {
unsigned left, n;
char *str;
unsigned char *eol;
gz_statep state;
| > | > > > | < | > | < < | | | | < < | > > | | 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 |
return -1;
}
/* slide output data if needed and insert byte before existing data */
if (state->x.next == state->out) {
unsigned char *src = state->out + state->x.have;
unsigned char *dest = state->out + (state->size << 1);
while (src > state->out)
*--dest = *--src;
state->x.next = dest;
}
state->x.have++;
state->x.next--;
state->x.next[0] = (unsigned char)c;
state->x.pos--;
state->past = 0;
return c;
}
/* -- see zlib.h -- */
char * ZEXPORT gzgets(gzFile file, char *buf, int len) {
unsigned left, n;
char *str;
unsigned char *eol;
gz_statep state;
/* check parameters, get internal structure, and check that it's for
reading */
if (file == NULL || buf == NULL || len < 1)
return NULL;
state = (gz_statep)file;
if (state->mode != GZ_READ)
return NULL;
/* check that there was no (serious) error */
if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again)
return NULL;
gz_error(state, Z_OK, NULL);
/* process a skip request */
if (state->skip && gz_skip(state) == -1)
return NULL;
/* copy output up to a new line, len-1 bytes, or there is no more output,
whichever comes first */
str = buf;
left = (unsigned)len - 1;
if (left) do {
/* assure that something is in the output buffer */
if (state->x.have == 0 && gz_fetch(state) == -1)
break; /* error */
if (state->x.have == 0) { /* end of file */
state->past = 1; /* read past end */
break; /* return what we have */
}
/* look for end-of-line in current output buffer */
n = state->x.have > left ? left : state->x.have;
eol = (unsigned char *)memchr(state->x.next, '\n', n);
if (eol != NULL)
n = (unsigned)(eol - state->x.next) + 1;
/* copy through end-of-line, or remainder if not found */
memcpy(buf, state->x.next, n);
state->x.have -= n;
state->x.next += n;
state->x.pos += n;
left -= n;
buf += n;
} while (left && eol == NULL);
/* append a terminating zero to the string (we don't check for a zero in
the contents, let the user worry about that) -- return the terminated
string, or if nothing was read, NULL */
if (buf == str)
return NULL;
buf[0] = 0;
return str;
}
/* -- see zlib.h -- */
|
| ︙ | ︙ | |||
566 567 568 569 570 571 572 |
/* if the state is not known, but we can find out, then do so (this is
mainly for right after a gzopen() or gzdopen()) */
if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0)
(void)gz_look(state);
/* return 1 if transparent, 0 if processing a gzip stream */
| | | < < | 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 |
/* if the state is not known, but we can find out, then do so (this is
mainly for right after a gzopen() or gzdopen()) */
if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0)
(void)gz_look(state);
/* return 1 if transparent, 0 if processing a gzip stream */
return state->direct == 1;
}
/* -- see zlib.h -- */
int ZEXPORT gzclose_r(gzFile file) {
int ret, err;
gz_statep state;
/* get internal structure and check that it's for reading */
if (file == NULL)
return Z_STREAM_ERROR;
state = (gz_statep)file;
if (state->mode != GZ_READ)
return Z_STREAM_ERROR;
/* free memory and close file */
if (state->size) {
inflateEnd(&(state->strm));
free(state->out);
|
| ︙ | ︙ |
Changes to compat/zlib/gzwrite.c.
1 | /* gzwrite.c -- zlib functions for writing gzip files | | | 1 2 3 4 5 6 7 8 9 | /* gzwrite.c -- zlib functions for writing gzip files * Copyright (C) 2004-2026 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #include "gzguts.h" /* Initialize state for writing a gzip file. Mark initialization by setting state->size to non-zero. Return -1 on a memory allocation failure, or 0 on |
| ︙ | ︙ | |||
70 71 72 73 74 75 76 77 |
/* allocate memory if this is the first time through */
if (state->size == 0 && gz_init(state) == -1)
return -1;
/* write directly if requested */
if (state->direct) {
while (strm->avail_in) {
put = strm->avail_in > max ? max : strm->avail_in;
| > > | > > | > | > > | > > | 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
/* allocate memory if this is the first time through */
if (state->size == 0 && gz_init(state) == -1)
return -1;
/* write directly if requested */
if (state->direct) {
while (strm->avail_in) {
errno = 0;
state->again = 0;
put = strm->avail_in > max ? max : strm->avail_in;
writ = (int)write(state->fd, strm->next_in, put);
if (writ < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK)
state->again = 1;
gz_error(state, Z_ERRNO, zstrerror());
return -1;
}
strm->avail_in -= (unsigned)writ;
strm->next_in += writ;
}
return 0;
}
/* check for a pending reset */
if (state->reset) {
/* don't start a new gzip member unless there is data to write and
we're not flushing */
if (strm->avail_in == 0 && flush == Z_NO_FLUSH)
return 0;
deflateReset(strm);
state->reset = 0;
}
/* run deflate() on provided input until it produces no more output */
ret = Z_OK;
do {
/* write out current buffer contents if full, or if flushing, but if
doing Z_FINISH then don't write until we get to Z_STREAM_END */
if (strm->avail_out == 0 || (flush != Z_NO_FLUSH &&
(flush != Z_FINISH || ret == Z_STREAM_END))) {
while (strm->next_out > state->x.next) {
errno = 0;
state->again = 0;
put = strm->next_out - state->x.next > (int)max ? max :
(unsigned)(strm->next_out - state->x.next);
writ = (int)write(state->fd, state->x.next, put);
if (writ < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK)
state->again = 1;
gz_error(state, Z_ERRNO, zstrerror());
return -1;
}
state->x.next += writ;
}
if (strm->avail_out == 0) {
strm->avail_out = state->size;
|
| ︙ | ︙ | |||
134 135 136 137 138 139 140 |
if (flush == Z_FINISH)
state->reset = 1;
/* all done, no errors */
return 0;
}
| | | > > | | | | | | > > > | | < | > > > | < < | < | > > | | < > > > > < < > > | | > | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
if (flush == Z_FINISH)
state->reset = 1;
/* all done, no errors */
return 0;
}
/* Compress state->skip (> 0) zeros to output. Return -1 on a write error or
memory allocation failure by gz_comp(), or 0 on success. state->skip is
updated with the number of successfully written zeros, in case there is a
stall on a non-blocking write destination. */
local int gz_zero(gz_statep state) {
int first, ret;
unsigned n;
z_streamp strm = &(state->strm);
/* consume whatever's left in the input buffer */
if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
return -1;
/* compress state->skip zeros */
first = 1;
do {
n = GT_OFF(state->size) || (z_off64_t)state->size > state->skip ?
(unsigned)state->skip : state->size;
if (first) {
memset(state->in, 0, n);
first = 0;
}
strm->avail_in = n;
strm->next_in = state->in;
ret = gz_comp(state, Z_NO_FLUSH);
n -= strm->avail_in;
state->x.pos += n;
state->skip -= n;
if (ret == -1)
return -1;
} while (state->skip);
return 0;
}
/* Write len bytes from buf to file. Return the number of bytes written. If
the returned value is less than len, then there was an error. If the error
was a non-blocking stall, then the number of bytes consumed is returned.
For any other error, 0 is returned. */
local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) {
z_size_t put = len;
int ret;
/* if len is zero, avoid unnecessary operations */
if (len == 0)
return 0;
/* allocate memory if this is the first time through */
if (state->size == 0 && gz_init(state) == -1)
return 0;
/* check for seek request */
if (state->skip && gz_zero(state) == -1)
return 0;
/* for small len, copy to input buffer, otherwise compress directly */
if (len < state->size) {
/* copy to input buffer, compress when full */
for (;;) {
unsigned have, copy;
if (state->strm.avail_in == 0)
state->strm.next_in = state->in;
have = (unsigned)((state->strm.next_in + state->strm.avail_in) -
state->in);
copy = state->size - have;
if (copy > len)
copy = (unsigned)len;
memcpy(state->in + have, buf, copy);
state->strm.avail_in += copy;
state->x.pos += copy;
buf = (const char *)buf + copy;
len -= copy;
if (len == 0)
break;
if (gz_comp(state, Z_NO_FLUSH) == -1)
return state->again ? put - len : 0;
}
}
else {
/* consume whatever's left in the input buffer */
if (state->strm.avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
return 0;
/* directly compress user buffer to file */
state->strm.next_in = (z_const Bytef *)buf;
do {
unsigned n = (unsigned)-1;
if (n > len)
n = (unsigned)len;
state->strm.avail_in = n;
ret = gz_comp(state, Z_NO_FLUSH);
n -= state->strm.avail_in;
state->x.pos += n;
len -= n;
if (ret == -1)
return state->again ? put - len : 0;
} while (len);
}
/* input was all buffered or compressed */
return put;
}
/* -- see zlib.h -- */
int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) {
gz_statep state;
/* get internal structure */
if (file == NULL)
return 0;
state = (gz_statep)file;
/* check that we're writing and that there's no (serious) error */
if (state->mode != GZ_WRITE || (state->err != Z_OK && !state->again))
return 0;
gz_error(state, Z_OK, NULL);
/* since an int is returned, make sure len fits in one, otherwise return
with an error (this avoids a flaw in the interface) */
if ((int)len < 0) {
gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
return 0;
}
|
| ︙ | ︙ | |||
264 265 266 267 268 269 270 |
gz_statep state;
/* get internal structure */
if (file == NULL)
return 0;
state = (gz_statep)file;
| | | > | 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
gz_statep state;
/* get internal structure */
if (file == NULL)
return 0;
state = (gz_statep)file;
/* check that we're writing and that there's no (serious) error */
if (state->mode != GZ_WRITE || (state->err != Z_OK && !state->again))
return 0;
gz_error(state, Z_OK, NULL);
/* compute bytes to read -- error on overflow */
len = nitems * size;
if (size && len / size != nitems) {
gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t");
return 0;
}
|
| ︙ | ︙ | |||
292 293 294 295 296 297 298 |
/* get internal structure */
if (file == NULL)
return -1;
state = (gz_statep)file;
strm = &(state->strm);
| | | > | < < | < | 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
/* get internal structure */
if (file == NULL)
return -1;
state = (gz_statep)file;
strm = &(state->strm);
/* check that we're writing and that there's no (serious) error */
if (state->mode != GZ_WRITE || (state->err != Z_OK && !state->again))
return -1;
gz_error(state, Z_OK, NULL);
/* check for seek request */
if (state->skip && gz_zero(state) == -1)
return -1;
/* try writing to input buffer for speed (state->size == 0 if buffer not
initialized) */
if (state->size) {
if (strm->avail_in == 0)
strm->next_in = state->in;
have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
|
| ︙ | ︙ | |||
334 335 336 337 338 339 340 |
gz_statep state;
/* get internal structure */
if (file == NULL)
return -1;
state = (gz_statep)file;
| | | > > > > > > > > > > > > > > > > > | > > > > | > > > > > > > > > > > > | < | | > | < < | | < | | > > > > > > > > > > > > | 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
gz_statep state;
/* get internal structure */
if (file == NULL)
return -1;
state = (gz_statep)file;
/* check that we're writing and that there's no (serious) error */
if (state->mode != GZ_WRITE || (state->err != Z_OK && !state->again))
return -1;
gz_error(state, Z_OK, NULL);
/* write string */
len = strlen(s);
if ((int)len < 0 || (unsigned)len != len) {
gz_error(state, Z_STREAM_ERROR, "string length does not fit in int");
return -1;
}
put = gz_write(state, s, len);
return len && put == 0 ? -1 : (int)put;
}
#if (((!defined(STDC) && !defined(Z_HAVE_STDARG_H)) || !defined(NO_vsnprintf)) && \
(defined(STDC) || defined(Z_HAVE_STDARG_H) || !defined(NO_snprintf))) || \
defined(ZLIB_INSECURE)
/* If the second half of the input buffer is occupied, write out the contents.
If there is any input remaining due to a non-blocking stall on write, move
it to the start of the buffer. Return true if this did not open up the
second half of the buffer. state->err should be checked after this to
handle a gz_comp() error. */
local int gz_vacate(gz_statep state) {
z_streamp strm;
strm = &(state->strm);
if (strm->next_in + strm->avail_in <= state->in + state->size)
return 0;
(void)gz_comp(state, Z_NO_FLUSH);
if (strm->avail_in == 0) {
strm->next_in = state->in;
return 0;
}
memmove(state->in, strm->next_in, strm->avail_in);
strm->next_in = state->in;
return strm->avail_in > state->size;
}
#endif
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
#include <stdarg.h>
/* -- see zlib.h -- */
int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) {
#if defined(NO_vsnprintf) && !defined(ZLIB_INSECURE)
#warning "vsnprintf() not available -- gzprintf() stub returns Z_STREAM_ERROR"
#warning "you can recompile with ZLIB_INSECURE defined to use vsprintf()"
/* prevent use of insecure vsprintf(), unless purposefully requested */
(void)file, (void)format, (void)va;
return Z_STREAM_ERROR;
#else
int len, ret;
char *next;
gz_statep state;
z_streamp strm;
/* get internal structure */
if (file == NULL)
return Z_STREAM_ERROR;
state = (gz_statep)file;
strm = &(state->strm);
/* check that we're writing and that there's no (serious) error */
if (state->mode != GZ_WRITE || (state->err != Z_OK && !state->again))
return Z_STREAM_ERROR;
gz_error(state, Z_OK, NULL);
/* make sure we have some buffer space */
if (state->size == 0 && gz_init(state) == -1)
return state->err;
/* check for seek request */
if (state->skip && gz_zero(state) == -1)
return state->err;
/* do the printf() into the input buffer, put length in len -- the input
buffer is double-sized just for this function, so there should be
state->size bytes available after the current contents */
ret = gz_vacate(state);
if (state->err) {
if (ret && state->again) {
/* There was a non-blocking stall on write, resulting in the part
of the second half of the output buffer being occupied. Return
a Z_BUF_ERROR to let the application know that this gzprintf()
needs to be retried. */
gz_error(state, Z_BUF_ERROR, "stalled write on gzprintf");
}
if (!state->again)
return state->err;
}
if (strm->avail_in == 0)
strm->next_in = state->in;
next = (char *)(state->in + (strm->next_in - state->in) + strm->avail_in);
next[state->size - 1] = 0;
#ifdef NO_vsnprintf
# ifdef HAS_vsprintf_void
(void)vsprintf(next, format, va);
|
| ︙ | ︙ | |||
408 409 410 411 412 413 414 |
# endif
#endif
/* check that printf() results fit in buffer */
if (len == 0 || (unsigned)len >= state->size || next[state->size - 1] != 0)
return 0;
| | | | | | | < < < < > > > > > > > > > > > > | | > | | < < | < > > > > > > > > > > > > | 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 |
# endif
#endif
/* check that printf() results fit in buffer */
if (len == 0 || (unsigned)len >= state->size || next[state->size - 1] != 0)
return 0;
/* update buffer and position */
strm->avail_in += (unsigned)len;
state->x.pos += len;
/* write out buffer if more than half is occupied */
ret = gz_vacate(state);
if (state->err && !state->again)
return state->err;
return len;
#endif
}
int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) {
va_list va;
int ret;
va_start(va, format);
ret = gzvprintf(file, format, va);
va_end(va);
return ret;
}
#else /* !STDC && !Z_HAVE_STDARG_H */
/* -- see zlib.h -- */
int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3,
int a4, int a5, int a6, int a7, int a8, int a9, int a10,
int a11, int a12, int a13, int a14, int a15, int a16,
int a17, int a18, int a19, int a20) {
#if defined(NO_snprintf) && !defined(ZLIB_INSECURE)
#warning "snprintf() not available -- gzprintf() stub returns Z_STREAM_ERROR"
#warning "you can recompile with ZLIB_INSECURE defined to use sprintf()"
/* prevent use of insecure sprintf(), unless purposefully requested */
(void)file, (void)format, (void)a1, (void)a2, (void)a3, (void)a4, (void)a5,
(void)a6, (void)a7, (void)a8, (void)a9, (void)a10, (void)a11, (void)a12,
(void)a13, (void)a14, (void)a15, (void)a16, (void)a17, (void)a18,
(void)a19, (void)a20;
return Z_STREAM_ERROR;
#else
int ret;
unsigned len, left;
char *next;
gz_statep state;
z_streamp strm;
/* get internal structure */
if (file == NULL)
return Z_STREAM_ERROR;
state = (gz_statep)file;
strm = &(state->strm);
/* check that can really pass pointer in ints */
if (sizeof(int) != sizeof(void *))
return Z_STREAM_ERROR;
/* check that we're writing and that there's no (serious) error */
if (state->mode != GZ_WRITE || (state->err != Z_OK && !state->again))
return Z_STREAM_ERROR;
gz_error(state, Z_OK, NULL);
/* make sure we have some buffer space */
if (state->size == 0 && gz_init(state) == -1)
return state->err;
/* check for seek request */
if (state->skip && gz_zero(state) == -1)
return state->err;
/* do the printf() into the input buffer, put length in len -- the input
buffer is double-sized just for this function, so there is guaranteed to
be state->size bytes available after the current contents */
ret = gz_vacate(state);
if (state->err) {
if (ret && state->again) {
/* There was a non-blocking stall on write, resulting in the part
of the second half of the output buffer being occupied. Return
a Z_BUF_ERROR to let the application know that this gzprintf()
needs to be retried. */
gz_error(state, Z_BUF_ERROR, "stalled write on gzprintf");
}
if (!state->again)
return state->err;
}
if (strm->avail_in == 0)
strm->next_in = state->in;
next = (char *)(strm->next_in + strm->avail_in);
next[state->size - 1] = 0;
#ifdef NO_snprintf
# ifdef HAS_sprintf_void
sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12,
|
| ︙ | ︙ | |||
506 507 508 509 510 511 512 |
/* check that printf() results fit in buffer */
if (len == 0 || len >= state->size || next[state->size - 1] != 0)
return 0;
/* update buffer and position, compress first half if past that */
strm->avail_in += len;
state->x.pos += len;
| | | | | | < < < < > | | > | < < | < | | > > | < < | < | 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 |
/* check that printf() results fit in buffer */
if (len == 0 || len >= state->size || next[state->size - 1] != 0)
return 0;
/* update buffer and position, compress first half if past that */
strm->avail_in += len;
state->x.pos += len;
/* write out buffer if more than half is occupied */
ret = gz_vacate(state);
if (state->err && !state->again)
return state->err;
return (int)len;
#endif
}
#endif
/* -- see zlib.h -- */
int ZEXPORT gzflush(gzFile file, int flush) {
gz_statep state;
/* get internal structure */
if (file == NULL)
return Z_STREAM_ERROR;
state = (gz_statep)file;
/* check that we're writing and that there's no (serious) error */
if (state->mode != GZ_WRITE || (state->err != Z_OK && !state->again))
return Z_STREAM_ERROR;
gz_error(state, Z_OK, NULL);
/* check flush parameter */
if (flush < 0 || flush > Z_FINISH)
return Z_STREAM_ERROR;
/* check for seek request */
if (state->skip && gz_zero(state) == -1)
return state->err;
/* compress remaining data with requested flush */
(void)gz_comp(state, flush);
return state->err;
}
/* -- see zlib.h -- */
int ZEXPORT gzsetparams(gzFile file, int level, int strategy) {
gz_statep state;
z_streamp strm;
/* get internal structure */
if (file == NULL)
return Z_STREAM_ERROR;
state = (gz_statep)file;
strm = &(state->strm);
/* check that we're compressing and that there's no (serious) error */
if (state->mode != GZ_WRITE || (state->err != Z_OK && !state->again) ||
state->direct)
return Z_STREAM_ERROR;
gz_error(state, Z_OK, NULL);
/* if no change is requested, then do nothing */
if (level == state->level && strategy == state->strategy)
return Z_OK;
/* check for seek request */
if (state->skip && gz_zero(state) == -1)
return state->err;
/* change compression parameters for subsequent input */
if (state->size) {
/* flush previous input with previous parameters before changing */
if (strm->avail_in && gz_comp(state, Z_BLOCK) == -1)
return state->err;
deflateParams(strm, level, strategy);
|
| ︙ | ︙ | |||
602 603 604 605 606 607 608 |
state = (gz_statep)file;
/* check that we're writing */
if (state->mode != GZ_WRITE)
return Z_STREAM_ERROR;
/* check for seek request */
| | < < | < | 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 |
state = (gz_statep)file;
/* check that we're writing */
if (state->mode != GZ_WRITE)
return Z_STREAM_ERROR;
/* check for seek request */
if (state->skip && gz_zero(state) == -1)
ret = state->err;
/* flush, free memory, and close file */
if (gz_comp(state, Z_FINISH) == -1)
ret = state->err;
if (state->size) {
if (!state->direct) {
(void)deflateEnd(&(state->strm));
|
| ︙ | ︙ |
Changes to compat/zlib/infback.c.
1 | /* infback.c -- inflate using a call-back interface | | | 1 2 3 4 5 6 7 8 9 | /* infback.c -- inflate using a call-back interface * Copyright (C) 1995-2026 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* This code is largely copied from inflate.c. Normally either infback.o or inflate.o would be linked into an application--not both. The interface with inffast.c is retained so that optimized assembler-coded versions of |
| ︙ | ︙ | |||
42 43 44 45 46 47 48 |
strm->opaque = (voidpf)0;
#endif
}
if (strm->zfree == (free_func)0)
#ifdef Z_SOLO
return Z_STREAM_ERROR;
#else
| | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 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 |
strm->opaque = (voidpf)0;
#endif
}
if (strm->zfree == (free_func)0)
#ifdef Z_SOLO
return Z_STREAM_ERROR;
#else
strm->zfree = zcfree;
#endif
state = (struct inflate_state FAR *)ZALLOC(strm, 1,
sizeof(struct inflate_state));
if (state == Z_NULL) return Z_MEM_ERROR;
Tracev((stderr, "inflate: allocated\n"));
strm->state = (struct internal_state FAR *)state;
state->dmax = 32768U;
state->wbits = (uInt)windowBits;
state->wsize = 1U << windowBits;
state->window = window;
state->wnext = 0;
state->whave = 0;
state->sane = 1;
return Z_OK;
}
/* Macros for inflateBack(): */
/* Load returned state from inflate_fast() */
#define LOAD() \
do { \
put = strm->next_out; \
left = strm->avail_out; \
|
| ︙ | ︙ | |||
289 290 291 292 293 294 295 |
switch (BITS(2)) {
case 0: /* stored block */
Tracev((stderr, "inflate: stored block%s\n",
state->last ? " (last)" : ""));
state->mode = STORED;
break;
case 1: /* fixed block */
| | | | | | 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
switch (BITS(2)) {
case 0: /* stored block */
Tracev((stderr, "inflate: stored block%s\n",
state->last ? " (last)" : ""));
state->mode = STORED;
break;
case 1: /* fixed block */
inflate_fixed(state);
Tracev((stderr, "inflate: fixed codes block%s\n",
state->last ? " (last)" : ""));
state->mode = LEN; /* decode codes */
break;
case 2: /* dynamic block */
Tracev((stderr, "inflate: dynamic codes block%s\n",
state->last ? " (last)" : ""));
state->mode = TABLE;
break;
default:
strm->msg = (z_const char *)"invalid block type";
state->mode = BAD;
}
DROPBITS(2);
break;
case STORED:
/* get and verify stored block length */
BYTEBITS(); /* go to byte boundary */
NEEDBITS(32);
if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
strm->msg = (z_const char *)"invalid stored block lengths";
state->mode = BAD;
break;
}
state->length = (unsigned)hold & 0xffff;
Tracev((stderr, "inflate: stored length %u\n",
state->length));
INITBITS();
|
| ︙ | ︙ | |||
349 350 351 352 353 354 355 |
DROPBITS(5);
state->ndist = BITS(5) + 1;
DROPBITS(5);
state->ncode = BITS(4) + 4;
DROPBITS(4);
#ifndef PKZIP_BUG_WORKAROUND
if (state->nlen > 286 || state->ndist > 30) {
| > | | 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
DROPBITS(5);
state->ndist = BITS(5) + 1;
DROPBITS(5);
state->ncode = BITS(4) + 4;
DROPBITS(4);
#ifndef PKZIP_BUG_WORKAROUND
if (state->nlen > 286 || state->ndist > 30) {
strm->msg = (z_const char *)
"too many length or distance symbols";
state->mode = BAD;
break;
}
#endif
Tracev((stderr, "inflate: table sizes ok\n"));
/* get code length code lengths (not a typo) */
|
| ︙ | ︙ | |||
371 372 373 374 375 376 377 |
state->lens[order[state->have++]] = 0;
state->next = state->codes;
state->lencode = (code const FAR *)(state->next);
state->lenbits = 7;
ret = inflate_table(CODES, state->lens, 19, &(state->next),
&(state->lenbits), state->work);
if (ret) {
| | | 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
state->lens[order[state->have++]] = 0;
state->next = state->codes;
state->lencode = (code const FAR *)(state->next);
state->lenbits = 7;
ret = inflate_table(CODES, state->lens, 19, &(state->next),
&(state->lenbits), state->work);
if (ret) {
strm->msg = (z_const char *)"invalid code lengths set";
state->mode = BAD;
break;
}
Tracev((stderr, "inflate: code lengths ok\n"));
/* get length and distance code code lengths */
state->have = 0;
|
| ︙ | ︙ | |||
394 395 396 397 398 399 400 |
state->lens[state->have++] = here.val;
}
else {
if (here.val == 16) {
NEEDBITS(here.bits + 2);
DROPBITS(here.bits);
if (state->have == 0) {
| > | | 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
state->lens[state->have++] = here.val;
}
else {
if (here.val == 16) {
NEEDBITS(here.bits + 2);
DROPBITS(here.bits);
if (state->have == 0) {
strm->msg = (z_const char *)
"invalid bit length repeat";
state->mode = BAD;
break;
}
len = (unsigned)(state->lens[state->have - 1]);
copy = 3 + BITS(2);
DROPBITS(2);
}
|
| ︙ | ︙ | |||
417 418 419 420 421 422 423 |
NEEDBITS(here.bits + 7);
DROPBITS(here.bits);
len = 0;
copy = 11 + BITS(7);
DROPBITS(7);
}
if (state->have + copy > state->nlen + state->ndist) {
| > | > | | | | 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 |
NEEDBITS(here.bits + 7);
DROPBITS(here.bits);
len = 0;
copy = 11 + BITS(7);
DROPBITS(7);
}
if (state->have + copy > state->nlen + state->ndist) {
strm->msg = (z_const char *)
"invalid bit length repeat";
state->mode = BAD;
break;
}
while (copy--)
state->lens[state->have++] = (unsigned short)len;
}
}
/* handle error breaks in while */
if (state->mode == BAD) break;
/* check for end-of-block code (better have one) */
if (state->lens[256] == 0) {
strm->msg = (z_const char *)
"invalid code -- missing end-of-block";
state->mode = BAD;
break;
}
/* build code tables -- note: do not change the lenbits or distbits
values here (9 and 6) without reading the comments in inftrees.h
concerning the ENOUGH constants, which depend on those values */
state->next = state->codes;
state->lencode = (code const FAR *)(state->next);
state->lenbits = 9;
ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
&(state->lenbits), state->work);
if (ret) {
strm->msg = (z_const char *)"invalid literal/lengths set";
state->mode = BAD;
break;
}
state->distcode = (code const FAR *)(state->next);
state->distbits = 6;
ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
&(state->next), &(state->distbits), state->work);
if (ret) {
strm->msg = (z_const char *)"invalid distances set";
state->mode = BAD;
break;
}
Tracev((stderr, "inflate: codes ok\n"));
state->mode = LEN;
/* fallthrough */
|
| ︙ | ︙ | |||
513 514 515 516 517 518 519 |
Tracevv((stderr, "inflate: end of block\n"));
state->mode = TYPE;
break;
}
/* invalid code */
if (here.op & 64) {
| | | 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
Tracevv((stderr, "inflate: end of block\n"));
state->mode = TYPE;
break;
}
/* invalid code */
if (here.op & 64) {
strm->msg = (z_const char *)"invalid literal/length code";
state->mode = BAD;
break;
}
/* length code -- get extra bits, if any */
state->extra = (unsigned)(here.op) & 15;
if (state->extra != 0) {
|
| ︙ | ︙ | |||
545 546 547 548 549 550 551 |
if ((unsigned)(last.bits + here.bits) <= bits) break;
PULLBYTE();
}
DROPBITS(last.bits);
}
DROPBITS(here.bits);
if (here.op & 64) {
| | | | 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
if ((unsigned)(last.bits + here.bits) <= bits) break;
PULLBYTE();
}
DROPBITS(last.bits);
}
DROPBITS(here.bits);
if (here.op & 64) {
strm->msg = (z_const char *)"invalid distance code";
state->mode = BAD;
break;
}
state->offset = (unsigned)here.val;
/* get distance extra bits, if any */
state->extra = (unsigned)(here.op) & 15;
if (state->extra != 0) {
NEEDBITS(state->extra);
state->offset += BITS(state->extra);
DROPBITS(state->extra);
}
if (state->offset > state->wsize - (state->whave < state->wsize ?
left : 0)) {
strm->msg = (z_const char *)"invalid distance too far back";
state->mode = BAD;
break;
}
Tracevv((stderr, "inflate: distance %u\n", state->offset));
/* copy match from window to output */
do {
|
| ︙ | ︙ |
Changes to compat/zlib/inffast.c.
1 | /* inffast.c -- fast decoding | | | 1 2 3 4 5 6 7 8 9 | /* inffast.c -- fast decoding * Copyright (C) 1995-2026 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #include "zutil.h" #include "inftrees.h" #include "inflate.h" #include "inffast.h" |
| ︙ | ︙ | |||
151 152 153 154 155 156 157 |
hold += (unsigned long)(*in++) << bits;
bits += 8;
}
}
dist += (unsigned)hold & ((1U << op) - 1);
#ifdef INFLATE_STRICT
if (dist > dmax) {
| > | | | | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
hold += (unsigned long)(*in++) << bits;
bits += 8;
}
}
dist += (unsigned)hold & ((1U << op) - 1);
#ifdef INFLATE_STRICT
if (dist > dmax) {
strm->msg = (z_const char *)
"invalid distance too far back";
state->mode = BAD;
break;
}
#endif
hold >>= op;
bits -= op;
Tracevv((stderr, "inflate: distance %u\n", dist));
op = (unsigned)(out - beg); /* max distance in output */
if (dist > op) { /* see if copy from window */
op = dist - op; /* distance back in window */
if (op > whave) {
if (state->sane) {
strm->msg = (z_const char *)
"invalid distance too far back";
state->mode = BAD;
break;
}
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
if (len <= op - whave) {
do {
*out++ = 0;
|
| ︙ | ︙ | |||
261 262 263 264 265 266 267 |
}
}
else if ((op & 64) == 0) { /* 2nd level distance code */
here = dcode + here->val + (hold & ((1U << op) - 1));
goto dodist;
}
else {
| | | | 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
}
}
else if ((op & 64) == 0) { /* 2nd level distance code */
here = dcode + here->val + (hold & ((1U << op) - 1));
goto dodist;
}
else {
strm->msg = (z_const char *)"invalid distance code";
state->mode = BAD;
break;
}
}
else if ((op & 64) == 0) { /* 2nd level length code */
here = lcode + here->val + (hold & ((1U << op) - 1));
goto dolen;
}
else if (op & 32) { /* end-of-block */
Tracevv((stderr, "inflate: end of block\n"));
state->mode = TYPE;
break;
}
else {
strm->msg = (z_const char *)"invalid literal/length code";
state->mode = BAD;
break;
}
} while (in < last && out < end);
/* return unused bytes (on entry, bits < 8, so in won't go too far back) */
len = bits >> 3;
|
| ︙ | ︙ |
Changes to compat/zlib/inffixed.h.
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 2 3 4 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 |
/* inffixed.h -- table for decoding fixed codes
* Generated automatically by makefixed().
*/
/* WARNING: this file should *not* be used by applications.
It is part of the implementation of this library and is
subject to change. Applications should only use zlib.h.
*/
static const code lenfix[512] = {
{96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
{0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
{0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
{0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
{0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
{21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
{0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
{0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
{18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
{0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
{0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
{0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
{20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
{0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
{0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
{0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
{16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
{0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
{0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
{0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
{0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
{0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
{0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
{0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
{17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
{0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
{0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
{0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
{19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
{0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
{0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
{0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
{16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
{0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
{0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
{0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
{0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
{20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
{0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
{0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
{17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
{0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
{0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
{0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
{20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
{0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
{0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
{0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
{16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
{0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
{0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
{0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
{0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
{0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
{0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
{0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
{16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
{0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
{0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
{0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
{19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
{0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
{0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
{0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
{16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
{0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
{0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
{0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
{0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
{64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
{0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
{0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
{18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
{0,9,255}
};
static const code distfix[32] = {
{16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
{21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
{18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
{19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
{16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
{22,5,193},{64,5,0}
};
|
Changes to compat/zlib/inflate.c.
1 | /* inflate.c -- zlib decompression | | | 1 2 3 4 5 6 7 8 9 | /* inflate.c -- zlib decompression * Copyright (C) 1995-2026 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* * Change history: * * 1.2.beta0 24 Nov 2002 |
| ︙ | ︙ | |||
81 82 83 84 85 86 87 | */ #include "zutil.h" #include "inftrees.h" #include "inflate.h" #include "inffast.h" | < < < < < < > | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
*/
#include "zutil.h"
#include "inftrees.h"
#include "inflate.h"
#include "inffast.h"
local int inflateStateCheck(z_streamp strm) {
struct inflate_state FAR *state;
if (strm == Z_NULL ||
strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
return 1;
state = (struct inflate_state FAR *)strm->state;
if (state == Z_NULL || state->strm != strm ||
state->mode < HEAD || state->mode > SYNC)
return 1;
return 0;
}
int ZEXPORT inflateResetKeep(z_streamp strm) {
struct inflate_state FAR *state;
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
strm->total_in = strm->total_out = state->total = 0;
strm->msg = Z_NULL;
strm->data_type = 0;
if (state->wrap) /* to support ill-conceived Java test suite */
strm->adler = state->wrap & 1;
state->mode = HEAD;
state->last = 0;
state->havedict = 0;
state->flags = -1;
state->dmax = 32768U;
|
| ︙ | ︙ | |||
198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
return Z_STREAM_ERROR;
#else
strm->zfree = zcfree;
#endif
state = (struct inflate_state FAR *)
ZALLOC(strm, 1, sizeof(struct inflate_state));
if (state == Z_NULL) return Z_MEM_ERROR;
Tracev((stderr, "inflate: allocated\n"));
strm->state = (struct internal_state FAR *)state;
state->strm = strm;
state->window = Z_NULL;
state->mode = HEAD; /* to pass state test in inflateReset2() */
ret = inflateReset2(strm, windowBits);
if (ret != Z_OK) {
| > | 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
return Z_STREAM_ERROR;
#else
strm->zfree = zcfree;
#endif
state = (struct inflate_state FAR *)
ZALLOC(strm, 1, sizeof(struct inflate_state));
if (state == Z_NULL) return Z_MEM_ERROR;
zmemzero(state, sizeof(struct inflate_state));
Tracev((stderr, "inflate: allocated\n"));
strm->state = (struct internal_state FAR *)state;
state->strm = strm;
state->window = Z_NULL;
state->mode = HEAD; /* to pass state test in inflateReset2() */
ret = inflateReset2(strm, windowBits);
if (ret != Z_OK) {
|
| ︙ | ︙ | |||
230 231 232 233 234 235 236 |
if (bits < 0) {
state->hold = 0;
state->bits = 0;
return Z_OK;
}
if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR;
value &= (1L << bits) - 1;
| | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
if (bits < 0) {
state->hold = 0;
state->bits = 0;
return Z_OK;
}
if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR;
value &= (1L << bits) - 1;
state->hold += (unsigned long)value << state->bits;
state->bits += (uInt)bits;
return Z_OK;
}
/*
Update the window with the last wsize (normally 32K) bytes written before
returning. If window does not exist yet, create it. This is only called
when a window is already in use, or when output has been written during this
inflate call, but the end of the deflate stream has not been reached yet.
It is also called to create a window for dictionary data when a dictionary
is loaded.
|
| ︙ | ︙ | |||
638 639 640 641 642 643 644 |
if (state->head != Z_NULL)
state->head->done = -1;
if (!(state->wrap & 1) || /* check if zlib header allowed */
#else
if (
#endif
((BITS(8) << 8) + (hold >> 8)) % 31) {
| | | | | | | 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 |
if (state->head != Z_NULL)
state->head->done = -1;
if (!(state->wrap & 1) || /* check if zlib header allowed */
#else
if (
#endif
((BITS(8) << 8) + (hold >> 8)) % 31) {
strm->msg = (z_const char *)"incorrect header check";
state->mode = BAD;
break;
}
if (BITS(4) != Z_DEFLATED) {
strm->msg = (z_const char *)"unknown compression method";
state->mode = BAD;
break;
}
DROPBITS(4);
len = BITS(4) + 8;
if (state->wbits == 0)
state->wbits = len;
if (len > 15 || len > state->wbits) {
strm->msg = (z_const char *)"invalid window size";
state->mode = BAD;
break;
}
state->dmax = 1U << len;
state->flags = 0; /* indicate zlib header */
Tracev((stderr, "inflate: zlib header ok\n"));
strm->adler = state->check = adler32(0L, Z_NULL, 0);
state->mode = hold & 0x200 ? DICTID : TYPE;
INITBITS();
break;
#ifdef GUNZIP
case FLAGS:
NEEDBITS(16);
state->flags = (int)(hold);
if ((state->flags & 0xff) != Z_DEFLATED) {
strm->msg = (z_const char *)"unknown compression method";
state->mode = BAD;
break;
}
if (state->flags & 0xe000) {
strm->msg = (z_const char *)"unknown header flags set";
state->mode = BAD;
break;
}
if (state->head != Z_NULL)
state->head->text = (int)((hold >> 8) & 1);
if ((state->flags & 0x0200) && (state->wrap & 4))
CRC2(state->check, hold);
|
| ︙ | ︙ | |||
789 790 791 792 793 794 795 |
state->head->comment = Z_NULL;
state->mode = HCRC;
/* fallthrough */
case HCRC:
if (state->flags & 0x0200) {
NEEDBITS(16);
if ((state->wrap & 4) && hold != (state->check & 0xffff)) {
| | | 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 |
state->head->comment = Z_NULL;
state->mode = HCRC;
/* fallthrough */
case HCRC:
if (state->flags & 0x0200) {
NEEDBITS(16);
if ((state->wrap & 4) && hold != (state->check & 0xffff)) {
strm->msg = (z_const char *)"header crc mismatch";
state->mode = BAD;
break;
}
INITBITS();
}
if (state->head != Z_NULL) {
state->head->hcrc = (int)((state->flags >> 9) & 1);
|
| ︙ | ︙ | |||
836 837 838 839 840 841 842 |
switch (BITS(2)) {
case 0: /* stored block */
Tracev((stderr, "inflate: stored block%s\n",
state->last ? " (last)" : ""));
state->mode = STORED;
break;
case 1: /* fixed block */
| | | | | | 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 |
switch (BITS(2)) {
case 0: /* stored block */
Tracev((stderr, "inflate: stored block%s\n",
state->last ? " (last)" : ""));
state->mode = STORED;
break;
case 1: /* fixed block */
inflate_fixed(state);
Tracev((stderr, "inflate: fixed codes block%s\n",
state->last ? " (last)" : ""));
state->mode = LEN_; /* decode codes */
if (flush == Z_TREES) {
DROPBITS(2);
goto inf_leave;
}
break;
case 2: /* dynamic block */
Tracev((stderr, "inflate: dynamic codes block%s\n",
state->last ? " (last)" : ""));
state->mode = TABLE;
break;
default:
strm->msg = (z_const char *)"invalid block type";
state->mode = BAD;
}
DROPBITS(2);
break;
case STORED:
BYTEBITS(); /* go to byte boundary */
NEEDBITS(32);
if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
strm->msg = (z_const char *)"invalid stored block lengths";
state->mode = BAD;
break;
}
state->length = (unsigned)hold & 0xffff;
Tracev((stderr, "inflate: stored length %u\n",
state->length));
INITBITS();
|
| ︙ | ︙ | |||
901 902 903 904 905 906 907 |
DROPBITS(5);
state->ndist = BITS(5) + 1;
DROPBITS(5);
state->ncode = BITS(4) + 4;
DROPBITS(4);
#ifndef PKZIP_BUG_WORKAROUND
if (state->nlen > 286 || state->ndist > 30) {
| > | | | | 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 |
DROPBITS(5);
state->ndist = BITS(5) + 1;
DROPBITS(5);
state->ncode = BITS(4) + 4;
DROPBITS(4);
#ifndef PKZIP_BUG_WORKAROUND
if (state->nlen > 286 || state->ndist > 30) {
strm->msg = (z_const char *)
"too many length or distance symbols";
state->mode = BAD;
break;
}
#endif
Tracev((stderr, "inflate: table sizes ok\n"));
state->have = 0;
state->mode = LENLENS;
/* fallthrough */
case LENLENS:
while (state->have < state->ncode) {
NEEDBITS(3);
state->lens[order[state->have++]] = (unsigned short)BITS(3);
DROPBITS(3);
}
while (state->have < 19)
state->lens[order[state->have++]] = 0;
state->next = state->codes;
state->lencode = state->distcode = (const code FAR *)(state->next);
state->lenbits = 7;
ret = inflate_table(CODES, state->lens, 19, &(state->next),
&(state->lenbits), state->work);
if (ret) {
strm->msg = (z_const char *)"invalid code lengths set";
state->mode = BAD;
break;
}
Tracev((stderr, "inflate: code lengths ok\n"));
state->have = 0;
state->mode = CODELENS;
/* fallthrough */
|
| ︙ | ︙ | |||
948 949 950 951 952 953 954 |
state->lens[state->have++] = here.val;
}
else {
if (here.val == 16) {
NEEDBITS(here.bits + 2);
DROPBITS(here.bits);
if (state->have == 0) {
| > | | 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 |
state->lens[state->have++] = here.val;
}
else {
if (here.val == 16) {
NEEDBITS(here.bits + 2);
DROPBITS(here.bits);
if (state->have == 0) {
strm->msg = (z_const char *)
"invalid bit length repeat";
state->mode = BAD;
break;
}
len = state->lens[state->have - 1];
copy = 3 + BITS(2);
DROPBITS(2);
}
|
| ︙ | ︙ | |||
971 972 973 974 975 976 977 |
NEEDBITS(here.bits + 7);
DROPBITS(here.bits);
len = 0;
copy = 11 + BITS(7);
DROPBITS(7);
}
if (state->have + copy > state->nlen + state->ndist) {
| > | > | | | | 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 |
NEEDBITS(here.bits + 7);
DROPBITS(here.bits);
len = 0;
copy = 11 + BITS(7);
DROPBITS(7);
}
if (state->have + copy > state->nlen + state->ndist) {
strm->msg = (z_const char *)
"invalid bit length repeat";
state->mode = BAD;
break;
}
while (copy--)
state->lens[state->have++] = (unsigned short)len;
}
}
/* handle error breaks in while */
if (state->mode == BAD) break;
/* check for end-of-block code (better have one) */
if (state->lens[256] == 0) {
strm->msg = (z_const char *)
"invalid code -- missing end-of-block";
state->mode = BAD;
break;
}
/* build code tables -- note: do not change the lenbits or distbits
values here (9 and 6) without reading the comments in inftrees.h
concerning the ENOUGH constants, which depend on those values */
state->next = state->codes;
state->lencode = (const code FAR *)(state->next);
state->lenbits = 9;
ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
&(state->lenbits), state->work);
if (ret) {
strm->msg = (z_const char *)"invalid literal/lengths set";
state->mode = BAD;
break;
}
state->distcode = (const code FAR *)(state->next);
state->distbits = 6;
ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
&(state->next), &(state->distbits), state->work);
if (ret) {
strm->msg = (z_const char *)"invalid distances set";
state->mode = BAD;
break;
}
Tracev((stderr, "inflate: codes ok\n"));
state->mode = LEN_;
if (flush == Z_TREES) goto inf_leave;
/* fallthrough */
|
| ︙ | ︙ | |||
1062 1063 1064 1065 1066 1067 1068 |
if (here.op & 32) {
Tracevv((stderr, "inflate: end of block\n"));
state->back = -1;
state->mode = TYPE;
break;
}
if (here.op & 64) {
| | | 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 |
if (here.op & 32) {
Tracevv((stderr, "inflate: end of block\n"));
state->back = -1;
state->mode = TYPE;
break;
}
if (here.op & 64) {
strm->msg = (z_const char *)"invalid literal/length code";
state->mode = BAD;
break;
}
state->extra = (unsigned)(here.op) & 15;
state->mode = LENEXT;
/* fallthrough */
case LENEXT:
|
| ︙ | ︙ | |||
1100 1101 1102 1103 1104 1105 1106 |
}
DROPBITS(last.bits);
state->back += last.bits;
}
DROPBITS(here.bits);
state->back += here.bits;
if (here.op & 64) {
| | | > | | 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 |
}
DROPBITS(last.bits);
state->back += last.bits;
}
DROPBITS(here.bits);
state->back += here.bits;
if (here.op & 64) {
strm->msg = (z_const char *)"invalid distance code";
state->mode = BAD;
break;
}
state->offset = (unsigned)here.val;
state->extra = (unsigned)(here.op) & 15;
state->mode = DISTEXT;
/* fallthrough */
case DISTEXT:
if (state->extra) {
NEEDBITS(state->extra);
state->offset += BITS(state->extra);
DROPBITS(state->extra);
state->back += state->extra;
}
#ifdef INFLATE_STRICT
if (state->offset > state->dmax) {
strm->msg = (z_const char *)"invalid distance too far back";
state->mode = BAD;
break;
}
#endif
Tracevv((stderr, "inflate: distance %u\n", state->offset));
state->mode = MATCH;
/* fallthrough */
case MATCH:
if (left == 0) goto inf_leave;
copy = out - left;
if (state->offset > copy) { /* copy from window */
copy = state->offset - copy;
if (copy > state->whave) {
if (state->sane) {
strm->msg = (z_const char *)
"invalid distance too far back";
state->mode = BAD;
break;
}
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
Trace((stderr, "inflate.c too far\n"));
copy -= state->whave;
if (copy > state->length) copy = state->length;
|
| ︙ | ︙ | |||
1191 1192 1193 1194 1195 1196 1197 |
UPDATE_CHECK(state->check, put - out, out);
out = left;
if ((state->wrap & 4) && (
#ifdef GUNZIP
state->flags ? hold :
#endif
ZSWAP32(hold)) != state->check) {
| | | | 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 |
UPDATE_CHECK(state->check, put - out, out);
out = left;
if ((state->wrap & 4) && (
#ifdef GUNZIP
state->flags ? hold :
#endif
ZSWAP32(hold)) != state->check) {
strm->msg = (z_const char *)"incorrect data check";
state->mode = BAD;
break;
}
INITBITS();
Tracev((stderr, "inflate: check matches trailer\n"));
}
#ifdef GUNZIP
state->mode = LENGTH;
/* fallthrough */
case LENGTH:
if (state->wrap && state->flags) {
NEEDBITS(32);
if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) {
strm->msg = (z_const char *)"incorrect length check";
state->mode = BAD;
break;
}
INITBITS();
Tracev((stderr, "inflate: length matches trailer\n"));
}
#endif
|
| ︙ | ︙ | |||
1436 1437 1438 1439 1440 1441 1442 |
return state->mode == STORED && state->bits == 0;
}
int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
struct inflate_state FAR *state;
struct inflate_state FAR *copy;
unsigned char FAR *window;
| < > | | | < | < | 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 |
return state->mode == STORED && state->bits == 0;
}
int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
struct inflate_state FAR *state;
struct inflate_state FAR *copy;
unsigned char FAR *window;
/* check input */
if (inflateStateCheck(source) || dest == Z_NULL)
return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)source->state;
/* allocate space */
copy = (struct inflate_state FAR *)
ZALLOC(source, 1, sizeof(struct inflate_state));
if (copy == Z_NULL) return Z_MEM_ERROR;
zmemzero(copy, sizeof(struct inflate_state));
window = Z_NULL;
if (state->window != Z_NULL) {
window = (unsigned char FAR *)
ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
if (window == Z_NULL) {
ZFREE(source, copy);
return Z_MEM_ERROR;
}
}
/* copy state */
zmemcpy(dest, source, sizeof(z_stream));
zmemcpy(copy, state, sizeof(struct inflate_state));
copy->strm = dest;
if (state->lencode >= state->codes &&
state->lencode <= state->codes + ENOUGH - 1) {
copy->lencode = copy->codes + (state->lencode - state->codes);
copy->distcode = copy->codes + (state->distcode - state->codes);
}
copy->next = copy->codes + (state->next - state->codes);
if (window != Z_NULL)
zmemcpy(window, state->window, state->whave);
copy->window = window;
dest->state = (struct internal_state FAR *)copy;
return Z_OK;
}
int ZEXPORT inflateUndermine(z_streamp strm, int subvert) {
struct inflate_state FAR *state;
|
| ︙ | ︙ |
Changes to compat/zlib/inflate.h.
| ︙ | ︙ | |||
96 97 98 99 100 101 102 |
unsigned wbits; /* log base 2 of requested window size */
unsigned wsize; /* window size or zero if not using window */
unsigned whave; /* valid bytes in the window */
unsigned wnext; /* window write index */
unsigned char FAR *window; /* allocated sliding window, if needed */
/* bit accumulator */
unsigned long hold; /* input bit accumulator */
| | | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
unsigned wbits; /* log base 2 of requested window size */
unsigned wsize; /* window size or zero if not using window */
unsigned whave; /* valid bytes in the window */
unsigned wnext; /* window write index */
unsigned char FAR *window; /* allocated sliding window, if needed */
/* bit accumulator */
unsigned long hold; /* input bit accumulator */
unsigned bits; /* number of bits in hold */
/* for string and stored block copying */
unsigned length; /* literal or length of data to copy */
unsigned offset; /* distance back to copy string from */
/* for table and code decoding */
unsigned extra; /* extra bits needed */
/* fixed and dynamic code tables */
code const FAR *lencode; /* starting table for length/literal codes */
|
| ︙ | ︙ |
Changes to compat/zlib/inftrees.c.
1 | /* inftrees.c -- generate Huffman trees for efficient decoding | | > > > > > > > > > > > > > > | | 1 2 3 4 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 | /* inftrees.c -- generate Huffman trees for efficient decoding * Copyright (C) 1995-2026 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #ifdef MAKEFIXED # ifndef BUILDFIXED # define BUILDFIXED # endif #endif #ifdef BUILDFIXED # define Z_ONCE #endif #include "zutil.h" #include "inftrees.h" #include "inflate.h" #ifndef NULL # define NULL 0 #endif #define MAXBITS 15 const char inflate_copyright[] = " inflate 1.3.2 Copyright 1995-2026 Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot include such an acknowledgment, I would appreciate that you keep this copyright string in the executable of your product. */ |
| ︙ | ︙ | |||
43 44 45 46 47 48 49 |
unsigned huff; /* Huffman code */
unsigned incr; /* for incrementing code, index */
unsigned fill; /* index for replicating entries */
unsigned low; /* low bits for current root entry */
unsigned mask; /* mask for low root bits */
code here; /* table entry for duplication */
code FAR *next; /* next available space in table */
| | | | | | 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 |
unsigned huff; /* Huffman code */
unsigned incr; /* for incrementing code, index */
unsigned fill; /* index for replicating entries */
unsigned low; /* low bits for current root entry */
unsigned mask; /* mask for low root bits */
code here; /* table entry for duplication */
code FAR *next; /* next available space in table */
const unsigned short FAR *base = NULL; /* base value table to use */
const unsigned short FAR *extra = NULL; /* extra bits table to use */
unsigned match = 0; /* use base and extra for symbol >= match */
unsigned short count[MAXBITS+1]; /* number of codes of each length */
unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
static const unsigned short lbase[31] = { /* Length codes 257..285 base */
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 199, 75};
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
8193, 12289, 16385, 24577, 0, 0};
static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
|
| ︙ | ︙ | |||
171 172 173 174 175 176 177 |
routine permits incomplete codes, so another loop after this one fills
in the rest of the decoding tables with invalid code markers.
*/
/* set up for code type */
switch (type) {
case CODES:
| < | < | 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
routine permits incomplete codes, so another loop after this one fills
in the rest of the decoding tables with invalid code markers.
*/
/* set up for code type */
switch (type) {
case CODES:
match = 20;
break;
case LENS:
base = lbase;
extra = lext;
match = 257;
break;
case DISTS:
base = dbase;
extra = dext;
}
/* initialize state for loop */
huff = 0; /* starting code */
sym = 0; /* starting code symbol */
len = min; /* starting code length */
next = *table; /* current table to fill in */
|
| ︙ | ︙ | |||
293 294 295 296 297 298 299 |
}
/* set return parameters */
*table += used;
*bits = root;
return 0;
}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
}
/* set return parameters */
*table += used;
*bits = root;
return 0;
}
#ifdef BUILDFIXED
/*
If this is compiled with BUILDFIXED defined, and if inflate will be used in
multiple threads, and if atomics are not available, then inflate() must be
called with a fixed block (e.g. 0x03 0x00) to initialize the tables and must
return before any other threads are allowed to call inflate.
*/
static code *lenfix, *distfix;
static code fixed[544];
/* State for z_once(). */
local z_once_t built = Z_ONCE_INIT;
local void buildtables(void) {
unsigned sym, bits;
static code *next;
unsigned short lens[288], work[288];
/* literal/length table */
sym = 0;
while (sym < 144) lens[sym++] = 8;
while (sym < 256) lens[sym++] = 9;
while (sym < 280) lens[sym++] = 7;
while (sym < 288) lens[sym++] = 8;
next = fixed;
lenfix = next;
bits = 9;
inflate_table(LENS, lens, 288, &(next), &(bits), work);
/* distance table */
sym = 0;
while (sym < 32) lens[sym++] = 5;
distfix = next;
bits = 5;
inflate_table(DISTS, lens, 32, &(next), &(bits), work);
}
#else /* !BUILDFIXED */
# include "inffixed.h"
#endif /* BUILDFIXED */
/*
Return state with length and distance decoding tables and index sizes set to
fixed code decoding. Normally this returns fixed tables from inffixed.h.
If BUILDFIXED is defined, then instead this routine builds the tables the
first time it's called, and returns those tables the first time and
thereafter. This reduces the size of the code by about 2K bytes, in
exchange for a little execution time. However, BUILDFIXED should not be
used for threaded applications if atomics are not available, as it will
not be thread-safe.
*/
void inflate_fixed(struct inflate_state FAR *state) {
#ifdef BUILDFIXED
z_once(&built, buildtables);
#endif /* BUILDFIXED */
state->lencode = lenfix;
state->lenbits = 9;
state->distcode = distfix;
state->distbits = 5;
}
#ifdef MAKEFIXED
#include <stdio.h>
/*
Write out the inffixed.h that will be #include'd above. Defining MAKEFIXED
also defines BUILDFIXED, so the tables are built on the fly. main() writes
those tables to stdout, which would directed to inffixed.h. Compile this
along with zutil.c:
cc -DMAKEFIXED -o fix inftrees.c zutil.c
./fix > inffixed.h
*/
int main(void) {
unsigned low, size;
struct inflate_state state;
inflate_fixed(&state);
puts("/* inffixed.h -- table for decoding fixed codes");
puts(" * Generated automatically by makefixed().");
puts(" */");
puts("");
puts("/* WARNING: this file should *not* be used by applications.");
puts(" It is part of the implementation of this library and is");
puts(" subject to change. Applications should only use zlib.h.");
puts(" */");
puts("");
size = 1U << 9;
printf("static const code lenfix[%u] = {", size);
low = 0;
for (;;) {
if ((low % 7) == 0) printf("\n ");
printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op,
state.lencode[low].bits, state.lencode[low].val);
if (++low == size) break;
putchar(',');
}
puts("\n};");
size = 1U << 5;
printf("\nstatic const code distfix[%u] = {", size);
low = 0;
for (;;) {
if ((low % 6) == 0) printf("\n ");
printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits,
state.distcode[low].val);
if (++low == size) break;
putchar(',');
}
puts("\n};");
return 0;
}
#endif /* MAKEFIXED */
|
Changes to compat/zlib/inftrees.h.
1 | /* inftrees.h -- header to use inftrees.c | | | 1 2 3 4 5 6 7 8 9 | /* inftrees.h -- header to use inftrees.c * Copyright (C) 1995-2026 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ |
| ︙ | ︙ | |||
56 57 58 59 60 61 62 |
LENS,
DISTS
} codetype;
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
unsigned codes, code FAR * FAR *table,
unsigned FAR *bits, unsigned short FAR *work);
| > > | 56 57 58 59 60 61 62 63 64 |
LENS,
DISTS
} codetype;
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
unsigned codes, code FAR * FAR *table,
unsigned FAR *bits, unsigned short FAR *work);
struct inflate_state;
void ZLIB_INTERNAL inflate_fixed(struct inflate_state FAR *state);
|
Changes to compat/zlib/msdos/Makefile.dj2.
| ︙ | ︙ | |||
26 27 28 29 30 31 32 | # LIBRARY_PATH=c:\usr\lib CC=gcc #CFLAGS=-MMD -O #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 #CFLAGS=-MMD -g -DZLIB_DEBUG | | | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# LIBRARY_PATH=c:\usr\lib
CC=gcc
#CFLAGS=-MMD -O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
#CFLAGS=-MMD -g -DZLIB_DEBUG
CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith \
-Wstrict-prototypes -Wmissing-prototypes
# If cp.exe is available, replace "copy /Y" with "cp -fp" .
CP=copy /Y
# If gnu install.exe is available, replace $(CP) with ginstall.
INSTALL=$(CP)
# The default value of RM is "rm -f." If "rm.exe" is found, comment out:
|
| ︙ | ︙ |
Deleted compat/zlib/nintendods/Makefile.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/nintendods/README.
|
| < < < < < |
Deleted compat/zlib/old/Makefile.emx.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/old/Makefile.riscos.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/old/README.
|
| < < < |
Deleted compat/zlib/old/descrip.mms.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/old/os2/Makefile.os2.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/old/os2/zlib.def.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted compat/zlib/old/visual-basic.txt.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to compat/zlib/os400/README400.
|
| | | 1 2 3 4 5 6 7 8 |
ZLIB version 1.3.2 for OS/400 installation instructions
1) Download and unpack the zlib tarball to some IFS directory.
(i.e.: /path/to/the/zlib/ifs/source/directory)
If the installed IFS command supports gzip format, this is straightforward,
else you have to unpack first to some directory on a system supporting it,
then move the whole directory to the IFS via the network (via SMB or FTP).
|
| ︙ | ︙ |
Changes to compat/zlib/os400/bndsrc.
| ︙ | ︙ | |||
119 120 121 122 123 124 125 126 127 |
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
/* Version 1.2.12 additional entry points. */
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
EXPORT SYMBOL("crc32_combine_gen64")
EXPORT SYMBOL("crc32_combine_gen")
EXPORT SYMBOL("crc32_combine_op")
ENDPGMEXP
| > > > > > > > > > > > > > > > > > | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
/* Version 1.2.12 additional entry points. */
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
EXPORT SYMBOL("crc32_combine_gen64")
EXPORT SYMBOL("crc32_combine_gen")
EXPORT SYMBOL("crc32_combine_op")
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
/* Version 1.3.1.2 additional entry points. */
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
EXPORT SYMBOL("deflateUsed")
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
/* Version 1.3.2 additional entry points. */
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
EXPORT SYMBOL("compressBound_z")
EXPORT SYMBOL("deflateBound_z")
EXPORT SYMBOL("compress_z")
EXPORT SYMBOL("compress2_z")
EXPORT SYMBOL("uncompress_z")
EXPORT SYMBOL("uncompress2_z")
ENDPGMEXP
|
Changes to compat/zlib/os400/make.sh.
| ︙ | ︙ | |||
183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
"${TOPDIR}/README" "${SCRIPTDIR}/README400"
do MEMBER="${LIBIFSNAME}/DOCS.FILE/`db2_name \"${TEXT}\"`.MBR"
if action_needed "${MEMBER}" "${TEXT}"
then CMD="CPY OBJ('${TEXT}') TOOBJ('${MEMBER}') TOCCSID(${TGTCCSID})"
CMD="${CMD} DTAFMT(*TEXT) REPLACE(*YES)"
system "${CMD}"
fi
done
# Create the OS/400 source program file for the C header files.
SRCPF="${LIBIFSNAME}/H.FILE"
| > | 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
"${TOPDIR}/README" "${SCRIPTDIR}/README400"
do MEMBER="${LIBIFSNAME}/DOCS.FILE/`db2_name \"${TEXT}\"`.MBR"
if action_needed "${MEMBER}" "${TEXT}"
then CMD="CPY OBJ('${TEXT}') TOOBJ('${MEMBER}') TOCCSID(${TGTCCSID})"
CMD="${CMD} DTAFMT(*TEXT) REPLACE(*YES)"
system "${CMD}"
system "CHGPFM FILE(${TARGETLIB}/DOCS) MBR(`basename ${TEXT}`) SRCTYPE(TXT)"
fi
done
# Create the OS/400 source program file for the C header files.
SRCPF="${LIBIFSNAME}/H.FILE"
|
| ︙ | ︙ | |||
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
then copy_hfile < "${HFILE}" > tmphdrfile
# Need to translate to target CCSID.
CMD="CPY OBJ('`pwd`/tmphdrfile') TOOBJ('${DEST}')"
CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
system "${CMD}"
# touch -r "${HFILE}" "${DEST}"
rm -f tmphdrfile
fi
IFSFILE="${IFSDIR}/include/`basename \"${HFILE}\"`"
if action_needed "${IFSFILE}" "${DEST}"
then rm -f "${IFSFILE}"
ln -s "${DEST}" "${IFSFILE}"
fi
done
# Install the ILE/RPG header file.
| > | > | > > > > > > > > > > > > > | | 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 |
then copy_hfile < "${HFILE}" > tmphdrfile
# Need to translate to target CCSID.
CMD="CPY OBJ('`pwd`/tmphdrfile') TOOBJ('${DEST}')"
CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
system "${CMD}"
system "CHGPFM FILE(${TARGETLIB}/H) MBR(`basename ${HFILE} .h`) SRCTYPE(H)"
# touch -r "${HFILE}" "${DEST}"
rm -f tmphdrfile
fi
IFSFILE="${IFSDIR}/include/`basename \"${HFILE}\"`"
if action_needed "${IFSFILE}" "${DEST}"
then rm -f "${IFSFILE}"
ln -s "${DEST}" "${IFSFILE}"
fi
done
# Install the ILE/RPG header file.
HFILE="${SCRIPTDIR}/zlibfixed.rpgle"
MBR="ZLIBFIXED"
DEST="${SRCPF}/${MBR}.MBR"
if action_needed "${DEST}" "${HFILE}"
then CMD="CPY OBJ('${HFILE}') TOOBJ('${DEST}')"
CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
system "${CMD}"
# touch -r "${HFILE}" "${DEST}"
system "CHGPFM FILE(${TARGETLIB}/H) MBR(${MBR}) SRCTYPE(RPGLE)"
fi
HFILE="${SCRIPTDIR}/zlibfree.rpgle"
MBR="ZLIBFREE"
DEST="${SRCPF}/${MBR}.MBR"
if action_needed "${DEST}" "${HFILE}"
then CMD="CPY OBJ('${HFILE}') TOOBJ('${DEST}')"
CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
system "${CMD}"
# touch -r "${HFILE}" "${DEST}"
system "CHGPFM FILE(${TARGETLIB}/H) MBR(${MBR}) SRCTYPE(RPGLE)"
fi
IFSFILE="${IFSDIR}/include/`basename \"${HFILE}\"`"
if action_needed "${IFSFILE}" "${DEST}"
then rm -f "${IFSFILE}"
ln -s "${DEST}" "${IFSFILE}"
fi
# Create and compile the identification source file.
echo '#pragma comment(user, "ZLIB version '"${VERSION}"'")' > os400.c
echo '#pragma comment(user, __DATE__)' >> os400.c
echo '#pragma comment(user, __TIME__)' >> os400.c
echo '#pragma comment(copyright, "Copyright (C) 1995-2026 Jean-Loup Gailly, Mark Adler. OS/400 version by P. Monnerat.")' >> os400.c
make_module OS400 os400.c
LINK= # No need to rebuild service program yet.
MODULES=
# Get source list.
|
| ︙ | ︙ | |||
307 308 309 310 311 312 313 |
CMD="${CMD} CCSID(${TGTCCSID}) TEXT('ZLIB: build tools')"
system "${CMD}"
fi
DEST="${LIBIFSNAME}/TOOLS.FILE/BNDSRC.MBR"
| | > | 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
CMD="${CMD} CCSID(${TGTCCSID}) TEXT('ZLIB: build tools')"
system "${CMD}"
fi
DEST="${LIBIFSNAME}/TOOLS.FILE/BNDSRC.MBR"
if action_needed "${DEST}" "${SCRIPTDIR}/bndsrc"
then CMD="CPY OBJ('${SCRIPTDIR}/bndsrc') TOOBJ('${DEST}')"
CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
system "${CMD}"
system "CHGPFM FILE(${TARGETLIB}/TOOLS) MBR(BNDSRC) SRCTYPE(BND)"
# touch -r "${SCRIPTDIR}/bndsrc" "${DEST}"
LINK=YES
fi
# Build the service program if needed.
|
| ︙ | ︙ | |||
357 358 359 360 361 362 363 |
if [ "${LINK}" ]
then rm -rf "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
CMD="${CMD} TEXT('ZLIB dynamic binding directory')"
system "${CMD}"
CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
| | | 374 375 376 377 378 379 380 381 382 383 |
if [ "${LINK}" ]
then rm -rf "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
CMD="${CMD} TEXT('ZLIB dynamic binding directory')"
system "${CMD}"
CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
CMD="${CMD} OBJ((${TARGETLIB}/${SRVPGM} *SRVPGM))"
system "${CMD}"
fi
|
Deleted compat/zlib/os400/zlib.inc.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Added compat/zlib/os400/zlibfixed.rpgle.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 |
* ZLIB.INC - Interface to the general purpose compression library
*
* ILE RPG400 version by Patrick Monnerat, DATASPHERE.
* Version 1.3.2
*
*
* WARNING:
* Procedures inflateInit(), inflateInit2(), deflateInit(),
* deflateInit2() and inflateBackInit() need to be called with
* two additional arguments:
* the package version string and the stream control structure.
* size. This is needed because RPG lacks some macro feature.
* Call these procedures as:
* inflateInit(...: ZLIB_VERSION: %size(z_stream))
*
/if not defined(ZLIB_H_)
/define ZLIB_H_
*
**************************************************************************
* Constants
**************************************************************************
*
* Versioning information.
*
D ZLIB_VERSION C '1.3.2'
D ZLIB_VERNUM C X'1320'
D ZLIB_VER_MAJOR C 1
D ZLIB_VER_MINOR C 3
D ZLIB_VER_REVISION...
D C 2
D ZLIB_VER_SUBREVISION...
D C 0
*
* Other equates.
*
D Z_NO_FLUSH C 0
D Z_PARTIAL_FLUSH...
D C 1
D Z_SYNC_FLUSH C 2
D Z_FULL_FLUSH C 3
D Z_FINISH C 4
D Z_BLOCK C 5
D Z_TREES C 6
*
D Z_OK C 0
D Z_STREAM_END C 1
D Z_NEED_DICT C 2
D Z_ERRNO C -1
D Z_STREAM_ERROR C -2
D Z_DATA_ERROR C -3
D Z_MEM_ERROR C -4
D Z_BUF_ERROR C -5
D Z_VERSION_ERROR...
D C -6
*
D Z_NO_COMPRESSION...
D C 0
D Z_BEST_SPEED C 1
D Z_BEST_COMPRESSION...
D C 9
D Z_DEFAULT_COMPRESSION...
D C -1
*
D Z_FILTERED C 1
D Z_HUFFMAN_ONLY C 2
D Z_RLE C 3
D Z_DEFAULT_STRATEGY...
D C 0
*
D Z_BINARY C 0
D Z_ASCII C 1
D Z_UNKNOWN C 2
*
D Z_DEFLATED C 8
*
D Z_NULL C 0
*
**************************************************************************
* Types
**************************************************************************
*
D z_streamp S * Stream struct ptr
D gzFile S * File pointer
D gz_headerp S *
D z_off_t S 10i 0 Stream offsets
D z_off64_t S 20i 0 Stream offsets
*
**************************************************************************
* Structures
**************************************************************************
*
* The GZIP encode/decode stream support structure.
*
D z_stream DS align based(z_streamp)
D zs_next_in * Next input byte
D zs_avail_in 10U 0 Byte cnt at next_in
D zs_total_in 10U 0 Total bytes read
D zs_next_out * Output buffer ptr
D zs_avail_out 10U 0 Room left @ next_out
D zs_total_out 10U 0 Total bytes written
D zs_msg * Last errmsg or null
D zs_state * Internal state
D zs_zalloc * procptr Int. state allocator
D zs_free * procptr Int. state dealloc.
D zs_opaque * Private alloc. data
D zs_data_type 10i 0 ASC/BIN best guess
D zs_adler 10u 0 Uncompr. adler32 val
D 10U 0 Reserved
D 10U 0 Ptr. alignment
*
**************************************************************************
* Utility function prototypes
**************************************************************************
*
D compress PR 10I 0 extproc('compress')
D dest 65535 options(*varsize) Destination buffer
D destLen 10U 0 Destination length
D source 65535 const options(*varsize) Source buffer
D sourceLen 10u 0 value Source length
*
D compress2 PR 10I 0 extproc('compress2')
D dest 65535 options(*varsize) Destination buffer
D destLen 10U 0 Destination length
D source 65535 const options(*varsize) Source buffer
D sourceLen 10U 0 value Source length
D level 10I 0 value Compression level
*
D compress_z PR 10I 0 extproc('compress')
D dest 65535 options(*varsize) Destination buffer
D destLen 20U 0 Destination length
D source 65535 const options(*varsize) Source buffer
D sourceLen 20u 0 value Source length
*
D compress2_z PR 10I 0 extproc('compress2')
D dest 65535 options(*varsize) Destination buffer
D destLen 20U 0 Destination length
D source 65535 const options(*varsize) Source buffer
D sourceLen 20U 0 value Source length
D level 10I 0 value Compression level
*
D compressBound PR 10U 0 extproc('compressBound')
D sourceLen 10U 0 value
*
D compressBound_z PR 20U 0 extproc('compressBound')
D sourceLen 20U 0 value
*
D uncompress PR 10I 0 extproc('uncompress')
D dest 65535 options(*varsize) Destination buffer
D destLen 10U 0 Destination length
D source 65535 const options(*varsize) Source buffer
D sourceLen 10U 0 value Source length
*
D uncompress2 PR 10I 0 extproc('uncompress2')
D dest 65535 options(*varsize) Destination buffer
D destLen 10U 0 Destination length
D source 65535 const options(*varsize) Source buffer
D sourceLen 10U 0 Source length
*
D uncompress_z PR 10I 0 extproc('uncompress')
D dest 65535 options(*varsize) Destination buffer
D destLen 20U 0 Destination length
D source 65535 const options(*varsize) Source buffer
D sourceLen 20U 0 value Source length
*
D uncompress2_z PR 10I 0 extproc('uncompress2')
D dest 65535 options(*varsize) Destination buffer
D destLen 20U 0 Destination length
D source 65535 const options(*varsize) Source buffer
D sourceLen 20U 0 Source length
*
/if not defined(LARGE_FILES)
D gzopen PR extproc('gzopen')
D like(gzFile)
D path * value options(*string) File pathname
D mode * value options(*string) Open mode
/else
D gzopen PR extproc('gzopen64')
D like(gzFile)
D path * value options(*string) File pathname
D mode * value options(*string) Open mode
*
D gzopen64 PR extproc('gzopen64')
D like(gzFile)
D path * value options(*string) File pathname
D mode * value options(*string) Open mode
/endif
*
D gzdopen PR extproc('gzdopen')
D like(gzFile)
D fd 10I 0 value File descriptor
D mode * value options(*string) Open mode
*
D gzbuffer PR 10I 0 extproc('gzbuffer')
D file value like(gzFile) File pointer
D size 10U 0 value
*
D gzsetparams PR 10I 0 extproc('gzsetparams')
D file value like(gzFile) File pointer
D level 10I 0 value
D strategy 10I 0 value
*
D gzread PR 10I 0 extproc('gzread')
D file value like(gzFile) File pointer
D buf 65535 options(*varsize) Buffer
D len 10u 0 value Buffer length
*
D gzfread PR 20I 0 extproc('gzfread')
D buf 65535 options(*varsize) Buffer
D size 20u 0 value Buffer length
D nitems 20u 0 value Buffer length
D file value like(gzFile) File pointer
*
D gzwrite PR 10I 0 extproc('gzwrite')
D file value like(gzFile) File pointer
D buf 65535 const options(*varsize) Buffer
D len 10u 0 value Buffer length
*
D gzfwrite PR 20I 0 extproc('gzfwrite')
D buf 65535 options(*varsize) Buffer
D size 20u 0 value Buffer length
D nitems 20u 0 value Buffer length
D file value like(gzFile) File pointer
*
D gzputs PR 10I 0 extproc('gzputs')
D file value like(gzFile) File pointer
D s * value options(*string) String to output
*
D gzgets PR * extproc('gzgets')
D file value like(gzFile) File pointer
D buf 65535 options(*varsize) Read buffer
D len 10i 0 value Buffer length
*
D gzputc PR 10i 0 extproc('gzputc')
D file value like(gzFile) File pointer
D c 10I 0 value Character to write
*
D gzgetc PR 10i 0 extproc('gzgetc')
D file value like(gzFile) File pointer
*
D gzgetc_ PR 10i 0 extproc('gzgetc_')
D file value like(gzFile) File pointer
*
D gzungetc PR 10i 0 extproc('gzungetc')
D c 10I 0 value Character to push
D file value like(gzFile) File pointer
*
D gzflush PR 10i 0 extproc('gzflush')
D file value like(gzFile) File pointer
D flush 10I 0 value Type of flush
*
/if not defined(LARGE_FILES)
D gzseek PR extproc('gzseek')
D like(z_off_t)
D file value like(gzFile) File pointer
D offset value like(z_off_t) Offset
D whence 10i 0 value Origin
/else
D gzseek PR extproc('gzseek64')
D like(z_off_t)
D file value like(gzFile) File pointer
D offset value like(z_off_t) Offset
D whence 10i 0 value Origin
*
D gzseek64 PR extproc('gzseek64')
D like(z_off64_t)
D file value like(gzFile) File pointer
D offset value like(z_off64_t) Offset
D whence 10i 0 value Origin
/endif
*
D gzrewind PR 10i 0 extproc('gzrewind')
D file value like(gzFile) File pointer
*
/if not defined(LARGE_FILES)
D gztell PR extproc('gztell')
D like(z_off_t)
D file value like(gzFile) File pointer
/else
D gztell PR extproc('gztell64')
D like(z_off_t)
D file value like(gzFile) File pointer
*
D gztell64 PR extproc('gztell64')
D like(z_off64_t)
D file value like(gzFile) File pointer
/endif
*
/if not defined(LARGE_FILES)
D gzoffset PR extproc('gzoffset')
D like(z_off_t)
D file value like(gzFile) File pointer
/else
D gzoffset PR extproc('gzoffset64')
D like(z_off_t)
D file value like(gzFile) File pointer
*
D gzoffset64 PR extproc('gzoffset64')
D like(z_off64_t)
D file value like(gzFile) File pointer
/endif
*
D gzeof PR 10i 0 extproc('gzeof')
D file value like(gzFile) File pointer
*
D gzdirect PR 10i 0 extproc('gzdirect')
D file value like(gzFile) File pointer
*
D gzclose_r PR 10i 0 extproc('gzclose_r')
D file value like(gzFile) File pointer
*
D gzclose_w PR 10i 0 extproc('gzclose_w')
D file value like(gzFile) File pointer
*
D gzclose PR 10i 0 extproc('gzclose')
D file value like(gzFile) File pointer
*
D gzerror PR * extproc('gzerror') Error string
D file value like(gzFile) File pointer
D errnum 10I 0 Error code
*
D gzclearerr PR extproc('gzclearerr')
D file value like(gzFile) File pointer
*
**************************************************************************
* Basic function prototypes
**************************************************************************
*
D zlibVersion PR * extproc('zlibVersion') Version string
*
D deflateInit PR 10I 0 extproc('deflateInit_') Init. compression
D strm like(z_stream) Compression stream
D level 10I 0 value Compression level
D version * value options(*string) Version string
D stream_size 10i 0 value Stream struct. size
*
D deflate PR 10I 0 extproc('deflate') Compress data
D strm like(z_stream) Compression stream
D flush 10I 0 value Flush type required
*
D deflateEnd PR 10I 0 extproc('deflateEnd') Termin. compression
D strm like(z_stream) Compression stream
*
D inflateInit PR 10I 0 extproc('inflateInit_') Init. expansion
D strm like(z_stream) Expansion stream
D version * value options(*string) Version string
D stream_size 10i 0 value Stream struct. size
*
D inflate PR 10I 0 extproc('inflate') Expand data
D strm like(z_stream) Expansion stream
D flush 10I 0 value Flush type required
*
D inflateEnd PR 10I 0 extproc('inflateEnd') Termin. expansion
D strm like(z_stream) Expansion stream
*
**************************************************************************
* Advanced function prototypes
**************************************************************************
*
D deflateInit2 PR 10I 0 extproc('deflateInit2_') Init. compression
D strm like(z_stream) Compression stream
D level 10I 0 value Compression level
D method 10I 0 value Compression method
D windowBits 10I 0 value log2(window size)
D memLevel 10I 0 value Mem/cmpress tradeoff
D strategy 10I 0 value Compression strategy
D version * value options(*string) Version string
D stream_size 10i 0 value Stream struct. size
*
D deflateSetDictionary...
D PR 10I 0 extproc('deflateSetDictionary') Init. dictionary
D strm like(z_stream) Compression stream
D dictionary 65535 const options(*varsize) Dictionary bytes
D dictLength 10U 0 value Dictionary length
*
D deflateCopy PR 10I 0 extproc('deflateCopy') Compress strm 2 strm
D dest like(z_stream) Destination stream
D source like(z_stream) Source stream
*
D deflateReset PR 10I 0 extproc('deflateReset') End and init. stream
D strm like(z_stream) Compression stream
*
D deflateParams PR 10I 0 extproc('deflateParams') Change level & strat
D strm like(z_stream) Compression stream
D level 10I 0 value Compression level
D strategy 10I 0 value Compression strategy
*
D deflateTune PR 10I 0 extproc('deflateTune')
D strm like(z_stream) Compression stream
D good 10I 0 value
D lazy 10I 0 value
D nice 10I 0 value
D chain 10I 0 value
*
D deflateBound PR 10U 0 extproc('deflateBound') Change level & strat
D strm like(z_stream) Compression stream
D sourcelen 10U 0 value Compression level
*
D deflateBound_z PR 20U 0 extproc('deflateBound') Change level & strat
D strm like(z_stream) Compression stream
D sourcelen 20U 0 value Compression level
*
D deflatePending PR 10I 0 extproc('deflatePending') Change level & strat
D strm like(z_stream) Compression stream
D pending 10U 0 Pending bytes
D bits 10I 0 Pending bits
*
D deflateUsed PR 10I 0 extproc('deflateUsed') Get used bits
D strm like(z_stream) Compression stream
D bits 10I 0 Used bits
*
D deflatePrime PR 10I 0 extproc('deflatePrime') Change level & strat
D strm like(z_stream) Compression stream
D bits 10I 0 value # of bits to insert
D value 10I 0 value Bits to insert
*
D inflateInit2 PR 10I 0 extproc('inflateInit2_') Init. expansion
D strm like(z_stream) Expansion stream
D windowBits 10I 0 value log2(window size)
D version * value options(*string) Version string
D stream_size 10i 0 value Stream struct. size
*
D inflateSetDictionary...
D PR 10I 0 extproc('inflateSetDictionary') Init. dictionary
D strm like(z_stream) Expansion stream
D dictionary 65535 const options(*varsize) Dictionary bytes
D dictLength 10U 0 value Dictionary length
*
D inflateGetDictionary...
D PR 10I 0 extproc('inflateGetDictionary') Get dictionary
D strm like(z_stream) Expansion stream
D dictionary 65535 options(*varsize) Dictionary bytes
D dictLength 10U 0 Dictionary length
*
D deflateGetDictionary...
D PR 10I 0 extproc('deflateGetDictionary') Get dictionary
D strm like(z_stream) Expansion stream
D dictionary 65535 options(*varsize) Dictionary bytes
D dictLength 10U 0 Dictionary length
*
D inflateSync PR 10I 0 extproc('inflateSync') Sync. expansion
D strm like(z_stream) Expansion stream
*
D inflateCopy PR 10I 0 extproc('inflateCopy')
D dest like(z_stream) Destination stream
D source like(z_stream) Source stream
*
D inflateReset PR 10I 0 extproc('inflateReset') End and init. stream
D strm like(z_stream) Expansion stream
*
D inflateReset2 PR 10I 0 extproc('inflateReset2') End and init. stream
D strm like(z_stream) Expansion stream
D windowBits 10I 0 value Log2(buffer size)
*
D inflatePrime PR 10I 0 extproc('inflatePrime') Insert bits
D strm like(z_stream) Expansion stream
D bits 10I 0 value Bit count
D value 10I 0 value Bits to insert
*
D inflateMark PR 10I 0 extproc('inflateMark') Get inflate info
D strm like(z_stream) Expansion stream
*
D inflateCodesUsed...
D PR 20U 0 extproc('inflateCodesUsed')
D strm like(z_stream) Expansion stream
*
D inflateValidate...
D PR 20U 0 extproc('inflateValidate')
D strm like(z_stream) Expansion stream
D check 10I 0 value
*
D inflateGetHeader...
D PR 10U 0 extproc('inflateGetHeader')
D strm like(z_stream) Expansion stream
D head like(gz_headerp)
*
D deflateSetHeader...
D PR 10U 0 extproc('deflateSetHeader')
D strm like(z_stream) Expansion stream
D head like(gz_headerp)
*
D inflateBackInit...
D PR 10I 0 extproc('inflateBackInit_')
D strm like(z_stream) Expansion stream
D windowBits 10I 0 value Log2(buffer size)
D window 65535 options(*varsize) Buffer
D version * value options(*string) Version string
D stream_size 10i 0 value Stream struct. size
*
D inflateBack PR 10I 0 extproc('inflateBack')
D strm like(z_stream) Expansion stream
D in * value procptr Input function
D in_desc * value Input descriptor
D out * value procptr Output function
D out_desc * value Output descriptor
*
D inflateBackEnd PR 10I 0 extproc('inflateBackEnd')
D strm like(z_stream) Expansion stream
*
D zlibCompileFlags...
D PR 10U 0 extproc('zlibCompileFlags')
*
**************************************************************************
* Checksum function prototypes
**************************************************************************
*
D adler32 PR 10U 0 extproc('adler32') New checksum
D adler 10U 0 value Old checksum
D buf 65535 const options(*varsize) Bytes to accumulate
D len 10U 0 value Buffer length
*
D adler32_combine...
D PR 10U 0 extproc('adler32_combine') New checksum
D adler1 10U 0 value Old checksum
D adler2 10U 0 value Old checksum
D len2 20U 0 value Buffer length
*
D adler32_z PR 10U 0 extproc('adler32_z') New checksum
D adler 10U 0 value Old checksum
D buf 65535 const options(*varsize) Bytes to accumulate
D len 20U 0 value Buffer length
*
D crc32 PR 10U 0 extproc('crc32') New checksum
D crc 10U 0 value Old checksum
D buf 65535 const options(*varsize) Bytes to accumulate
D len 10U 0 value Buffer length
*
D crc32_combine...
D PR 10U 0 extproc('crc32_combine') New checksum
D crc1 10U 0 value Old checksum
D crc2 10U 0 value Old checksum
D len2 20U 0 value Buffer length
*
D crc32_z PR 10U 0 extproc('crc32_z') New checksum
D crc 10U 0 value Old checksum
D buf 65535 const options(*varsize) Bytes to accumulate
D len 20U 0 value Buffer length
*
D crc32_combine_gen...
D PR 10U 0 extproc('crc32_combine_gen') Operator
D len2 20U 0 value Buffer length
*
D crc32_combine_gen64...
D PR 10U 0 extproc('crc32_combine_gen64') Operator
D len2 20U 0 value Buffer length
*
D crc32_combine_op...
D PR 10U 0 extproc('crc32_combine_op') New Checksum
D crc1 10U 0 value Old checksum
D crc2 10U 0 value Old checksum
D op 10U 0 value Operator
*
**************************************************************************
* Miscellaneous function prototypes
**************************************************************************
*
D zError PR * extproc('zError') Error string
D err 10I 0 value Error code
*
D inflateSyncPoint...
D PR 10I 0 extproc('inflateSyncPoint')
D strm like(z_stream) Expansion stream
*
D get_crc_table PR * extproc('get_crc_table') Ptr to ulongs
*
D inflateUndermine...
D PR 10I 0 extproc('inflateUndermine')
D strm like(z_stream) Expansion stream
D arg 10I 0 value Error code
*
D inflateResetKeep...
D PR 10I 0 extproc('inflateResetKeep') End and init. stream
D strm like(z_stream) Expansion stream
*
D deflateResetKeep...
D PR 10I 0 extproc('deflateResetKeep') End and init. stream
D strm like(z_stream) Expansion stream
*
/endif
|
Added compat/zlib/os400/zlibfree.rpgle.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 |
**free
// ZLIB.INC - Interface to the general purpose compression library
// ILE RPG400 version by Patrick Monnerat, DATASPHERE.
// Version 1.3.2
// WARNING:
// Procedures inflateInit(), inflateInit2(), deflateInit(),
// deflateInit2() and inflateBackInit() need to be called with
// two additional arguments:
// the package version string and the stream control structure.
// size. This is needed because RPG lacks some macro feature.
// Call these procedures as:
// inflateInit(...: ZLIB_VERSION: %size(z_stream))
/if not defined(ZLIB_H_)
/define ZLIB_H_
//*************************************************************************
// Constants
//*************************************************************************
// Versioning information.
Dcl-C ZLIB_VERSION '1.3.2';
Dcl-C ZLIB_VERNUM X'1320';
Dcl-C ZLIB_VER_MAJOR 1;
Dcl-C ZLIB_VER_MINOR 3;
Dcl-C ZLIB_VER_REVISION 2;
Dcl-C ZLIB_VER_SUBREVISION 0;
// Other equates.
Dcl-C Z_NO_FLUSH 0;
Dcl-C Z_PARTIAL_FLUSH 1;
Dcl-C Z_SYNC_FLUSH 2;
Dcl-C Z_FULL_FLUSH 3;
Dcl-C Z_FINISH 4;
Dcl-C Z_BLOCK 5;
Dcl-C Z_TREES 6;
Dcl-C Z_OK 0;
Dcl-C Z_STREAM_END 1;
Dcl-C Z_NEED_DICT 2;
Dcl-C Z_ERRNO -1;
Dcl-C Z_STREAM_ERROR -2;
Dcl-C Z_DATA_ERROR -3;
Dcl-C Z_MEM_ERROR -4;
Dcl-C Z_BUF_ERROR -5;
Dcl-C Z_VERSION_ERROR -6;
Dcl-C Z_NO_COMPRESSION 0;
Dcl-C Z_BEST_SPEED 1;
Dcl-C Z_BEST_COMPRESSION 9;
Dcl-C Z_DEFAULT_COMPRESSION -1;
Dcl-C Z_FILTERED 1;
Dcl-C Z_HUFFMAN_ONLY 2;
Dcl-C Z_RLE 3;
Dcl-C Z_DEFAULT_STRATEGY 0;
Dcl-C Z_BINARY 0;
Dcl-C Z_ASCII 1;
Dcl-C Z_UNKNOWN 2;
Dcl-C Z_DEFLATED 8;
Dcl-C Z_NULL 0;
//*************************************************************************
// Types
//*************************************************************************
Dcl-S z_streamp Pointer; // Stream struct ptr
Dcl-S gzFile Pointer; // File pointer
Dcl-S gz_headerp Pointer;
Dcl-S z_off_t Int(10); // Stream offsets
Dcl-S z_off64_t Int(20); // Stream offsets
//*************************************************************************
// Structures
//*************************************************************************
// The GZIP encode/decode stream support structure.
Dcl-Ds z_stream Align Based(z_streamp);
zs_next_in Pointer; // Next input byte
zs_avail_in Uns(10); // Byte cnt at next_in
zs_total_in Uns(10); // Total bytes read
zs_next_out Pointer; // Output buffer ptr
zs_avail_out Uns(10); // Room left @ next_out
zs_total_out Uns(10); // Total bytes written
zs_msg Pointer; // Last errmsg or null
zs_state Pointer; // Internal state
zs_zalloc Pointer(*PROC); // Int. state allocator
zs_free Pointer(*PROC); // Int. state dealloc.
zs_opaque Pointer; // Private alloc. data
zs_data_type Int(10); // ASC/BIN best guess
zs_adler Uns(10); // Uncompr. adler32 val
*N Uns(10); // Reserved
*N Uns(10); // Ptr. alignment
End-Ds;
//*************************************************************************
// Utility function prototypes
//*************************************************************************
Dcl-Pr compress Int(10) Extproc('compress');
dest Char(65535) Options(*VARSIZE); // Destination buffer
destLen Uns(10); // Destination length
source Char(65535) Const Options(*VARSIZE); // Source buffer
sourceLen Uns(10) Value; // Source length
End-Pr;
Dcl-Pr compress_z Int(10) Extproc('compress_z');
dest Char(65535) Options(*VARSIZE); // Destination buffer
destLen Uns(20); // Destination length
source Char(65535) Const Options(*VARSIZE); // Source buffer
sourceLen Uns(20) Value; // Source length
End-Pr;
Dcl-Pr compress2 Int(10) Extproc('compress2');
dest Char(65535) Options(*VARSIZE); // Destination buffer
destLen Uns(10); // Destination length
source Char(65535) Const Options(*VARSIZE); // Source buffer
sourceLen Uns(10) Value; // Source length
level Int(10) Value; // Compression level
End-Pr;
Dcl-Pr compress2_z Int(10) Extproc('compress2_z');
dest Char(65535) Options(*VARSIZE); // Destination buffer
destLen Uns(20); // Destination length
source Char(65535) Const Options(*VARSIZE); // Source buffer
sourceLen Uns(20) Value; // Source length
level Int(10) Value; // Compression level
End-Pr;
Dcl-Pr compressBound Uns(10) Extproc('compressBound');
sourceLen Uns(10) Value;
End-Pr;
Dcl-Pr compressBound_z Uns(10) Extproc('compressBound_z');
sourceLen Uns(20) Value;
End-Pr;
Dcl-Pr uncompress Int(10) Extproc('uncompress');
dest Char(65535) Options(*VARSIZE); // Destination buffer
destLen Uns(10); // Destination length
source Char(65535) Const Options(*VARSIZE); // Source buffer
sourceLen Uns(10) Value; // Source length
End-Pr;
Dcl-Pr uncompress_z Int(10) Extproc('uncompress_z');
dest Char(65535) Options(*VARSIZE); // Destination buffer
destLen Uns(20); // Destination length
source Char(65535) Const Options(*VARSIZE); // Source buffer
sourceLen Uns(20) Value; // Source length
End-Pr;
Dcl-Pr uncompress2 Int(10) Extproc('uncompress2');
dest Char(65535) Options(*VARSIZE); // Destination buffer
destLen Uns(10); // Destination length
source Char(65535) Const Options(*VARSIZE); // Source buffer
sourceLen Uns(10); // Source length
End-Pr;
Dcl-Pr uncompress2_z Int(10) Extproc('uncompress2_z');
dest Char(65535) Options(*VARSIZE); // Destination buffer
destLen Uns(20); // Destination length
source Char(65535) Const Options(*VARSIZE); // Source buffer
sourceLen Uns(20); // Source length
End-Pr;
/if not defined(LARGE_FILES)
Dcl-Pr gzopen Extproc('gzopen') Like(gzFile);
path Pointer Value Options(*STRING); // File pathname
mode Pointer Value Options(*STRING); // Open mode
End-Pr;
/else
Dcl-Pr gzopen Extproc('gzopen64') Like(gzFile);
path Pointer Value Options(*STRING); // File pathname
mode Pointer Value Options(*STRING); // Open mode
End-Pr;
Dcl-Pr gzopen64 Extproc('gzopen64') Like(gzFile);
path Pointer Value Options(*STRING); // File pathname
mode Pointer Value Options(*STRING); // Open mode
End-Pr;
/endif
Dcl-Pr gzdopen Extproc('gzdopen') Like(gzFile);
fd Int(10) Value; // File descriptor
mode Pointer Value Options(*STRING); // Open mode
End-Pr;
Dcl-Pr gzbuffer Int(10) Extproc('gzbuffer');
file Value Like(gzFile); // File pointer
size Uns(10) Value;
End-Pr;
Dcl-Pr gzsetparams Int(10) Extproc('gzsetparams');
file Value Like(gzFile); // File pointer
level Int(10) Value;
strategy Int(10) Value;
End-Pr;
Dcl-Pr gzread Int(10) Extproc('gzread');
file Value Like(gzFile); // File pointer
buf Char(65535) Options(*VARSIZE); // Buffer
len Uns(10) Value; // Buffer length
End-Pr;
Dcl-Pr gzfread Int(20) Extproc('gzfread');
buf Char(65535) Options(*VARSIZE); // Buffer
size Uns(20) Value; // Buffer length
nitems Uns(20) Value; // Buffer length
file Value Like(gzFile); // File pointer
End-Pr;
Dcl-Pr gzwrite Int(10) Extproc('gzwrite');
file Value Like(gzFile); // File pointer
buf Char(65535) Const Options(*VARSIZE); // Buffer
len Uns(10) Value; // Buffer length
End-Pr;
Dcl-Pr gzfwrite Int(20) Extproc('gzfwrite');
buf Char(65535) Options(*VARSIZE); // Buffer
size Uns(20) Value; // Buffer length
nitems Uns(20) Value; // Buffer length
file Value Like(gzFile); // File pointer
End-Pr;
Dcl-Pr gzputs Int(10) Extproc('gzputs');
file Value Like(gzFile); // File pointer
s Pointer Value Options(*STRING); // String to output
End-Pr;
Dcl-Pr gzgets Pointer Extproc('gzgets');
file Value Like(gzFile); // File pointer
buf Char(65535) Options(*VARSIZE); // Read buffer
len Int(10) Value; // Buffer length
End-Pr;
Dcl-Pr gzputc Int(10) Extproc('gzputc');
file Value Like(gzFile); // File pointer
c Int(10) Value; // Character to write
End-Pr;
Dcl-Pr gzgetc Int(10) Extproc('gzgetc');
file Value Like(gzFile); // File pointer
End-Pr;
Dcl-Pr gzgetc_ Int(10) Extproc('gzgetc_');
file Value Like(gzFile); // File pointer
End-Pr;
Dcl-Pr gzungetc Int(10) Extproc('gzungetc');
c Int(10) Value; // Character to push
file Value Like(gzFile); // File pointer
End-Pr;
Dcl-Pr gzflush Int(10) Extproc('gzflush');
file Value Like(gzFile); // File pointer
flush Int(10) Value; // Type of flush
End-Pr;
/if not defined(LARGE_FILES)
Dcl-Pr gzseek Extproc('gzseek') Like(z_off_t);
file Value Like(gzFile); // File pointer
offset Value Like(z_off_t); // Offset
whence Int(10) Value; // Origin
End-Pr;
/else
Dcl-Pr gzseek Extproc('gzseek64') Like(z_off_t);
file Value Like(gzFile); // File pointer
offset Value Like(z_off_t); // Offset
whence Int(10) Value; // Origin
End-Pr;
Dcl-Pr gzseek64 Extproc('gzseek64') Like(z_off64_t);
file Value Like(gzFile); // File pointer
offset Value Like(z_off64_t); // Offset
whence Int(10) Value; // Origin
End-Pr;
/endif
Dcl-Pr gzrewind Int(10) Extproc('gzrewind');
file Value Like(gzFile); // File pointer
End-Pr;
/if not defined(LARGE_FILES)
Dcl-Pr gztell Extproc('gztell') Like(z_off_t);
file Value Like(gzFile); // File pointer
End-Pr;
/else
Dcl-Pr gztell Extproc('gztell64') Like(z_off_t);
file Value Like(gzFile); // File pointer
End-Pr;
Dcl-Pr gztell64 Extproc('gztell64') Like(z_off64_t);
file Value Like(gzFile); // File pointer
End-Pr;
/endif
/if not defined(LARGE_FILES)
Dcl-Pr gzoffset Extproc('gzoffset') Like(z_off_t);
file Value Like(gzFile); // File pointer
End-Pr;
/else
Dcl-Pr gzoffset Extproc('gzoffset64') Like(z_off_t);
file Value Like(gzFile); // File pointer
End-Pr;
Dcl-Pr gzoffset64 Extproc('gzoffset64') Like(z_off64_t);
file Value Like(gzFile); // File pointer
End-Pr;
/endif
Dcl-Pr gzeof Int(10) Extproc('gzeof');
file Value Like(gzFile); // File pointer
End-Pr;
Dcl-Pr gzdirect Int(10) Extproc('gzdirect');
file Value Like(gzFile); // File pointer
End-Pr;
Dcl-Pr gzclose_r Int(10) Extproc('gzclose_r');
file Value Like(gzFile); // File pointer
End-Pr;
Dcl-Pr gzclose_w Int(10) Extproc('gzclose_w');
file Value Like(gzFile); // File pointer
End-Pr;
Dcl-Pr gzclose Int(10) Extproc('gzclose');
file Value Like(gzFile); // File pointer
End-Pr;
Dcl-Pr gzerror Pointer Extproc('gzerror'); // Error string
file Value Like(gzFile); // File pointer
errnum Int(10); // Error code
End-Pr;
Dcl-Pr gzclearerr Extproc('gzclearerr');
file Value Like(gzFile); // File pointer
End-Pr;
//*************************************************************************
// Basic function prototypes
//*************************************************************************
Dcl-Pr zlibVersion Pointer Extproc('zlibVersion'); // Version string
End-Pr;
Dcl-Pr deflateInit Int(10) Extproc('deflateInit_'); // Init. compression
strm Like(z_stream); // Compression stream
level Int(10) Value; // Compression level
version Pointer Value Options(*STRING); // Version string
stream_size Int(10) Value; // Stream struct. size
End-Pr;
Dcl-Pr deflate Int(10) Extproc('deflate'); // Compress data
strm Like(z_stream); // Compression stream
flush Int(10) Value; // Flush type required
End-Pr;
Dcl-Pr deflateEnd Int(10) Extproc('deflateEnd'); // Termin. compression
strm Like(z_stream); // Compression stream
End-Pr;
Dcl-Pr inflateInit Int(10) Extproc('inflateInit_'); // Init. expansion
strm Like(z_stream); // Expansion stream
version Pointer Value Options(*STRING); // Version string
stream_size Int(10) Value; // Stream struct. size
End-Pr;
Dcl-Pr inflate Int(10) Extproc('inflate'); // Expand data
strm Like(z_stream); // Expansion stream
flush Int(10) Value; // Flush type required
End-Pr;
Dcl-Pr inflateEnd Int(10) Extproc('inflateEnd'); // Termin. expansion
strm Like(z_stream); // Expansion stream
End-Pr;
//*************************************************************************
// Advanced function prototypes
//*************************************************************************
Dcl-Pr deflateInit2 Int(10) Extproc('deflateInit2_'); // Init. compression
strm Like(z_stream); // Compression stream
level Int(10) Value; // Compression level
method Int(10) Value; // Compression method
windowBits Int(10) Value; // log2(window size)
memLevel Int(10) Value; // Mem/cmpress tradeoff
strategy Int(10) Value; // Compression strategy
version Pointer Value Options(*STRING); // Version string
stream_size Int(10) Value; // Stream struct. size
End-Pr;
Dcl-Pr deflateSetDictionary Int(10) Extproc('deflateSetDictionary'); // Init. dictionary
strm Like(z_stream); // Compression stream
dictionary Char(65535) Const Options(*VARSIZE); // Dictionary bytes
dictLength Uns(10) Value; // Dictionary length
End-Pr;
Dcl-Pr deflateCopy Int(10) Extproc('deflateCopy'); // Compress strm 2 strm
dest Like(z_stream); // Destination stream
source Like(z_stream); // Source stream
End-Pr;
Dcl-Pr deflateReset Int(10) Extproc('deflateReset'); // End and init. stream
strm Like(z_stream); // Compression stream
End-Pr;
Dcl-Pr deflateParams Int(10) Extproc('deflateParams'); // Change level & strat
strm Like(z_stream); // Compression stream
level Int(10) Value; // Compression level
strategy Int(10) Value; // Compression strategy
End-Pr;
Dcl-Pr deflateTune Int(10) Extproc('deflateTune');
strm Like(z_stream); // Compression stream
good Int(10) Value;
lazy Int(10) Value;
nice Int(10) Value;
chain_ Int(10) Value;
End-Pr;
Dcl-Pr deflateBound Uns(10) Extproc('deflateBound'); // Change level & strat
strm Like(z_stream); // Compression stream
sourcelen Uns(10) Value; // Source length
End-Pr;
Dcl-Pr deflateBound_z Uns(10) Extproc('deflateBound_z'); // Change level & strat
strm Like(z_stream); // Compression stream
sourcelen Uns(20) Value; // Source length
End-Pr;
Dcl-Pr deflatePending Int(10) Extproc('deflatePending'); // Change level & strat
strm Like(z_stream); // Compression stream
pending Uns(10); // Pending bytes
bits Int(10); // Pending bits
End-Pr;
Dcl-Pr deflateUsed Int(10) Extproc('deflateUsed'); // Get used bits
strm Like(z_stream); // Compression stream
bits Int(10); // Used bits
End-Pr;
Dcl-Pr deflatePrime Int(10) Extproc('deflatePrime'); // Change level & strat
strm Like(z_stream); // Compression stream
bits Int(10) Value; // # of bits to insert
value Int(10) Value; // Bits to insert
End-Pr;
Dcl-Pr inflateInit2 Int(10) Extproc('inflateInit2_'); // Init. expansion
strm Like(z_stream); // Expansion stream
windowBits Int(10) Value; // log2(window size)
version Pointer Value Options(*STRING); // Version string
stream_size Int(10) Value; // Stream struct. size
End-Pr;
Dcl-Pr inflateSetDictionary Int(10) Extproc('inflateSetDictionary'); // Init. dictionary
strm Like(z_stream); // Expansion stream
dictionary Char(65535) Const Options(*VARSIZE); // Dictionary bytes
dictLength Uns(10) Value; // Dictionary length
End-Pr;
Dcl-Pr inflateGetDictionary Int(10) Extproc('inflateGetDictionary'); // Get dictionary
strm Like(z_stream); // Expansion stream
dictionary Char(65535) Options(*VARSIZE); // Dictionary bytes
dictLength Uns(10); // Dictionary length
End-Pr;
Dcl-Pr deflateGetDictionary Int(10) Extproc('deflateGetDictionary'); // Get dictionary
strm Like(z_stream); // Expansion stream
dictionary Char(65535) Options(*VARSIZE); // Dictionary bytes
dictLength Uns(10); // Dictionary length
End-Pr;
Dcl-Pr inflateSync Int(10) Extproc('inflateSync'); // Sync. expansion
strm Like(z_stream); // Expansion stream
End-Pr;
Dcl-Pr inflateCopy Int(10) Extproc('inflateCopy');
dest Like(z_stream); // Destination stream
source Like(z_stream); // Source stream
End-Pr;
Dcl-Pr inflateReset Int(10) Extproc('inflateReset'); // End and init. stream
strm Like(z_stream); // Expansion stream
End-Pr;
Dcl-Pr inflateReset2 Int(10) Extproc('inflateReset2'); // End and init. stream
strm Like(z_stream); // Expansion stream
windowBits Int(10) Value; // Log2(buffer size)
End-Pr;
Dcl-Pr inflatePrime Int(10) Extproc('inflatePrime'); // Insert bits
strm Like(z_stream); // Expansion stream
bits Int(10) Value; // Bit count
value Int(10) Value; // Bits to insert
End-Pr;
Dcl-Pr inflateMark Int(10) Extproc('inflateMark'); // Get inflate info
strm Like(z_stream); // Expansion stream
End-Pr;
Dcl-Pr inflateCodesUsed Uns(20) Extproc('inflateCodesUsed');
strm Like(z_stream); // Expansion stream
End-Pr;
Dcl-Pr inflateValidate Uns(20) Extproc('inflateValidate');
strm Like(z_stream); // Expansion stream
check Int(10) Value;
End-Pr;
Dcl-Pr inflateGetHeader Uns(10) Extproc('inflateGetHeader');
strm Like(z_stream); // Expansion stream
head Like(GZ_HEADERP);
End-Pr;
Dcl-Pr deflateSetHeader Uns(10) Extproc('deflateSetHeader');
strm Like(z_stream); // Expansion stream
head Like(GZ_HEADERP);
End-Pr;
Dcl-Pr inflateBackInit Int(10) Extproc('inflateBackInit_');
strm Like(z_stream); // Expansion stream
windowBits Int(10) Value; // Log2(buffer size)
window Char(65535) Options(*VARSIZE); // Buffer
version Pointer Value Options(*STRING); // Version string
stream_size Int(10) Value; // Stream struct. size
End-Pr;
Dcl-Pr inflateBack Int(10) Extproc('inflateBack');
strm Like(z_stream); // Expansion stream
in_ Pointer(*PROC) Value; // Input function
in_desc Pointer Value; // Input descriptor
out_ Pointer(*PROC) Value; // Output function
out_desc Pointer Value; // Output descriptor
End-Pr;
Dcl-Pr inflateBackEnd Int(10) Extproc('inflateBackend');
strm Like(z_stream); // Expansion stream
End-Pr;
Dcl-Pr zlibCompileFlags Uns(10) Extproc('zlibCompileFlags') End-Pr;
//*************************************************************************
// Checksum function prototypes
//*************************************************************************
Dcl-Pr adler32 Uns(10) Extproc('adler32'); // New checksum
adler Uns(10) Value; // Old checksum
buf Char(65535) Const Options(*VARSIZE); // Bytes to accumulate
len Uns(10) Value; // Buffer length
End-Pr;
Dcl-Pr adler32_combine Uns(10) Extproc('adler32_combine'); // New checksum
adler1 Uns(10) Value; // Old checksum
adler2 Uns(10) Value; // Old checksum
len2 Uns(20) Value; // Buffer length
End-Pr;
Dcl-Pr adler32_z Uns(10) Extproc('adler32_z'); // New checksum
adler Uns(10) Value; // Old checksum
buf Char(65535) Const Options(*VARSIZE); // Bytes to accumulate
len Uns(20) Value; // Buffer length
End-Pr;
Dcl-Pr crc32 Uns(10) Extproc('crc32'); // New checksum
crc Uns(10) Value; // Old checksum
buf Char(65535) Const Options(*VARSIZE); // Bytes to accumulate
len Uns(10) Value; // Buffer length
End-Pr;
Dcl-Pr crc32_combine Uns(10) Extproc('crc32_combine'); // New checksum
crc1 Uns(10) Value; // Old checksum
crc2 Uns(10) Value; // Old checksum
len2 Uns(20) Value; // 2nd Buffer length
End-Pr;
Dcl-Pr crc32_z Uns(10) Extproc('crc32_z'); // New checksum
crc Uns(10) Value; // Old checksum
buf Char(65535) Const Options(*VARSIZE); // Bytes to accumulate
len Uns(20) Value; // Buffer length
End-Pr;
Dcl-Pr crc32_combine_gen Uns(10) Extproc('crc32_combine_gen');
len Uns(20) Value; // 2nd Buffer length
End-Pr;
Dcl-Pr crc32_combine_gen64 Uns(10) Extproc('crc32_combine_gen64');
len Uns(20) Value; // 2nd Buffer length
End-Pr;
Dcl-Pr crc32_combine_op Uns(10) Extproc('crc32_combine_op'); // New checksum
crc1 Uns(10) Value; // Old checksum
crc2 Uns(10) Value; // Old checksum
op Uns(10) Value; // Operator
End-Pr;
//*************************************************************************
// Miscellaneous function prototypes
//*************************************************************************
Dcl-Pr zError Pointer Extproc('zError'); // Error string
err Int(10) Value; // Error code
End-Pr;
Dcl-Pr inflateSyncPoint Int(10) Extproc('inflateSyncPoint');
strm Like(z_stream); // Expansion stream
End-Pr;
Dcl-Pr get_crc_table Pointer Extproc('get_crc_table'); // Ptr to ulongs
End-Pr;
Dcl-Pr inflateUndermine Int(10) Extproc('inflateUndermine');
strm Like(z_stream); // Expansion stream
arg Int(10) Value; // Error code
End-Pr;
Dcl-Pr inflateResetKeep Int(10) Extproc('inflateResetKeep'); // End and init. stream
strm Like(z_stream); // Expansion stream
End-Pr;
Dcl-Pr deflateResetKeep Int(10) Extproc('deflateResetKeep'); // End and init. stream
strm Like(z_stream); // Expansion stream
End-Pr;
/endif
|
Changes to compat/zlib/qnx/package.qpg.
| ︙ | ︙ | |||
21 22 23 24 25 26 27 |
<QPG:EmailAddress></QPG:EmailAddress>
</QPG:Responsible>
<QPG:Values>
<QPG:Files>
<QPG:Add file="../zconf.h" install="/opt/include/" user="root:sys" permission="644"/>
<QPG:Add file="../zlib.h" install="/opt/include/" user="root:sys" permission="644"/>
| | | | | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
<QPG:EmailAddress></QPG:EmailAddress>
</QPG:Responsible>
<QPG:Values>
<QPG:Files>
<QPG:Add file="../zconf.h" install="/opt/include/" user="root:sys" permission="644"/>
<QPG:Add file="../zlib.h" install="/opt/include/" user="root:sys" permission="644"/>
<QPG:Add file="../libz.so.1.3.2" install="/opt/lib/" user="root:bin" permission="644"/>
<QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.3.2"/>
<QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.3.2"/>
<QPG:Add file="../libz.so.1.3.2" install="/opt/lib/" component="slib"/>
</QPG:Files>
<QPG:PackageFilter>
<QPM:PackageManifest>
<QPM:PackageDescription>
<QPM:PackageType>Library</QPM:PackageType>
<QPM:PackageReleaseNotes></QPM:PackageReleaseNotes>
|
| ︙ | ︙ | |||
54 55 56 57 58 59 60 |
<QPM:AuthorURL>www.gzip.org/zlib</QPM:AuthorURL>
<QPM:AuthorEmbedURL></QPM:AuthorEmbedURL>
<QPM:AuthorEmail>zlib@gzip.org</QPM:AuthorEmail>
<QPM:ProductIconSmall></QPM:ProductIconSmall>
<QPM:ProductIconLarge></QPM:ProductIconLarge>
<QPM:ProductDescriptionShort>A massively spiffy yet delicately unobtrusive compression library.</QPM:ProductDescriptionShort>
<QPM:ProductDescriptionLong>zlib is designed to be a free, general-purpose, legally unencumbered, lossless data compression library for use on virtually any computer hardware and operating system.</QPM:ProductDescriptionLong>
| | | | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
<QPM:AuthorURL>www.gzip.org/zlib</QPM:AuthorURL>
<QPM:AuthorEmbedURL></QPM:AuthorEmbedURL>
<QPM:AuthorEmail>zlib@gzip.org</QPM:AuthorEmail>
<QPM:ProductIconSmall></QPM:ProductIconSmall>
<QPM:ProductIconLarge></QPM:ProductIconLarge>
<QPM:ProductDescriptionShort>A massively spiffy yet delicately unobtrusive compression library.</QPM:ProductDescriptionShort>
<QPM:ProductDescriptionLong>zlib is designed to be a free, general-purpose, legally unencumbered, lossless data compression library for use on virtually any computer hardware and operating system.</QPM:ProductDescriptionLong>
<QPM:ProductDescriptionURL>https://zlib.net/</QPM:ProductDescriptionURL>
<QPM:ProductDescriptionEmbedURL></QPM:ProductDescriptionEmbedURL>
</QPM:ProductDescription>
<QPM:ReleaseDescription>
<QPM:ReleaseVersion>1.3.2</QPM:ReleaseVersion>
<QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency>
<QPM:ReleaseStability>Stable</QPM:ReleaseStability>
<QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor>
<QPM:ReleaseNoteMajor></QPM:ReleaseNoteMajor>
<QPM:ExcludeCountries>
<QPM:Country></QPM:Country>
</QPM:ExcludeCountries>
|
| ︙ | ︙ |
Added compat/zlib/test/CMakeLists.txt.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
function(ZLIB_findTestEnv testName)
set(testEnv "PATH=")
if(MSVC OR MINGW)
set(separator "\\\;")
else()
set(separator ":")
endif()
string(APPEND testEnv "$<TARGET_FILE_DIR:ZLIB::ZLIB>${separator}")
string(APPEND testEnv "$ENV{PATH}")
set_tests_properties(${testName} PROPERTIES ENVIRONMENT "${testEnv}")
endfunction()
if(ZLIB_BUILD_SHARED)
add_executable(zlib_example example.c)
target_link_libraries(zlib_example ZLIB::ZLIB)
target_compile_definitions(zlib_example PRIVATE ZLIB_BUILD)
add_test(NAME zlib_example COMMAND zlib_example)
add_executable(minigzip minigzip.c)
target_compile_definitions(
minigzip PRIVATE $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
target_link_libraries(minigzip ZLIB::ZLIB)
if(MSVC
OR MSYS
OR MINGW
OR CYGWIN)
zlib_findtestenv(zlib_example)
endif(
MSVC
OR MSYS
OR MINGW
OR CYGWIN)
if(HAVE_OFF64_T)
add_executable(zlib_example64 example.c)
target_compile_definitions(
zlib_example64
PRIVATE ZLIB_BUILD
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
target_link_libraries(zlib_example64 ZLIB::ZLIB)
add_test(NAME zlib_example64 COMMAND zlib_example64)
if(MSVC
OR MSYS
OR MINGW
OR CYGWIN)
zlib_findtestenv(zlib_example64)
endif(
MSVC
OR MSYS
OR MINGW
OR CYGWIN)
endif(HAVE_OFF64_T)
endif(ZLIB_BUILD_SHARED)
if(ZLIB_BUILD_STATIC)
add_executable(zlib_static_example example.c)
target_link_libraries(zlib_static_example ZLIB::ZLIBSTATIC)
target_compile_definitions(
zlib_static_example
PRIVATE ZLIB_BUILD
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
add_test(NAME zlib_static_example COMMAND zlib_static_example)
add_executable(static_minigzip minigzip.c)
target_link_libraries(static_minigzip ZLIB::ZLIBSTATIC)
if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL
"Clang")
set(CFLAGS_OLD ${CMAKE_C_FLAGS})
set(CMAKE_C_FLAGS
""
CACHE STRING "" FORCE)
if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
find_program(GCOV_EXECUTABLE gcov)
endif(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
if(${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
set(llvm_names llvm_cov)
list(APPEND llvm_names llvm-cov)
foreach(ver RANGE 11 99)
list(APPEND llvm_names llvm-cov-${ver})
endforeach(ver RANGE 11 99)
find_program(GCOV_EXECUTABLE NAMES ${llvm_names})
set(llvm_option "gcov")
endif(${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
add_executable(infcover infcover.c)
target_link_libraries(infcover ZLIB::ZLIBSTATIC)
target_compile_options(infcover PRIVATE -coverage)
target_link_options(infcover PRIVATE -coverage)
target_compile_definitions(
infcover PRIVATE $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
add_test(NAME zlib_coverage COMMAND infcover)
set(INFCOVER_DIR ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/infcover.dir)
add_test(
NAME zlib_coverage-summary
COMMAND
${GCOV_EXECUTABLE} ${llvm_option}
${CMAKE_CURRENT_SOURCE_DIR}/infcover.c -o
${INFCOVER_DIR}/infcover.c.gcda)
set_tests_properties(zlib_coverage-summary PROPERTIES DEPENDS
zlib-coverage)
set(CMAKE_C_FLAGS
${CFLAGS_OLD}
CACHE STRING "" FORCE)
endif(${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID}
STREQUAL "Clang")
if(HAVE_OFF64_T)
add_executable(zlib_static_example64 example.c)
target_compile_definitions(
zlib_static_example64
PRIVATE ZLIB_BUILD
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
target_link_libraries(zlib_static_example64 ZLIB::ZLIBSTATIC)
add_test(NAME zlib_static_example64 COMMAND zlib_static_example64)
endif(HAVE_OFF64_T)
endif(ZLIB_BUILD_STATIC)
add_test(
NAME zlib_install
COMMAND ${CMAKE_COMMAND} --install ${zlib_BINARY_DIR} --prefix
${CMAKE_CURRENT_BINARY_DIR}/test_install --config $<CONFIG>
WORKING_DIRECTORY ${zlib_BINARY_DIR})
set_tests_properties(zlib_install PROPERTIES FIXTURES_SETUP zlib_install)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/find_package_no_components_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/find_package_wrong_components_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/find_package_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/findpackage_test/CMakeLists.txt @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/find_package_no_components_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/findpackage_no_components_test/CMakeLists.txt @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/find_package_wrong_components_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/findpackage_wrong_components_test/CMakeLists.txt @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test/CMakeLists.txt @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_exclude_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test/CMakeLists.txt
@ONLY)
# CMAKE_GENERATOR_PLATFORM doesn't work in the if
set(GENERATOR ${CMAKE_GENERATOR_PLATFORM})
if(GENERATOR)
set(PLATFORM "-A ${GENERATOR}")
endif(GENERATOR)
#
# findpackage_test
#
add_test(
NAME zlib_find_package_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install --fresh
-G "${CMAKE_GENERATOR}" -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
add_test(
NAME zlib_find_package_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
add_test(
NAME zlib_find_package_test
COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
set_tests_properties(
zlib_find_package_configure PROPERTIES FIXTURES_REQUIRED zlib_install
FIXTURES_SETUP fp_config)
set_tests_properties(
zlib_find_package_build PROPERTIES FIXTURES_REQUIRED fp_config
FIXTURES_SETUP fp_build)
set_tests_properties(
zlib_find_package_test PROPERTIES FIXTURES_REQUIRED fp_build ENVIRONMENT
CTEST_OUTPUT_ON_FAILURE=1)
#
# findpackage_no_components_test
#
add_test(
NAME zlib_find_package_no_components_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/findpackage_no_components_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install --fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_no_components_test)
set_tests_properties(
zlib_find_package_no_components_configure
PROPERTIES FIXTURES_REQUIRED zlib_install)
if(NOT ZLIB_BUILD_SHARED OR NOT ZLIB_BUILD_STATIC)
set_tests_properties(
zlib_find_package_no_components_configure
PROPERTIES WILL_FAIL TRUE)
endif(NOT ZLIB_BUILD_SHARED OR NOT ZLIB_BUILD_STATIC)
#
# findpackage_no_component_test
#
add_test(
NAME zlib_find_package_wrong_components_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/findpackage_wrong_components_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install --fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_wrong_components_test)
set_tests_properties(
zlib_find_package_wrong_components_configure
PROPERTIES FIXTURES_REQUIRED zlib_install
WILL_FAIL TRUE)
#
# add_subdirectory_test
#
add_test(
NAME zlib_add_subdirectory_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install --fresh
-G "${CMAKE_GENERATOR}" -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
add_test(
NAME zlib_add_subdirectory_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
add_test(
NAME zlib_add_subdirectory_test
COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
set_tests_properties(
zlib_add_subdirectory_configure PROPERTIES FIXTURES_REQUIRED zlib_install
FIXTURES_SETUP as_config)
set_tests_properties(
zlib_add_subdirectory_build PROPERTIES FIXTURES_REQUIRED as_config
FIXTURES_SETUP as_build)
set_tests_properties(
zlib_add_subdirectory_test PROPERTIES FIXTURES_REQUIRED as_build
ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1)
#
# add_subdirectory_exclude_test
#
add_test(
NAME zlib_add_subdirectory_exclude_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install --fresh
-G "${CMAKE_GENERATOR}" -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
add_test(
NAME zlib_add_subdirectory_exclude_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
add_test(
NAME zlib_add_subdirectory_exclude_test
COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
set_tests_properties(
zlib_add_subdirectory_exclude_configure
PROPERTIES FIXTURES_REQUIRED zlib_install FIXTURES_SETUP asx_config)
set_tests_properties(
zlib_add_subdirectory_exclude_build PROPERTIES FIXTURES_REQUIRED as_config
FIXTURES_SETUP asx_build)
set_tests_properties(
zlib_add_subdirectory_exclude_test
PROPERTIES FIXTURES_REQUIRED asx_build ENVIRONMENT
CTEST_OUTPUT_ON_FAILURE=1)
|
Added compat/zlib/test/add_subdirectory_exclude_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 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 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
zlib_find_package_test
LANGUAGES C
VERSION @zlib_VERSION@)
enable_testing()
option(ZLIB_BUILD_TESTING "" OFF)
option(ZLIB_BUILD_SHARED "" @ZLIB_BUILD_SHARED@)
option(ZLIB_BUILD_STATIC "" @ZLIB_BUILD_STATIC@)
add_subdirectory(@zlib_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/zlib
EXCLUDE_FROM_ALL)
if(ZLIB_BUILD_SHARED)
add_executable(test_example @zlib_SOURCE_DIR@/test/example.c)
target_link_libraries(test_example ZLIB::ZLIB)
if(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
add_test(NAME zlib_test_example_shared COMMAND test_example)
endif(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
endif(ZLIB_BUILD_SHARED)
if(ZLIB_BUILD_STATIC)
add_executable(test_example_static @zlib_SOURCE_DIR@/test/example.c)
target_link_libraries(test_example_static ZLIB::ZLIBSTATIC)
add_test(NAME zlib_test_example_static COMMAND test_example_static)
endif(ZLIB_BUILD_STATIC)
|
Added compat/zlib/test/add_subdirectory_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
zlib_find_package_test
LANGUAGES C
VERSION @zlib_VERSION@)
enable_testing()
option(ZLIB_BUILD_TESTING "" OFF)
option(ZLIB_BUILD_SHARED "" @ZLIB_BUILD_SHARED@)
option(ZLIB_BUILD_STATIC "" @ZLIB_BUILD_STATIC@)
add_subdirectory(@zlib_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/zlib)
if(ZLIB_BUILD_SHARED)
add_executable(test_example @zlib_SOURCE_DIR@/test/example.c)
target_link_libraries(test_example ZLIB::ZLIB)
if(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
add_test(NAME zlib_test_example_shared COMMAND test_example)
endif(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
endif(ZLIB_BUILD_SHARED)
if(ZLIB_BUILD_STATIC)
add_executable(test_example_static @zlib_SOURCE_DIR@/test/example.c)
target_link_libraries(test_example_static ZLIB::ZLIBSTATIC)
add_test(NAME zlib_test_example_static COMMAND test_example_static)
endif(@ZLIB_BUILD_STATIC)
|
Changes to compat/zlib/test/example.c.
1 | /* example.c -- usage example of the zlib compression library | | > > > > | > > | 1 2 3 4 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 |
/* example.c -- usage example of the zlib compression library
* Copyright (C) 1995-2026 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
#if defined(_WIN32) && !defined(_CRT_SECURE_NO_WARNINGS)
# define _CRT_SECURE_NO_WARNINGS
#endif
#include "zlib.h"
#include <stdio.h>
#ifdef STDC
# include <string.h>
# include <stdlib.h>
#endif
#if defined(VMS)
# define TESTFILE "foo-gz"
#elif defined(__riscos) && !defined(__TARGET_UNIXLIB__)
# define TESTFILE "foo/gz"
#else
# define TESTFILE "foo.gz"
#endif
#define CHECK_ERR(err, msg) { \
if (err != Z_OK) { \
fprintf(stderr, "%s error: %d\n", msg, err); \
|
| ︙ | ︙ | |||
315 316 317 318 319 320 321 |
CHECK_ERR(err, "large inflate");
}
err = inflateEnd(&d_stream);
CHECK_ERR(err, "inflateEnd");
if (d_stream.total_out != 2*uncomprLen + uncomprLen/2) {
| | | 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
CHECK_ERR(err, "large inflate");
}
err = inflateEnd(&d_stream);
CHECK_ERR(err, "inflateEnd");
if (d_stream.total_out != 2*uncomprLen + uncomprLen/2) {
fprintf(stderr, "bad large inflate: %lu\n", d_stream.total_out);
exit(1);
} else {
printf("large_inflate(): OK\n");
}
}
/* ===========================================================================
|
| ︙ | ︙ | |||
500 501 502 503 504 505 506 |
} else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) {
fprintf(stderr, "warning: different zlib version linked: %s\n",
zlibVersion());
}
printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n",
| | | 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 |
} else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) {
fprintf(stderr, "warning: different zlib version linked: %s\n",
zlibVersion());
}
printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n",
ZLIB_VERSION, (unsigned)ZLIB_VERNUM, zlibCompileFlags());
compr = (Byte*)calloc((uInt)comprLen, 1);
uncompr = (Byte*)calloc((uInt)uncomprLen, 1);
/* compr and uncompr are cleared to avoid reading uninitialized
* data and to ensure that uncompr compresses well.
*/
if (compr == Z_NULL || uncompr == Z_NULL) {
|
| ︙ | ︙ |
Added compat/zlib/test/find_package_no_components_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
zlib_find_package_test
LANGUAGES C
VERSION @zlib_VERSION@)
enable_testing()
option(ZLIB_BUILD_SHARED "" @ZLIB_BUILD_SHARED@)
option(ZLIB_BUILD_STATIC "" @ZLIB_BUILD_STATIC@)
find_package(ZLIB @zlib_VERSION@ CONFIG REQUIRED)
if(ZLIB_BUILD_SHARED)
add_executable(test_example @zlib_SOURCE_DIR@/test/example.c)
target_link_libraries(test_example ZLIB::ZLIB)
if(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
add_test(NAME zlib_test_example_shared COMMAND test_example)
endif(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
endif(ZLIB_BUILD_SHARED)
if(ZLIB_BUILD_STATIC)
add_executable(test_example_static @zlib_SOURCE_DIR@/test/example.c)
target_link_libraries(test_example_static ZLIB::ZLIBSTATIC)
add_test(NAME zlib_test_example_static COMMAND test_example_static)
endif(ZLIB_BUILD_STATIC)
|
Added compat/zlib/test/find_package_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
zlib_find_package_test
LANGUAGES C
VERSION @zlib_VERSION@)
enable_testing()
option(ZLIB_BUILD_SHARED "" @ZLIB_BUILD_SHARED@)
option(ZLIB_BUILD_STATIC "" @ZLIB_BUILD_STATIC@)
if(ZLIB_BUILD_SHARED)
find_package(ZLIB @zlib_VERSION@ CONFIG COMPONENTS shared REQUIRED)
add_executable(test_example @zlib_SOURCE_DIR@/test/example.c)
target_link_libraries(test_example ZLIB::ZLIB)
if(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
add_test(NAME zlib_test_example_shared COMMAND test_example)
endif(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
endif(ZLIB_BUILD_SHARED)
if(ZLIB_BUILD_STATIC)
find_package(ZLIB @zlib_VERSION@ CONFIG COMPONENTS static REQUIRED)
add_executable(test_example_static @zlib_SOURCE_DIR@/test/example.c)
target_link_libraries(test_example_static ZLIB::ZLIBSTATIC)
add_test(NAME zlib_test_example_static COMMAND test_example_static)
endif(ZLIB_BUILD_STATIC)
|
Added compat/zlib/test/find_package_wrong_components_test.cmake.in.
> > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
cmake_minimum_required(VERSION 3.12...3.31)
project(
zlib_find_package_test
LANGUAGES C
VERSION @zlib_VERSION@)
enable_testing()
option(ZLIB_BUILD_SHARED "" @ZLIB_BUILD_SHARED@)
option(ZLIB_BUILD_STATIC "" @ZLIB_BUILD_STATIC@)
find_package(ZLIB @zlib_VERSION@ CONFIG COMPONENTS wrong REQUIRED)
if(ZLIB_BUILD_SHARED)
add_executable(test_example @zlib_SOURCE_DIR@/test/example.c)
target_link_libraries(test_example ZLIB::ZLIB)
if(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
add_test(NAME zlib_test_example_shared COMMAND test_example)
endif(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
endif(ZLIB_BUILD_SHARED)
if(ZLIB_BUILD_STATIC)
add_executable(test_example_static @zlib_SOURCE_DIR@/test/example.c)
target_link_libraries(test_example_static ZLIB::ZLIBSTATIC)
add_test(NAME zlib_test_example_static COMMAND test_example_static)
endif(ZLIB_BUILD_STATIC)
|
Changes to compat/zlib/test/infcover.c.
1 | /* infcover.c -- test zlib's inflate routines with full code coverage | | | 1 2 3 4 5 6 7 8 9 | /* infcover.c -- test zlib's inflate routines with full code coverage * Copyright (C) 2011, 2016, 2024 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* to use, do: ./configure --cover && make cover */ #include <stdio.h> #include <stdlib.h> |
| ︙ | ︙ | |||
181 182 183 184 185 186 187 |
}
/* show the current total requested allocations in bytes */
local void mem_used(z_stream *strm, char *prefix)
{
struct mem_zone *zone = strm->opaque;
| | | | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
}
/* show the current total requested allocations in bytes */
local void mem_used(z_stream *strm, char *prefix)
{
struct mem_zone *zone = strm->opaque;
fprintf(stderr, "%s: %zu allocated\n", prefix, zone->total);
}
/* show the high water allocation in bytes */
local void mem_high(z_stream *strm, char *prefix)
{
struct mem_zone *zone = strm->opaque;
fprintf(stderr, "%s: %zu high water mark\n", prefix, zone->highwater);
}
/* release the memory allocation zone -- if there are any surprises, notify */
local void mem_done(z_stream *strm, char *prefix)
{
int count = 0;
struct mem_item *item, *next;
|
| ︙ | ︙ | |||
214 215 216 217 218 219 220 |
free(item);
item = next;
count++;
}
/* issue alerts about anything unexpected */
if (count || zone->total)
| | | 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
free(item);
item = next;
count++;
}
/* issue alerts about anything unexpected */
if (count || zone->total)
fprintf(stderr, "** %s: %zu bytes in %d blocks not freed\n",
prefix, zone->total, count);
if (zone->notlifo)
fprintf(stderr, "** %s: %d frees not LIFO\n", prefix, zone->notlifo);
if (zone->rogue)
fprintf(stderr, "** %s: %d frees not recognized\n",
prefix, zone->rogue);
|
| ︙ | ︙ | |||
440 441 442 443 444 445 446 |
ret = inflateUndermine(&strm, 1); assert(ret == Z_DATA_ERROR);
(void)inflateMark(&strm);
ret = inflateEnd(&strm); assert(ret == Z_OK);
mem_done(&strm, "miscellaneous, force memory errors");
}
/* input and output functions for inflateBack() */
| | | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 |
ret = inflateUndermine(&strm, 1); assert(ret == Z_DATA_ERROR);
(void)inflateMark(&strm);
ret = inflateEnd(&strm); assert(ret == Z_OK);
mem_done(&strm, "miscellaneous, force memory errors");
}
/* input and output functions for inflateBack() */
local unsigned pull(void *desc, unsigned char z_const **buf)
{
static unsigned int next = 0;
static unsigned char dat[] = {0x63, 0, 2, 0};
struct inflate_state *state;
if (desc == Z_NULL) {
next = 0;
|
| ︙ | ︙ |
Changes to compat/zlib/test/minigzip.c.
1 | /* minigzip.c -- simulate gzip using the zlib compression library | | > > > > > > > > > > > | 1 2 3 4 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 | /* minigzip.c -- simulate gzip using the zlib compression library * Copyright (C) 1995-2026 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ /* * minigzip is a minimal implementation of the gzip utility. This is * only an example of using zlib and isn't meant to replace the * full-featured gzip. No attempt is made to deal with file systems * limiting names to 14 or 8+3 characters, etc... Error checking is * very limited. So use minigzip only for testing; use gzip for the * real thing. On MSDOS, use only on file names without extension * or in pipe mode. */ /* @(#) $Id$ */ #ifndef _POSIX_C_SOURCE # define _POSIX_C_SOURCE 200112L #endif #if defined(_WIN32) && !defined(_CRT_SECURE_NO_WARNINGS) # define _CRT_SECURE_NO_WARNINGS #endif #if defined(_WIN32) && !defined(_CRT_NONSTDC_NO_DEPRECATE) # define _CRT_NONSTDC_NO_DEPRECATE #endif #include "zlib.h" #include <stdio.h> #ifdef STDC # include <string.h> # include <stdlib.h> |
| ︙ | ︙ | |||
36 37 38 39 40 41 42 | # include <stdlib.h> # endif # define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) #else # define SET_BINARY_MODE(file) #endif | < < < < < | | > > | > | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | # include <stdlib.h> # endif # define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) #else # define SET_BINARY_MODE(file) #endif #ifdef VMS # define unlink delete # define GZ_SUFFIX "-gz" #endif #if defined(__riscos) && !defined(__TARGET_UNIXLIB__) # define GZ_SUFFIX "/gz" # ifndef __GNUC__ # define unlink remove # define fileno(file) file->__file # endif #endif #if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os # include <unix.h> /* for fileno */ #endif #if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE) #ifndef WIN32 /* unlink already in stdio.h for WIN32 */ |
| ︙ | ︙ | |||
105 106 107 108 109 110 111 |
msgbuf[chars] = 0;
}
wcstombs(buf, msgbuf, chars + 1);
LocalFree(msgbuf);
}
else {
| | | 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
msgbuf[chars] = 0;
}
wcstombs(buf, msgbuf, chars + 1);
LocalFree(msgbuf);
}
else {
sprintf(buf, "unknown win32 error (%lu)", error);
}
SetLastError(lasterr);
return buf;
}
static void pwinerror (s)
|
| ︙ | ︙ | |||
137 138 139 140 141 142 143 144 145 146 147 148 149 150 | #ifdef MAXSEG_64K # define local static /* Needed for systems with limitation on stack size. */ #else # define local #endif #ifdef Z_SOLO /* for Z_SOLO, create simplified gz* functions using deflate and inflate */ #if defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE) # include <unistd.h> /* for unlink() */ #endif | > > > > > > > > > > > > > > > > > > > | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
#ifdef MAXSEG_64K
# define local static
/* Needed for systems with limitation on stack size. */
#else
# define local
#endif
/* ===========================================================================
* Safe string copy. Copy up to len bytes from src to dst, if src terminates
* with a null by then. If not, copy len-1 bytes from src, terminating it with
* a null in dst[len-1], cutting src short. Return a pointer to the terminating
* null. If len is zero, nothing is written to *dst and NULL is returned.
*/
static char *string_copy(char *dst, char const *src, z_size_t len) {
if (len == 0)
return NULL;
while (--len) {
*dst = *src++;
if (*dst == 0)
return dst;
dst++;
}
*dst = 0;
return dst;
}
#ifdef Z_SOLO
/* for Z_SOLO, create simplified gz* functions using deflate and inflate */
#if defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE)
# include <unistd.h> /* for unlink() */
#endif
|
| ︙ | ︙ | |||
220 221 222 223 224 225 226 |
strm->avail_in = len;
do {
strm->next_out = out;
strm->avail_out = BUFLEN;
(void)deflate(strm, Z_NO_FLUSH);
fwrite(out, 1, BUFLEN - strm->avail_out, gz->file);
} while (strm->avail_out == 0);
| | | | | 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
strm->avail_in = len;
do {
strm->next_out = out;
strm->avail_out = BUFLEN;
(void)deflate(strm, Z_NO_FLUSH);
fwrite(out, 1, BUFLEN - strm->avail_out, gz->file);
} while (strm->avail_out == 0);
return (int)len;
}
static int gzread(gzFile gz, void *buf, unsigned len) {
int ret;
unsigned got;
unsigned char in[1];
z_stream *strm;
if (gz == NULL || gz->write)
return 0;
if (gz->err)
return 0;
strm = &(gz->strm);
strm->next_out = (void *)buf;
strm->avail_out = len;
do {
got = (unsigned)fread(in, 1, 1, gz->file);
if (got == 0)
break;
strm->next_in = in;
strm->avail_in = 1;
ret = inflate(strm, Z_NO_FLUSH);
if (ret == Z_DATA_ERROR) {
gz->err = Z_DATA_ERROR;
gz->msg = strm->msg;
return 0;
}
if (ret == Z_STREAM_END)
inflateReset(strm);
} while (strm->avail_out);
return (int)(len - strm->avail_out);
}
static int gzclose(gzFile gz) {
z_stream *strm;
unsigned char out[BUFLEN];
if (gz == NULL)
|
| ︙ | ︙ | |||
387 388 389 390 391 392 393 |
/* ===========================================================================
* Compress the given file: create a corresponding .gz file and remove the
* original.
*/
static void file_compress(char *file, char *mode) {
| | < < < | | < > | < < < | < < | < < < > | 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
/* ===========================================================================
* Compress the given file: create a corresponding .gz file and remove the
* original.
*/
static void file_compress(char *file, char *mode) {
local char outfile[MAX_NAME_LEN+1], *end;
FILE *in;
gzFile out;
if (strlen(file) + strlen(GZ_SUFFIX) >= sizeof(outfile)) {
fprintf(stderr, "%s: filename too long\n", prog);
exit(1);
}
end = string_copy(outfile, file, sizeof(outfile));
string_copy(end, GZ_SUFFIX, sizeof(outfile) - (z_size_t)(end - outfile));
in = fopen(file, "rb");
if (in == NULL) {
perror(file);
exit(1);
}
out = gzopen(outfile, mode);
if (out == NULL) {
fclose(in);
fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile);
exit(1);
}
gz_compress(in, out);
unlink(file);
}
/* ===========================================================================
* Uncompress the given file and remove the original.
*/
static void file_uncompress(char *file) {
local char buf[MAX_NAME_LEN+1];
char *infile, *outfile;
FILE *out;
gzFile in;
z_size_t len = strlen(file);
if (len + strlen(GZ_SUFFIX) >= sizeof(buf)) {
fprintf(stderr, "%s: filename too long\n", prog);
exit(1);
}
string_copy(buf, file, sizeof(buf));
if (len > SUFFIX_LEN && strcmp(file+len-SUFFIX_LEN, GZ_SUFFIX) == 0) {
infile = file;
outfile = buf;
outfile[len-3] = '\0';
} else {
outfile = file;
infile = buf;
string_copy(buf + len, GZ_SUFFIX, sizeof(buf) - len);
}
in = gzopen(infile, "rb");
if (in == NULL) {
fprintf(stderr, "%s: can't gzopen %s\n", prog, infile);
exit(1);
}
out = fopen(outfile, "wb");
if (out == NULL) {
gzclose(in);
perror(file);
exit(1);
}
gz_uncompress(in, out);
unlink(infile);
|
| ︙ | ︙ | |||
484 485 486 487 488 489 490 |
* -1 to -9 : compression level
*/
int main(int argc, char *argv[]) {
int copyout = 0;
int uncompr = 0;
gzFile file;
| | < < < | < < | 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 |
* -1 to -9 : compression level
*/
int main(int argc, char *argv[]) {
int copyout = 0;
int uncompr = 0;
gzFile file;
char *bname, outmode[5];
string_copy(outmode, "wb6 ", sizeof(outmode));
prog = argv[0];
bname = strrchr(argv[0], '/');
if (bname)
bname++;
else
bname = argv[0];
argc--, argv++;
|
| ︙ | ︙ |
Changes to compat/zlib/treebuild.xml.
1 | <?xml version="1.0" ?> | | | | 1 2 3 4 5 6 7 8 9 10 |
<?xml version="1.0" ?>
<package name="zlib" version="1.3.2">
<library name="zlib" dlversion="1.3.2" dlname="z">
<property name="description"> zip compression library </property>
<property name="include-target-dir" value="$(@PACKAGE/install-includedir)" />
<!-- fixme: not implemented yet -->
<property name="compiler/c/inline" value="yes" />
<include-file name="zlib.h" scope="public" mode="644" />
|
| ︙ | ︙ |
Changes to compat/zlib/trees.c.
1 | /* trees.c -- output deflated data using Huffman coding | | | 1 2 3 4 5 6 7 8 9 | /* trees.c -- output deflated data using Huffman coding * Copyright (C) 1995-2026 Jean-loup Gailly * detect_data_type() function provided freely by Cosmin Truta, 2006 * For conditions of distribution and use, see copyright notice in zlib.h */ /* * ALGORITHM * |
| ︙ | ︙ | |||
108 109 110 111 112 113 114 | /* First normalized length for each code (0 = MIN_MATCH) */ local int base_dist[D_CODES]; /* First normalized distance for each code (0 = distance of 1) */ #else # include "trees.h" | | | 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
/* First normalized length for each code (0 = MIN_MATCH) */
local int base_dist[D_CODES];
/* First normalized distance for each code (0 = distance of 1) */
#else
# include "trees.h"
#endif /* defined(GEN_TREES_H) || !defined(STDC) */
struct static_tree_desc_s {
const ct_data *static_tree; /* static tree or NULL */
const intf *extra_bits; /* extra bits for each code or NULL */
int extra_base; /* base index for extra_bits */
int elems; /* max number of elements in the tree */
int max_length; /* max bit length for the codes */
|
| ︙ | ︙ | |||
148 149 150 151 152 153 154 |
/* ===========================================================================
* Reverse the first len bits of a code, using straightforward code (a faster
* method would use a table)
* IN assertion: 1 <= len <= 15
*/
local unsigned bi_reverse(unsigned code, int len) {
| | | 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
/* ===========================================================================
* Reverse the first len bits of a code, using straightforward code (a faster
* method would use a table)
* IN assertion: 1 <= len <= 15
*/
local unsigned bi_reverse(unsigned code, int len) {
unsigned res = 0;
do {
res |= code & 1;
code >>= 1, res <<= 1;
} while (--len > 0);
return res >> 1;
}
|
| ︙ | ︙ | |||
180 181 182 183 184 185 186 187 188 189 |
*/
local void bi_windup(deflate_state *s) {
if (s->bi_valid > 8) {
put_short(s, s->bi_buf);
} else if (s->bi_valid > 0) {
put_byte(s, (Byte)s->bi_buf);
}
s->bi_buf = 0;
s->bi_valid = 0;
#ifdef ZLIB_DEBUG
| > | | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
*/
local void bi_windup(deflate_state *s) {
if (s->bi_valid > 8) {
put_short(s, s->bi_buf);
} else if (s->bi_valid > 0) {
put_byte(s, (Byte)s->bi_buf);
}
s->bi_used = ((s->bi_valid - 1) & 7) + 1;
s->bi_buf = 0;
s->bi_valid = 0;
#ifdef ZLIB_DEBUG
s->bits_sent = (s->bits_sent + 7) & ~(ulg)7;
#endif
}
/* ===========================================================================
* Generate the codes for a given tree and bit counts (which need not be
* optimal).
* IN assertion: the array bl_count contains the bit length statistics for
|
| ︙ | ︙ | |||
462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
s->d_desc.stat_desc = &static_d_desc;
s->bl_desc.dyn_tree = s->bl_tree;
s->bl_desc.stat_desc = &static_bl_desc;
s->bi_buf = 0;
s->bi_valid = 0;
#ifdef ZLIB_DEBUG
s->compressed_len = 0L;
s->bits_sent = 0L;
#endif
/* Initialize the first block of the first file: */
init_block(s);
| > | 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
s->d_desc.stat_desc = &static_d_desc;
s->bl_desc.dyn_tree = s->bl_tree;
s->bl_desc.stat_desc = &static_bl_desc;
s->bi_buf = 0;
s->bi_valid = 0;
s->bi_used = 0;
#ifdef ZLIB_DEBUG
s->compressed_len = 0L;
s->bits_sent = 0L;
#endif
/* Initialize the first block of the first file: */
init_block(s);
|
| ︙ | ︙ | |||
720 721 722 723 724 725 726 |
tree[max_code + 1].Len = (ush)0xffff; /* guard */
for (n = 0; n <= max_code; n++) {
curlen = nextlen; nextlen = tree[n + 1].Len;
if (++count < max_count && curlen == nextlen) {
continue;
} else if (count < min_count) {
| | | 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 |
tree[max_code + 1].Len = (ush)0xffff; /* guard */
for (n = 0; n <= max_code; n++) {
curlen = nextlen; nextlen = tree[n + 1].Len;
if (++count < max_count && curlen == nextlen) {
continue;
} else if (count < min_count) {
s->bl_tree[curlen].Freq += (ush)count;
} else if (curlen != 0) {
if (curlen != prevlen) s->bl_tree[curlen].Freq++;
s->bl_tree[REP_3_6].Freq++;
} else if (count <= 10) {
s->bl_tree[REPZ_3_10].Freq++;
} else {
s->bl_tree[REPZ_11_138].Freq++;
|
| ︙ | ︙ | |||
813 814 815 816 817 818 819 |
* 3 but the actual value used is 4.)
*/
for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
}
/* Update opt_len to include the bit length tree and counts */
s->opt_len += 3*((ulg)max_blindex + 1) + 5 + 5 + 4;
| | | 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 |
* 3 but the actual value used is 4.)
*/
for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
}
/* Update opt_len to include the bit length tree and counts */
s->opt_len += 3*((ulg)max_blindex + 1) + 5 + 5 + 4;
Tracev((stderr, "\ndyn trees: dyn %lu, stat %lu",
s->opt_len, s->static_len));
return max_blindex;
}
/* ===========================================================================
* Send the header for a block using dynamic Huffman trees: the counts, the
|
| ︙ | ︙ | |||
839 840 841 842 843 844 845 |
send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */
send_bits(s, dcodes - 1, 5);
send_bits(s, blcodes - 4, 4); /* not -3 as stated in appnote.txt */
for (rank = 0; rank < blcodes; rank++) {
Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
send_bits(s, s->bl_tree[bl_order[rank]].Len, 3);
}
| | | | | 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 |
send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */
send_bits(s, dcodes - 1, 5);
send_bits(s, blcodes - 4, 4); /* not -3 as stated in appnote.txt */
for (rank = 0; rank < blcodes; rank++) {
Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
send_bits(s, s->bl_tree[bl_order[rank]].Len, 3);
}
Tracev((stderr, "\nbl tree: sent %lu", s->bits_sent));
send_tree(s, (ct_data *)s->dyn_ltree, lcodes - 1); /* literal tree */
Tracev((stderr, "\nlit tree: sent %lu", s->bits_sent));
send_tree(s, (ct_data *)s->dyn_dtree, dcodes - 1); /* distance tree */
Tracev((stderr, "\ndist tree: sent %lu", s->bits_sent));
}
/* ===========================================================================
* Send a stored block
*/
void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
ulg stored_len, int last) {
|
| ︙ | ︙ | |||
928 929 930 931 932 933 934 |
code = d_code(dist);
Assert (code < D_CODES, "bad d_code");
send_code(s, code, dtree); /* send the distance code */
extra = extra_dbits[code];
if (extra != 0) {
dist -= (unsigned)base_dist[code];
| | | 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 |
code = d_code(dist);
Assert (code < D_CODES, "bad d_code");
send_code(s, code, dtree); /* send the distance code */
extra = extra_dbits[code];
if (extra != 0) {
dist -= (unsigned)base_dist[code];
send_bits(s, (int)dist, extra); /* send the extra bits */
}
} /* literal or match pair ? */
/* Check for no overlay of pending_buf on needed symbols */
#ifdef LIT_MEM
Assert(s->pending < 2 * (s->lit_bufsize + sx), "pendingBuf overflow");
#else
|
| ︙ | ︙ | |||
1002 1003 1004 1005 1006 1007 1008 |
/* Check if the file is binary or text */
if (s->strm->data_type == Z_UNKNOWN)
s->strm->data_type = detect_data_type(s);
/* Construct the literal and distance trees */
build_tree(s, (tree_desc *)(&(s->l_desc)));
| | | | 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 |
/* Check if the file is binary or text */
if (s->strm->data_type == Z_UNKNOWN)
s->strm->data_type = detect_data_type(s);
/* Construct the literal and distance trees */
build_tree(s, (tree_desc *)(&(s->l_desc)));
Tracev((stderr, "\nlit data: dyn %lu, stat %lu", s->opt_len,
s->static_len));
build_tree(s, (tree_desc *)(&(s->d_desc)));
Tracev((stderr, "\ndist data: dyn %lu, stat %lu", s->opt_len,
s->static_len));
/* At this point, opt_len and static_len are the total bit lengths of
* the compressed block data, excluding the tree representations.
*/
/* Build the bit length tree for the above two trees, and get the index
* in bl_order of the last bit length code to send.
|
| ︙ | ︙ | |||
1079 1080 1081 1082 1083 1084 1085 |
if (last) {
bi_windup(s);
#ifdef ZLIB_DEBUG
s->compressed_len += 7; /* align on byte boundary */
#endif
}
Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len >> 3,
| | | 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 |
if (last) {
bi_windup(s);
#ifdef ZLIB_DEBUG
s->compressed_len += 7; /* align on byte boundary */
#endif
}
Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len >> 3,
s->compressed_len - 7*(ulg)last));
}
/* ===========================================================================
* Save the match info and tally the frequency counts. Return true if
* the current block must be flushed.
*/
int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) {
|
| ︙ | ︙ |
Changes to compat/zlib/uncompr.c.
1 | /* uncompr.c -- decompress a memory buffer | | | 1 2 3 4 5 6 7 8 9 | /* uncompr.c -- decompress a memory buffer * Copyright (C) 1995-2026 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #define ZLIB_INTERNAL #include "zlib.h" |
| ︙ | ︙ | |||
19 20 21 22 23 24 25 26 |
of source bytes consumed. Upon return, source + *sourceLen points to the
first unused input byte.
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_BUF_ERROR if there was not enough room in the output buffer, or
Z_DATA_ERROR if the input data was corrupted, including if the input data is
an incomplete zlib stream.
*/
| > > | | | | > > > < | < < < | | < | | > > > > > | < | < < | > > > > > > > > | > > > > > > | | 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 |
of source bytes consumed. Upon return, source + *sourceLen points to the
first unused input byte.
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_BUF_ERROR if there was not enough room in the output buffer, or
Z_DATA_ERROR if the input data was corrupted, including if the input data is
an incomplete zlib stream.
The _z versions of the functions take size_t length arguments.
*/
int ZEXPORT uncompress2_z(Bytef *dest, z_size_t *destLen, const Bytef *source,
z_size_t *sourceLen) {
z_stream stream;
int err;
const uInt max = (uInt)-1;
z_size_t len, left;
if (sourceLen == NULL || (*sourceLen > 0 && source == NULL) ||
destLen == NULL || (*destLen > 0 && dest == NULL))
return Z_STREAM_ERROR;
len = *sourceLen;
left = *destLen;
if (left == 0 && dest == Z_NULL)
dest = (Bytef *)&stream.reserved; /* next_out cannot be NULL */
stream.next_in = (z_const Bytef *)source;
stream.avail_in = 0;
stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0;
stream.opaque = (voidpf)0;
err = inflateInit(&stream);
if (err != Z_OK) return err;
stream.next_out = dest;
stream.avail_out = 0;
do {
if (stream.avail_out == 0) {
stream.avail_out = left > (z_size_t)max ? max : (uInt)left;
left -= stream.avail_out;
}
if (stream.avail_in == 0) {
stream.avail_in = len > (z_size_t)max ? max : (uInt)len;
len -= stream.avail_in;
}
err = inflate(&stream, Z_NO_FLUSH);
} while (err == Z_OK);
/* Set len and left to the unused input data and unused output space. Set
*sourceLen to the amount of input consumed. Set *destLen to the amount
of data produced. */
len += stream.avail_in;
left += stream.avail_out;
*sourceLen -= len;
*destLen -= left;
inflateEnd(&stream);
return err == Z_STREAM_END ? Z_OK :
err == Z_NEED_DICT ? Z_DATA_ERROR :
err == Z_BUF_ERROR && len == 0 ? Z_DATA_ERROR :
err;
}
int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source,
uLong *sourceLen) {
int ret;
z_size_t got = *destLen, used = *sourceLen;
ret = uncompress2_z(dest, &got, source, &used);
*sourceLen = (uLong)used;
*destLen = (uLong)got;
return ret;
}
int ZEXPORT uncompress_z(Bytef *dest, z_size_t *destLen, const Bytef *source,
z_size_t sourceLen) {
z_size_t used = sourceLen;
return uncompress2_z(dest, destLen, source, &used);
}
int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source,
uLong sourceLen) {
uLong used = sourceLen;
return uncompress2(dest, destLen, source, &used);
}
|
Changes to compat/zlib/win32/DLL_FAQ.txt.
1 2 3 4 5 6 7 8 |
Frequently Asked Questions about ZLIB1.DLL
This document describes the design, the rationale, and the usage
of the common DLL build of zlib, named ZLIB1.DLL. If you have
general questions about zlib, you should see the file "FAQ" found
in the zlib distribution, or at the following location:
| | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Frequently Asked Questions about ZLIB1.DLL
This document describes the design, the rationale, and the usage
of the common DLL build of zlib, named ZLIB1.DLL. If you have
general questions about zlib, you should see the file "FAQ" found
in the zlib distribution, or at the following location:
https://www.zlib.net/zlib_faq.html
1. What is ZLIB1.DLL, and how can I get it?
- ZLIB1.DLL is the common build of zlib as a DLL.
(Please remark the character '1' in the name.)
|
| ︙ | ︙ |
Changes to compat/zlib/win32/Makefile.gcc.
1 2 3 4 5 6 | # Makefile for zlib, derived from Makefile.dj2. # Modified for mingw32 by C. Spieler, 6/16/98. # Updated for zlib 1.2.x by Christian Spieler and Cosmin Truta, Mar-2003. # Last updated: Mar 2012. # Tested under Cygwin and MinGW. | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # Makefile for zlib, derived from Makefile.dj2. # Modified for mingw32 by C. Spieler, 6/16/98. # Updated for zlib 1.2.x by Christian Spieler and Cosmin Truta, Mar-2003. # Last updated: Mar 2012. # Tested under Cygwin and MinGW. # Copyright (C) 1995-2026 Jean-loup Gailly. # For conditions of distribution and use, see copyright notice in zlib.h # To compile, or to compile and test, type from the top level zlib directory: # # make -fwin32/Makefile.gcc; make test testdll -fwin32/Makefile.gcc # # To install libz.a, zconf.h and zlib.h in the system directories, type: |
| ︙ | ︙ | |||
46 47 48 49 50 51 52 | LD = $(CC) LDFLAGS = $(LOC) AR = $(PREFIX)ar ARFLAGS = rcs RC = $(PREFIX)windres | | | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | LD = $(CC) LDFLAGS = $(LOC) AR = $(PREFIX)ar ARFLAGS = rcs RC = $(PREFIX)windres RCFLAGS = STRIP = $(PREFIX)strip CP = cp -fp # If GNU install is available, replace $(CP) with install. INSTALL = $(CP) RM = rm -f |
| ︙ | ︙ | |||
72 73 74 75 76 77 78 | ./example echo hello world | ./minigzip | ./minigzip -d testdll: example_d.exe minigzip_d.exe ./example_d echo hello world | ./minigzip_d | ./minigzip_d -d | | | | | 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 | ./example echo hello world | ./minigzip | ./minigzip -d testdll: example_d.exe minigzip_d.exe ./example_d echo hello world | ./minigzip_d | ./minigzip_d -d %.o: %.c $(CC) $(CFLAGS) -c -o $@ $< %.o: %.S $(AS) $(ASFLAGS) -c -o $@ $< $(STATICLIB): $(OBJS) $(OBJA) $(AR) $(ARFLAGS) $@ $(OBJS) $(OBJA) $(IMPLIB): $(SHAREDLIB) $(SHAREDLIB): win32/zlib.def $(OBJS) $(OBJA) zlibrc.o $(CC) -shared -static-libgcc -Wl,--out-implib,$(IMPLIB) $(LDFLAGS) \ -o $@ win32/zlib.def $(OBJS) $(OBJA) zlibrc.o $(STRIP) $@ example.exe: example.o $(STATICLIB) $(LD) $(LDFLAGS) -o $@ example.o $(STATICLIB) $(STRIP) $@ |
| ︙ | ︙ |
Changes to compat/zlib/win32/README-WIN32.txt.
1 2 | ZLIB DATA COMPRESSION LIBRARY | | | | | | | | 1 2 3 4 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 | ZLIB DATA COMPRESSION LIBRARY zlib 1.3.2 is a general purpose data compression library. All the code is thread safe. The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files https://datatracker.ietf.org/doc/html/rfc1951 (zlib format), rfc1951.txt (deflate format), and rfc1952.txt (gzip format). All functions of the compression library are documented in the file zlib.h (volunteer to write man pages welcome, contact zlib@gzip.org). Two compiled examples are distributed in this package, example and minigzip. The example_d and minigzip_d flavors validate that the zlib1.dll file is working correctly. Questions about zlib should be sent to <zlib@gzip.org>. The zlib home page is https://zlib.net/ . Before reporting a problem, please check this site to verify that you have the latest version of zlib; otherwise get the latest version and check whether the problem still exists or not. PLEASE read DLL_FAQ.txt, and the zlib FAQ https://zlib.net/zlib_faq.html before asking for help. Manifest: The package zlib-1.3.2-win32-x86.zip will contain the following files: README-WIN32.txt This document ChangeLog Changes since previous zlib packages DLL_FAQ.txt Frequently asked questions about zlib1.dll zlib.3.pdf Documentation of this library in Adobe Acrobat format example.exe A statically-bound example (using zlib.lib, not the dll) |
| ︙ | ︙ | |||
55 56 57 58 59 60 61 |
the program's runtime directory (where the .exe resides)
zlib1.pdb Install in the same directory as zlib1.dll, in order to debug
an application crash using WinDbg or similar tools.
All .pdb files above are entirely optional, but are very useful to a developer
attempting to diagnose program misbehavior or a crash. Many additional
important files for developers can be found in the zlib127.zip source package
| | | | 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 |
the program's runtime directory (where the .exe resides)
zlib1.pdb Install in the same directory as zlib1.dll, in order to debug
an application crash using WinDbg or similar tools.
All .pdb files above are entirely optional, but are very useful to a developer
attempting to diagnose program misbehavior or a crash. Many additional
important files for developers can be found in the zlib127.zip source package
available from https://zlib.net/ - review that package's README file for details.
Acknowledgments:
The deflate format used by zlib was defined by Phil Katz. The deflate and
zlib specifications were written by L. Peter Deutsch. Thanks to all the
people who reported problems and suggested various improvements in zlib; they
are too numerous to cite here.
Copyright notice:
(C) 1995-2026 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
|
| ︙ | ︙ |
Changes to compat/zlib/win32/zlib.def.
| ︙ | ︙ | |||
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 |
deflateSetDictionary
deflateGetDictionary
deflateCopy
deflateReset
deflateParams
deflateTune
deflateBound
deflatePending
deflatePrime
deflateSetHeader
inflateSetDictionary
inflateGetDictionary
inflateSync
inflateCopy
inflateReset
inflateReset2
inflatePrime
inflateMark
inflateGetHeader
inflateBack
inflateBackEnd
zlibCompileFlags
; utility functions
compress
compress2
compressBound
uncompress
uncompress2
gzopen
gzdopen
gzbuffer
gzsetparams
gzread
gzfread
gzwrite
| > > > > > > > | 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 |
deflateSetDictionary
deflateGetDictionary
deflateCopy
deflateReset
deflateParams
deflateTune
deflateBound
deflateBound_z
deflatePending
deflateUsed
deflatePrime
deflateSetHeader
inflateSetDictionary
inflateGetDictionary
inflateSync
inflateCopy
inflateReset
inflateReset2
inflatePrime
inflateMark
inflateGetHeader
inflateBack
inflateBackEnd
zlibCompileFlags
; utility functions
compress
compress2
compress_z
compress2_z
compressBound
compressBound_z
uncompress
uncompress2
uncompress_z
uncompress2_z
gzopen
gzdopen
gzbuffer
gzsetparams
gzread
gzfread
gzwrite
|
| ︙ | ︙ |
Changes to compat/zlib/win32/zlib1.rc.
1 2 3 | #include <winver.h> #include "../zlib.h" | < | < < | | | 1 2 3 4 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 |
#include <winver.h>
#include "../zlib.h"
VS_VERSION_INFO VERSIONINFO
FILEVERSION ZLIB_VER_MAJOR,ZLIB_VER_MINOR,ZLIB_VER_REVISION,0
PRODUCTVERSION ZLIB_VER_MAJOR,ZLIB_VER_MINOR,ZLIB_VER_REVISION,0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG
FILEFLAGS 1
#else
FILEFLAGS 0
#endif
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE 0 // not used
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
//language ID = U.S. English, char set = Windows, Multilingual
BEGIN
VALUE "FileDescription", "zlib data compression library\0"
VALUE "FileVersion", ZLIB_VERSION "\0"
VALUE "InternalName", "zlib1.dll\0"
VALUE "LegalCopyright", "(C) 1995-2026 Jean-loup Gailly & Mark Adler\0"
VALUE "OriginalFilename", "zlib1.dll\0"
VALUE "ProductName", "zlib\0"
VALUE "ProductVersion", ZLIB_VERSION "\0"
VALUE "Comments", "For more information visit https://www.zlib.net/\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 1252
END
END
|
Changes to compat/zlib/zconf.h.
1 | /* zconf.h -- configuration of the zlib compression library | | | 1 2 3 4 5 6 7 8 9 | /* zconf.h -- configuration of the zlib compression library * Copyright (C) 1995-2026 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #ifndef ZCONF_H #define ZCONF_H |
| ︙ | ︙ | |||
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 | # define adler32 z_adler32 # define adler32_combine z_adler32_combine # define adler32_combine64 z_adler32_combine64 # define adler32_z z_adler32_z # ifndef Z_SOLO # define compress z_compress # define compress2 z_compress2 # define compressBound z_compressBound # endif # define crc32 z_crc32 # define crc32_combine z_crc32_combine # define crc32_combine64 z_crc32_combine64 # define crc32_combine_gen z_crc32_combine_gen # define crc32_combine_gen64 z_crc32_combine_gen64 # define crc32_combine_op z_crc32_combine_op # define crc32_z z_crc32_z # define deflate z_deflate # define deflateBound z_deflateBound # define deflateCopy z_deflateCopy # define deflateEnd z_deflateEnd # define deflateGetDictionary z_deflateGetDictionary # define deflateInit z_deflateInit # define deflateInit2 z_deflateInit2 # define deflateInit2_ z_deflateInit2_ # define deflateInit_ z_deflateInit_ # define deflateParams z_deflateParams # define deflatePending z_deflatePending # define deflatePrime z_deflatePrime # define deflateReset z_deflateReset # define deflateResetKeep z_deflateResetKeep # define deflateSetDictionary z_deflateSetDictionary # define deflateSetHeader z_deflateSetHeader # define deflateTune z_deflateTune # define deflate_copyright z_deflate_copyright # define get_crc_table z_get_crc_table # ifndef Z_SOLO # define gz_error z_gz_error # define gz_intmax z_gz_intmax # define gz_strwinerror z_gz_strwinerror # define gzbuffer z_gzbuffer | > > > > > | 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 | # define adler32 z_adler32 # define adler32_combine z_adler32_combine # define adler32_combine64 z_adler32_combine64 # define adler32_z z_adler32_z # ifndef Z_SOLO # define compress z_compress # define compress2 z_compress2 # define compress_z z_compress_z # define compress2_z z_compress2_z # define compressBound z_compressBound # define compressBound_z z_compressBound_z # endif # define crc32 z_crc32 # define crc32_combine z_crc32_combine # define crc32_combine64 z_crc32_combine64 # define crc32_combine_gen z_crc32_combine_gen # define crc32_combine_gen64 z_crc32_combine_gen64 # define crc32_combine_op z_crc32_combine_op # define crc32_z z_crc32_z # define deflate z_deflate # define deflateBound z_deflateBound # define deflateBound_z z_deflateBound_z # define deflateCopy z_deflateCopy # define deflateEnd z_deflateEnd # define deflateGetDictionary z_deflateGetDictionary # define deflateInit z_deflateInit # define deflateInit2 z_deflateInit2 # define deflateInit2_ z_deflateInit2_ # define deflateInit_ z_deflateInit_ # define deflateParams z_deflateParams # define deflatePending z_deflatePending # define deflatePrime z_deflatePrime # define deflateReset z_deflateReset # define deflateResetKeep z_deflateResetKeep # define deflateSetDictionary z_deflateSetDictionary # define deflateSetHeader z_deflateSetHeader # define deflateTune z_deflateTune # define deflateUsed z_deflateUsed # define deflate_copyright z_deflate_copyright # define get_crc_table z_get_crc_table # ifndef Z_SOLO # define gz_error z_gz_error # define gz_intmax z_gz_intmax # define gz_strwinerror z_gz_strwinerror # define gzbuffer z_gzbuffer |
| ︙ | ︙ | |||
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint # define inflateUndermine z_inflateUndermine # define inflateValidate z_inflateValidate # define inflate_copyright z_inflate_copyright # define inflate_fast z_inflate_fast # define inflate_table z_inflate_table # ifndef Z_SOLO # define uncompress z_uncompress # define uncompress2 z_uncompress2 # endif # define zError z_zError # ifndef Z_SOLO # define zcalloc z_zcalloc # define zcfree z_zcfree # endif # define zlibCompileFlags z_zlibCompileFlags | > > > | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint # define inflateUndermine z_inflateUndermine # define inflateValidate z_inflateValidate # define inflate_copyright z_inflate_copyright # define inflate_fast z_inflate_fast # define inflate_table z_inflate_table # define inflate_fixed z_inflate_fixed # ifndef Z_SOLO # define uncompress z_uncompress # define uncompress2 z_uncompress2 # define uncompress_z z_uncompress_z # define uncompress2_z z_uncompress2_z # endif # define zError z_zError # ifndef Z_SOLO # define zcalloc z_zcalloc # define zcfree z_zcfree # endif # define zlibCompileFlags z_zlibCompileFlags |
| ︙ | ︙ | |||
230 231 232 233 234 235 236 | #ifndef STDC # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ # define const /* note: need a more gentle solution here */ # endif #endif | > | | | | > | 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
#ifndef STDC
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
# define const /* note: need a more gentle solution here */
# endif
#endif
#ifndef z_const
# ifdef ZLIB_CONST
# define z_const const
# else
# define z_const
# endif
#endif
#ifdef Z_SOLO
# ifdef _WIN64
typedef unsigned long long z_size_t;
# else
typedef unsigned long z_size_t;
|
| ︙ | ︙ | |||
429 430 431 432 433 434 435 | #ifdef Z_U4 typedef Z_U4 z_crc_t; #else typedef unsigned long z_crc_t; #endif | | | | 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 | #ifdef Z_U4 typedef Z_U4 z_crc_t; #else typedef unsigned long z_crc_t; #endif #if HAVE_UNISTD_H-0 /* may be set to #if 1 by ./configure */ # define Z_HAVE_UNISTD_H #endif #if HAVE_STDARG_H-0 /* may be set to #if 1 by ./configure */ # define Z_HAVE_STDARG_H #endif #ifdef STDC # ifndef Z_SOLO # include <sys/types.h> /* for off_t */ # endif |
| ︙ | ︙ | |||
466 467 468 469 470 471 472 | * equivalently requesting no 64-bit operations */ #if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 # undef _LARGEFILE64_SOURCE #endif #ifndef Z_HAVE_UNISTD_H | | < < < < | | 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
* equivalently requesting no 64-bit operations
*/
#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
# undef _LARGEFILE64_SOURCE
#endif
#ifndef Z_HAVE_UNISTD_H
# if defined(__WATCOMC__) || defined(__GO32__) || \
(defined(_LARGEFILE64_SOURCE) && !defined(_WIN32))
# define Z_HAVE_UNISTD_H
# endif
#endif
#ifndef Z_SOLO
# if defined(Z_HAVE_UNISTD_H)
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
# ifdef VMS
|
| ︙ | ︙ | |||
506 507 508 509 510 511 512 | #if !defined(SEEK_SET) && !defined(Z_SOLO) # define SEEK_SET 0 /* Seek from beginning of file. */ # define SEEK_CUR 1 /* Seek from current position. */ # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ #endif #ifndef z_off_t | | | > | | > > | | < | 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 | #if !defined(SEEK_SET) && !defined(Z_SOLO) # define SEEK_SET 0 /* Seek from beginning of file. */ # define SEEK_CUR 1 /* Seek from current position. */ # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ #endif #ifndef z_off_t # define z_off_t long long #endif #if !defined(_WIN32) && defined(Z_LARGE64) # define z_off64_t off64_t #elif defined(__MINGW32__) # define z_off64_t long long #elif defined(_WIN32) && !defined(__GNUC__) # define z_off64_t __int64 #elif defined(__GO32__) # define z_off64_t offset_t #else # define z_off64_t z_off_t #endif /* MVS linker does not support external names larger than 8 bytes */ #if defined(__MVS__) #pragma map(deflateInit_,"DEIN") #pragma map(deflateInit2_,"DEIN2") #pragma map(deflateEnd,"DEEND") |
| ︙ | ︙ |
Deleted compat/zlib/zconf.h.cmakein.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to compat/zlib/zconf.h.in.
1 | /* zconf.h -- configuration of the zlib compression library | | | 1 2 3 4 5 6 7 8 9 | /* zconf.h -- configuration of the zlib compression library * Copyright (C) 1995-2026 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #ifndef ZCONF_H #define ZCONF_H |
| ︙ | ︙ | |||
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 | # define adler32 z_adler32 # define adler32_combine z_adler32_combine # define adler32_combine64 z_adler32_combine64 # define adler32_z z_adler32_z # ifndef Z_SOLO # define compress z_compress # define compress2 z_compress2 # define compressBound z_compressBound # endif # define crc32 z_crc32 # define crc32_combine z_crc32_combine # define crc32_combine64 z_crc32_combine64 # define crc32_combine_gen z_crc32_combine_gen # define crc32_combine_gen64 z_crc32_combine_gen64 # define crc32_combine_op z_crc32_combine_op # define crc32_z z_crc32_z # define deflate z_deflate # define deflateBound z_deflateBound # define deflateCopy z_deflateCopy # define deflateEnd z_deflateEnd # define deflateGetDictionary z_deflateGetDictionary # define deflateInit z_deflateInit # define deflateInit2 z_deflateInit2 # define deflateInit2_ z_deflateInit2_ # define deflateInit_ z_deflateInit_ # define deflateParams z_deflateParams # define deflatePending z_deflatePending # define deflatePrime z_deflatePrime # define deflateReset z_deflateReset # define deflateResetKeep z_deflateResetKeep # define deflateSetDictionary z_deflateSetDictionary # define deflateSetHeader z_deflateSetHeader # define deflateTune z_deflateTune # define deflate_copyright z_deflate_copyright # define get_crc_table z_get_crc_table # ifndef Z_SOLO # define gz_error z_gz_error # define gz_intmax z_gz_intmax # define gz_strwinerror z_gz_strwinerror # define gzbuffer z_gzbuffer | > > > > > | 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 | # define adler32 z_adler32 # define adler32_combine z_adler32_combine # define adler32_combine64 z_adler32_combine64 # define adler32_z z_adler32_z # ifndef Z_SOLO # define compress z_compress # define compress2 z_compress2 # define compress_z z_compress_z # define compress2_z z_compress2_z # define compressBound z_compressBound # define compressBound_z z_compressBound_z # endif # define crc32 z_crc32 # define crc32_combine z_crc32_combine # define crc32_combine64 z_crc32_combine64 # define crc32_combine_gen z_crc32_combine_gen # define crc32_combine_gen64 z_crc32_combine_gen64 # define crc32_combine_op z_crc32_combine_op # define crc32_z z_crc32_z # define deflate z_deflate # define deflateBound z_deflateBound # define deflateBound_z z_deflateBound_z # define deflateCopy z_deflateCopy # define deflateEnd z_deflateEnd # define deflateGetDictionary z_deflateGetDictionary # define deflateInit z_deflateInit # define deflateInit2 z_deflateInit2 # define deflateInit2_ z_deflateInit2_ # define deflateInit_ z_deflateInit_ # define deflateParams z_deflateParams # define deflatePending z_deflatePending # define deflatePrime z_deflatePrime # define deflateReset z_deflateReset # define deflateResetKeep z_deflateResetKeep # define deflateSetDictionary z_deflateSetDictionary # define deflateSetHeader z_deflateSetHeader # define deflateTune z_deflateTune # define deflateUsed z_deflateUsed # define deflate_copyright z_deflate_copyright # define get_crc_table z_get_crc_table # ifndef Z_SOLO # define gz_error z_gz_error # define gz_intmax z_gz_intmax # define gz_strwinerror z_gz_strwinerror # define gzbuffer z_gzbuffer |
| ︙ | ︙ | |||
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint # define inflateUndermine z_inflateUndermine # define inflateValidate z_inflateValidate # define inflate_copyright z_inflate_copyright # define inflate_fast z_inflate_fast # define inflate_table z_inflate_table # ifndef Z_SOLO # define uncompress z_uncompress # define uncompress2 z_uncompress2 # endif # define zError z_zError # ifndef Z_SOLO # define zcalloc z_zcalloc # define zcfree z_zcfree # endif # define zlibCompileFlags z_zlibCompileFlags | > > > | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint # define inflateUndermine z_inflateUndermine # define inflateValidate z_inflateValidate # define inflate_copyright z_inflate_copyright # define inflate_fast z_inflate_fast # define inflate_table z_inflate_table # define inflate_fixed z_inflate_fixed # ifndef Z_SOLO # define uncompress z_uncompress # define uncompress2 z_uncompress2 # define uncompress_z z_uncompress_z # define uncompress2_z z_uncompress2_z # endif # define zError z_zError # ifndef Z_SOLO # define zcalloc z_zcalloc # define zcfree z_zcfree # endif # define zlibCompileFlags z_zlibCompileFlags |
| ︙ | ︙ | |||
230 231 232 233 234 235 236 | #ifndef STDC # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ # define const /* note: need a more gentle solution here */ # endif #endif | > | | | | > | 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
#ifndef STDC
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
# define const /* note: need a more gentle solution here */
# endif
#endif
#ifndef z_const
# ifdef ZLIB_CONST
# define z_const const
# else
# define z_const
# endif
#endif
#ifdef Z_SOLO
# ifdef _WIN64
typedef unsigned long long z_size_t;
# else
typedef unsigned long z_size_t;
|
| ︙ | ︙ | |||
429 430 431 432 433 434 435 | #ifdef Z_U4 typedef Z_U4 z_crc_t; #else typedef unsigned long z_crc_t; #endif | | | | 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 | #ifdef Z_U4 typedef Z_U4 z_crc_t; #else typedef unsigned long z_crc_t; #endif #if HAVE_UNISTD_H-0 /* may be set to #if 1 by ./configure */ # define Z_HAVE_UNISTD_H #endif #if HAVE_STDARG_H-0 /* may be set to #if 1 by ./configure */ # define Z_HAVE_STDARG_H #endif #ifdef STDC # ifndef Z_SOLO # include <sys/types.h> /* for off_t */ # endif |
| ︙ | ︙ | |||
466 467 468 469 470 471 472 | * equivalently requesting no 64-bit operations */ #if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 # undef _LARGEFILE64_SOURCE #endif #ifndef Z_HAVE_UNISTD_H | | < < < < | | 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
* equivalently requesting no 64-bit operations
*/
#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
# undef _LARGEFILE64_SOURCE
#endif
#ifndef Z_HAVE_UNISTD_H
# if defined(__WATCOMC__) || defined(__GO32__) || \
(defined(_LARGEFILE64_SOURCE) && !defined(_WIN32))
# define Z_HAVE_UNISTD_H
# endif
#endif
#ifndef Z_SOLO
# if defined(Z_HAVE_UNISTD_H)
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
# ifdef VMS
|
| ︙ | ︙ | |||
506 507 508 509 510 511 512 | #if !defined(SEEK_SET) && !defined(Z_SOLO) # define SEEK_SET 0 /* Seek from beginning of file. */ # define SEEK_CUR 1 /* Seek from current position. */ # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ #endif #ifndef z_off_t | | | > | | > > | | < | 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 | #if !defined(SEEK_SET) && !defined(Z_SOLO) # define SEEK_SET 0 /* Seek from beginning of file. */ # define SEEK_CUR 1 /* Seek from current position. */ # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ #endif #ifndef z_off_t # define z_off_t long long #endif #if !defined(_WIN32) && defined(Z_LARGE64) # define z_off64_t off64_t #elif defined(__MINGW32__) # define z_off64_t long long #elif defined(_WIN32) && !defined(__GNUC__) # define z_off64_t __int64 #elif defined(__GO32__) # define z_off64_t offset_t #else # define z_off64_t z_off_t #endif /* MVS linker does not support external names larger than 8 bytes */ #if defined(__MVS__) #pragma map(deflateInit_,"DEIN") #pragma map(deflateInit2_,"DEIN2") #pragma map(deflateEnd,"DEEND") |
| ︙ | ︙ |
Changes to compat/zlib/zlib.3.
|
| | | 1 2 3 4 5 6 7 8 | .TH ZLIB 3 "17 Feb 2026" .SH NAME zlib \- compression/decompression library .SH SYNOPSIS [see .I zlib.h for full description] .SH DESCRIPTION |
| ︙ | ︙ | |||
53 54 55 56 57 58 59 | .LP An experimental package to read and write files in the .zip format, written on top of .I zlib by Gilles Vollant (info@winimage.com), is available at: .IP | | | | | | | | | | | | 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | .LP An experimental package to read and write files in the .zip format, written on top of .I zlib by Gilles Vollant (info@winimage.com), is available at: .IP https://www.winimage.com/zLibDll/minizip.html and also in the .I contrib/minizip directory of the main .I zlib source distribution. .SH "SEE ALSO" The .I zlib web site can be found at: .IP https://zlib.net/ .LP The data format used by the .I zlib library is described by RFC (Request for Comments) 1950 to 1952 at: .IP https://datatracker.ietf.org/doc/html/rfc1950 (for the zlib header and trailer format) .br https://datatracker.ietf.org/doc/html/rfc1951 (for the deflate compressed data format) .br https://datatracker.ietf.org/doc/html/rfc1952 (for the gzip header and trailer format) .LP Mark Nelson wrote an article about .I zlib for the Jan. 1997 issue of Dr. Dobb's Journal; a copy of the article is available at: .IP https://zlib.net/nelson/ .SH "REPORTING PROBLEMS" Before reporting a problem, please check the .I zlib web site to verify that you have the latest version of .IR zlib ; otherwise, obtain the latest version and see if the problem still exists. Please read the .I zlib FAQ at: .IP https://zlib.net/zlib_faq.html .LP before asking for help. Send questions and/or comments to zlib@gzip.org, or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). .SH AUTHORS AND LICENSE Version 1.3.2 .LP Copyright (C) 1995-2026 Jean-loup Gailly and Mark Adler .LP This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. .LP Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it |
| ︙ | ︙ |
Changes to compat/zlib/zlib.3.pdf.
cannot compute difference between binary files
Changes to compat/zlib/zlib.h.
1 | /* zlib.h -- interface of the 'zlib' general purpose compression library | | | | 1 2 3 4 5 6 7 8 9 10 11 | /* zlib.h -- interface of the 'zlib' general purpose compression library version 1.3.2, February 17th, 2026 Copyright (C) 1995-2026 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it |
| ︙ | ︙ | |||
20 21 22 23 24 25 26 | 3. This notice may not be removed or altered from any source distribution. Jean-loup Gailly Mark Adler jloup@gzip.org madler@alumni.caltech.edu The data format used by the zlib library is described by RFCs (Request for | | > > > | > | | | | 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 |
3. This notice may not be removed or altered from any source distribution.
Jean-loup Gailly Mark Adler
jloup@gzip.org madler@alumni.caltech.edu
The data format used by the zlib library is described by RFCs (Request for
Comments) 1950 to 1952 at https://datatracker.ietf.org/doc/html/rfc1950
(zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
*/
#ifndef ZLIB_H
#define ZLIB_H
#ifdef ZLIB_BUILD
# include <zconf.h>
#else
# include "zconf.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define ZLIB_VERSION "1.3.2"
#define ZLIB_VERNUM 0x1320
#define ZLIB_VER_MAJOR 1
#define ZLIB_VER_MINOR 3
#define ZLIB_VER_REVISION 2
#define ZLIB_VER_SUBREVISION 0
/*
The 'zlib' compression library provides in-memory compression and
decompression functions, including integrity checks of the uncompressed data.
This version of the library supports only one compression method (deflation)
but other algorithms will be added later and will have the same stream
|
| ︙ | ︙ | |||
437 438 439 440 441 442 443 |
the zlib or gzip format, this will cause inflate() to return immediately
after the header and before the first block. When doing a raw inflate,
inflate() will go ahead and process the first block, and will return when it
gets to the end of that block, or when it runs out of data.
The Z_BLOCK option assists in appending to or combining deflate streams.
To assist in this, on return inflate() always sets strm->data_type to the
| | | 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 |
the zlib or gzip format, this will cause inflate() to return immediately
after the header and before the first block. When doing a raw inflate,
inflate() will go ahead and process the first block, and will return when it
gets to the end of that block, or when it runs out of data.
The Z_BLOCK option assists in appending to or combining deflate streams.
To assist in this, on return inflate() always sets strm->data_type to the
number of unused bits in the input taken from strm->next_in, plus 64 if
inflate() is currently decoding the last block in the deflate stream, plus
128 if inflate() returned immediately after decoding an end-of-block code or
decoding the complete header up to just before the first byte of the deflate
stream. The end-of-block will not be indicated until all of the uncompressed
data from that block has been written to strm->next_out. The number of
unused bits may in general be greater than seven, except when bit 7 of
data_type is set, in which case the number of unused bits will be less than
|
| ︙ | ︙ | |||
583 584 585 586 587 588 589 |
for the internal compression state. memLevel=1 uses minimum memory but is
slow and reduces compression ratio; memLevel=9 uses maximum memory for
optimal speed. The default value is 8. See zconf.h for total memory usage
as a function of windowBits and memLevel.
The strategy parameter is used to tune the compression algorithm. Use the
value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
| < | > | | | | | > | > | | > | | | 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 |
for the internal compression state. memLevel=1 uses minimum memory but is
slow and reduces compression ratio; memLevel=9 uses maximum memory for
optimal speed. The default value is 8. See zconf.h for total memory usage
as a function of windowBits and memLevel.
The strategy parameter is used to tune the compression algorithm. Use the
value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
filter (or predictor), Z_RLE to limit match distances to one (run-length
encoding), or Z_HUFFMAN_ONLY to force Huffman encoding only (no string
matching). Filtered data consists mostly of small values with a somewhat
random distribution, as produced by the PNG filters. In this case, the
compression algorithm is tuned to compress them better. The effect of
Z_FILTERED is to force more Huffman coding and less string matching than the
default; it is intermediate between Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY.
Z_RLE is almost as fast as Z_HUFFMAN_ONLY, but should give better
compression for PNG image data than Huffman only. The degree of string
matching from most to none is: Z_DEFAULT_STRATEGY, Z_FILTERED, Z_RLE, then
Z_HUFFMAN_ONLY. The strategy parameter affects the compression ratio but
never the correctness of the compressed output, even if it is not set
optimally for the given data. Z_FIXED uses the default string matching, but
prevents the use of dynamic Huffman codes, allowing for a simpler decoder
for special applications.
deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid
method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is
incompatible with the version assumed by the caller (ZLIB_VERSION). msg is
set to null if there is no error message. deflateInit2 does not perform any
compression: this will be done by deflate().
|
| ︙ | ︙ | |||
754 755 756 757 758 759 760 |
specific input data. Read the deflate.c source code for the meaning of the
max_lazy, good_length, nice_length, and max_chain parameters.
deflateTune() can be called after deflateInit() or deflateInit2(), and
returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
*/
| | | > > > > > > > > > > > > > > > > > > | 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 |
specific input data. Read the deflate.c source code for the meaning of the
max_lazy, good_length, nice_length, and max_chain parameters.
deflateTune() can be called after deflateInit() or deflateInit2(), and
returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
*/
ZEXTERN uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen);
ZEXTERN z_size_t ZEXPORT deflateBound_z(z_streamp strm, z_size_t sourceLen);
/*
deflateBound() returns an upper bound on the compressed size after
deflation of sourceLen bytes. It must be called after deflateInit() or
deflateInit2(), and after deflateSetHeader(), if used. This would be used
to allocate an output buffer for deflation in a single pass, and so would be
called before deflate(). If that first deflate() call is provided the
sourceLen input bytes, an output buffer allocated to the size returned by
deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed
to return Z_STREAM_END. Note that it is possible for the compressed size to
be larger than the value returned by deflateBound() if flush options other
than Z_FINISH or Z_NO_FLUSH are used.
delfateBound_z() is the same, but takes and returns a size_t length. Note
that a long is 32 bits on Windows.
*/
ZEXTERN int ZEXPORT deflatePending(z_streamp strm,
unsigned *pending,
int *bits);
/*
deflatePending() returns the number of bytes and bits of output that have
been generated, but not yet provided in the available output. The bytes not
provided would be due to the available output space having being consumed.
The number of bits of output not provided are between 0 and 7, where they
await more bits to join them in order to fill out a full byte. If pending
or bits are Z_NULL, then those values are not set.
deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source
stream state was inconsistent. If an int is 16 bits and memLevel is 9, then
it is possible for the number of pending bytes to not fit in an unsigned. In
that case Z_BUF_ERROR is returned and *pending is set to the maximum value
of an unsigned.
*/
ZEXTERN int ZEXPORT deflateUsed(z_streamp strm,
int *bits);
/*
deflateUsed() returns in *bits the most recent number of deflate bits used
in the last byte when flushing to a byte boundary. The result is in 1..8, or
0 if there has not yet been a flush. This helps determine the location of
the last bit of a deflate stream.
deflateUsed returns Z_OK if success, or Z_STREAM_ERROR if the source
stream state was inconsistent.
*/
ZEXTERN int ZEXPORT deflatePrime(z_streamp strm,
int bits,
int value);
/*
|
| ︙ | ︙ | |||
983 984 985 986 987 988 989 |
the windowBits parameter is invalid.
*/
ZEXTERN int ZEXPORT inflatePrime(z_streamp strm,
int bits,
int value);
/*
| | | | | | > | | > | > > > > > > > > | 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 |
the windowBits parameter is invalid.
*/
ZEXTERN int ZEXPORT inflatePrime(z_streamp strm,
int bits,
int value);
/*
This function inserts bits in the inflate input stream. The intent is to
use inflatePrime() to start inflating at a bit position in the middle of a
byte. The provided bits will be used before any bytes are used from
next_in. This function should be used with raw inflate, before the first
inflate() call, after inflateInit2() or inflateReset(). It can also be used
after an inflate() return indicates the end of a deflate block or header
when using Z_BLOCK. bits must be less than or equal to 16, and that many of
the least significant bits of value will be inserted in the input. The
other bits in value can be non-zero, and will be ignored.
If bits is negative, then the input stream bit buffer is emptied. Then
inflatePrime() can be called again to put bits in the buffer. This is used
to clear out bits leftover after feeding inflate a block description prior
to feeding inflate codes.
inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
stream state was inconsistent, or if bits is out of range. If inflate was
in the middle of processing a header, trailer, or stored block lengths, then
it is possible for there to be only eight bits available in the bit buffer.
In that case, bits > 8 is considered out of range. However, when used as
outlined above, there will always be 16 bits available in the buffer for
insertion. As noted in its documentation above, inflate records the number
of bits in the bit buffer on return in data_type. 32 minus that is the
number of bits available for insertion. inflatePrime does not update
data_type with the new number of bits in buffer.
*/
ZEXTERN long ZEXPORT inflateMark(z_streamp strm);
/*
This function returns two values, one in the lower 16 bits of the return
value, and the other in the remaining upper bits, obtained by shifting the
return value down 16 bits. If the upper value is -1 and the lower value is
|
| ︙ | ︙ | |||
1043 1044 1045 1046 1047 1048 1049 |
being decoded, then head->done is set to -1 to indicate that there will be
no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be
used to force inflate() to return immediately after header processing is
complete and before any actual data is decompressed.
The text, time, xflags, and os fields are filled in with the gzip header
contents. hcrc is set to true if there is a header CRC. (The header CRC
| > > | | | | | < | | > | | | < | | > | 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 |
being decoded, then head->done is set to -1 to indicate that there will be
no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be
used to force inflate() to return immediately after header processing is
complete and before any actual data is decompressed.
The text, time, xflags, and os fields are filled in with the gzip header
contents. hcrc is set to true if there is a header CRC. (The header CRC
was valid if done is set to one.) The extra, name, and comment pointers
much each be either Z_NULL or point to space to store that information from
the header. If extra is not Z_NULL, then extra_max contains the maximum
number of bytes that can be written to extra. Once done is true, extra_len
contains the actual extra field length, and extra contains the extra field,
or that field truncated if extra_max is less than extra_len. If name is not
Z_NULL, then up to name_max characters, including the terminating zero, are
written there. If comment is not Z_NULL, then up to comm_max characters,
including the terminating zero, are written there. The application can tell
that the name or comment did not fit in the provided space by the absence of
a terminating zero. If any of extra, name, or comment are not present in
the header, then that field's pointer is set to Z_NULL. This allows the use
of deflateSetHeader() with the returned structure to duplicate the header.
Note that if those fields initially pointed to allocated memory, then the
application will need to save them elsewhere so that they can be eventually
freed.
If inflateGetHeader is not used, then the header information is simply
discarded. The header is always checked for validity, including the header
CRC if present. inflateReset() will reset the process to discard the header
information. The application would need to call inflateGetHeader() again to
retrieve the header from the next gzip stream.
|
| ︙ | ︙ | |||
1204 1205 1206 1207 1208 1209 1210 |
18-19: 0 (reserved)
Operation variations (changes in library functionality):
20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate
21: FASTEST -- deflate algorithm with only one, lowest compression level
22,23: 0 (reserved)
| | | > | | > | > > | > > > > | > > | | | > > | 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 |
18-19: 0 (reserved)
Operation variations (changes in library functionality):
20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate
21: FASTEST -- deflate algorithm with only one, lowest compression level
22,23: 0 (reserved)
The sprintf variant used by gzprintf (all zeros is best):
24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format
25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() is not secure!
26: 0 = returns value, 1 = void -- 1 means inferred string length returned
27: 0 = gzprintf() present, 1 = not -- 1 means gzprintf() returns an error
Remainder:
28-31: 0 (reserved)
*/
#ifndef Z_SOLO
/* utility functions */
/*
The following utility functions are implemented on top of the basic
stream-oriented functions. To simplify the interface, some default options
are assumed (compression level and memory usage, standard memory allocation
functions). The source code of these utility functions can be modified if
you need special options. The _z versions of the functions use the size_t
type for lengths. Note that a long is 32 bits on Windows.
*/
ZEXTERN int ZEXPORT compress(Bytef *dest, uLongf *destLen,
const Bytef *source, uLong sourceLen);
ZEXTERN int ZEXPORT compress_z(Bytef *dest, z_size_t *destLen,
const Bytef *source, z_size_t sourceLen);
/*
Compresses the source buffer into the destination buffer. sourceLen is
the byte length of the source buffer. Upon entry, destLen is the total size
of the destination buffer, which must be at least the value returned by
compressBound(sourceLen). Upon exit, destLen is the actual size of the
compressed data. compress() is equivalent to compress2() with a level
parameter of Z_DEFAULT_COMPRESSION.
compress returns Z_OK if success, Z_MEM_ERROR if there was not
enough memory, Z_BUF_ERROR if there was not enough room in the output
buffer.
*/
ZEXTERN int ZEXPORT compress2(Bytef *dest, uLongf *destLen,
const Bytef *source, uLong sourceLen,
int level);
ZEXTERN int ZEXPORT compress2_z(Bytef *dest, z_size_t *destLen,
const Bytef *source, z_size_t sourceLen,
int level);
/*
Compresses the source buffer into the destination buffer. The level
parameter has the same meaning as in deflateInit. sourceLen is the byte
length of the source buffer. Upon entry, destLen is the total size of the
destination buffer, which must be at least the value returned by
compressBound(sourceLen). Upon exit, destLen is the actual size of the
compressed data.
compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
Z_STREAM_ERROR if the level parameter is invalid.
*/
ZEXTERN uLong ZEXPORT compressBound(uLong sourceLen);
ZEXTERN z_size_t ZEXPORT compressBound_z(z_size_t sourceLen);
/*
compressBound() returns an upper bound on the compressed size after
compress() or compress2() on sourceLen bytes. It would be used before a
compress() or compress2() call to allocate the destination buffer.
*/
ZEXTERN int ZEXPORT uncompress(Bytef *dest, uLongf *destLen,
const Bytef *source, uLong sourceLen);
ZEXTERN int ZEXPORT uncompress_z(Bytef *dest, z_size_t *destLen,
const Bytef *source, z_size_t sourceLen);
/*
Decompresses the source buffer into the destination buffer. sourceLen is
the byte length of the source buffer. On entry, *destLen is the total size
of the destination buffer, which must be large enough to hold the entire
uncompressed data. (The size of the uncompressed data must have been saved
previously by the compressor and transmitted to the decompressor by some
mechanism outside the scope of this compression library.) On exit, *destLen
is the actual size of the uncompressed data.
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
enough memory, Z_BUF_ERROR if there was not enough room in the output
buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In
the case where there is not enough room, uncompress() will fill the output
buffer with the uncompressed data up to that point.
*/
ZEXTERN int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen,
const Bytef *source, uLong *sourceLen);
ZEXTERN int ZEXPORT uncompress2_z(Bytef *dest, z_size_t *destLen,
const Bytef *source, z_size_t *sourceLen);
/*
Same as uncompress, except that sourceLen is a pointer, where the
length of the source is *sourceLen. On return, *sourceLen is the number of
source bytes consumed.
*/
/* gzip file access functions */
|
| ︙ | ︙ | |||
1310 1311 1312 1313 1314 1315 1316 |
Open the gzip (.gz) file at path for reading and decompressing, or
compressing and writing. The mode parameter is as in fopen ("rb" or "wb")
but can also include a compression level ("wb9") or a strategy: 'f' for
filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h",
'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression
as in "wb9F". (See the description of deflateInit2 for more information
about the strategy parameter.) 'T' will request transparent writing or
| | > > > > | | | | | > > > > > > | > > | 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 |
Open the gzip (.gz) file at path for reading and decompressing, or
compressing and writing. The mode parameter is as in fopen ("rb" or "wb")
but can also include a compression level ("wb9") or a strategy: 'f' for
filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h",
'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression
as in "wb9F". (See the description of deflateInit2 for more information
about the strategy parameter.) 'T' will request transparent writing or
appending with no compression and not using the gzip format. 'T' cannot be
used to force transparent reading. Transparent reading is automatically
performed if there is no gzip header at the start. Transparent reading can
be disabled with the 'G' option, which will instead return an error if there
is no gzip header. 'N' will open the file in non-blocking mode.
'a' can be used instead of 'w' to request that the gzip stream that will
be written be appended to the file. '+' will result in an error, since
reading and writing to the same gzip file is not supported. The addition of
'x' when writing will create the file exclusively, which fails if the file
already exists. On systems that support it, the addition of 'e' when
reading or writing will set the flag to close the file on an execve() call.
These functions, as well as gzip, will read and decode a sequence of gzip
streams in a file. The append function of gzopen() can be used to create
such a file. (Also see gzflush() for another way to do this.) When
appending, gzopen does not test whether the file begins with a gzip stream,
nor does it look for the end of the gzip streams to begin appending. gzopen
will simply append a gzip stream to the existing file.
gzopen can be used to read a file which is not in gzip format; in this
case gzread will directly read from the file without decompression. When
reading, this will be detected automatically by looking for the magic two-
byte gzip header.
gzopen returns NULL if the file could not be opened, if there was
insufficient memory to allocate the gzFile state, or if an invalid mode was
specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).
errno can be checked to determine if the reason gzopen failed was that the
file could not be opened. Note that if 'N' is in mode for non-blocking, the
open() itself can fail in order to not block. In that case gzopen() will
return NULL and errno will be EAGAIN or ENONBLOCK. The call to gzopen() can
then be re-tried. If the application would like to block on opening the
file, then it can use open() without O_NONBLOCK, and then gzdopen() with the
resulting file descriptor and 'N' in the mode, which will set it to non-
blocking.
*/
ZEXTERN gzFile ZEXPORT gzdopen(int fd, const char *mode);
/*
Associate a gzFile with the file descriptor fd. File descriptors are
obtained from calls like open, dup, creat, pipe or fileno (if the file has
been previously opened with fopen). The mode parameter is as in gzopen. An
'e' in mode will set fd's flag to close the file on an execve() call. An 'N'
in mode will set fd's non-blocking flag.
The next call of gzclose on the returned gzFile will also close the file
descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,
mode);. The duplicated descriptor should be saved to avoid a leak, since
gzdopen does not close fd if it fails. If you are using fileno() to get the
file descriptor from a FILE *, then you will have to use dup() to avoid
|
| ︙ | ︙ | |||
1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 |
gzread to be tried again. Z_OK indicates that a gzip stream was completed
on the last gzread. Z_BUF_ERROR indicates that the input file ended in the
middle of a gzip stream. Note that gzread does not return -1 in the event
of an incomplete gzip stream. This error is deferred until gzclose(), which
will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip
stream. Alternatively, gzerror can be used before gzclose to detect this
case.
gzread returns the number of uncompressed bytes actually read, less than
len for end of file, or -1 for error. If len is too large to fit in an int,
then nothing is read, -1 is returned, and the error state is set to
| > > > > > | > | 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 |
gzread to be tried again. Z_OK indicates that a gzip stream was completed
on the last gzread. Z_BUF_ERROR indicates that the input file ended in the
middle of a gzip stream. Note that gzread does not return -1 in the event
of an incomplete gzip stream. This error is deferred until gzclose(), which
will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip
stream. Alternatively, gzerror can be used before gzclose to detect this
case.
gzread can be used to read a gzip file on a non-blocking device. If the
input stalls and there is no uncompressed data to return, then gzread() will
return -1, and errno will be EAGAIN or EWOULDBLOCK. gzread() can then be
called again.
gzread returns the number of uncompressed bytes actually read, less than
len for end of file, or -1 for error. If len is too large to fit in an int,
then nothing is read, -1 is returned, and the error state is set to
Z_STREAM_ERROR. If some data was read before an error, then that data is
returned until exhausted, after which the next call will signal the error.
*/
ZEXTERN z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems,
gzFile file);
/*
Read and decompress up to nitems items of size size from file into buf,
otherwise operating as gzread() does. This duplicates the interface of
|
| ︙ | ︙ | |||
1439 1440 1441 1442 1443 1444 1445 |
is read, zero is returned, and the error state is set to Z_STREAM_ERROR.
In the event that the end of file is reached and only a partial item is
available at the end, i.e. the remaining uncompressed data length is not a
multiple of size, then the final partial item is nevertheless read into buf
and the end-of-file flag is set. The length of the partial item read is not
provided, but could be inferred from the result of gztell(). This behavior
| | | | > | > > > > > > > > > > > > > | > > | | | > > > | > > > > > > > > | > > | > > > | > > > > | | | | > > > > > > > > > | 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 |
is read, zero is returned, and the error state is set to Z_STREAM_ERROR.
In the event that the end of file is reached and only a partial item is
available at the end, i.e. the remaining uncompressed data length is not a
multiple of size, then the final partial item is nevertheless read into buf
and the end-of-file flag is set. The length of the partial item read is not
provided, but could be inferred from the result of gztell(). This behavior
is the same as that of fread() implementations in common libraries. This
could result in data loss if used with size != 1 when reading a concurrently
written file or a non-blocking file. In that case, use size == 1 or gzread()
instead.
*/
ZEXTERN int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len);
/*
Compress and write the len uncompressed bytes at buf to file. gzwrite
returns the number of uncompressed bytes written, or 0 in case of error or
if len is 0. If the write destination is non-blocking, then gzwrite() may
return a number of bytes written that is not 0 and less than len.
If len does not fit in an int, then 0 is returned and nothing is written.
*/
ZEXTERN z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size,
z_size_t nitems, gzFile file);
/*
Compress and write nitems items of size size from buf to file, duplicating
the interface of stdio's fwrite(), with size_t request and return types. If
the library defines size_t, then z_size_t is identical to size_t. If not,
then z_size_t is an unsigned integer type that can contain a pointer.
gzfwrite() returns the number of full items written of size size, or zero
if there was an error. If the multiplication of size and nitems overflows,
i.e. the product does not fit in a z_size_t, then nothing is written, zero
is returned, and the error state is set to Z_STREAM_ERROR.
If writing a concurrently read file or a non-blocking file with size != 1,
a partial item could be written, with no way of knowing how much of it was
not written, resulting in data loss. In that case, use size == 1 or
gzwrite() instead.
*/
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
ZEXTERN int ZEXPORTVA gzprintf(gzFile file, const char *format, ...);
#else
ZEXTERN int ZEXPORTVA gzprintf();
#endif
/*
Convert, format, compress, and write the arguments (...) to file under
control of the string format, as in fprintf. gzprintf returns the number of
uncompressed bytes actually written, or a negative zlib error code in case
of error. The number of uncompressed bytes written is limited to 8191, or
one less than the buffer size given to gzbuffer(). The caller should assure
that this limit is not exceeded. If it is exceeded, then gzprintf() will
return an error (0) with nothing written.
In that last case, there may also be a buffer overflow with unpredictable
consequences, which is possible only if zlib was compiled with the insecure
functions sprintf() or vsprintf(), because the secure snprintf() and
vsnprintf() functions were not available. That would only be the case for
a non-ANSI C compiler. zlib may have been built without gzprintf() because
secure functions were not available and having gzprintf() be insecure was
not an option, in which case, gzprintf() returns Z_STREAM_ERROR. All of
these possibilities can be determined using zlibCompileFlags().
If a Z_BUF_ERROR is returned, then nothing was written due to a stall on
the non-blocking write destination.
*/
ZEXTERN int ZEXPORT gzputs(gzFile file, const char *s);
/*
Compress and write the given null-terminated string s to file, excluding
the terminating null character.
gzputs returns the number of characters written, or -1 in case of error.
The number of characters written may be less than the length of the string
if the write destination is non-blocking.
If the length of the string does not fit in an int, then -1 is returned
and nothing is written.
*/
ZEXTERN char * ZEXPORT gzgets(gzFile file, char *buf, int len);
/*
Read and decompress bytes from file into buf, until len-1 characters are
read, or until a newline character is read and transferred to buf, or an
end-of-file condition is encountered. If any characters are read or if len
is one, the string is terminated with a null character. If no characters
are read due to an end-of-file or len is less than one, then the buffer is
left untouched.
gzgets returns buf which is a null-terminated string, or it returns NULL
for end-of-file or in case of error. If some data was read before an error,
then that data is returned until exhausted, after which the next call will
return NULL to signal the error.
gzgets can be used on a file being concurrently written, and on a non-
blocking device, both as for gzread(). However lines may be broken in the
middle, leaving it up to the application to reassemble them as needed.
*/
ZEXTERN int ZEXPORT gzputc(gzFile file, int c);
/*
Compress and write c, converted to an unsigned char, into file. gzputc
returns the value that was written, or -1 in case of error.
*/
ZEXTERN int ZEXPORT gzgetc(gzFile file);
/*
Read and decompress one byte from file. gzgetc returns this byte or -1 in
case of end of file or error. If some data was read before an error, then
that data is returned until exhausted, after which the next call will return
-1 to signal the error.
This is implemented as a macro for speed. As such, it does not do all of
the checking the other functions do. I.e. it does not check to see if file
is NULL, nor whether the structure file points to has been clobbered or not.
gzgetc can be used to read a gzip file on a non-blocking device. If the
input stalls and there is no uncompressed data to return, then gzgetc() will
return -1, and errno will be EAGAIN or EWOULDBLOCK. gzread() can then be
called again.
*/
ZEXTERN int ZEXPORT gzungetc(int c, gzFile file);
/*
Push c back onto the stream for file to be read as the first character on
the next read. At least one character of push-back is always allowed.
gzungetc() returns the character pushed, or -1 on failure. gzungetc() will
fail if c is -1, and may fail if a character has been pushed but not read
yet. If gzungetc is used immediately after gzopen or gzdopen, at least the
output buffer size of pushed characters is allowed. (See gzbuffer above.)
The pushed character will be discarded if the stream is repositioned with
gzseek() or gzrewind().
gzungetc(-1, file) will force any pending seek to execute. Then gztell()
will report the position, even if the requested seek reached end of file.
This can be used to determine the number of uncompressed bytes in a gzip
file without having to read it into a buffer.
*/
ZEXTERN int ZEXPORT gzflush(gzFile file, int flush);
/*
Flush all pending output to file. The parameter flush is as in the
deflate() function. The return value is the zlib error number (see function
gzerror below). gzflush is only permitted when writing.
|
| ︙ | ︙ | |||
1555 1556 1557 1558 1559 1560 1561 |
or gzwrite on file. The offset represents a number of bytes in the
uncompressed data stream. The whence parameter is defined as in lseek(2);
the value SEEK_END is not supported.
If the file is opened for reading, this function is emulated but can be
extremely slow. If the file is opened for writing, only forward seeks are
supported; gzseek then compresses a sequence of zeroes up to the new
| | > | | | 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 |
or gzwrite on file. The offset represents a number of bytes in the
uncompressed data stream. The whence parameter is defined as in lseek(2);
the value SEEK_END is not supported.
If the file is opened for reading, this function is emulated but can be
extremely slow. If the file is opened for writing, only forward seeks are
supported; gzseek then compresses a sequence of zeroes up to the new
starting position. For reading or writing, any actual seeking is deferred
until the next read or write operation, or close operation when writing.
gzseek returns the resulting offset location as measured in bytes from
the beginning of the uncompressed stream, or -1 in case of error, in
particular if the file is opened for writing and the new starting position
would be before the current position.
*/
ZEXTERN int ZEXPORT gzrewind(gzFile file);
/*
Rewind file. This function is supported only for reading.
gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET).
*/
/*
ZEXTERN z_off_t ZEXPORT gztell(gzFile file);
Return the starting position for the next gzread or gzwrite on file.
This position represents a number of bytes in the uncompressed data stream,
and is zero when starting, even if appending or reading a gzip stream from
the middle of a file using gzdopen().
gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
|
| ︙ | ︙ | |||
1616 1617 1618 1619 1620 1621 1622 |
(0) if file is a gzip stream being decompressed.
If the input file is empty, gzdirect() will return true, since the input
does not contain a gzip stream.
If gzdirect() is used immediately after gzopen() or gzdopen() it will
cause buffers to be allocated to allow reading the file to determine if it
| | | > > > | | 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 |
(0) if file is a gzip stream being decompressed.
If the input file is empty, gzdirect() will return true, since the input
does not contain a gzip stream.
If gzdirect() is used immediately after gzopen() or gzdopen() it will
cause buffers to be allocated to allow reading the file to determine if it
is a gzip file. Therefore if gzbuffer() is used, it should be called before
gzdirect(). If the input is being written concurrently or the device is non-
blocking, then gzdirect() may give a different answer once four bytes of
input have been accumulated, which is what is needed to confirm or deny a
gzip header. Before this, gzdirect() will return true (1).
When writing, gzdirect() returns true (1) if transparent writing was
requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note:
gzdirect() is not needed when writing. Transparent writing must be
explicitly requested, so the application already knows the answer. When
linking statically, using gzdirect() will include all of the zlib code for
gzip file reading and decompression, which may not be desired.)
*/
ZEXTERN int ZEXPORT gzclose(gzFile file);
/*
Flush all pending output for file, if necessary, close file and
deallocate the (de)compression state. Note that once file is closed, you
cannot call gzerror with file, since its structures have been deallocated.
gzclose must not be called more than once on the same file, just as free
must not be called more than once on the same allocation.
|
| ︙ | ︙ | |||
1655 1656 1657 1658 1659 1660 1661 |
decompression code will be included the application when linking to a static
zlib library.
*/
ZEXTERN const char * ZEXPORT gzerror(gzFile file, int *errnum);
/*
Return the error message for the last error which occurred on file.
| | | | > | 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 |
decompression code will be included the application when linking to a static
zlib library.
*/
ZEXTERN const char * ZEXPORT gzerror(gzFile file, int *errnum);
/*
Return the error message for the last error which occurred on file.
If errnum is not NULL, *errnum is set to zlib error number. If an error
occurred in the file system and not in the compression library, *errnum is
set to Z_ERRNO and the application may consult errno to get the exact error
code.
The application must not modify the returned string. Future calls to
this function may invalidate the previously returned string. If file is
closed, then the string previously returned by gzerror will no longer be
available.
gzerror() should be used to distinguish errors from end-of-file for those
|
| ︙ | ︙ | |||
1708 1709 1710 1711 1712 1713 1714 |
}
if (adler != original_adler) error();
*/
ZEXTERN uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf,
z_size_t len);
/*
| | > | 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 |
}
if (adler != original_adler) error();
*/
ZEXTERN uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf,
z_size_t len);
/*
Same as adler32(), but with a size_t length. Note that a long is 32 bits
on Windows.
*/
/*
ZEXTERN uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2,
z_off_t len2);
Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
|
| ︙ | ︙ | |||
1744 1745 1746 1747 1748 1749 1750 |
}
if (crc != original_crc) error();
*/
ZEXTERN uLong ZEXPORT crc32_z(uLong crc, const Bytef *buf,
z_size_t len);
/*
| | > | | | 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 |
}
if (crc != original_crc) error();
*/
ZEXTERN uLong ZEXPORT crc32_z(uLong crc, const Bytef *buf,
z_size_t len);
/*
Same as crc32(), but with a size_t length. Note that a long is 32 bits on
Windows.
*/
/*
ZEXTERN uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2);
Combine two CRC-32 check values into one. For two sequences of bytes,
seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32
check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
len2. len2 must be non-negative, otherwise zero is returned.
*/
/*
ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t len2);
Return the operator corresponding to length len2, to be used with
crc32_combine_op(). len2 must be non-negative, otherwise zero is returned.
*/
ZEXTERN uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op);
/*
Give the same result as crc32_combine(), using op in place of len2. op is
is generated from len2 by crc32_combine_gen(). This will be faster than
crc32_combine() if the generated op is used more than once.
|
| ︙ | ︙ | |||
1884 1885 1886 1887 1888 1889 1890 |
# define crc32_combine_gen crc32_combine_gen64
# endif
# ifndef Z_LARGE64
ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *);
ZEXTERN z_off_t ZEXPORT gzseek64(gzFile, z_off_t, int);
ZEXTERN z_off_t ZEXPORT gztell64(gzFile);
ZEXTERN z_off_t ZEXPORT gzoffset64(gzFile);
| | | | | 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 |
# define crc32_combine_gen crc32_combine_gen64
# endif
# ifndef Z_LARGE64
ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *);
ZEXTERN z_off_t ZEXPORT gzseek64(gzFile, z_off_t, int);
ZEXTERN z_off_t ZEXPORT gztell64(gzFile);
ZEXTERN z_off_t ZEXPORT gzoffset64(gzFile);
ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t);
ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t);
ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t);
# endif
#else
ZEXTERN gzFile ZEXPORT gzopen(const char *, const char *);
ZEXTERN z_off_t ZEXPORT gzseek(gzFile, z_off_t, int);
ZEXTERN z_off_t ZEXPORT gztell(gzFile);
ZEXTERN z_off_t ZEXPORT gzoffset(gzFile);
ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t);
|
| ︙ | ︙ |
Changes to compat/zlib/zlib.map.
| ︙ | ︙ | |||
94 95 96 97 98 99 100 |
} ZLIB_1.2.7.1;
ZLIB_1.2.12 {
crc32_combine_gen;
crc32_combine_gen64;
crc32_combine_op;
} ZLIB_1.2.9;
| > > > > > > > > > > > > > > > > | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
} ZLIB_1.2.7.1;
ZLIB_1.2.12 {
crc32_combine_gen;
crc32_combine_gen64;
crc32_combine_op;
} ZLIB_1.2.9;
ZLIB_1.3.1.2 {
deflateUsed;
} ZLIB_1.2.12;
ZLIB_1.3.2 {
global:
compressBound_z;
deflateBound_z;
compress_z;
compress2_z;
uncompress_z;
uncompress2_z;
local:
inflate_fixed;
} ZLIB_1.3.1.2;
|
Changes to compat/zlib/zlib.pc.cmakein.
1 2 | prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=@CMAKE_INSTALL_PREFIX@ | | | | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
sharedlibdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${exec_prefix}/@CMAKE_INSTALL_INCLUDEDIR@
Name: zlib
Description: zlib compression library
Version: @zlib_VERSION@
License: Zlib
Requires:
Libs: -L${libdir} -L${sharedlibdir} -lz
Cflags: -I${includedir}
|
Changes to compat/zlib/zlib.pc.in.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
sharedlibdir=@sharedlibdir@
includedir=@includedir@
Name: zlib
Description: zlib compression library
Version: @VERSION@
Requires:
Libs: -L${libdir} -L${sharedlibdir} -lz
Cflags: -I${includedir}
| > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
sharedlibdir=@sharedlibdir@
includedir=@includedir@
Name: zlib
Description: zlib compression library
Version: @VERSION@
License: Zlib
Requires:
Libs: -L${libdir} -L${sharedlibdir} -lz
Cflags: -I${includedir}
|
Added compat/zlib/zlibConfig.cmake.in.
> > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
@PACKAGE_INIT@
set(_ZLIB_supported_components "shared" "static")
if(ZLIB_FIND_COMPONENTS)
foreach(_comp ${ZLIB_FIND_COMPONENTS})
if(NOT _comp IN_LIST _ZLIB_supported_components)
set(ZLIB_FOUND False)
set(ZLIB_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
endif(NOT _comp IN_LIST _ZLIB_supported_components)
include("${CMAKE_CURRENT_LIST_DIR}/ZLIB-${_comp}.cmake")
endforeach(_comp ${ZLIB_FIND_COMPONENTS})
else(ZLIB_FIND_COMPONENTS)
foreach(_component_config IN LISTS _ZLIB_supported_components)
include("${CMAKE_CURRENT_LIST_DIR}/ZLIB-${_component_config}.cmake")
endforeach(_component_config IN LISTS _ZLIB_supported_components)
endif(ZLIB_FIND_COMPONENTS)
|
Changes to compat/zlib/zutil.c.
1 | /* zutil.c -- target dependent utility functions for the compression library | | | 1 2 3 4 5 6 7 8 9 | /* zutil.c -- target dependent utility functions for the compression library * Copyright (C) 1995-2026 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #include "zutil.h" #ifndef Z_SOLO |
| ︙ | ︙ | |||
82 83 84 85 86 87 88 |
#ifdef PKZIP_BUG_WORKAROUND
flags += 1L << 20;
#endif
#ifdef FASTEST
flags += 1L << 21;
#endif
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
| | > | > > > | | | | | | | | | > | > > > | | | | | | | | | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
#ifdef PKZIP_BUG_WORKAROUND
flags += 1L << 20;
#endif
#ifdef FASTEST
flags += 1L << 21;
#endif
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
# ifdef NO_vsnprintf
# ifdef ZLIB_INSECURE
flags += 1L << 25;
# else
flags += 1L << 27;
# endif
# ifdef HAS_vsprintf_void
flags += 1L << 26;
# endif
# else
# ifdef HAS_vsnprintf_void
flags += 1L << 26;
# endif
# endif
#else
flags += 1L << 24;
# ifdef NO_snprintf
# ifdef ZLIB_INSECURE
flags += 1L << 25;
# else
flags += 1L << 27;
# endif
# ifdef HAS_sprintf_void
flags += 1L << 26;
# endif
# else
# ifdef HAS_snprintf_void
flags += 1L << 26;
# endif
# endif
#endif
return flags;
}
#ifdef ZLIB_DEBUG
#include <stdlib.h>
# ifndef verbose
|
| ︙ | ︙ | |||
138 139 140 141 142 143 144 |
* Its value is always 0 and should not be used.
*/
int errno = 0;
#endif
#ifndef HAVE_MEMCPY
| | | > | | | | | < < > | > > | > | > | | | | > > | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
* Its value is always 0 and should not be used.
*/
int errno = 0;
#endif
#ifndef HAVE_MEMCPY
void ZLIB_INTERNAL zmemcpy(void FAR *dst, const void FAR *src, z_size_t n) {
uchf *p = dst;
const uchf *q = src;
while (n) {
*p++ = *q++;
n--;
}
}
int ZLIB_INTERNAL zmemcmp(const void FAR *s1, const void FAR *s2, z_size_t n) {
const uchf *p = s1, *q = s2;
while (n) {
if (*p++ != *q++)
return (int)p[-1] - (int)q[-1];
n--;
}
return 0;
}
void ZLIB_INTERNAL zmemzero(void FAR *b, z_size_t len) {
uchf *p = b;
if (len == 0) return;
while (len) {
*p++ = 0;
len--;
}
}
#endif
#ifndef Z_SOLO
#ifdef SYS16BIT
#ifdef __TURBOC__
|
| ︙ | ︙ |
Changes to compat/zlib/zutil.h.
1 | /* zutil.h -- internal interface and configuration of the compression library | | | 1 2 3 4 5 6 7 8 9 | /* zutil.h -- internal interface and configuration of the compression library * Copyright (C) 1995-2026 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ |
| ︙ | ︙ | |||
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 |
#ifndef local
# define local static
#endif
/* since "static" is used to mean two completely different things in C, we
define "local" for the non-static meaning of "static", for readability
(compile with -Dlocal if your debugger can't find static symbols) */
typedef unsigned char uch;
typedef uch FAR uchf;
typedef unsigned short ush;
typedef ush FAR ushf;
typedef unsigned long ulg;
#if !defined(Z_U8) && !defined(Z_SOLO) && defined(STDC)
# include <limits.h>
# if (ULONG_MAX == 0xffffffffffffffff)
# define Z_U8 unsigned long
# elif (ULLONG_MAX == 0xffffffffffffffff)
# define Z_U8 unsigned long long
# elif (UINT_MAX == 0xffffffffffffffff)
# define Z_U8 unsigned
# endif
#endif
extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
/* (size given to avoid silly warnings with Visual C++) */
#define ERR_MSG(err) z_errmsg[(err) < -6 || (err) > 2 ? 9 : 2 - (err)]
#define ERR_RETURN(strm,err) \
return (strm->msg = ERR_MSG(err), (err))
/* To be used only when the state is known to be valid */
/* common constants */
| > > > > > > | > > | 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 |
#ifndef local
# define local static
#endif
/* since "static" is used to mean two completely different things in C, we
define "local" for the non-static meaning of "static", for readability
(compile with -Dlocal if your debugger can't find static symbols) */
extern const char deflate_copyright[];
extern const char inflate_copyright[];
extern const char inflate9_copyright[];
typedef unsigned char uch;
typedef uch FAR uchf;
typedef unsigned short ush;
typedef ush FAR ushf;
typedef unsigned long ulg;
#if !defined(Z_U8) && !defined(Z_SOLO) && defined(STDC)
# include <limits.h>
# if (ULONG_MAX == 0xffffffffffffffff)
# define Z_U8 unsigned long
# elif (ULLONG_MAX == 0xffffffffffffffff)
# define Z_U8 unsigned long long
# elif (ULONG_LONG_MAX == 0xffffffffffffffff)
# define Z_U8 unsigned long long
# elif (UINT_MAX == 0xffffffffffffffff)
# define Z_U8 unsigned
# endif
#endif
extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
/* (size given to avoid silly warnings with Visual C++) */
#define ERR_MSG(err) z_errmsg[(err) < -6 || (err) > 2 ? 9 : 2 - (err)]
#define ERR_RETURN(strm,err) \
return (strm->msg = ERR_MSG(err), (err))
/* To be used only when the state is known to be valid */
/* common constants */
#if MAX_WBITS < 9 || MAX_WBITS > 15
# error MAX_WBITS must be in 9..15
#endif
#ifndef DEF_WBITS
# define DEF_WBITS MAX_WBITS
#endif
/* default windowBits for decompression. MAX_WBITS is for compression only */
#if MAX_MEM_LEVEL >= 8
# define DEF_MEM_LEVEL 8
|
| ︙ | ︙ | |||
137 138 139 140 141 142 143 | # endif #endif #if defined(MACOS) # define OS_CODE 7 #endif | | | 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | # endif #endif #if defined(MACOS) # define OS_CODE 7 #endif #if defined(__acorn) || defined(__riscos) # define OS_CODE 13 #endif #if defined(WIN32) && !defined(__CYGWIN__) # define OS_CODE 10 #endif |
| ︙ | ︙ | |||
164 165 166 167 168 169 170 | #if defined(__BORLANDC__) && !defined(MSDOS) #pragma warn -8004 #pragma warn -8008 #pragma warn -8066 #endif /* provide prototypes for these when building zlib without LFS */ | < | | | | | 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
#if defined(__BORLANDC__) && !defined(MSDOS)
#pragma warn -8004
#pragma warn -8008
#pragma warn -8066
#endif
/* provide prototypes for these when building zlib without LFS */
#ifndef Z_LARGE64
ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t);
ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t);
ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t);
#endif
/* common defaults */
#ifndef OS_CODE
# define OS_CODE 3 /* assume Unix */
#endif
|
| ︙ | ︙ | |||
207 208 209 210 211 212 213 | # define zmemzero(dest, len) _fmemset(dest, 0, len) # else # define zmemcpy memcpy # define zmemcmp memcmp # define zmemzero(dest, len) memset(dest, 0, len) # endif #else | | | | | 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | # define zmemzero(dest, len) _fmemset(dest, 0, len) # else # define zmemcpy memcpy # define zmemcmp memcmp # define zmemzero(dest, len) memset(dest, 0, len) # endif #else void ZLIB_INTERNAL zmemcpy(void FAR *, const void FAR *, z_size_t); int ZLIB_INTERNAL zmemcmp(const void FAR *, const void FAR *, z_size_t); void ZLIB_INTERNAL zmemzero(void FAR *, z_size_t); #endif /* Diagnostic functions */ #ifdef ZLIB_DEBUG # include <stdio.h> extern int ZLIB_INTERNAL z_verbose; extern void ZLIB_INTERNAL z_error(char *m); |
| ︙ | ︙ | |||
247 248 249 250 251 252 253 254 |
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
/* Reverse the bytes in a 32-bit value */
#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
#endif /* ZUTIL_H */
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
/* Reverse the bytes in a 32-bit value */
#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
#ifdef Z_ONCE
/*
Create a local z_once() function depending on the availability of atomics.
*/
/* Check for the availability of atomics. */
#if defined(__STDC__) && __STDC_VERSION__ >= 201112L && \
!defined(__STDC_NO_ATOMICS__)
#include <stdatomic.h>
typedef struct {
atomic_flag begun;
atomic_int done;
} z_once_t;
#define Z_ONCE_INIT {ATOMIC_FLAG_INIT, 0}
/*
Run the provided init() function exactly once, even if multiple threads
invoke once() at the same time. The state must be a once_t initialized with
Z_ONCE_INIT.
*/
local void z_once(z_once_t *state, void (*init)(void)) {
if (!atomic_load(&state->done)) {
if (atomic_flag_test_and_set(&state->begun))
while (!atomic_load(&state->done))
;
else {
init();
atomic_store(&state->done, 1);
}
}
}
#else /* no atomics */
#warning zlib not thread-safe
typedef struct z_once_s {
volatile int begun;
volatile int done;
} z_once_t;
#define Z_ONCE_INIT {0, 0}
/* Test and set. Alas, not atomic, but tries to limit the period of
vulnerability. */
local int test_and_set(int volatile *flag) {
int was;
was = *flag;
*flag = 1;
return was;
}
/* Run the provided init() function once. This is not thread-safe. */
local void z_once(z_once_t *state, void (*init)(void)) {
if (!state->done) {
if (test_and_set(&state->begun))
while (!state->done)
;
else {
init();
state->done = 1;
}
}
}
#endif /* ?atomics */
#endif /* Z_ONCE */
#endif /* ZUTIL_H */
|