mirror of
https://git.FreeBSD.org/src.git
synced 2026-06-02 11:24:32 +00:00
Vendor import of zlib 1.3.2.
This commit is contained in:
@@ -0,0 +1,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: {}
|
||||
+134
@@ -0,0 +1,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"],
|
||||
)
|
||||
+244
-152
@@ -1,98 +1,126 @@
|
||||
cmake_minimum_required(VERSION 2.4.4...3.15.0)
|
||||
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
|
||||
cmake_minimum_required(VERSION 3.12...3.31)
|
||||
|
||||
project(zlib C)
|
||||
project(
|
||||
zlib
|
||||
LANGUAGES C
|
||||
VERSION 1.3.2
|
||||
HOMEPAGE_URL "https://zlib.net/"
|
||||
DESCRIPTION "a general-purpose lossless data-compression library")
|
||||
|
||||
set(VERSION "1.3.1")
|
||||
# ============================================================================
|
||||
# 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)
|
||||
|
||||
option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" ON)
|
||||
# ============================================================================
|
||||
# configuration
|
||||
# ============================================================================
|
||||
|
||||
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
|
||||
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
|
||||
set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
|
||||
set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages")
|
||||
set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
|
||||
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)
|
||||
|
||||
include(CheckTypeSize)
|
||||
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(CheckCSourceCompiles)
|
||||
enable_testing()
|
||||
include(CMakePackageConfigHelpers)
|
||||
include(CheckTypeSize)
|
||||
include(CPack)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
|
||||
check_include_file(stdint.h HAVE_STDINT_H)
|
||||
check_include_file(stddef.h HAVE_STDDEF_H)
|
||||
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)
|
||||
# We add these other definitions here because CheckTypeSize.cmake
|
||||
# in CMake 2.4.x does not automatically do so and we want
|
||||
# compatibility with CMake 2.4.x.
|
||||
if(HAVE_SYS_TYPES_H)
|
||||
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
|
||||
endif()
|
||||
if(HAVE_STDINT_H)
|
||||
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
|
||||
endif()
|
||||
if(HAVE_STDDEF_H)
|
||||
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
|
||||
endif()
|
||||
check_type_size(off64_t OFF64_T)
|
||||
if(HAVE_OFF64_T)
|
||||
add_definitions(-D_LARGEFILE64_SOURCE=1)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
|
||||
unset(CMAKE_REQUIRED_DEFINITIONS) # clear variable
|
||||
|
||||
#
|
||||
# Check for fseeko
|
||||
#
|
||||
check_function_exists(fseeko HAVE_FSEEKO)
|
||||
if(NOT HAVE_FSEEKO)
|
||||
add_definitions(-DNO_FSEEKO)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Check for stdarg.h
|
||||
#
|
||||
check_include_file(stdarg.h HAVE_STDARG_H)
|
||||
|
||||
#
|
||||
# Check for unistd.h
|
||||
#
|
||||
check_include_file(unistd.h Z_HAVE_UNISTD_H)
|
||||
check_include_file(unistd.h HAVE_UNISTD_H)
|
||||
|
||||
#
|
||||
# Check visibility attribute is supported
|
||||
#
|
||||
if(MSVC)
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS "-WX")
|
||||
else(MSVC)
|
||||
set(CMAKE_REQUIRED_FLAGS "-Werror")
|
||||
endif(MSVC)
|
||||
|
||||
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
|
||||
# If we're doing an out of source build and the user has a zconf.h
|
||||
# in their source tree...
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h)
|
||||
message(STATUS "Renaming")
|
||||
message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h")
|
||||
message(STATUS "to 'zconf.h.included' because this file is included with zlib")
|
||||
message(STATUS "but CMake generates it automatically in the build directory.")
|
||||
file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included)
|
||||
endif()
|
||||
endif()
|
||||
check_c_source_compiles(
|
||||
"
|
||||
#include <stdlib.h>
|
||||
static void f(void) __attribute__ ((visibility(\"hidden\")));
|
||||
int main(void) {return 0;}
|
||||
"
|
||||
HAVE___ATTR__VIS_HIDDEN)
|
||||
|
||||
set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc)
|
||||
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
|
||||
${ZLIB_PC} @ONLY)
|
||||
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
|
||||
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_PUBLIC_HDRS
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zconf.h
|
||||
zlib.h
|
||||
)
|
||||
set(ZLIB_PRIVATE_HDRS
|
||||
crc32.h
|
||||
deflate.h
|
||||
@@ -102,8 +130,8 @@ set(ZLIB_PRIVATE_HDRS
|
||||
inflate.h
|
||||
inftrees.h
|
||||
trees.h
|
||||
zutil.h
|
||||
)
|
||||
zutil.h)
|
||||
|
||||
set(ZLIB_SRCS
|
||||
adler32.c
|
||||
compress.c
|
||||
@@ -119,100 +147,164 @@ set(ZLIB_SRCS
|
||||
inffast.c
|
||||
trees.c
|
||||
uncompr.c
|
||||
zutil.c
|
||||
)
|
||||
zutil.c)
|
||||
|
||||
if(NOT MINGW)
|
||||
set(ZLIB_DLL_SRCS
|
||||
win32/zlib1.rc # If present will override custom build rule below.
|
||||
)
|
||||
endif()
|
||||
if(WIN32)
|
||||
set(zlib_static_suffix "s")
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
endif(WIN32)
|
||||
|
||||
# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION
|
||||
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
|
||||
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
|
||||
"\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
|
||||
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(MINGW)
|
||||
# This gets us DLL resource information when compiling on MinGW.
|
||||
if(NOT CMAKE_RC_COMPILER)
|
||||
set(CMAKE_RC_COMPILER windres.exe)
|
||||
endif()
|
||||
if(NOT CYGWIN)
|
||||
set_target_properties(zlib PROPERTIES SOVERSION ${zlib_VERSION_MAJOR}
|
||||
VERSION ${INSTALL_VERSION})
|
||||
endif(NOT CYGWIN)
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
|
||||
COMMAND ${CMAKE_RC_COMPILER}
|
||||
-D GCC_WINDRES
|
||||
-I ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
-I ${CMAKE_CURRENT_BINARY_DIR}
|
||||
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
|
||||
-i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
|
||||
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
|
||||
endif(MINGW)
|
||||
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)
|
||||
|
||||
add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
|
||||
set_target_properties(zlib PROPERTIES SOVERSION 1)
|
||||
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(NOT CYGWIN)
|
||||
# This property causes shared libraries on Linux to have the full version
|
||||
# encoded into their final filename. We disable this on Cygwin because
|
||||
# it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll
|
||||
# seems to be the default.
|
||||
#
|
||||
# This has no effect with MSVC, on that platform the version info for
|
||||
# the DLL comes from the resource file win32/zlib1.rc
|
||||
set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
|
||||
endif()
|
||||
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(UNIX)
|
||||
# On unix-like platforms the library is almost always called libz
|
||||
set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
|
||||
if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
|
||||
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
|
||||
endif()
|
||||
elseif(BUILD_SHARED_LIBS AND WIN32)
|
||||
# Creates zlib1.dll when building shared library version
|
||||
set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
|
||||
endif()
|
||||
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(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
|
||||
install(TARGETS zlib zlibstatic
|
||||
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
|
||||
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
|
||||
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
|
||||
endif()
|
||||
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
|
||||
install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}")
|
||||
endif()
|
||||
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
|
||||
install(FILES zlib.3 DESTINATION "${INSTALL_MAN_DIR}/man3")
|
||||
endif()
|
||||
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
|
||||
install(FILES ${ZLIB_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}")
|
||||
endif()
|
||||
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)
|
||||
|
||||
#============================================================================
|
||||
# Example binaries
|
||||
#============================================================================
|
||||
if(ZLIB_BUILD_EXAMPLES)
|
||||
add_executable(example test/example.c)
|
||||
target_link_libraries(example zlib)
|
||||
add_test(example example)
|
||||
configure_package_config_file(
|
||||
${zlib_SOURCE_DIR}/zlibConfig.cmake.in
|
||||
${zlib_BINARY_DIR}/ZLIBConfig.cmake
|
||||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
|
||||
|
||||
add_executable(minigzip test/minigzip.c)
|
||||
target_link_libraries(minigzip zlib)
|
||||
write_basic_package_version_file(
|
||||
"${zlib_BINARY_DIR}/ZLIBConfigVersion.cmake"
|
||||
VERSION "${zlib_VERSION}"
|
||||
COMPATIBILITY AnyNewerVersion)
|
||||
|
||||
if(HAVE_OFF64_T)
|
||||
add_executable(example64 test/example.c)
|
||||
target_link_libraries(example64 zlib)
|
||||
set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
|
||||
add_test(example64 example64)
|
||||
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)
|
||||
|
||||
add_executable(minigzip64 test/minigzip.c)
|
||||
target_link_libraries(minigzip64 zlib)
|
||||
set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
|
||||
endif()
|
||||
endif()
|
||||
# ============================================================================
|
||||
# Tests
|
||||
# ============================================================================
|
||||
if(ZLIB_BUILD_TESTING)
|
||||
enable_testing()
|
||||
add_subdirectory(test)
|
||||
endif(ZLIB_BUILD_TESTING)
|
||||
|
||||
add_subdirectory(contrib)
|
||||
|
||||
@@ -1,6 +1,57 @@
|
||||
|
||||
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
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
|
||||
If your question is not there, please check the zlib home page
|
||||
http://zlib.net/ which may have more recent information.
|
||||
The latest zlib FAQ is at http://zlib.net/zlib_faq.html
|
||||
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?
|
||||
@@ -19,7 +19,7 @@ The latest zlib FAQ is at http://zlib.net/zlib_faq.html
|
||||
3. Where can I get a Visual Basic interface to zlib?
|
||||
|
||||
See
|
||||
* http://marknelson.us/1997/01/01/zlib-engine/
|
||||
* https://zlib.net/nelson/
|
||||
* win32/DLL_FAQ.txt in the zlib distribution
|
||||
|
||||
4. compress() returns Z_BUF_ERROR.
|
||||
@@ -38,7 +38,7 @@ The latest zlib FAQ is at http://zlib.net/zlib_faq.html
|
||||
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 http://zlib.net/zlib_how.html for a
|
||||
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.)?
|
||||
@@ -109,8 +109,8 @@ The latest zlib FAQ is at http://zlib.net/zlib_faq.html
|
||||
|
||||
16. Can zlib decode Flate data in an Adobe PDF file?
|
||||
|
||||
Yes. See http://www.pdflib.com/ . To modify PDF forms, see
|
||||
http://sourceforge.net/projects/acroformtool/ .
|
||||
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?
|
||||
|
||||
@@ -156,6 +156,10 @@ The latest zlib FAQ is at http://zlib.net/zlib_faq.html
|
||||
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.
|
||||
|
||||
@@ -235,7 +239,7 @@ The latest zlib FAQ is at http://zlib.net/zlib_faq.html
|
||||
As far as we know, no. In fact, that was originally the whole point behind
|
||||
zlib. Look here for some more information:
|
||||
|
||||
http://www.gzip.org/#faq11
|
||||
https://web.archive.org/web/20180729212847/http://www.gzip.org/#faq11
|
||||
|
||||
32. Can zlib work with greater than 4 GB of data?
|
||||
|
||||
@@ -258,20 +262,20 @@ The latest zlib FAQ is at http://zlib.net/zlib_faq.html
|
||||
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(), 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().
|
||||
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 portable implementation here:
|
||||
find a good portable implementation in stb_sprintf.h here:
|
||||
|
||||
http://www.ijs.si/software/snprintf/
|
||||
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
|
||||
@@ -283,7 +287,7 @@ The latest zlib FAQ is at http://zlib.net/zlib_faq.html
|
||||
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: http://zlib.net/ .
|
||||
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?
|
||||
@@ -314,9 +318,9 @@ The latest zlib FAQ is at http://zlib.net/zlib_faq.html
|
||||
|
||||
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, http://www.gnupg.org/ , which already includes zlib
|
||||
encryption, use GnuPG, https://www.gnupg.org/ , which already includes zlib
|
||||
compression. For PKZIP compatible "encryption", look at
|
||||
http://www.info-zip.org/
|
||||
https://infozip.sourceforge.net/
|
||||
|
||||
39. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
|
||||
|
||||
|
||||
@@ -21,12 +21,11 @@ zlib.pc.cmakein zlib.pc template for cmake
|
||||
zlib2ansi perl script to convert source files for C++ compilation
|
||||
|
||||
amiga/ makefiles for Amiga SAS C
|
||||
as400/ makefiles for AS/400
|
||||
doc/ documentation for formats and algorithms
|
||||
msdos/ makefiles for MSDOS
|
||||
nintendods/ makefile for Nintendo DS
|
||||
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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Copyright notice:
|
||||
|
||||
(C) 1995-2022 Jean-loup Gailly and Mark Adler
|
||||
(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
|
||||
|
||||
@@ -0,0 +1,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")
|
||||
+34
-18
@@ -1,5 +1,5 @@
|
||||
# Makefile for zlib
|
||||
# Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
|
||||
# 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:
|
||||
@@ -13,6 +13,8 @@
|
||||
# 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
|
||||
@@ -25,10 +27,11 @@ LDFLAGS=
|
||||
TEST_LIBS=-L. libz.a
|
||||
LDSHARED=$(CC)
|
||||
CPP=$(CC) -E
|
||||
VGFMAFLAG=
|
||||
|
||||
STATICLIB=libz.a
|
||||
SHAREDLIB=libz.so
|
||||
SHAREDLIBV=libz.so.1.3.1
|
||||
SHAREDLIBV=libz.so.1.3.2
|
||||
SHAREDLIBM=libz.so.1
|
||||
LIBS=$(STATICLIB) $(SHAREDLIBV)
|
||||
|
||||
@@ -112,16 +115,16 @@ test64: all64
|
||||
fi
|
||||
@rm -f tmp64_$$
|
||||
|
||||
infcover.o: $(SRCDIR)test/infcover.c $(SRCDIR)zlib.h zconf.h
|
||||
$(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/infcover.c
|
||||
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) -o $@ infcover.o libz.a
|
||||
$(CC) $(CFLAGS) -coverage -o $@ infcover.o libz.a
|
||||
|
||||
cover: infcover
|
||||
rm -f *.gcda
|
||||
${QEMU_RUN} ./infcover
|
||||
gcov inf*.c
|
||||
${GCOV} ${LLVM_GCOV_FLAG} inf*.c -o ./infcover.gcda
|
||||
|
||||
libz.a: $(OBJS)
|
||||
$(AR) $(ARFLAGS) $@ $(OBJS)
|
||||
@@ -158,6 +161,9 @@ adler32.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
|
||||
|
||||
@@ -176,7 +182,7 @@ inftrees.o: $(SRCDIR)inftrees.c
|
||||
trees.o: $(SRCDIR)trees.c
|
||||
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)trees.c
|
||||
|
||||
zutil.o: $(SRCDIR)zutil.c
|
||||
zutil.o: $(SRCDIR)zutil.c $(SRCDIR)gzguts.h
|
||||
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)zutil.c
|
||||
|
||||
compress.o: $(SRCDIR)compress.c
|
||||
@@ -208,6 +214,11 @@ crc32.lo: $(SRCDIR)crc32.c
|
||||
$(CC) $(SFLAGS) $(ZINC) -DPIC -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) -DPIC -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) -DPIC -c -o objs/deflate.o $(SRCDIR)deflate.c
|
||||
@@ -238,7 +249,7 @@ trees.lo: $(SRCDIR)trees.c
|
||||
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/trees.o $(SRCDIR)trees.c
|
||||
-@mv objs/trees.o $@
|
||||
|
||||
zutil.lo: $(SRCDIR)zutil.c
|
||||
zutil.lo: $(SRCDIR)zutil.c $(SRCDIR)gzguts.h
|
||||
-@mkdir objs 2>/dev/null || test -d objs
|
||||
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/zutil.o $(SRCDIR)zutil.c
|
||||
-@mv objs/zutil.o $@
|
||||
@@ -274,7 +285,7 @@ gzwrite.lo: $(SRCDIR)gzwrite.c
|
||||
-@mv objs/gzwrite.o $@
|
||||
|
||||
|
||||
placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
|
||||
placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a $(SRCDIR)zlib.map
|
||||
$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
|
||||
rm -f $(SHAREDLIB) $(SHAREDLIBM)
|
||||
ln -s $@ $(SHAREDLIB)
|
||||
@@ -349,12 +360,13 @@ 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.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
|
||||
@@ -378,7 +390,7 @@ clean: minizip-clean
|
||||
rm -f contrib/infback9/*.gcda contrib/infback9/*.gcno contrib/infback9/*.gcov
|
||||
|
||||
maintainer-clean: distclean
|
||||
distclean: clean zconf zconf.h.cmakein
|
||||
distclean: clean zconf # zconf.h.cmakein
|
||||
rm -f Makefile zlib.pc configure.log
|
||||
-@rm -f .DS_Store
|
||||
@if [ -f Makefile.in ]; then \
|
||||
@@ -389,7 +401,8 @@ distclean: clean zconf zconf.h.cmakein
|
||||
tags:
|
||||
etags $(SRCDIR)*.[ch]
|
||||
|
||||
adler32.o zutil.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
|
||||
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
|
||||
@@ -398,8 +411,10 @@ infback.o inflate.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.
|
||||
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 zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.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
|
||||
@@ -408,3 +423,4 @@ infback.lo inflate.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftree
|
||||
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
|
||||
@@ -1,10 +1,10 @@
|
||||
ZLIB DATA COMPRESSION LIBRARY
|
||||
|
||||
zlib 1.3.1 is a general purpose data compression library. All the code is
|
||||
thread safe. The data format used by the zlib library is described by RFCs
|
||||
(Request for Comments) 1950 to 1952 in the files
|
||||
http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
|
||||
rfc1952 (gzip format).
|
||||
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
|
||||
@@ -21,17 +21,17 @@ 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
|
||||
http://zlib.net/ . Before reporting a problem, please check this site to
|
||||
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 http://zlib.net/zlib_faq.html before asking for help.
|
||||
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://marknelson.us/posts/1997/01/01/zlib-engine.html .
|
||||
https://zlib.net/nelson/ .
|
||||
|
||||
The changes made in version 1.3.1 are documented in the file ChangeLog.
|
||||
The changes made in version 1.3.2 are documented in the file ChangeLog.
|
||||
|
||||
Unsupported third party contributions are provided in directory contrib/ .
|
||||
|
||||
@@ -43,9 +43,9 @@ 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
|
||||
http://docs.python.org/library/zlib.html .
|
||||
https://docs.python.org/3/library/zlib.html .
|
||||
|
||||
zlib is built into tcl: http://wiki.tcl.tk/4610 .
|
||||
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
|
||||
@@ -69,9 +69,7 @@ Notes for some targets:
|
||||
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
|
||||
other compilers. Use "make test" to check your compiler.
|
||||
|
||||
- gzdopen is not supported on RISCOS or BEOS.
|
||||
|
||||
- For PalmOs, see http://palmzlib.sourceforge.net/
|
||||
- For PalmOs, see https://palmzlib.sourceforge.net/
|
||||
|
||||
|
||||
Acknowledgments:
|
||||
@@ -83,7 +81,7 @@ Acknowledgments:
|
||||
|
||||
Copyright notice:
|
||||
|
||||
(C) 1995-2024 Jean-loup Gailly and Mark Adler
|
||||
(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
|
||||
|
||||
@@ -0,0 +1,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
|
||||
+34
-10
@@ -1,5 +1,5 @@
|
||||
/* compress.c -- compress a memory buffer
|
||||
* Copyright (C) 1995-2005, 2014, 2016 Jean-loup Gailly, Mark Adler
|
||||
* Copyright (C) 1995-2026 Jean-loup Gailly, Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
@@ -18,13 +18,19 @@
|
||||
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(Bytef *dest, uLongf *destLen, const Bytef *source,
|
||||
uLong sourceLen, int level) {
|
||||
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;
|
||||
uLong left;
|
||||
z_size_t left;
|
||||
|
||||
if ((sourceLen > 0 && source == NULL) ||
|
||||
destLen == NULL || (*destLen > 0 && dest == NULL))
|
||||
return Z_STREAM_ERROR;
|
||||
|
||||
left = *destLen;
|
||||
*destLen = 0;
|
||||
@@ -43,23 +49,36 @@ int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
|
||||
|
||||
do {
|
||||
if (stream.avail_out == 0) {
|
||||
stream.avail_out = left > (uLong)max ? max : (uInt)left;
|
||||
stream.avail_out = left > (z_size_t)max ? max : (uInt)left;
|
||||
left -= stream.avail_out;
|
||||
}
|
||||
if (stream.avail_in == 0) {
|
||||
stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen;
|
||||
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 = stream.total_out;
|
||||
*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);
|
||||
@@ -69,7 +88,12 @@ int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source,
|
||||
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) {
|
||||
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
|
||||
(sourceLen >> 25) + 13;
|
||||
z_size_t bound = compressBound_z(sourceLen);
|
||||
return (uLong)bound != bound ? (uLong)-1 : (uLong)bound;
|
||||
}
|
||||
|
||||
@@ -87,10 +87,15 @@ 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)'
|
||||
@@ -116,40 +121,49 @@ case "$1" in
|
||||
-h* | --help)
|
||||
echo 'usage:' | tee -a configure.log
|
||||
echo ' configure [--const] [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log
|
||||
echo ' [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log
|
||||
echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | 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 ;;
|
||||
-u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;;
|
||||
-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) shared=0; 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=`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=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 ;;
|
||||
*)
|
||||
echo "unknown option: $1" | tee -a configure.log
|
||||
echo "$0 --help for help" | tee -a configure.log
|
||||
leave 1;;
|
||||
--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$$
|
||||
@@ -184,41 +198,89 @@ else
|
||||
fi
|
||||
|
||||
case "$cc" in
|
||||
*gcc*) gcc=1 ;;
|
||||
*clang*) gcc=1 ;;
|
||||
*gcc*) gcc=1
|
||||
GCOV="gcov" ;;
|
||||
*clang*) gcc=1
|
||||
clang=1 ;;
|
||||
esac
|
||||
case `$cc -v 2>&1` in
|
||||
*gcc*) gcc=1 ;;
|
||||
*clang*) gcc=1 ;;
|
||||
*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}"
|
||||
SFLAGS="${CFLAGS--O3} -fPIC"
|
||||
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" -eq 1; then
|
||||
if test "$zconst" -eq 1; then
|
||||
CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -DZLIB_CONST"
|
||||
else
|
||||
CFLAGS="${CFLAGS} -Wall -Wextra"
|
||||
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"
|
||||
@@ -227,7 +289,7 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
|
||||
uname=`(uname -s || echo unknown) 2>/dev/null`
|
||||
fi
|
||||
case "$uname" in
|
||||
Linux* | linux* | *-linux* | GNU | GNU/* | solaris*)
|
||||
Linux* | linux* | *-linux* | GNU | GNU/* | solaris* | Haiku)
|
||||
case "$mname" in
|
||||
*sparc*)
|
||||
LDFLAGS="${LDFLAGS} -Wl,--no-warn-rwx-segments" ;;
|
||||
@@ -258,6 +320,7 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
|
||||
SHAREDLIB='libz.sl' ;;
|
||||
esac ;;
|
||||
AIX*)
|
||||
LDSHARED=${LDSHARED-"$cc -shared"}
|
||||
LDFLAGS="${LDFLAGS} -Wl,-brtl" ;;
|
||||
Darwin* | darwin* | *-darwin*)
|
||||
shared_ext='.dylib'
|
||||
@@ -363,7 +426,12 @@ else
|
||||
AIX*) # Courtesy of dbakker@arrayasolutions.com
|
||||
SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
|
||||
CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
|
||||
LDSHARED=${LDSHARED-"xlc -G"} ;;
|
||||
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"}
|
||||
@@ -424,6 +492,13 @@ tryboth()
|
||||
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
|
||||
:
|
||||
@@ -443,7 +518,7 @@ 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 -o $test$shared_ext $test.o; then
|
||||
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
|
||||
@@ -505,7 +580,7 @@ int main(void) {
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
if try $CC $CFLAGS -o $test $test.c; then
|
||||
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}"
|
||||
@@ -539,7 +614,7 @@ int main(void) {
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
if try $CC $CFLAGS -o $test $test.c; then
|
||||
if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then
|
||||
echo "Checking for fseeko... Yes." | tee -a configure.log
|
||||
else
|
||||
CFLAGS="${CFLAGS} -DNO_FSEEKO"
|
||||
@@ -556,7 +631,7 @@ cat > $test.c <<EOF
|
||||
#include <errno.h>
|
||||
int main() { return strlen(strerror(errno)); }
|
||||
EOF
|
||||
if try $CC $CFLAGS -o $test $test.c; then
|
||||
if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then
|
||||
echo "Checking for strerror... Yes." | tee -a configure.log
|
||||
else
|
||||
CFLAGS="${CFLAGS} -DNO_STRERROR"
|
||||
@@ -575,7 +650,7 @@ cat > $test.c <<EOF
|
||||
int main() { return 0; }
|
||||
EOF
|
||||
if try $CC -c $CFLAGS $test.c; then
|
||||
sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
|
||||
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
|
||||
@@ -590,7 +665,7 @@ cat > $test.c <<EOF
|
||||
int main() { return 0; }
|
||||
EOF
|
||||
if try $CC -c $CFLAGS $test.c; then
|
||||
sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
|
||||
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
|
||||
@@ -618,7 +693,6 @@ 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
|
||||
CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
|
||||
if test -n "$GCC_CLASSIC"; then
|
||||
CC=$GCC_CLASSIC
|
||||
fi
|
||||
@@ -663,7 +737,7 @@ int main()
|
||||
return (mytest("Hello%d\n", 1));
|
||||
}
|
||||
EOF
|
||||
if try $CC $CFLAGS -o $test $test.c; then
|
||||
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
|
||||
@@ -703,7 +777,10 @@ EOF
|
||||
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>
|
||||
@@ -753,7 +830,7 @@ int main()
|
||||
}
|
||||
EOF
|
||||
|
||||
if try $CC $CFLAGS -o $test $test.c; then
|
||||
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
|
||||
@@ -787,7 +864,10 @@ EOF
|
||||
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>
|
||||
@@ -835,6 +915,70 @@ EOF
|
||||
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
|
||||
@@ -866,10 +1010,15 @@ 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#
|
||||
|
||||
@@ -0,0 +1,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)
|
||||
@@ -6,7 +6,7 @@ for help about these, not the zlib authors. Thanks.
|
||||
|
||||
ada/ by Dmitriy Anisimkov <anisimkov@yahoo.com>
|
||||
Support for Ada
|
||||
See http://zlib-ada.sourceforge.net/
|
||||
See https://zlib-ada.sourceforge.net/
|
||||
|
||||
blast/ by Mark Adler <madler@alumni.caltech.edu>
|
||||
Decompressor for output of PKWare Data Compression Library (DCL)
|
||||
@@ -37,7 +37,7 @@ iostream3/ by Ludwig Schwardt <schwardt@sun.ac.za>
|
||||
minizip/ by Gilles Vollant <info@winimage.com>
|
||||
Mini zip and unzip based on zlib
|
||||
Includes Zip64 support by Mathias Svensson <mathias@result42.com>
|
||||
See http://www.winimage.com/zLibDll/minizip.html
|
||||
See https://www.winimage.com/zLibDll/minizip.html
|
||||
|
||||
pascal/ by Bob Dellaca <bobdl@xtra.co.nz> et al.
|
||||
Support for Pascal
|
||||
@@ -46,12 +46,12 @@ 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
|
||||
|
||||
untgz/ by Pedro A. Aranda Gutierrez <paag@tid.es>
|
||||
A very simple tar.gz file extractor using zlib
|
||||
|
||||
vstudio/ by Gilles Vollant <info@winimage.com>
|
||||
Building a minizip-enhanced zlib with Microsoft Visual Studio
|
||||
Includes vc11 from kreuzerkrieg and vc12 from davispuh
|
||||
zlib1-dll/
|
||||
by @Vollstrecker on github.com
|
||||
Build the legacy zlib1.dll with zlib and minizip.
|
||||
@@ -0,0 +1,217 @@
|
||||
cmake_minimum_required(VERSION 3.12...3.31)
|
||||
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
|
||||
|
||||
project(
|
||||
zlibAda
|
||||
VERSION 1.0.0
|
||||
LANGUAGES C ADA
|
||||
DESCRIPTION "A library for creating zipfiles based in zlib"
|
||||
HOMEPAGE_URL "https://www.zlib.net")
|
||||
|
||||
option(ZLIB_ADA_BUILD_SHARED "Enable building ada bindings shared library" ON)
|
||||
option(ZLIB_ADA_BUILD_STATIC "Enable building ada bindings static library" ON)
|
||||
option(ZLIB_ADA_BUILD_TESTING "Enable building tests for ada bindings library" ON)
|
||||
|
||||
if(WIN32 OR CYGWIN)
|
||||
set(zlib_Ada_static_suffix "s")
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
endif(WIN32 OR CYGWIN)
|
||||
|
||||
if(NOT DEFINED ZLIB_BUILD_ADA)
|
||||
if(ZLIB_ADA_BUILD_SHARED)
|
||||
list(APPEND REQUIRED_COMPONENTS "shared")
|
||||
endif(ZLIB_ADA_BUILD_SHARED)
|
||||
|
||||
if(ZLIB_ADA_BUILD_STATIC)
|
||||
list(APPEND REQUIRED_COMPONENTS "static")
|
||||
endif(ZLIB_ADA_BUILD_STATIC)
|
||||
|
||||
find_package(ZLIB REQUIRED COMPONENTS ${REQUIRED_COMPONENTS} CONFIG)
|
||||
endif(NOT DEFINED ZLIB_BUILD_ADA)
|
||||
|
||||
function(ZLIB_ADA_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(ZLIB_ADA_findTestEnv testName)
|
||||
|
||||
if(ZLIB_ADA_BUILD_SHARED)
|
||||
ada_add_library(zlib_ada_Ada SHARED
|
||||
zlib-thin.adb
|
||||
zlib.adb)
|
||||
|
||||
set_target_properties(zlib_ada_Ada
|
||||
PROPERTIES OUTPUT_NAME zlib-ada)
|
||||
|
||||
target_link_libraries(zlib_ada_Ada
|
||||
INTERFACE ZLIB::ZLIB)
|
||||
|
||||
ada_add_library(zlib_ada_streams SHARED
|
||||
zlib-streams.adb)
|
||||
|
||||
target_link_libraries(zlib_ada_streams
|
||||
PUBLIC
|
||||
zlib_ada_Ada)
|
||||
|
||||
ada_find_ali(zlib_ada_streams)
|
||||
|
||||
if(ZLIB_ADA_BUILD_TESTING)
|
||||
enable_testing()
|
||||
ada_add_executable(zlib_ada_test test.adb)
|
||||
|
||||
target_link_libraries(zlib_ada_test
|
||||
PRIVATE
|
||||
zlib_ada_Ada
|
||||
zlib_ada_streams)
|
||||
|
||||
ada_find_ali(zlib_ada_test)
|
||||
|
||||
add_test(NAME zlib_ada_ada-test COMMAND zlib_ada_test)
|
||||
set_tests_properties(zlib_ada_ada-test PROPERTIES FIXTURES_REQUIRED zlib_ada_cleanup)
|
||||
|
||||
if(MSVC
|
||||
OR MSYS
|
||||
OR MINGW
|
||||
OR CYGWIN)
|
||||
zlib_ada_findtestenv(zlib_ada_ada-test)
|
||||
endif(
|
||||
MSVC
|
||||
OR MSYS
|
||||
OR MINGW
|
||||
OR CYGWIN)
|
||||
|
||||
ada_add_executable(zlib_ada_buffer_demo buffer_demo.adb)
|
||||
|
||||
target_link_libraries(zlib_ada_buffer_demo
|
||||
PRIVATE
|
||||
zlib_ada_Ada)
|
||||
|
||||
ada_find_ali(zlib_ada_buffer_demo)
|
||||
|
||||
add_test(NAME zlib_ada_buffer-demo COMMAND zlib_ada_buffer_demo)
|
||||
|
||||
if(MSVC
|
||||
OR MSYS
|
||||
OR MINGW
|
||||
OR CYGWIN)
|
||||
zlib_ada_findtestenv(zlib_ada_buffer-demo)
|
||||
endif(
|
||||
MSVC
|
||||
OR MSYS
|
||||
OR MINGW
|
||||
OR CYGWIN)
|
||||
|
||||
ada_add_executable(zlib_ada_mtest mtest.adb)
|
||||
|
||||
target_link_libraries(zlib_ada_mtest
|
||||
PRIVATE
|
||||
zlib_ada_Ada)
|
||||
|
||||
ada_find_ali(zlib_ada_mtest)
|
||||
|
||||
#Not adding test as this is an endless-loop
|
||||
|
||||
ada_add_executable(zlib_ada_read read.adb)
|
||||
|
||||
target_link_libraries(zlib_ada_read
|
||||
PRIVATE
|
||||
zlib_ada_Ada)
|
||||
|
||||
ada_find_ali(zlib_ada_read)
|
||||
|
||||
add_test(NAME zlib_ada_read COMMAND zlib_ada_read)
|
||||
|
||||
if(MSVC
|
||||
OR MSYS
|
||||
OR MINGW
|
||||
OR CYGWIN)
|
||||
zlib_ada_findtestenv(zlib_ada_read)
|
||||
endif(
|
||||
MSVC
|
||||
OR MSYS
|
||||
OR MINGW
|
||||
OR CYGWIN)
|
||||
endif(ZLIB_ADA_BUILD_TESTING)
|
||||
endif(ZLIB_ADA_BUILD_SHARED)
|
||||
|
||||
if(ZLIB_ADA_BUILD_STATIC)
|
||||
ada_add_library(zlib_ada_AdaStatic STATIC
|
||||
zlib-thin.adb
|
||||
zlib.adb)
|
||||
|
||||
target_link_libraries(zlib_ada_AdaStatic
|
||||
INTERFACE ZLIB::ZLIBSTATIC)
|
||||
|
||||
set_target_properties(zlib_ada_AdaStatic
|
||||
PROPERTIES OUTPUT_NAME zlib-ada${zlib_Ada_static_suffix})
|
||||
|
||||
ada_add_library(zlib_ada_streamsStatic STATIC
|
||||
zlib-streams.adb)
|
||||
|
||||
target_link_libraries(zlib_ada_streamsStatic
|
||||
PUBLIC
|
||||
zlib_ada_AdaStatic)
|
||||
|
||||
ada_find_ali(zlib_ada_streamsStatic)
|
||||
|
||||
if(ZLIB_ADA_BUILD_TESTING)
|
||||
enable_testing()
|
||||
ada_add_executable(zlib_ada_testStatic test.adb)
|
||||
|
||||
target_link_libraries(zlib_ada_testStatic
|
||||
PRIVATE
|
||||
zlib_ada_AdaStatic
|
||||
zlib_ada_streamsStatic)
|
||||
|
||||
ada_find_ali(zlib_ada_testStatic)
|
||||
|
||||
add_test(NAME zlib_ada_testStatic COMMAND zlib_ada_testStatic)
|
||||
set_tests_properties(zlib_ada_testStatic PROPERTIES FIXTURES_REQUIRED zlib_ada_cleanup)
|
||||
|
||||
ada_add_executable(zlib_ada_buffer-demoStatic buffer_demo.adb)
|
||||
|
||||
target_link_libraries(zlib_ada_buffer-demoStatic
|
||||
PRIVATE
|
||||
zlib_ada_AdaStatic)
|
||||
|
||||
ada_find_ali(zlib_ada_buffer-demoStatic)
|
||||
|
||||
add_test(NAME zlib_ada_buffer-demoStatic COMMAND zlib_ada_buffer-demoStatic)
|
||||
|
||||
ada_add_executable(zlib_ada_mtestStatic mtest.adb)
|
||||
|
||||
target_link_libraries(zlib_ada_mtestStatic
|
||||
PRIVATE
|
||||
zlib_ada_AdaStatic)
|
||||
|
||||
ada_find_ali(zlib_ada_mtestStatic)
|
||||
|
||||
# Not adding test as this is an endless-loop
|
||||
|
||||
ada_add_executable(zlib_ada_readStatic read.adb)
|
||||
|
||||
target_link_libraries(zlib_ada_readStatic
|
||||
PRIVATE
|
||||
zlib_ada_AdaStatic)
|
||||
|
||||
ada_find_ali(zlib_ada_readStatic)
|
||||
|
||||
add_test(NAME zlib_ada_readStatic COMMAND zlib_ada_readStatic)
|
||||
endif(ZLIB_ADA_BUILD_TESTING)
|
||||
endif(ZLIB_ADA_BUILD_STATIC)
|
||||
|
||||
if(ZLIB_ADA_BUILD_TESTING)
|
||||
add_test(NAME zlib_ada_cleanup COMMAND ${CMAKE_COMMAND} -E rm ${CMAKE_CURRENT_BINARY_DIR}/testzlib.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/testzlib.out ${CMAKE_CURRENT_BINARY_DIR}/testzlib.zlb)
|
||||
set_tests_properties(zlib_ada_cleanup PROPERTIES FIXTURES_CLEANUP zlib_ada_cleanup)
|
||||
endif(ZLIB_ADA_BUILD_TESTING)
|
||||
@@ -0,0 +1,23 @@
|
||||
set(CMAKE_ADA_COMPILER "@CMAKE_ADA_COMPILER@")
|
||||
set(CMAKE_ADA_COMPILER_ARG1 "@CMAKE_ADA_COMPILER_ARG1@")
|
||||
set(CMAKE_ADA_COMPILER_ID "@CMAKE_ADA_COMPILER_ID@")
|
||||
set(CMAKE_ADA_COMPILER_VERSION "@CMAKE_ADA_COMPILER_VERSION@")
|
||||
set(CMAKE_ADA_PLATFORM_ID "@CMAKE_ADA_PLATFORM_ID@")
|
||||
set(CMAKE_AR "@CMAKE_AR@")
|
||||
#set(CMAKE_RANLIB "@CMAKE_RANLIB@")
|
||||
#set(CMAKE_LINKER "@CMAKE_LINKER@")
|
||||
set(CMAKE_ADA_COMPILER_LOADED TRUE)
|
||||
set(CMAKE_ADA_COMPILER_WORKS @CMAKE_ADA_COMPILER_WORKS@)
|
||||
#set(CMAKE_ADA_ABI_COMPILED @CMAKE_ADA_ABI_COMPILED@)
|
||||
|
||||
set(CMAKE_ADA_COMPILER_ENV_VAR "ADA")
|
||||
|
||||
set(CMAKE_ADA_COMPILER_ID_RUN TRUE)
|
||||
set(CMAKE_ADA_SOURCE_FILE_EXTENSIONS adb;ADB)
|
||||
set(CMAKE_ADA_IGNORE_EXTENSIONS ;o;O;obj;OBJ;ali)
|
||||
|
||||
set(CMAKE_ADA_BINDER_HELPER "@CMAKE_ADA_BINDER_HELPER@")
|
||||
set(CMAKE_ADA_COMPILER_HELPER "@CMAKE_ADA_COMPILER_HELPER@")
|
||||
set(CMAKE_ADA_EXE_LINK_HELPER "@CMAKE_ADA_EXE_LINK_HELPER@")
|
||||
set(CMAKE_ADA_SHARED_LINK_HELPER "@CMAKE_ADA_SHARED_LINK_HELPER@")
|
||||
set(CMAKE_ADA_STATIC_LINK_HELPER "@CMAKE_ADA_STATIC_LINK_HELPER@")
|
||||
@@ -0,0 +1,133 @@
|
||||
include(CMakeLanguageInformation)
|
||||
|
||||
set(CMAKE_ADA_OUTPUT_EXTENSION .o)
|
||||
set(CMAKE_ADA_OUTPUT_EXTENSION_REPLACE TRUE)
|
||||
|
||||
if(CMAKE_USER_MAKE_RULES_OVERRIDE)
|
||||
include(${CMAKE_USER_MAKE_RULES_OVERRIDE} RESULT_VARIABLE _override)
|
||||
set(CMAKE_USER_MAKE_RULES_OVERRIDE "${_override}")
|
||||
endif(CMAKE_USER_MAKE_RULES_OVERRIDE)
|
||||
|
||||
|
||||
if(CMAKE_USER_MAKE_RULES_OVERRIDE_ADA)
|
||||
include(${CMAKE_USER_MAKE_RULES_OVERRIDE_ADA} RESULT_VARIABLE _override)
|
||||
set(CMAKE_USER_MAKE_RULES_OVERRIDE_ADA "${_override}")
|
||||
endif(CMAKE_USER_MAKE_RULES_OVERRIDE_ADA)
|
||||
|
||||
set(CMAKE_ADA_FLAGS_INIT "$ENV{ADAFLAGS} ${CMAKE_ADA_FLAGS_INIT}")
|
||||
|
||||
string(APPEND CMAKE_ADA_FLAGS_INIT " ")
|
||||
string(APPEND CMAKE_ADA_FLAGS_DEBUG_INIT " -g")
|
||||
string(APPEND CMAKE_ADA_FLAGS_MINSIZEREL_INIT " -Os")
|
||||
string(APPEND CMAKE_ADA_FLAGS_RELEASE_INIT " -O3")
|
||||
string(APPEND CMAKE_ADA_FLAGS_RELWITHDEBINFO_INIT " -O2 -g")
|
||||
|
||||
cmake_initialize_per_config_variable(CMAKE_ADA_FLAGS "Flags used by the Ada compiler")
|
||||
|
||||
if(CMAKE_ADA_STANDARD_LIBRARIES_INIT)
|
||||
set(CMAKE_ADA_STANDARD_LIBRARIES
|
||||
"${CMAKE_ADA_STANDARD_LIBRARIES_INIT}"
|
||||
CACHE
|
||||
STRING "Libraries linked by default with all Ada applications.")
|
||||
mark_as_advanced(CMAKE_ADA_STANDARD_LIBRARIES)
|
||||
endif(CMAKE_ADA_STANDARD_LIBRARIES_INIT)
|
||||
|
||||
if(NOT CMAKE_ADA_COMPILER_LAUNCHER AND DEFINED ENV{CMAKE_ADA_COMPILER_LAUNCHER})
|
||||
set(CMAKE_ADA_COMPILER_LAUNCHER
|
||||
"$ENV{CMAKE_ADA_COMPILER_LAUNCHER}"
|
||||
CACHE
|
||||
STRING "Compiler launcher for Ada.")
|
||||
endif(NOT CMAKE_ADA_COMPILER_LAUNCHER AND DEFINED ENV{CMAKE_ADA_COMPILER_LAUNCHER})
|
||||
|
||||
if(NOT CMAKE_ADA_LINKER_LAUNCHER AND DEFINED ENV{CMAKE_ADA_LINKER_LAUNCHER})
|
||||
set(CMAKE_ADA_LINKER_LAUNCHER
|
||||
"$ENV{CMAKE_ADA_LINKER_LAUNCHER}"
|
||||
CACHE
|
||||
STRING "Linker launcher for Ada.")
|
||||
endif(NOT CMAKE_ADA_LINKER_LAUNCHER AND DEFINED ENV{CMAKE_ADA_LINKER_LAUNCHER})
|
||||
|
||||
include(CMakeCommonLanguageInclude)
|
||||
_cmake_common_language_platform_flags(ADA)
|
||||
|
||||
if(NOT CMAKE_ADA_CREATE_SHARED_LIBRARY)
|
||||
set(CMAKE_ADA_CREATE_SHARED_LIBRARY
|
||||
"${CMAKE_ADA_BINDER_HELPER} <CMAKE_ADA_COMPILER> <OBJECTS> FLAGS <FLAGS> <LINK_FLAGS>"
|
||||
"${CMAKE_ADA_SHARED_LINK_HELPER} <CMAKE_ADA_COMPILER> <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
endif(NOT CMAKE_ADA_CREATE_SHARED_LIBRARY)
|
||||
|
||||
if(NOT CMAKE_ADA_CREATE_STATIC_LIBRARY)
|
||||
set(CMAKE_ADA_CREATE_STATIC_LIBRARY
|
||||
"${CMAKE_ADA_STATIC_LINK_HELPER} ${CMAKE_AR} <TARGET> <OBJECTS>")
|
||||
endif(NOT CMAKE_ADA_CREATE_STATIC_LIBRARY)
|
||||
|
||||
if(NOT CMAKE_ADA_COMPILE_OBJECT)
|
||||
set(CMAKE_ADA_COMPILE_OBJECT
|
||||
"${CMAKE_ADA_COMPILER_HELPER} <CMAKE_ADA_COMPILER> <OBJECT_DIR> <SOURCE> <FLAGS>")
|
||||
endif(NOT CMAKE_ADA_COMPILE_OBJECT)
|
||||
|
||||
if(NOT CMAKE_ADA_LINK_EXECUTABLE)
|
||||
set(CMAKE_ADA_LINK_EXECUTABLE
|
||||
"${CMAKE_ADA_BINDER_HELPER} <CMAKE_ADA_COMPILER> <OBJECTS> FLAGS <FLAGS> <LINK_FLAGS>"
|
||||
"${CMAKE_ADA_EXE_LINK_HELPER} <CMAKE_ADA_COMPILER> <TARGET> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> OBJ <OBJECTS> LIBS <LINK_LIBRARIES>")
|
||||
endif(NOT CMAKE_ADA_LINK_EXECUTABLE)
|
||||
|
||||
function(ada_add_executable)
|
||||
if(ARGC GREATER 1)
|
||||
math(EXPR last_index "${ARGC} - 1")
|
||||
foreach(source RANGE 1 ${last_index})
|
||||
list(APPEND SOURCES ${ARGV${source}})
|
||||
string(REPLACE ".adb" "" ali "${ARGV${source}}")
|
||||
set(clean_file "CMakeFiles/${ARGV0}.dir/${ali}.ali")
|
||||
list(APPEND CLEAN_FILES ${clean_file})
|
||||
list(APPEND CLEAN_FILES b~${ali}.adb)
|
||||
list(APPEND CLEAN_FILES b~${ali}.ads)
|
||||
list(APPEND CLEAN_FILES b~${ali}.ali)
|
||||
list(APPEND CLEAN_FILES b~${ali}.o)
|
||||
endforeach(source RANGE 1 ${ARGC})
|
||||
|
||||
add_executable(${ARGV0} ${ARGV1} ${SOURCES})
|
||||
|
||||
set_target_properties(${ARGV0}
|
||||
PROPERTIES
|
||||
ADDITIONAL_CLEAN_FILES "${CLEAN_FILES}")
|
||||
endif(ARGC GREATER 1)
|
||||
endfunction(ada_add_executable)
|
||||
|
||||
function(ada_add_library)
|
||||
if(ARGC GREATER 2)
|
||||
math(EXPR last_index "${ARGC} - 1")
|
||||
foreach(source RANGE 2 ${last_index})
|
||||
list(APPEND SOURCES ${ARGV${source}})
|
||||
string(REPLACE ".adb" "" ali "${ARGV${source}}")
|
||||
set(clean_file "CMakeFiles/${ARGV0}.dir/${ali}.ali")
|
||||
list(APPEND CLEAN_FILES ${clean_file})
|
||||
list(APPEND CLEAN_FILES b~${ali}.adb)
|
||||
list(APPEND CLEAN_FILES b~${ali}.ads)
|
||||
list(APPEND CLEAN_FILES b~${ali}.ali)
|
||||
list(APPEND CLEAN_FILES b~${ali}.o)
|
||||
endforeach(source RANGE 2 ${ARGC})
|
||||
|
||||
add_library(${ARGV0} ${ARGV1} ${SOURCES})
|
||||
|
||||
set_target_properties(${ARGV0}
|
||||
PROPERTIES
|
||||
ADDITIONAL_CLEAN_FILES "${CLEAN_FILES};dummylib.adb;dummylib.ali;dummylib.o"
|
||||
ALI_FLAG "-aO${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${ARGV0}.dir/")
|
||||
endif(ARGC GREATER 2)
|
||||
endfunction(ada_add_library)
|
||||
|
||||
function(ada_find_ali)
|
||||
get_target_property(link_libs ${ARGV0} LINK_LIBRARIES)
|
||||
|
||||
foreach(lib IN LISTS link_libs)
|
||||
get_target_property(ali ${lib} ALI_FLAG)
|
||||
string(APPEND FLAGS ${ali} " ")
|
||||
unset(ali)
|
||||
endforeach(lib IN LISTS link_libs)
|
||||
|
||||
set_target_properties(${ARGV0}
|
||||
PROPERTIES
|
||||
LINK_FLAGS ${FLAGS})
|
||||
endfunction(ada_find_ali)
|
||||
|
||||
set(CMAKE_ADA_INFORMATION_LOADED TRUE)
|
||||
@@ -0,0 +1,33 @@
|
||||
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake)
|
||||
|
||||
# Load system-specific compiler preferences for this language.
|
||||
include(Platform/${CMAKE_SYSTEM_NAME}-Determine-Ada OPTIONAL)
|
||||
include(Platform/${CMAKE_SYSTEM_NAME}-Ada OPTIONAL)
|
||||
|
||||
if(NOT CMAKE_ADA_COMPILER_NAMES)
|
||||
set(CMAKE_ADA_COMPILER_NAMES gnat)
|
||||
|
||||
foreach(ver RANGE 11 99)
|
||||
list(APPEND CMAKE_ADA_COMPILER_NAMES gnat-${ver})
|
||||
endforeach(ver RANGE 11 99)
|
||||
endif(NOT CMAKE_ADA_COMPILER_NAMES)
|
||||
|
||||
if(NOT CMAKE_ADA_COMPILER)
|
||||
set(CMAKE_ADA_COMPILER_INIT NOTFOUND)
|
||||
_cmake_find_compiler(ADA)
|
||||
else(NOT CMAKE_REAL_ADA_COMPILER)
|
||||
_cmake_find_compiler_path(ADA)
|
||||
endif(NOT CMAKE_ADA_COMPILER)
|
||||
|
||||
mark_as_advanced(CMAKE_ADA_COMPILER)
|
||||
set(CMAKE_ADA_COMPILER_ID "GNU")
|
||||
set(CMAKE_ADA_BINDER_HELPER "${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/binder_helper.cmake")
|
||||
set(CMAKE_ADA_COMPILER_HELPER "${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/compile_helper.cmake")
|
||||
set(CMAKE_ADA_EXE_LINK_HELPER "${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/exe_link_helper.cmake")
|
||||
set(CMAKE_ADA_SHARED_LINK_HELPER "${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/shared_link_helper.cmake")
|
||||
set(CMAKE_ADA_STATIC_LINK_HELPER "${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/static_link_helper.cmake")
|
||||
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/CMakeADACompiler.cmake.in
|
||||
${CMAKE_PLATFORM_INFO_DIR}/CMakeADACompiler.cmake
|
||||
@ONLY)
|
||||
@@ -0,0 +1,46 @@
|
||||
include(CMakeTestCompilerCommon)
|
||||
unset(CMAKE_ADA_COMPILER_WORKS CACHE)
|
||||
|
||||
if(NOT CMAKE_ADA_COMPILER_WORKS)
|
||||
PrintTestCompilerStatus("ADA" "")
|
||||
set(_ADA_TEST_FILE "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.adb")
|
||||
|
||||
file(WRITE ${_ADA_TEST_FILE}
|
||||
"with Ada.Text_IO; use Ada.Text_IO;\n"
|
||||
"\n"
|
||||
"procedure main is\n"
|
||||
"begin\n"
|
||||
"Put_Line(\"Hello, World!\");\n"
|
||||
"end Main;\n")
|
||||
|
||||
try_compile(CMAKE_ADA_COMPILER_WORKS ${CMAKE_BINARY_DIR}
|
||||
${_ADA_TEST_FILE}
|
||||
OUTPUT_VARIABLE __CMAKE_ADA_COMPILER_OUTPUT)
|
||||
|
||||
set(CMAKE_ADA_COMPILER_WORKS ${CMAKE_ADA_COMPILER_WORKS})
|
||||
unset(CMAKE_ADA_COMPILER_WORKS CACHE)
|
||||
set(ADA_TEST_WAS_RUN TRUE)
|
||||
endif(NOT CMAKE_ADA_COMPILER_WORKS)
|
||||
|
||||
if(NOT CMAKE_ADA_COMPILER_WORKS)
|
||||
PrintTestCompilerStatus("ADA" " -- broken")
|
||||
|
||||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||
"Determining if the Ada compiler works failed with "
|
||||
"the following output:\n${__CMAKE_ADA_COMPILER_OUTPUT}\n\n")
|
||||
|
||||
message(FATAL_ERROR "The Ada compiler \"${CMAKE_ADA_COMPILER}\" "
|
||||
"is not able to compile a simple test program.\nIt fails "
|
||||
"with the following output:\n ${__CMAKE_ADA_COMPILER_OUTPUT}\n\n"
|
||||
"CMake will not be able to correctly generate this project.")
|
||||
else(NOT CMAKE_ADA_COMPILER_WORKS)
|
||||
if(ADA_TEST_WAS_RUN)
|
||||
PrintTestCompilerStatus("ADA" " -- works")
|
||||
|
||||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||
"Determining if the Ada compiler works passed with "
|
||||
"the following output:\n${__CMAKE_ADA_COMPILER_OUTPUT}\n\n")
|
||||
endif(ADA_TEST_WAS_RUN)
|
||||
endif(NOT CMAKE_ADA_COMPILER_WORKS)
|
||||
|
||||
unset(__CMAKE_ADA_COMPILER_OUTPUT)
|
||||
@@ -0,0 +1,47 @@
|
||||
#CMAKE_ARGV0 = /path/to/cmake
|
||||
#CMAKE_ARGV1 = -P
|
||||
#CMAKE_ARGV2 = path/to/this/file
|
||||
#CMAKE_ARGV3 = binder
|
||||
#CMAKE_ARGV4 = ali
|
||||
|
||||
if(NOT CMAKE_ARGV3)
|
||||
message(FATAL_ERROR "binder not set")
|
||||
endif(NOT CMAKE_ARGV3)
|
||||
|
||||
string(REPLACE ".o" ".ali" ALI ${CMAKE_ARGV4})
|
||||
|
||||
set (REACHED_FLAGS FALSE)
|
||||
#iterate over additional objects, only the main one is needed
|
||||
foreach(arg RANGE 5 ${CMAKE_ARGC})
|
||||
if(CMAKE_ARGV${arg} STREQUAL FLAGS)
|
||||
set(REACHED_FLAGS TRUE)
|
||||
continue()
|
||||
endif(CMAKE_ARGV${arg} STREQUAL FLAGS)
|
||||
|
||||
string(SUBSTRING "${CMAKE_ARGV${arg}}" 0 2 start)
|
||||
|
||||
if(start STREQUAL "-O")
|
||||
continue()
|
||||
endif(start STREQUAL "-O")
|
||||
|
||||
if(REACHED_FLAGS)
|
||||
list(APPEND FLAGS ${CMAKE_ARGV${arg}})
|
||||
endif(REACHED_FLAGS)
|
||||
endforeach(arg RANGE 5 CMAKE_ARGC)
|
||||
|
||||
#first see if there is a main function
|
||||
execute_process(COMMAND ${CMAKE_ARGV3} bind ${ALI} ${FLAGS}
|
||||
RESULT_VARIABLE MAIN_RESULT
|
||||
OUTPUT_VARIABLE dont_care
|
||||
ERROR_VARIABLE ERROR)
|
||||
|
||||
if(MAIN_RESULT)
|
||||
execute_process(COMMAND ${CMAKE_ARGV3} bind -n ${ALI} ${FLAGS}
|
||||
RESULT_VARIABLE RESULT
|
||||
OUTPUT_VARIABLE dont_care
|
||||
ERROR_VARIABLE ERROR)
|
||||
endif(MAIN_RESULT)
|
||||
|
||||
if(RESULT)
|
||||
message(FATAL_ERROR ${RESULT} ${ERROR})
|
||||
endif(RESULT)
|
||||
@@ -0,0 +1,32 @@
|
||||
#CMAKE_ARGV0 = /path/to/cmake
|
||||
#CMAKE_ARGV1 = -P
|
||||
#CMAKE_ARGV2 = path/to/this/file
|
||||
#CMAKE_ARGV3 = compiler
|
||||
#CMAKE_ARGV4 = OBJECT-DIR
|
||||
#CMAKE_ARGV5 = source-file
|
||||
|
||||
if(NOT CMAKE_ARGV3)
|
||||
message(FATAL_ERROR "compiler not set")
|
||||
endif(NOT CMAKE_ARGV3)
|
||||
|
||||
if(NOT CMAKE_ARGV4)
|
||||
message(FATAL_ERROR "object dir not set")
|
||||
endif(NOT CMAKE_ARGV4)
|
||||
|
||||
if(NOT CMAKE_ARGV5)
|
||||
message(FATAL_ERROR "source not set")
|
||||
endif(NOT CMAKE_ARGV5)
|
||||
|
||||
foreach(arg RANGE 6 ${CMAKE_ARGC})
|
||||
list(APPEND FLAGS "${CMAKE_ARGV${arg}}")
|
||||
endforeach(arg RANGE 6 ${CMAKE_ARGC})
|
||||
|
||||
execute_process(COMMAND ${CMAKE_ARGV3} compile ${FLAGS} ${CMAKE_ARGV5}
|
||||
WORKING_DIRECTORY ${CMAKE_ARGV4}
|
||||
RESULT_VARIABLE RESULT
|
||||
OUTPUT_VARIABLE dont_care
|
||||
ERROR_VARIABLE ERROR)
|
||||
|
||||
if(RESULT)
|
||||
message(FATAL_ERROR ${RESULT} ${ERROR})
|
||||
endif(RESULT)
|
||||
@@ -0,0 +1,53 @@
|
||||
#CMAKE_ARGV0 = /path/to/cmake
|
||||
#CMAKE_ARGV1 = -P
|
||||
#CMAKE_ARGV2 = path/to/this/file
|
||||
#CMAKE_ARGV3 = linker
|
||||
#CMAKE_ARGV4 = output-name
|
||||
#CMAKE_ARGV5...CMAKE_AGVN = OBJECTS
|
||||
#CMAKE_ARGVN+1 = LIBS
|
||||
#CMAKE_ARGVN+2...CMAKE_ARGVM libraries
|
||||
|
||||
if(NOT CMAKE_ARGV3)
|
||||
message(FATAL_ERROR "linker not set")
|
||||
endif(NOT CMAKE_ARGV3)
|
||||
|
||||
set(REACHED_LIBS FALSE)
|
||||
set(REACHED_OBJ FALSE)
|
||||
foreach(arg RANGE 5 ${CMAKE_ARGC})
|
||||
if(CMAKE_ARGV${arg} STREQUAL LIBS)
|
||||
set(REACHED_LIBS TRUE)
|
||||
set(REACHED_OBJ FALSE)
|
||||
continue()
|
||||
endif(CMAKE_ARGV${arg} STREQUAL LIBS)
|
||||
|
||||
if(CMAKE_ARGV${arg} STREQUAL OBJ)
|
||||
set(REACHED_LIBS FALSE)
|
||||
set(REACHED_OBJ TRUE)
|
||||
continue()
|
||||
endif(CMAKE_ARGV${arg} STREQUAL OBJ)
|
||||
|
||||
if(CMAKE_ARGC EQUAL arg)
|
||||
continue()
|
||||
endif(CMAKE_ARGC EQUAL arg)
|
||||
|
||||
if(REACHED_LIBS)
|
||||
list(APPEND LIBS "${CMAKE_ARGV${arg}}")
|
||||
elseif(REACHED_OBJ AND NOT ALI)
|
||||
string(REPLACE ".o" ".ali" ALI "${CMAKE_ARGV${arg}}")
|
||||
else(REACHED_LIBS)
|
||||
string(SUBSTRING "${CMAKE_ARGV${arg}}" 0 3 start)
|
||||
|
||||
if(NOT start STREQUAL -aO)
|
||||
list(APPEND FLAGS "${CMAKE_ARGV${arg}}")
|
||||
endif(NOT start STREQUAL -aO)
|
||||
endif(REACHED_LIBS)
|
||||
endforeach(arg RANGE 5 ${CMAKE_ARGC})
|
||||
|
||||
execute_process(COMMAND ${CMAKE_ARGV3} link ${ALI} -o ${CMAKE_ARGV4} ${FLAGS} ${OTHER_OBJECTS} ${LIBS}
|
||||
RESULT_VARIABLE RESULT
|
||||
OUTPUT_VARIABLE dont_care
|
||||
ERROR_VARIABLE ERROR)
|
||||
|
||||
if(RESULT)
|
||||
message(FATAL_ERROR ${RESULT} ${ERROR})
|
||||
endif(RESULT)
|
||||
@@ -0,0 +1,52 @@
|
||||
#CMAKE_ARGV0 = /path/to/cmake
|
||||
#CMAKE_ARGV1 = -P
|
||||
#CMAKE_ARGV2 = path/to/this/file
|
||||
#CMAKE_ARGV3 = linker
|
||||
#CMAKE_ARGV4 = output-name
|
||||
#CMAKE_ARGV5...CMAKE_AGVN = OBJECTS
|
||||
#CMAKE_ARGVN+1 = LIBS
|
||||
#CMAKE_ARGVN+2...CMAKE_ARGVM libraries
|
||||
|
||||
if(NOT CMAKE_ARGV3)
|
||||
message(FATAL_ERROR "linker not set")
|
||||
endif(NOT CMAKE_ARGV3)
|
||||
|
||||
set(REACHED_FILES FALSE)
|
||||
foreach(arg RANGE 5 ${CMAKE_ARGC})
|
||||
if(CMAKE_ARGV${arg} STREQUAL "LIBS")
|
||||
set(REACHED_FILES TRUE)
|
||||
continue()
|
||||
endif(CMAKE_ARGV${arg} STREQUAL "LIBS")
|
||||
|
||||
if(CMAKE_ARGC EQUAL arg)
|
||||
continue()
|
||||
endif(CMAKE_ARGC EQUAL arg)
|
||||
|
||||
if(REACHED_LIBS)
|
||||
list(APPEND LIBS "${CMAKE_ARGV${arg}} ")
|
||||
else(REACHED_LIBS)
|
||||
list(APPEND OBJECT_FILES "${CMAKE_ARGV${arg}}")
|
||||
endif(REACHED_LIBS)
|
||||
endforeach(arg RANGE 5 ${CMAKE_ARGC})
|
||||
|
||||
file(WRITE dummylib.adb
|
||||
"procedure dummylib is\n"
|
||||
"begin\n"
|
||||
" null;\n"
|
||||
"end;\n")
|
||||
|
||||
execute_process(COMMAND ${CMAKE_ARGV3} compile -fPIC dummylib.adb
|
||||
OUTPUT_VARIABLE dont_care
|
||||
ERROR_VARIABLE ERROR)
|
||||
execute_process(COMMAND ${CMAKE_ARGV3} bind -n dummylib.ali
|
||||
OUTPUT_VARIABLE dont_care
|
||||
ERROR_VARIABLE ERROR)
|
||||
|
||||
execute_process(COMMAND ${CMAKE_ARGV3} link -shared dummylib.ali -o ${CMAKE_ARGV4} ${OBJECT_FILES} ${LIBS}
|
||||
RESULT_VARIABLE RESULT
|
||||
OUTPUT_VARIABLE dont_care
|
||||
ERROR_VARIABLE ERROR)
|
||||
|
||||
if(RESULT)
|
||||
message(FATAL_ERROR ${RESULT} ${ERROR})
|
||||
endif(RESULT)
|
||||
@@ -0,0 +1,25 @@
|
||||
#CMAKE_ARGV0 = /path/to/cmake
|
||||
#CMAKE_ARGV1 = -P
|
||||
#CMAKE_ARGV2 = path/to/this/file
|
||||
#CMAKE_ARGV3 = path/to/ar
|
||||
#CMAKE_ARGV4 = output-name
|
||||
#CMAKE_ARGV5...CMAKE_AGVN = OBJECTS
|
||||
|
||||
if(NOT CMAKE_ARGV3)
|
||||
message(FATAL_ERROR "linker not set")
|
||||
endif(NOT CMAKE_ARGV3)
|
||||
|
||||
foreach(arg RANGE 5 ${CMAKE_ARGC})
|
||||
if(NOT CMAKE_ARGC EQUAL arg)
|
||||
list(APPEND OBJECT_FILES "${CMAKE_ARGV${arg}}")
|
||||
endif(NOT CMAKE_ARGC EQUAL arg)
|
||||
endforeach(arg RANGE 6 ${CMAKE_ARGC})
|
||||
|
||||
execute_process(COMMAND ${CMAKE_ARGV3} rcs ${CMAKE_ARGV4} ${OBJECT_FILES}
|
||||
RESULT_VARIABLE RESULT
|
||||
OUTPUT_VARIABLE dont_care
|
||||
ERROR_VARIABLE ERROR)
|
||||
|
||||
if(RESULT)
|
||||
message(FATAL_ERROR ${RESULT} ${ERROR})
|
||||
endif(RESULT)
|
||||
@@ -2,7 +2,7 @@
|
||||
Release 1.3
|
||||
|
||||
ZLib.Ada is a thick binding interface to the popular ZLib data
|
||||
compression library, available at http://www.gzip.org/zlib/.
|
||||
compression library, available at https://zlib.net/.
|
||||
It provides Ada-style access to the ZLib C library.
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ the main functionality of ZLib.Ada.
|
||||
The routines from the package specifications are commented.
|
||||
|
||||
|
||||
Homepage: http://zlib-ada.sourceforge.net/
|
||||
Homepage: https://zlib-ada.sourceforge.net/
|
||||
Author: Dmitriy Anisimkov <anisimkov@yahoo.com>
|
||||
|
||||
Contributors: Pascal Obry <pascal@obry.org>, Steve Sangwine <sjs@essex.ac.uk>
|
||||
|
||||
@@ -12,7 +12,8 @@ package body ZLib.Thin is
|
||||
|
||||
ZLIB_VERSION : constant Chars_Ptr := zlibVersion;
|
||||
|
||||
Z_Stream_Size : constant Int := Z_Stream'Size / System.Storage_Unit;
|
||||
Dummy : Z_Stream;
|
||||
Z_Stream_Size : constant Int := Dummy'Size / System.Storage_Unit;
|
||||
|
||||
--------------
|
||||
-- Avail_In --
|
||||
|
||||
@@ -0,0 +1,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)
|
||||
+11
-5
@@ -1,8 +1,14 @@
|
||||
blast: blast.c blast.h
|
||||
cc -DTEST -o blast blast.c
|
||||
all: test
|
||||
|
||||
test: blast
|
||||
blast < test.pk | cmp - test.txt
|
||||
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 blast blast.o
|
||||
rm -f libblast.so blast-test blast-test.o
|
||||
|
||||
@@ -0,0 +1,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;
|
||||
}
|
||||
@@ -33,7 +33,6 @@
|
||||
#include <setjmp.h> /* for setjmp(), longjmp(), and jmp_buf */
|
||||
#include "blast.h" /* prototype for blast() */
|
||||
|
||||
#define local static /* for local function definitions */
|
||||
#define MAXBITS 13 /* maximum code length */
|
||||
#define MAXWIN 4096 /* maximum window size */
|
||||
|
||||
@@ -421,46 +420,3 @@ int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow,
|
||||
err = 1;
|
||||
return err;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
/* 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;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
Mark Adler madler@alumni.caltech.edu
|
||||
*/
|
||||
|
||||
#define local static /* for local function definitions */
|
||||
|
||||
/*
|
||||
* blast() decompresses the PKWare Data Compression Library (DCL) compressed
|
||||
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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)
|
||||
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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
|
||||
@@ -0,0 +1,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;
|
||||
@@ -0,0 +1,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 */
|
||||
@@ -152,7 +152,7 @@ procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer;
|
||||
const OutBuf: Pointer; BufSize: Integer);
|
||||
|
||||
const
|
||||
zlib_version = '1.3.1';
|
||||
zlib_version = '1.3.2';
|
||||
|
||||
type
|
||||
EZlibError = class(Exception);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// © 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 http://www.boost.org/LICENSE_1_0.txt)
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// © 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 http://www.boost.org/LICENSE_1_0.txt)
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// © 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 http://www.boost.org/LICENSE_1_0.txt)
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// © 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 http://www.boost.org/LICENSE_1_0.txt)
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// © 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 http://www.boost.org/LICENSE_1_0.txt)
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// © 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 http://www.boost.org/LICENSE_1_0.txt)
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// © 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 http://www.boost.org/LICENSE_1_0.txt)
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// © 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 http://www.boost.org/LICENSE_1_0.txt)
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
using System;
|
||||
@@ -17,7 +17,7 @@ using NUnit.Framework;
|
||||
// Unit tests for the DotZLib class library
|
||||
// ----------------------------------------
|
||||
//
|
||||
// Use this with NUnit 2 from http://www.nunit.org
|
||||
// Use this with NUnit 2 from https://www.nunit.org
|
||||
//
|
||||
|
||||
namespace DotZLibTests
|
||||
@@ -156,7 +156,7 @@ namespace DotZLibTests
|
||||
public void Info_Version()
|
||||
{
|
||||
Info info = new Info();
|
||||
Assert.AreEqual("1.3.1", Info.Version);
|
||||
Assert.AreEqual("1.3.2", Info.Version);
|
||||
Assert.AreEqual(32, info.SizeOfUInt);
|
||||
Assert.AreEqual(32, info.SizeOfULong);
|
||||
Assert.AreEqual(32, info.SizeOfPointer);
|
||||
|
||||
@@ -55,4 +55,4 @@ Build instructions:
|
||||
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 http://www.boost.org/LICENSE_1_0.txt)
|
||||
(See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
@@ -0,0 +1,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)
|
||||
+570
-574
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,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)
|
||||
+12
-12
@@ -293,7 +293,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
|
||||
mode = TABLE;
|
||||
break;
|
||||
case 3:
|
||||
strm->msg = (char *)"invalid block type";
|
||||
strm->msg = (z_const char *)"invalid block type";
|
||||
mode = BAD;
|
||||
}
|
||||
DROPBITS(2);
|
||||
@@ -304,7 +304,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
|
||||
BYTEBITS(); /* go to byte boundary */
|
||||
NEEDBITS(32);
|
||||
if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
|
||||
strm->msg = (char *)"invalid stored block lengths";
|
||||
strm->msg = (z_const char *)"invalid stored block lengths";
|
||||
mode = BAD;
|
||||
break;
|
||||
}
|
||||
@@ -341,7 +341,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
|
||||
state->ncode = BITS(4) + 4;
|
||||
DROPBITS(4);
|
||||
if (state->nlen > 286) {
|
||||
strm->msg = (char *)"too many length symbols";
|
||||
strm->msg = (z_const char *)"too many length symbols";
|
||||
mode = BAD;
|
||||
break;
|
||||
}
|
||||
@@ -362,7 +362,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
|
||||
ret = inflate_table9(CODES, state->lens, 19, &(state->next),
|
||||
&(lenbits), state->work);
|
||||
if (ret) {
|
||||
strm->msg = (char *)"invalid code lengths set";
|
||||
strm->msg = (z_const char *)"invalid code lengths set";
|
||||
mode = BAD;
|
||||
break;
|
||||
}
|
||||
@@ -386,7 +386,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
|
||||
NEEDBITS(here.bits + 2);
|
||||
DROPBITS(here.bits);
|
||||
if (state->have == 0) {
|
||||
strm->msg = (char *)"invalid bit length repeat";
|
||||
strm->msg = (z_const char *)"invalid bit length repeat";
|
||||
mode = BAD;
|
||||
break;
|
||||
}
|
||||
@@ -409,7 +409,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
|
||||
DROPBITS(7);
|
||||
}
|
||||
if (state->have + copy > state->nlen + state->ndist) {
|
||||
strm->msg = (char *)"invalid bit length repeat";
|
||||
strm->msg = (z_const char *)"invalid bit length repeat";
|
||||
mode = BAD;
|
||||
break;
|
||||
}
|
||||
@@ -423,7 +423,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
|
||||
|
||||
/* check for end-of-block code (better have one) */
|
||||
if (state->lens[256] == 0) {
|
||||
strm->msg = (char *)"invalid code -- missing end-of-block";
|
||||
strm->msg = (z_const char *)"invalid code -- missing end-of-block";
|
||||
mode = BAD;
|
||||
break;
|
||||
}
|
||||
@@ -437,7 +437,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
|
||||
ret = inflate_table9(LENS, state->lens, state->nlen,
|
||||
&(state->next), &(lenbits), state->work);
|
||||
if (ret) {
|
||||
strm->msg = (char *)"invalid literal/lengths set";
|
||||
strm->msg = (z_const char *)"invalid literal/lengths set";
|
||||
mode = BAD;
|
||||
break;
|
||||
}
|
||||
@@ -447,7 +447,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
|
||||
state->ndist, &(state->next), &(distbits),
|
||||
state->work);
|
||||
if (ret) {
|
||||
strm->msg = (char *)"invalid distances set";
|
||||
strm->msg = (z_const char *)"invalid distances set";
|
||||
mode = BAD;
|
||||
break;
|
||||
}
|
||||
@@ -495,7 +495,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
|
||||
|
||||
/* invalid code */
|
||||
if (here.op & 64) {
|
||||
strm->msg = (char *)"invalid literal/length code";
|
||||
strm->msg = (z_const char *)"invalid literal/length code";
|
||||
mode = BAD;
|
||||
break;
|
||||
}
|
||||
@@ -527,7 +527,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
|
||||
}
|
||||
DROPBITS(here.bits);
|
||||
if (here.op & 64) {
|
||||
strm->msg = (char *)"invalid distance code";
|
||||
strm->msg = (z_const char *)"invalid distance code";
|
||||
mode = BAD;
|
||||
break;
|
||||
}
|
||||
@@ -541,7 +541,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
|
||||
DROPBITS(extra);
|
||||
}
|
||||
if (offset > WSIZE - (wrap ? 0: left)) {
|
||||
strm->msg = (char *)"invalid distance too far back";
|
||||
strm->msg = (z_const char *)"invalid distance too far back";
|
||||
mode = BAD;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* inftree9.c -- generate Huffman trees for efficient decoding
|
||||
* Copyright (C) 1995-2024 Mark Adler
|
||||
* Copyright (C) 1995-2026 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define MAXBITS 15
|
||||
|
||||
const char inflate9_copyright[] =
|
||||
" inflate9 1.3.1 Copyright 1995-2024 Mark Adler ";
|
||||
" 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
|
||||
@@ -59,7 +59,7 @@ int inflate_table9(codetype type, unsigned short FAR *lens, unsigned codes,
|
||||
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, 203, 77};
|
||||
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,
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
* Christian Michelsen Research AS
|
||||
* Advanced Computing
|
||||
* Fantoftvegen 38, 5036 BERGEN, Norway
|
||||
* http://www.cmr.no
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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.
|
||||
+14
-10
@@ -1,21 +1,25 @@
|
||||
CC?=cc
|
||||
CFLAGS := $(CFLAGS) -O -I../..
|
||||
CPPFLAGS = -I../..
|
||||
|
||||
UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a
|
||||
ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $*.c
|
||||
|
||||
all: miniunz minizip
|
||||
|
||||
miniunz: $(UNZ_OBJS)
|
||||
$(CC) $(CFLAGS) -o $@ $(UNZ_OBJS)
|
||||
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
|
||||
|
||||
minizip: $(ZIP_OBJS)
|
||||
$(CC) $(CFLAGS) -o $@ $(ZIP_OBJS)
|
||||
miniunz: $(UNZ_OBJS)
|
||||
${CC} ${LDFLAGS} -o $@ $(UNZ_OBJS)
|
||||
|
||||
test: miniunz minizip
|
||||
minizip: $(ZIP_OBJS)
|
||||
${CC} ${LDFLAGS} -o $@ $(ZIP_OBJS)
|
||||
|
||||
test: miniunz minizip
|
||||
@rm -f test.*
|
||||
@echo hello hello hello > test.txt
|
||||
./minizip test test.txt
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
MiniZip - Copyright (c) 1998-2010 - by Gilles Vollant - version 1.1 64 bits from Mathias Svensson
|
||||
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 ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
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.
|
||||
@@ -11,7 +11,7 @@ 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 ( http://www.gdal.org/ )
|
||||
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.
|
||||
@@ -36,14 +36,9 @@ Credits
|
||||
Mathias Svensson - ZIP64 zip support
|
||||
Mathias Svensson - BZip Compression method support in zip
|
||||
|
||||
Resources
|
||||
Resource
|
||||
|
||||
ZipLayout http://result42.com/projects/ZipFileLayout
|
||||
Command line tool for Windows that shows the layout and information of the headers in a zip archive.
|
||||
Used when debugging and validating the creation of zip files using MiniZip64
|
||||
|
||||
|
||||
ZIP App Note http://www.pkware.com/documents/casestudies/APPNOTE.TXT
|
||||
ZIP App Note https://www.pkware.com/documents/casestudies/APPNOTE.TXT
|
||||
Zip File specification
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
# -*- Autoconf -*-
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_INIT([minizip], [1.3.1], [bugzilla.redhat.com])
|
||||
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], AC_HELP_STRING([--enable-demos], [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
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
/* crypt.h -- base code for crypt/uncrypt ZIPfile
|
||||
|
||||
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
Copyright (C) 1998-2026 Gilles Vollant
|
||||
|
||||
This code is a modified version of crypting code in Infozip distribution
|
||||
|
||||
@@ -23,7 +20,7 @@
|
||||
This code support the "Traditional PKWARE Encryption".
|
||||
|
||||
The new AES encryption added on Zip format by Winzip (see the page
|
||||
http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
|
||||
https://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
|
||||
Encryption is not supported.
|
||||
*/
|
||||
|
||||
@@ -50,7 +47,7 @@ static int update_keys(unsigned long* pkeys, const z_crc_t* pcrc_32_tab, int c)
|
||||
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
|
||||
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
|
||||
{
|
||||
register int keyshift = (int)((*(pkeys+1)) >> 24);
|
||||
int keyshift = (int)((*(pkeys+1)) >> 24);
|
||||
(*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
|
||||
}
|
||||
return c;
|
||||
@@ -106,7 +103,7 @@ static unsigned crypthead(const char* passwd, /* password string */
|
||||
*/
|
||||
if (++calls == 1)
|
||||
{
|
||||
srand((unsigned)(time(NULL) ^ ZCR_SEED2));
|
||||
srand((unsigned)time(NULL) ^ ZCR_SEED2);
|
||||
}
|
||||
init_keys(passwd, pkeys, pcrc_32_tab);
|
||||
for (n = 0; n < RAND_HEAD_LEN-2; n++)
|
||||
|
||||
@@ -0,0 +1,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
|
||||
@@ -1,10 +1,10 @@
|
||||
/* ioapi.h -- IO base function header for compress/uncompress .zip
|
||||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
part of the MiniZip project - ( https://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://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 ( http://result42.com )
|
||||
Copyright (C) 2009-2010 Mathias Svensson ( https://result42.com )
|
||||
|
||||
For more info read MiniZip_info.txt
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(IOAPI_NO_64) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
|
||||
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
|
||||
#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)
|
||||
|
||||
+12
-39
@@ -1,10 +1,10 @@
|
||||
/* ioapi.h -- IO base function header for compress/uncompress .zip
|
||||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
part of the MiniZip project - ( https://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://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 ( http://result42.com )
|
||||
Copyright (C) 2009-2010 Mathias Svensson ( https://result42.com )
|
||||
|
||||
For more info read MiniZip_info.txt
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _ZLIBIOAPI64_H
|
||||
#define _ZLIBIOAPI64_H
|
||||
#ifndef ZLIBIOAPI64_H
|
||||
#define ZLIBIOAPI64_H
|
||||
|
||||
#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
|
||||
#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.
|
||||
/* 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
|
||||
@@ -67,39 +67,12 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
#ifndef ZPOS64_T
|
||||
#ifdef _WIN32
|
||||
#define ZPOS64_T fpos_t
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#define ZPOS64_T uint64_t
|
||||
#endif
|
||||
#endif
|
||||
*/
|
||||
|
||||
#ifdef HAVE_MINIZIP64_CONF_H
|
||||
#include "mz64conf.h"
|
||||
#endif
|
||||
|
||||
/* a type chosen by DEFINE */
|
||||
#ifdef HAVE_64BIT_INT_CUSTOM
|
||||
typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
|
||||
#else
|
||||
#ifdef HAS_STDINT_H
|
||||
#include "stdint.h"
|
||||
typedef uint64_t ZPOS64_T;
|
||||
#else
|
||||
|
||||
|
||||
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
typedef unsigned __int64 ZPOS64_T;
|
||||
#else
|
||||
typedef unsigned long long int ZPOS64_T;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#include "ints.h"
|
||||
typedef ui64_t ZPOS64_T;
|
||||
|
||||
/* Maximum unsigned 32-bit value used as placeholder for zip64 */
|
||||
#ifndef MAXU32
|
||||
@@ -188,8 +161,8 @@ typedef struct zlib_filefunc64_32_def_s
|
||||
|
||||
#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 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))
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
/* iowin32.c -- IO base function header for compress/uncompress .zip
|
||||
Version 1.1, February 14h, 2010
|
||||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
part of the MiniZip project - ( https://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://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 ( http://result42.com )
|
||||
Copyright (C) 2009-2010 Mathias Svensson ( https://result42.com )
|
||||
|
||||
For more info read MiniZip_info.txt
|
||||
|
||||
@@ -26,7 +25,7 @@
|
||||
#endif
|
||||
|
||||
|
||||
// see Include/shared/winapifamily.h in the Windows Kit
|
||||
/* 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)
|
||||
@@ -89,7 +88,7 @@ static voidpf win32_build_iowin(HANDLE hFile) {
|
||||
}
|
||||
|
||||
voidpf ZCALLBACK win32_open64_file_func(voidpf opaque, const void* filename, int mode) {
|
||||
const char* mode_fopen = NULL;
|
||||
(void)opaque;
|
||||
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
|
||||
HANDLE hFile = NULL;
|
||||
|
||||
@@ -117,7 +116,7 @@ voidpf ZCALLBACK win32_open64_file_func(voidpf opaque, const void* filename, int
|
||||
|
||||
|
||||
voidpf ZCALLBACK win32_open64_file_funcA(voidpf opaque, const void* filename, int mode) {
|
||||
const char* mode_fopen = NULL;
|
||||
(void)opaque;
|
||||
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
|
||||
HANDLE hFile = NULL;
|
||||
|
||||
@@ -140,7 +139,7 @@ voidpf ZCALLBACK win32_open64_file_funcA(voidpf opaque, const void* filename, in
|
||||
|
||||
|
||||
voidpf ZCALLBACK win32_open64_file_funcW(voidpf opaque, const void* filename, int mode) {
|
||||
const char* mode_fopen = NULL;
|
||||
(void)opaque;
|
||||
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
|
||||
HANDLE hFile = NULL;
|
||||
|
||||
@@ -159,7 +158,7 @@ voidpf ZCALLBACK win32_open64_file_funcW(voidpf opaque, const void* filename, in
|
||||
|
||||
|
||||
voidpf ZCALLBACK win32_open_file_func(voidpf opaque, const char* filename, int mode) {
|
||||
const char* mode_fopen = NULL;
|
||||
(void)opaque;
|
||||
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
|
||||
HANDLE hFile = NULL;
|
||||
|
||||
@@ -187,6 +186,7 @@ voidpf ZCALLBACK win32_open_file_func(voidpf opaque, const char* filename, int m
|
||||
|
||||
|
||||
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)
|
||||
@@ -208,6 +208,7 @@ uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void* buf,uLo
|
||||
|
||||
|
||||
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)
|
||||
@@ -247,6 +248,7 @@ static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *n
|
||||
}
|
||||
|
||||
long ZCALLBACK win32_tell_file_func(voidpf opaque, voidpf stream) {
|
||||
(void)opaque;
|
||||
long ret=-1;
|
||||
HANDLE hFile = NULL;
|
||||
if (stream!=NULL)
|
||||
@@ -269,6 +271,7 @@ long ZCALLBACK win32_tell_file_func(voidpf opaque, voidpf stream) {
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -293,6 +296,7 @@ ZPOS64_T ZCALLBACK win32_tell64_file_func(voidpf opaque, voidpf stream) {
|
||||
|
||||
|
||||
long ZCALLBACK win32_seek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) {
|
||||
(void)opaque;
|
||||
DWORD dwMoveMethod=0xFFFFFFFF;
|
||||
HANDLE hFile = NULL;
|
||||
|
||||
@@ -330,6 +334,7 @@ long ZCALLBACK win32_seek_file_func(voidpf opaque, voidpf stream, uLong offset,
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -368,6 +373,7 @@ long ZCALLBACK win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T off
|
||||
}
|
||||
|
||||
int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream) {
|
||||
(void)opaque;
|
||||
int ret=-1;
|
||||
|
||||
if (stream!=NULL)
|
||||
@@ -385,6 +391,7 @@ int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream) {
|
||||
}
|
||||
|
||||
int ZCALLBACK win32_error_file_func(voidpf opaque, voidpf stream) {
|
||||
(void)opaque;
|
||||
int ret=-1;
|
||||
if (stream!=NULL)
|
||||
{
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
/* iowin32.h -- IO base function header for compress/uncompress .zip
|
||||
Version 1.1, February 14h, 2010
|
||||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
part of the MiniZip project - ( https://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://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 ( http://result42.com )
|
||||
Copyright (C) 2009-2010 Mathias Svensson ( https://result42.com )
|
||||
|
||||
For more info read MiniZip_info.txt
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ $ 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 __unix__
|
||||
#define fill_zlib_filefunc64_32_def_from_filefunc32 fillzffunc64from
|
||||
#define Write_Zip64EndOfCentralDirectoryLocator Write_Zip64EoDLocator
|
||||
#define Write_Zip64EndOfCentralDirectoryRecord Write_Zip64EoDRecord
|
||||
|
||||
+24
-24
@@ -1,15 +1,14 @@
|
||||
/*
|
||||
miniunz.c
|
||||
Version 1.1, February 14h, 2010
|
||||
sample part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
sample part of the MiniZip project - ( https://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://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 ( http://result42.com )
|
||||
Copyright (C) 2009-2010 Mathias Svensson ( https://result42.com )
|
||||
*/
|
||||
|
||||
#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
|
||||
@@ -39,6 +38,9 @@
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||
# define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -83,6 +85,7 @@
|
||||
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;
|
||||
|
||||
@@ -93,8 +96,7 @@ static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_dat
|
||||
LocalFileTimeToFileTime(&ftLocal,&ftm);
|
||||
SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
|
||||
CloseHandle(hFile);
|
||||
#else
|
||||
#if defined(unix) || defined(__APPLE__)
|
||||
#elif defined(__unix__) || defined(__unix) || defined(__APPLE__)
|
||||
(void)dosdate;
|
||||
struct utimbuf ut;
|
||||
struct tm newdate;
|
||||
@@ -116,7 +118,6 @@ static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_dat
|
||||
(void)dosdate;
|
||||
(void)tmu_date;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -127,9 +128,7 @@ static int mymkdir(const char* dirname) {
|
||||
int ret=0;
|
||||
#ifdef _WIN32
|
||||
ret = _mkdir(dirname);
|
||||
#elif unix
|
||||
ret = mkdir (dirname,0775);
|
||||
#elif __APPLE__
|
||||
#elif defined(__unix__) || defined(__unix) || defined(__APPLE__)
|
||||
ret = mkdir (dirname,0775);
|
||||
#else
|
||||
(void)dirname;
|
||||
@@ -151,7 +150,7 @@ static int makedir(const char *newdir) {
|
||||
printf("Error allocating memory\n");
|
||||
return UNZ_INTERNALERROR;
|
||||
}
|
||||
strcpy(buffer,newdir);
|
||||
memcpy(buffer,newdir,len+1);
|
||||
|
||||
if (buffer[len-1] == '/') {
|
||||
buffer[len-1] = '\0';
|
||||
@@ -187,7 +186,7 @@ static int makedir(const char *newdir) {
|
||||
|
||||
static void do_banner(void) {
|
||||
printf("MiniUnz 1.1, demo of zLib + Unz package written by Gilles Vollant\n");
|
||||
printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n");
|
||||
printf("more info at https://www.winimage.com/zLibDll/unzip.html\n\n");
|
||||
}
|
||||
|
||||
static void do_help(void) {
|
||||
@@ -235,12 +234,12 @@ static int do_list(unzFile uf) {
|
||||
|
||||
err = unzGetGlobalInfo64(uf,&gi);
|
||||
if (err!=UNZ_OK)
|
||||
printf("error %d with zipfile in unzGetGlobalInfo \n",err);
|
||||
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[256];
|
||||
char filename_inzip[65536+1];
|
||||
unz_file_info64 file_info;
|
||||
uLong ratio=0;
|
||||
const char *string_method = "";
|
||||
@@ -305,7 +304,7 @@ static int do_list(unzFile uf) {
|
||||
|
||||
|
||||
static int do_extract_currentfile(unzFile uf, const int* popt_extract_without_path, int* popt_overwrite, const char* password) {
|
||||
char filename_inzip[256];
|
||||
char filename_inzip[65536+1];
|
||||
char* filename_withoutpath;
|
||||
char* p;
|
||||
int err=UNZ_OK;
|
||||
@@ -482,13 +481,17 @@ static int do_extract(unzFile uf, int opt_extract_without_path, int opt_overwrit
|
||||
|
||||
err = unzGetGlobalInfo64(uf,&gi);
|
||||
if (err!=UNZ_OK)
|
||||
printf("error %d with zipfile in unzGetGlobalInfo \n",err);
|
||||
{
|
||||
printf("error %d with zipfile in unzGetGlobalInfo\n",err);
|
||||
return err;
|
||||
}
|
||||
|
||||
for (i=0;i<gi.number_entry;i++)
|
||||
{
|
||||
if (do_extract_currentfile(uf,&opt_extract_without_path,
|
||||
err = do_extract_currentfile(uf,&opt_extract_without_path,
|
||||
&opt_overwrite,
|
||||
password) != UNZ_OK)
|
||||
password);
|
||||
if (err != UNZ_OK)
|
||||
break;
|
||||
|
||||
if ((i+1)<gi.number_entry)
|
||||
@@ -502,7 +505,7 @@ static int do_extract(unzFile uf, int opt_extract_without_path, int opt_overwrit
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return err;
|
||||
}
|
||||
|
||||
static int do_extract_onefile(unzFile uf, const char* filename, int opt_extract_without_path, int opt_overwrite, const char* password) {
|
||||
@@ -512,12 +515,9 @@ static int do_extract_onefile(unzFile uf, const char* filename, int opt_extract_
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (do_extract_currentfile(uf,&opt_extract_without_path,
|
||||
return do_extract_currentfile(uf,&opt_extract_without_path,
|
||||
&opt_overwrite,
|
||||
password) == UNZ_OK)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
password);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+16
-14
@@ -1,15 +1,14 @@
|
||||
/*
|
||||
minizip.c
|
||||
Version 1.1, February 14h, 2010
|
||||
sample part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
sample part of the MiniZip project - ( https://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://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 ( http://result42.com )
|
||||
Copyright (C) 2009-2010 Mathias Svensson ( https://result42.com )
|
||||
*/
|
||||
|
||||
|
||||
@@ -41,6 +40,9 @@
|
||||
|
||||
|
||||
|
||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||
# define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -59,6 +61,7 @@
|
||||
#endif
|
||||
|
||||
#include "zip.h"
|
||||
#include "ints.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define USEWIN32IOAPI
|
||||
@@ -74,6 +77,7 @@
|
||||
/* 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;
|
||||
@@ -91,8 +95,7 @@ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
#if defined(unix) || defined(__APPLE__)
|
||||
#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) {
|
||||
@@ -143,7 +146,6 @@ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -161,7 +163,7 @@ static int check_exist_file(const char* filename) {
|
||||
|
||||
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 http://www.winimage.com/zLibDll/minizip.html\n\n");
|
||||
printf("more info on MiniZip at https://www.winimage.com/zLibDll/minizip.html\n\n");
|
||||
}
|
||||
|
||||
static void do_help(void) {
|
||||
@@ -192,7 +194,7 @@ static int getFileCrc(const char* filenameinzip, void* buf, unsigned long size_b
|
||||
do
|
||||
{
|
||||
err = ZIP_OK;
|
||||
size_read = fread(buf,1,size_buf,fin);
|
||||
size_read = (unsigned long)fread(buf,1,size_buf,fin);
|
||||
if (size_read < size_buf)
|
||||
if (feof(fin)==0)
|
||||
{
|
||||
@@ -224,7 +226,7 @@ static int isLargeFile(const char* filename) {
|
||||
FSEEKO_FUNC(pFile, 0, SEEK_END);
|
||||
pos = (ZPOS64_T)FTELLO_FUNC(pFile);
|
||||
|
||||
printf("File : %s is %llu bytes\n", filename, pos);
|
||||
printf("File : %s is %"PUI64" bytes\n", filename, pos);
|
||||
|
||||
if(pos >= 0xffffffff)
|
||||
largeFile = 1;
|
||||
@@ -244,7 +246,7 @@ int main(int argc, char *argv[]) {
|
||||
char filename_try[MAXFILENAME+16];
|
||||
int zipok;
|
||||
int err=0;
|
||||
size_t size_buf=0;
|
||||
unsigned long size_buf=0;
|
||||
void* buf=NULL;
|
||||
const char* password=NULL;
|
||||
|
||||
@@ -306,7 +308,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
else
|
||||
{
|
||||
int i,len;
|
||||
int len;
|
||||
int dot_found=0;
|
||||
|
||||
zipok = 1 ;
|
||||
@@ -432,7 +434,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
if( lastslash != NULL )
|
||||
{
|
||||
savefilenameinzip = lastslash+1; // base filename follows last slash.
|
||||
savefilenameinzip = lastslash+1; /* base filename follows last slash. */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -505,5 +507,5 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
free(buf);
|
||||
return 0;
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@/minizip
|
||||
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}
|
||||
|
||||
@@ -0,0 +1,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}
|
||||
@@ -0,0 +1,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)
|
||||
+40
-31
@@ -5,6 +5,9 @@
|
||||
*/
|
||||
|
||||
/* Code */
|
||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||
# define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -32,7 +35,7 @@ extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char*
|
||||
FILE* fpZip = fopen(file, "rb");
|
||||
FILE* fpOut = fopen(fileOut, "wb");
|
||||
FILE* fpOutCD = fopen(fileOutTmp, "wb");
|
||||
if (fpZip != NULL && fpOut != NULL) {
|
||||
if (fpZip != NULL && fpOut != NULL && fpOutCD != NULL ) {
|
||||
int entries = 0;
|
||||
uLong totalBytes = 0;
|
||||
char header[30];
|
||||
@@ -140,28 +143,28 @@ extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char*
|
||||
|
||||
/* Central directory entry */
|
||||
{
|
||||
char header[46];
|
||||
char central[46];
|
||||
char* comment = "";
|
||||
int comsize = (int) strlen(comment);
|
||||
WRITE_32(header, 0x02014b50);
|
||||
WRITE_16(header + 4, version);
|
||||
WRITE_16(header + 6, version);
|
||||
WRITE_16(header + 8, gpflag);
|
||||
WRITE_16(header + 10, method);
|
||||
WRITE_16(header + 12, filetime);
|
||||
WRITE_16(header + 14, filedate);
|
||||
WRITE_32(header + 16, crc);
|
||||
WRITE_32(header + 20, cpsize);
|
||||
WRITE_32(header + 24, uncpsize);
|
||||
WRITE_16(header + 28, fnsize);
|
||||
WRITE_16(header + 30, extsize);
|
||||
WRITE_16(header + 32, comsize);
|
||||
WRITE_16(header + 34, 0); /* disk # */
|
||||
WRITE_16(header + 36, 0); /* int attrb */
|
||||
WRITE_32(header + 38, 0); /* ext attrb */
|
||||
WRITE_32(header + 42, currentOffset);
|
||||
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(header, 1, 46, fpOutCD) == 46) {
|
||||
if (fwrite(central, 1, 46, fpOutCD) == 46) {
|
||||
offsetCD += 46;
|
||||
|
||||
/* Filename */
|
||||
@@ -215,23 +218,23 @@ extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char*
|
||||
/* Final central directory */
|
||||
{
|
||||
int entriesZip = entries;
|
||||
char header[22];
|
||||
char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools";
|
||||
char end[22];
|
||||
char* comment = ""; /* "ZIP File recovered by zlib/minizip/mztools"; */
|
||||
int comsize = (int) strlen(comment);
|
||||
if (entriesZip > 0xffff) {
|
||||
entriesZip = 0xffff;
|
||||
}
|
||||
WRITE_32(header, 0x06054b50);
|
||||
WRITE_16(header + 4, 0); /* disk # */
|
||||
WRITE_16(header + 6, 0); /* disk # */
|
||||
WRITE_16(header + 8, entriesZip); /* hack */
|
||||
WRITE_16(header + 10, entriesZip); /* hack */
|
||||
WRITE_32(header + 12, offsetCD); /* size of CD */
|
||||
WRITE_32(header + 16, offset); /* offset to CD */
|
||||
WRITE_16(header + 20, comsize); /* comment */
|
||||
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(header, 1, 22, fpOutCD) == 22) {
|
||||
if (fwrite(end, 1, 22, fpOutCD) == 22) {
|
||||
|
||||
/* Comment field */
|
||||
if (comsize > 0) {
|
||||
@@ -279,6 +282,12 @@ extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char*
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (fpOutCD != NULL)
|
||||
fclose(fpOutCD);
|
||||
if (fpZip != NULL)
|
||||
fclose(fpZip);
|
||||
if (fpOut != NULL)
|
||||
fclose(fpOut);
|
||||
err = Z_STREAM_ERROR;
|
||||
}
|
||||
return err;
|
||||
|
||||
@@ -0,0 +1,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
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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)
|
||||
@@ -0,0 +1,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)
|
||||
|
||||
+17
-18
@@ -1,14 +1,13 @@
|
||||
/* unzip.c -- IO for uncompress .zip files using zlib
|
||||
Version 1.1, February 14h, 2010
|
||||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
part of the MiniZip project - ( https://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://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 ( http://result42.com )
|
||||
Copyright (C) 2009-2010 Mathias Svensson ( https://result42.com )
|
||||
|
||||
For more info read MiniZip_info.txt
|
||||
|
||||
@@ -68,10 +67,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef NOUNCRYPT
|
||||
#define NOUNCRYPT
|
||||
#ifdef ZLIB_DLL
|
||||
# undef ZLIB_DLL
|
||||
#endif
|
||||
|
||||
#include "zlib.h"
|
||||
#include "unzip.h"
|
||||
|
||||
@@ -92,7 +90,7 @@
|
||||
|
||||
|
||||
#ifndef CASESENSITIVITYDEFAULT_NO
|
||||
# if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES)
|
||||
# if (!defined(__unix__) && !defined(__unix) || defined(__CYGWIN__)) && !defined(CASESENSITIVITYDEFAULT_YES)
|
||||
# define CASESENSITIVITYDEFAULT_NO
|
||||
# endif
|
||||
#endif
|
||||
@@ -115,7 +113,7 @@
|
||||
|
||||
|
||||
const char unz_copyright[] =
|
||||
" unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
|
||||
" 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
|
||||
@@ -687,6 +685,7 @@ extern unzFile ZEXPORT unzOpen2_64(const void *path,
|
||||
{
|
||||
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);
|
||||
@@ -846,7 +845,7 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
|
||||
if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK)
|
||||
err=UNZ_ERRNO;
|
||||
|
||||
// relative offset of local header
|
||||
/* 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;
|
||||
@@ -869,7 +868,7 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
|
||||
lSeek -= uSizeRead;
|
||||
}
|
||||
|
||||
// Read extrafield
|
||||
/* Read extrafield */
|
||||
if ((err==UNZ_OK) && (extraField!=NULL))
|
||||
{
|
||||
ZPOS64_T uSizeRead ;
|
||||
@@ -900,7 +899,7 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
|
||||
{
|
||||
uLong acc = 0;
|
||||
|
||||
// since lSeek now points to after the extra field we need to move back
|
||||
/* since lSeek now points to after the extra field we need to move back */
|
||||
lSeek -= file_info.size_file_extra;
|
||||
|
||||
if (lSeek!=0)
|
||||
@@ -1529,10 +1528,10 @@ extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file) {
|
||||
file_in_zip64_read_info_s* pfile_in_zip_read_info;
|
||||
s=(unz64_s*)file;
|
||||
if (file==NULL)
|
||||
return 0; //UNZ_PARAMERROR;
|
||||
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 0; /* UNZ_PARAMERROR; */
|
||||
return pfile_in_zip_read_info->pos_in_zipfile +
|
||||
pfile_in_zip_read_info->byte_before_the_zipfile;
|
||||
}
|
||||
@@ -1613,7 +1612,7 @@ extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len) {
|
||||
uInt i;
|
||||
for(i=0;i<uReadThis;i++)
|
||||
pfile_in_zip_read_info->read_buffer[i] =
|
||||
zdecode(s->keys,s->pcrc_32_tab,
|
||||
(char)zdecode(s->keys,s->pcrc_32_tab,
|
||||
pfile_in_zip_read_info->read_buffer[i]);
|
||||
}
|
||||
# endif
|
||||
@@ -1701,7 +1700,7 @@ extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len) {
|
||||
if (err!=BZ_OK)
|
||||
break;
|
||||
#endif
|
||||
} // end Z_BZIP2ED
|
||||
} /* end Z_BZIP2ED */
|
||||
else
|
||||
{
|
||||
ZPOS64_T uTotalOutBefore,uTotalOutAfter;
|
||||
@@ -1944,7 +1943,7 @@ extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file) {
|
||||
unz64_s* s;
|
||||
|
||||
if (file==NULL)
|
||||
return 0; //UNZ_PARAMERROR;
|
||||
return 0; /* UNZ_PARAMERROR; */
|
||||
s=(unz64_s*)file;
|
||||
if (!s->current_file_ok)
|
||||
return 0;
|
||||
@@ -1958,7 +1957,7 @@ extern uLong ZEXPORT unzGetOffset(unzFile file) {
|
||||
ZPOS64_T offset64;
|
||||
|
||||
if (file==NULL)
|
||||
return 0; //UNZ_PARAMERROR;
|
||||
return 0; /* UNZ_PARAMERROR; */
|
||||
offset64 = unzGetOffset64(file);
|
||||
return (uLong)offset64;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
/* unzip.h -- IO for uncompress .zip files using zlib
|
||||
Version 1.1, February 14h, 2010
|
||||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
part of the MiniZip project - ( https://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://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 ( http://result42.com )
|
||||
Copyright (C) 2009-2010 Mathias Svensson ( https://result42.com )
|
||||
|
||||
For more info read MiniZip_info.txt
|
||||
|
||||
@@ -70,6 +69,8 @@ typedef unzFile__ *unzFile;
|
||||
typedef voidp unzFile;
|
||||
#endif
|
||||
|
||||
extern const char unz_copyright[];
|
||||
|
||||
|
||||
#define UNZ_OK (0)
|
||||
#define UNZ_END_OF_LIST_OF_FILE (-100)
|
||||
@@ -313,6 +314,10 @@ extern int ZEXPORT unzGetCurrentFileInfo(unzFile file,
|
||||
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.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
+341
-51
@@ -1,11 +1,10 @@
|
||||
/* zip.c -- IO on .zip files using zlib
|
||||
Version 1.1, February 14h, 2010
|
||||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
part of the MiniZip project - ( https://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://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 ( http://result42.com )
|
||||
Copyright (C) 2009-2010 Mathias Svensson ( https://result42.com )
|
||||
|
||||
For more info read MiniZip_info.txt
|
||||
|
||||
@@ -25,8 +24,13 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#ifndef ZLIB_CONST
|
||||
# define ZLIB_CONST
|
||||
#endif
|
||||
#ifdef ZLIB_DLL
|
||||
# undef ZLIB_DLL
|
||||
#endif
|
||||
#include "zlib.h"
|
||||
#include "zip.h"
|
||||
|
||||
@@ -50,7 +54,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef Z_BUFSIZE
|
||||
#define Z_BUFSIZE (64*1024) //(16384)
|
||||
#define Z_BUFSIZE (64*1024) /* (16384) */
|
||||
#endif
|
||||
|
||||
#ifndef Z_MAXFILENAMEINZIP
|
||||
@@ -69,7 +73,7 @@
|
||||
/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
|
||||
|
||||
|
||||
// NOT sure that this work on ALL platform
|
||||
/* 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
|
||||
@@ -91,7 +95,7 @@
|
||||
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
||||
#endif
|
||||
#endif
|
||||
const char zip_copyright[] =" zip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
|
||||
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))
|
||||
@@ -123,6 +127,19 @@ typedef struct linkedlist_data_s
|
||||
} 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 */
|
||||
@@ -174,6 +191,10 @@ typedef struct
|
||||
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;
|
||||
|
||||
|
||||
@@ -264,6 +285,229 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len)
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
@@ -551,7 +795,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
|
||||
|
||||
for (i=(int)uReadSize-3; (i--)>0;)
|
||||
{
|
||||
// Signature "0x07064b50" Zip64 end of central directory locater
|
||||
/* 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;
|
||||
@@ -599,7 +843,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
|
||||
if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK)
|
||||
return 0;
|
||||
|
||||
if (uL != 0x06064b50) // signature of 'Zip64 end of central directory'
|
||||
if (uL != 0x06064b50) /* signature of 'Zip64 end of central directory' */
|
||||
return 0;
|
||||
|
||||
return relativeOffset;
|
||||
@@ -628,7 +872,7 @@ local int LoadCentralDirectoryRecord(zip64_internal* pziinit) {
|
||||
|
||||
int hasZIP64Record = 0;
|
||||
|
||||
// check first if we find a ZIP64 record
|
||||
/* check first if we find a ZIP64 record */
|
||||
central_pos = zip64local_SearchCentralDir64(&pziinit->z_filefunc,pziinit->filestream);
|
||||
if(central_pos > 0)
|
||||
{
|
||||
@@ -694,13 +938,13 @@ local int LoadCentralDirectoryRecord(zip64_internal* pziinit) {
|
||||
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.
|
||||
/* TODO..
|
||||
// read the comment from the standard central header. */
|
||||
size_comment = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Read End of central Directory info
|
||||
/* Read End of central Directory info */
|
||||
if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
|
||||
err=ZIP_ERRNO;
|
||||
|
||||
@@ -843,6 +1087,7 @@ extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* glo
|
||||
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 */
|
||||
|
||||
|
||||
|
||||
@@ -858,7 +1103,7 @@ extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* glo
|
||||
ziinit.globalcomment = NULL;
|
||||
if (append == APPEND_STATUS_ADDINZIP)
|
||||
{
|
||||
// Read and Cache Central Directory Records
|
||||
/* Read and Cache Central Directory Records */
|
||||
err = LoadCentralDirectoryRecord(&ziinit);
|
||||
}
|
||||
|
||||
@@ -899,6 +1144,7 @@ extern zipFile ZEXPORT zipOpen2_64(const void *pathname, int append, zipcharpc*
|
||||
{
|
||||
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);
|
||||
@@ -942,7 +1188,7 @@ local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt s
|
||||
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
|
||||
/* 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)
|
||||
@@ -986,13 +1232,13 @@ local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt s
|
||||
|
||||
if ((err==ZIP_OK) && (zi->ci.zip64))
|
||||
{
|
||||
// write the Zip64 extended info
|
||||
/* 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)
|
||||
/* 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);
|
||||
@@ -1005,6 +1251,46 @@ local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt s
|
||||
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
|
||||
@@ -1027,7 +1313,6 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c
|
||||
int err = ZIP_OK;
|
||||
|
||||
# ifdef NOCRYPT
|
||||
(crcForCrypting);
|
||||
if (password != NULL)
|
||||
return ZIP_PARAMERROR;
|
||||
# endif
|
||||
@@ -1043,14 +1328,14 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c
|
||||
return ZIP_PARAMERROR;
|
||||
#endif
|
||||
|
||||
// The filename and comment length must fit in 16 bits.
|
||||
/* 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
|
||||
/* 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.
|
||||
// length, but that will be checked for later. */
|
||||
if ((size_extrafield_local>0xffff) || (size_extrafield_global>0xffff))
|
||||
return ZIP_PARAMERROR;
|
||||
|
||||
@@ -1092,6 +1377,9 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c
|
||||
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;
|
||||
@@ -1102,7 +1390,7 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c
|
||||
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.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);
|
||||
|
||||
@@ -1197,7 +1485,7 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c
|
||||
else if(zi->ci.method == Z_BZIP2ED)
|
||||
{
|
||||
#ifdef HAVE_BZIP2
|
||||
// Init BZip stuff here
|
||||
/* Init BZip stuff here */
|
||||
zi->ci.bstream.bzalloc = 0;
|
||||
zi->ci.bstream.bzfree = 0;
|
||||
zi->ci.bstream.opaque = (voidpf)0;
|
||||
@@ -1399,7 +1687,7 @@ extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned i
|
||||
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;
|
||||
/* 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) ;
|
||||
@@ -1412,7 +1700,7 @@ extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned i
|
||||
else
|
||||
#endif
|
||||
{
|
||||
zi->ci.stream.next_in = (Bytef*)(uintptr_t)buf;
|
||||
zi->ci.stream.next_in = buf;
|
||||
zi->ci.stream.avail_in = len;
|
||||
|
||||
while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0))
|
||||
@@ -1457,7 +1745,7 @@ extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned i
|
||||
zi->ci.pos_in_buffered_data += copy_this;
|
||||
}
|
||||
}
|
||||
}// while(...)
|
||||
}/* while(...) */
|
||||
}
|
||||
|
||||
return err;
|
||||
@@ -1563,7 +1851,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
|
||||
compressed_size += zi->ci.crypt_header_size;
|
||||
# endif
|
||||
|
||||
// update Current Item crc and sizes,
|
||||
/* update Current Item crc and sizes, */
|
||||
if(compressed_size >= 0xffffffff || uncompressed_size >= 0xffffffff || zi->ci.pos_local_header >= 0xffffffff)
|
||||
{
|
||||
/*version Made by*/
|
||||
@@ -1581,7 +1869,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
|
||||
else
|
||||
zip64local_putValue_inmemory(zi->ci.central_header+20, compressed_size,4); /*compr size*/
|
||||
|
||||
/// set internal file attributes field
|
||||
/* 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);
|
||||
|
||||
@@ -1590,15 +1878,15 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
|
||||
else
|
||||
zip64local_putValue_inmemory(zi->ci.central_header+24, uncompressed_size,4); /*uncompr size*/
|
||||
|
||||
// Add ZIP64 extra info field for uncompressed size
|
||||
/* Add ZIP64 extra info field for uncompressed size */
|
||||
if(uncompressed_size >= 0xffffffff)
|
||||
datasize += 8;
|
||||
|
||||
// Add ZIP64 extra info field for compressed size
|
||||
/* 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
|
||||
/* Add ZIP64 extra info field for relative offset to local file header of current file */
|
||||
if(zi->ci.pos_local_header >= 0xffffffff)
|
||||
datasize += 8;
|
||||
|
||||
@@ -1608,16 +1896,16 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
|
||||
|
||||
if((uLong)(datasize + 4) > zi->ci.size_centralExtraFree)
|
||||
{
|
||||
// we cannot write more data to the buffer that we have room for.
|
||||
/* 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
|
||||
/* Add Extra Information Header for 'ZIP64 information' */
|
||||
zip64local_putValue_inmemory(p, 0x0001, 2); /* HeaderID */
|
||||
p += 2;
|
||||
zip64local_putValue_inmemory(p, datasize, 2); // DataSize
|
||||
zip64local_putValue_inmemory(p, datasize, 2); /* DataSize */
|
||||
p += 2;
|
||||
|
||||
if(uncompressed_size >= 0xffffffff)
|
||||
@@ -1638,13 +1926,13 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
|
||||
p += 8;
|
||||
}
|
||||
|
||||
// Update how much extra free space we got in the memory buffer
|
||||
/* 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 )
|
||||
// ( 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
|
||||
/* 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);
|
||||
}
|
||||
@@ -1656,7 +1944,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
|
||||
|
||||
if (err==ZIP_OK)
|
||||
{
|
||||
// Update the LocalFileHeader with the new values.
|
||||
/* Update the LocalFileHeader with the new values. */
|
||||
|
||||
ZPOS64_T cur_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream);
|
||||
|
||||
@@ -1670,7 +1958,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
|
||||
{
|
||||
if(zi->ci.pos_zip64extrainfo > 0)
|
||||
{
|
||||
// Update the size in the ZIP64 extended field.
|
||||
/* 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;
|
||||
|
||||
@@ -1681,7 +1969,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
|
||||
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
|
||||
err = ZIP_BADZIPFILE; /* Caller passed zip64 = 0, so no room for zip64 info -> fatal */
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1735,7 +2023,7 @@ local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_
|
||||
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 ?
|
||||
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);
|
||||
@@ -1782,7 +2070,7 @@ local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centr
|
||||
{
|
||||
{
|
||||
if(zi->number_entry >= 0xFFFF)
|
||||
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); // use value in ZIP64 record
|
||||
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);
|
||||
}
|
||||
@@ -1791,7 +2079,7 @@ local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centr
|
||||
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
|
||||
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);
|
||||
}
|
||||
@@ -1871,6 +2159,8 @@ extern int ZEXPORT zipClose(zipFile file, const char* global_comment) {
|
||||
}
|
||||
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)
|
||||
{
|
||||
@@ -1919,13 +2209,13 @@ extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHea
|
||||
header = *(short*)p;
|
||||
dataSize = *(((short*)p)+1);
|
||||
|
||||
if( header == sHeader ) // Header found.
|
||||
if( header == sHeader ) /* Header found. */
|
||||
{
|
||||
p += dataSize + 4; // skip it. do not copy to temp buffer
|
||||
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.
|
||||
/* 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;
|
||||
@@ -1935,14 +2225,14 @@ extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHea
|
||||
|
||||
if(size < *dataLen)
|
||||
{
|
||||
// clean old extra info block.
|
||||
/* clean old extra info block. */
|
||||
memset(pData,0, *dataLen);
|
||||
|
||||
// copy the new extra info block over the old
|
||||
/* copy the new extra info block over the old */
|
||||
if(size > 0)
|
||||
memcpy(pData, pNewHeader, size);
|
||||
|
||||
// set the new extra info size
|
||||
/* set the new extra info size */
|
||||
*dataLen = size;
|
||||
|
||||
retVal = ZIP_OK;
|
||||
|
||||
+21
-14
@@ -1,11 +1,10 @@
|
||||
/* zip.h -- IO on .zip files using zlib
|
||||
Version 1.1, February 14h, 2010
|
||||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
part of the MiniZip project - ( https://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://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 ( http://result42.com )
|
||||
Copyright (C) 2009-2010 Mathias Svensson ( https://result42.com )
|
||||
|
||||
For more info read MiniZip_info.txt
|
||||
|
||||
@@ -35,7 +34,7 @@
|
||||
|
||||
See header of zip.h
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
#ifndef _zip12_H
|
||||
#define _zip12_H
|
||||
@@ -44,7 +43,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//#define HAVE_BZIP2
|
||||
/* #define HAVE_BZIP2 */
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#include "zlib.h"
|
||||
@@ -69,6 +68,8 @@ typedef zipFile__ *zipFile;
|
||||
typedef voidp zipFile;
|
||||
#endif
|
||||
|
||||
extern const char zip_copyright[];
|
||||
|
||||
#define ZIP_OK (0)
|
||||
#define ZIP_EOF (0)
|
||||
#define ZIP_ERRNO (Z_ERRNO)
|
||||
@@ -127,12 +128,12 @@ extern zipFile ZEXPORT zipOpen64(const void *pathname, int append);
|
||||
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,
|
||||
@@ -186,7 +187,7 @@ extern int ZEXPORT zipOpenNewFileInZip64(zipFile file,
|
||||
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,
|
||||
@@ -311,12 +312,12 @@ extern int ZEXPORT zipWriteInFileInZip(zipFile file,
|
||||
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,
|
||||
@@ -326,17 +327,23 @@ 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);
|
||||
@@ -355,7 +362,7 @@ extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHea
|
||||
|
||||
Remove ZIP64 Extra information from a Local File Header extra field data
|
||||
zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001);
|
||||
*/
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
<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-2024 Jean-loup Gailly and Mark Adler</Copyright>
|
||||
<version>1.3.1</version>
|
||||
<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.
|
||||
@@ -20,6 +21,7 @@
|
||||
|
||||
<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" />
|
||||
|
||||
@@ -10,7 +10,7 @@ unit zlibpas;
|
||||
interface
|
||||
|
||||
const
|
||||
ZLIB_VERSION = '1.3.1';
|
||||
ZLIB_VERSION = '1.3.2';
|
||||
ZLIB_VERNUM = $12a0;
|
||||
|
||||
type
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user