Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .cmake-format.yaml +245 -0
- .gitattributes +1 -0
- .github/workflows/c-std.yml +230 -0
- .github/workflows/cmake.yml +112 -0
- .github/workflows/configure.yml +136 -0
- .github/workflows/fuzz.yml +25 -0
- .github/workflows/msys-cygwin.yml +77 -0
- .gitignore +51 -0
- BUILD.bazel +134 -0
- CMakeLists.txt +330 -0
- ChangeLog +1621 -0
- FAQ +367 -0
- INDEX +68 -0
- LICENSE +22 -0
- MODULE.bazel +9 -0
- Makefile.in +419 -0
- README +115 -0
- README-cmake.md +83 -0
- adler32.c +164 -0
- amiga/Makefile.pup +69 -0
- amiga/Makefile.sas +68 -0
- compress.c +75 -0
- configure +966 -0
- contrib/README.contrib +57 -0
- contrib/ada/buffer_demo.adb +106 -0
- contrib/ada/mtest.adb +156 -0
- contrib/ada/read.adb +156 -0
- contrib/ada/readme.txt +65 -0
- contrib/ada/test.adb +463 -0
- contrib/ada/zlib-streams.adb +225 -0
- contrib/ada/zlib-streams.ads +114 -0
- contrib/ada/zlib-thin.adb +142 -0
- contrib/ada/zlib-thin.ads +450 -0
- contrib/ada/zlib.adb +701 -0
- contrib/ada/zlib.ads +328 -0
- contrib/ada/zlib.gpr +20 -0
- contrib/blast/Makefile +8 -0
- contrib/blast/README +4 -0
- contrib/blast/blast.c +466 -0
- contrib/blast/blast.h +83 -0
- contrib/blast/test.pk +0 -0
- contrib/blast/test.txt +1 -0
- contrib/delphi/ZLib.pas +557 -0
- contrib/delphi/ZLibConst.pas +11 -0
- contrib/delphi/readme.txt +76 -0
- contrib/delphi/zlibd32.mak +99 -0
- contrib/dotzlib/DotZLib.build +33 -0
- contrib/dotzlib/DotZLib.chm +0 -0
- contrib/dotzlib/DotZLib.sln +21 -0
- contrib/dotzlib/DotZLib/AssemblyInfo.cs +58 -0
.cmake-format.yaml
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_help_parse: Options affecting listfile parsing
|
| 2 |
+
parse:
|
| 3 |
+
_help_additional_commands:
|
| 4 |
+
- Specify structure for custom cmake functions
|
| 5 |
+
additional_commands:
|
| 6 |
+
foo:
|
| 7 |
+
flags:
|
| 8 |
+
- BAR
|
| 9 |
+
- BAZ
|
| 10 |
+
kwargs:
|
| 11 |
+
HEADERS: '*'
|
| 12 |
+
SOURCES: '*'
|
| 13 |
+
DEPENDS: '*'
|
| 14 |
+
_help_override_spec:
|
| 15 |
+
- Override configurations per-command where available
|
| 16 |
+
override_spec: {}
|
| 17 |
+
_help_vartags:
|
| 18 |
+
- Specify variable tags.
|
| 19 |
+
vartags: []
|
| 20 |
+
_help_proptags:
|
| 21 |
+
- Specify property tags.
|
| 22 |
+
proptags: []
|
| 23 |
+
_help_format: Options affecting formatting.
|
| 24 |
+
format:
|
| 25 |
+
_help_disable:
|
| 26 |
+
- Disable formatting entirely, making cmake-format a no-op
|
| 27 |
+
disable: false
|
| 28 |
+
_help_line_width:
|
| 29 |
+
- How wide to allow formatted cmake files
|
| 30 |
+
line_width: 80
|
| 31 |
+
_help_tab_size:
|
| 32 |
+
- How many spaces to tab for indent
|
| 33 |
+
tab_size: 4
|
| 34 |
+
_help_use_tabchars:
|
| 35 |
+
- If true, lines are indented using tab characters (utf-8
|
| 36 |
+
- 0x09) instead of <tab_size> space characters (utf-8 0x20).
|
| 37 |
+
- In cases where the layout would require a fractional tab
|
| 38 |
+
- character, the behavior of the fractional indentation is
|
| 39 |
+
- governed by <fractional_tab_policy>
|
| 40 |
+
use_tabchars: false
|
| 41 |
+
_help_fractional_tab_policy:
|
| 42 |
+
- If <use_tabchars> is True, then the value of this variable
|
| 43 |
+
- indicates how fractional indentions are handled during
|
| 44 |
+
- whitespace replacement. If set to 'use-space', fractional
|
| 45 |
+
- indentation is left as spaces (utf-8 0x20). If set to
|
| 46 |
+
- '`round-up` fractional indentation is replaced with a single'
|
| 47 |
+
- tab character (utf-8 0x09) effectively shifting the column
|
| 48 |
+
- to the next tabstop
|
| 49 |
+
fractional_tab_policy: use-space
|
| 50 |
+
_help_max_subgroups_hwrap:
|
| 51 |
+
- If an argument group contains more than this many sub-groups
|
| 52 |
+
- (parg or kwarg groups) then force it to a vertical layout.
|
| 53 |
+
max_subgroups_hwrap: 2
|
| 54 |
+
_help_max_pargs_hwrap:
|
| 55 |
+
- If a positional argument group contains more than this many
|
| 56 |
+
- arguments, then force it to a vertical layout.
|
| 57 |
+
max_pargs_hwrap: 6
|
| 58 |
+
_help_max_rows_cmdline:
|
| 59 |
+
- If a cmdline positional group consumes more than this many
|
| 60 |
+
- lines without nesting, then invalidate the layout (and nest)
|
| 61 |
+
max_rows_cmdline: 2
|
| 62 |
+
_help_separate_ctrl_name_with_space:
|
| 63 |
+
- If true, separate flow control names from their parentheses
|
| 64 |
+
- with a space
|
| 65 |
+
separate_ctrl_name_with_space: false
|
| 66 |
+
_help_separate_fn_name_with_space:
|
| 67 |
+
- If true, separate function names from parentheses with a
|
| 68 |
+
- space
|
| 69 |
+
separate_fn_name_with_space: false
|
| 70 |
+
_help_dangle_parens:
|
| 71 |
+
- If a statement is wrapped to more than one line, than dangle
|
| 72 |
+
- the closing parenthesis on its own line.
|
| 73 |
+
dangle_parens: false
|
| 74 |
+
_help_dangle_align:
|
| 75 |
+
- If the trailing parenthesis must be 'dangled' on its on
|
| 76 |
+
- 'line, then align it to this reference: `prefix`: the start'
|
| 77 |
+
- 'of the statement, `prefix-indent`: the start of the'
|
| 78 |
+
- 'statement, plus one indentation level, `child`: align to'
|
| 79 |
+
- the column of the arguments
|
| 80 |
+
dangle_align: prefix
|
| 81 |
+
_help_min_prefix_chars:
|
| 82 |
+
- If the statement spelling length (including space and
|
| 83 |
+
- parenthesis) is smaller than this amount, then force reject
|
| 84 |
+
- nested layouts.
|
| 85 |
+
min_prefix_chars: 4
|
| 86 |
+
_help_max_prefix_chars:
|
| 87 |
+
- If the statement spelling length (including space and
|
| 88 |
+
- parenthesis) is larger than the tab width by more than this
|
| 89 |
+
- amount, then force reject un-nested layouts.
|
| 90 |
+
max_prefix_chars: 10
|
| 91 |
+
_help_max_lines_hwrap:
|
| 92 |
+
- If a candidate layout is wrapped horizontally but it exceeds
|
| 93 |
+
- this many lines, then reject the layout.
|
| 94 |
+
max_lines_hwrap: 2
|
| 95 |
+
_help_line_ending:
|
| 96 |
+
- What style line endings to use in the output.
|
| 97 |
+
line_ending: unix
|
| 98 |
+
_help_command_case:
|
| 99 |
+
- Format command names consistently as 'lower' or 'upper' case
|
| 100 |
+
command_case: canonical
|
| 101 |
+
_help_keyword_case:
|
| 102 |
+
- Format keywords consistently as 'lower' or 'upper' case
|
| 103 |
+
keyword_case: unchanged
|
| 104 |
+
_help_always_wrap:
|
| 105 |
+
- A list of command names which should always be wrapped
|
| 106 |
+
always_wrap: []
|
| 107 |
+
_help_enable_sort:
|
| 108 |
+
- If true, the argument lists which are known to be sortable
|
| 109 |
+
- will be sorted lexicographicall
|
| 110 |
+
enable_sort: true
|
| 111 |
+
_help_autosort:
|
| 112 |
+
- If true, the parsers may infer whether or not an argument
|
| 113 |
+
- list is sortable (without annotation).
|
| 114 |
+
autosort: false
|
| 115 |
+
_help_require_valid_layout:
|
| 116 |
+
- By default, if cmake-format cannot successfully fit
|
| 117 |
+
- everything into the desired linewidth it will apply the
|
| 118 |
+
- last, most aggressive attempt that it made. If this flag is
|
| 119 |
+
- True, however, cmake-format will print error, exit with non-
|
| 120 |
+
- zero status code, and write-out nothing
|
| 121 |
+
require_valid_layout: false
|
| 122 |
+
_help_layout_passes:
|
| 123 |
+
- A dictionary mapping layout nodes to a list of wrap
|
| 124 |
+
- decisions. See the documentation for more information.
|
| 125 |
+
layout_passes: {}
|
| 126 |
+
_help_markup: Options affecting comment reflow and formatting.
|
| 127 |
+
markup:
|
| 128 |
+
_help_bullet_char:
|
| 129 |
+
- What character to use for bulleted lists
|
| 130 |
+
bullet_char: '*'
|
| 131 |
+
_help_enum_char:
|
| 132 |
+
- What character to use as punctuation after numerals in an
|
| 133 |
+
- enumerated list
|
| 134 |
+
enum_char: .
|
| 135 |
+
_help_first_comment_is_literal:
|
| 136 |
+
- If comment markup is enabled, don't reflow the first comment
|
| 137 |
+
- block in each listfile. Use this to preserve formatting of
|
| 138 |
+
- your copyright/license statements.
|
| 139 |
+
first_comment_is_literal: false
|
| 140 |
+
_help_literal_comment_pattern:
|
| 141 |
+
- If comment markup is enabled, don't reflow any comment block
|
| 142 |
+
- which matches this (regex) pattern. Default is `None`
|
| 143 |
+
- (disabled).
|
| 144 |
+
literal_comment_pattern: null
|
| 145 |
+
_help_fence_pattern:
|
| 146 |
+
- Regular expression to match preformat fences in comments
|
| 147 |
+
- default= ``r'^\s*([`~]{3}[`~]*)(.*)$'``
|
| 148 |
+
fence_pattern: ^\s*([`~]{3}[`~]*)(.*)$
|
| 149 |
+
_help_ruler_pattern:
|
| 150 |
+
- Regular expression to match rulers in comments default=
|
| 151 |
+
- '``r''^\s*[^\w\s]{3}.*[^\w\s]{3}$''``'
|
| 152 |
+
ruler_pattern: ^\s*[^\w\s]{3}.*[^\w\s]{3}$
|
| 153 |
+
_help_explicit_trailing_pattern:
|
| 154 |
+
- If a comment line matches starts with this pattern then it
|
| 155 |
+
- is explicitly a trailing comment for the preceding argument.
|
| 156 |
+
- Default is '#<'
|
| 157 |
+
explicit_trailing_pattern: '#<'
|
| 158 |
+
_help_hashruler_min_length:
|
| 159 |
+
- If a comment line starts with at least this many consecutive
|
| 160 |
+
- hash characters, then don't lstrip() them off. This allows
|
| 161 |
+
- for lazy hash rulers where the first hash char is not
|
| 162 |
+
- separated by space
|
| 163 |
+
hashruler_min_length: 10
|
| 164 |
+
_help_canonicalize_hashrulers:
|
| 165 |
+
- If true, then insert a space between the first hash char and
|
| 166 |
+
- remaining hash chars in a hash ruler, and normalize its
|
| 167 |
+
- length to fill the column
|
| 168 |
+
canonicalize_hashrulers: true
|
| 169 |
+
_help_enable_markup:
|
| 170 |
+
- enable comment markup parsing and reflow
|
| 171 |
+
enable_markup: true
|
| 172 |
+
_help_lint: Options affecting the linter
|
| 173 |
+
lint:
|
| 174 |
+
_help_disabled_codes:
|
| 175 |
+
- a list of lint codes to disable
|
| 176 |
+
disabled_codes: []
|
| 177 |
+
_help_function_pattern:
|
| 178 |
+
- regular expression pattern describing valid function names
|
| 179 |
+
function_pattern: '[0-9a-z_]+'
|
| 180 |
+
_help_macro_pattern:
|
| 181 |
+
- regular expression pattern describing valid macro names
|
| 182 |
+
macro_pattern: '[0-9A-Z_]+'
|
| 183 |
+
_help_global_var_pattern:
|
| 184 |
+
- regular expression pattern describing valid names for
|
| 185 |
+
- variables with global (cache) scope
|
| 186 |
+
global_var_pattern: '[A-Z][0-9A-Z_]+'
|
| 187 |
+
_help_internal_var_pattern:
|
| 188 |
+
- regular expression pattern describing valid names for
|
| 189 |
+
- variables with global scope (but internal semantic)
|
| 190 |
+
internal_var_pattern: _[A-Z][0-9A-Z_]+
|
| 191 |
+
_help_local_var_pattern:
|
| 192 |
+
- regular expression pattern describing valid names for
|
| 193 |
+
- variables with local scope
|
| 194 |
+
local_var_pattern: '[a-z][a-z0-9_]+'
|
| 195 |
+
_help_private_var_pattern:
|
| 196 |
+
- regular expression pattern describing valid names for
|
| 197 |
+
- privatedirectory variables
|
| 198 |
+
private_var_pattern: _[0-9a-z_]+
|
| 199 |
+
_help_public_var_pattern:
|
| 200 |
+
- regular expression pattern describing valid names for public
|
| 201 |
+
- directory variables
|
| 202 |
+
public_var_pattern: '[A-Z][0-9A-Z_]+'
|
| 203 |
+
_help_argument_var_pattern:
|
| 204 |
+
- regular expression pattern describing valid names for
|
| 205 |
+
- function/macro arguments and loop variables.
|
| 206 |
+
argument_var_pattern: '[a-z][a-z0-9_]+'
|
| 207 |
+
_help_keyword_pattern:
|
| 208 |
+
- regular expression pattern describing valid names for
|
| 209 |
+
- keywords used in functions or macros
|
| 210 |
+
keyword_pattern: '[A-Z][0-9A-Z_]+'
|
| 211 |
+
_help_max_conditionals_custom_parser:
|
| 212 |
+
- In the heuristic for C0201, how many conditionals to match
|
| 213 |
+
- within a loop in before considering the loop a parser.
|
| 214 |
+
max_conditionals_custom_parser: 2
|
| 215 |
+
_help_min_statement_spacing:
|
| 216 |
+
- Require at least this many newlines between statements
|
| 217 |
+
min_statement_spacing: 1
|
| 218 |
+
_help_max_statement_spacing:
|
| 219 |
+
- Require no more than this many newlines between statements
|
| 220 |
+
max_statement_spacing: 2
|
| 221 |
+
max_returns: 6
|
| 222 |
+
max_branches: 12
|
| 223 |
+
max_arguments: 5
|
| 224 |
+
max_localvars: 15
|
| 225 |
+
max_statements: 50
|
| 226 |
+
_help_encode: Options affecting file encoding
|
| 227 |
+
encode:
|
| 228 |
+
_help_emit_byteorder_mark:
|
| 229 |
+
- If true, emit the unicode byte-order mark (BOM) at the start
|
| 230 |
+
- of the file
|
| 231 |
+
emit_byteorder_mark: false
|
| 232 |
+
_help_input_encoding:
|
| 233 |
+
- Specify the encoding of the input file. Defaults to utf-8
|
| 234 |
+
input_encoding: utf-8
|
| 235 |
+
_help_output_encoding:
|
| 236 |
+
- Specify the encoding of the output file. Defaults to utf-8.
|
| 237 |
+
- Note that cmake only claims to support utf-8 so be careful
|
| 238 |
+
- when using anything else
|
| 239 |
+
output_encoding: utf-8
|
| 240 |
+
_help_misc: Miscellaneous configurations options.
|
| 241 |
+
misc:
|
| 242 |
+
_help_per_command:
|
| 243 |
+
- A dictionary containing any per-command configuration
|
| 244 |
+
- overrides. Currently only `command_case` is supported.
|
| 245 |
+
per_command: {}
|
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
doc/crc-doc.1.0.pdf filter=lfs diff=lfs merge=lfs -text
|
.github/workflows/c-std.yml
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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+
workflow_dispatch:
|
| 8 |
+
push:
|
| 9 |
+
pull_request:
|
| 10 |
+
|
| 11 |
+
jobs:
|
| 12 |
+
|
| 13 |
+
main:
|
| 14 |
+
name: ${{ matrix.os.name }} ${{ matrix.compiler }} ${{ matrix.arch.name }} ${{ matrix.std.name }} ${{ matrix.builder }}
|
| 15 |
+
runs-on: ${{ matrix.os.value }}
|
| 16 |
+
strategy:
|
| 17 |
+
fail-fast: false
|
| 18 |
+
matrix:
|
| 19 |
+
os:
|
| 20 |
+
- name: Linux
|
| 21 |
+
value: ubuntu-latest
|
| 22 |
+
|
| 23 |
+
- name: MacOS
|
| 24 |
+
value: macos-latest
|
| 25 |
+
|
| 26 |
+
- name: Windows
|
| 27 |
+
value: windows-latest
|
| 28 |
+
cmake-opt: -G Ninja
|
| 29 |
+
|
| 30 |
+
compiler:
|
| 31 |
+
- gcc
|
| 32 |
+
- clang
|
| 33 |
+
|
| 34 |
+
arch:
|
| 35 |
+
- name: 64-bit
|
| 36 |
+
tag: amd64
|
| 37 |
+
compiler-opt: -m64
|
| 38 |
+
cmake-opt: -A x64
|
| 39 |
+
|
| 40 |
+
- name: 32-bit
|
| 41 |
+
tag: i386
|
| 42 |
+
compiler-opt: -m32
|
| 43 |
+
cmake-opt: -A Win32
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
builder:
|
| 47 |
+
- configure
|
| 48 |
+
- cmake
|
| 49 |
+
|
| 50 |
+
std:
|
| 51 |
+
- name: c89
|
| 52 |
+
value: c89
|
| 53 |
+
|
| 54 |
+
- name: gnu89
|
| 55 |
+
value: gnu89
|
| 56 |
+
|
| 57 |
+
- name: c94
|
| 58 |
+
value: iso9899:199409
|
| 59 |
+
|
| 60 |
+
- name: c99
|
| 61 |
+
value: c99
|
| 62 |
+
|
| 63 |
+
- name: gnu99
|
| 64 |
+
value: gnu99
|
| 65 |
+
|
| 66 |
+
- name: c11
|
| 67 |
+
value: c11
|
| 68 |
+
|
| 69 |
+
- name: gnu11
|
| 70 |
+
value: gnu11
|
| 71 |
+
|
| 72 |
+
- name: c17
|
| 73 |
+
value: c17
|
| 74 |
+
|
| 75 |
+
- name: gnu17
|
| 76 |
+
value: gnu17
|
| 77 |
+
|
| 78 |
+
- name: c2x
|
| 79 |
+
value: c2x
|
| 80 |
+
|
| 81 |
+
- name: gnu2x
|
| 82 |
+
value: gnu2x
|
| 83 |
+
|
| 84 |
+
exclude:
|
| 85 |
+
# Don't run 32-bit on MacOS
|
| 86 |
+
- { os: { name: MacOS },
|
| 87 |
+
arch: { tag: i386 } }
|
| 88 |
+
|
| 89 |
+
# Don't run configure on Windows
|
| 90 |
+
- { os: { name: Windows },
|
| 91 |
+
builder: configure }
|
| 92 |
+
|
| 93 |
+
# Don't run gcc 32-bit on Windows
|
| 94 |
+
- { os: { name: Windows },
|
| 95 |
+
arch: { tag: i386 } }
|
| 96 |
+
|
| 97 |
+
steps:
|
| 98 |
+
|
| 99 |
+
- name: Checkout repository
|
| 100 |
+
uses: actions/checkout@v4
|
| 101 |
+
with:
|
| 102 |
+
show-progress: 'false'
|
| 103 |
+
|
| 104 |
+
- name: Install packages (Linux)
|
| 105 |
+
if: runner.os == 'Linux' && matrix.arch.tag == 'i386'
|
| 106 |
+
run: |
|
| 107 |
+
sudo apt-get update
|
| 108 |
+
sudo apt install gcc-multilib libc6-dev-i386-cross
|
| 109 |
+
|
| 110 |
+
- name: Install packages (Windows)
|
| 111 |
+
if: runner.os == 'Windows'
|
| 112 |
+
run: |
|
| 113 |
+
choco install --no-progress ninja
|
| 114 |
+
|
| 115 |
+
- name: Generate project files (configure)
|
| 116 |
+
if: matrix.builder == 'configure'
|
| 117 |
+
run: |
|
| 118 |
+
./configure
|
| 119 |
+
env:
|
| 120 |
+
CC: ${{ matrix.compiler }}
|
| 121 |
+
CFLAGS: -std=${{ matrix.std.value }} ${{ matrix.arch.compiler-opt }} -Werror -Wall -Wextra
|
| 122 |
+
|
| 123 |
+
- name: Compile source code (configure)
|
| 124 |
+
if: matrix.builder == 'configure'
|
| 125 |
+
run: make -j2
|
| 126 |
+
|
| 127 |
+
- name: Run test cases (configure)
|
| 128 |
+
if: matrix.builder == 'configure'
|
| 129 |
+
run: |
|
| 130 |
+
make test
|
| 131 |
+
make cover
|
| 132 |
+
|
| 133 |
+
- name: Generate project files (cmake)
|
| 134 |
+
if: matrix.builder == 'cmake'
|
| 135 |
+
run: |
|
| 136 |
+
cmake -S . -B ./build1 -D CMAKE_BUILD_TYPE=Release ${{ matrix.os.cmake-opt }} -DZLIB_BUILD_TESTING=OFF
|
| 137 |
+
env:
|
| 138 |
+
CC: ${{ matrix.compiler }}
|
| 139 |
+
CFLAGS: -std=${{ matrix.std.value }} ${{ matrix.arch.compiler-opt }} -Werror -Wall -Wextra
|
| 140 |
+
|
| 141 |
+
- name: Generate project files with tests (cmake)
|
| 142 |
+
if: matrix.builder == 'cmake'
|
| 143 |
+
run: |
|
| 144 |
+
cmake -S . -B ./build2 -D CMAKE_BUILD_TYPE=Release ${{ matrix.os.cmake-opt }} -DZLIB_BUILD_MINIZIP=ON -DMINIZIP_ENABLE_BZIP2=OFF
|
| 145 |
+
env:
|
| 146 |
+
CC: ${{ matrix.compiler }}
|
| 147 |
+
CFLAGS: -std=${{ matrix.std.value }} ${{ matrix.arch.compiler-opt }} -Wall -Wextra
|
| 148 |
+
|
| 149 |
+
- name: Compile source code (cmake)
|
| 150 |
+
if: matrix.builder == 'cmake'
|
| 151 |
+
run: cmake --build ./build1 --config Release
|
| 152 |
+
|
| 153 |
+
- name: Compile source code with tests (cmake)
|
| 154 |
+
if: matrix.builder == 'cmake'
|
| 155 |
+
run: cmake --build ./build2 --config Release
|
| 156 |
+
|
| 157 |
+
- name: Run test cases (cmake)
|
| 158 |
+
if: matrix.builder == 'cmake'
|
| 159 |
+
run: ctest ./build2 -C Release --output-on-failure --max-width 120
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
msvc:
|
| 163 |
+
name: ${{ matrix.os.name }} ${{ matrix.compiler }} ${{ matrix.arch.name }} ${{ matrix.std.name }} ${{ matrix.builder }}
|
| 164 |
+
runs-on: ${{ matrix.os.value }}
|
| 165 |
+
strategy:
|
| 166 |
+
fail-fast: false
|
| 167 |
+
matrix:
|
| 168 |
+
os:
|
| 169 |
+
- name: Windows
|
| 170 |
+
value: windows-latest
|
| 171 |
+
|
| 172 |
+
compiler:
|
| 173 |
+
- cl
|
| 174 |
+
|
| 175 |
+
arch:
|
| 176 |
+
- name: 32-bit
|
| 177 |
+
value: -A Win32
|
| 178 |
+
|
| 179 |
+
- name: 64-bit
|
| 180 |
+
value: -A x64
|
| 181 |
+
|
| 182 |
+
builder:
|
| 183 |
+
- cmake
|
| 184 |
+
|
| 185 |
+
std:
|
| 186 |
+
- name: default
|
| 187 |
+
value: ""
|
| 188 |
+
|
| 189 |
+
- name: C11
|
| 190 |
+
value: /std:c11
|
| 191 |
+
|
| 192 |
+
- name: C17
|
| 193 |
+
value: /std:c17
|
| 194 |
+
|
| 195 |
+
# not available on the runner yet
|
| 196 |
+
# - name: C20
|
| 197 |
+
# value: /std:c20
|
| 198 |
+
|
| 199 |
+
- name: latest
|
| 200 |
+
value: /std:clatest
|
| 201 |
+
|
| 202 |
+
steps:
|
| 203 |
+
|
| 204 |
+
- name: Checkout repository
|
| 205 |
+
uses: actions/checkout@v4
|
| 206 |
+
with:
|
| 207 |
+
show-progress: 'false'
|
| 208 |
+
|
| 209 |
+
- name: Generate project files (cmake)
|
| 210 |
+
run: |
|
| 211 |
+
cmake -S . -B ./build1 ${{ matrix.arch.value }} -D CMAKE_BUILD_TYPE=Release -DZLIB_BUILD_TESTING=OFF
|
| 212 |
+
env:
|
| 213 |
+
CC: ${{ matrix.compiler }}
|
| 214 |
+
CFLAGS: /WX ${{ matrix.std.value }}
|
| 215 |
+
|
| 216 |
+
- name: Generate project files with tests (cmake)
|
| 217 |
+
run: |
|
| 218 |
+
cmake -S . -B ./build2 ${{ matrix.arch.value }} -D CMAKE_BUILD_TYPE=Release -DZLIB_BUILD_MINIZIP=ON -DMINIZIP_ENABLE_BZIP2=OFF
|
| 219 |
+
env:
|
| 220 |
+
CC: ${{ matrix.compiler }}
|
| 221 |
+
CFLAGS: ${{ matrix.std.value }}
|
| 222 |
+
|
| 223 |
+
- name: Compile source code (cmake)
|
| 224 |
+
run: cmake --build ./build1 --config Release -v
|
| 225 |
+
|
| 226 |
+
- name: Compile source code with tests(cmake)
|
| 227 |
+
run: cmake --build ./build2 --config Release -v
|
| 228 |
+
|
| 229 |
+
- name: Run test cases (cmake)
|
| 230 |
+
run: ctest ./build2 -C Release --output-on-failure --max-width 120
|
.github/workflows/cmake.yml
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: CMake
|
| 2 |
+
on: [push, pull_request]
|
| 3 |
+
jobs:
|
| 4 |
+
ci-cmake:
|
| 5 |
+
name: ${{ matrix.name }}
|
| 6 |
+
runs-on: ${{ matrix.os }}
|
| 7 |
+
strategy:
|
| 8 |
+
fail-fast: false
|
| 9 |
+
matrix:
|
| 10 |
+
include:
|
| 11 |
+
- name: Ubuntu GCC
|
| 12 |
+
os: ubuntu-latest
|
| 13 |
+
compiler: gcc
|
| 14 |
+
cflags: -Wall -Wextra
|
| 15 |
+
pkgtgt: package package_source
|
| 16 |
+
cmake-args: -DMINIZIP_ENABLE_BZIP2=ON
|
| 17 |
+
|
| 18 |
+
- name: Ubuntu GCC -O3
|
| 19 |
+
os: ubuntu-latest
|
| 20 |
+
compiler: gcc
|
| 21 |
+
cflags: -O3 -Wall -Wextra
|
| 22 |
+
pkgtgt: package package_source
|
| 23 |
+
cmake-args: -DMINIZIP_ENABLE_BZIP2=ON
|
| 24 |
+
|
| 25 |
+
- name: Ubuntu Clang
|
| 26 |
+
os: ubuntu-latest
|
| 27 |
+
compiler: clang
|
| 28 |
+
cflags: -Wall -Wextra
|
| 29 |
+
pkgtgt: package package_source
|
| 30 |
+
cmake-args: -DMINIZIP_ENABLE_BZIP2=ON
|
| 31 |
+
|
| 32 |
+
- name: Ubuntu Clang Debug
|
| 33 |
+
os: ubuntu-latest
|
| 34 |
+
compiler: clang
|
| 35 |
+
cflags: -Wall -Wextra
|
| 36 |
+
build-config: Debug
|
| 37 |
+
pkgtgt: package package_source
|
| 38 |
+
cmake-args: -DMINIZIP_ENABLE_BZIP2=ON
|
| 39 |
+
|
| 40 |
+
- name: Windows MSVC Win32
|
| 41 |
+
os: windows-latest
|
| 42 |
+
compiler: cl
|
| 43 |
+
cflags: /W3
|
| 44 |
+
cmake-args: -A Win32
|
| 45 |
+
pkgtgt: PACKAGE
|
| 46 |
+
|
| 47 |
+
- name: Windows MSVC Win64
|
| 48 |
+
os: windows-latest
|
| 49 |
+
compiler: cl
|
| 50 |
+
cflags: /W3
|
| 51 |
+
cmake-args: -A x64 -DMINIZIP_ENABLE_BZIP2=OFF
|
| 52 |
+
pkgtgt: PACKAGE
|
| 53 |
+
|
| 54 |
+
- name: Windows GCC
|
| 55 |
+
os: windows-latest
|
| 56 |
+
compiler: gcc
|
| 57 |
+
cflags: -Wall -Wextra
|
| 58 |
+
cmake-args: -G Ninja -DMINIZIP_ENABLE_BZIP2=OFF
|
| 59 |
+
pkgtgt: package
|
| 60 |
+
|
| 61 |
+
- name: macOS Clang
|
| 62 |
+
os: macos-latest
|
| 63 |
+
compiler: clang
|
| 64 |
+
cflags: -Wall -Wextra
|
| 65 |
+
pkgtgt: package
|
| 66 |
+
cmake-args: -DMINIZIP_ENABLE_BZIP2=ON
|
| 67 |
+
|
| 68 |
+
- name: macOS GCC
|
| 69 |
+
os: macos-latest
|
| 70 |
+
compiler: gcc-12
|
| 71 |
+
cflags: -Wall -Wextra
|
| 72 |
+
pkgtgt: package
|
| 73 |
+
cmake-args: -DMINIZIP_ENABLE_BZIP2=ON
|
| 74 |
+
|
| 75 |
+
steps:
|
| 76 |
+
- name: Checkout repository
|
| 77 |
+
uses: actions/checkout@v4
|
| 78 |
+
|
| 79 |
+
- name: Install packages (Windows)
|
| 80 |
+
if: runner.os == 'Windows'
|
| 81 |
+
run: |
|
| 82 |
+
choco install --no-progress ninja
|
| 83 |
+
|
| 84 |
+
- name: Install packages (Linux)
|
| 85 |
+
if: runner.os == 'Linux'
|
| 86 |
+
run: |
|
| 87 |
+
sudo apt install libbz2-dev
|
| 88 |
+
- name: Generate project files
|
| 89 |
+
run: cmake -S . -B ../build ${{ matrix.cmake-args }} -D CMAKE_BUILD_TYPE=${{ matrix.build-config || 'Release' }} -DZLIB_BUILD_MINIZIP=ON
|
| 90 |
+
env:
|
| 91 |
+
CC: ${{ matrix.compiler }}
|
| 92 |
+
CFLAGS: ${{ matrix.cflags }}
|
| 93 |
+
|
| 94 |
+
- name: Compile source code
|
| 95 |
+
run: cmake --build ../build --config ${{ matrix.build-config || 'Release' }}
|
| 96 |
+
|
| 97 |
+
- name: Run test cases
|
| 98 |
+
run: ctest -C Release --output-on-failure --max-width 120
|
| 99 |
+
working-directory: ../build
|
| 100 |
+
|
| 101 |
+
- name: create packages
|
| 102 |
+
run: cmake --build ../build --config ${{ matrix.build-config || 'Release' }} -t ${{ matrix.pkgtgt }}
|
| 103 |
+
|
| 104 |
+
- name: Upload build errors
|
| 105 |
+
uses: actions/upload-artifact@v4
|
| 106 |
+
if: failure()
|
| 107 |
+
with:
|
| 108 |
+
name: ${{ matrix.name }} (cmake)
|
| 109 |
+
path: |
|
| 110 |
+
../build/CMakeFiles/CMakeOutput.log
|
| 111 |
+
../build/CMakeFiles/CMakeError.log
|
| 112 |
+
retention-days: 7
|
.github/workflows/configure.yml
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Configure
|
| 2 |
+
on: [push, pull_request]
|
| 3 |
+
jobs:
|
| 4 |
+
ci-configure:
|
| 5 |
+
name: ${{ matrix.name }}
|
| 6 |
+
runs-on: ${{ matrix.os }}
|
| 7 |
+
strategy:
|
| 8 |
+
fail-fast: false
|
| 9 |
+
matrix:
|
| 10 |
+
include:
|
| 11 |
+
- name: Ubuntu GCC
|
| 12 |
+
os: ubuntu-latest
|
| 13 |
+
compiler: gcc
|
| 14 |
+
configure-args: --warn
|
| 15 |
+
|
| 16 |
+
# Test out of source builds
|
| 17 |
+
- name: Ubuntu GCC OSB
|
| 18 |
+
os: ubuntu-latest
|
| 19 |
+
compiler: gcc
|
| 20 |
+
configure-args: --warn
|
| 21 |
+
build-dir: ../build
|
| 22 |
+
src-dir: ../zlib
|
| 23 |
+
|
| 24 |
+
- name: Ubuntu GCC ARM SF
|
| 25 |
+
os: ubuntu-latest
|
| 26 |
+
compiler: arm-linux-gnueabi-gcc
|
| 27 |
+
configure-args: --warn
|
| 28 |
+
chost: arm-linux-gnueabi
|
| 29 |
+
packages: qemu-system qemu-user gcc-arm-linux-gnueabi libc-dev-armel-cross
|
| 30 |
+
qemu-run: qemu-arm -L /usr/arm-linux-gnueabi
|
| 31 |
+
|
| 32 |
+
- name: Ubuntu GCC ARM HF
|
| 33 |
+
os: ubuntu-latest
|
| 34 |
+
compiler: arm-linux-gnueabihf-gcc
|
| 35 |
+
configure-args: --warn
|
| 36 |
+
chost: arm-linux-gnueabihf
|
| 37 |
+
packages: qemu-system qemu-user gcc-arm-linux-gnueabihf libc-dev-armhf-cross
|
| 38 |
+
qemu-run: qemu-arm -L /usr/arm-linux-gnueabihf
|
| 39 |
+
|
| 40 |
+
- name: Ubuntu GCC AARCH64
|
| 41 |
+
os: ubuntu-latest
|
| 42 |
+
compiler: aarch64-linux-gnu-gcc
|
| 43 |
+
configure-args: --warn
|
| 44 |
+
chost: aarch64-linux-gnu
|
| 45 |
+
packages: qemu-system qemu-user gcc-aarch64-linux-gnu libc-dev-arm64-cross
|
| 46 |
+
qemu-run: qemu-aarch64 -L /usr/aarch64-linux-gnu
|
| 47 |
+
|
| 48 |
+
- name: Ubuntu GCC PPC
|
| 49 |
+
os: ubuntu-latest
|
| 50 |
+
compiler: powerpc-linux-gnu-gcc
|
| 51 |
+
configure-args: --warn --static
|
| 52 |
+
chost: powerpc-linux-gnu
|
| 53 |
+
packages: qemu-system qemu-user gcc-powerpc-linux-gnu libc-dev-powerpc-cross
|
| 54 |
+
qemu-run: qemu-ppc -L /usr/powerpc-linux-gnu
|
| 55 |
+
cflags: -static
|
| 56 |
+
ldflags: -static
|
| 57 |
+
|
| 58 |
+
- name: Ubuntu GCC PPC64
|
| 59 |
+
os: ubuntu-latest
|
| 60 |
+
compiler: powerpc64-linux-gnu-gcc
|
| 61 |
+
configure-args: --warn --static
|
| 62 |
+
chost: powerpc-linux-gnu
|
| 63 |
+
packages: qemu-system qemu-user gcc-powerpc64-linux-gnu libc-dev-ppc64-cross
|
| 64 |
+
qemu-run: qemu-ppc64 -L /usr/powerpc64-linux-gnu
|
| 65 |
+
cflags: -static
|
| 66 |
+
ldflags: -static
|
| 67 |
+
|
| 68 |
+
- name: Ubuntu GCC PPC64LE
|
| 69 |
+
os: ubuntu-latest
|
| 70 |
+
compiler: powerpc64le-linux-gnu-gcc
|
| 71 |
+
configure-args: --warn
|
| 72 |
+
chost: powerpc64le-linux-gnu
|
| 73 |
+
packages: qemu-system qemu-user gcc-powerpc64le-linux-gnu libc-dev-ppc64el-cross
|
| 74 |
+
qemu-run: qemu-ppc64le -L /usr/powerpc64le-linux-gnu
|
| 75 |
+
|
| 76 |
+
- name: Ubuntu GCC S390X
|
| 77 |
+
os: ubuntu-latest
|
| 78 |
+
compiler: s390x-linux-gnu-gcc
|
| 79 |
+
configure-args: --warn --static
|
| 80 |
+
chost: s390x-linux-gnu
|
| 81 |
+
packages: qemu-system qemu-user gcc-s390x-linux-gnu libc-dev-s390x-cross
|
| 82 |
+
qemu-run: qemu-s390x -L /usr/s390x-linux-gnu
|
| 83 |
+
cflags: -static
|
| 84 |
+
ldflags: -static
|
| 85 |
+
|
| 86 |
+
- name: macOS GCC
|
| 87 |
+
os: macos-latest
|
| 88 |
+
compiler: gcc-12
|
| 89 |
+
configure-args: --warn
|
| 90 |
+
|
| 91 |
+
- name: macOS Clang
|
| 92 |
+
os: macos-latest
|
| 93 |
+
compiler: clang
|
| 94 |
+
configure-args: --warn
|
| 95 |
+
|
| 96 |
+
steps:
|
| 97 |
+
- name: Checkout repository
|
| 98 |
+
uses: actions/checkout@v4
|
| 99 |
+
|
| 100 |
+
- name: Install packages (Ubuntu)
|
| 101 |
+
if: runner.os == 'Linux' && matrix.packages
|
| 102 |
+
run: |
|
| 103 |
+
sudo apt-get update
|
| 104 |
+
sudo apt-get install -y ${{ matrix.packages }}
|
| 105 |
+
|
| 106 |
+
- name: Generate project files
|
| 107 |
+
run: |
|
| 108 |
+
[ -d ${{ matrix.build-dir || '.' }} ] || mkdir ${{ matrix.build-dir || '.' }}
|
| 109 |
+
cd ${{ matrix.build-dir || '.' }}
|
| 110 |
+
${{ matrix.src-dir || '.' }}/configure ${{ matrix.configure-args }}
|
| 111 |
+
env:
|
| 112 |
+
CC: ${{ matrix.compiler }}
|
| 113 |
+
CFLAGS: ${{ matrix.cflags }}
|
| 114 |
+
LDFLAGS: ${{ matrix.ldflags }}
|
| 115 |
+
CHOST: ${{ matrix.chost }}
|
| 116 |
+
|
| 117 |
+
- name: Compile source code
|
| 118 |
+
run: make -j2
|
| 119 |
+
working-directory: ${{ matrix.build-dir }}
|
| 120 |
+
|
| 121 |
+
- name: Run test cases
|
| 122 |
+
run: |
|
| 123 |
+
make test
|
| 124 |
+
make cover
|
| 125 |
+
working-directory: ${{ matrix.build-dir }}
|
| 126 |
+
env:
|
| 127 |
+
QEMU_RUN: ${{ matrix.qemu-run }}
|
| 128 |
+
|
| 129 |
+
- name: Upload build errors
|
| 130 |
+
uses: actions/upload-artifact@v4
|
| 131 |
+
if: failure()
|
| 132 |
+
with:
|
| 133 |
+
name: ${{ matrix.name }} (configure)
|
| 134 |
+
path: |
|
| 135 |
+
${{ matrix.build-dir || '.' }}/configure.log
|
| 136 |
+
retention-days: 7
|
.github/workflows/fuzz.yml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: OSS-Fuzz
|
| 2 |
+
on: [pull_request]
|
| 3 |
+
jobs:
|
| 4 |
+
Fuzzing:
|
| 5 |
+
runs-on: ubuntu-latest
|
| 6 |
+
steps:
|
| 7 |
+
- name: Build Fuzzers
|
| 8 |
+
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
|
| 9 |
+
with:
|
| 10 |
+
oss-fuzz-project-name: 'zlib'
|
| 11 |
+
dry-run: false
|
| 12 |
+
|
| 13 |
+
- name: Run Fuzzers
|
| 14 |
+
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
|
| 15 |
+
with:
|
| 16 |
+
oss-fuzz-project-name: 'zlib'
|
| 17 |
+
fuzz-seconds: 300
|
| 18 |
+
dry-run: false
|
| 19 |
+
|
| 20 |
+
- name: Upload Crash
|
| 21 |
+
uses: actions/upload-artifact@v4
|
| 22 |
+
if: failure()
|
| 23 |
+
with:
|
| 24 |
+
name: artifacts
|
| 25 |
+
path: ./out/artifacts
|
.github/workflows/msys-cygwin.yml
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: mingw/cygwin
|
| 2 |
+
|
| 3 |
+
on: [push, pull_request]
|
| 4 |
+
|
| 5 |
+
jobs:
|
| 6 |
+
MSys:
|
| 7 |
+
runs-on: windows-latest
|
| 8 |
+
strategy:
|
| 9 |
+
fail-fast: false
|
| 10 |
+
matrix:
|
| 11 |
+
sys: [mingw32, mingw64, ucrt64, clang64]
|
| 12 |
+
name: MSys - ${{ matrix.sys }}
|
| 13 |
+
defaults:
|
| 14 |
+
run:
|
| 15 |
+
shell: msys2 {0}
|
| 16 |
+
steps:
|
| 17 |
+
- name: Checkout
|
| 18 |
+
uses: actions/checkout@v4
|
| 19 |
+
with:
|
| 20 |
+
fetch-depth: 0
|
| 21 |
+
- name: Setup MSYS2
|
| 22 |
+
uses: msys2/setup-msys2@v2
|
| 23 |
+
with:
|
| 24 |
+
msystem: ${{ matrix.sys }}
|
| 25 |
+
update: true
|
| 26 |
+
install: >-
|
| 27 |
+
make
|
| 28 |
+
pacboy: >-
|
| 29 |
+
toolchain:p
|
| 30 |
+
cmake:p
|
| 31 |
+
- name: Configure
|
| 32 |
+
run: |
|
| 33 |
+
cmake -G"Unix Makefiles" \
|
| 34 |
+
-S . \
|
| 35 |
+
-B build \
|
| 36 |
+
-DCMAKE_VERBOSE_MAKEFILE=ON \
|
| 37 |
+
-DCMAKE_BUILD_TYPE=Release \
|
| 38 |
+
-DMINIZIP_ENABLE_BZIP2=ON
|
| 39 |
+
- name: Build
|
| 40 |
+
run: cmake --build build --config Release
|
| 41 |
+
- name: Run tests
|
| 42 |
+
run: ctest --output-on-failure --test-dir build -C Release
|
| 43 |
+
|
| 44 |
+
cygwin:
|
| 45 |
+
strategy:
|
| 46 |
+
fail-fast: false
|
| 47 |
+
runs-on: windows-latest
|
| 48 |
+
defaults:
|
| 49 |
+
run:
|
| 50 |
+
shell: C:\cygwin\bin\bash.exe --login -o igncr '{0}'
|
| 51 |
+
name: Cygwin
|
| 52 |
+
steps:
|
| 53 |
+
- name: Checkout
|
| 54 |
+
uses: actions/checkout@v4
|
| 55 |
+
with:
|
| 56 |
+
fetch-depth: 0
|
| 57 |
+
- name: Setup cygwin
|
| 58 |
+
uses: cygwin/cygwin-install-action@master
|
| 59 |
+
with:
|
| 60 |
+
packages: >-
|
| 61 |
+
cmake
|
| 62 |
+
cygwin-devel
|
| 63 |
+
gcc-core
|
| 64 |
+
gcc-g++
|
| 65 |
+
ninja
|
| 66 |
+
- name: Configure
|
| 67 |
+
run: |
|
| 68 |
+
cmake /cygdrive/d/a/zlib/zlib \
|
| 69 |
+
-B build \
|
| 70 |
+
-DCMAKE_BUILD_TYPE=Release \
|
| 71 |
+
-DZLIB_BUILD_MINIZIP=ON \
|
| 72 |
+
-DMINIZIP_ENABLE_BZIP2=OFF \
|
| 73 |
+
-G Ninja
|
| 74 |
+
- name: Build
|
| 75 |
+
run: cmake --build build --config Release -v -j1
|
| 76 |
+
- name: Run tests
|
| 77 |
+
run: ctest --output-on-failure --test-dir build -C Release
|
.gitignore
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.diff
|
| 2 |
+
*.patch
|
| 3 |
+
*.orig
|
| 4 |
+
*.rej
|
| 5 |
+
|
| 6 |
+
*~
|
| 7 |
+
*.a
|
| 8 |
+
*.lo
|
| 9 |
+
*.o
|
| 10 |
+
*.dylib
|
| 11 |
+
|
| 12 |
+
*.gcda
|
| 13 |
+
*.gcno
|
| 14 |
+
*.gcov
|
| 15 |
+
|
| 16 |
+
/zconf.h
|
| 17 |
+
/Makefile
|
| 18 |
+
/example
|
| 19 |
+
/example64
|
| 20 |
+
/examplesh
|
| 21 |
+
**/libz.so*
|
| 22 |
+
/minigzip
|
| 23 |
+
/minigzip64
|
| 24 |
+
/minigzipsh
|
| 25 |
+
/zlib.pc
|
| 26 |
+
/configure.log
|
| 27 |
+
/build
|
| 28 |
+
|
| 29 |
+
.DS_Store
|
| 30 |
+
.vs
|
| 31 |
+
*.user
|
| 32 |
+
*.nupkg
|
| 33 |
+
contrib/vstudio/vc143/x86
|
| 34 |
+
contrib/vstudio/vc143/x64
|
| 35 |
+
contrib/vstudio/vc143/arm
|
| 36 |
+
contrib/vstudio/vc143/arm64
|
| 37 |
+
contrib/nuget/bin
|
| 38 |
+
contrib/nuget/obj
|
| 39 |
+
*.included
|
| 40 |
+
|
| 41 |
+
# Bazel directories
|
| 42 |
+
/bazel-*
|
| 43 |
+
/bazel-bin
|
| 44 |
+
/bazel-genfiles
|
| 45 |
+
/bazel-out
|
| 46 |
+
/bazel-testlogs
|
| 47 |
+
user.bazelrc
|
| 48 |
+
|
| 49 |
+
# MODULE.bazel.lock is ignored for now as per this recommendation:
|
| 50 |
+
# https://github.com/bazelbuild/bazel/issues/20369
|
| 51 |
+
MODULE.bazel.lock
|
BUILD.bazel
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copied from https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/zlib/1.3.1.bcr.4/patches
|
| 2 |
+
# Adapted from https://github.com/protocolbuffers/protobuf/blob/master/third_party/zlib.BUILD
|
| 3 |
+
|
| 4 |
+
# Copyright 2008 Google Inc. All rights reserved.
|
| 5 |
+
#
|
| 6 |
+
# Redistribution and use in source and binary forms, with or without
|
| 7 |
+
# modification, are permitted provided that the following conditions are
|
| 8 |
+
# met:
|
| 9 |
+
#
|
| 10 |
+
# * Redistributions of source code must retain the above copyright
|
| 11 |
+
# notice, this list of conditions and the following disclaimer.
|
| 12 |
+
# * Redistributions in binary form must reproduce the above
|
| 13 |
+
# copyright notice, this list of conditions and the following disclaimer
|
| 14 |
+
# in the documentation and/or other materials provided with the
|
| 15 |
+
# distribution.
|
| 16 |
+
# * Neither the name of Google Inc. nor the names of its
|
| 17 |
+
# contributors may be used to endorse or promote products derived from
|
| 18 |
+
# this software without specific prior written permission.
|
| 19 |
+
#
|
| 20 |
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 21 |
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 22 |
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 23 |
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 24 |
+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 25 |
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 26 |
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 27 |
+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 28 |
+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 29 |
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 30 |
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 31 |
+
#
|
| 32 |
+
# Code generated by the Protocol Buffer compiler is owned by the owner
|
| 33 |
+
# of the input file used when generating it. This code is not
|
| 34 |
+
# standalone and requires a support library to be linked with it. This
|
| 35 |
+
# support library is itself covered by the above license.
|
| 36 |
+
|
| 37 |
+
load("@rules_cc//cc:defs.bzl", "cc_library")
|
| 38 |
+
load("@rules_license//rules:license.bzl", "license")
|
| 39 |
+
|
| 40 |
+
package(
|
| 41 |
+
default_applicable_licenses = [":license"],
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
license(
|
| 45 |
+
name = "license",
|
| 46 |
+
license_kinds = ["@rules_license//licenses/spdx:Zlib"],
|
| 47 |
+
license_text = "LICENSE",
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
exports_files([
|
| 51 |
+
"LICENSE",
|
| 52 |
+
])
|
| 53 |
+
|
| 54 |
+
_ZLIB_HEADERS = [
|
| 55 |
+
"crc32.h",
|
| 56 |
+
"deflate.h",
|
| 57 |
+
"gzguts.h",
|
| 58 |
+
"inffast.h",
|
| 59 |
+
"inffixed.h",
|
| 60 |
+
"inflate.h",
|
| 61 |
+
"inftrees.h",
|
| 62 |
+
"trees.h",
|
| 63 |
+
"zconf.h",
|
| 64 |
+
"zlib.h",
|
| 65 |
+
"zutil.h",
|
| 66 |
+
]
|
| 67 |
+
|
| 68 |
+
_ZLIB_PREFIXED_HEADERS = ["zlib/include/" + hdr for hdr in _ZLIB_HEADERS]
|
| 69 |
+
|
| 70 |
+
# In order to limit the damage from the `includes` propagation
|
| 71 |
+
# via `:zlib`, copy the public headers to a subdirectory and
|
| 72 |
+
# expose those.
|
| 73 |
+
genrule(
|
| 74 |
+
name = "copy_public_headers",
|
| 75 |
+
srcs = _ZLIB_HEADERS,
|
| 76 |
+
outs = _ZLIB_PREFIXED_HEADERS,
|
| 77 |
+
cmd_bash = "cp $(SRCS) $(@D)/zlib/include/",
|
| 78 |
+
cmd_bat = " && ".join(
|
| 79 |
+
["@copy /Y \"$(location %s)\" \"$(@D)\\zlib\\include\\\" >NUL" %
|
| 80 |
+
s for s in _ZLIB_HEADERS],
|
| 81 |
+
),
|
| 82 |
+
)
|
| 83 |
+
|
| 84 |
+
config_setting(
|
| 85 |
+
name = "mingw_gcc_compiler",
|
| 86 |
+
flag_values = {
|
| 87 |
+
"@bazel_tools//tools/cpp:compiler": "mingw-gcc",
|
| 88 |
+
},
|
| 89 |
+
visibility = [":__subpackages__"],
|
| 90 |
+
)
|
| 91 |
+
|
| 92 |
+
cc_library(
|
| 93 |
+
name = "z",
|
| 94 |
+
srcs = [
|
| 95 |
+
"adler32.c",
|
| 96 |
+
"compress.c",
|
| 97 |
+
"crc32.c",
|
| 98 |
+
"deflate.c",
|
| 99 |
+
"gzclose.c",
|
| 100 |
+
"gzlib.c",
|
| 101 |
+
"gzread.c",
|
| 102 |
+
"gzwrite.c",
|
| 103 |
+
"infback.c",
|
| 104 |
+
"inffast.c",
|
| 105 |
+
"inflate.c",
|
| 106 |
+
"inftrees.c",
|
| 107 |
+
"trees.c",
|
| 108 |
+
"uncompr.c",
|
| 109 |
+
"zutil.c",
|
| 110 |
+
# Include the un-prefixed headers in srcs to work
|
| 111 |
+
# around the fact that zlib isn't consistent in its
|
| 112 |
+
# choice of <> or "" delimiter when including itself.
|
| 113 |
+
] + _ZLIB_HEADERS,
|
| 114 |
+
hdrs = _ZLIB_PREFIXED_HEADERS,
|
| 115 |
+
copts = select({
|
| 116 |
+
":mingw_gcc_compiler": [
|
| 117 |
+
"-fpermissive",
|
| 118 |
+
],
|
| 119 |
+
"@platforms//os:windows": [],
|
| 120 |
+
"//conditions:default": [
|
| 121 |
+
"-Wno-deprecated-non-prototype",
|
| 122 |
+
"-Wno-unused-variable",
|
| 123 |
+
"-Wno-implicit-function-declaration",
|
| 124 |
+
],
|
| 125 |
+
}),
|
| 126 |
+
includes = ["zlib/include/"],
|
| 127 |
+
visibility = ["//visibility:public"],
|
| 128 |
+
)
|
| 129 |
+
|
| 130 |
+
alias(
|
| 131 |
+
name = "zlib",
|
| 132 |
+
actual = ":z",
|
| 133 |
+
visibility = ["//visibility:public"],
|
| 134 |
+
)
|
CMakeLists.txt
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cmake_minimum_required(VERSION 3.12...3.31)
|
| 2 |
+
|
| 3 |
+
project(
|
| 4 |
+
zlib
|
| 5 |
+
LANGUAGES C
|
| 6 |
+
VERSION 1.4.1.1
|
| 7 |
+
HOMEPAGE_URL "https://zlib.net/"
|
| 8 |
+
DESCRIPTION "a general-purpose lossless data-compression library")
|
| 9 |
+
|
| 10 |
+
# ============================================================================
|
| 11 |
+
# CPack
|
| 12 |
+
# ============================================================================
|
| 13 |
+
set(CPACK_PACKAGE_VENDOR "zlib-Project")
|
| 14 |
+
set(CPACK_PACKAGE_DESCRIPTION_FILE ${zlib_SOURCE_DIR}/README)
|
| 15 |
+
set(CPACK_RESOURCE_FILE_LICENSE ${zlib_SOURCE_DIR}/LICENSE)
|
| 16 |
+
set(CPACK_RESOURCE_FILE_README ${zlib_SOURCE_DIR}/README)
|
| 17 |
+
|
| 18 |
+
# ============================================================================
|
| 19 |
+
# configuration
|
| 20 |
+
# ============================================================================
|
| 21 |
+
|
| 22 |
+
option(ZLIB_BUILD_TESTING "Enable Zlib Examples as tests" ON)
|
| 23 |
+
option(ZLIB_BUILD_SHARED "Enable building zlib shared library" ON)
|
| 24 |
+
option(ZLIB_BUILD_STATIC "Enable building zlib static library" ON)
|
| 25 |
+
option(ZLIB_BUILD_MINIZIP "Enable building libminizip contrib library" OFF)
|
| 26 |
+
option(ZLIB_INSTALL "Enable installation of zlib" ON)
|
| 27 |
+
option(ZLIB_PREFIX "prefix for all types and library functions, see zconf.h.in"
|
| 28 |
+
OFF)
|
| 29 |
+
mark_as_advanced(ZLIB_PREFIX)
|
| 30 |
+
|
| 31 |
+
if(WIN32)
|
| 32 |
+
option(ZLIB_INSTALL_COMPAT_DLL "Install a copy as zlib1.dll" ON)
|
| 33 |
+
endif(WIN32)
|
| 34 |
+
|
| 35 |
+
get_property(IS_MULTI GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
| 36 |
+
|
| 37 |
+
if(NOT DEFINED CMAKE_BUILD_TYPE AND NOT IS_MULTI)
|
| 38 |
+
message(STATUS "No CMAKE_BUILD_TYPE set -- using Release")
|
| 39 |
+
set(CMAKE_BUILD_TYPE Release)
|
| 40 |
+
endif(NOT DEFINED CMAKE_BUILD_TYPE AND NOT IS_MULTI)
|
| 41 |
+
|
| 42 |
+
include(CheckCSourceCompiles)
|
| 43 |
+
include(CheckFunctionExists)
|
| 44 |
+
include(CheckIncludeFile)
|
| 45 |
+
include(CMakePackageConfigHelpers)
|
| 46 |
+
include(CheckTypeSize)
|
| 47 |
+
include(CPack)
|
| 48 |
+
include(GNUInstallDirs)
|
| 49 |
+
|
| 50 |
+
set(CPACK_INCLUDED TRUE)
|
| 51 |
+
|
| 52 |
+
if(NOT ZLIB_CONF_WRITTEN)
|
| 53 |
+
set(Z_PREFIX ${ZLIB_PREFIX})
|
| 54 |
+
set(CONF_OUT_FILE ${zlib_BINARY_DIR}/zconf.h.cmakein)
|
| 55 |
+
file(READ ${zlib_SOURCE_DIR}/zconf.h ZCONF_CONTENT LIMIT 245)
|
| 56 |
+
file(WRITE ${CONF_OUT_FILE} ${ZCONF_CONTENT})
|
| 57 |
+
file(APPEND ${CONF_OUT_FILE} "#cmakedefine Z_PREFIX 1\n")
|
| 58 |
+
file(APPEND ${CONF_OUT_FILE} "#cmakedefine HAVE_STDARG_H 1\n")
|
| 59 |
+
file(APPEND ${CONF_OUT_FILE} "#cmakedefine HAVE_UNISTD_H 1\n")
|
| 60 |
+
file(READ ${zlib_SOURCE_DIR}/zconf.h ZCONF_CONTENT OFFSET 244)
|
| 61 |
+
set(FIRST_ITEM TRUE)
|
| 62 |
+
|
| 63 |
+
foreach(item IN LISTS ZCONF_CONTENT)
|
| 64 |
+
if(FIRST_ITEM)
|
| 65 |
+
string(APPEND OUT_CONTENT ${item})
|
| 66 |
+
set(FIRST_ITEM FALSE)
|
| 67 |
+
else(FIRST_ITEM)
|
| 68 |
+
string(APPEND OUT_CONTENT "\;" ${item})
|
| 69 |
+
endif(FIRST_ITEM)
|
| 70 |
+
endforeach(item IN LISTS ${ZCONF_CONTENT})
|
| 71 |
+
|
| 72 |
+
file(APPEND ${CONF_OUT_FILE} ${OUT_CONTENT})
|
| 73 |
+
set(ZLIB_CONF_WRITTEN
|
| 74 |
+
TRUE
|
| 75 |
+
CACHE BOOL "zconf.h.cmakein was created")
|
| 76 |
+
mark_as_advanced(ZLIB_CONF_WRITTEN)
|
| 77 |
+
endif(NOT ZLIB_CONF_WRITTEN)
|
| 78 |
+
|
| 79 |
+
#
|
| 80 |
+
# Check to see if we have large file support
|
| 81 |
+
#
|
| 82 |
+
set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
|
| 83 |
+
check_type_size(off64_t OFF64_T)
|
| 84 |
+
unset(CMAKE_REQUIRED_DEFINITIONS) # clear variable
|
| 85 |
+
|
| 86 |
+
#
|
| 87 |
+
# Check for fseeko
|
| 88 |
+
#
|
| 89 |
+
check_function_exists(fseeko HAVE_FSEEKO)
|
| 90 |
+
|
| 91 |
+
#
|
| 92 |
+
# Check for stdarg.h
|
| 93 |
+
#
|
| 94 |
+
check_include_file(stdarg.h HAVE_STDARG_H)
|
| 95 |
+
|
| 96 |
+
#
|
| 97 |
+
# Check for unistd.h
|
| 98 |
+
#
|
| 99 |
+
check_include_file(unistd.h HAVE_UNISTD_H)
|
| 100 |
+
|
| 101 |
+
#
|
| 102 |
+
# Check visibility attribute is supported
|
| 103 |
+
#
|
| 104 |
+
if(MSVC)
|
| 105 |
+
set(CMAKE_REQUIRED_FLAGS "-WX")
|
| 106 |
+
else(MSVC)
|
| 107 |
+
set(CMAKE_REQUIRED_FLAGS "-WError")
|
| 108 |
+
endif(MSVC)
|
| 109 |
+
|
| 110 |
+
check_c_source_compiles(
|
| 111 |
+
"
|
| 112 |
+
#include <stdlib.h>
|
| 113 |
+
static void f(void) __attribute__ ((visibility(\"hidden\")));
|
| 114 |
+
int main(void) {return 0;}
|
| 115 |
+
"
|
| 116 |
+
HAVE___ATTR__VIS_HIDDEN)
|
| 117 |
+
|
| 118 |
+
unset(CMAKE_COMPILE_FLAGS)
|
| 119 |
+
set(ZLIB_PC ${zlib_BINARY_DIR}/zlib.pc)
|
| 120 |
+
configure_file(${zlib_SOURCE_DIR}/zlib.pc.cmakein ${ZLIB_PC} @ONLY)
|
| 121 |
+
configure_file(${zlib_BINARY_DIR}/zconf.h.cmakein ${zlib_BINARY_DIR}/zconf.h)
|
| 122 |
+
|
| 123 |
+
# ============================================================================
|
| 124 |
+
# zlib
|
| 125 |
+
# ============================================================================
|
| 126 |
+
|
| 127 |
+
set(ZLIB_PUBLIC_HDRS ${zlib_BINARY_DIR}/zconf.h zlib.h)
|
| 128 |
+
|
| 129 |
+
set(ZLIB_PRIVATE_HDRS
|
| 130 |
+
crc32.h
|
| 131 |
+
deflate.h
|
| 132 |
+
gzguts.h
|
| 133 |
+
inffast.h
|
| 134 |
+
inffixed.h
|
| 135 |
+
inflate.h
|
| 136 |
+
inftrees.h
|
| 137 |
+
trees.h
|
| 138 |
+
zutil.h)
|
| 139 |
+
|
| 140 |
+
set(ZLIB_SRCS
|
| 141 |
+
adler32.c
|
| 142 |
+
compress.c
|
| 143 |
+
crc32.c
|
| 144 |
+
deflate.c
|
| 145 |
+
gzclose.c
|
| 146 |
+
gzlib.c
|
| 147 |
+
gzread.c
|
| 148 |
+
gzwrite.c
|
| 149 |
+
inflate.c
|
| 150 |
+
infback.c
|
| 151 |
+
inftrees.c
|
| 152 |
+
inffast.c
|
| 153 |
+
trees.c
|
| 154 |
+
uncompr.c
|
| 155 |
+
zutil.c)
|
| 156 |
+
|
| 157 |
+
if(WIN32)
|
| 158 |
+
set(zlib_static_suffix "s")
|
| 159 |
+
set(CMAKE_DEBUG_POSTFIX "d")
|
| 160 |
+
endif(WIN32)
|
| 161 |
+
|
| 162 |
+
if(ZLIB_BUILD_SHARED)
|
| 163 |
+
add_library(
|
| 164 |
+
zlib SHARED ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}
|
| 165 |
+
$<$<OR:$<BOOL:${WIN32}>,$<BOOL:${CYGWIN}>>:win32/zlib1.rc>)
|
| 166 |
+
add_library(ZLIB::ZLIB ALIAS zlib)
|
| 167 |
+
target_include_directories(
|
| 168 |
+
zlib
|
| 169 |
+
PUBLIC $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
|
| 170 |
+
$<BUILD_INTERFACE:${zlib_SOURCE_DIR}>
|
| 171 |
+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
| 172 |
+
target_compile_definitions(
|
| 173 |
+
zlib
|
| 174 |
+
PRIVATE ZLIB_BUILD
|
| 175 |
+
$<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
|
| 176 |
+
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
|
| 177 |
+
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
|
| 178 |
+
$<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
|
| 179 |
+
PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
|
| 180 |
+
set(INSTALL_VERSION ${zlib_VERSION})
|
| 181 |
+
|
| 182 |
+
if(NOT CYGWIN)
|
| 183 |
+
set_target_properties(zlib PROPERTIES SOVERSION ${zlib_VERSION_MAJOR}
|
| 184 |
+
VERSION ${INSTALL_VERSION})
|
| 185 |
+
endif(NOT CYGWIN)
|
| 186 |
+
|
| 187 |
+
set_target_properties(
|
| 188 |
+
zlib
|
| 189 |
+
PROPERTIES DEFINE_SYMBOL ZLIB_DLL
|
| 190 |
+
EXPORT_NAME ZLIB
|
| 191 |
+
OUTPUT_NAME z)
|
| 192 |
+
if(UNIX
|
| 193 |
+
AND NOT APPLE
|
| 194 |
+
AND NOT (CMAKE_SYSTEM_NAME STREQUAL AIX))
|
| 195 |
+
# On unix-like platforms the library is almost always called libz
|
| 196 |
+
set_target_properties(
|
| 197 |
+
zlib
|
| 198 |
+
PROPERTIES LINK_FLAGS
|
| 199 |
+
"-Wl,--version-script,\"${zlib_SOURCE_DIR}/zlib.map\"")
|
| 200 |
+
endif(
|
| 201 |
+
UNIX
|
| 202 |
+
AND NOT APPLE
|
| 203 |
+
AND NOT (CMAKE_SYSTEM_NAME STREQUAL AIX))
|
| 204 |
+
endif(ZLIB_BUILD_SHARED)
|
| 205 |
+
|
| 206 |
+
if(ZLIB_BUILD_STATIC)
|
| 207 |
+
add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS}
|
| 208 |
+
${ZLIB_PRIVATE_HDRS})
|
| 209 |
+
add_library(ZLIB::ZLIBSTATIC ALIAS zlibstatic)
|
| 210 |
+
target_include_directories(
|
| 211 |
+
zlibstatic
|
| 212 |
+
PUBLIC $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
|
| 213 |
+
$<BUILD_INTERFACE:${zlib_SOURCE_DIR}>
|
| 214 |
+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
| 215 |
+
target_compile_definitions(
|
| 216 |
+
zlibstatic
|
| 217 |
+
PRIVATE ZLIB_BUILD
|
| 218 |
+
$<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
|
| 219 |
+
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
|
| 220 |
+
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
|
| 221 |
+
$<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
|
| 222 |
+
PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
|
| 223 |
+
set_target_properties(
|
| 224 |
+
zlibstatic PROPERTIES EXPORT_NAME ZLIBSTATIC OUTPUT_NAME
|
| 225 |
+
z${zlib_static_suffix})
|
| 226 |
+
endif(ZLIB_BUILD_STATIC)
|
| 227 |
+
|
| 228 |
+
if(ZLIB_INSTALL)
|
| 229 |
+
if(ZLIB_BUILD_SHARED)
|
| 230 |
+
install(
|
| 231 |
+
TARGETS zlib
|
| 232 |
+
COMPONENT Runtime
|
| 233 |
+
EXPORT zlibSharedExport
|
| 234 |
+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
| 235 |
+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
| 236 |
+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
| 237 |
+
install(
|
| 238 |
+
EXPORT zlibSharedExport
|
| 239 |
+
FILE ZLIB-shared.cmake
|
| 240 |
+
NAMESPACE ZLIB::
|
| 241 |
+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
|
| 242 |
+
if(ZLIB_INSTALL_COMPAT_DLL)
|
| 243 |
+
install(
|
| 244 |
+
FILES $<TARGET_FILE:zlib>
|
| 245 |
+
COMPONENT Runtime
|
| 246 |
+
RENAME zlib1.dll
|
| 247 |
+
DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
| 248 |
+
endif(ZLIB_INSTALL_COMPAT_DLL)
|
| 249 |
+
|
| 250 |
+
if(MSVC)
|
| 251 |
+
install(
|
| 252 |
+
FILES $<TARGET_PDB_FILE:zlib>
|
| 253 |
+
COMPONENT Runtime
|
| 254 |
+
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
| 255 |
+
CONFIGURATIONS Debug OR RelWithDebInfo
|
| 256 |
+
OPTIONAL)
|
| 257 |
+
endif(MSVC)
|
| 258 |
+
endif(ZLIB_BUILD_SHARED)
|
| 259 |
+
|
| 260 |
+
if(ZLIB_BUILD_STATIC)
|
| 261 |
+
install(
|
| 262 |
+
TARGETS zlibstatic
|
| 263 |
+
COMPONENT Development
|
| 264 |
+
EXPORT zlibStaticExport
|
| 265 |
+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
| 266 |
+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
| 267 |
+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
| 268 |
+
install(
|
| 269 |
+
EXPORT zlibStaticExport
|
| 270 |
+
FILE ZLIB-static.cmake
|
| 271 |
+
NAMESPACE ZLIB::
|
| 272 |
+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
|
| 273 |
+
|
| 274 |
+
if(ZLIB_INSTALL_COMPAT_DLL AND MINGW)
|
| 275 |
+
install(
|
| 276 |
+
FILES $<TARGET_FILE:zlibstatic>
|
| 277 |
+
COMPONENT Development
|
| 278 |
+
RENAME libz.dll.a
|
| 279 |
+
DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
| 280 |
+
endif(ZLIB_INSTALL_COMPAT_DLL AND MINGW)
|
| 281 |
+
endif(ZLIB_BUILD_STATIC)
|
| 282 |
+
|
| 283 |
+
configure_package_config_file(
|
| 284 |
+
${zlib_SOURCE_DIR}/zlibConfig.cmake.in
|
| 285 |
+
${zlib_BINARY_DIR}/ZLIBConfig.cmake
|
| 286 |
+
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
|
| 287 |
+
|
| 288 |
+
write_basic_package_version_file(
|
| 289 |
+
"${zlib_BINARY_DIR}/ZLIBConfigVersion.cmake"
|
| 290 |
+
VERSION "${zlib_VERSION}"
|
| 291 |
+
COMPATIBILITY AnyNewerVersion)
|
| 292 |
+
|
| 293 |
+
install(FILES ${zlib_BINARY_DIR}/ZLIBConfig.cmake
|
| 294 |
+
${zlib_BINARY_DIR}/ZLIBConfigVersion.cmake
|
| 295 |
+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
|
| 296 |
+
install(
|
| 297 |
+
FILES ${ZLIB_PUBLIC_HDRS}
|
| 298 |
+
COMPONENT Development
|
| 299 |
+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
| 300 |
+
install(
|
| 301 |
+
FILES zlib.3
|
| 302 |
+
COMPONENT Docs
|
| 303 |
+
DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
|
| 304 |
+
install(
|
| 305 |
+
FILES LICENSE
|
| 306 |
+
doc/algorithm.txt
|
| 307 |
+
doc/crc-doc.1.0.pdf
|
| 308 |
+
doc/rfc1950.txt
|
| 309 |
+
doc/rfc1951.txt
|
| 310 |
+
doc/rfc1952.txt
|
| 311 |
+
doc/txtvsbin.txt
|
| 312 |
+
COMPONENT Docs
|
| 313 |
+
DESTINATION "${CMAKE_INSTALL_DOCDIR}/zlib")
|
| 314 |
+
install(
|
| 315 |
+
FILES ${ZLIB_PC}
|
| 316 |
+
COMPONENT Development
|
| 317 |
+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
| 318 |
+
endif(ZLIB_INSTALL)
|
| 319 |
+
|
| 320 |
+
# ============================================================================
|
| 321 |
+
# Tests
|
| 322 |
+
# ============================================================================
|
| 323 |
+
if(ZLIB_BUILD_TESTING)
|
| 324 |
+
enable_testing()
|
| 325 |
+
add_subdirectory(test)
|
| 326 |
+
endif(ZLIB_BUILD_TESTING)
|
| 327 |
+
|
| 328 |
+
if(ZLIB_BUILD_MINIZIP)
|
| 329 |
+
add_subdirectory(contrib/minizip/)
|
| 330 |
+
endif(ZLIB_BUILD_MINIZIP)
|
ChangeLog
ADDED
|
@@ -0,0 +1,1621 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
ChangeLog file for zlib
|
| 3 |
+
|
| 4 |
+
Changes in 1.3.1.1 (xx Jan 2024)
|
| 5 |
+
-
|
| 6 |
+
|
| 7 |
+
Changes in 1.3.1 (22 Jan 2024)
|
| 8 |
+
- Reject overflows of zip header fields in minizip
|
| 9 |
+
- Fix bug in inflateSync() for data held in bit buffer
|
| 10 |
+
- Add LIT_MEM define to use more memory for a small deflate speedup
|
| 11 |
+
- Fix decision on the emission of Zip64 end records in minizip
|
| 12 |
+
- Add bounds checking to ERR_MSG() macro, used by zError()
|
| 13 |
+
- Neutralize zip file traversal attacks in miniunz
|
| 14 |
+
- Fix a bug in ZLIB_DEBUG compiles in check_match()
|
| 15 |
+
- Various portability and appearance improvements
|
| 16 |
+
|
| 17 |
+
Changes in 1.3 (18 Aug 2023)
|
| 18 |
+
- Remove K&R function definitions and zlib2ansi
|
| 19 |
+
- Fix bug in deflateBound() for level 0 and memLevel 9
|
| 20 |
+
- Fix bug when gzungetc() is used immediately after gzopen()
|
| 21 |
+
- Fix bug when using gzflush() with a very small buffer
|
| 22 |
+
- Fix crash when gzsetparams() attempted for transparent write
|
| 23 |
+
- Fix test/example.c to work with FORCE_STORED
|
| 24 |
+
- Rewrite of zran in examples (see zran.c version history)
|
| 25 |
+
- Fix minizip to allow it to open an empty zip file
|
| 26 |
+
- Fix reading disk number start on zip64 files in minizip
|
| 27 |
+
- Fix logic error in minizip argument processing
|
| 28 |
+
- Add minizip testing to Makefile
|
| 29 |
+
- Read multiple bytes instead of byte-by-byte in minizip unzip.c
|
| 30 |
+
- Add memory sanitizer to configure (--memory)
|
| 31 |
+
- Various portability improvements
|
| 32 |
+
- Various documentation improvements
|
| 33 |
+
- Various spelling and typo corrections
|
| 34 |
+
|
| 35 |
+
Changes in 1.2.13 (13 Oct 2022)
|
| 36 |
+
- Fix configure issue that discarded provided CC definition
|
| 37 |
+
- Correct incorrect inputs provided to the CRC functions
|
| 38 |
+
- Repair prototypes and exporting of new CRC functions
|
| 39 |
+
- Fix inflateBack to detect invalid input with distances too far
|
| 40 |
+
- Have infback() deliver all of the available output up to any error
|
| 41 |
+
- Fix a bug when getting a gzip header extra field with inflate()
|
| 42 |
+
- Fix bug in block type selection when Z_FIXED used
|
| 43 |
+
- Tighten deflateBound bounds
|
| 44 |
+
- Remove deleted assembler code references
|
| 45 |
+
- Various portability and appearance improvements
|
| 46 |
+
|
| 47 |
+
Changes in 1.2.12 (27 Mar 2022)
|
| 48 |
+
- Cygwin does not have _wopen(), so do not create gzopen_w() there
|
| 49 |
+
- Permit a deflateParams() parameter change as soon as possible
|
| 50 |
+
- Limit hash table inserts after switch from stored deflate
|
| 51 |
+
- Fix bug when window full in deflate_stored()
|
| 52 |
+
- Fix CLEAR_HASH macro to be usable as a single statement
|
| 53 |
+
- Avoid a conversion error in gzseek when off_t type too small
|
| 54 |
+
- Have Makefile return non-zero error code on test failure
|
| 55 |
+
- Avoid some conversion warnings in gzread.c and gzwrite.c
|
| 56 |
+
- Update use of errno for newer Windows CE versions
|
| 57 |
+
- Small speedup to inflate [psumbera]
|
| 58 |
+
- Return an error if the gzputs string length can't fit in an int
|
| 59 |
+
- Add address checking in clang to -w option of configure
|
| 60 |
+
- Don't compute check value for raw inflate if asked to validate
|
| 61 |
+
- Handle case where inflateSync used when header never processed
|
| 62 |
+
- Avoid the use of ptrdiff_t
|
| 63 |
+
- Avoid an undefined behavior of memcpy() in gzappend()
|
| 64 |
+
- Avoid undefined behaviors of memcpy() in gz*printf()
|
| 65 |
+
- Avoid an undefined behavior of memcpy() in _tr_stored_block()
|
| 66 |
+
- Make the names in functions declarations identical to definitions
|
| 67 |
+
- Remove old assembler code in which bugs have manifested
|
| 68 |
+
- Fix deflateEnd() to not report an error at start of raw deflate
|
| 69 |
+
- Add legal disclaimer to README
|
| 70 |
+
- Emphasize the need to continue decompressing gzip members
|
| 71 |
+
- Correct the initialization requirements for deflateInit2()
|
| 72 |
+
- Fix a bug that can crash deflate on some input when using Z_FIXED
|
| 73 |
+
- Assure that the number of bits for deflatePrime() is valid
|
| 74 |
+
- Use a structure to make globals in enough.c evident
|
| 75 |
+
- Use a macro for the printf format of big_t in enough.c
|
| 76 |
+
- Clean up code style in enough.c, update version
|
| 77 |
+
- Use inline function instead of macro for index in enough.c
|
| 78 |
+
- Clarify that prefix codes are counted in enough.c
|
| 79 |
+
- Show all the codes for the maximum tables size in enough.c
|
| 80 |
+
- Add gznorm.c example, which normalizes gzip files
|
| 81 |
+
- Fix the zran.c example to work on a multiple-member gzip file
|
| 82 |
+
- Add tables for crc32_combine(), to speed it up by a factor of 200
|
| 83 |
+
- Add crc32_combine_gen() and crc32_combine_op() for fast combines
|
| 84 |
+
- Speed up software CRC-32 computation by a factor of 1.5 to 3
|
| 85 |
+
- Use atomic test and set, if available, for dynamic CRC tables
|
| 86 |
+
- Don't bother computing check value after successful inflateSync()
|
| 87 |
+
- Correct comment in crc32.c
|
| 88 |
+
- Add use of the ARMv8 crc32 instructions when requested
|
| 89 |
+
- Use ARM crc32 instructions if the ARM architecture has them
|
| 90 |
+
- Explicitly note that the 32-bit check values are 32 bits
|
| 91 |
+
- Avoid adding empty gzip member after gzflush with Z_FINISH
|
| 92 |
+
- Fix memory leak on error in gzlog.c
|
| 93 |
+
- Fix error in comment on the polynomial representation of a byte
|
| 94 |
+
- Clarify gz* function interfaces, referring to parameter names
|
| 95 |
+
- Change macro name in inflate.c to avoid collision in VxWorks
|
| 96 |
+
- Correct typo in blast.c
|
| 97 |
+
- Improve portability of contrib/minizip
|
| 98 |
+
- Fix indentation in minizip's zip.c
|
| 99 |
+
- Replace black/white with allow/block. (theresa-m)
|
| 100 |
+
- minizip warning fix if MAXU32 already defined. (gvollant)
|
| 101 |
+
- Fix unztell64() in minizip to work past 4GB. (Daniël Hörchner)
|
| 102 |
+
- Clean up minizip to reduce warnings for testing
|
| 103 |
+
- Add fallthrough comments for gcc
|
| 104 |
+
- Eliminate use of ULL constants
|
| 105 |
+
- Separate out address sanitizing from warnings in configure
|
| 106 |
+
- Remove destructive aspects of make distclean
|
| 107 |
+
- Check for cc masquerading as gcc or clang in configure
|
| 108 |
+
- Fix crc32.c to compile local functions only if used
|
| 109 |
+
|
| 110 |
+
Changes in 1.2.11 (15 Jan 2017)
|
| 111 |
+
- Fix deflate stored bug when pulling last block from window
|
| 112 |
+
- Permit immediate deflateParams changes before any deflate input
|
| 113 |
+
|
| 114 |
+
Changes in 1.2.10 (2 Jan 2017)
|
| 115 |
+
- Avoid warnings on snprintf() return value
|
| 116 |
+
- Fix bug in deflate_stored() for zero-length input
|
| 117 |
+
- Fix bug in gzwrite.c that produced corrupt gzip files
|
| 118 |
+
- Remove files to be installed before copying them in Makefile.in
|
| 119 |
+
- Add warnings when compiling with assembler code
|
| 120 |
+
|
| 121 |
+
Changes in 1.2.9 (31 Dec 2016)
|
| 122 |
+
- Fix contrib/minizip to permit unzipping with desktop API [Zouzou]
|
| 123 |
+
- Improve contrib/blast to return unused bytes
|
| 124 |
+
- Assure that gzoffset() is correct when appending
|
| 125 |
+
- Improve compress() and uncompress() to support large lengths
|
| 126 |
+
- Fix bug in test/example.c where error code not saved
|
| 127 |
+
- Remedy Coverity warning [Randers-Pehrson]
|
| 128 |
+
- Improve speed of gzprintf() in transparent mode
|
| 129 |
+
- Fix inflateInit2() bug when windowBits is 16 or 32
|
| 130 |
+
- Change DEBUG macro to ZLIB_DEBUG
|
| 131 |
+
- Avoid uninitialized access by gzclose_w()
|
| 132 |
+
- Allow building zlib outside of the source directory
|
| 133 |
+
- Fix bug that accepted invalid zlib header when windowBits is zero
|
| 134 |
+
- Fix gzseek() problem on MinGW due to buggy _lseeki64 there
|
| 135 |
+
- Loop on write() calls in gzwrite.c in case of non-blocking I/O
|
| 136 |
+
- Add --warn (-w) option to ./configure for more compiler warnings
|
| 137 |
+
- Reject a window size of 256 bytes if not using the zlib wrapper
|
| 138 |
+
- Fix bug when level 0 used with Z_HUFFMAN or Z_RLE
|
| 139 |
+
- Add --debug (-d) option to ./configure to define ZLIB_DEBUG
|
| 140 |
+
- Fix bugs in creating a very large gzip header
|
| 141 |
+
- Add uncompress2() function, which returns the input size used
|
| 142 |
+
- Assure that deflateParams() will not switch functions mid-block
|
| 143 |
+
- Dramatically speed up deflation for level 0 (storing)
|
| 144 |
+
- Add gzfread(), duplicating the interface of fread()
|
| 145 |
+
- Add gzfwrite(), duplicating the interface of fwrite()
|
| 146 |
+
- Add deflateGetDictionary() function
|
| 147 |
+
- Use snprintf() for later versions of Microsoft C
|
| 148 |
+
- Fix *Init macros to use z_ prefix when requested
|
| 149 |
+
- Replace as400 with os400 for OS/400 support [Monnerat]
|
| 150 |
+
- Add crc32_z() and adler32_z() functions with size_t lengths
|
| 151 |
+
- Update Visual Studio project files [AraHaan]
|
| 152 |
+
|
| 153 |
+
Changes in 1.2.8 (28 Apr 2013)
|
| 154 |
+
- Update contrib/minizip/iowin32.c for Windows RT [Vollant]
|
| 155 |
+
- Do not force Z_CONST for C++
|
| 156 |
+
- Clean up contrib/vstudio [Roß]
|
| 157 |
+
- Correct spelling error in zlib.h
|
| 158 |
+
- Fix mixed line endings in contrib/vstudio
|
| 159 |
+
|
| 160 |
+
Changes in 1.2.7.3 (13 Apr 2013)
|
| 161 |
+
- Fix version numbers and DLL names in contrib/vstudio/*/zlib.rc
|
| 162 |
+
|
| 163 |
+
Changes in 1.2.7.2 (13 Apr 2013)
|
| 164 |
+
- Change check for a four-byte type back to hexadecimal
|
| 165 |
+
- Fix typo in win32/Makefile.msc
|
| 166 |
+
- Add casts in gzwrite.c for pointer differences
|
| 167 |
+
|
| 168 |
+
Changes in 1.2.7.1 (24 Mar 2013)
|
| 169 |
+
- Replace use of unsafe string functions with snprintf if available
|
| 170 |
+
- Avoid including stddef.h on Windows for Z_SOLO compile [Niessink]
|
| 171 |
+
- Fix gzgetc undefine when Z_PREFIX set [Turk]
|
| 172 |
+
- Eliminate use of mktemp in Makefile (not always available)
|
| 173 |
+
- Fix bug in 'F' mode for gzopen()
|
| 174 |
+
- Add inflateGetDictionary() function
|
| 175 |
+
- Correct comment in deflate.h
|
| 176 |
+
- Use _snprintf for snprintf in Microsoft C
|
| 177 |
+
- On Darwin, only use /usr/bin/libtool if libtool is not Apple
|
| 178 |
+
- Delete "--version" file if created by "ar --version" [Richard G.]
|
| 179 |
+
- Fix configure check for veracity of compiler error return codes
|
| 180 |
+
- Fix CMake compilation of static lib for MSVC2010 x64
|
| 181 |
+
- Remove unused variable in infback9.c
|
| 182 |
+
- Fix argument checks in gzlog_compress() and gzlog_write()
|
| 183 |
+
- Clean up the usage of z_const and respect const usage within zlib
|
| 184 |
+
- Clean up examples/gzlog.[ch] comparisons of different types
|
| 185 |
+
- Avoid shift equal to bits in type (caused endless loop)
|
| 186 |
+
- Fix uninitialized value bug in gzputc() introduced by const patches
|
| 187 |
+
- Fix memory allocation error in examples/zran.c [Nor]
|
| 188 |
+
- Fix bug where gzopen(), gzclose() would write an empty file
|
| 189 |
+
- Fix bug in gzclose() when gzwrite() runs out of memory
|
| 190 |
+
- Check for input buffer malloc failure in examples/gzappend.c
|
| 191 |
+
- Add note to contrib/blast to use binary mode in stdio
|
| 192 |
+
- Fix comparisons of differently signed integers in contrib/blast
|
| 193 |
+
- Check for invalid code length codes in contrib/puff
|
| 194 |
+
- Fix serious but very rare decompression bug in inftrees.c
|
| 195 |
+
- Update inflateBack() comments, since inflate() can be faster
|
| 196 |
+
- Use underscored I/O function names for WINAPI_FAMILY
|
| 197 |
+
- Add _tr_flush_bits to the external symbols prefixed by --zprefix
|
| 198 |
+
- Add contrib/vstudio/vc10 pre-build step for static only
|
| 199 |
+
- Quote --version-script argument in CMakeLists.txt
|
| 200 |
+
- Don't specify --version-script on Apple platforms in CMakeLists.txt
|
| 201 |
+
- Fix casting error in contrib/testzlib/testzlib.c
|
| 202 |
+
- Fix types in contrib/minizip to match result of get_crc_table()
|
| 203 |
+
- Simplify contrib/vstudio/vc10 with 'd' suffix
|
| 204 |
+
- Add TOP support to win32/Makefile.msc
|
| 205 |
+
- Support i686 and amd64 assembler builds in CMakeLists.txt
|
| 206 |
+
- Fix typos in the use of _LARGEFILE64_SOURCE in zconf.h
|
| 207 |
+
- Add vc11 and vc12 build files to contrib/vstudio
|
| 208 |
+
- Add gzvprintf() as an undocumented function in zlib
|
| 209 |
+
- Fix configure for Sun shell
|
| 210 |
+
- Remove runtime check in configure for four-byte integer type
|
| 211 |
+
- Add casts and consts to ease user conversion to C++
|
| 212 |
+
- Add man pages for minizip and miniunzip
|
| 213 |
+
- In Makefile uninstall, don't rm if preceding cd fails
|
| 214 |
+
- Do not return Z_BUF_ERROR if deflateParam() has nothing to write
|
| 215 |
+
|
| 216 |
+
Changes in 1.2.7 (2 May 2012)
|
| 217 |
+
- Replace use of memmove() with a simple copy for portability
|
| 218 |
+
- Test for existence of strerror
|
| 219 |
+
- Restore gzgetc_ for backward compatibility with 1.2.6
|
| 220 |
+
- Fix build with non-GNU make on Solaris
|
| 221 |
+
- Require gcc 4.0 or later on Mac OS X to use the hidden attribute
|
| 222 |
+
- Include unistd.h for Watcom C
|
| 223 |
+
- Use __WATCOMC__ instead of __WATCOM__
|
| 224 |
+
- Do not use the visibility attribute if NO_VIZ defined
|
| 225 |
+
- Improve the detection of no hidden visibility attribute
|
| 226 |
+
- Avoid using __int64 for gcc or solo compilation
|
| 227 |
+
- Cast to char * in gzprintf to avoid warnings [Zinser]
|
| 228 |
+
- Fix make_vms.com for VAX [Zinser]
|
| 229 |
+
- Don't use library or built-in byte swaps
|
| 230 |
+
- Simplify test and use of gcc hidden attribute
|
| 231 |
+
- Fix bug in gzclose_w() when gzwrite() fails to allocate memory
|
| 232 |
+
- Add "x" (O_EXCL) and "e" (O_CLOEXEC) modes support to gzopen()
|
| 233 |
+
- Fix bug in test/minigzip.c for configure --solo
|
| 234 |
+
- Fix contrib/vstudio project link errors [Mohanathas]
|
| 235 |
+
- Add ability to choose the builder in make_vms.com [Schweda]
|
| 236 |
+
- Add DESTDIR support to mingw32 win32/Makefile.gcc
|
| 237 |
+
- Fix comments in win32/Makefile.gcc for proper usage
|
| 238 |
+
- Allow overriding the default install locations for cmake
|
| 239 |
+
- Generate and install the pkg-config file with cmake
|
| 240 |
+
- Build both a static and a shared version of zlib with cmake
|
| 241 |
+
- Include version symbols for cmake builds
|
| 242 |
+
- If using cmake with MSVC, add the source directory to the includes
|
| 243 |
+
- Remove unneeded EXTRA_CFLAGS from win32/Makefile.gcc [Truta]
|
| 244 |
+
- Move obsolete emx makefile to old [Truta]
|
| 245 |
+
- Allow the use of -Wundef when compiling or using zlib
|
| 246 |
+
- Avoid the use of the -u option with mktemp
|
| 247 |
+
- Improve inflate() documentation on the use of Z_FINISH
|
| 248 |
+
- Recognize clang as gcc
|
| 249 |
+
- Add gzopen_w() in Windows for wide character path names
|
| 250 |
+
- Rename zconf.h in CMakeLists.txt to move it out of the way
|
| 251 |
+
- Add source directory in CMakeLists.txt for building examples
|
| 252 |
+
- Look in build directory for zlib.pc in CMakeLists.txt
|
| 253 |
+
- Remove gzflags from zlibvc.def in vc9 and vc10
|
| 254 |
+
- Fix contrib/minizip compilation in the MinGW environment
|
| 255 |
+
- Update ./configure for Solaris, support --64 [Mooney]
|
| 256 |
+
- Remove -R. from Solaris shared build (possible security issue)
|
| 257 |
+
- Avoid race condition for parallel make (-j) running example
|
| 258 |
+
- Fix type mismatch between get_crc_table() and crc_table
|
| 259 |
+
- Fix parsing of version with "-" in CMakeLists.txt [Snider, Ziegler]
|
| 260 |
+
- Fix the path to zlib.map in CMakeLists.txt
|
| 261 |
+
- Force the native libtool in Mac OS X to avoid GNU libtool [Beebe]
|
| 262 |
+
- Add instructions to win32/Makefile.gcc for shared install [Torri]
|
| 263 |
+
|
| 264 |
+
Changes in 1.2.6.1 (12 Feb 2012)
|
| 265 |
+
- Avoid the use of the Objective-C reserved name "id"
|
| 266 |
+
- Include io.h in gzguts.h for Microsoft compilers
|
| 267 |
+
- Fix problem with ./configure --prefix and gzgetc macro
|
| 268 |
+
- Include gz_header definition when compiling zlib solo
|
| 269 |
+
- Put gzflags() functionality back in zutil.c
|
| 270 |
+
- Avoid library header include in crc32.c for Z_SOLO
|
| 271 |
+
- Use name in GCC_CLASSIC as C compiler for coverage testing, if set
|
| 272 |
+
- Minor cleanup in contrib/minizip/zip.c [Vollant]
|
| 273 |
+
- Update make_vms.com [Zinser]
|
| 274 |
+
- Remove unnecessary gzgetc_ function
|
| 275 |
+
- Use optimized byte swap operations for Microsoft and GNU [Snyder]
|
| 276 |
+
- Fix minor typo in zlib.h comments [Rzesniowiecki]
|
| 277 |
+
|
| 278 |
+
Changes in 1.2.6 (29 Jan 2012)
|
| 279 |
+
- Update the Pascal interface in contrib/pascal
|
| 280 |
+
- Fix function numbers for gzgetc_ in zlibvc.def files
|
| 281 |
+
- Fix configure.ac for contrib/minizip [Schiffer]
|
| 282 |
+
- Fix large-entry detection in minizip on 64-bit systems [Schiffer]
|
| 283 |
+
- Have ./configure use the compiler return code for error indication
|
| 284 |
+
- Fix CMakeLists.txt for cross compilation [McClure]
|
| 285 |
+
- Fix contrib/minizip/zip.c for 64-bit architectures [Dalsnes]
|
| 286 |
+
- Fix compilation of contrib/minizip on FreeBSD [Marquez]
|
| 287 |
+
- Correct suggested usages in win32/Makefile.msc [Shachar, Horvath]
|
| 288 |
+
- Include io.h for Turbo C / Borland C on all platforms [Truta]
|
| 289 |
+
- Make version explicit in contrib/minizip/configure.ac [Bosmans]
|
| 290 |
+
- Avoid warning for no encryption in contrib/minizip/zip.c [Vollant]
|
| 291 |
+
- Minor cleanup up contrib/minizip/unzip.c [Vollant]
|
| 292 |
+
- Fix bug when compiling minizip with C++ [Vollant]
|
| 293 |
+
- Protect for long name and extra fields in contrib/minizip [Vollant]
|
| 294 |
+
- Avoid some warnings in contrib/minizip [Vollant]
|
| 295 |
+
- Add -I../.. -L../.. to CFLAGS for minizip and miniunzip
|
| 296 |
+
- Add missing libs to minizip linker command
|
| 297 |
+
- Add support for VPATH builds in contrib/minizip
|
| 298 |
+
- Add an --enable-demos option to contrib/minizip/configure
|
| 299 |
+
- Add the generation of configure.log by ./configure
|
| 300 |
+
- Exit when required parameters not provided to win32/Makefile.gcc
|
| 301 |
+
- Have gzputc return the character written instead of the argument
|
| 302 |
+
- Use the -m option on ldconfig for BSD systems [Tobias]
|
| 303 |
+
- Correct in zlib.map when deflateResetKeep was added
|
| 304 |
+
|
| 305 |
+
Changes in 1.2.5.3 (15 Jan 2012)
|
| 306 |
+
- Restore gzgetc function for binary compatibility
|
| 307 |
+
- Do not use _lseeki64 under Borland C++ [Truta]
|
| 308 |
+
- Update win32/Makefile.msc to build test/*.c [Truta]
|
| 309 |
+
- Remove old/visualc6 given CMakefile and other alternatives
|
| 310 |
+
- Update AS400 build files and documentation [Monnerat]
|
| 311 |
+
- Update win32/Makefile.gcc to build test/*.c [Truta]
|
| 312 |
+
- Permit stronger flushes after Z_BLOCK flushes
|
| 313 |
+
- Avoid extraneous empty blocks when doing empty flushes
|
| 314 |
+
- Permit Z_NULL arguments to deflatePending
|
| 315 |
+
- Allow deflatePrime() to insert bits in the middle of a stream
|
| 316 |
+
- Remove second empty static block for Z_PARTIAL_FLUSH
|
| 317 |
+
- Write out all of the available bits when using Z_BLOCK
|
| 318 |
+
- Insert the first two strings in the hash table after a flush
|
| 319 |
+
|
| 320 |
+
Changes in 1.2.5.2 (17 Dec 2011)
|
| 321 |
+
- fix ld error: unable to find version dependency 'ZLIB_1.2.5'
|
| 322 |
+
- use relative symlinks for shared libs
|
| 323 |
+
- Avoid searching past window for Z_RLE strategy
|
| 324 |
+
- Assure that high-water mark initialization is always applied in deflate
|
| 325 |
+
- Add assertions to fill_window() in deflate.c to match comments
|
| 326 |
+
- Update python link in README
|
| 327 |
+
- Correct spelling error in gzread.c
|
| 328 |
+
- Fix bug in gzgets() for a concatenated empty gzip stream
|
| 329 |
+
- Correct error in comment for gz_make()
|
| 330 |
+
- Change gzread() and related to ignore junk after gzip streams
|
| 331 |
+
- Allow gzread() and related to continue after gzclearerr()
|
| 332 |
+
- Allow gzrewind() and gzseek() after a premature end-of-file
|
| 333 |
+
- Simplify gzseek() now that raw after gzip is ignored
|
| 334 |
+
- Change gzgetc() to a macro for speed (~40% speedup in testing)
|
| 335 |
+
- Fix gzclose() to return the actual error last encountered
|
| 336 |
+
- Always add large file support for windows
|
| 337 |
+
- Include zconf.h for windows large file support
|
| 338 |
+
- Include zconf.h.cmakein for windows large file support
|
| 339 |
+
- Update zconf.h.cmakein on make distclean
|
| 340 |
+
- Merge vestigial vsnprintf determination from zutil.h to gzguts.h
|
| 341 |
+
- Clarify how gzopen() appends in zlib.h comments
|
| 342 |
+
- Correct documentation of gzdirect() since junk at end now ignored
|
| 343 |
+
- Add a transparent write mode to gzopen() when 'T' is in the mode
|
| 344 |
+
- Update python link in zlib man page
|
| 345 |
+
- Get inffixed.h and MAKEFIXED result to match
|
| 346 |
+
- Add a ./config --solo option to make zlib subset with no library use
|
| 347 |
+
- Add undocumented inflateResetKeep() function for CAB file decoding
|
| 348 |
+
- Add --cover option to ./configure for gcc coverage testing
|
| 349 |
+
- Add #define ZLIB_CONST option to use const in the z_stream interface
|
| 350 |
+
- Add comment to gzdopen() in zlib.h to use dup() when using fileno()
|
| 351 |
+
- Note behavior of uncompress() to provide as much data as it can
|
| 352 |
+
- Add files in contrib/minizip to aid in building libminizip
|
| 353 |
+
- Split off AR options in Makefile.in and configure
|
| 354 |
+
- Change ON macro to Z_ARG to avoid application conflicts
|
| 355 |
+
- Facilitate compilation with Borland C++ for pragmas and vsnprintf
|
| 356 |
+
- Include io.h for Turbo C / Borland C++
|
| 357 |
+
- Move example.c and minigzip.c to test/
|
| 358 |
+
- Simplify incomplete code table filling in inflate_table()
|
| 359 |
+
- Remove code from inflate.c and infback.c that is impossible to execute
|
| 360 |
+
- Test the inflate code with full coverage
|
| 361 |
+
- Allow deflateSetDictionary, inflateSetDictionary at any time (in raw)
|
| 362 |
+
- Add deflateResetKeep and fix inflateResetKeep to retain dictionary
|
| 363 |
+
- Fix gzwrite.c to accommodate reduced memory zlib compilation
|
| 364 |
+
- Have inflate() with Z_FINISH avoid the allocation of a window
|
| 365 |
+
- Do not set strm->adler when doing raw inflate
|
| 366 |
+
- Fix gzeof() to behave just like feof() when read is not past end of file
|
| 367 |
+
- Fix bug in gzread.c when end-of-file is reached
|
| 368 |
+
- Avoid use of Z_BUF_ERROR in gz* functions except for premature EOF
|
| 369 |
+
- Document gzread() capability to read concurrently written files
|
| 370 |
+
- Remove hard-coding of resource compiler in CMakeLists.txt [Blammo]
|
| 371 |
+
|
| 372 |
+
Changes in 1.2.5.1 (10 Sep 2011)
|
| 373 |
+
- Update FAQ entry on shared builds (#13)
|
| 374 |
+
- Avoid symbolic argument to chmod in Makefile.in
|
| 375 |
+
- Fix bug and add consts in contrib/puff [Oberhumer]
|
| 376 |
+
- Update contrib/puff/zeros.raw test file to have all block types
|
| 377 |
+
- Add full coverage test for puff in contrib/puff/Makefile
|
| 378 |
+
- Fix static-only-build install in Makefile.in
|
| 379 |
+
- Fix bug in unzGetCurrentFileInfo() in contrib/minizip [Kuno]
|
| 380 |
+
- Add libz.a dependency to shared in Makefile.in for parallel builds
|
| 381 |
+
- Spell out "number" (instead of "nb") in zlib.h for total_in, total_out
|
| 382 |
+
- Replace $(...) with `...` in configure for non-bash sh [Bowler]
|
| 383 |
+
- Add darwin* to Darwin* and solaris* to SunOS\ 5* in configure [Groffen]
|
| 384 |
+
- Add solaris* to Linux* in configure to allow gcc use [Groffen]
|
| 385 |
+
- Add *bsd* to Linux* case in configure [Bar-Lev]
|
| 386 |
+
- Add inffast.obj to dependencies in win32/Makefile.msc
|
| 387 |
+
- Correct spelling error in deflate.h [Kohler]
|
| 388 |
+
- Change libzdll.a again to libz.dll.a (!) in win32/Makefile.gcc
|
| 389 |
+
- Add test to configure for GNU C looking for gcc in output of $cc -v
|
| 390 |
+
- Add zlib.pc generation to win32/Makefile.gcc [Weigelt]
|
| 391 |
+
- Fix bug in zlib.h for _FILE_OFFSET_BITS set and _LARGEFILE64_SOURCE not
|
| 392 |
+
- Add comment in zlib.h that adler32_combine with len2 < 0 makes no sense
|
| 393 |
+
- Make NO_DIVIDE option in adler32.c much faster (thanks to John Reiser)
|
| 394 |
+
- Make stronger test in zconf.h to include unistd.h for LFS
|
| 395 |
+
- Apply Darwin patches for 64-bit file offsets to contrib/minizip [Slack]
|
| 396 |
+
- Fix zlib.h LFS support when Z_PREFIX used
|
| 397 |
+
- Add updated as400 support (removed from old) [Monnerat]
|
| 398 |
+
- Avoid deflate sensitivity to volatile input data
|
| 399 |
+
- Avoid division in adler32_combine for NO_DIVIDE
|
| 400 |
+
- Clarify the use of Z_FINISH with deflateBound() amount of space
|
| 401 |
+
- Set binary for output file in puff.c
|
| 402 |
+
- Use u4 type for crc_table to avoid conversion warnings
|
| 403 |
+
- Apply casts in zlib.h to avoid conversion warnings
|
| 404 |
+
- Add OF to prototypes for adler32_combine_ and crc32_combine_ [Miller]
|
| 405 |
+
- Improve inflateSync() documentation to note indeterminacy
|
| 406 |
+
- Add deflatePending() function to return the amount of pending output
|
| 407 |
+
- Correct the spelling of "specification" in FAQ [Randers-Pehrson]
|
| 408 |
+
- Add a check in configure for stdarg.h, use for gzprintf()
|
| 409 |
+
- Check that pointers fit in ints when gzprint() compiled old style
|
| 410 |
+
- Add dummy name before $(SHAREDLIBV) in Makefile [Bar-Lev, Bowler]
|
| 411 |
+
- Delete line in configure that adds -L. libz.a to LDFLAGS [Weigelt]
|
| 412 |
+
- Add debug records in assembler code [Londer]
|
| 413 |
+
- Update RFC references to use http://tools.ietf.org/html/... [Li]
|
| 414 |
+
- Add --archs option, use of libtool to configure for Mac OS X [Borstel]
|
| 415 |
+
|
| 416 |
+
Changes in 1.2.5 (19 Apr 2010)
|
| 417 |
+
- Disable visibility attribute in win32/Makefile.gcc [Bar-Lev]
|
| 418 |
+
- Default to libdir as sharedlibdir in configure [Nieder]
|
| 419 |
+
- Update copyright dates on modified source files
|
| 420 |
+
- Update trees.c to be able to generate modified trees.h
|
| 421 |
+
- Exit configure for MinGW, suggesting win32/Makefile.gcc
|
| 422 |
+
- Check for NULL path in gz_open [Homurlu]
|
| 423 |
+
|
| 424 |
+
Changes in 1.2.4.5 (18 Apr 2010)
|
| 425 |
+
- Set sharedlibdir in configure [Torok]
|
| 426 |
+
- Set LDFLAGS in Makefile.in [Bar-Lev]
|
| 427 |
+
- Avoid mkdir objs race condition in Makefile.in [Bowler]
|
| 428 |
+
- Add ZLIB_INTERNAL in front of internal inter-module functions and arrays
|
| 429 |
+
- Define ZLIB_INTERNAL to hide internal functions and arrays for GNU C
|
| 430 |
+
- Don't use hidden attribute when it is a warning generator (e.g. Solaris)
|
| 431 |
+
|
| 432 |
+
Changes in 1.2.4.4 (18 Apr 2010)
|
| 433 |
+
- Fix CROSS_PREFIX executable testing, CHOST extract, mingw* [Torok]
|
| 434 |
+
- Undefine _LARGEFILE64_SOURCE in zconf.h if it is zero, but not if empty
|
| 435 |
+
- Try to use bash or ksh regardless of functionality of /bin/sh
|
| 436 |
+
- Fix configure incompatibility with NetBSD sh
|
| 437 |
+
- Remove attempt to run under bash or ksh since have better NetBSD fix
|
| 438 |
+
- Fix win32/Makefile.gcc for MinGW [Bar-Lev]
|
| 439 |
+
- Add diagnostic messages when using CROSS_PREFIX in configure
|
| 440 |
+
- Added --sharedlibdir option to configure [Weigelt]
|
| 441 |
+
- Use hidden visibility attribute when available [Frysinger]
|
| 442 |
+
|
| 443 |
+
Changes in 1.2.4.3 (10 Apr 2010)
|
| 444 |
+
- Only use CROSS_PREFIX in configure for ar and ranlib if they exist
|
| 445 |
+
- Use CROSS_PREFIX for nm [Bar-Lev]
|
| 446 |
+
- Assume _LARGEFILE64_SOURCE defined is equivalent to true
|
| 447 |
+
- Avoid use of undefined symbols in #if with && and ||
|
| 448 |
+
- Make *64 prototypes in gzguts.h consistent with functions
|
| 449 |
+
- Add -shared load option for MinGW in configure [Bowler]
|
| 450 |
+
- Move z_off64_t to public interface, use instead of off64_t
|
| 451 |
+
- Remove ! from shell test in configure (not portable to Solaris)
|
| 452 |
+
- Change +0 macro tests to -0 for possibly increased portability
|
| 453 |
+
|
| 454 |
+
Changes in 1.2.4.2 (9 Apr 2010)
|
| 455 |
+
- Add consistent carriage returns to readme.txt's in masmx86 and masmx64
|
| 456 |
+
- Really provide prototypes for *64 functions when building without LFS
|
| 457 |
+
- Only define unlink() in minigzip.c if unistd.h not included
|
| 458 |
+
- Update README to point to contrib/vstudio project files
|
| 459 |
+
- Move projects/vc6 to old/ and remove projects/
|
| 460 |
+
- Include stdlib.h in minigzip.c for setmode() definition under WinCE
|
| 461 |
+
- Clean up assembler builds in win32/Makefile.msc [Rowe]
|
| 462 |
+
- Include sys/types.h for Microsoft for off_t definition
|
| 463 |
+
- Fix memory leak on error in gz_open()
|
| 464 |
+
- Symbolize nm as $NM in configure [Weigelt]
|
| 465 |
+
- Use TEST_LDSHARED instead of LDSHARED to link test programs [Weigelt]
|
| 466 |
+
- Add +0 to _FILE_OFFSET_BITS and _LFS64_LARGEFILE in case not defined
|
| 467 |
+
- Fix bug in gzeof() to take into account unused input data
|
| 468 |
+
- Avoid initialization of structures with variables in puff.c
|
| 469 |
+
- Updated win32/README-WIN32.txt [Rowe]
|
| 470 |
+
|
| 471 |
+
Changes in 1.2.4.1 (28 Mar 2010)
|
| 472 |
+
- Remove the use of [a-z] constructs for sed in configure [gentoo 310225]
|
| 473 |
+
- Remove $(SHAREDLIB) from LIBS in Makefile.in [Creech]
|
| 474 |
+
- Restore "for debugging" comment on sprintf() in gzlib.c
|
| 475 |
+
- Remove fdopen for MVS from gzguts.h
|
| 476 |
+
- Put new README-WIN32.txt in win32 [Rowe]
|
| 477 |
+
- Add check for shell to configure and invoke another shell if needed
|
| 478 |
+
- Fix big fat stinking bug in gzseek() on uncompressed files
|
| 479 |
+
- Remove vestigial F_OPEN64 define in zutil.h
|
| 480 |
+
- Set and check the value of _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE
|
| 481 |
+
- Avoid errors on non-LFS systems when applications define LFS macros
|
| 482 |
+
- Set EXE to ".exe" in configure for MINGW [Kahle]
|
| 483 |
+
- Match crc32() in crc32.c exactly to the prototype in zlib.h [Sherrill]
|
| 484 |
+
- Add prefix for cross-compilation in win32/makefile.gcc [Bar-Lev]
|
| 485 |
+
- Add DLL install in win32/makefile.gcc [Bar-Lev]
|
| 486 |
+
- Allow Linux* or linux* from uname in configure [Bar-Lev]
|
| 487 |
+
- Allow ldconfig to be redefined in configure and Makefile.in [Bar-Lev]
|
| 488 |
+
- Add cross-compilation prefixes to configure [Bar-Lev]
|
| 489 |
+
- Match type exactly in gz_load() invocation in gzread.c
|
| 490 |
+
- Match type exactly of zcalloc() in zutil.c to zlib.h alloc_func
|
| 491 |
+
- Provide prototypes for *64 functions when building zlib without LFS
|
| 492 |
+
- Don't use -lc when linking shared library on MinGW
|
| 493 |
+
- Remove errno.h check in configure and vestigial errno code in zutil.h
|
| 494 |
+
|
| 495 |
+
Changes in 1.2.4 (14 Mar 2010)
|
| 496 |
+
- Fix VER3 extraction in configure for no fourth subversion
|
| 497 |
+
- Update zlib.3, add docs to Makefile.in to make .pdf out of it
|
| 498 |
+
- Add zlib.3.pdf to distribution
|
| 499 |
+
- Don't set error code in gzerror() if passed pointer is NULL
|
| 500 |
+
- Apply destination directory fixes to CMakeLists.txt [Lowman]
|
| 501 |
+
- Move #cmakedefine's to a new zconf.in.cmakein
|
| 502 |
+
- Restore zconf.h for builds that don't use configure or cmake
|
| 503 |
+
- Add distclean to dummy Makefile for convenience
|
| 504 |
+
- Update and improve INDEX, README, and FAQ
|
| 505 |
+
- Update CMakeLists.txt for the return of zconf.h [Lowman]
|
| 506 |
+
- Update contrib/vstudio/vc9 and vc10 [Vollant]
|
| 507 |
+
- Change libz.dll.a back to libzdll.a in win32/Makefile.gcc
|
| 508 |
+
- Apply license and readme changes to contrib/asm686 [Raiter]
|
| 509 |
+
- Check file name lengths and add -c option in minigzip.c [Li]
|
| 510 |
+
- Update contrib/amd64 and contrib/masmx86/ [Vollant]
|
| 511 |
+
- Avoid use of "eof" parameter in trees.c to not shadow library variable
|
| 512 |
+
- Update make_vms.com for removal of zlibdefs.h [Zinser]
|
| 513 |
+
- Update assembler code and vstudio projects in contrib [Vollant]
|
| 514 |
+
- Remove outdated assembler code contrib/masm686 and contrib/asm586
|
| 515 |
+
- Remove old vc7 and vc8 from contrib/vstudio
|
| 516 |
+
- Update win32/Makefile.msc, add ZLIB_VER_SUBREVISION [Rowe]
|
| 517 |
+
- Fix memory leaks in gzclose_r() and gzclose_w(), file leak in gz_open()
|
| 518 |
+
- Add contrib/gcc_gvmat64 for longest_match and inflate_fast [Vollant]
|
| 519 |
+
- Remove *64 functions from win32/zlib.def (they're not 64-bit yet)
|
| 520 |
+
- Fix bug in void-returning vsprintf() case in gzwrite.c
|
| 521 |
+
- Fix name change from inflate.h in contrib/inflate86/inffas86.c
|
| 522 |
+
- Check if temporary file exists before removing in make_vms.com [Zinser]
|
| 523 |
+
- Fix make install and uninstall for --static option
|
| 524 |
+
- Fix usage of _MSC_VER in gzguts.h and zutil.h [Truta]
|
| 525 |
+
- Update readme.txt in contrib/masmx64 and masmx86 to assemble
|
| 526 |
+
|
| 527 |
+
Changes in 1.2.3.9 (21 Feb 2010)
|
| 528 |
+
- Expunge gzio.c
|
| 529 |
+
- Move as400 build information to old
|
| 530 |
+
- Fix updates in contrib/minizip and contrib/vstudio
|
| 531 |
+
- Add const to vsnprintf test in configure to avoid warnings [Weigelt]
|
| 532 |
+
- Delete zconf.h (made by configure) [Weigelt]
|
| 533 |
+
- Change zconf.in.h to zconf.h.in per convention [Weigelt]
|
| 534 |
+
- Check for NULL buf in gzgets()
|
| 535 |
+
- Return empty string for gzgets() with len == 1 (like fgets())
|
| 536 |
+
- Fix description of gzgets() in zlib.h for end-of-file, NULL return
|
| 537 |
+
- Update minizip to 1.1 [Vollant]
|
| 538 |
+
- Avoid MSVC loss of data warnings in gzread.c, gzwrite.c
|
| 539 |
+
- Note in zlib.h that gzerror() should be used to distinguish from EOF
|
| 540 |
+
- Remove use of snprintf() from gzlib.c
|
| 541 |
+
- Fix bug in gzseek()
|
| 542 |
+
- Update contrib/vstudio, adding vc9 and vc10 [Kuno, Vollant]
|
| 543 |
+
- Fix zconf.h generation in CMakeLists.txt [Lowman]
|
| 544 |
+
- Improve comments in zconf.h where modified by configure
|
| 545 |
+
|
| 546 |
+
Changes in 1.2.3.8 (13 Feb 2010)
|
| 547 |
+
- Clean up text files (tabs, trailing whitespace, etc.) [Oberhumer]
|
| 548 |
+
- Use z_off64_t in gz_zero() and gz_skip() to match state->skip
|
| 549 |
+
- Avoid comparison problem when sizeof(int) == sizeof(z_off64_t)
|
| 550 |
+
- Revert to Makefile.in from 1.2.3.6 (live with the clutter)
|
| 551 |
+
- Fix missing error return in gzflush(), add zlib.h note
|
| 552 |
+
- Add *64 functions to zlib.map [Levin]
|
| 553 |
+
- Fix signed/unsigned comparison in gz_comp()
|
| 554 |
+
- Use SFLAGS when testing shared linking in configure
|
| 555 |
+
- Add --64 option to ./configure to use -m64 with gcc
|
| 556 |
+
- Fix ./configure --help to correctly name options
|
| 557 |
+
- Have make fail if a test fails [Levin]
|
| 558 |
+
- Avoid buffer overrun in contrib/masmx64/gvmat64.asm [Simpson]
|
| 559 |
+
- Remove assembler object files from contrib
|
| 560 |
+
|
| 561 |
+
Changes in 1.2.3.7 (24 Jan 2010)
|
| 562 |
+
- Always gzopen() with O_LARGEFILE if available
|
| 563 |
+
- Fix gzdirect() to work immediately after gzopen() or gzdopen()
|
| 564 |
+
- Make gzdirect() more precise when the state changes while reading
|
| 565 |
+
- Improve zlib.h documentation in many places
|
| 566 |
+
- Catch memory allocation failure in gz_open()
|
| 567 |
+
- Complete close operation if seek forward in gzclose_w() fails
|
| 568 |
+
- Return Z_ERRNO from gzclose_r() if close() fails
|
| 569 |
+
- Return Z_STREAM_ERROR instead of EOF for gzclose() being passed NULL
|
| 570 |
+
- Return zero for gzwrite() errors to match zlib.h description
|
| 571 |
+
- Return -1 on gzputs() error to match zlib.h description
|
| 572 |
+
- Add zconf.in.h to allow recovery from configure modification [Weigelt]
|
| 573 |
+
- Fix static library permissions in Makefile.in [Weigelt]
|
| 574 |
+
- Avoid warnings in configure tests that hide functionality [Weigelt]
|
| 575 |
+
- Add *BSD and DragonFly to Linux case in configure [gentoo 123571]
|
| 576 |
+
- Change libzdll.a to libz.dll.a in win32/Makefile.gcc [gentoo 288212]
|
| 577 |
+
- Avoid access of uninitialized data for first inflateReset2 call [Gomes]
|
| 578 |
+
- Keep object files in subdirectories to reduce the clutter somewhat
|
| 579 |
+
- Remove default Makefile and zlibdefs.h, add dummy Makefile
|
| 580 |
+
- Add new external functions to Z_PREFIX, remove duplicates, z_z_ -> z_
|
| 581 |
+
- Remove zlibdefs.h completely -- modify zconf.h instead
|
| 582 |
+
|
| 583 |
+
Changes in 1.2.3.6 (17 Jan 2010)
|
| 584 |
+
- Avoid void * arithmetic in gzread.c and gzwrite.c
|
| 585 |
+
- Make compilers happier with const char * for gz_error message
|
| 586 |
+
- Avoid unused parameter warning in inflate.c
|
| 587 |
+
- Avoid signed-unsigned comparison warning in inflate.c
|
| 588 |
+
- Indent #pragma's for traditional C
|
| 589 |
+
- Fix usage of strwinerror() in glib.c, change to gz_strwinerror()
|
| 590 |
+
- Correct email address in configure for system options
|
| 591 |
+
- Update make_vms.com and add make_vms.com to contrib/minizip [Zinser]
|
| 592 |
+
- Update zlib.map [Brown]
|
| 593 |
+
- Fix Makefile.in for Solaris 10 make of example64 and minizip64 [Torok]
|
| 594 |
+
- Apply various fixes to CMakeLists.txt [Lowman]
|
| 595 |
+
- Add checks on len in gzread() and gzwrite()
|
| 596 |
+
- Add error message for no more room for gzungetc()
|
| 597 |
+
- Remove zlib version check in gzwrite()
|
| 598 |
+
- Defer compression of gzprintf() result until need to
|
| 599 |
+
- Use snprintf() in gzdopen() if available
|
| 600 |
+
- Remove USE_MMAP configuration determination (only used by minigzip)
|
| 601 |
+
- Remove examples/pigz.c (available separately)
|
| 602 |
+
- Update examples/gun.c to 1.6
|
| 603 |
+
|
| 604 |
+
Changes in 1.2.3.5 (8 Jan 2010)
|
| 605 |
+
- Add space after #if in zutil.h for some compilers
|
| 606 |
+
- Fix relatively harmless bug in deflate_fast() [Exarevsky]
|
| 607 |
+
- Fix same problem in deflate_slow()
|
| 608 |
+
- Add $(SHAREDLIBV) to LIBS in Makefile.in [Brown]
|
| 609 |
+
- Add deflate_rle() for faster Z_RLE strategy run-length encoding
|
| 610 |
+
- Add deflate_huff() for faster Z_HUFFMAN_ONLY encoding
|
| 611 |
+
- Change name of "write" variable in inffast.c to avoid library collisions
|
| 612 |
+
- Fix premature EOF from gzread() in gzio.c [Brown]
|
| 613 |
+
- Use zlib header window size if windowBits is 0 in inflateInit2()
|
| 614 |
+
- Remove compressBound() call in deflate.c to avoid linking compress.o
|
| 615 |
+
- Replace use of errno in gz* with functions, support WinCE [Alves]
|
| 616 |
+
- Provide alternative to perror() in minigzip.c for WinCE [Alves]
|
| 617 |
+
- Don't use _vsnprintf on later versions of MSVC [Lowman]
|
| 618 |
+
- Add CMake build script and input file [Lowman]
|
| 619 |
+
- Update contrib/minizip to 1.1 [Svensson, Vollant]
|
| 620 |
+
- Moved nintendods directory from contrib to root
|
| 621 |
+
- Replace gzio.c with a new set of routines with the same functionality
|
| 622 |
+
- Add gzbuffer(), gzoffset(), gzclose_r(), gzclose_w() as part of above
|
| 623 |
+
- Update contrib/minizip to 1.1b
|
| 624 |
+
- Change gzeof() to return 0 on error instead of -1 to agree with zlib.h
|
| 625 |
+
|
| 626 |
+
Changes in 1.2.3.4 (21 Dec 2009)
|
| 627 |
+
- Use old school .SUFFIXES in Makefile.in for FreeBSD compatibility
|
| 628 |
+
- Update comments in configure and Makefile.in for default --shared
|
| 629 |
+
- Fix test -z's in configure [Marquess]
|
| 630 |
+
- Build examplesh and minigzipsh when not testing
|
| 631 |
+
- Change NULL's to Z_NULL's in deflate.c and in comments in zlib.h
|
| 632 |
+
- Import LDFLAGS from the environment in configure
|
| 633 |
+
- Fix configure to populate SFLAGS with discovered CFLAGS options
|
| 634 |
+
- Adapt make_vms.com to the new Makefile.in [Zinser]
|
| 635 |
+
- Add zlib2ansi script for C++ compilation [Marquess]
|
| 636 |
+
- Add _FILE_OFFSET_BITS=64 test to make test (when applicable)
|
| 637 |
+
- Add AMD64 assembler code for longest match to contrib [Teterin]
|
| 638 |
+
- Include options from $SFLAGS when doing $LDSHARED
|
| 639 |
+
- Simplify 64-bit file support by introducing z_off64_t type
|
| 640 |
+
- Make shared object files in objs directory to work around old Sun cc
|
| 641 |
+
- Use only three-part version number for Darwin shared compiles
|
| 642 |
+
- Add rc option to ar in Makefile.in for when ./configure not run
|
| 643 |
+
- Add -WI,-rpath,. to LDFLAGS for OSF 1 V4*
|
| 644 |
+
- Set LD_LIBRARYN32_PATH for SGI IRIX shared compile
|
| 645 |
+
- Protect against _FILE_OFFSET_BITS being defined when compiling zlib
|
| 646 |
+
- Rename Makefile.in targets allstatic to static and allshared to shared
|
| 647 |
+
- Fix static and shared Makefile.in targets to be independent
|
| 648 |
+
- Correct error return bug in gz_open() by setting state [Brown]
|
| 649 |
+
- Put spaces before ;;'s in configure for better sh compatibility
|
| 650 |
+
- Add pigz.c (parallel implementation of gzip) to examples/
|
| 651 |
+
- Correct constant in crc32.c to UL [Leventhal]
|
| 652 |
+
- Reject negative lengths in crc32_combine()
|
| 653 |
+
- Add inflateReset2() function to work like inflateEnd()/inflateInit2()
|
| 654 |
+
- Include sys/types.h for _LARGEFILE64_SOURCE [Brown]
|
| 655 |
+
- Correct typo in doc/algorithm.txt [Janik]
|
| 656 |
+
- Fix bug in adler32_combine() [Zhu]
|
| 657 |
+
- Catch missing-end-of-block-code error in all inflates and in puff
|
| 658 |
+
Assures that random input to inflate eventually results in an error
|
| 659 |
+
- Added enough.c (calculation of ENOUGH for inftrees.h) to examples/
|
| 660 |
+
- Update ENOUGH and its usage to reflect discovered bounds
|
| 661 |
+
- Fix gzerror() error report on empty input file [Brown]
|
| 662 |
+
- Add ush casts in trees.c to avoid pedantic runtime errors
|
| 663 |
+
- Fix typo in zlib.h uncompress() description [Reiss]
|
| 664 |
+
- Correct inflate() comments with regard to automatic header detection
|
| 665 |
+
- Remove deprecation comment on Z_PARTIAL_FLUSH (it stays)
|
| 666 |
+
- Put new version of gzlog (2.0) in examples with interruption recovery
|
| 667 |
+
- Add puff compile option to permit invalid distance-too-far streams
|
| 668 |
+
- Add puff TEST command options, ability to read piped input
|
| 669 |
+
- Prototype the *64 functions in zlib.h when _FILE_OFFSET_BITS == 64, but
|
| 670 |
+
_LARGEFILE64_SOURCE not defined
|
| 671 |
+
- Fix Z_FULL_FLUSH to truly erase the past by resetting s->strstart
|
| 672 |
+
- Fix deflateSetDictionary() to use all 32K for output consistency
|
| 673 |
+
- Remove extraneous #define MIN_LOOKAHEAD in deflate.c (in deflate.h)
|
| 674 |
+
- Clear bytes after deflate lookahead to avoid use of uninitialized data
|
| 675 |
+
- Change a limit in inftrees.c to be more transparent to Coverity Prevent
|
| 676 |
+
- Update win32/zlib.def with exported symbols from zlib.h
|
| 677 |
+
- Correct spelling errors in zlib.h [Willem, Sobrado]
|
| 678 |
+
- Allow Z_BLOCK for deflate() to force a new block
|
| 679 |
+
- Allow negative bits in inflatePrime() to delete existing bit buffer
|
| 680 |
+
- Add Z_TREES flush option to inflate() to return at end of trees
|
| 681 |
+
- Add inflateMark() to return current state information for random access
|
| 682 |
+
- Add Makefile for NintendoDS to contrib [Costa]
|
| 683 |
+
- Add -w in configure compile tests to avoid spurious warnings [Beucler]
|
| 684 |
+
- Fix typos in zlib.h comments for deflateSetDictionary()
|
| 685 |
+
- Fix EOF detection in transparent gzread() [Maier]
|
| 686 |
+
|
| 687 |
+
Changes in 1.2.3.3 (2 October 2006)
|
| 688 |
+
- Make --shared the default for configure, add a --static option
|
| 689 |
+
- Add compile option to permit invalid distance-too-far streams
|
| 690 |
+
- Add inflateUndermine() function which is required to enable above
|
| 691 |
+
- Remove use of "this" variable name for C++ compatibility [Marquess]
|
| 692 |
+
- Add testing of shared library in make test, if shared library built
|
| 693 |
+
- Use ftello() and fseeko() if available instead of ftell() and fseek()
|
| 694 |
+
- Provide two versions of all functions that use the z_off_t type for
|
| 695 |
+
binary compatibility -- a normal version and a 64-bit offset version,
|
| 696 |
+
per the Large File Support Extension when _LARGEFILE64_SOURCE is
|
| 697 |
+
defined; use the 64-bit versions by default when _FILE_OFFSET_BITS
|
| 698 |
+
is defined to be 64
|
| 699 |
+
- Add a --uname= option to configure to perhaps help with cross-compiling
|
| 700 |
+
|
| 701 |
+
Changes in 1.2.3.2 (3 September 2006)
|
| 702 |
+
- Turn off silly Borland warnings [Hay]
|
| 703 |
+
- Use off64_t and define _LARGEFILE64_SOURCE when present
|
| 704 |
+
- Fix missing dependency on inffixed.h in Makefile.in
|
| 705 |
+
- Rig configure --shared to build both shared and static [Teredesai, Truta]
|
| 706 |
+
- Remove zconf.in.h and instead create a new zlibdefs.h file
|
| 707 |
+
- Fix contrib/minizip/unzip.c non-encrypted after encrypted [Vollant]
|
| 708 |
+
- Add treebuild.xml (see http://treebuild.metux.de/) [Weigelt]
|
| 709 |
+
|
| 710 |
+
Changes in 1.2.3.1 (16 August 2006)
|
| 711 |
+
- Add watcom directory with OpenWatcom make files [Daniel]
|
| 712 |
+
- Remove #undef of FAR in zconf.in.h for MVS [Fedtke]
|
| 713 |
+
- Update make_vms.com [Zinser]
|
| 714 |
+
- Use -fPIC for shared build in configure [Teredesai, Nicholson]
|
| 715 |
+
- Use only major version number for libz.so on IRIX and OSF1 [Reinholdtsen]
|
| 716 |
+
- Use fdopen() (not _fdopen()) for Interix in zutil.h [Bäck]
|
| 717 |
+
- Add some FAQ entries about the contrib directory
|
| 718 |
+
- Update the MVS question in the FAQ
|
| 719 |
+
- Avoid extraneous reads after EOF in gzio.c [Brown]
|
| 720 |
+
- Correct spelling of "successfully" in gzio.c [Randers-Pehrson]
|
| 721 |
+
- Add comments to zlib.h about gzerror() usage [Brown]
|
| 722 |
+
- Set extra flags in gzip header in gzopen() like deflate() does
|
| 723 |
+
- Make configure options more compatible with double-dash conventions
|
| 724 |
+
[Weigelt]
|
| 725 |
+
- Clean up compilation under Solaris SunStudio cc [Rowe, Reinholdtsen]
|
| 726 |
+
- Fix uninstall target in Makefile.in [Truta]
|
| 727 |
+
- Add pkgconfig support [Weigelt]
|
| 728 |
+
- Use $(DESTDIR) macro in Makefile.in [Reinholdtsen, Weigelt]
|
| 729 |
+
- Replace set_data_type() with a more accurate detect_data_type() in
|
| 730 |
+
trees.c, according to the txtvsbin.txt document [Truta]
|
| 731 |
+
- Swap the order of #include <stdio.h> and #include "zlib.h" in
|
| 732 |
+
gzio.c, example.c and minigzip.c [Truta]
|
| 733 |
+
- Shut up annoying VS2005 warnings about standard C deprecation [Rowe,
|
| 734 |
+
Truta] (where?)
|
| 735 |
+
- Fix target "clean" from win32/Makefile.bor [Truta]
|
| 736 |
+
- Create .pdb and .manifest files in win32/makefile.msc [Ziegler, Rowe]
|
| 737 |
+
- Update zlib www home address in win32/DLL_FAQ.txt [Truta]
|
| 738 |
+
- Update contrib/masmx86/inffas32.asm for VS2005 [Vollant, Van Wassenhove]
|
| 739 |
+
- Enable browse info in the "Debug" and "ASM Debug" configurations in
|
| 740 |
+
the Visual C++ 6 project, and set (non-ASM) "Debug" as default [Truta]
|
| 741 |
+
- Add pkgconfig support [Weigelt]
|
| 742 |
+
- Add ZLIB_VER_MAJOR, ZLIB_VER_MINOR and ZLIB_VER_REVISION in zlib.h,
|
| 743 |
+
for use in win32/zlib1.rc [Polushin, Rowe, Truta]
|
| 744 |
+
- Add a document that explains the new text detection scheme to
|
| 745 |
+
doc/txtvsbin.txt [Truta]
|
| 746 |
+
- Add rfc1950.txt, rfc1951.txt and rfc1952.txt to doc/ [Truta]
|
| 747 |
+
- Move algorithm.txt into doc/ [Truta]
|
| 748 |
+
- Synchronize FAQ with website
|
| 749 |
+
- Fix compressBound(), was low for some pathological cases [Fearnley]
|
| 750 |
+
- Take into account wrapper variations in deflateBound()
|
| 751 |
+
- Set examples/zpipe.c input and output to binary mode for Windows
|
| 752 |
+
- Update examples/zlib_how.html with new zpipe.c (also web site)
|
| 753 |
+
- Fix some warnings in examples/gzlog.c and examples/zran.c (it seems
|
| 754 |
+
that gcc became pickier in 4.0)
|
| 755 |
+
- Add zlib.map for Linux: "All symbols from zlib-1.1.4 remain
|
| 756 |
+
un-versioned, the patch adds versioning only for symbols introduced in
|
| 757 |
+
zlib-1.2.0 or later. It also declares as local those symbols which are
|
| 758 |
+
not designed to be exported." [Levin]
|
| 759 |
+
- Update Z_PREFIX list in zconf.in.h, add --zprefix option to configure
|
| 760 |
+
- Do not initialize global static by default in trees.c, add a response
|
| 761 |
+
NO_INIT_GLOBAL_POINTERS to initialize them if needed [Marquess]
|
| 762 |
+
- Don't use strerror() in gzio.c under WinCE [Yakimov]
|
| 763 |
+
- Don't use errno.h in zutil.h under WinCE [Yakimov]
|
| 764 |
+
- Move arguments for AR to its usage to allow replacing ar [Marot]
|
| 765 |
+
- Add HAVE_VISIBILITY_PRAGMA in zconf.in.h for Mozilla [Randers-Pehrson]
|
| 766 |
+
- Improve inflateInit() and inflateInit2() documentation
|
| 767 |
+
- Fix structure size comment in inflate.h
|
| 768 |
+
- Change configure help option from --h* to --help [Santos]
|
| 769 |
+
|
| 770 |
+
Changes in 1.2.3 (18 July 2005)
|
| 771 |
+
- Apply security vulnerability fixes to contrib/infback9 as well
|
| 772 |
+
- Clean up some text files (carriage returns, trailing space)
|
| 773 |
+
- Update testzlib, vstudio, masmx64, and masmx86 in contrib [Vollant]
|
| 774 |
+
|
| 775 |
+
Changes in 1.2.2.4 (11 July 2005)
|
| 776 |
+
- Add inflatePrime() function for starting inflation at bit boundary
|
| 777 |
+
- Avoid some Visual C warnings in deflate.c
|
| 778 |
+
- Avoid more silly Visual C warnings in inflate.c and inftrees.c for 64-bit
|
| 779 |
+
compile
|
| 780 |
+
- Fix some spelling errors in comments [Betts]
|
| 781 |
+
- Correct inflateInit2() error return documentation in zlib.h
|
| 782 |
+
- Add zran.c example of compressed data random access to examples
|
| 783 |
+
directory, shows use of inflatePrime()
|
| 784 |
+
- Fix cast for assignments to strm->state in inflate.c and infback.c
|
| 785 |
+
- Fix zlibCompileFlags() in zutil.c to use 1L for long shifts [Oberhumer]
|
| 786 |
+
- Move declarations of gf2 functions to right place in crc32.c [Oberhumer]
|
| 787 |
+
- Add cast in trees.c t avoid a warning [Oberhumer]
|
| 788 |
+
- Avoid some warnings in fitblk.c, gun.c, gzjoin.c in examples [Oberhumer]
|
| 789 |
+
- Update make_vms.com [Zinser]
|
| 790 |
+
- Initialize state->write in inflateReset() since copied in inflate_fast()
|
| 791 |
+
- Be more strict on incomplete code sets in inflate_table() and increase
|
| 792 |
+
ENOUGH and MAXD -- this repairs a possible security vulnerability for
|
| 793 |
+
invalid inflate input. Thanks to Tavis Ormandy and Markus Oberhumer for
|
| 794 |
+
discovering the vulnerability and providing test cases
|
| 795 |
+
- Add ia64 support to configure for HP-UX [Smith]
|
| 796 |
+
- Add error return to gzread() for format or i/o error [Levin]
|
| 797 |
+
- Use malloc.h for OS/2 [Necasek]
|
| 798 |
+
|
| 799 |
+
Changes in 1.2.2.3 (27 May 2005)
|
| 800 |
+
- Replace 1U constants in inflate.c and inftrees.c for 64-bit compile
|
| 801 |
+
- Typecast fread() return values in gzio.c [Vollant]
|
| 802 |
+
- Remove trailing space in minigzip.c outmode (VC++ can't deal with it)
|
| 803 |
+
- Fix crc check bug in gzread() after gzungetc() [Heiner]
|
| 804 |
+
- Add the deflateTune() function to adjust internal compression parameters
|
| 805 |
+
- Add a fast gzip decompressor, gun.c, to examples (use of inflateBack)
|
| 806 |
+
- Remove an incorrect assertion in examples/zpipe.c
|
| 807 |
+
- Add C++ wrapper in infback9.h [Donais]
|
| 808 |
+
- Fix bug in inflateCopy() when decoding fixed codes
|
| 809 |
+
- Note in zlib.h how much deflateSetDictionary() actually uses
|
| 810 |
+
- Remove USE_DICT_HEAD in deflate.c (would mess up inflate if used)
|
| 811 |
+
- Add _WIN32_WCE to define WIN32 in zconf.in.h [Spencer]
|
| 812 |
+
- Don't include stderr.h or errno.h for _WIN32_WCE in zutil.h [Spencer]
|
| 813 |
+
- Add gzdirect() function to indicate transparent reads
|
| 814 |
+
- Update contrib/minizip [Vollant]
|
| 815 |
+
- Fix compilation of deflate.c when both ASMV and FASTEST [Oberhumer]
|
| 816 |
+
- Add casts in crc32.c to avoid warnings [Oberhumer]
|
| 817 |
+
- Add contrib/masmx64 [Vollant]
|
| 818 |
+
- Update contrib/asm586, asm686, masmx86, testzlib, vstudio [Vollant]
|
| 819 |
+
|
| 820 |
+
Changes in 1.2.2.2 (30 December 2004)
|
| 821 |
+
- Replace structure assignments in deflate.c and inflate.c with zmemcpy to
|
| 822 |
+
avoid implicit memcpy calls (portability for no-library compilation)
|
| 823 |
+
- Increase sprintf() buffer size in gzdopen() to allow for large numbers
|
| 824 |
+
- Add INFLATE_STRICT to check distances against zlib header
|
| 825 |
+
- Improve WinCE errno handling and comments [Chang]
|
| 826 |
+
- Remove comment about no gzip header processing in FAQ
|
| 827 |
+
- Add Z_FIXED strategy option to deflateInit2() to force fixed trees
|
| 828 |
+
- Add updated make_vms.com [Coghlan], update README
|
| 829 |
+
- Create a new "examples" directory, move gzappend.c there, add zpipe.c,
|
| 830 |
+
fitblk.c, gzlog.[ch], gzjoin.c, and zlib_how.html
|
| 831 |
+
- Add FAQ entry and comments in deflate.c on uninitialized memory access
|
| 832 |
+
- Add Solaris 9 make options in configure [Gilbert]
|
| 833 |
+
- Allow strerror() usage in gzio.c for STDC
|
| 834 |
+
- Fix DecompressBuf in contrib/delphi/ZLib.pas [ManChesTer]
|
| 835 |
+
- Update contrib/masmx86/inffas32.asm and gvmat32.asm [Vollant]
|
| 836 |
+
- Use z_off_t for adler32_combine() and crc32_combine() lengths
|
| 837 |
+
- Make adler32() much faster for small len
|
| 838 |
+
- Use OS_CODE in deflate() default gzip header
|
| 839 |
+
|
| 840 |
+
Changes in 1.2.2.1 (31 October 2004)
|
| 841 |
+
- Allow inflateSetDictionary() call for raw inflate
|
| 842 |
+
- Fix inflate header crc check bug for file names and comments
|
| 843 |
+
- Add deflateSetHeader() and gz_header structure for custom gzip headers
|
| 844 |
+
- Add inflateGetheader() to retrieve gzip headers
|
| 845 |
+
- Add crc32_combine() and adler32_combine() functions
|
| 846 |
+
- Add alloc_func, free_func, in_func, out_func to Z_PREFIX list
|
| 847 |
+
- Use zstreamp consistently in zlib.h (inflate_back functions)
|
| 848 |
+
- Remove GUNZIP condition from definition of inflate_mode in inflate.h
|
| 849 |
+
and in contrib/inflate86/inffast.S [Truta, Anderson]
|
| 850 |
+
- Add support for AMD64 in contrib/inflate86/inffas86.c [Anderson]
|
| 851 |
+
- Update projects/README.projects and projects/visualc6 [Truta]
|
| 852 |
+
- Update win32/DLL_FAQ.txt [Truta]
|
| 853 |
+
- Avoid warning under NO_GZCOMPRESS in gzio.c; fix typo [Truta]
|
| 854 |
+
- Deprecate Z_ASCII; use Z_TEXT instead [Truta]
|
| 855 |
+
- Use a new algorithm for setting strm->data_type in trees.c [Truta]
|
| 856 |
+
- Do not define an exit() prototype in zutil.c unless DEBUG defined
|
| 857 |
+
- Remove prototype of exit() from zutil.c, example.c, minigzip.c [Truta]
|
| 858 |
+
- Add comment in zlib.h for Z_NO_FLUSH parameter to deflate()
|
| 859 |
+
- Fix Darwin build version identification [Peterson]
|
| 860 |
+
|
| 861 |
+
Changes in 1.2.2 (3 October 2004)
|
| 862 |
+
- Update zlib.h comments on gzip in-memory processing
|
| 863 |
+
- Set adler to 1 in inflateReset() to support Java test suite [Walles]
|
| 864 |
+
- Add contrib/dotzlib [Ravn]
|
| 865 |
+
- Update win32/DLL_FAQ.txt [Truta]
|
| 866 |
+
- Update contrib/minizip [Vollant]
|
| 867 |
+
- Move contrib/visual-basic.txt to old/ [Truta]
|
| 868 |
+
- Fix assembler builds in projects/visualc6/ [Truta]
|
| 869 |
+
|
| 870 |
+
Changes in 1.2.1.2 (9 September 2004)
|
| 871 |
+
- Update INDEX file
|
| 872 |
+
- Fix trees.c to update strm->data_type (no one ever noticed!)
|
| 873 |
+
- Fix bug in error case in inflate.c, infback.c, and infback9.c [Brown]
|
| 874 |
+
- Add "volatile" to crc table flag declaration (for DYNAMIC_CRC_TABLE)
|
| 875 |
+
- Add limited multitasking protection to DYNAMIC_CRC_TABLE
|
| 876 |
+
- Add NO_vsnprintf for VMS in zutil.h [Mozilla]
|
| 877 |
+
- Don't declare strerror() under VMS [Mozilla]
|
| 878 |
+
- Add comment to DYNAMIC_CRC_TABLE to use get_crc_table() to initialize
|
| 879 |
+
- Update contrib/ada [Anisimkov]
|
| 880 |
+
- Update contrib/minizip [Vollant]
|
| 881 |
+
- Fix configure to not hardcode directories for Darwin [Peterson]
|
| 882 |
+
- Fix gzio.c to not return error on empty files [Brown]
|
| 883 |
+
- Fix indentation; update version in contrib/delphi/ZLib.pas and
|
| 884 |
+
contrib/pascal/zlibpas.pas [Truta]
|
| 885 |
+
- Update mkasm.bat in contrib/masmx86 [Truta]
|
| 886 |
+
- Update contrib/untgz [Truta]
|
| 887 |
+
- Add projects/README.projects [Truta]
|
| 888 |
+
- Add project for MS Visual C++ 6.0 in projects/visualc6 [Cadieux, Truta]
|
| 889 |
+
- Update win32/DLL_FAQ.txt [Truta]
|
| 890 |
+
- Update list of Z_PREFIX symbols in zconf.h [Randers-Pehrson, Truta]
|
| 891 |
+
- Remove an unnecessary assignment to curr in inftrees.c [Truta]
|
| 892 |
+
- Add OS/2 to exe builds in configure [Poltorak]
|
| 893 |
+
- Remove err dummy parameter in zlib.h [Kientzle]
|
| 894 |
+
|
| 895 |
+
Changes in 1.2.1.1 (9 January 2004)
|
| 896 |
+
- Update email address in README
|
| 897 |
+
- Several FAQ updates
|
| 898 |
+
- Fix a big fat bug in inftrees.c that prevented decoding valid
|
| 899 |
+
dynamic blocks with only literals and no distance codes --
|
| 900 |
+
Thanks to "Hot Emu" for the bug report and sample file
|
| 901 |
+
- Add a note to puff.c on no distance codes case
|
| 902 |
+
|
| 903 |
+
Changes in 1.2.1 (17 November 2003)
|
| 904 |
+
- Remove a tab in contrib/gzappend/gzappend.c
|
| 905 |
+
- Update some interfaces in contrib for new zlib functions
|
| 906 |
+
- Update zlib version number in some contrib entries
|
| 907 |
+
- Add Windows CE definition for ptrdiff_t in zutil.h [Mai, Truta]
|
| 908 |
+
- Support shared libraries on Hurd and KFreeBSD [Brown]
|
| 909 |
+
- Fix error in NO_DIVIDE option of adler32.c
|
| 910 |
+
|
| 911 |
+
Changes in 1.2.0.8 (4 November 2003)
|
| 912 |
+
- Update version in contrib/delphi/ZLib.pas and contrib/pascal/zlibpas.pas
|
| 913 |
+
- Add experimental NO_DIVIDE #define in adler32.c
|
| 914 |
+
- Possibly faster on some processors (let me know if it is)
|
| 915 |
+
- Correct Z_BLOCK to not return on first inflate call if no wrap
|
| 916 |
+
- Fix strm->data_type on inflate() return to correctly indicate EOB
|
| 917 |
+
- Add deflatePrime() function for appending in the middle of a byte
|
| 918 |
+
- Add contrib/gzappend for an example of appending to a stream
|
| 919 |
+
- Update win32/DLL_FAQ.txt [Truta]
|
| 920 |
+
- Delete Turbo C comment in README [Truta]
|
| 921 |
+
- Improve some indentation in zconf.h [Truta]
|
| 922 |
+
- Fix infinite loop on bad input in configure script [Church]
|
| 923 |
+
- Fix gzeof() for concatenated gzip files [Johnson]
|
| 924 |
+
- Add example to contrib/visual-basic.txt [Michael B.]
|
| 925 |
+
- Add -p to mkdir's in Makefile.in [vda]
|
| 926 |
+
- Fix configure to properly detect presence or lack of printf functions
|
| 927 |
+
- Add AS400 support [Monnerat]
|
| 928 |
+
- Add a little Cygwin support [Wilson]
|
| 929 |
+
|
| 930 |
+
Changes in 1.2.0.7 (21 September 2003)
|
| 931 |
+
- Correct some debug formats in contrib/infback9
|
| 932 |
+
- Cast a type in a debug statement in trees.c
|
| 933 |
+
- Change search and replace delimiter in configure from % to # [Beebe]
|
| 934 |
+
- Update contrib/untgz to 0.2 with various fixes [Truta]
|
| 935 |
+
- Add build support for Amiga [Nikl]
|
| 936 |
+
- Remove some directories in old that have been updated to 1.2
|
| 937 |
+
- Add dylib building for Mac OS X in configure and Makefile.in
|
| 938 |
+
- Remove old distribution stuff from Makefile
|
| 939 |
+
- Update README to point to DLL_FAQ.txt, and add comment on Mac OS X
|
| 940 |
+
- Update links in README
|
| 941 |
+
|
| 942 |
+
Changes in 1.2.0.6 (13 September 2003)
|
| 943 |
+
- Minor FAQ updates
|
| 944 |
+
- Update contrib/minizip to 1.00 [Vollant]
|
| 945 |
+
- Remove test of gz functions in example.c when GZ_COMPRESS defined [Truta]
|
| 946 |
+
- Update POSTINC comment for 68060 [Nikl]
|
| 947 |
+
- Add contrib/infback9 with deflate64 decoding (unsupported)
|
| 948 |
+
- For MVS define NO_vsnprintf and undefine FAR [van Burik]
|
| 949 |
+
- Add pragma for fdopen on MVS [van Burik]
|
| 950 |
+
|
| 951 |
+
Changes in 1.2.0.5 (8 September 2003)
|
| 952 |
+
- Add OF to inflateBackEnd() declaration in zlib.h
|
| 953 |
+
- Remember start when using gzdopen in the middle of a file
|
| 954 |
+
- Use internal off_t counters in gz* functions to properly handle seeks
|
| 955 |
+
- Perform more rigorous check for distance-too-far in inffast.c
|
| 956 |
+
- Add Z_BLOCK flush option to return from inflate at block boundary
|
| 957 |
+
- Set strm->data_type on return from inflate
|
| 958 |
+
- Indicate bits unused, if at block boundary, and if in last block
|
| 959 |
+
- Replace size_t with ptrdiff_t in crc32.c, and check for correct size
|
| 960 |
+
- Add condition so old NO_DEFLATE define still works for compatibility
|
| 961 |
+
- FAQ update regarding the Windows DLL [Truta]
|
| 962 |
+
- INDEX update: add qnx entry, remove aix entry [Truta]
|
| 963 |
+
- Install zlib.3 into mandir [Wilson]
|
| 964 |
+
- Move contrib/zlib_dll_FAQ.txt to win32/DLL_FAQ.txt; update [Truta]
|
| 965 |
+
- Adapt the zlib interface to the new DLL convention guidelines [Truta]
|
| 966 |
+
- Introduce ZLIB_WINAPI macro to allow the export of functions using
|
| 967 |
+
the WINAPI calling convention, for Visual Basic [Vollant, Truta]
|
| 968 |
+
- Update msdos and win32 scripts and makefiles [Truta]
|
| 969 |
+
- Export symbols by name, not by ordinal, in win32/zlib.def [Truta]
|
| 970 |
+
- Add contrib/ada [Anisimkov]
|
| 971 |
+
- Move asm files from contrib/vstudio/vc70_32 to contrib/asm386 [Truta]
|
| 972 |
+
- Rename contrib/asm386 to contrib/masmx86 [Truta, Vollant]
|
| 973 |
+
- Add contrib/masm686 [Truta]
|
| 974 |
+
- Fix offsets in contrib/inflate86 and contrib/masmx86/inffas32.asm
|
| 975 |
+
[Truta, Vollant]
|
| 976 |
+
- Update contrib/delphi; rename to contrib/pascal; add example [Truta]
|
| 977 |
+
- Remove contrib/delphi2; add a new contrib/delphi [Truta]
|
| 978 |
+
- Avoid inclusion of the nonstandard <memory.h> in contrib/iostream,
|
| 979 |
+
and fix some method prototypes [Truta]
|
| 980 |
+
- Fix the ZCR_SEED2 constant to avoid warnings in contrib/minizip
|
| 981 |
+
[Truta]
|
| 982 |
+
- Avoid the use of backslash (\) in contrib/minizip [Vollant]
|
| 983 |
+
- Fix file time handling in contrib/untgz; update makefiles [Truta]
|
| 984 |
+
- Update contrib/vstudio/vc70_32 to comply with the new DLL guidelines
|
| 985 |
+
[Vollant]
|
| 986 |
+
- Remove contrib/vstudio/vc15_16 [Vollant]
|
| 987 |
+
- Rename contrib/vstudio/vc70_32 to contrib/vstudio/vc7 [Truta]
|
| 988 |
+
- Update README.contrib [Truta]
|
| 989 |
+
- Invert the assignment order of match_head and s->prev[...] in
|
| 990 |
+
INSERT_STRING [Truta]
|
| 991 |
+
- Compare TOO_FAR with 32767 instead of 32768, to avoid 16-bit warnings
|
| 992 |
+
[Truta]
|
| 993 |
+
- Compare function pointers with 0, not with NULL or Z_NULL [Truta]
|
| 994 |
+
- Fix prototype of syncsearch in inflate.c [Truta]
|
| 995 |
+
- Introduce ASMINF macro to be enabled when using an ASM implementation
|
| 996 |
+
of inflate_fast [Truta]
|
| 997 |
+
- Change NO_DEFLATE to NO_GZCOMPRESS [Truta]
|
| 998 |
+
- Modify test_gzio in example.c to take a single file name as a
|
| 999 |
+
parameter [Truta]
|
| 1000 |
+
- Exit the example.c program if gzopen fails [Truta]
|
| 1001 |
+
- Add type casts around strlen in example.c [Truta]
|
| 1002 |
+
- Remove casting to sizeof in minigzip.c; give a proper type
|
| 1003 |
+
to the variable compared with SUFFIX_LEN [Truta]
|
| 1004 |
+
- Update definitions of STDC and STDC99 in zconf.h [Truta]
|
| 1005 |
+
- Synchronize zconf.h with the new Windows DLL interface [Truta]
|
| 1006 |
+
- Use SYS16BIT instead of __32BIT__ to distinguish between
|
| 1007 |
+
16- and 32-bit platforms [Truta]
|
| 1008 |
+
- Use far memory allocators in small 16-bit memory models for
|
| 1009 |
+
Turbo C [Truta]
|
| 1010 |
+
- Add info about the use of ASMV, ASMINF and ZLIB_WINAPI in
|
| 1011 |
+
zlibCompileFlags [Truta]
|
| 1012 |
+
- Cygwin has vsnprintf [Wilson]
|
| 1013 |
+
- In Windows16, OS_CODE is 0, as in MSDOS [Truta]
|
| 1014 |
+
- In Cygwin, OS_CODE is 3 (Unix), not 11 (Windows32) [Wilson]
|
| 1015 |
+
|
| 1016 |
+
Changes in 1.2.0.4 (10 August 2003)
|
| 1017 |
+
- Minor FAQ updates
|
| 1018 |
+
- Be more strict when checking inflateInit2's windowBits parameter
|
| 1019 |
+
- Change NO_GUNZIP compile option to NO_GZIP to cover deflate as well
|
| 1020 |
+
- Add gzip wrapper option to deflateInit2 using windowBits
|
| 1021 |
+
- Add updated QNX rule in configure and qnx directory [Bonnefoy]
|
| 1022 |
+
- Make inflate distance-too-far checks more rigorous
|
| 1023 |
+
- Clean up FAR usage in inflate
|
| 1024 |
+
- Add casting to sizeof() in gzio.c and minigzip.c
|
| 1025 |
+
|
| 1026 |
+
Changes in 1.2.0.3 (19 July 2003)
|
| 1027 |
+
- Fix silly error in gzungetc() implementation [Vollant]
|
| 1028 |
+
- Update contrib/minizip and contrib/vstudio [Vollant]
|
| 1029 |
+
- Fix printf format in example.c
|
| 1030 |
+
- Correct cdecl support in zconf.in.h [Anisimkov]
|
| 1031 |
+
- Minor FAQ updates
|
| 1032 |
+
|
| 1033 |
+
Changes in 1.2.0.2 (13 July 2003)
|
| 1034 |
+
- Add ZLIB_VERNUM in zlib.h for numerical preprocessor comparisons
|
| 1035 |
+
- Attempt to avoid warnings in crc32.c for pointer-int conversion
|
| 1036 |
+
- Add AIX to configure, remove aix directory [Bakker]
|
| 1037 |
+
- Add some casts to minigzip.c
|
| 1038 |
+
- Improve checking after insecure sprintf() or vsprintf() calls
|
| 1039 |
+
- Remove #elif's from crc32.c
|
| 1040 |
+
- Change leave label to inf_leave in inflate.c and infback.c to avoid
|
| 1041 |
+
library conflicts
|
| 1042 |
+
- Remove inflate gzip decoding by default--only enable gzip decoding by
|
| 1043 |
+
special request for stricter backward compatibility
|
| 1044 |
+
- Add zlibCompileFlags() function to return compilation information
|
| 1045 |
+
- More typecasting in deflate.c to avoid warnings
|
| 1046 |
+
- Remove leading underscore from _Capital #defines [Truta]
|
| 1047 |
+
- Fix configure to link shared library when testing
|
| 1048 |
+
- Add some Windows CE target adjustments [Mai]
|
| 1049 |
+
- Remove #define ZLIB_DLL in zconf.h [Vollant]
|
| 1050 |
+
- Add zlib.3 [Rodgers]
|
| 1051 |
+
- Update RFC URL in deflate.c and algorithm.txt [Mai]
|
| 1052 |
+
- Add zlib_dll_FAQ.txt to contrib [Truta]
|
| 1053 |
+
- Add UL to some constants [Truta]
|
| 1054 |
+
- Update minizip and vstudio [Vollant]
|
| 1055 |
+
- Remove vestigial NEED_DUMMY_RETURN from zconf.in.h
|
| 1056 |
+
- Expand use of NO_DUMMY_DECL to avoid all dummy structures
|
| 1057 |
+
- Added iostream3 to contrib [Schwardt]
|
| 1058 |
+
- Replace rewind() with fseek() for WinCE [Truta]
|
| 1059 |
+
- Improve setting of zlib format compression level flags
|
| 1060 |
+
- Report 0 for huffman and rle strategies and for level == 0 or 1
|
| 1061 |
+
- Report 2 only for level == 6
|
| 1062 |
+
- Only deal with 64K limit when necessary at compile time [Truta]
|
| 1063 |
+
- Allow TOO_FAR check to be turned off at compile time [Truta]
|
| 1064 |
+
- Add gzclearerr() function [Souza]
|
| 1065 |
+
- Add gzungetc() function
|
| 1066 |
+
|
| 1067 |
+
Changes in 1.2.0.1 (17 March 2003)
|
| 1068 |
+
- Add Z_RLE strategy for run-length encoding [Truta]
|
| 1069 |
+
- When Z_RLE requested, restrict matches to distance one
|
| 1070 |
+
- Update zlib.h, minigzip.c, gzopen(), gzdopen() for Z_RLE
|
| 1071 |
+
- Correct FASTEST compilation to allow level == 0
|
| 1072 |
+
- Clean up what gets compiled for FASTEST
|
| 1073 |
+
- Incorporate changes to zconf.in.h [Vollant]
|
| 1074 |
+
- Refine detection of Turbo C need for dummy returns
|
| 1075 |
+
- Refine ZLIB_DLL compilation
|
| 1076 |
+
- Include additional header file on VMS for off_t typedef
|
| 1077 |
+
- Try to use _vsnprintf where it supplants vsprintf [Vollant]
|
| 1078 |
+
- Add some casts in inffast.c
|
| 1079 |
+
- Enhance comments in zlib.h on what happens if gzprintf() tries to
|
| 1080 |
+
write more than 4095 bytes before compression
|
| 1081 |
+
- Remove unused state from inflateBackEnd()
|
| 1082 |
+
- Remove exit(0) from minigzip.c, example.c
|
| 1083 |
+
- Get rid of all those darn tabs
|
| 1084 |
+
- Add "check" target to Makefile.in that does the same thing as "test"
|
| 1085 |
+
- Add "mostlyclean" and "maintainer-clean" targets to Makefile.in
|
| 1086 |
+
- Update contrib/inflate86 [Anderson]
|
| 1087 |
+
- Update contrib/testzlib, contrib/vstudio, contrib/minizip [Vollant]
|
| 1088 |
+
- Add msdos and win32 directories with makefiles [Truta]
|
| 1089 |
+
- More additions and improvements to the FAQ
|
| 1090 |
+
|
| 1091 |
+
Changes in 1.2.0 (9 March 2003)
|
| 1092 |
+
- New and improved inflate code
|
| 1093 |
+
- About 20% faster
|
| 1094 |
+
- Does not allocate 32K window unless and until needed
|
| 1095 |
+
- Automatically detects and decompresses gzip streams
|
| 1096 |
+
- Raw inflate no longer needs an extra dummy byte at end
|
| 1097 |
+
- Added inflateBack functions using a callback interface--even faster
|
| 1098 |
+
than inflate, useful for file utilities (gzip, zip)
|
| 1099 |
+
- Added inflateCopy() function to record state for random access on
|
| 1100 |
+
externally generated deflate streams (e.g. in gzip files)
|
| 1101 |
+
- More readable code (I hope)
|
| 1102 |
+
- New and improved crc32()
|
| 1103 |
+
- About 50% faster, thanks to suggestions from Rodney Brown
|
| 1104 |
+
- Add deflateBound() and compressBound() functions
|
| 1105 |
+
- Fix memory leak in deflateInit2()
|
| 1106 |
+
- Permit setting dictionary for raw deflate (for parallel deflate)
|
| 1107 |
+
- Fix const declaration for gzwrite()
|
| 1108 |
+
- Check for some malloc() failures in gzio.c
|
| 1109 |
+
- Fix bug in gzopen() on single-byte file 0x1f
|
| 1110 |
+
- Fix bug in gzread() on concatenated file with 0x1f at end of buffer
|
| 1111 |
+
and next buffer doesn't start with 0x8b
|
| 1112 |
+
- Fix uncompress() to return Z_DATA_ERROR on truncated input
|
| 1113 |
+
- Free memory at end of example.c
|
| 1114 |
+
- Remove MAX #define in trees.c (conflicted with some libraries)
|
| 1115 |
+
- Fix static const's in deflate.c, gzio.c, and zutil.[ch]
|
| 1116 |
+
- Declare malloc() and free() in gzio.c if STDC not defined
|
| 1117 |
+
- Use malloc() instead of calloc() in zutil.c if int big enough
|
| 1118 |
+
- Define STDC for AIX
|
| 1119 |
+
- Add aix/ with approach for compiling shared library on AIX
|
| 1120 |
+
- Add HP-UX support for shared libraries in configure
|
| 1121 |
+
- Add OpenUNIX support for shared libraries in configure
|
| 1122 |
+
- Use $cc instead of gcc to build shared library
|
| 1123 |
+
- Make prefix directory if needed when installing
|
| 1124 |
+
- Correct Macintosh avoidance of typedef Byte in zconf.h
|
| 1125 |
+
- Correct Turbo C memory allocation when under Linux
|
| 1126 |
+
- Use libz.a instead of -lz in Makefile (assure use of compiled library)
|
| 1127 |
+
- Update configure to check for snprintf or vsnprintf functions and their
|
| 1128 |
+
return value, warn during make if using an insecure function
|
| 1129 |
+
- Fix configure problem with compile-time knowledge of HAVE_UNISTD_H that
|
| 1130 |
+
is lost when library is used--resolution is to build new zconf.h
|
| 1131 |
+
- Documentation improvements (in zlib.h):
|
| 1132 |
+
- Document raw deflate and inflate
|
| 1133 |
+
- Update RFCs URL
|
| 1134 |
+
- Point out that zlib and gzip formats are different
|
| 1135 |
+
- Note that Z_BUF_ERROR is not fatal
|
| 1136 |
+
- Document string limit for gzprintf() and possible buffer overflow
|
| 1137 |
+
- Note requirement on avail_out when flushing
|
| 1138 |
+
- Note permitted values of flush parameter of inflate()
|
| 1139 |
+
- Add some FAQs (and even answers) to the FAQ
|
| 1140 |
+
- Add contrib/inflate86/ for x86 faster inflate
|
| 1141 |
+
- Add contrib/blast/ for PKWare Data Compression Library decompression
|
| 1142 |
+
- Add contrib/puff/ simple inflate for deflate format description
|
| 1143 |
+
|
| 1144 |
+
Changes in 1.1.4 (11 March 2002)
|
| 1145 |
+
- ZFREE was repeated on same allocation on some error conditions
|
| 1146 |
+
This creates a security problem described in
|
| 1147 |
+
http://www.zlib.org/advisory-2002-03-11.txt
|
| 1148 |
+
- Returned incorrect error (Z_MEM_ERROR) on some invalid data
|
| 1149 |
+
- Avoid accesses before window for invalid distances with inflate window
|
| 1150 |
+
less than 32K
|
| 1151 |
+
- force windowBits > 8 to avoid a bug in the encoder for a window size
|
| 1152 |
+
of 256 bytes. (A complete fix will be available in 1.1.5)
|
| 1153 |
+
|
| 1154 |
+
Changes in 1.1.3 (9 July 1998)
|
| 1155 |
+
- fix "an inflate input buffer bug that shows up on rare but persistent
|
| 1156 |
+
occasions" (Mark)
|
| 1157 |
+
- fix gzread and gztell for concatenated .gz files (Didier Le Botlan)
|
| 1158 |
+
- fix gzseek(..., SEEK_SET) in write mode
|
| 1159 |
+
- fix crc check after a gzeek (Frank Faubert)
|
| 1160 |
+
- fix miniunzip when the last entry in a zip file is itself a zip file
|
| 1161 |
+
(J Lillge)
|
| 1162 |
+
- add contrib/asm586 and contrib/asm686 (Brian Raiter)
|
| 1163 |
+
See http://www.muppetlabs.com/~breadbox/software/assembly.html
|
| 1164 |
+
- add support for Delphi 3 in contrib/delphi (Bob Dellaca)
|
| 1165 |
+
- add support for C++Builder 3 and Delphi 3 in contrib/delphi2 (Davide Moretti)
|
| 1166 |
+
- do not exit prematurely in untgz if 0 at start of block (Magnus Holmgren)
|
| 1167 |
+
- use macro EXTERN instead of extern to support DLL for BeOS (Sander Stoks)
|
| 1168 |
+
- added a FAQ file
|
| 1169 |
+
|
| 1170 |
+
- Support gzdopen on Mac with Metrowerks (Jason Linhart)
|
| 1171 |
+
- Do not redefine Byte on Mac (Brad Pettit & Jason Linhart)
|
| 1172 |
+
- define SEEK_END too if SEEK_SET is not defined (Albert Chin-A-Young)
|
| 1173 |
+
- avoid some warnings with Borland C (Tom Tanner)
|
| 1174 |
+
- fix a problem in contrib/minizip/zip.c for 16-bit MSDOS (Gilles Vollant)
|
| 1175 |
+
- emulate utime() for WIN32 in contrib/untgz (Gilles Vollant)
|
| 1176 |
+
- allow several arguments to configure (Tim Mooney, Frodo Looijaard)
|
| 1177 |
+
- use libdir and includedir in Makefile.in (Tim Mooney)
|
| 1178 |
+
- support shared libraries on OSF1 V4 (Tim Mooney)
|
| 1179 |
+
- remove so_locations in "make clean" (Tim Mooney)
|
| 1180 |
+
- fix maketree.c compilation error (Glenn, Mark)
|
| 1181 |
+
- Python interface to zlib now in Python 1.5 (Jeremy Hylton)
|
| 1182 |
+
- new Makefile.riscos (Rich Walker)
|
| 1183 |
+
- initialize static descriptors in trees.c for embedded targets (Nick Smith)
|
| 1184 |
+
- use "foo-gz" in example.c for RISCOS and VMS (Nick Smith)
|
| 1185 |
+
- add the OS/2 files in Makefile.in too (Andrew Zabolotny)
|
| 1186 |
+
- fix fdopen and halloc macros for Microsoft C 6.0 (Tom Lane)
|
| 1187 |
+
- fix maketree.c to allow clean compilation of inffixed.h (Mark)
|
| 1188 |
+
- fix parameter check in deflateCopy (Gunther Nikl)
|
| 1189 |
+
- cleanup trees.c, use compressed_len only in debug mode (Christian Spieler)
|
| 1190 |
+
- Many portability patches by Christian Spieler:
|
| 1191 |
+
. zutil.c, zutil.h: added "const" for zmem*
|
| 1192 |
+
. Make_vms.com: fixed some typos
|
| 1193 |
+
. Make_vms.com: msdos/Makefile.*: removed zutil.h from some dependency lists
|
| 1194 |
+
. msdos/Makefile.msc: remove "default rtl link library" info from obj files
|
| 1195 |
+
. msdos/Makefile.*: use model-dependent name for the built zlib library
|
| 1196 |
+
. msdos/Makefile.emx, nt/Makefile.emx, nt/Makefile.gcc:
|
| 1197 |
+
new makefiles, for emx (DOS/OS2), emx&rsxnt and mingw32 (Windows 9x / NT)
|
| 1198 |
+
- use define instead of typedef for Bytef also for MSC small/medium (Tom Lane)
|
| 1199 |
+
- replace __far with _far for better portability (Christian Spieler, Tom Lane)
|
| 1200 |
+
- fix test for errno.h in configure (Tim Newsham)
|
| 1201 |
+
|
| 1202 |
+
Changes in 1.1.2 (19 March 98)
|
| 1203 |
+
- added contrib/minzip, mini zip and unzip based on zlib (Gilles Vollant)
|
| 1204 |
+
See http://www.winimage.com/zLibDll/unzip.html
|
| 1205 |
+
- preinitialize the inflate tables for fixed codes, to make the code
|
| 1206 |
+
completely thread safe (Mark)
|
| 1207 |
+
- some simplifications and slight speed-up to the inflate code (Mark)
|
| 1208 |
+
- fix gzeof on non-compressed files (Allan Schrum)
|
| 1209 |
+
- add -std1 option in configure for OSF1 to fix gzprintf (Martin Mokrejs)
|
| 1210 |
+
- use default value of 4K for Z_BUFSIZE for 16-bit MSDOS (Tim Wegner + Glenn)
|
| 1211 |
+
- added os2/Makefile.def and os2/zlib.def (Andrew Zabolotny)
|
| 1212 |
+
- add shared lib support for UNIX_SV4.2MP (MATSUURA Takanori)
|
| 1213 |
+
- do not wrap extern "C" around system includes (Tom Lane)
|
| 1214 |
+
- mention zlib binding for TCL in README (Andreas Kupries)
|
| 1215 |
+
- added amiga/Makefile.pup for Amiga powerUP SAS/C PPC (Andreas Kleinert)
|
| 1216 |
+
- allow "make install prefix=..." even after configure (Glenn Randers-Pehrson)
|
| 1217 |
+
- allow "configure --prefix $HOME" (Tim Mooney)
|
| 1218 |
+
- remove warnings in example.c and gzio.c (Glenn Randers-Pehrson)
|
| 1219 |
+
- move Makefile.sas to amiga/Makefile.sas
|
| 1220 |
+
|
| 1221 |
+
Changes in 1.1.1 (27 Feb 98)
|
| 1222 |
+
- fix macros _tr_tally_* in deflate.h for debug mode (Glenn Randers-Pehrson)
|
| 1223 |
+
- remove block truncation heuristic which had very marginal effect for zlib
|
| 1224 |
+
(smaller lit_bufsize than in gzip 1.2.4) and degraded a little the
|
| 1225 |
+
compression ratio on some files. This also allows inlining _tr_tally for
|
| 1226 |
+
matches in deflate_slow
|
| 1227 |
+
- added msdos/Makefile.w32 for WIN32 Microsoft Visual C++ (Bob Frazier)
|
| 1228 |
+
|
| 1229 |
+
Changes in 1.1.0 (24 Feb 98)
|
| 1230 |
+
- do not return STREAM_END prematurely in inflate (John Bowler)
|
| 1231 |
+
- revert to the zlib 1.0.8 inflate to avoid the gcc 2.8.0 bug (Jeremy Buhler)
|
| 1232 |
+
- compile with -DFASTEST to get compression code optimized for speed only
|
| 1233 |
+
- in minigzip, try mmap'ing the input file first (Miguel Albrecht)
|
| 1234 |
+
- increase size of I/O buffers in minigzip.c and gzio.c (not a big gain
|
| 1235 |
+
on Sun but significant on HP)
|
| 1236 |
+
|
| 1237 |
+
- add a pointer to experimental unzip library in README (Gilles Vollant)
|
| 1238 |
+
- initialize variable gcc in configure (Chris Herborth)
|
| 1239 |
+
|
| 1240 |
+
Changes in 1.0.9 (17 Feb 1998)
|
| 1241 |
+
- added gzputs and gzgets functions
|
| 1242 |
+
- do not clear eof flag in gzseek (Mark Diekhans)
|
| 1243 |
+
- fix gzseek for files in transparent mode (Mark Diekhans)
|
| 1244 |
+
- do not assume that vsprintf returns the number of bytes written (Jens Krinke)
|
| 1245 |
+
- replace EXPORT with ZEXPORT to avoid conflict with other programs
|
| 1246 |
+
- added compress2 in zconf.h, zlib.def, zlib.dnt
|
| 1247 |
+
- new asm code from Gilles Vollant in contrib/asm386
|
| 1248 |
+
- simplify the inflate code (Mark):
|
| 1249 |
+
. Replace ZALLOC's in huft_build() with single ZALLOC in inflate_blocks_new()
|
| 1250 |
+
. ZALLOC the length list in inflate_trees_fixed() instead of using stack
|
| 1251 |
+
. ZALLOC the value area for huft_build() instead of using stack
|
| 1252 |
+
. Simplify Z_FINISH check in inflate()
|
| 1253 |
+
|
| 1254 |
+
- Avoid gcc 2.8.0 comparison bug a little differently than zlib 1.0.8
|
| 1255 |
+
- in inftrees.c, avoid cc -O bug on HP (Farshid Elahi)
|
| 1256 |
+
- in zconf.h move the ZLIB_DLL stuff earlier to avoid problems with
|
| 1257 |
+
the declaration of FAR (Gilles Vollant)
|
| 1258 |
+
- install libz.so* with mode 755 (executable) instead of 644 (Marc Lehmann)
|
| 1259 |
+
- read_buf buf parameter of type Bytef* instead of charf*
|
| 1260 |
+
- zmemcpy parameters are of type Bytef*, not charf* (Joseph Strout)
|
| 1261 |
+
- do not redeclare unlink in minigzip.c for WIN32 (John Bowler)
|
| 1262 |
+
- fix check for presence of directories in "make install" (Ian Willis)
|
| 1263 |
+
|
| 1264 |
+
Changes in 1.0.8 (27 Jan 1998)
|
| 1265 |
+
- fixed offsets in contrib/asm386/gvmat32.asm (Gilles Vollant)
|
| 1266 |
+
- fix gzgetc and gzputc for big endian systems (Markus Oberhumer)
|
| 1267 |
+
- added compress2() to allow setting the compression level
|
| 1268 |
+
- include sys/types.h to get off_t on some systems (Marc Lehmann & QingLong)
|
| 1269 |
+
- use constant arrays for the static trees in trees.c instead of computing
|
| 1270 |
+
them at run time (thanks to Ken Raeburn for this suggestion). To create
|
| 1271 |
+
trees.h, compile with GEN_TREES_H and run "make test"
|
| 1272 |
+
- check return code of example in "make test" and display result
|
| 1273 |
+
- pass minigzip command line options to file_compress
|
| 1274 |
+
- simplifying code of inflateSync to avoid gcc 2.8 bug
|
| 1275 |
+
|
| 1276 |
+
- support CC="gcc -Wall" in configure -s (QingLong)
|
| 1277 |
+
- avoid a flush caused by ftell in gzopen for write mode (Ken Raeburn)
|
| 1278 |
+
- fix test for shared library support to avoid compiler warnings
|
| 1279 |
+
- zlib.lib -> zlib.dll in msdos/zlib.rc (Gilles Vollant)
|
| 1280 |
+
- check for TARGET_OS_MAC in addition to MACOS (Brad Pettit)
|
| 1281 |
+
- do not use fdopen for Metrowerks on Mac (Brad Pettit))
|
| 1282 |
+
- add checks for gzputc and gzputc in example.c
|
| 1283 |
+
- avoid warnings in gzio.c and deflate.c (Andreas Kleinert)
|
| 1284 |
+
- use const for the CRC table (Ken Raeburn)
|
| 1285 |
+
- fixed "make uninstall" for shared libraries
|
| 1286 |
+
- use Tracev instead of Trace in infblock.c
|
| 1287 |
+
- in example.c use correct compressed length for test_sync
|
| 1288 |
+
- suppress +vnocompatwarnings in configure for HPUX (not always supported)
|
| 1289 |
+
|
| 1290 |
+
Changes in 1.0.7 (20 Jan 1998)
|
| 1291 |
+
- fix gzseek which was broken in write mode
|
| 1292 |
+
- return error for gzseek to negative absolute position
|
| 1293 |
+
- fix configure for Linux (Chun-Chung Chen)
|
| 1294 |
+
- increase stack space for MSC (Tim Wegner)
|
| 1295 |
+
- get_crc_table and inflateSyncPoint are EXPORTed (Gilles Vollant)
|
| 1296 |
+
- define EXPORTVA for gzprintf (Gilles Vollant)
|
| 1297 |
+
- added man page zlib.3 (Rick Rodgers)
|
| 1298 |
+
- for contrib/untgz, fix makedir() and improve Makefile
|
| 1299 |
+
|
| 1300 |
+
- check gzseek in write mode in example.c
|
| 1301 |
+
- allocate extra buffer for seeks only if gzseek is actually called
|
| 1302 |
+
- avoid signed/unsigned comparisons (Tim Wegner, Gilles Vollant)
|
| 1303 |
+
- add inflateSyncPoint in zconf.h
|
| 1304 |
+
- fix list of exported functions in nt/zlib.dnt and mdsos/zlib.def
|
| 1305 |
+
|
| 1306 |
+
Changes in 1.0.6 (19 Jan 1998)
|
| 1307 |
+
- add functions gzprintf, gzputc, gzgetc, gztell, gzeof, gzseek, gzrewind and
|
| 1308 |
+
gzsetparams (thanks to Roland Giersig and Kevin Ruland for some of this code)
|
| 1309 |
+
- Fix a deflate bug occurring only with compression level 0 (thanks to
|
| 1310 |
+
Andy Buckler for finding this one)
|
| 1311 |
+
- In minigzip, pass transparently also the first byte for .Z files
|
| 1312 |
+
- return Z_BUF_ERROR instead of Z_OK if output buffer full in uncompress()
|
| 1313 |
+
- check Z_FINISH in inflate (thanks to Marc Schluper)
|
| 1314 |
+
- Implement deflateCopy (thanks to Adam Costello)
|
| 1315 |
+
- make static libraries by default in configure, add --shared option
|
| 1316 |
+
- move MSDOS or Windows specific files to directory msdos
|
| 1317 |
+
- suppress the notion of partial flush to simplify the interface
|
| 1318 |
+
(but the symbol Z_PARTIAL_FLUSH is kept for compatibility with 1.0.4)
|
| 1319 |
+
- suppress history buffer provided by application to simplify the interface
|
| 1320 |
+
(this feature was not implemented anyway in 1.0.4)
|
| 1321 |
+
- next_in and avail_in must be initialized before calling inflateInit or
|
| 1322 |
+
inflateInit2
|
| 1323 |
+
- add EXPORT in all exported functions (for Windows DLL)
|
| 1324 |
+
- added Makefile.nt (thanks to Stephen Williams)
|
| 1325 |
+
- added the unsupported "contrib" directory:
|
| 1326 |
+
contrib/asm386/ by Gilles Vollant <info@winimage.com>
|
| 1327 |
+
386 asm code replacing longest_match()
|
| 1328 |
+
contrib/iostream/ by Kevin Ruland <kevin@rodin.wustl.edu>
|
| 1329 |
+
A C++ I/O streams interface to the zlib gz* functions
|
| 1330 |
+
contrib/iostream2/ by Tyge Løvset <Tyge.Lovset@cmr.no>
|
| 1331 |
+
Another C++ I/O streams interface
|
| 1332 |
+
contrib/untgz/ by "Pedro A. Aranda Guti\irrez" <paag@tid.es>
|
| 1333 |
+
A very simple tar.gz file extractor using zlib
|
| 1334 |
+
contrib/visual-basic.txt by Carlos Rios <c_rios@sonda.cl>
|
| 1335 |
+
How to use compress(), uncompress() and the gz* functions from VB
|
| 1336 |
+
- pass params -f (filtered data), -h (huffman only), -1 to -9 (compression
|
| 1337 |
+
level) in minigzip (thanks to Tom Lane)
|
| 1338 |
+
|
| 1339 |
+
- use const for rommable constants in deflate
|
| 1340 |
+
- added test for gzseek and gztell in example.c
|
| 1341 |
+
- add undocumented function inflateSyncPoint() (hack for Paul Mackerras)
|
| 1342 |
+
- add undocumented function zError to convert error code to string
|
| 1343 |
+
(for Tim Smithers)
|
| 1344 |
+
- Allow compilation of gzio with -DNO_DEFLATE to avoid the compression code
|
| 1345 |
+
- Use default memcpy for Symantec MSDOS compiler
|
| 1346 |
+
- Add EXPORT keyword for check_func (needed for Windows DLL)
|
| 1347 |
+
- add current directory to LD_LIBRARY_PATH for "make test"
|
| 1348 |
+
- create also a link for libz.so.1
|
| 1349 |
+
- added support for FUJITSU UXP/DS (thanks to Toshiaki Nomura)
|
| 1350 |
+
- use $(SHAREDLIB) instead of libz.so in Makefile.in (for HPUX)
|
| 1351 |
+
- added -soname for Linux in configure (Chun-Chung Chen,
|
| 1352 |
+
- assign numbers to the exported functions in zlib.def (for Windows DLL)
|
| 1353 |
+
- add advice in zlib.h for best usage of deflateSetDictionary
|
| 1354 |
+
- work around compiler bug on Atari (cast Z_NULL in call of s->checkfn)
|
| 1355 |
+
- allow compilation with ANSI keywords only enabled for TurboC in large model
|
| 1356 |
+
- avoid "versionString"[0] (Borland bug)
|
| 1357 |
+
- add NEED_DUMMY_RETURN for Borland
|
| 1358 |
+
- use variable z_verbose for tracing in debug mode (L. Peter Deutsch)
|
| 1359 |
+
- allow compilation with CC
|
| 1360 |
+
- defined STDC for OS/2 (David Charlap)
|
| 1361 |
+
- limit external names to 8 chars for MVS (Thomas Lund)
|
| 1362 |
+
- in minigzip.c, use static buffers only for 16-bit systems
|
| 1363 |
+
- fix suffix check for "minigzip -d foo.gz"
|
| 1364 |
+
- do not return an error for the 2nd of two consecutive gzflush() (Felix Lee)
|
| 1365 |
+
- use _fdopen instead of fdopen for MSC >= 6.0 (Thomas Fanslau)
|
| 1366 |
+
- added makelcc.bat for lcc-win32 (Tom St Denis)
|
| 1367 |
+
- in Makefile.dj2, use copy and del instead of install and rm (Frank Donahoe)
|
| 1368 |
+
- Avoid expanded $Id$. Use "rcs -kb" or "cvs admin -kb" to avoid Id expansion
|
| 1369 |
+
- check for unistd.h in configure (for off_t)
|
| 1370 |
+
- remove useless check parameter in inflate_blocks_free
|
| 1371 |
+
- avoid useless assignment of s->check to itself in inflate_blocks_new
|
| 1372 |
+
- do not flush twice in gzclose (thanks to Ken Raeburn)
|
| 1373 |
+
- rename FOPEN as F_OPEN to avoid clash with /usr/include/sys/file.h
|
| 1374 |
+
- use NO_ERRNO_H instead of enumeration of operating systems with errno.h
|
| 1375 |
+
- work around buggy fclose on pipes for HP/UX
|
| 1376 |
+
- support zlib DLL with BORLAND C++ 5.0 (thanks to Glenn Randers-Pehrson)
|
| 1377 |
+
- fix configure if CC is already equal to gcc
|
| 1378 |
+
|
| 1379 |
+
Changes in 1.0.5 (3 Jan 98)
|
| 1380 |
+
- Fix inflate to terminate gracefully when fed corrupted or invalid data
|
| 1381 |
+
- Use const for rommable constants in inflate
|
| 1382 |
+
- Eliminate memory leaks on error conditions in inflate
|
| 1383 |
+
- Removed some vestigial code in inflate
|
| 1384 |
+
- Update web address in README
|
| 1385 |
+
|
| 1386 |
+
Changes in 1.0.4 (24 Jul 96)
|
| 1387 |
+
- In very rare conditions, deflate(s, Z_FINISH) could fail to produce an EOF
|
| 1388 |
+
bit, so the decompressor could decompress all the correct data but went
|
| 1389 |
+
on to attempt decompressing extra garbage data. This affected minigzip too
|
| 1390 |
+
- zlibVersion and gzerror return const char* (needed for DLL)
|
| 1391 |
+
- port to RISCOS (no fdopen, no multiple dots, no unlink, no fileno)
|
| 1392 |
+
- use z_error only for DEBUG (avoid problem with DLLs)
|
| 1393 |
+
|
| 1394 |
+
Changes in 1.0.3 (2 Jul 96)
|
| 1395 |
+
- use z_streamp instead of z_stream *, which is now a far pointer in MSDOS
|
| 1396 |
+
small and medium models; this makes the library incompatible with previous
|
| 1397 |
+
versions for these models. (No effect in large model or on other systems.)
|
| 1398 |
+
- return OK instead of BUF_ERROR if previous deflate call returned with
|
| 1399 |
+
avail_out as zero but there is nothing to do
|
| 1400 |
+
- added memcmp for non STDC compilers
|
| 1401 |
+
- define NO_DUMMY_DECL for more Mac compilers (.h files merged incorrectly)
|
| 1402 |
+
- define __32BIT__ if __386__ or i386 is defined (pb. with Watcom and SCO)
|
| 1403 |
+
- better check for 16-bit mode MSC (avoids problem with Symantec)
|
| 1404 |
+
|
| 1405 |
+
Changes in 1.0.2 (23 May 96)
|
| 1406 |
+
- added Windows DLL support
|
| 1407 |
+
- added a function zlibVersion (for the DLL support)
|
| 1408 |
+
- fixed declarations using Bytef in infutil.c (pb with MSDOS medium model)
|
| 1409 |
+
- Bytef is define's instead of typedef'd only for Borland C
|
| 1410 |
+
- avoid reading uninitialized memory in example.c
|
| 1411 |
+
- mention in README that the zlib format is now RFC1950
|
| 1412 |
+
- updated Makefile.dj2
|
| 1413 |
+
- added algorithm.doc
|
| 1414 |
+
|
| 1415 |
+
Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion]
|
| 1416 |
+
- fix array overlay in deflate.c which sometimes caused bad compressed data
|
| 1417 |
+
- fix inflate bug with empty stored block
|
| 1418 |
+
- fix MSDOS medium model which was broken in 0.99
|
| 1419 |
+
- fix deflateParams() which could generate bad compressed data
|
| 1420 |
+
- Bytef is define'd instead of typedef'ed (work around Borland bug)
|
| 1421 |
+
- added an INDEX file
|
| 1422 |
+
- new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32),
|
| 1423 |
+
Watcom (Makefile.wat), Amiga SAS/C (Makefile.sas)
|
| 1424 |
+
- speed up adler32 for modern machines without auto-increment
|
| 1425 |
+
- added -ansi for IRIX in configure
|
| 1426 |
+
- static_init_done in trees.c is an int
|
| 1427 |
+
- define unlink as delete for VMS
|
| 1428 |
+
- fix configure for QNX
|
| 1429 |
+
- add configure branch for SCO and HPUX
|
| 1430 |
+
- avoid many warnings (unused variables, dead assignments, etc...)
|
| 1431 |
+
- no fdopen for BeOS
|
| 1432 |
+
- fix the Watcom fix for 32 bit mode (define FAR as empty)
|
| 1433 |
+
- removed redefinition of Byte for MKWERKS
|
| 1434 |
+
- work around an MWKERKS bug (incorrect merge of all .h files)
|
| 1435 |
+
|
| 1436 |
+
Changes in 0.99 (27 Jan 96)
|
| 1437 |
+
- allow preset dictionary shared between compressor and decompressor
|
| 1438 |
+
- allow compression level 0 (no compression)
|
| 1439 |
+
- add deflateParams in zlib.h: allow dynamic change of compression level
|
| 1440 |
+
and compression strategy
|
| 1441 |
+
- test large buffers and deflateParams in example.c
|
| 1442 |
+
- add optional "configure" to build zlib as a shared library
|
| 1443 |
+
- suppress Makefile.qnx, use configure instead
|
| 1444 |
+
- fixed deflate for 64-bit systems (detected on Cray)
|
| 1445 |
+
- fixed inflate_blocks for 64-bit systems (detected on Alpha)
|
| 1446 |
+
- declare Z_DEFLATED in zlib.h (possible parameter for deflateInit2)
|
| 1447 |
+
- always return Z_BUF_ERROR when deflate() has nothing to do
|
| 1448 |
+
- deflateInit and inflateInit are now macros to allow version checking
|
| 1449 |
+
- prefix all global functions and types with z_ with -DZ_PREFIX
|
| 1450 |
+
- make falloc completely reentrant (inftrees.c)
|
| 1451 |
+
- fixed very unlikely race condition in ct_static_init
|
| 1452 |
+
- free in reverse order of allocation to help memory manager
|
| 1453 |
+
- use zlib-1.0/* instead of zlib/* inside the tar.gz
|
| 1454 |
+
- make zlib warning-free with "gcc -O3 -Wall -Wwrite-strings -Wpointer-arith
|
| 1455 |
+
-Wconversion -Wstrict-prototypes -Wmissing-prototypes"
|
| 1456 |
+
- allow gzread on concatenated .gz files
|
| 1457 |
+
- deflateEnd now returns Z_DATA_ERROR if it was premature
|
| 1458 |
+
- deflate is finally (?) fully deterministic (no matches beyond end of input)
|
| 1459 |
+
- Document Z_SYNC_FLUSH
|
| 1460 |
+
- add uninstall in Makefile
|
| 1461 |
+
- Check for __cpluplus in zlib.h
|
| 1462 |
+
- Better test in ct_align for partial flush
|
| 1463 |
+
- avoid harmless warnings for Borland C++
|
| 1464 |
+
- initialize hash_head in deflate.c
|
| 1465 |
+
- avoid warning on fdopen (gzio.c) for HP cc -Aa
|
| 1466 |
+
- include stdlib.h for STDC compilers
|
| 1467 |
+
- include errno.h for Cray
|
| 1468 |
+
- ignore error if ranlib doesn't exist
|
| 1469 |
+
- call ranlib twice for NeXTSTEP
|
| 1470 |
+
- use exec_prefix instead of prefix for libz.a
|
| 1471 |
+
- renamed ct_* as _tr_* to avoid conflict with applications
|
| 1472 |
+
- clear z->msg in inflateInit2 before any error return
|
| 1473 |
+
- initialize opaque in example.c, gzio.c, deflate.c and inflate.c
|
| 1474 |
+
- fixed typo in zconf.h (_GNUC__ => __GNUC__)
|
| 1475 |
+
- check for WIN32 in zconf.h and zutil.c (avoid farmalloc in 32-bit mode)
|
| 1476 |
+
- fix typo in Make_vms.com (f$trnlnm -> f$getsyi)
|
| 1477 |
+
- in fcalloc, normalize pointer if size > 65520 bytes
|
| 1478 |
+
- don't use special fcalloc for 32 bit Borland C++
|
| 1479 |
+
- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc.
|
| 1480 |
+
- use Z_BINARY instead of BINARY
|
| 1481 |
+
- document that gzclose after gzdopen will close the file
|
| 1482 |
+
- allow "a" as mode in gzopen
|
| 1483 |
+
- fix error checking in gzread
|
| 1484 |
+
- allow skipping .gz extra-field on pipes
|
| 1485 |
+
- added reference to Perl interface in README
|
| 1486 |
+
- put the crc table in FAR data (I dislike more and more the medium model :)
|
| 1487 |
+
- added get_crc_table
|
| 1488 |
+
- added a dimension to all arrays (Borland C can't count)
|
| 1489 |
+
- workaround Borland C bug in declaration of inflate_codes_new & inflate_fast
|
| 1490 |
+
- guard against multiple inclusion of *.h (for precompiled header on Mac)
|
| 1491 |
+
- Watcom C pretends to be Microsoft C small model even in 32 bit mode
|
| 1492 |
+
- don't use unsized arrays to avoid silly warnings by Visual C++:
|
| 1493 |
+
warning C4746: 'inflate_mask' : unsized array treated as '__far'
|
| 1494 |
+
(what's wrong with far data in far model?)
|
| 1495 |
+
- define enum out of inflate_blocks_state to allow compilation with C++
|
| 1496 |
+
|
| 1497 |
+
Changes in 0.95 (16 Aug 95)
|
| 1498 |
+
- fix MSDOS small and medium model (now easier to adapt to any compiler)
|
| 1499 |
+
- inlined send_bits
|
| 1500 |
+
- fix the final (:-) bug for deflate with flush (output was correct but
|
| 1501 |
+
not completely flushed in rare occasions)
|
| 1502 |
+
- default window size is same for compression and decompression
|
| 1503 |
+
(it's now sufficient to set MAX_WBITS in zconf.h)
|
| 1504 |
+
- voidp -> voidpf and voidnp -> voidp (for consistency with other
|
| 1505 |
+
typedefs and because voidnp was not near in large model)
|
| 1506 |
+
|
| 1507 |
+
Changes in 0.94 (13 Aug 95)
|
| 1508 |
+
- support MSDOS medium model
|
| 1509 |
+
- fix deflate with flush (could sometimes generate bad output)
|
| 1510 |
+
- fix deflateReset (zlib header was incorrectly suppressed)
|
| 1511 |
+
- added support for VMS
|
| 1512 |
+
- allow a compression level in gzopen()
|
| 1513 |
+
- gzflush now calls fflush
|
| 1514 |
+
- For deflate with flush, flush even if no more input is provided
|
| 1515 |
+
- rename libgz.a as libz.a
|
| 1516 |
+
- avoid complex expression in infcodes.c triggering Turbo C bug
|
| 1517 |
+
- work around a problem with gcc on Alpha (in INSERT_STRING)
|
| 1518 |
+
- don't use inline functions (problem with some gcc versions)
|
| 1519 |
+
- allow renaming of Byte, uInt, etc... with #define
|
| 1520 |
+
- avoid warning about (unused) pointer before start of array in deflate.c
|
| 1521 |
+
- avoid various warnings in gzio.c, example.c, infblock.c, adler32.c, zutil.c
|
| 1522 |
+
- avoid reserved word 'new' in trees.c
|
| 1523 |
+
|
| 1524 |
+
Changes in 0.93 (25 June 95)
|
| 1525 |
+
- temporarily disable inline functions
|
| 1526 |
+
- make deflate deterministic
|
| 1527 |
+
- give enough lookahead for PARTIAL_FLUSH
|
| 1528 |
+
- Set binary mode for stdin/stdout in minigzip.c for OS/2
|
| 1529 |
+
- don't even use signed char in inflate (not portable enough)
|
| 1530 |
+
- fix inflate memory leak for segmented architectures
|
| 1531 |
+
|
| 1532 |
+
Changes in 0.92 (3 May 95)
|
| 1533 |
+
- don't assume that char is signed (problem on SGI)
|
| 1534 |
+
- Clear bit buffer when starting a stored block
|
| 1535 |
+
- no memcpy on Pyramid
|
| 1536 |
+
- suppressed inftest.c
|
| 1537 |
+
- optimized fill_window, put longest_match inline for gcc
|
| 1538 |
+
- optimized inflate on stored blocks
|
| 1539 |
+
- untabify all sources to simplify patches
|
| 1540 |
+
|
| 1541 |
+
Changes in 0.91 (2 May 95)
|
| 1542 |
+
- Default MEM_LEVEL is 8 (not 9 for Unix) as documented in zlib.h
|
| 1543 |
+
- Document the memory requirements in zconf.h
|
| 1544 |
+
- added "make install"
|
| 1545 |
+
- fix sync search logic in inflateSync
|
| 1546 |
+
- deflate(Z_FULL_FLUSH) now works even if output buffer too short
|
| 1547 |
+
- after inflateSync, don't scare people with just "lo world"
|
| 1548 |
+
- added support for DJGPP
|
| 1549 |
+
|
| 1550 |
+
Changes in 0.9 (1 May 95)
|
| 1551 |
+
- don't assume that zalloc clears the allocated memory (the TurboC bug
|
| 1552 |
+
was Mark's bug after all :)
|
| 1553 |
+
- let again gzread copy uncompressed data unchanged (was working in 0.71)
|
| 1554 |
+
- deflate(Z_FULL_FLUSH), inflateReset and inflateSync are now fully implemented
|
| 1555 |
+
- added a test of inflateSync in example.c
|
| 1556 |
+
- moved MAX_WBITS to zconf.h because users might want to change that
|
| 1557 |
+
- document explicitly that zalloc(64K) on MSDOS must return a normalized
|
| 1558 |
+
pointer (zero offset)
|
| 1559 |
+
- added Makefiles for Microsoft C, Turbo C, Borland C++
|
| 1560 |
+
- faster crc32()
|
| 1561 |
+
|
| 1562 |
+
Changes in 0.8 (29 April 95)
|
| 1563 |
+
- added fast inflate (inffast.c)
|
| 1564 |
+
- deflate(Z_FINISH) now returns Z_STREAM_END when done. Warning: this
|
| 1565 |
+
is incompatible with previous versions of zlib which returned Z_OK
|
| 1566 |
+
- work around a TurboC compiler bug (bad code for b << 0, see infutil.h)
|
| 1567 |
+
(actually that was not a compiler bug, see 0.81 above)
|
| 1568 |
+
- gzread no longer reads one extra byte in certain cases
|
| 1569 |
+
- In gzio destroy(), don't reference a freed structure
|
| 1570 |
+
- avoid many warnings for MSDOS
|
| 1571 |
+
- avoid the ERROR symbol which is used by MS Windows
|
| 1572 |
+
|
| 1573 |
+
Changes in 0.71 (14 April 95)
|
| 1574 |
+
- Fixed more MSDOS compilation problems :( There is still a bug with
|
| 1575 |
+
TurboC large model
|
| 1576 |
+
|
| 1577 |
+
Changes in 0.7 (14 April 95)
|
| 1578 |
+
- Added full inflate support
|
| 1579 |
+
- Simplified the crc32() interface. The pre- and post-conditioning
|
| 1580 |
+
(one's complement) is now done inside crc32(). WARNING: this is
|
| 1581 |
+
incompatible with previous versions; see zlib.h for the new usage
|
| 1582 |
+
|
| 1583 |
+
Changes in 0.61 (12 April 95)
|
| 1584 |
+
- workaround for a bug in TurboC. example and minigzip now work on MSDOS
|
| 1585 |
+
|
| 1586 |
+
Changes in 0.6 (11 April 95)
|
| 1587 |
+
- added minigzip.c
|
| 1588 |
+
- added gzdopen to reopen a file descriptor as gzFile
|
| 1589 |
+
- added transparent reading of non-gziped files in gzread
|
| 1590 |
+
- fixed bug in gzread (don't read crc as data)
|
| 1591 |
+
- fixed bug in destroy (gzio.c) (don't return Z_STREAM_END for gzclose)
|
| 1592 |
+
- don't allocate big arrays in the stack (for MSDOS)
|
| 1593 |
+
- fix some MSDOS compilation problems
|
| 1594 |
+
|
| 1595 |
+
Changes in 0.5:
|
| 1596 |
+
- do real compression in deflate.c. Z_PARTIAL_FLUSH is supported but
|
| 1597 |
+
not yet Z_FULL_FLUSH
|
| 1598 |
+
- support decompression but only in a single step (forced Z_FINISH)
|
| 1599 |
+
- added opaque object for zalloc and zfree
|
| 1600 |
+
- added deflateReset and inflateReset
|
| 1601 |
+
- added a variable zlib_version for consistency checking
|
| 1602 |
+
- renamed the 'filter' parameter of deflateInit2 as 'strategy'
|
| 1603 |
+
Added Z_FILTERED and Z_HUFFMAN_ONLY constants
|
| 1604 |
+
|
| 1605 |
+
Changes in 0.4:
|
| 1606 |
+
- avoid "zip" everywhere, use zlib instead of ziplib
|
| 1607 |
+
- suppress Z_BLOCK_FLUSH, interpret Z_PARTIAL_FLUSH as block flush
|
| 1608 |
+
if compression method == 8
|
| 1609 |
+
- added adler32 and crc32
|
| 1610 |
+
- renamed deflateOptions as deflateInit2, call one or the other but not both
|
| 1611 |
+
- added the method parameter for deflateInit2
|
| 1612 |
+
- added inflateInit2
|
| 1613 |
+
- simplified considerably deflateInit and inflateInit by not supporting
|
| 1614 |
+
user-provided history buffer. This is supported only in deflateInit2
|
| 1615 |
+
and inflateInit2
|
| 1616 |
+
|
| 1617 |
+
Changes in 0.3:
|
| 1618 |
+
- prefix all macro names with Z_
|
| 1619 |
+
- use Z_FINISH instead of deflateEnd to finish compression
|
| 1620 |
+
- added Z_HUFFMAN_ONLY
|
| 1621 |
+
- added gzerror()
|
FAQ
ADDED
|
@@ -0,0 +1,367 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Frequently Asked Questions about zlib
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
If your question is not there, please check the zlib home page
|
| 6 |
+
http://zlib.net/ which may have more recent information.
|
| 7 |
+
The latest zlib FAQ is at http://zlib.net/zlib_faq.html
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
1. Is zlib Y2K-compliant?
|
| 11 |
+
|
| 12 |
+
Yes. zlib doesn't handle dates.
|
| 13 |
+
|
| 14 |
+
2. Where can I get a Windows DLL version?
|
| 15 |
+
|
| 16 |
+
The zlib sources can be compiled without change to produce a DLL. See the
|
| 17 |
+
file win32/DLL_FAQ.txt in the zlib distribution.
|
| 18 |
+
|
| 19 |
+
3. Where can I get a Visual Basic interface to zlib?
|
| 20 |
+
|
| 21 |
+
See
|
| 22 |
+
* https://marknelson.us/posts/1997/01/01/zlib-engine.html
|
| 23 |
+
* win32/DLL_FAQ.txt in the zlib distribution
|
| 24 |
+
|
| 25 |
+
4. compress() returns Z_BUF_ERROR.
|
| 26 |
+
|
| 27 |
+
Make sure that before the call of compress(), the length of the compressed
|
| 28 |
+
buffer is equal to the available size of the compressed buffer and not
|
| 29 |
+
zero. For Visual Basic, check that this parameter is passed by reference
|
| 30 |
+
("as any"), not by value ("as long").
|
| 31 |
+
|
| 32 |
+
5. deflate() or inflate() returns Z_BUF_ERROR.
|
| 33 |
+
|
| 34 |
+
Before making the call, make sure that avail_in and avail_out are not zero.
|
| 35 |
+
When setting the parameter flush equal to Z_FINISH, also make sure that
|
| 36 |
+
avail_out is big enough to allow processing all pending input. Note that a
|
| 37 |
+
Z_BUF_ERROR is not fatal--another call to deflate() or inflate() can be
|
| 38 |
+
made with more input or output space. A Z_BUF_ERROR may in fact be
|
| 39 |
+
unavoidable depending on how the functions are used, since it is not
|
| 40 |
+
possible to tell whether or not there is more output pending when
|
| 41 |
+
strm.avail_out returns with zero. See http://zlib.net/zlib_how.html for a
|
| 42 |
+
heavily annotated example.
|
| 43 |
+
|
| 44 |
+
6. Where's the zlib documentation (man pages, etc.)?
|
| 45 |
+
|
| 46 |
+
It's in zlib.h . Examples of zlib usage are in the files test/example.c
|
| 47 |
+
and test/minigzip.c, with more in examples/ .
|
| 48 |
+
|
| 49 |
+
7. Why don't you use GNU autoconf or libtool or ...?
|
| 50 |
+
|
| 51 |
+
Because we would like to keep zlib as a very small and simple package.
|
| 52 |
+
zlib is rather portable and doesn't need much configuration.
|
| 53 |
+
|
| 54 |
+
8. I found a bug in zlib.
|
| 55 |
+
|
| 56 |
+
Most of the time, such problems are due to an incorrect usage of zlib.
|
| 57 |
+
Please try to reproduce the problem with a small program and send the
|
| 58 |
+
corresponding source to us at zlib@gzip.org . Do not send multi-megabyte
|
| 59 |
+
data files without prior agreement.
|
| 60 |
+
|
| 61 |
+
9. Why do I get "undefined reference to gzputc"?
|
| 62 |
+
|
| 63 |
+
If "make test" produces something like
|
| 64 |
+
|
| 65 |
+
example.o(.text+0x154): undefined reference to `gzputc'
|
| 66 |
+
|
| 67 |
+
check that you don't have old files libz.* in /usr/lib, /usr/local/lib or
|
| 68 |
+
/usr/X11R6/lib. Remove any old versions, then do "make install".
|
| 69 |
+
|
| 70 |
+
10. I need a Delphi interface to zlib.
|
| 71 |
+
|
| 72 |
+
See the contrib/delphi directory in the zlib distribution.
|
| 73 |
+
|
| 74 |
+
11. Can zlib handle .zip archives?
|
| 75 |
+
|
| 76 |
+
Not by itself, no. See the directory contrib/minizip in the zlib
|
| 77 |
+
distribution.
|
| 78 |
+
|
| 79 |
+
12. Can zlib handle .Z files?
|
| 80 |
+
|
| 81 |
+
No, sorry. You have to spawn an uncompress or gunzip subprocess, or adapt
|
| 82 |
+
the code of uncompress on your own.
|
| 83 |
+
|
| 84 |
+
13. How can I make a Unix shared library?
|
| 85 |
+
|
| 86 |
+
By default a shared (and a static) library is built for Unix. So:
|
| 87 |
+
|
| 88 |
+
make distclean
|
| 89 |
+
./configure
|
| 90 |
+
make
|
| 91 |
+
|
| 92 |
+
14. How do I install a shared zlib library on Unix?
|
| 93 |
+
|
| 94 |
+
After the above, then:
|
| 95 |
+
|
| 96 |
+
make install
|
| 97 |
+
|
| 98 |
+
However, many flavors of Unix come with a shared zlib already installed.
|
| 99 |
+
Before going to the trouble of compiling a shared version of zlib and
|
| 100 |
+
trying to install it, you may want to check if it's already there! If you
|
| 101 |
+
can #include <zlib.h>, it's there. The -lz option will probably link to
|
| 102 |
+
it. You can check the version at the top of zlib.h or with the
|
| 103 |
+
ZLIB_VERSION symbol defined in zlib.h .
|
| 104 |
+
|
| 105 |
+
15. I have a question about OttoPDF.
|
| 106 |
+
|
| 107 |
+
We are not the authors of OttoPDF. The real author is on the OttoPDF web
|
| 108 |
+
site: Joel Hainley, jhainley@myndkryme.com.
|
| 109 |
+
|
| 110 |
+
16. Can zlib decode Flate data in an Adobe PDF file?
|
| 111 |
+
|
| 112 |
+
Yes. See http://www.pdflib.com/ . To modify PDF forms, see
|
| 113 |
+
http://sourceforge.net/projects/acroformtool/ .
|
| 114 |
+
|
| 115 |
+
17. Why am I getting this "register_frame_info not found" error on Solaris?
|
| 116 |
+
|
| 117 |
+
After installing zlib 1.1.4 on Solaris 2.6, running applications using zlib
|
| 118 |
+
generates an error such as:
|
| 119 |
+
|
| 120 |
+
ld.so.1: rpm: fatal: relocation error: file /usr/local/lib/libz.so:
|
| 121 |
+
symbol __register_frame_info: referenced symbol not found
|
| 122 |
+
|
| 123 |
+
The symbol __register_frame_info is not part of zlib, it is generated by
|
| 124 |
+
the C compiler (cc or gcc). You must recompile applications using zlib
|
| 125 |
+
which have this problem. This problem is specific to Solaris. See
|
| 126 |
+
http://www.sunfreeware.com for Solaris versions of zlib and applications
|
| 127 |
+
using zlib.
|
| 128 |
+
|
| 129 |
+
18. Why does gzip give an error on a file I make with compress/deflate?
|
| 130 |
+
|
| 131 |
+
The compress and deflate functions produce data in the zlib format, which
|
| 132 |
+
is different and incompatible with the gzip format. The gz* functions in
|
| 133 |
+
zlib on the other hand use the gzip format. Both the zlib and gzip formats
|
| 134 |
+
use the same compressed data format internally, but have different headers
|
| 135 |
+
and trailers around the compressed data.
|
| 136 |
+
|
| 137 |
+
19. Ok, so why are there two different formats?
|
| 138 |
+
|
| 139 |
+
The gzip format was designed to retain the directory information about a
|
| 140 |
+
single file, such as the name and last modification date. The zlib format
|
| 141 |
+
on the other hand was designed for in-memory and communication channel
|
| 142 |
+
applications, and has a much more compact header and trailer and uses a
|
| 143 |
+
faster integrity check than gzip.
|
| 144 |
+
|
| 145 |
+
20. Well that's nice, but how do I make a gzip file in memory?
|
| 146 |
+
|
| 147 |
+
You can request that deflate write the gzip format instead of the zlib
|
| 148 |
+
format using deflateInit2(). You can also request that inflate decode the
|
| 149 |
+
gzip format using inflateInit2(). Read zlib.h for more details.
|
| 150 |
+
|
| 151 |
+
21. Is zlib thread-safe?
|
| 152 |
+
|
| 153 |
+
Yes. However any library routines that zlib uses and any application-
|
| 154 |
+
provided memory allocation routines must also be thread-safe. zlib's gz*
|
| 155 |
+
functions use stdio library routines, and most of zlib's functions use the
|
| 156 |
+
library memory allocation routines by default. zlib's *Init* functions
|
| 157 |
+
allow for the application to provide custom memory allocation routines.
|
| 158 |
+
|
| 159 |
+
Of course, you should only operate on any given zlib or gzip stream from a
|
| 160 |
+
single thread at a time.
|
| 161 |
+
|
| 162 |
+
22. Can I use zlib in my commercial application?
|
| 163 |
+
|
| 164 |
+
Yes. Please read the license in zlib.h.
|
| 165 |
+
|
| 166 |
+
23. Is zlib under the GNU license?
|
| 167 |
+
|
| 168 |
+
No. Please read the license in zlib.h.
|
| 169 |
+
|
| 170 |
+
24. The license says that altered source versions must be "plainly marked". So
|
| 171 |
+
what exactly do I need to do to meet that requirement?
|
| 172 |
+
|
| 173 |
+
You need to change the ZLIB_VERSION and ZLIB_VERNUM #defines in zlib.h. In
|
| 174 |
+
particular, the final version number needs to be changed to "f", and an
|
| 175 |
+
identification string should be appended to ZLIB_VERSION. Version numbers
|
| 176 |
+
x.x.x.f are reserved for modifications to zlib by others than the zlib
|
| 177 |
+
maintainers. For example, if the version of the base zlib you are altering
|
| 178 |
+
is "1.2.3.4", then in zlib.h you should change ZLIB_VERNUM to 0x123f, and
|
| 179 |
+
ZLIB_VERSION to something like "1.2.3.f-zachary-mods-v3". You can also
|
| 180 |
+
update the version strings in deflate.c and inftrees.c.
|
| 181 |
+
|
| 182 |
+
For altered source distributions, you should also note the origin and
|
| 183 |
+
nature of the changes in zlib.h, as well as in ChangeLog and README, along
|
| 184 |
+
with the dates of the alterations. The origin should include at least your
|
| 185 |
+
name (or your company's name), and an email address to contact for help or
|
| 186 |
+
issues with the library.
|
| 187 |
+
|
| 188 |
+
Note that distributing a compiled zlib library along with zlib.h and
|
| 189 |
+
zconf.h is also a source distribution, and so you should change
|
| 190 |
+
ZLIB_VERSION and ZLIB_VERNUM and note the origin and nature of the changes
|
| 191 |
+
in zlib.h as you would for a full source distribution.
|
| 192 |
+
|
| 193 |
+
25. Will zlib work on a big-endian or little-endian architecture, and can I
|
| 194 |
+
exchange compressed data between them?
|
| 195 |
+
|
| 196 |
+
Yes and yes.
|
| 197 |
+
|
| 198 |
+
26. Will zlib work on a 64-bit machine?
|
| 199 |
+
|
| 200 |
+
Yes. It has been tested on 64-bit machines, and has no dependence on any
|
| 201 |
+
data types being limited to 32-bits in length. If you have any
|
| 202 |
+
difficulties, please provide a complete problem report to zlib@gzip.org
|
| 203 |
+
|
| 204 |
+
27. Will zlib decompress data from the PKWare Data Compression Library?
|
| 205 |
+
|
| 206 |
+
No. The PKWare DCL uses a completely different compressed data format than
|
| 207 |
+
does PKZIP and zlib. However, you can look in zlib's contrib/blast
|
| 208 |
+
directory for a possible solution to your problem.
|
| 209 |
+
|
| 210 |
+
28. Can I access data randomly in a compressed stream?
|
| 211 |
+
|
| 212 |
+
No, not without some preparation. If when compressing you periodically use
|
| 213 |
+
Z_FULL_FLUSH, carefully write all the pending data at those points, and
|
| 214 |
+
keep an index of those locations, then you can start decompression at those
|
| 215 |
+
points. You have to be careful to not use Z_FULL_FLUSH too often, since it
|
| 216 |
+
can significantly degrade compression. Alternatively, you can scan a
|
| 217 |
+
deflate stream once to generate an index, and then use that index for
|
| 218 |
+
random access. See examples/zran.c .
|
| 219 |
+
|
| 220 |
+
29. Does zlib work on MVS, OS/390, CICS, etc.?
|
| 221 |
+
|
| 222 |
+
It has in the past, but we have not heard of any recent evidence. There
|
| 223 |
+
were working ports of zlib 1.1.4 to MVS, but those links no longer work.
|
| 224 |
+
If you know of recent, successful applications of zlib on these operating
|
| 225 |
+
systems, please let us know. Thanks.
|
| 226 |
+
|
| 227 |
+
30. Is there some simpler, easier to read version of inflate I can look at to
|
| 228 |
+
understand the deflate format?
|
| 229 |
+
|
| 230 |
+
First off, you should read RFC 1951. Second, yes. Look in zlib's
|
| 231 |
+
contrib/puff directory.
|
| 232 |
+
|
| 233 |
+
31. Does zlib infringe on any patents?
|
| 234 |
+
|
| 235 |
+
As far as we know, no. In fact, that was originally the whole point behind
|
| 236 |
+
zlib. Look here for some more information:
|
| 237 |
+
|
| 238 |
+
http://www.gzip.org/#faq11
|
| 239 |
+
|
| 240 |
+
32. Can zlib work with greater than 4 GB of data?
|
| 241 |
+
|
| 242 |
+
Yes. inflate() and deflate() will process any amount of data correctly.
|
| 243 |
+
Each call of inflate() or deflate() is limited to input and output chunks
|
| 244 |
+
of the maximum value that can be stored in the compiler's "unsigned int"
|
| 245 |
+
type, but there is no limit to the number of chunks. Note however that the
|
| 246 |
+
strm.total_in and strm_total_out counters may be limited to 4 GB. These
|
| 247 |
+
counters are provided as a convenience and are not used internally by
|
| 248 |
+
inflate() or deflate(). The application can easily set up its own counters
|
| 249 |
+
updated after each call of inflate() or deflate() to count beyond 4 GB.
|
| 250 |
+
compress() and uncompress() may be limited to 4 GB, since they operate in a
|
| 251 |
+
single call. gzseek() and gztell() may be limited to 4 GB depending on how
|
| 252 |
+
zlib is compiled. See the zlibCompileFlags() function in zlib.h.
|
| 253 |
+
|
| 254 |
+
The word "may" appears several times above since there is a 4 GB limit only
|
| 255 |
+
if the compiler's "long" type is 32 bits. If the compiler's "long" type is
|
| 256 |
+
64 bits, then the limit is 16 exabytes.
|
| 257 |
+
|
| 258 |
+
33. Does zlib have any security vulnerabilities?
|
| 259 |
+
|
| 260 |
+
The only one that we are aware of is potentially in gzprintf(). If zlib is
|
| 261 |
+
compiled to use sprintf() or vsprintf(), then there is no protection
|
| 262 |
+
against a buffer overflow of an 8K string space (or other value as set by
|
| 263 |
+
gzbuffer()), other than the caller of gzprintf() assuring that the output
|
| 264 |
+
will not exceed 8K. On the other hand, if zlib is compiled to use
|
| 265 |
+
snprintf() or vsnprintf(), which should normally be the case, then there is
|
| 266 |
+
no vulnerability. The ./configure script will display warnings if an
|
| 267 |
+
insecure variation of sprintf() will be used by gzprintf(). Also the
|
| 268 |
+
zlibCompileFlags() function will return information on what variant of
|
| 269 |
+
sprintf() is used by gzprintf().
|
| 270 |
+
|
| 271 |
+
If you don't have snprintf() or vsnprintf() and would like one, you can
|
| 272 |
+
find a portable implementation here:
|
| 273 |
+
|
| 274 |
+
http://www.ijs.si/software/snprintf/
|
| 275 |
+
|
| 276 |
+
Note that you should be using the most recent version of zlib. Versions
|
| 277 |
+
1.1.3 and before were subject to a double-free vulnerability, and versions
|
| 278 |
+
1.2.1 and 1.2.2 were subject to an access exception when decompressing
|
| 279 |
+
invalid compressed data.
|
| 280 |
+
|
| 281 |
+
34. Is there a Java version of zlib?
|
| 282 |
+
|
| 283 |
+
Probably what you want is to use zlib in Java. zlib is already included
|
| 284 |
+
as part of the Java SDK in the java.util.zip package. If you really want
|
| 285 |
+
a version of zlib written in the Java language, look on the zlib home
|
| 286 |
+
page for links: http://zlib.net/ .
|
| 287 |
+
|
| 288 |
+
35. I get this or that compiler or source-code scanner warning when I crank it
|
| 289 |
+
up to maximally-pedantic. Can't you guys write proper code?
|
| 290 |
+
|
| 291 |
+
Many years ago, we gave up attempting to avoid warnings on every compiler
|
| 292 |
+
in the universe. It just got to be a waste of time, and some compilers
|
| 293 |
+
were downright silly as well as contradicted each other. So now, we simply
|
| 294 |
+
make sure that the code always works.
|
| 295 |
+
|
| 296 |
+
36. Valgrind (or some similar memory access checker) says that deflate is
|
| 297 |
+
performing a conditional jump that depends on an uninitialized value.
|
| 298 |
+
Isn't that a bug?
|
| 299 |
+
|
| 300 |
+
No. That is intentional for performance reasons, and the output of deflate
|
| 301 |
+
is not affected. This only started showing up recently since zlib 1.2.x
|
| 302 |
+
uses malloc() by default for allocations, whereas earlier versions used
|
| 303 |
+
calloc(), which zeros out the allocated memory. Even though the code was
|
| 304 |
+
correct, versions 1.2.4 and later was changed to not stimulate these
|
| 305 |
+
checkers.
|
| 306 |
+
|
| 307 |
+
37. Will zlib read the (insert any ancient or arcane format here) compressed
|
| 308 |
+
data format?
|
| 309 |
+
|
| 310 |
+
Probably not. Look in the comp.compression FAQ for pointers to various
|
| 311 |
+
formats and associated software.
|
| 312 |
+
|
| 313 |
+
38. How can I encrypt/decrypt zip files with zlib?
|
| 314 |
+
|
| 315 |
+
zlib doesn't support encryption. The original PKZIP encryption is very
|
| 316 |
+
weak and can be broken with freely available programs. To get strong
|
| 317 |
+
encryption, use GnuPG, http://www.gnupg.org/ , which already includes zlib
|
| 318 |
+
compression. For PKZIP compatible "encryption", look at
|
| 319 |
+
http://www.info-zip.org/
|
| 320 |
+
|
| 321 |
+
39. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
|
| 322 |
+
|
| 323 |
+
"gzip" is the gzip format, and "deflate" is the zlib format. They should
|
| 324 |
+
probably have called the second one "zlib" instead to avoid confusion with
|
| 325 |
+
the raw deflate compressed data format. While the HTTP 1.1 RFC 2616
|
| 326 |
+
correctly points to the zlib specification in RFC 1950 for the "deflate"
|
| 327 |
+
transfer encoding, there have been reports of servers and browsers that
|
| 328 |
+
incorrectly produce or expect raw deflate data per the deflate
|
| 329 |
+
specification in RFC 1951, most notably Microsoft. So even though the
|
| 330 |
+
"deflate" transfer encoding using the zlib format would be the more
|
| 331 |
+
efficient approach (and in fact exactly what the zlib format was designed
|
| 332 |
+
for), using the "gzip" transfer encoding is probably more reliable due to
|
| 333 |
+
an unfortunate choice of name on the part of the HTTP 1.1 authors.
|
| 334 |
+
|
| 335 |
+
Bottom line: use the gzip format for HTTP 1.1 encoding.
|
| 336 |
+
|
| 337 |
+
40. Does zlib support the new "Deflate64" format introduced by PKWare?
|
| 338 |
+
|
| 339 |
+
No. PKWare has apparently decided to keep that format proprietary, since
|
| 340 |
+
they have not documented it as they have previous compression formats. In
|
| 341 |
+
any case, the compression improvements are so modest compared to other more
|
| 342 |
+
modern approaches, that it's not worth the effort to implement.
|
| 343 |
+
|
| 344 |
+
41. I'm having a problem with the zip functions in zlib, can you help?
|
| 345 |
+
|
| 346 |
+
There are no zip functions in zlib. You are probably using minizip by
|
| 347 |
+
Giles Vollant, which is found in the contrib directory of zlib. It is not
|
| 348 |
+
part of zlib. In fact none of the stuff in contrib is part of zlib. The
|
| 349 |
+
files in there are not supported by the zlib authors. You need to contact
|
| 350 |
+
the authors of the respective contribution for help.
|
| 351 |
+
|
| 352 |
+
42. The match.asm code in contrib is under the GNU General Public License.
|
| 353 |
+
Since it's part of zlib, doesn't that mean that all of zlib falls under the
|
| 354 |
+
GNU GPL?
|
| 355 |
+
|
| 356 |
+
No. The files in contrib are not part of zlib. They were contributed by
|
| 357 |
+
other authors and are provided as a convenience to the user within the zlib
|
| 358 |
+
distribution. Each item in contrib has its own license.
|
| 359 |
+
|
| 360 |
+
43. Is zlib subject to export controls? What is its ECCN?
|
| 361 |
+
|
| 362 |
+
zlib is not subject to export controls, and so is classified as EAR99.
|
| 363 |
+
|
| 364 |
+
44. Can you please sign these lengthy legal documents and fax them back to us
|
| 365 |
+
so that we can use your software in our product?
|
| 366 |
+
|
| 367 |
+
No. Go away. Shoo.
|
INDEX
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
CMakeLists.txt cmake build file
|
| 2 |
+
ChangeLog history of changes
|
| 3 |
+
FAQ Frequently Asked Questions about zlib
|
| 4 |
+
INDEX this file
|
| 5 |
+
Makefile dummy Makefile that tells you to ./configure
|
| 6 |
+
Makefile.in template for Unix Makefile
|
| 7 |
+
README guess what
|
| 8 |
+
configure configure script for Unix
|
| 9 |
+
make_vms.com makefile for VMS
|
| 10 |
+
test/example.c zlib usages examples for build testing
|
| 11 |
+
test/minigzip.c minimal gzip-like functionality for build testing
|
| 12 |
+
test/infcover.c inf*.c code coverage for build coverage testing
|
| 13 |
+
treebuild.xml XML description of source file dependencies
|
| 14 |
+
zconf.h.cmakein zconf.h template for cmake
|
| 15 |
+
zconf.h.in zconf.h template for configure
|
| 16 |
+
zlib.3 Man page for zlib
|
| 17 |
+
zlib.3.pdf Man page in PDF format
|
| 18 |
+
zlib.map Linux symbol information
|
| 19 |
+
zlib.pc.in Template for pkg-config descriptor
|
| 20 |
+
zlib.pc.cmakein zlib.pc template for cmake
|
| 21 |
+
zlib2ansi perl script to convert source files for C++ compilation
|
| 22 |
+
|
| 23 |
+
amiga/ makefiles for Amiga SAS C
|
| 24 |
+
as400/ makefiles for AS/400
|
| 25 |
+
doc/ documentation for formats and algorithms
|
| 26 |
+
msdos/ makefiles for MSDOS
|
| 27 |
+
nintendods/ makefile for Nintendo DS
|
| 28 |
+
old/ makefiles for various architectures and zlib documentation
|
| 29 |
+
files that have not yet been updated for zlib 1.2.x
|
| 30 |
+
qnx/ makefiles for QNX
|
| 31 |
+
watcom/ makefiles for OpenWatcom
|
| 32 |
+
win32/ makefiles for Windows
|
| 33 |
+
|
| 34 |
+
zlib public header files (required for library use):
|
| 35 |
+
zconf.h
|
| 36 |
+
zlib.h
|
| 37 |
+
|
| 38 |
+
private source files used to build the zlib library:
|
| 39 |
+
adler32.c
|
| 40 |
+
compress.c
|
| 41 |
+
crc32.c
|
| 42 |
+
crc32.h
|
| 43 |
+
deflate.c
|
| 44 |
+
deflate.h
|
| 45 |
+
gzclose.c
|
| 46 |
+
gzguts.h
|
| 47 |
+
gzlib.c
|
| 48 |
+
gzread.c
|
| 49 |
+
gzwrite.c
|
| 50 |
+
infback.c
|
| 51 |
+
inffast.c
|
| 52 |
+
inffast.h
|
| 53 |
+
inffixed.h
|
| 54 |
+
inflate.c
|
| 55 |
+
inflate.h
|
| 56 |
+
inftrees.c
|
| 57 |
+
inftrees.h
|
| 58 |
+
trees.c
|
| 59 |
+
trees.h
|
| 60 |
+
uncompr.c
|
| 61 |
+
zutil.c
|
| 62 |
+
zutil.h
|
| 63 |
+
|
| 64 |
+
source files for sample programs
|
| 65 |
+
See examples/README.examples
|
| 66 |
+
|
| 67 |
+
unsupported contributions by third parties
|
| 68 |
+
See contrib/README.contrib
|
LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright notice:
|
| 2 |
+
|
| 3 |
+
(C) 1995-2024 Jean-loup Gailly and Mark Adler
|
| 4 |
+
|
| 5 |
+
This software is provided 'as-is', without any express or implied
|
| 6 |
+
warranty. In no event will the authors be held liable for any damages
|
| 7 |
+
arising from the use of this software.
|
| 8 |
+
|
| 9 |
+
Permission is granted to anyone to use this software for any purpose,
|
| 10 |
+
including commercial applications, and to alter it and redistribute it
|
| 11 |
+
freely, subject to the following restrictions:
|
| 12 |
+
|
| 13 |
+
1. The origin of this software must not be misrepresented; you must not
|
| 14 |
+
claim that you wrote the original software. If you use this software
|
| 15 |
+
in a product, an acknowledgment in the product documentation would be
|
| 16 |
+
appreciated but is not required.
|
| 17 |
+
2. Altered source versions must be plainly marked as such, and must not be
|
| 18 |
+
misrepresented as being the original software.
|
| 19 |
+
3. This notice may not be removed or altered from any source distribution.
|
| 20 |
+
|
| 21 |
+
Jean-loup Gailly Mark Adler
|
| 22 |
+
jloup@gzip.org madler@alumni.caltech.edu
|
MODULE.bazel
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module(
|
| 2 |
+
name = "zlib",
|
| 3 |
+
version = "0.0.0",
|
| 4 |
+
compatibility_level = 1,
|
| 5 |
+
)
|
| 6 |
+
|
| 7 |
+
bazel_dep(name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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Makefile for zlib
|
| 2 |
+
# Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
|
| 3 |
+
# For conditions of distribution and use, see copyright notice in zlib.h
|
| 4 |
+
|
| 5 |
+
# To compile and test, type:
|
| 6 |
+
# ./configure; make test
|
| 7 |
+
# Normally configure builds both a static and a shared library.
|
| 8 |
+
# If you want to build just a static library, use: ./configure --static
|
| 9 |
+
|
| 10 |
+
# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
|
| 11 |
+
# make install
|
| 12 |
+
# To install in $HOME instead of /usr/local, use:
|
| 13 |
+
# make install prefix=$HOME
|
| 14 |
+
|
| 15 |
+
CC=cc
|
| 16 |
+
GCOV=GCOV
|
| 17 |
+
LLVM_GCOV_FLAG=LLMV_GCOV_FLAG
|
| 18 |
+
|
| 19 |
+
CFLAGS=-O
|
| 20 |
+
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
|
| 21 |
+
#CFLAGS=-g -DZLIB_DEBUG
|
| 22 |
+
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
|
| 23 |
+
# -Wstrict-prototypes -Wmissing-prototypes
|
| 24 |
+
|
| 25 |
+
SFLAGS=-O
|
| 26 |
+
LDFLAGS=
|
| 27 |
+
TEST_LIBS=-L. libz.a
|
| 28 |
+
LDSHARED=$(CC)
|
| 29 |
+
CPP=$(CC) -E
|
| 30 |
+
|
| 31 |
+
STATICLIB=libz.a
|
| 32 |
+
SHAREDLIB=libz.so
|
| 33 |
+
SHAREDLIBV=libz.so.1.3.1.1
|
| 34 |
+
SHAREDLIBM=libz.so.1
|
| 35 |
+
LIBS=$(STATICLIB) $(SHAREDLIBV)
|
| 36 |
+
|
| 37 |
+
AR=ar
|
| 38 |
+
ARFLAGS=rc
|
| 39 |
+
RANLIB=ranlib
|
| 40 |
+
LDCONFIG=ldconfig
|
| 41 |
+
LDSHAREDLIBC=-lc
|
| 42 |
+
TAR=tar
|
| 43 |
+
SHELL=/bin/sh
|
| 44 |
+
EXE=
|
| 45 |
+
|
| 46 |
+
prefix = /usr/local
|
| 47 |
+
exec_prefix = ${prefix}
|
| 48 |
+
libdir = ${exec_prefix}/lib
|
| 49 |
+
sharedlibdir = ${libdir}
|
| 50 |
+
includedir = ${prefix}/include
|
| 51 |
+
mandir = ${prefix}/share/man
|
| 52 |
+
man3dir = ${mandir}/man3
|
| 53 |
+
pkgconfigdir = ${libdir}/pkgconfig
|
| 54 |
+
SRCDIR=
|
| 55 |
+
ZINC=
|
| 56 |
+
ZINCOUT=-I.
|
| 57 |
+
|
| 58 |
+
OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o
|
| 59 |
+
OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
|
| 60 |
+
OBJC = $(OBJZ) $(OBJG)
|
| 61 |
+
|
| 62 |
+
PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo
|
| 63 |
+
PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo
|
| 64 |
+
PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)
|
| 65 |
+
|
| 66 |
+
# to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo
|
| 67 |
+
OBJA =
|
| 68 |
+
PIC_OBJA =
|
| 69 |
+
|
| 70 |
+
OBJS = $(OBJC) $(OBJA)
|
| 71 |
+
|
| 72 |
+
PIC_OBJS = $(PIC_OBJC) $(PIC_OBJA)
|
| 73 |
+
|
| 74 |
+
all: static shared
|
| 75 |
+
|
| 76 |
+
static: example$(EXE) minigzip$(EXE)
|
| 77 |
+
|
| 78 |
+
shared: examplesh$(EXE) minigzipsh$(EXE)
|
| 79 |
+
|
| 80 |
+
all64: example64$(EXE) minigzip64$(EXE)
|
| 81 |
+
|
| 82 |
+
check: test
|
| 83 |
+
|
| 84 |
+
test: all teststatic testshared
|
| 85 |
+
|
| 86 |
+
teststatic: static
|
| 87 |
+
@TMPST=tmpst_$$; \
|
| 88 |
+
if echo hello world | ${QEMU_RUN} ./minigzip | ${QEMU_RUN} ./minigzip -d && ${QEMU_RUN} ./example $$TMPST ; then \
|
| 89 |
+
echo ' *** zlib test OK ***'; \
|
| 90 |
+
else \
|
| 91 |
+
echo ' *** zlib test FAILED ***'; false; \
|
| 92 |
+
fi
|
| 93 |
+
@rm -f tmpst_$$
|
| 94 |
+
|
| 95 |
+
testshared: shared
|
| 96 |
+
@LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
|
| 97 |
+
LD_LIBRARYN32_PATH=`pwd`:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \
|
| 98 |
+
DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \
|
| 99 |
+
SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \
|
| 100 |
+
TMPSH=tmpsh_$$; \
|
| 101 |
+
if echo hello world | ${QEMU_RUN} ./minigzipsh | ${QEMU_RUN} ./minigzipsh -d && ${QEMU_RUN} ./examplesh $$TMPSH; then \
|
| 102 |
+
echo ' *** zlib shared test OK ***'; \
|
| 103 |
+
else \
|
| 104 |
+
echo ' *** zlib shared test FAILED ***'; false; \
|
| 105 |
+
fi
|
| 106 |
+
@rm -f tmpsh_$$
|
| 107 |
+
|
| 108 |
+
test64: all64
|
| 109 |
+
@TMP64=tmp64_$$; \
|
| 110 |
+
if echo hello world | ${QEMU_RUN} ./minigzip64 | ${QEMU_RUN} ./minigzip64 -d && ${QEMU_RUN} ./example64 $$TMP64; then \
|
| 111 |
+
echo ' *** zlib 64-bit test OK ***'; \
|
| 112 |
+
else \
|
| 113 |
+
echo ' *** zlib 64-bit test FAILED ***'; false; \
|
| 114 |
+
fi
|
| 115 |
+
@rm -f tmp64_$$
|
| 116 |
+
|
| 117 |
+
infcover.o: $(SRCDIR)test/infcover.c $(SRCDIR)zlib.h zconf.h
|
| 118 |
+
$(CC) $(CFLAGS) $(ZINCOUT) -c -coverage -o $@ $(SRCDIR)test/infcover.c
|
| 119 |
+
|
| 120 |
+
infcover: infcover.o libz.a
|
| 121 |
+
$(CC) $(CFLAGS) -coverage -o $@ infcover.o libz.a
|
| 122 |
+
|
| 123 |
+
cover: infcover
|
| 124 |
+
ifdef $(GCOV)
|
| 125 |
+
rm -f *.gcda
|
| 126 |
+
${QEMU_RUN} ./infcover
|
| 127 |
+
${GCOV} ${LLVM_GCOV_FLAG} inf*.c -o ./infcover.gcda
|
| 128 |
+
else
|
| 129 |
+
@echo 'cover disabled as no suitable gcov was found'
|
| 130 |
+
endif
|
| 131 |
+
|
| 132 |
+
libz.a: $(OBJS)
|
| 133 |
+
$(AR) $(ARFLAGS) $@ $(OBJS)
|
| 134 |
+
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
|
| 135 |
+
|
| 136 |
+
match.o: match.S
|
| 137 |
+
$(CPP) match.S > _match.s
|
| 138 |
+
$(CC) -c _match.s
|
| 139 |
+
mv _match.o match.o
|
| 140 |
+
rm -f _match.s
|
| 141 |
+
|
| 142 |
+
match.lo: match.S
|
| 143 |
+
$(CPP) match.S > _match.s
|
| 144 |
+
$(CC) -c -fPIC _match.s
|
| 145 |
+
mv _match.o match.lo
|
| 146 |
+
rm -f _match.s
|
| 147 |
+
|
| 148 |
+
example.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h
|
| 149 |
+
$(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/example.c
|
| 150 |
+
|
| 151 |
+
minigzip.o: $(SRCDIR)test/minigzip.c $(SRCDIR)zlib.h zconf.h
|
| 152 |
+
$(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/minigzip.c
|
| 153 |
+
|
| 154 |
+
example64.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h
|
| 155 |
+
$(CC) $(CFLAGS) $(ZINCOUT) -D_FILE_OFFSET_BITS=64 -c -o $@ $(SRCDIR)test/example.c
|
| 156 |
+
|
| 157 |
+
minigzip64.o: $(SRCDIR)test/minigzip.c $(SRCDIR)zlib.h zconf.h
|
| 158 |
+
$(CC) $(CFLAGS) $(ZINCOUT) -D_FILE_OFFSET_BITS=64 -c -o $@ $(SRCDIR)test/minigzip.c
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
adler32.o: $(SRCDIR)adler32.c
|
| 162 |
+
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)adler32.c
|
| 163 |
+
|
| 164 |
+
crc32.o: $(SRCDIR)crc32.c
|
| 165 |
+
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)crc32.c
|
| 166 |
+
|
| 167 |
+
deflate.o: $(SRCDIR)deflate.c
|
| 168 |
+
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)deflate.c
|
| 169 |
+
|
| 170 |
+
infback.o: $(SRCDIR)infback.c
|
| 171 |
+
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)infback.c
|
| 172 |
+
|
| 173 |
+
inffast.o: $(SRCDIR)inffast.c
|
| 174 |
+
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inffast.c
|
| 175 |
+
|
| 176 |
+
inflate.o: $(SRCDIR)inflate.c
|
| 177 |
+
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inflate.c
|
| 178 |
+
|
| 179 |
+
inftrees.o: $(SRCDIR)inftrees.c
|
| 180 |
+
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inftrees.c
|
| 181 |
+
|
| 182 |
+
trees.o: $(SRCDIR)trees.c
|
| 183 |
+
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)trees.c
|
| 184 |
+
|
| 185 |
+
zutil.o: $(SRCDIR)zutil.c $(SRCDIR)gzguts.h
|
| 186 |
+
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)zutil.c
|
| 187 |
+
|
| 188 |
+
compress.o: $(SRCDIR)compress.c
|
| 189 |
+
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)compress.c
|
| 190 |
+
|
| 191 |
+
uncompr.o: $(SRCDIR)uncompr.c
|
| 192 |
+
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)uncompr.c
|
| 193 |
+
|
| 194 |
+
gzclose.o: $(SRCDIR)gzclose.c
|
| 195 |
+
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzclose.c
|
| 196 |
+
|
| 197 |
+
gzlib.o: $(SRCDIR)gzlib.c
|
| 198 |
+
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzlib.c
|
| 199 |
+
|
| 200 |
+
gzread.o: $(SRCDIR)gzread.c
|
| 201 |
+
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzread.c
|
| 202 |
+
|
| 203 |
+
gzwrite.o: $(SRCDIR)gzwrite.c
|
| 204 |
+
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzwrite.c
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
adler32.lo: $(SRCDIR)adler32.c
|
| 208 |
+
-@mkdir objs 2>/dev/null || test -d objs
|
| 209 |
+
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/adler32.o $(SRCDIR)adler32.c
|
| 210 |
+
-@mv objs/adler32.o $@
|
| 211 |
+
|
| 212 |
+
crc32.lo: $(SRCDIR)crc32.c
|
| 213 |
+
-@mkdir objs 2>/dev/null || test -d objs
|
| 214 |
+
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/crc32.o $(SRCDIR)crc32.c
|
| 215 |
+
-@mv objs/crc32.o $@
|
| 216 |
+
|
| 217 |
+
deflate.lo: $(SRCDIR)deflate.c
|
| 218 |
+
-@mkdir objs 2>/dev/null || test -d objs
|
| 219 |
+
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/deflate.o $(SRCDIR)deflate.c
|
| 220 |
+
-@mv objs/deflate.o $@
|
| 221 |
+
|
| 222 |
+
infback.lo: $(SRCDIR)infback.c
|
| 223 |
+
-@mkdir objs 2>/dev/null || test -d objs
|
| 224 |
+
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/infback.o $(SRCDIR)infback.c
|
| 225 |
+
-@mv objs/infback.o $@
|
| 226 |
+
|
| 227 |
+
inffast.lo: $(SRCDIR)inffast.c
|
| 228 |
+
-@mkdir objs 2>/dev/null || test -d objs
|
| 229 |
+
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/inffast.o $(SRCDIR)inffast.c
|
| 230 |
+
-@mv objs/inffast.o $@
|
| 231 |
+
|
| 232 |
+
inflate.lo: $(SRCDIR)inflate.c
|
| 233 |
+
-@mkdir objs 2>/dev/null || test -d objs
|
| 234 |
+
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/inflate.o $(SRCDIR)inflate.c
|
| 235 |
+
-@mv objs/inflate.o $@
|
| 236 |
+
|
| 237 |
+
inftrees.lo: $(SRCDIR)inftrees.c
|
| 238 |
+
-@mkdir objs 2>/dev/null || test -d objs
|
| 239 |
+
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/inftrees.o $(SRCDIR)inftrees.c
|
| 240 |
+
-@mv objs/inftrees.o $@
|
| 241 |
+
|
| 242 |
+
trees.lo: $(SRCDIR)trees.c
|
| 243 |
+
-@mkdir objs 2>/dev/null || test -d objs
|
| 244 |
+
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/trees.o $(SRCDIR)trees.c
|
| 245 |
+
-@mv objs/trees.o $@
|
| 246 |
+
|
| 247 |
+
zutil.lo: $(SRCDIR)zutil.c $(SRCDIR)gzguts.h
|
| 248 |
+
-@mkdir objs 2>/dev/null || test -d objs
|
| 249 |
+
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/zutil.o $(SRCDIR)zutil.c
|
| 250 |
+
-@mv objs/zutil.o $@
|
| 251 |
+
|
| 252 |
+
compress.lo: $(SRCDIR)compress.c
|
| 253 |
+
-@mkdir objs 2>/dev/null || test -d objs
|
| 254 |
+
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/compress.o $(SRCDIR)compress.c
|
| 255 |
+
-@mv objs/compress.o $@
|
| 256 |
+
|
| 257 |
+
uncompr.lo: $(SRCDIR)uncompr.c
|
| 258 |
+
-@mkdir objs 2>/dev/null || test -d objs
|
| 259 |
+
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/uncompr.o $(SRCDIR)uncompr.c
|
| 260 |
+
-@mv objs/uncompr.o $@
|
| 261 |
+
|
| 262 |
+
gzclose.lo: $(SRCDIR)gzclose.c
|
| 263 |
+
-@mkdir objs 2>/dev/null || test -d objs
|
| 264 |
+
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzclose.o $(SRCDIR)gzclose.c
|
| 265 |
+
-@mv objs/gzclose.o $@
|
| 266 |
+
|
| 267 |
+
gzlib.lo: $(SRCDIR)gzlib.c
|
| 268 |
+
-@mkdir objs 2>/dev/null || test -d objs
|
| 269 |
+
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzlib.o $(SRCDIR)gzlib.c
|
| 270 |
+
-@mv objs/gzlib.o $@
|
| 271 |
+
|
| 272 |
+
gzread.lo: $(SRCDIR)gzread.c
|
| 273 |
+
-@mkdir objs 2>/dev/null || test -d objs
|
| 274 |
+
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzread.o $(SRCDIR)gzread.c
|
| 275 |
+
-@mv objs/gzread.o $@
|
| 276 |
+
|
| 277 |
+
gzwrite.lo: $(SRCDIR)gzwrite.c
|
| 278 |
+
-@mkdir objs 2>/dev/null || test -d objs
|
| 279 |
+
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzwrite.o $(SRCDIR)gzwrite.c
|
| 280 |
+
-@mv objs/gzwrite.o $@
|
| 281 |
+
|
| 282 |
+
|
| 283 |
+
placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
|
| 284 |
+
$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
|
| 285 |
+
rm -f $(SHAREDLIB) $(SHAREDLIBM)
|
| 286 |
+
ln -s $@ $(SHAREDLIB)
|
| 287 |
+
ln -s $@ $(SHAREDLIBM)
|
| 288 |
+
-@rmdir objs
|
| 289 |
+
|
| 290 |
+
example$(EXE): example.o $(STATICLIB)
|
| 291 |
+
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ example.o $(TEST_LIBS)
|
| 292 |
+
|
| 293 |
+
minigzip$(EXE): minigzip.o $(STATICLIB)
|
| 294 |
+
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ minigzip.o $(TEST_LIBS)
|
| 295 |
+
|
| 296 |
+
examplesh$(EXE): example.o $(SHAREDLIBV)
|
| 297 |
+
$(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS) -L. $(SHAREDLIBV)
|
| 298 |
+
|
| 299 |
+
minigzipsh$(EXE): minigzip.o $(SHAREDLIBV)
|
| 300 |
+
$(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) -L. $(SHAREDLIBV)
|
| 301 |
+
|
| 302 |
+
example64$(EXE): example64.o $(STATICLIB)
|
| 303 |
+
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ example64.o $(TEST_LIBS)
|
| 304 |
+
|
| 305 |
+
minigzip64$(EXE): minigzip64.o $(STATICLIB)
|
| 306 |
+
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ minigzip64.o $(TEST_LIBS)
|
| 307 |
+
|
| 308 |
+
install-libs: $(LIBS)
|
| 309 |
+
-@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi
|
| 310 |
+
-@if [ ! -d $(DESTDIR)$(libdir) ]; then mkdir -p $(DESTDIR)$(libdir); fi
|
| 311 |
+
-@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi
|
| 312 |
+
-@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi
|
| 313 |
+
-@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
|
| 314 |
+
rm -f $(DESTDIR)$(libdir)/$(STATICLIB)
|
| 315 |
+
cp $(STATICLIB) $(DESTDIR)$(libdir)
|
| 316 |
+
chmod 644 $(DESTDIR)$(libdir)/$(STATICLIB)
|
| 317 |
+
-@($(RANLIB) $(DESTDIR)$(libdir)/libz.a || true) >/dev/null 2>&1
|
| 318 |
+
-@if test -n "$(SHAREDLIBV)"; then \
|
| 319 |
+
rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \
|
| 320 |
+
cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir); \
|
| 321 |
+
echo "cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)"; \
|
| 322 |
+
chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \
|
| 323 |
+
echo "chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV)"; \
|
| 324 |
+
rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
|
| 325 |
+
ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB); \
|
| 326 |
+
ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \
|
| 327 |
+
($(LDCONFIG) || true) >/dev/null 2>&1; \
|
| 328 |
+
fi
|
| 329 |
+
rm -f $(DESTDIR)$(man3dir)/zlib.3
|
| 330 |
+
cp $(SRCDIR)zlib.3 $(DESTDIR)$(man3dir)
|
| 331 |
+
chmod 644 $(DESTDIR)$(man3dir)/zlib.3
|
| 332 |
+
rm -f $(DESTDIR)$(pkgconfigdir)/zlib.pc
|
| 333 |
+
cp zlib.pc $(DESTDIR)$(pkgconfigdir)
|
| 334 |
+
chmod 644 $(DESTDIR)$(pkgconfigdir)/zlib.pc
|
| 335 |
+
# The ranlib in install is needed on NeXTSTEP which checks file times
|
| 336 |
+
# ldconfig is for Linux
|
| 337 |
+
|
| 338 |
+
install: install-libs
|
| 339 |
+
-@if [ ! -d $(DESTDIR)$(includedir) ]; then mkdir -p $(DESTDIR)$(includedir); fi
|
| 340 |
+
rm -f $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h
|
| 341 |
+
cp $(SRCDIR)zlib.h zconf.h $(DESTDIR)$(includedir)
|
| 342 |
+
chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h
|
| 343 |
+
|
| 344 |
+
uninstall:
|
| 345 |
+
cd $(DESTDIR)$(includedir) && rm -f zlib.h zconf.h
|
| 346 |
+
cd $(DESTDIR)$(libdir) && rm -f libz.a; \
|
| 347 |
+
if test -n "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \
|
| 348 |
+
rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
|
| 349 |
+
fi
|
| 350 |
+
cd $(DESTDIR)$(man3dir) && rm -f zlib.3
|
| 351 |
+
cd $(DESTDIR)$(pkgconfigdir) && rm -f zlib.pc
|
| 352 |
+
|
| 353 |
+
docs: zlib.3.pdf
|
| 354 |
+
|
| 355 |
+
zlib.3.pdf: $(SRCDIR)zlib.3
|
| 356 |
+
groff -mandoc -f H -T ps $(SRCDIR)zlib.3 | ps2pdf - $@
|
| 357 |
+
|
| 358 |
+
# zconf.h.cmakein: $(SRCDIR)zconf.h.in
|
| 359 |
+
# -@ TEMPFILE=zconfh_$$; \
|
| 360 |
+
# echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" >> $$TEMPFILE &&\
|
| 361 |
+
# sed -f $$TEMPFILE $(SRCDIR)zconf.h.in > $@ &&\
|
| 362 |
+
# touch -r $(SRCDIR)zconf.h.in $@ &&\
|
| 363 |
+
# rm $$TEMPFILE
|
| 364 |
+
#
|
| 365 |
+
|
| 366 |
+
zconf: $(SRCDIR)zconf.h.in
|
| 367 |
+
cp -p $(SRCDIR)zconf.h.in zconf.h
|
| 368 |
+
|
| 369 |
+
minizip-test: static
|
| 370 |
+
cd contrib/minizip && { CC="$(CC)" CFLAGS="$(CFLAGS)" $(MAKE) test ; cd ../.. ; }
|
| 371 |
+
|
| 372 |
+
minizip-clean:
|
| 373 |
+
cd contrib/minizip && { $(MAKE) clean ; cd ../.. ; }
|
| 374 |
+
|
| 375 |
+
mostlyclean: clean
|
| 376 |
+
clean: minizip-clean
|
| 377 |
+
rm -f *.o *.lo *~ \
|
| 378 |
+
example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
|
| 379 |
+
example64$(EXE) minigzip64$(EXE) \
|
| 380 |
+
infcover \
|
| 381 |
+
libz.* foo.gz so_locations \
|
| 382 |
+
_match.s maketree contrib/infback9/*.o
|
| 383 |
+
rm -rf objs
|
| 384 |
+
rm -f *.gcda *.gcno *.gcov
|
| 385 |
+
rm -f contrib/infback9/*.gcda contrib/infback9/*.gcno contrib/infback9/*.gcov
|
| 386 |
+
|
| 387 |
+
maintainer-clean: distclean
|
| 388 |
+
distclean: clean zconf # zconf.h.cmakein
|
| 389 |
+
rm -f Makefile zlib.pc configure.log
|
| 390 |
+
-@rm -f .DS_Store
|
| 391 |
+
@if [ -f Makefile.in ]; then \
|
| 392 |
+
printf 'all:\n\t-@echo "Please use ./configure first. Thank you."\n' > Makefile ; \
|
| 393 |
+
printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile ; \
|
| 394 |
+
touch -r $(SRCDIR)Makefile.in Makefile ; fi
|
| 395 |
+
|
| 396 |
+
tags:
|
| 397 |
+
etags $(SRCDIR)*.[ch]
|
| 398 |
+
|
| 399 |
+
adler32.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
|
| 400 |
+
zutil.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
|
| 401 |
+
gzclose.o gzlib.o gzread.o gzwrite.o: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
|
| 402 |
+
compress.o example.o minigzip.o uncompr.o: $(SRCDIR)zlib.h zconf.h
|
| 403 |
+
crc32.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h
|
| 404 |
+
deflate.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
|
| 405 |
+
infback.o inflate.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h $(SRCDIR)inffixed.h
|
| 406 |
+
inffast.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
|
| 407 |
+
inftrees.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
|
| 408 |
+
trees.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
|
| 409 |
+
|
| 410 |
+
adler32.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
|
| 411 |
+
zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
|
| 412 |
+
gzclose.lo gzlib.lo gzread.lo gzwrite.lo: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
|
| 413 |
+
compress.lo example.lo minigzip.lo uncompr.lo: $(SRCDIR)zlib.h zconf.h
|
| 414 |
+
crc32.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h
|
| 415 |
+
deflate.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
|
| 416 |
+
infback.lo inflate.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h $(SRCDIR)inffixed.h
|
| 417 |
+
inffast.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
|
| 418 |
+
inftrees.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
|
| 419 |
+
trees.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
|
README
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ZLIB DATA COMPRESSION LIBRARY
|
| 2 |
+
|
| 3 |
+
zlib 1.3.1.1 is a general purpose data compression library. All the code is
|
| 4 |
+
thread safe. The data format used by the zlib library is described by RFCs
|
| 5 |
+
(Request for Comments) 1950 to 1952 in the files
|
| 6 |
+
http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
|
| 7 |
+
rfc1952 (gzip format).
|
| 8 |
+
|
| 9 |
+
All functions of the compression library are documented in the file zlib.h
|
| 10 |
+
(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example
|
| 11 |
+
of the library is given in the file test/example.c which also tests that
|
| 12 |
+
the library is working correctly. Another example is given in the file
|
| 13 |
+
test/minigzip.c. The compression library itself is composed of all source
|
| 14 |
+
files in the root directory.
|
| 15 |
+
|
| 16 |
+
To compile all files and run the test program, follow the instructions given at
|
| 17 |
+
the top of Makefile.in. In short "./configure; make test", and if that goes
|
| 18 |
+
well, "make install" should work for most flavors of Unix. For Windows, use
|
| 19 |
+
one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use
|
| 20 |
+
make_vms.com.
|
| 21 |
+
|
| 22 |
+
Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant
|
| 23 |
+
<info@winimage.com> for the Windows DLL version. The zlib home page is
|
| 24 |
+
http://zlib.net/ . Before reporting a problem, please check this site to
|
| 25 |
+
verify that you have the latest version of zlib; otherwise get the latest
|
| 26 |
+
version and check whether the problem still exists or not.
|
| 27 |
+
|
| 28 |
+
PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help.
|
| 29 |
+
|
| 30 |
+
Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
|
| 31 |
+
issue of Dr. Dobb's Journal; a copy of the article is available at
|
| 32 |
+
https://marknelson.us/posts/1997/01/01/zlib-engine.html .
|
| 33 |
+
|
| 34 |
+
The changes made in version 1.3.1.1 are documented in the file ChangeLog.
|
| 35 |
+
|
| 36 |
+
Unsupported third party contributions are provided in directory contrib/ .
|
| 37 |
+
|
| 38 |
+
zlib is available in Java using the java.util.zip package. Follow the API
|
| 39 |
+
Documentation link at: https://docs.oracle.com/search/?q=java.util.zip .
|
| 40 |
+
|
| 41 |
+
A Perl interface to zlib and bzip2 written by Paul Marquess <pmqs@cpan.org>
|
| 42 |
+
can be found at https://github.com/pmqs/IO-Compress .
|
| 43 |
+
|
| 44 |
+
A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
|
| 45 |
+
available in Python 1.5 and later versions, see
|
| 46 |
+
http://docs.python.org/library/zlib.html .
|
| 47 |
+
|
| 48 |
+
zlib is built into tcl: http://wiki.tcl.tk/4610 .
|
| 49 |
+
|
| 50 |
+
An experimental package to read and write files in .zip format, written on top
|
| 51 |
+
of zlib by Gilles Vollant <info@winimage.com>, is available in the
|
| 52 |
+
contrib/minizip directory of zlib.
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
Notes for some targets:
|
| 56 |
+
|
| 57 |
+
- For Windows DLL versions, please see win32/DLL_FAQ.txt
|
| 58 |
+
|
| 59 |
+
- For 64-bit Irix, deflate.c must be compiled without any optimization. With
|
| 60 |
+
-O, one libpng test fails. The test works in 32 bit mode (with the -n32
|
| 61 |
+
compiler flag). The compiler bug has been reported to SGI.
|
| 62 |
+
|
| 63 |
+
- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works
|
| 64 |
+
when compiled with cc.
|
| 65 |
+
|
| 66 |
+
- On Digital Unix 4.0D (formerly OSF/1) on AlphaServer, the cc option -std1 is
|
| 67 |
+
necessary to get gzprintf working correctly. This is done by configure.
|
| 68 |
+
|
| 69 |
+
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
|
| 70 |
+
other compilers. Use "make test" to check your compiler.
|
| 71 |
+
|
| 72 |
+
- For PalmOs, see http://palmzlib.sourceforge.net/
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
Acknowledgments:
|
| 76 |
+
|
| 77 |
+
The deflate format used by zlib was defined by Phil Katz. The deflate and
|
| 78 |
+
zlib specifications were written by L. Peter Deutsch. Thanks to all the
|
| 79 |
+
people who reported problems and suggested various improvements in zlib; they
|
| 80 |
+
are too numerous to cite here.
|
| 81 |
+
|
| 82 |
+
Copyright notice:
|
| 83 |
+
|
| 84 |
+
(C) 1995-2024 Jean-loup Gailly and Mark Adler
|
| 85 |
+
|
| 86 |
+
This software is provided 'as-is', without any express or implied
|
| 87 |
+
warranty. In no event will the authors be held liable for any damages
|
| 88 |
+
arising from the use of this software.
|
| 89 |
+
|
| 90 |
+
Permission is granted to anyone to use this software for any purpose,
|
| 91 |
+
including commercial applications, and to alter it and redistribute it
|
| 92 |
+
freely, subject to the following restrictions:
|
| 93 |
+
|
| 94 |
+
1. The origin of this software must not be misrepresented; you must not
|
| 95 |
+
claim that you wrote the original software. If you use this software
|
| 96 |
+
in a product, an acknowledgment in the product documentation would be
|
| 97 |
+
appreciated but is not required.
|
| 98 |
+
2. Altered source versions must be plainly marked as such, and must not be
|
| 99 |
+
misrepresented as being the original software.
|
| 100 |
+
3. This notice may not be removed or altered from any source distribution.
|
| 101 |
+
|
| 102 |
+
Jean-loup Gailly Mark Adler
|
| 103 |
+
jloup@gzip.org madler@alumni.caltech.edu
|
| 104 |
+
|
| 105 |
+
If you use the zlib library in a product, we would appreciate *not* receiving
|
| 106 |
+
lengthy legal documents to sign. The sources are provided for free but without
|
| 107 |
+
warranty of any kind. The library has been entirely written by Jean-loup
|
| 108 |
+
Gailly and Mark Adler; it does not include third-party code. We make all
|
| 109 |
+
contributions to and distributions of this project solely in our personal
|
| 110 |
+
capacity, and are not conveying any rights to any intellectual property of
|
| 111 |
+
any third parties.
|
| 112 |
+
|
| 113 |
+
If you redistribute modified sources, we would appreciate that you include in
|
| 114 |
+
the file ChangeLog history information documenting your changes. Please read
|
| 115 |
+
the FAQ for more information on the distribution of modified source versions.
|
README-cmake.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# For building with cmake at least version 3.12 (minizip 3.12) is needed
|
| 2 |
+
|
| 3 |
+
In most cases the usual
|
| 4 |
+
|
| 5 |
+
cmake -S . -B build -D CMAKE_BUILD_TYPE=Release
|
| 6 |
+
|
| 7 |
+
will create everything you need, however if you want something off default you can adjust several options fit your needs.
|
| 8 |
+
Every option is list below (excluding the cmake-standard options), they can be set via cmake-gui or on cmdline with
|
| 9 |
+
|
| 10 |
+
-D<option>=ON/OFF
|
| 11 |
+
|
| 12 |
+
## ZLIB-options with defaults ##
|
| 13 |
+
|
| 14 |
+
ZLIB_BUILD_TESTING=ON -- Enable Zlib Examples as tests
|
| 15 |
+
|
| 16 |
+
ZLIB_BUILD_SHARED=ON -- Enable building zlib shared library
|
| 17 |
+
|
| 18 |
+
ZLIB_BUILD_STATIC=ON -- Enable building zlib static library
|
| 19 |
+
|
| 20 |
+
ZLIB_BUILD_MINIZIP=ON -- Enable building libminizip contrib library
|
| 21 |
+
|
| 22 |
+
If this option is turned on, additional options are available from minizip (see below)
|
| 23 |
+
|
| 24 |
+
ZLIB_INSTALL=ON -- Enable installation of zlib
|
| 25 |
+
|
| 26 |
+
ZLIB_PREFIX=OFF -- prefix for all types and library functions, see zconf.h.in
|
| 27 |
+
|
| 28 |
+
ZLIB_INSTALL_COMPAT_DLL=ON -- Install a copy as zlib1.dll
|
| 29 |
+
|
| 30 |
+
This option is only on windows available and may/will be turned off and removed somewhen in the future.
|
| 31 |
+
If you rely cmake for finding and using zlib, this can be turned off, as `zlib1.dll` will never be used.
|
| 32 |
+
|
| 33 |
+
## minizip-options with defaults ##
|
| 34 |
+
|
| 35 |
+
MINIZIP_BUILD_SHARED=ON -- Enable building minizip shared library
|
| 36 |
+
|
| 37 |
+
MINIZIP_BUILD_STATIC=ON -- Enable building minizip static library
|
| 38 |
+
|
| 39 |
+
MINIZIP_BUILD_TESTING=ON -- Enable testing of minizip
|
| 40 |
+
|
| 41 |
+
MINIZIP_ENABLE_BZIP2=ON -- Build minizip withj bzip2 support
|
| 42 |
+
|
| 43 |
+
A usable installation of bzip2 is needed or config will fail. Turn this option of in this case.
|
| 44 |
+
|
| 45 |
+
MINIZIP_INSTALL=ON -- Enable installation of minizip
|
| 46 |
+
|
| 47 |
+
MINIZIP_INSTALL_COMPAT_DLL=ON -- Install a copy as libminizip-1.dll
|
| 48 |
+
|
| 49 |
+
This option is only available on mingw as they tend to name this lib different. Maybe this will also be
|
| 50 |
+
removed in the future as. If you rely cmake for finding and using zlib, this can be turned off, as
|
| 51 |
+
the other file will never be used.
|
| 52 |
+
|
| 53 |
+
## Using the libs ##
|
| 54 |
+
|
| 55 |
+
To pull in what you need it's enough to just write
|
| 56 |
+
|
| 57 |
+
find_package(ZLIB CONFIG)
|
| 58 |
+
|
| 59 |
+
or
|
| 60 |
+
|
| 61 |
+
find_package(minizip CONFIG)
|
| 62 |
+
|
| 63 |
+
in your CMakeLists.txt, however it is advised to specify what you really want via:
|
| 64 |
+
|
| 65 |
+
find_package(ZLIB CONFIG COMPONENTS shared static REQUIRED)
|
| 66 |
+
|
| 67 |
+
or
|
| 68 |
+
|
| 69 |
+
find_package(minizip CONFIG COMPONENTS shared static REQUIRED)
|
| 70 |
+
|
| 71 |
+
As it's possible to only build the shared or the static lib, you can make sure that everything you need
|
| 72 |
+
is found. If no COMPONENTS are requested, everything that is found will satisfy your request. If the
|
| 73 |
+
libraries are optional in you project, you can omit the REQUIRED and check yourself if the targets you
|
| 74 |
+
want to link against are created.
|
| 75 |
+
|
| 76 |
+
When you search for minizip, it will search zlib for you, so only one of both is needed.
|
| 77 |
+
|
| 78 |
+
## Imported targets ##
|
| 79 |
+
|
| 80 |
+
When found the following targets are created for you:
|
| 81 |
+
|
| 82 |
+
ZLIB::ZLIB and ZLIB::ZLIBSTATIC -- for zlib
|
| 83 |
+
MINIZIP::minizip and MINIZIP::minizipstatic -- for minizip
|
adler32.c
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* adler32.c -- compute the Adler-32 checksum of a data stream
|
| 2 |
+
* Copyright (C) 1995-2011, 2016 Mark Adler
|
| 3 |
+
* For conditions of distribution and use, see copyright notice in zlib.h
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
/* @(#) $Id$ */
|
| 7 |
+
|
| 8 |
+
#include "zutil.h"
|
| 9 |
+
|
| 10 |
+
#define BASE 65521U /* largest prime smaller than 65536 */
|
| 11 |
+
#define NMAX 5552
|
| 12 |
+
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
| 13 |
+
|
| 14 |
+
#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
|
| 15 |
+
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
|
| 16 |
+
#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
|
| 17 |
+
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
|
| 18 |
+
#define DO16(buf) DO8(buf,0); DO8(buf,8);
|
| 19 |
+
|
| 20 |
+
/* use NO_DIVIDE if your processor does not do division in hardware --
|
| 21 |
+
try it both ways to see which is faster */
|
| 22 |
+
#ifdef NO_DIVIDE
|
| 23 |
+
/* note that this assumes BASE is 65521, where 65536 % 65521 == 15
|
| 24 |
+
(thank you to John Reiser for pointing this out) */
|
| 25 |
+
# define CHOP(a) \
|
| 26 |
+
do { \
|
| 27 |
+
unsigned long tmp = a >> 16; \
|
| 28 |
+
a &= 0xffffUL; \
|
| 29 |
+
a += (tmp << 4) - tmp; \
|
| 30 |
+
} while (0)
|
| 31 |
+
# define MOD28(a) \
|
| 32 |
+
do { \
|
| 33 |
+
CHOP(a); \
|
| 34 |
+
if (a >= BASE) a -= BASE; \
|
| 35 |
+
} while (0)
|
| 36 |
+
# define MOD(a) \
|
| 37 |
+
do { \
|
| 38 |
+
CHOP(a); \
|
| 39 |
+
MOD28(a); \
|
| 40 |
+
} while (0)
|
| 41 |
+
# define MOD63(a) \
|
| 42 |
+
do { /* this assumes a is not negative */ \
|
| 43 |
+
z_off64_t tmp = a >> 32; \
|
| 44 |
+
a &= 0xffffffffL; \
|
| 45 |
+
a += (tmp << 8) - (tmp << 5) + tmp; \
|
| 46 |
+
tmp = a >> 16; \
|
| 47 |
+
a &= 0xffffL; \
|
| 48 |
+
a += (tmp << 4) - tmp; \
|
| 49 |
+
tmp = a >> 16; \
|
| 50 |
+
a &= 0xffffL; \
|
| 51 |
+
a += (tmp << 4) - tmp; \
|
| 52 |
+
if (a >= BASE) a -= BASE; \
|
| 53 |
+
} while (0)
|
| 54 |
+
#else
|
| 55 |
+
# define MOD(a) a %= BASE
|
| 56 |
+
# define MOD28(a) a %= BASE
|
| 57 |
+
# define MOD63(a) a %= BASE
|
| 58 |
+
#endif
|
| 59 |
+
|
| 60 |
+
/* ========================================================================= */
|
| 61 |
+
uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) {
|
| 62 |
+
unsigned long sum2;
|
| 63 |
+
unsigned n;
|
| 64 |
+
|
| 65 |
+
/* split Adler-32 into component sums */
|
| 66 |
+
sum2 = (adler >> 16) & 0xffff;
|
| 67 |
+
adler &= 0xffff;
|
| 68 |
+
|
| 69 |
+
/* in case user likes doing a byte at a time, keep it fast */
|
| 70 |
+
if (len == 1) {
|
| 71 |
+
adler += buf[0];
|
| 72 |
+
if (adler >= BASE)
|
| 73 |
+
adler -= BASE;
|
| 74 |
+
sum2 += adler;
|
| 75 |
+
if (sum2 >= BASE)
|
| 76 |
+
sum2 -= BASE;
|
| 77 |
+
return adler | (sum2 << 16);
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
/* initial Adler-32 value (deferred check for len == 1 speed) */
|
| 81 |
+
if (buf == Z_NULL)
|
| 82 |
+
return 1L;
|
| 83 |
+
|
| 84 |
+
/* in case short lengths are provided, keep it somewhat fast */
|
| 85 |
+
if (len < 16) {
|
| 86 |
+
while (len--) {
|
| 87 |
+
adler += *buf++;
|
| 88 |
+
sum2 += adler;
|
| 89 |
+
}
|
| 90 |
+
if (adler >= BASE)
|
| 91 |
+
adler -= BASE;
|
| 92 |
+
MOD28(sum2); /* only added so many BASE's */
|
| 93 |
+
return adler | (sum2 << 16);
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
/* do length NMAX blocks -- requires just one modulo operation */
|
| 97 |
+
while (len >= NMAX) {
|
| 98 |
+
len -= NMAX;
|
| 99 |
+
n = NMAX / 16; /* NMAX is divisible by 16 */
|
| 100 |
+
do {
|
| 101 |
+
DO16(buf); /* 16 sums unrolled */
|
| 102 |
+
buf += 16;
|
| 103 |
+
} while (--n);
|
| 104 |
+
MOD(adler);
|
| 105 |
+
MOD(sum2);
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
/* do remaining bytes (less than NMAX, still just one modulo) */
|
| 109 |
+
if (len) { /* avoid modulos if none remaining */
|
| 110 |
+
while (len >= 16) {
|
| 111 |
+
len -= 16;
|
| 112 |
+
DO16(buf);
|
| 113 |
+
buf += 16;
|
| 114 |
+
}
|
| 115 |
+
while (len--) {
|
| 116 |
+
adler += *buf++;
|
| 117 |
+
sum2 += adler;
|
| 118 |
+
}
|
| 119 |
+
MOD(adler);
|
| 120 |
+
MOD(sum2);
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
/* return recombined sums */
|
| 124 |
+
return adler | (sum2 << 16);
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
/* ========================================================================= */
|
| 128 |
+
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) {
|
| 129 |
+
return adler32_z(adler, buf, len);
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
/* ========================================================================= */
|
| 133 |
+
local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) {
|
| 134 |
+
unsigned long sum1;
|
| 135 |
+
unsigned long sum2;
|
| 136 |
+
unsigned rem;
|
| 137 |
+
|
| 138 |
+
/* for negative len, return invalid adler32 as a clue for debugging */
|
| 139 |
+
if (len2 < 0)
|
| 140 |
+
return 0xffffffffUL;
|
| 141 |
+
|
| 142 |
+
/* the derivation of this formula is left as an exercise for the reader */
|
| 143 |
+
MOD63(len2); /* assumes len2 >= 0 */
|
| 144 |
+
rem = (unsigned)len2;
|
| 145 |
+
sum1 = adler1 & 0xffff;
|
| 146 |
+
sum2 = rem * sum1;
|
| 147 |
+
MOD(sum2);
|
| 148 |
+
sum1 += (adler2 & 0xffff) + BASE - 1;
|
| 149 |
+
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
|
| 150 |
+
if (sum1 >= BASE) sum1 -= BASE;
|
| 151 |
+
if (sum1 >= BASE) sum1 -= BASE;
|
| 152 |
+
if (sum2 >= ((unsigned long)BASE << 1)) sum2 -= ((unsigned long)BASE << 1);
|
| 153 |
+
if (sum2 >= BASE) sum2 -= BASE;
|
| 154 |
+
return sum1 | (sum2 << 16);
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
/* ========================================================================= */
|
| 158 |
+
uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) {
|
| 159 |
+
return adler32_combine_(adler1, adler2, len2);
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2) {
|
| 163 |
+
return adler32_combine_(adler1, adler2, len2);
|
| 164 |
+
}
|
amiga/Makefile.pup
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Amiga powerUP (TM) Makefile
|
| 2 |
+
# makefile for libpng and SAS C V6.58/7.00 PPC compiler
|
| 3 |
+
# Copyright (C) 1998 by Andreas R. Kleinert
|
| 4 |
+
|
| 5 |
+
LIBNAME = libzip.a
|
| 6 |
+
|
| 7 |
+
CC = scppc
|
| 8 |
+
CFLAGS = NOSTKCHK NOSINT OPTIMIZE OPTGO OPTPEEP OPTINLOCAL OPTINL \
|
| 9 |
+
OPTLOOP OPTRDEP=8 OPTDEP=8 OPTCOMP=8 NOVER
|
| 10 |
+
AR = ppc-amigaos-ar cr
|
| 11 |
+
RANLIB = ppc-amigaos-ranlib
|
| 12 |
+
LD = ppc-amigaos-ld -r
|
| 13 |
+
LDFLAGS = -o
|
| 14 |
+
LDLIBS = LIB:scppc.a LIB:end.o
|
| 15 |
+
RM = delete quiet
|
| 16 |
+
|
| 17 |
+
OBJS = adler32.o compress.o crc32.o gzclose.o gzlib.o gzread.o gzwrite.o \
|
| 18 |
+
uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o
|
| 19 |
+
|
| 20 |
+
TEST_OBJS = example.o minigzip.o
|
| 21 |
+
|
| 22 |
+
all: example minigzip
|
| 23 |
+
|
| 24 |
+
check: test
|
| 25 |
+
test: all
|
| 26 |
+
example
|
| 27 |
+
echo hello world | minigzip | minigzip -d
|
| 28 |
+
|
| 29 |
+
$(LIBNAME): $(OBJS)
|
| 30 |
+
$(AR) $@ $(OBJS)
|
| 31 |
+
-$(RANLIB) $@
|
| 32 |
+
|
| 33 |
+
example: example.o $(LIBNAME)
|
| 34 |
+
$(LD) $(LDFLAGS) $@ LIB:c_ppc.o $@.o $(LIBNAME) $(LDLIBS)
|
| 35 |
+
|
| 36 |
+
minigzip: minigzip.o $(LIBNAME)
|
| 37 |
+
$(LD) $(LDFLAGS) $@ LIB:c_ppc.o $@.o $(LIBNAME) $(LDLIBS)
|
| 38 |
+
|
| 39 |
+
mostlyclean: clean
|
| 40 |
+
clean:
|
| 41 |
+
$(RM) *.o example minigzip $(LIBNAME) foo.gz
|
| 42 |
+
|
| 43 |
+
zip:
|
| 44 |
+
zip -ul9 zlib README ChangeLog Makefile Make????.??? Makefile.?? \
|
| 45 |
+
descrip.mms *.[ch]
|
| 46 |
+
|
| 47 |
+
tgz:
|
| 48 |
+
cd ..; tar cfz zlib/zlib.tgz zlib/README zlib/ChangeLog zlib/Makefile \
|
| 49 |
+
zlib/Make????.??? zlib/Makefile.?? zlib/descrip.mms zlib/*.[ch]
|
| 50 |
+
|
| 51 |
+
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
| 52 |
+
|
| 53 |
+
adler32.o: zlib.h zconf.h
|
| 54 |
+
compress.o: zlib.h zconf.h
|
| 55 |
+
crc32.o: crc32.h zlib.h zconf.h
|
| 56 |
+
deflate.o: deflate.h zutil.h zlib.h zconf.h
|
| 57 |
+
example.o: zlib.h zconf.h
|
| 58 |
+
gzclose.o: zlib.h zconf.h gzguts.h
|
| 59 |
+
gzlib.o: zlib.h zconf.h gzguts.h
|
| 60 |
+
gzread.o: zlib.h zconf.h gzguts.h
|
| 61 |
+
gzwrite.o: zlib.h zconf.h gzguts.h
|
| 62 |
+
inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
|
| 63 |
+
inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
|
| 64 |
+
infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
|
| 65 |
+
inftrees.o: zutil.h zlib.h zconf.h inftrees.h
|
| 66 |
+
minigzip.o: zlib.h zconf.h
|
| 67 |
+
trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
|
| 68 |
+
uncompr.o: zlib.h zconf.h
|
| 69 |
+
zutil.o: zutil.h zlib.h zconf.h
|
amiga/Makefile.sas
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SMakefile for zlib
|
| 2 |
+
# Modified from the standard UNIX Makefile Copyright Jean-loup Gailly
|
| 3 |
+
# Osma Ahvenlampi <Osma.Ahvenlampi@hut.fi>
|
| 4 |
+
# Amiga, SAS/C 6.56 & Smake
|
| 5 |
+
|
| 6 |
+
CC=sc
|
| 7 |
+
CFLAGS=OPT
|
| 8 |
+
#CFLAGS=OPT CPU=68030
|
| 9 |
+
#CFLAGS=DEBUG=LINE
|
| 10 |
+
LDFLAGS=LIB z.lib
|
| 11 |
+
|
| 12 |
+
SCOPTIONS=OPTSCHED OPTINLINE OPTALIAS OPTTIME OPTINLOCAL STRMERGE \
|
| 13 |
+
NOICONS PARMS=BOTH NOSTACKCHECK UTILLIB NOVERSION ERRORREXX \
|
| 14 |
+
DEF=POSTINC
|
| 15 |
+
|
| 16 |
+
OBJS = adler32.o compress.o crc32.o gzclose.o gzlib.o gzread.o gzwrite.o \
|
| 17 |
+
uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o
|
| 18 |
+
|
| 19 |
+
TEST_OBJS = example.o minigzip.o
|
| 20 |
+
|
| 21 |
+
all: SCOPTIONS example minigzip
|
| 22 |
+
|
| 23 |
+
check: test
|
| 24 |
+
test: all
|
| 25 |
+
example
|
| 26 |
+
echo hello world | minigzip | minigzip -d
|
| 27 |
+
|
| 28 |
+
install: z.lib
|
| 29 |
+
copy clone zlib.h zconf.h INCLUDE:
|
| 30 |
+
copy clone z.lib LIB:
|
| 31 |
+
|
| 32 |
+
z.lib: $(OBJS)
|
| 33 |
+
oml z.lib r $(OBJS)
|
| 34 |
+
|
| 35 |
+
example: example.o z.lib
|
| 36 |
+
$(CC) $(CFLAGS) LINK TO $@ example.o $(LDFLAGS)
|
| 37 |
+
|
| 38 |
+
minigzip: minigzip.o z.lib
|
| 39 |
+
$(CC) $(CFLAGS) LINK TO $@ minigzip.o $(LDFLAGS)
|
| 40 |
+
|
| 41 |
+
mostlyclean: clean
|
| 42 |
+
clean:
|
| 43 |
+
-delete force quiet example minigzip *.o z.lib foo.gz *.lnk SCOPTIONS
|
| 44 |
+
|
| 45 |
+
SCOPTIONS: Makefile.sas
|
| 46 |
+
copy to $@ <from <
|
| 47 |
+
$(SCOPTIONS)
|
| 48 |
+
<
|
| 49 |
+
|
| 50 |
+
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
| 51 |
+
|
| 52 |
+
adler32.o: zlib.h zconf.h
|
| 53 |
+
compress.o: zlib.h zconf.h
|
| 54 |
+
crc32.o: crc32.h zlib.h zconf.h
|
| 55 |
+
deflate.o: deflate.h zutil.h zlib.h zconf.h
|
| 56 |
+
example.o: zlib.h zconf.h
|
| 57 |
+
gzclose.o: zlib.h zconf.h gzguts.h
|
| 58 |
+
gzlib.o: zlib.h zconf.h gzguts.h
|
| 59 |
+
gzread.o: zlib.h zconf.h gzguts.h
|
| 60 |
+
gzwrite.o: zlib.h zconf.h gzguts.h
|
| 61 |
+
inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
|
| 62 |
+
inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
|
| 63 |
+
infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
|
| 64 |
+
inftrees.o: zutil.h zlib.h zconf.h inftrees.h
|
| 65 |
+
minigzip.o: zlib.h zconf.h
|
| 66 |
+
trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
|
| 67 |
+
uncompr.o: zlib.h zconf.h
|
| 68 |
+
zutil.o: zutil.h zlib.h zconf.h
|
compress.c
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* compress.c -- compress a memory buffer
|
| 2 |
+
* Copyright (C) 1995-2005, 2014, 2016 Jean-loup Gailly, Mark Adler
|
| 3 |
+
* For conditions of distribution and use, see copyright notice in zlib.h
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
/* @(#) $Id$ */
|
| 7 |
+
|
| 8 |
+
#define ZLIB_INTERNAL
|
| 9 |
+
#include "zlib.h"
|
| 10 |
+
|
| 11 |
+
/* ===========================================================================
|
| 12 |
+
Compresses the source buffer into the destination buffer. The level
|
| 13 |
+
parameter has the same meaning as in deflateInit. sourceLen is the byte
|
| 14 |
+
length of the source buffer. Upon entry, destLen is the total size of the
|
| 15 |
+
destination buffer, which must be at least 0.1% larger than sourceLen plus
|
| 16 |
+
12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
|
| 17 |
+
|
| 18 |
+
compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
| 19 |
+
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
|
| 20 |
+
Z_STREAM_ERROR if the level parameter is invalid.
|
| 21 |
+
*/
|
| 22 |
+
int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
|
| 23 |
+
uLong sourceLen, int level) {
|
| 24 |
+
z_stream stream;
|
| 25 |
+
int err;
|
| 26 |
+
const uInt max = (uInt)-1;
|
| 27 |
+
uLong left;
|
| 28 |
+
|
| 29 |
+
left = *destLen;
|
| 30 |
+
*destLen = 0;
|
| 31 |
+
|
| 32 |
+
stream.zalloc = (alloc_func)0;
|
| 33 |
+
stream.zfree = (free_func)0;
|
| 34 |
+
stream.opaque = (voidpf)0;
|
| 35 |
+
|
| 36 |
+
err = deflateInit(&stream, level);
|
| 37 |
+
if (err != Z_OK) return err;
|
| 38 |
+
|
| 39 |
+
stream.next_out = dest;
|
| 40 |
+
stream.avail_out = 0;
|
| 41 |
+
stream.next_in = (z_const Bytef *)source;
|
| 42 |
+
stream.avail_in = 0;
|
| 43 |
+
|
| 44 |
+
do {
|
| 45 |
+
if (stream.avail_out == 0) {
|
| 46 |
+
stream.avail_out = left > (uLong)max ? max : (uInt)left;
|
| 47 |
+
left -= stream.avail_out;
|
| 48 |
+
}
|
| 49 |
+
if (stream.avail_in == 0) {
|
| 50 |
+
stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen;
|
| 51 |
+
sourceLen -= stream.avail_in;
|
| 52 |
+
}
|
| 53 |
+
err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH);
|
| 54 |
+
} while (err == Z_OK);
|
| 55 |
+
|
| 56 |
+
*destLen = stream.total_out;
|
| 57 |
+
deflateEnd(&stream);
|
| 58 |
+
return err == Z_STREAM_END ? Z_OK : err;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
/* ===========================================================================
|
| 62 |
+
*/
|
| 63 |
+
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source,
|
| 64 |
+
uLong sourceLen) {
|
| 65 |
+
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
/* ===========================================================================
|
| 69 |
+
If the default memLevel or windowBits for deflateInit() is changed, then
|
| 70 |
+
this function needs to be updated.
|
| 71 |
+
*/
|
| 72 |
+
uLong ZEXPORT compressBound(uLong sourceLen) {
|
| 73 |
+
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
|
| 74 |
+
(sourceLen >> 25) + 13;
|
| 75 |
+
}
|
configure
ADDED
|
@@ -0,0 +1,966 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
# configure script for zlib.
|
| 3 |
+
#
|
| 4 |
+
# Normally configure builds both a static and a shared library.
|
| 5 |
+
# If you want to build just a static library, use: ./configure --static
|
| 6 |
+
#
|
| 7 |
+
# To impose specific compiler or flags or install directory, use for example:
|
| 8 |
+
# prefix=$HOME CC=cc CFLAGS="-O4" ./configure
|
| 9 |
+
# or for csh/tcsh users:
|
| 10 |
+
# (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure)
|
| 11 |
+
|
| 12 |
+
# Incorrect settings of CC or CFLAGS may prevent creating a shared library.
|
| 13 |
+
# If you have problems, try without defining CC and CFLAGS before reporting
|
| 14 |
+
# an error.
|
| 15 |
+
|
| 16 |
+
# start off configure.log
|
| 17 |
+
echo -------------------- >> configure.log
|
| 18 |
+
echo $0 $* >> configure.log
|
| 19 |
+
date >> configure.log
|
| 20 |
+
|
| 21 |
+
# get source directory
|
| 22 |
+
SRCDIR=`dirname $0`
|
| 23 |
+
if test $SRCDIR = "."; then
|
| 24 |
+
ZINC=""
|
| 25 |
+
ZINCOUT="-I."
|
| 26 |
+
SRCDIR=""
|
| 27 |
+
else
|
| 28 |
+
ZINC='-I. -include zconf.h'
|
| 29 |
+
ZINCOUT='-I. -I$(SRCDIR)'
|
| 30 |
+
SRCDIR="$SRCDIR/"
|
| 31 |
+
fi
|
| 32 |
+
|
| 33 |
+
# set command prefix for cross-compilation
|
| 34 |
+
if [ -n "${CHOST}" ]; then
|
| 35 |
+
uname=${CHOST}
|
| 36 |
+
mname=${CHOST}
|
| 37 |
+
CROSS_PREFIX="${CHOST}-"
|
| 38 |
+
else
|
| 39 |
+
mname=`(uname -a || echo unknown) 2>/dev/null`
|
| 40 |
+
fi
|
| 41 |
+
|
| 42 |
+
# destination name for static library
|
| 43 |
+
STATICLIB=libz.a
|
| 44 |
+
|
| 45 |
+
# extract zlib version numbers from zlib.h
|
| 46 |
+
VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}zlib.h`
|
| 47 |
+
VER3=`echo ${VER}|sed -n -e 's/\([0-9]\{1,\}\(\\.[0-9]\{1,\}\)\{1,2\}\).*/\1/p'`
|
| 48 |
+
VER1=`echo ${VER}|sed -n -e 's/\([0-9]\{1,\}\)\\..*/\1/p'`
|
| 49 |
+
|
| 50 |
+
# establish commands for library building
|
| 51 |
+
if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then
|
| 52 |
+
AR=${AR-"${CROSS_PREFIX}ar"}
|
| 53 |
+
test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
|
| 54 |
+
else
|
| 55 |
+
AR=${AR-"ar"}
|
| 56 |
+
test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log
|
| 57 |
+
fi
|
| 58 |
+
ARFLAGS=${ARFLAGS-"rc"}
|
| 59 |
+
if "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null || test $? -lt 126; then
|
| 60 |
+
RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"}
|
| 61 |
+
test -n "${CROSS_PREFIX}" && echo Using ${RANLIB} | tee -a configure.log
|
| 62 |
+
else
|
| 63 |
+
RANLIB=${RANLIB-"ranlib"}
|
| 64 |
+
fi
|
| 65 |
+
if "${CROSS_PREFIX}nm" --version >/dev/null 2>/dev/null || test $? -lt 126; then
|
| 66 |
+
NM=${NM-"${CROSS_PREFIX}nm"}
|
| 67 |
+
test -n "${CROSS_PREFIX}" && echo Using ${NM} | tee -a configure.log
|
| 68 |
+
else
|
| 69 |
+
NM=${NM-"nm"}
|
| 70 |
+
fi
|
| 71 |
+
|
| 72 |
+
# set defaults before processing command line options
|
| 73 |
+
LDCONFIG=${LDCONFIG-"ldconfig"}
|
| 74 |
+
LDSHAREDLIBC="${LDSHAREDLIBC--lc}"
|
| 75 |
+
ARCHS=
|
| 76 |
+
prefix=${prefix-/usr/local}
|
| 77 |
+
exec_prefix=${exec_prefix-'${prefix}'}
|
| 78 |
+
libdir=${libdir-'${exec_prefix}/lib'}
|
| 79 |
+
sharedlibdir=${sharedlibdir-'${libdir}'}
|
| 80 |
+
includedir=${includedir-'${prefix}/include'}
|
| 81 |
+
mandir=${mandir-'${prefix}/share/man'}
|
| 82 |
+
shared_ext='.so'
|
| 83 |
+
shared=1
|
| 84 |
+
solo=0
|
| 85 |
+
cover=0
|
| 86 |
+
zprefix=0
|
| 87 |
+
zconst=0
|
| 88 |
+
build64=0
|
| 89 |
+
gcc=0
|
| 90 |
+
clang=0
|
| 91 |
+
warn=0
|
| 92 |
+
debug=0
|
| 93 |
+
address=0
|
| 94 |
+
memory=0
|
| 95 |
+
unknown=0
|
| 96 |
+
old_cc="$CC"
|
| 97 |
+
old_cflags="$CFLAGS"
|
| 98 |
+
OBJC='$(OBJZ) $(OBJG)'
|
| 99 |
+
PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)'
|
| 100 |
+
|
| 101 |
+
# leave this script, optionally in a bad way
|
| 102 |
+
leave()
|
| 103 |
+
{
|
| 104 |
+
if test "$*" != "0"; then
|
| 105 |
+
echo "** $0 aborting." | tee -a configure.log
|
| 106 |
+
fi
|
| 107 |
+
rm -rf $test.[co] $test $test$shared_ext $test.gcno $test.dSYM ./--version
|
| 108 |
+
echo -------------------- >> configure.log
|
| 109 |
+
echo >> configure.log
|
| 110 |
+
echo >> configure.log
|
| 111 |
+
exit $1
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
# process command line options
|
| 115 |
+
while test $# -ge 1
|
| 116 |
+
do
|
| 117 |
+
case "$1" in
|
| 118 |
+
-h* | --help)
|
| 119 |
+
echo 'usage:' | tee -a configure.log
|
| 120 |
+
echo ' configure [--const] [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log
|
| 121 |
+
echo ' [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log
|
| 122 |
+
echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log
|
| 123 |
+
exit 0 ;;
|
| 124 |
+
-p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;;
|
| 125 |
+
-e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;;
|
| 126 |
+
-l*=* | --libdir=*) libdir=`echo $1 | sed 's/.*=//'`; shift ;;
|
| 127 |
+
--sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/.*=//'`; shift ;;
|
| 128 |
+
-i*=* | --includedir=*) includedir=`echo $1 | sed 's/.*=//'`;shift ;;
|
| 129 |
+
-u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;;
|
| 130 |
+
-p* | --prefix) prefix="$2"; shift; shift ;;
|
| 131 |
+
-e* | --eprefix) exec_prefix="$2"; shift; shift ;;
|
| 132 |
+
-l* | --libdir) libdir="$2"; shift; shift ;;
|
| 133 |
+
-i* | --includedir) includedir="$2"; shift; shift ;;
|
| 134 |
+
-s* | --shared | --enable-shared) shared=1; shift ;;
|
| 135 |
+
-t | --static) shared=0; shift ;;
|
| 136 |
+
--solo) solo=1; shift ;;
|
| 137 |
+
--cover) cover=1; shift ;;
|
| 138 |
+
-z* | --zprefix) zprefix=1; shift ;;
|
| 139 |
+
-6* | --64) build64=1; shift ;;
|
| 140 |
+
-a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
|
| 141 |
+
--sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;;
|
| 142 |
+
--localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;;
|
| 143 |
+
-c* | --const) zconst=1; shift ;;
|
| 144 |
+
-w* | --warn) warn=1; shift ;;
|
| 145 |
+
-d* | --debug) debug=1; shift ;;
|
| 146 |
+
--sanitize) address=1; shift ;;
|
| 147 |
+
--address) address=1; shift ;;
|
| 148 |
+
--memory) memory=1; shift ;;
|
| 149 |
+
*) unknown=1; echo "unknown option ignored: $1" | tee -a configure.log; shift;;
|
| 150 |
+
esac
|
| 151 |
+
done
|
| 152 |
+
if test $unknown -eq 1; then
|
| 153 |
+
echo "$0 --help for help" | tee -a configure.log
|
| 154 |
+
fi
|
| 155 |
+
|
| 156 |
+
# temporary file name
|
| 157 |
+
test=ztest$$
|
| 158 |
+
|
| 159 |
+
# put arguments in log, also put test file in log if used in arguments
|
| 160 |
+
show()
|
| 161 |
+
{
|
| 162 |
+
case "$*" in
|
| 163 |
+
*$test.c*)
|
| 164 |
+
echo === $test.c === >> configure.log
|
| 165 |
+
cat $test.c >> configure.log
|
| 166 |
+
echo === >> configure.log;;
|
| 167 |
+
esac
|
| 168 |
+
echo $* >> configure.log
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
# check for gcc vs. cc and set compile and link flags based on the system identified by uname
|
| 172 |
+
cat > $test.c <<EOF
|
| 173 |
+
extern int getchar();
|
| 174 |
+
int hello() {return getchar();}
|
| 175 |
+
EOF
|
| 176 |
+
|
| 177 |
+
if test -z "$CC"; then
|
| 178 |
+
echo Checking for ${CROSS_PREFIX}gcc... | tee -a configure.log
|
| 179 |
+
if ${CROSS_PREFIX}gcc -v >/dev/null 2>&1; then
|
| 180 |
+
cc=${CROSS_PREFIX}gcc
|
| 181 |
+
else
|
| 182 |
+
cc=${CROSS_PREFIX}cc
|
| 183 |
+
fi
|
| 184 |
+
else
|
| 185 |
+
cc=${CC}
|
| 186 |
+
fi
|
| 187 |
+
|
| 188 |
+
case "$cc" in
|
| 189 |
+
*gcc*) gcc=1
|
| 190 |
+
GCOV="gcov" ;;
|
| 191 |
+
*clang*) gcc=1
|
| 192 |
+
clang=1 ;;
|
| 193 |
+
esac
|
| 194 |
+
case `$cc -v 2>&1` in
|
| 195 |
+
*gcc*) gcc=1
|
| 196 |
+
GCOV="gcov" ;;
|
| 197 |
+
*clang*) gcc=1
|
| 198 |
+
clang=1 ;;
|
| 199 |
+
esac
|
| 200 |
+
|
| 201 |
+
if test "$clang" -eq 1; then
|
| 202 |
+
if test "$cc" = "clang"; then
|
| 203 |
+
if which -s llvm-cov; then
|
| 204 |
+
GCOV="llvm-cov"
|
| 205 |
+
LLVM_GCOV_FLAG="gcov"
|
| 206 |
+
GCOV="llvm-cov"
|
| 207 |
+
LLVM_GCOV_FLAG="gcov"
|
| 208 |
+
echo "Using ${GCOV} for coverage"
|
| 209 |
+
else
|
| 210 |
+
cover=0
|
| 211 |
+
GCOV=""
|
| 212 |
+
LLVM_GCOV_FLAG=""
|
| 213 |
+
echo "Deactivating cover as no suitable gcov can be found"
|
| 214 |
+
fi
|
| 215 |
+
else
|
| 216 |
+
clangV=`echo "$cc" | sed -e 's/^.*-//'`
|
| 217 |
+
if which -s llvm-cov-${clangV}; then
|
| 218 |
+
GCOV="llvm-cov-${clangV}"
|
| 219 |
+
LLVM_GCOV_FLAG="gcov"
|
| 220 |
+
echo "Using ${GCOV} for coverage"
|
| 221 |
+
else
|
| 222 |
+
cover=0
|
| 223 |
+
GCOV=""
|
| 224 |
+
LLVM_GCOV_FLAG=""
|
| 225 |
+
echo "Deactivating cover as no suitable gcov can be found"
|
| 226 |
+
fi
|
| 227 |
+
fi
|
| 228 |
+
fi
|
| 229 |
+
|
| 230 |
+
show $cc -c $test.c
|
| 231 |
+
if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
|
| 232 |
+
echo ... using gcc >> configure.log
|
| 233 |
+
CC="$cc"
|
| 234 |
+
CFLAGS="${CFLAGS--O3} -fPIC"
|
| 235 |
+
SFLAGS="${CFLAGS--O3}"
|
| 236 |
+
if test "$ARCHS"; then
|
| 237 |
+
CFLAGS="${CFLAGS} ${ARCHS}"
|
| 238 |
+
LDFLAGS="${LDFLAGS} ${ARCHS}"
|
| 239 |
+
fi
|
| 240 |
+
if test $build64 -eq 1; then
|
| 241 |
+
CFLAGS="${CFLAGS} -m64"
|
| 242 |
+
SFLAGS="${SFLAGS} -m64"
|
| 243 |
+
fi
|
| 244 |
+
if test "$warn" -eq 1; then
|
| 245 |
+
if test "$zconst" -eq 1; then
|
| 246 |
+
CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -DZLIB_CONST"
|
| 247 |
+
else
|
| 248 |
+
CFLAGS="${CFLAGS} -Wall -Wextra"
|
| 249 |
+
fi
|
| 250 |
+
fi
|
| 251 |
+
if test $address -eq 1; then
|
| 252 |
+
CFLAGS="${CFLAGS} -g -fsanitize=address -fno-omit-frame-pointer"
|
| 253 |
+
fi
|
| 254 |
+
if test $memory -eq 1; then
|
| 255 |
+
CFLAGS="${CFLAGS} -g -fsanitize=memory -fno-omit-frame-pointer"
|
| 256 |
+
fi
|
| 257 |
+
if test $debug -eq 1; then
|
| 258 |
+
CFLAGS="${CFLAGS} -DZLIB_DEBUG"
|
| 259 |
+
SFLAGS="${SFLAGS} -DZLIB_DEBUG"
|
| 260 |
+
fi
|
| 261 |
+
if test -z "$uname"; then
|
| 262 |
+
uname=`(uname -s || echo unknown) 2>/dev/null`
|
| 263 |
+
fi
|
| 264 |
+
case "$uname" in
|
| 265 |
+
Linux* | linux* | *-linux* | GNU | GNU/* | solaris* | Haiku)
|
| 266 |
+
case "$mname" in
|
| 267 |
+
*sparc*)
|
| 268 |
+
LDFLAGS="${LDFLAGS} -Wl,--no-warn-rwx-segments" ;;
|
| 269 |
+
esac
|
| 270 |
+
LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;;
|
| 271 |
+
*BSD | *bsd* | DragonFly)
|
| 272 |
+
LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"}
|
| 273 |
+
LDCONFIG="ldconfig -m" ;;
|
| 274 |
+
CYGWIN* | Cygwin* | cygwin* | *-cygwin* | OS/2*)
|
| 275 |
+
EXE='.exe' ;;
|
| 276 |
+
MINGW* | mingw* | *-mingw*)
|
| 277 |
+
rm -f $test.[co] $test $test$shared_ext
|
| 278 |
+
echo "If this doesn't work for you, try win32/Makefile.gcc." | tee -a configure.log
|
| 279 |
+
LDSHARED=${LDSHARED-"$cc -shared"}
|
| 280 |
+
LDSHAREDLIBC=""
|
| 281 |
+
EXE='.exe' ;;
|
| 282 |
+
QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
|
| 283 |
+
# (alain.bonnefoy@icbt.com)
|
| 284 |
+
LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
|
| 285 |
+
HP-UX*)
|
| 286 |
+
LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
|
| 287 |
+
case `(uname -m || echo unknown) 2>/dev/null` in
|
| 288 |
+
ia64)
|
| 289 |
+
shared_ext='.so'
|
| 290 |
+
SHAREDLIB='libz.so' ;;
|
| 291 |
+
*)
|
| 292 |
+
shared_ext='.sl'
|
| 293 |
+
SHAREDLIB='libz.sl' ;;
|
| 294 |
+
esac ;;
|
| 295 |
+
AIX*)
|
| 296 |
+
LDSHARED=${LDSHARED-"$cc -shared"}
|
| 297 |
+
LDFLAGS="${LDFLAGS} -Wl,-brtl" ;;
|
| 298 |
+
Darwin* | darwin* | *-darwin*)
|
| 299 |
+
shared_ext='.dylib'
|
| 300 |
+
SHAREDLIB=libz$shared_ext
|
| 301 |
+
SHAREDLIBV=libz.$VER$shared_ext
|
| 302 |
+
SHAREDLIBM=libz.$VER1$shared_ext
|
| 303 |
+
LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
|
| 304 |
+
if "${CROSS_PREFIX}libtool" -V 2>&1 | grep Apple > /dev/null; then
|
| 305 |
+
AR="${CROSS_PREFIX}libtool"
|
| 306 |
+
elif libtool -V 2>&1 | grep Apple > /dev/null; then
|
| 307 |
+
AR="libtool"
|
| 308 |
+
else
|
| 309 |
+
AR="/usr/bin/libtool"
|
| 310 |
+
fi
|
| 311 |
+
ARFLAGS="-o" ;;
|
| 312 |
+
*)
|
| 313 |
+
LDSHARED=${LDSHARED-"$cc -shared"} ;;
|
| 314 |
+
esac
|
| 315 |
+
else
|
| 316 |
+
# find system name and corresponding cc options
|
| 317 |
+
CC=${CC-cc}
|
| 318 |
+
gcc=0
|
| 319 |
+
echo ... using $CC >> configure.log
|
| 320 |
+
if test -z "$uname"; then
|
| 321 |
+
uname=`(uname -sr || echo unknown) 2>/dev/null`
|
| 322 |
+
fi
|
| 323 |
+
case "$uname" in
|
| 324 |
+
HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
|
| 325 |
+
CFLAGS=${CFLAGS-"-O"}
|
| 326 |
+
# LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
|
| 327 |
+
LDSHARED=${LDSHARED-"ld -b"}
|
| 328 |
+
case `(uname -m || echo unknown) 2>/dev/null` in
|
| 329 |
+
ia64)
|
| 330 |
+
shared_ext='.so'
|
| 331 |
+
SHAREDLIB='libz.so' ;;
|
| 332 |
+
*)
|
| 333 |
+
shared_ext='.sl'
|
| 334 |
+
SHAREDLIB='libz.sl' ;;
|
| 335 |
+
esac ;;
|
| 336 |
+
IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
|
| 337 |
+
CFLAGS=${CFLAGS-"-ansi -O2"}
|
| 338 |
+
LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
|
| 339 |
+
OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
|
| 340 |
+
CFLAGS=${CFLAGS-"-O -std1"}
|
| 341 |
+
LDFLAGS="${LDFLAGS} -Wl,-rpath,."
|
| 342 |
+
LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;;
|
| 343 |
+
OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
|
| 344 |
+
CFLAGS=${CFLAGS-"-O -std1"}
|
| 345 |
+
LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
|
| 346 |
+
QNX*) SFLAGS=${CFLAGS-"-4 -O"}
|
| 347 |
+
CFLAGS=${CFLAGS-"-4 -O"}
|
| 348 |
+
LDSHARED=${LDSHARED-"cc"}
|
| 349 |
+
RANLIB=${RANLIB-"true"}
|
| 350 |
+
AR="cc"
|
| 351 |
+
ARFLAGS="-A" ;;
|
| 352 |
+
SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
|
| 353 |
+
CFLAGS=${CFLAGS-"-O3"}
|
| 354 |
+
LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;;
|
| 355 |
+
SunOS\ 5* | solaris*)
|
| 356 |
+
LDSHARED=${LDSHARED-"cc -G -h libz$shared_ext.$VER1"}
|
| 357 |
+
SFLAGS=${CFLAGS-"-fast -KPIC"}
|
| 358 |
+
CFLAGS=${CFLAGS-"-fast"}
|
| 359 |
+
if test $build64 -eq 1; then
|
| 360 |
+
# old versions of SunPRO/Workshop/Studio don't support -m64,
|
| 361 |
+
# but newer ones do. Check for it.
|
| 362 |
+
flag64=`$CC -flags | egrep -- '^-m64'`
|
| 363 |
+
if test x"$flag64" != x"" ; then
|
| 364 |
+
CFLAGS="${CFLAGS} -m64"
|
| 365 |
+
SFLAGS="${SFLAGS} -m64"
|
| 366 |
+
else
|
| 367 |
+
case `(uname -m || echo unknown) 2>/dev/null` in
|
| 368 |
+
i86*)
|
| 369 |
+
SFLAGS="$SFLAGS -xarch=amd64"
|
| 370 |
+
CFLAGS="$CFLAGS -xarch=amd64" ;;
|
| 371 |
+
*)
|
| 372 |
+
SFLAGS="$SFLAGS -xarch=v9"
|
| 373 |
+
CFLAGS="$CFLAGS -xarch=v9" ;;
|
| 374 |
+
esac
|
| 375 |
+
fi
|
| 376 |
+
fi
|
| 377 |
+
if test -n "$ZINC"; then
|
| 378 |
+
ZINC='-I- -I. -I$(SRCDIR)'
|
| 379 |
+
fi
|
| 380 |
+
;;
|
| 381 |
+
SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
|
| 382 |
+
CFLAGS=${CFLAGS-"-O2"}
|
| 383 |
+
LDSHARED=${LDSHARED-"ld"} ;;
|
| 384 |
+
SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
|
| 385 |
+
CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"}
|
| 386 |
+
LDSHARED=${LDSHARED-"cc -xarch=v9b"} ;;
|
| 387 |
+
UNIX_System_V\ 4.2.0)
|
| 388 |
+
SFLAGS=${CFLAGS-"-KPIC -O"}
|
| 389 |
+
CFLAGS=${CFLAGS-"-O"}
|
| 390 |
+
LDSHARED=${LDSHARED-"cc -G"} ;;
|
| 391 |
+
UNIX_SV\ 4.2MP)
|
| 392 |
+
SFLAGS=${CFLAGS-"-Kconform_pic -O"}
|
| 393 |
+
CFLAGS=${CFLAGS-"-O"}
|
| 394 |
+
LDSHARED=${LDSHARED-"cc -G"} ;;
|
| 395 |
+
OpenUNIX\ 5)
|
| 396 |
+
SFLAGS=${CFLAGS-"-KPIC -O"}
|
| 397 |
+
CFLAGS=${CFLAGS-"-O"}
|
| 398 |
+
LDSHARED=${LDSHARED-"cc -G"} ;;
|
| 399 |
+
AIX*) # Courtesy of dbakker@arrayasolutions.com
|
| 400 |
+
SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
|
| 401 |
+
CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
|
| 402 |
+
LDSHARED=${LDSHARED-"xlc -G"} ;;
|
| 403 |
+
# send working options for other systems to zlib@gzip.org
|
| 404 |
+
*) SFLAGS=${CFLAGS-"-O"}
|
| 405 |
+
CFLAGS=${CFLAGS-"-O"}
|
| 406 |
+
LDSHARED=${LDSHARED-"cc -shared"} ;;
|
| 407 |
+
esac
|
| 408 |
+
fi
|
| 409 |
+
|
| 410 |
+
# destination names for shared library if not defined above
|
| 411 |
+
SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
|
| 412 |
+
SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
|
| 413 |
+
SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
|
| 414 |
+
|
| 415 |
+
echo >> configure.log
|
| 416 |
+
|
| 417 |
+
# define functions for testing compiler and library characteristics and logging the results
|
| 418 |
+
|
| 419 |
+
cat > $test.c <<EOF
|
| 420 |
+
#error error
|
| 421 |
+
EOF
|
| 422 |
+
if ($CC -c $CFLAGS $test.c) 2>/dev/null; then
|
| 423 |
+
try()
|
| 424 |
+
{
|
| 425 |
+
show $*
|
| 426 |
+
test "`( $* ) 2>&1 | tee -a configure.log`" = ""
|
| 427 |
+
}
|
| 428 |
+
echo - using any output from compiler to indicate an error >> configure.log
|
| 429 |
+
else
|
| 430 |
+
try()
|
| 431 |
+
{
|
| 432 |
+
show $*
|
| 433 |
+
got=`( $* ) 2>&1`
|
| 434 |
+
ret=$?
|
| 435 |
+
if test "$got" != ""; then
|
| 436 |
+
printf "%s\n" "$got" >> configure.log
|
| 437 |
+
fi
|
| 438 |
+
if test $ret -ne 0; then
|
| 439 |
+
echo "(exit code "$ret")" >> configure.log
|
| 440 |
+
fi
|
| 441 |
+
return $ret
|
| 442 |
+
}
|
| 443 |
+
fi
|
| 444 |
+
|
| 445 |
+
tryboth()
|
| 446 |
+
{
|
| 447 |
+
show $*
|
| 448 |
+
got=`( $* ) 2>&1`
|
| 449 |
+
ret=$?
|
| 450 |
+
if test "$got" != ""; then
|
| 451 |
+
printf "%s\n" "$got" >> configure.log
|
| 452 |
+
fi
|
| 453 |
+
if test $ret -ne 0; then
|
| 454 |
+
echo "(exit code "$ret")" >> configure.log
|
| 455 |
+
return $ret
|
| 456 |
+
fi
|
| 457 |
+
test "$got" = ""
|
| 458 |
+
}
|
| 459 |
+
|
| 460 |
+
cat > $test.c << EOF
|
| 461 |
+
int foo() { return 0; }
|
| 462 |
+
EOF
|
| 463 |
+
echo "Checking for obsessive-compulsive compiler options..." >> configure.log
|
| 464 |
+
if try $CC -c $CFLAGS $test.c; then
|
| 465 |
+
:
|
| 466 |
+
else
|
| 467 |
+
echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log
|
| 468 |
+
leave 1
|
| 469 |
+
fi
|
| 470 |
+
|
| 471 |
+
echo >> configure.log
|
| 472 |
+
|
| 473 |
+
# see if shared library build supported
|
| 474 |
+
cat > $test.c <<EOF
|
| 475 |
+
extern int getchar();
|
| 476 |
+
int hello() {return getchar();}
|
| 477 |
+
EOF
|
| 478 |
+
if test $shared -eq 1; then
|
| 479 |
+
echo Checking for shared library support... | tee -a configure.log
|
| 480 |
+
# we must test in two steps (cc then ld), required at least on SunOS 4.x
|
| 481 |
+
if try $CC -c $SFLAGS $test.c &&
|
| 482 |
+
try $LDSHARED $SFLAGS -o $test$shared_ext $test.o; then
|
| 483 |
+
echo Building shared library $SHAREDLIBV with $CC. | tee -a configure.log
|
| 484 |
+
elif test -z "$old_cc" -a -z "$old_cflags"; then
|
| 485 |
+
echo No shared library support. | tee -a configure.log
|
| 486 |
+
shared=0;
|
| 487 |
+
else
|
| 488 |
+
echo 'No shared library support; try without defining CC and CFLAGS' | tee -a configure.log
|
| 489 |
+
shared=0;
|
| 490 |
+
fi
|
| 491 |
+
fi
|
| 492 |
+
if test $shared -eq 0; then
|
| 493 |
+
LDSHARED="$CC"
|
| 494 |
+
ALL="static"
|
| 495 |
+
TEST="all teststatic"
|
| 496 |
+
SHAREDLIB=""
|
| 497 |
+
SHAREDLIBV=""
|
| 498 |
+
SHAREDLIBM=""
|
| 499 |
+
echo Building static library $STATICLIB version $VER with $CC. | tee -a configure.log
|
| 500 |
+
else
|
| 501 |
+
ALL="static shared"
|
| 502 |
+
TEST="all teststatic testshared"
|
| 503 |
+
fi
|
| 504 |
+
|
| 505 |
+
echo >> configure.log
|
| 506 |
+
|
| 507 |
+
# check for size_t
|
| 508 |
+
cat > $test.c <<EOF
|
| 509 |
+
#include <stdio.h>
|
| 510 |
+
#include <stdlib.h>
|
| 511 |
+
size_t dummy = 0;
|
| 512 |
+
EOF
|
| 513 |
+
if try $CC -c $CFLAGS $test.c; then
|
| 514 |
+
echo "Checking for size_t... Yes." | tee -a configure.log
|
| 515 |
+
else
|
| 516 |
+
echo "Checking for size_t... No." | tee -a configure.log
|
| 517 |
+
# find a size_t integer type
|
| 518 |
+
# check for long long
|
| 519 |
+
cat > $test.c << EOF
|
| 520 |
+
long long dummy = 0;
|
| 521 |
+
EOF
|
| 522 |
+
if try $CC -c $CFLAGS $test.c; then
|
| 523 |
+
echo "Checking for long long... Yes." | tee -a configure.log
|
| 524 |
+
cat > $test.c <<EOF
|
| 525 |
+
#include <stdio.h>
|
| 526 |
+
int main(void) {
|
| 527 |
+
if (sizeof(void *) <= sizeof(int)) puts("int");
|
| 528 |
+
else if (sizeof(void *) <= sizeof(long)) puts("long");
|
| 529 |
+
else puts("z_longlong");
|
| 530 |
+
return 0;
|
| 531 |
+
}
|
| 532 |
+
EOF
|
| 533 |
+
else
|
| 534 |
+
echo "Checking for long long... No." | tee -a configure.log
|
| 535 |
+
cat > $test.c <<EOF
|
| 536 |
+
#include <stdio.h>
|
| 537 |
+
int main(void) {
|
| 538 |
+
if (sizeof(void *) <= sizeof(int)) puts("int");
|
| 539 |
+
else puts("long");
|
| 540 |
+
return 0;
|
| 541 |
+
}
|
| 542 |
+
EOF
|
| 543 |
+
fi
|
| 544 |
+
if try $CC $CFLAGS -o $test $test.c; then
|
| 545 |
+
sizet=`./$test`
|
| 546 |
+
echo "Checking for a pointer-size integer type..." $sizet"." | tee -a configure.log
|
| 547 |
+
CFLAGS="${CFLAGS} -DNO_SIZE_T=${sizet}"
|
| 548 |
+
SFLAGS="${SFLAGS} -DNO_SIZE_T=${sizet}"
|
| 549 |
+
else
|
| 550 |
+
echo "Checking for a pointer-size integer type... not found." | tee -a configure.log
|
| 551 |
+
fi
|
| 552 |
+
fi
|
| 553 |
+
|
| 554 |
+
echo >> configure.log
|
| 555 |
+
|
| 556 |
+
# check for large file support, and if none, check for fseeko()
|
| 557 |
+
cat > $test.c <<EOF
|
| 558 |
+
#include <sys/types.h>
|
| 559 |
+
off64_t dummy = 0;
|
| 560 |
+
EOF
|
| 561 |
+
if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then
|
| 562 |
+
CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1"
|
| 563 |
+
SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1"
|
| 564 |
+
ALL="${ALL} all64"
|
| 565 |
+
TEST="${TEST} test64"
|
| 566 |
+
echo "Checking for off64_t... Yes." | tee -a configure.log
|
| 567 |
+
echo "Checking for fseeko... Yes." | tee -a configure.log
|
| 568 |
+
else
|
| 569 |
+
echo "Checking for off64_t... No." | tee -a configure.log
|
| 570 |
+
echo >> configure.log
|
| 571 |
+
cat > $test.c <<EOF
|
| 572 |
+
#include <stdio.h>
|
| 573 |
+
int main(void) {
|
| 574 |
+
fseeko(NULL, 0, 0);
|
| 575 |
+
return 0;
|
| 576 |
+
}
|
| 577 |
+
EOF
|
| 578 |
+
if try $CC $CFLAGS -o $test $test.c; then
|
| 579 |
+
echo "Checking for fseeko... Yes." | tee -a configure.log
|
| 580 |
+
else
|
| 581 |
+
CFLAGS="${CFLAGS} -DNO_FSEEKO"
|
| 582 |
+
SFLAGS="${SFLAGS} -DNO_FSEEKO"
|
| 583 |
+
echo "Checking for fseeko... No." | tee -a configure.log
|
| 584 |
+
fi
|
| 585 |
+
fi
|
| 586 |
+
|
| 587 |
+
echo >> configure.log
|
| 588 |
+
|
| 589 |
+
# check for strerror() for use by gz* functions
|
| 590 |
+
cat > $test.c <<EOF
|
| 591 |
+
#include <string.h>
|
| 592 |
+
#include <errno.h>
|
| 593 |
+
int main() { return strlen(strerror(errno)); }
|
| 594 |
+
EOF
|
| 595 |
+
if try $CC $CFLAGS -o $test $test.c; then
|
| 596 |
+
echo "Checking for strerror... Yes." | tee -a configure.log
|
| 597 |
+
else
|
| 598 |
+
CFLAGS="${CFLAGS} -DNO_STRERROR"
|
| 599 |
+
SFLAGS="${SFLAGS} -DNO_STRERROR"
|
| 600 |
+
echo "Checking for strerror... No." | tee -a configure.log
|
| 601 |
+
fi
|
| 602 |
+
|
| 603 |
+
# copy clean zconf.h for subsequent edits
|
| 604 |
+
cp -p ${SRCDIR}zconf.h.in zconf.h
|
| 605 |
+
|
| 606 |
+
echo >> configure.log
|
| 607 |
+
|
| 608 |
+
# check for unistd.h and save result in zconf.h
|
| 609 |
+
cat > $test.c <<EOF
|
| 610 |
+
#include <unistd.h>
|
| 611 |
+
int main() { return 0; }
|
| 612 |
+
EOF
|
| 613 |
+
if try $CC -c $CFLAGS $test.c; then
|
| 614 |
+
sed < zconf.h "/^#if HAVE_UNISTD_H-0.* may be/s/ HAVE_UNISTD_H-0\(.*\) may be/ 1\1 was/" > zconf.temp.h
|
| 615 |
+
mv zconf.temp.h zconf.h
|
| 616 |
+
echo "Checking for unistd.h... Yes." | tee -a configure.log
|
| 617 |
+
else
|
| 618 |
+
echo "Checking for unistd.h... No." | tee -a configure.log
|
| 619 |
+
fi
|
| 620 |
+
|
| 621 |
+
echo >> configure.log
|
| 622 |
+
|
| 623 |
+
# check for stdarg.h and save result in zconf.h
|
| 624 |
+
cat > $test.c <<EOF
|
| 625 |
+
#include <stdarg.h>
|
| 626 |
+
int main() { return 0; }
|
| 627 |
+
EOF
|
| 628 |
+
if try $CC -c $CFLAGS $test.c; then
|
| 629 |
+
sed < zconf.h "/^#if HAVE_STDARG_H-0.* may be/s/ HAVE_STDARG_H-0\(.*\) may be/ 1\1 was/" > zconf.temp.h
|
| 630 |
+
mv zconf.temp.h zconf.h
|
| 631 |
+
echo "Checking for stdarg.h... Yes." | tee -a configure.log
|
| 632 |
+
else
|
| 633 |
+
echo "Checking for stdarg.h... No." | tee -a configure.log
|
| 634 |
+
fi
|
| 635 |
+
|
| 636 |
+
# if the z_ prefix was requested, save that in zconf.h
|
| 637 |
+
if test $zprefix -eq 1; then
|
| 638 |
+
sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h
|
| 639 |
+
mv zconf.temp.h zconf.h
|
| 640 |
+
echo >> configure.log
|
| 641 |
+
echo "Using z_ prefix on all symbols." | tee -a configure.log
|
| 642 |
+
fi
|
| 643 |
+
|
| 644 |
+
# if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists
|
| 645 |
+
if test $solo -eq 1; then
|
| 646 |
+
sed '/#define ZCONF_H/a\
|
| 647 |
+
#define Z_SOLO
|
| 648 |
+
|
| 649 |
+
' < zconf.h > zconf.temp.h
|
| 650 |
+
mv zconf.temp.h zconf.h
|
| 651 |
+
OBJC='$(OBJZ)'
|
| 652 |
+
PIC_OBJC='$(PIC_OBJZ)'
|
| 653 |
+
fi
|
| 654 |
+
|
| 655 |
+
# if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
|
| 656 |
+
if test $cover -eq 1; then
|
| 657 |
+
if test -n "$GCC_CLASSIC"; then
|
| 658 |
+
CC=$GCC_CLASSIC
|
| 659 |
+
fi
|
| 660 |
+
fi
|
| 661 |
+
|
| 662 |
+
echo >> configure.log
|
| 663 |
+
|
| 664 |
+
# conduct a series of tests to resolve eight possible cases of using "vs" or "s" printf functions
|
| 665 |
+
# (using stdarg or not), with or without "n" (proving size of buffer), and with or without a
|
| 666 |
+
# return value. The most secure result is vsnprintf() with a return value. snprintf() with a
|
| 667 |
+
# return value is secure as well, but then gzprintf() will be limited to 20 arguments.
|
| 668 |
+
cat > $test.c <<EOF
|
| 669 |
+
#include <stdio.h>
|
| 670 |
+
#include <stdarg.h>
|
| 671 |
+
#include "zconf.h"
|
| 672 |
+
int main()
|
| 673 |
+
{
|
| 674 |
+
#ifndef STDC
|
| 675 |
+
choke me
|
| 676 |
+
#endif
|
| 677 |
+
return 0;
|
| 678 |
+
}
|
| 679 |
+
EOF
|
| 680 |
+
if try $CC -c $CFLAGS $test.c; then
|
| 681 |
+
echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." | tee -a configure.log
|
| 682 |
+
|
| 683 |
+
echo >> configure.log
|
| 684 |
+
cat > $test.c <<EOF
|
| 685 |
+
#include <stdio.h>
|
| 686 |
+
#include <stdarg.h>
|
| 687 |
+
int mytest(const char *fmt, ...)
|
| 688 |
+
{
|
| 689 |
+
char buf[20];
|
| 690 |
+
va_list ap;
|
| 691 |
+
va_start(ap, fmt);
|
| 692 |
+
vsnprintf(buf, sizeof(buf), fmt, ap);
|
| 693 |
+
va_end(ap);
|
| 694 |
+
return 0;
|
| 695 |
+
}
|
| 696 |
+
int main()
|
| 697 |
+
{
|
| 698 |
+
return (mytest("Hello%d\n", 1));
|
| 699 |
+
}
|
| 700 |
+
EOF
|
| 701 |
+
if try $CC $CFLAGS -o $test $test.c; then
|
| 702 |
+
echo "Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log
|
| 703 |
+
|
| 704 |
+
echo >> configure.log
|
| 705 |
+
cat >$test.c <<EOF
|
| 706 |
+
#include <stdio.h>
|
| 707 |
+
#include <stdarg.h>
|
| 708 |
+
int mytest(const char *fmt, ...)
|
| 709 |
+
{
|
| 710 |
+
int n;
|
| 711 |
+
char buf[20];
|
| 712 |
+
va_list ap;
|
| 713 |
+
va_start(ap, fmt);
|
| 714 |
+
n = vsnprintf(buf, sizeof(buf), fmt, ap);
|
| 715 |
+
va_end(ap);
|
| 716 |
+
return n;
|
| 717 |
+
}
|
| 718 |
+
int main()
|
| 719 |
+
{
|
| 720 |
+
return (mytest("Hello%d\n", 1));
|
| 721 |
+
}
|
| 722 |
+
EOF
|
| 723 |
+
|
| 724 |
+
if try $CC -c $CFLAGS $test.c; then
|
| 725 |
+
echo "Checking for return value of vsnprintf()... Yes." | tee -a configure.log
|
| 726 |
+
else
|
| 727 |
+
CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
|
| 728 |
+
SFLAGS="$SFLAGS -DHAS_vsnprintf_void"
|
| 729 |
+
echo "Checking for return value of vsnprintf()... No." | tee -a configure.log
|
| 730 |
+
echo " WARNING: apparently vsnprintf() does not return a value. zlib" | tee -a configure.log
|
| 731 |
+
echo " can build but will be open to possible string-format security" | tee -a configure.log
|
| 732 |
+
echo " vulnerabilities." | tee -a configure.log
|
| 733 |
+
fi
|
| 734 |
+
else
|
| 735 |
+
CFLAGS="$CFLAGS -DNO_vsnprintf"
|
| 736 |
+
SFLAGS="$SFLAGS -DNO_vsnprintf"
|
| 737 |
+
echo "Checking for vsnprintf() in stdio.h... No." | tee -a configure.log
|
| 738 |
+
echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log
|
| 739 |
+
echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
|
| 740 |
+
echo " vulnerabilities." | tee -a configure.log
|
| 741 |
+
|
| 742 |
+
echo >> configure.log
|
| 743 |
+
cat >$test.c <<EOF
|
| 744 |
+
#include <stdio.h>
|
| 745 |
+
#include <stdarg.h>
|
| 746 |
+
int mytest(const char *fmt, ...)
|
| 747 |
+
{
|
| 748 |
+
int n;
|
| 749 |
+
char buf[20];
|
| 750 |
+
va_list ap;
|
| 751 |
+
va_start(ap, fmt);
|
| 752 |
+
n = vsprintf(buf, fmt, ap);
|
| 753 |
+
va_end(ap);
|
| 754 |
+
return n;
|
| 755 |
+
}
|
| 756 |
+
int main()
|
| 757 |
+
{
|
| 758 |
+
return (mytest("Hello%d\n", 1));
|
| 759 |
+
}
|
| 760 |
+
EOF
|
| 761 |
+
|
| 762 |
+
if try $CC -c $CFLAGS $test.c; then
|
| 763 |
+
echo "Checking for return value of vsprintf()... Yes." | tee -a configure.log
|
| 764 |
+
else
|
| 765 |
+
CFLAGS="$CFLAGS -DHAS_vsprintf_void"
|
| 766 |
+
SFLAGS="$SFLAGS -DHAS_vsprintf_void"
|
| 767 |
+
echo "Checking for return value of vsprintf()... No." | tee -a configure.log
|
| 768 |
+
echo " WARNING: apparently vsprintf() does not return a value. zlib" | tee -a configure.log
|
| 769 |
+
echo " can build but will be open to possible string-format security" | tee -a configure.log
|
| 770 |
+
echo " vulnerabilities." | tee -a configure.log
|
| 771 |
+
fi
|
| 772 |
+
fi
|
| 773 |
+
else
|
| 774 |
+
echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." | tee -a configure.log
|
| 775 |
+
|
| 776 |
+
echo >> configure.log
|
| 777 |
+
cat >$test.c <<EOF
|
| 778 |
+
#include <stdio.h>
|
| 779 |
+
int mytest()
|
| 780 |
+
{
|
| 781 |
+
char buf[20];
|
| 782 |
+
snprintf(buf, sizeof(buf), "%s", "foo");
|
| 783 |
+
return 0;
|
| 784 |
+
}
|
| 785 |
+
int main()
|
| 786 |
+
{
|
| 787 |
+
return (mytest());
|
| 788 |
+
}
|
| 789 |
+
EOF
|
| 790 |
+
|
| 791 |
+
if try $CC $CFLAGS -o $test $test.c; then
|
| 792 |
+
echo "Checking for snprintf() in stdio.h... Yes." | tee -a configure.log
|
| 793 |
+
|
| 794 |
+
echo >> configure.log
|
| 795 |
+
cat >$test.c <<EOF
|
| 796 |
+
#include <stdio.h>
|
| 797 |
+
int mytest()
|
| 798 |
+
{
|
| 799 |
+
char buf[20];
|
| 800 |
+
return snprintf(buf, sizeof(buf), "%s", "foo");
|
| 801 |
+
}
|
| 802 |
+
int main()
|
| 803 |
+
{
|
| 804 |
+
return (mytest());
|
| 805 |
+
}
|
| 806 |
+
EOF
|
| 807 |
+
|
| 808 |
+
if try $CC -c $CFLAGS $test.c; then
|
| 809 |
+
echo "Checking for return value of snprintf()... Yes." | tee -a configure.log
|
| 810 |
+
else
|
| 811 |
+
CFLAGS="$CFLAGS -DHAS_snprintf_void"
|
| 812 |
+
SFLAGS="$SFLAGS -DHAS_snprintf_void"
|
| 813 |
+
echo "Checking for return value of snprintf()... No." | tee -a configure.log
|
| 814 |
+
echo " WARNING: apparently snprintf() does not return a value. zlib" | tee -a configure.log
|
| 815 |
+
echo " can build but will be open to possible string-format security" | tee -a configure.log
|
| 816 |
+
echo " vulnerabilities." | tee -a configure.log
|
| 817 |
+
fi
|
| 818 |
+
else
|
| 819 |
+
CFLAGS="$CFLAGS -DNO_snprintf"
|
| 820 |
+
SFLAGS="$SFLAGS -DNO_snprintf"
|
| 821 |
+
echo "Checking for snprintf() in stdio.h... No." | tee -a configure.log
|
| 822 |
+
echo " WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log
|
| 823 |
+
echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
|
| 824 |
+
echo " vulnerabilities." | tee -a configure.log
|
| 825 |
+
|
| 826 |
+
echo >> configure.log
|
| 827 |
+
cat >$test.c <<EOF
|
| 828 |
+
#include <stdio.h>
|
| 829 |
+
int mytest()
|
| 830 |
+
{
|
| 831 |
+
char buf[20];
|
| 832 |
+
return sprintf(buf, "%s", "foo");
|
| 833 |
+
}
|
| 834 |
+
int main()
|
| 835 |
+
{
|
| 836 |
+
return (mytest());
|
| 837 |
+
}
|
| 838 |
+
EOF
|
| 839 |
+
|
| 840 |
+
if try $CC -c $CFLAGS $test.c; then
|
| 841 |
+
echo "Checking for return value of sprintf()... Yes." | tee -a configure.log
|
| 842 |
+
else
|
| 843 |
+
CFLAGS="$CFLAGS -DHAS_sprintf_void"
|
| 844 |
+
SFLAGS="$SFLAGS -DHAS_sprintf_void"
|
| 845 |
+
echo "Checking for return value of sprintf()... No." | tee -a configure.log
|
| 846 |
+
echo " WARNING: apparently sprintf() does not return a value. zlib" | tee -a configure.log
|
| 847 |
+
echo " can build but will be open to possible string-format security" | tee -a configure.log
|
| 848 |
+
echo " vulnerabilities." | tee -a configure.log
|
| 849 |
+
fi
|
| 850 |
+
fi
|
| 851 |
+
fi
|
| 852 |
+
|
| 853 |
+
# see if we can hide zlib internal symbols that are linked between separate source files
|
| 854 |
+
if test "$gcc" -eq 1; then
|
| 855 |
+
echo >> configure.log
|
| 856 |
+
cat > $test.c <<EOF
|
| 857 |
+
#define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
|
| 858 |
+
int ZLIB_INTERNAL foo;
|
| 859 |
+
int main()
|
| 860 |
+
{
|
| 861 |
+
return 0;
|
| 862 |
+
}
|
| 863 |
+
EOF
|
| 864 |
+
if tryboth $CC -c $CFLAGS $test.c; then
|
| 865 |
+
CFLAGS="$CFLAGS -DHAVE_HIDDEN"
|
| 866 |
+
SFLAGS="$SFLAGS -DHAVE_HIDDEN"
|
| 867 |
+
echo "Checking for attribute(visibility) support... Yes." | tee -a configure.log
|
| 868 |
+
else
|
| 869 |
+
echo "Checking for attribute(visibility) support... No." | tee -a configure.log
|
| 870 |
+
fi
|
| 871 |
+
fi
|
| 872 |
+
|
| 873 |
+
# show the results in the log
|
| 874 |
+
echo >> configure.log
|
| 875 |
+
echo ALL = $ALL >> configure.log
|
| 876 |
+
echo AR = $AR >> configure.log
|
| 877 |
+
echo ARFLAGS = $ARFLAGS >> configure.log
|
| 878 |
+
echo CC = $CC >> configure.log
|
| 879 |
+
echo CFLAGS = $CFLAGS >> configure.log
|
| 880 |
+
echo CPP = $CPP >> configure.log
|
| 881 |
+
echo EXE = $EXE >> configure.log
|
| 882 |
+
echo LDCONFIG = $LDCONFIG >> configure.log
|
| 883 |
+
echo LDFLAGS = $LDFLAGS >> configure.log
|
| 884 |
+
echo LDSHARED = $LDSHARED >> configure.log
|
| 885 |
+
echo LDSHAREDLIBC = $LDSHAREDLIBC >> configure.log
|
| 886 |
+
echo OBJC = $OBJC >> configure.log
|
| 887 |
+
echo PIC_OBJC = $PIC_OBJC >> configure.log
|
| 888 |
+
echo RANLIB = $RANLIB >> configure.log
|
| 889 |
+
echo SFLAGS = $SFLAGS >> configure.log
|
| 890 |
+
echo SHAREDLIB = $SHAREDLIB >> configure.log
|
| 891 |
+
echo SHAREDLIBM = $SHAREDLIBM >> configure.log
|
| 892 |
+
echo SHAREDLIBV = $SHAREDLIBV >> configure.log
|
| 893 |
+
echo STATICLIB = $STATICLIB >> configure.log
|
| 894 |
+
echo TEST = $TEST >> configure.log
|
| 895 |
+
echo VER = $VER >> configure.log
|
| 896 |
+
echo SRCDIR = $SRCDIR >> configure.log
|
| 897 |
+
echo exec_prefix = $exec_prefix >> configure.log
|
| 898 |
+
echo includedir = $includedir >> configure.log
|
| 899 |
+
echo libdir = $libdir >> configure.log
|
| 900 |
+
echo mandir = $mandir >> configure.log
|
| 901 |
+
echo prefix = $prefix >> configure.log
|
| 902 |
+
echo sharedlibdir = $sharedlibdir >> configure.log
|
| 903 |
+
echo uname = $uname >> configure.log
|
| 904 |
+
|
| 905 |
+
# update Makefile with the configure results
|
| 906 |
+
sed < ${SRCDIR}Makefile.in "
|
| 907 |
+
/^CC *=/s#=.*#=$CC#
|
| 908 |
+
/^GCOV *=/s#=.*#=$GCOV#
|
| 909 |
+
/^LLVM_GCOV_FLAG *=/s#=.*#=$LLVM_GCOV_FLAG#
|
| 910 |
+
/^CFLAGS *=/s#=.*#=$CFLAGS#
|
| 911 |
+
/^SFLAGS *=/s#=.*#=$SFLAGS#
|
| 912 |
+
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
|
| 913 |
+
/^LDSHARED *=/s#=.*#=$LDSHARED#
|
| 914 |
+
/^CPP *=/s#=.*#=$CPP#
|
| 915 |
+
/^STATICLIB *=/s#=.*#=$STATICLIB#
|
| 916 |
+
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
|
| 917 |
+
/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
|
| 918 |
+
/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
|
| 919 |
+
/^AR *=/s#=.*#=$AR#
|
| 920 |
+
/^ARFLAGS *=/s#=.*#=$ARFLAGS#
|
| 921 |
+
/^RANLIB *=/s#=.*#=$RANLIB#
|
| 922 |
+
/^LDCONFIG *=/s#=.*#=$LDCONFIG#
|
| 923 |
+
/^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC#
|
| 924 |
+
/^EXE *=/s#=.*#=$EXE#
|
| 925 |
+
/^SRCDIR *=/s#=.*#=$SRCDIR#
|
| 926 |
+
/^ZINC *=/s#=.*#=$ZINC#
|
| 927 |
+
/^ZINCOUT *=/s#=.*#=$ZINCOUT#
|
| 928 |
+
/^prefix *=/s#=.*#=$prefix#
|
| 929 |
+
/^exec_prefix *=/s#=.*#=$exec_prefix#
|
| 930 |
+
/^libdir *=/s#=.*#=$libdir#
|
| 931 |
+
/^sharedlibdir *=/s#=.*#=$sharedlibdir#
|
| 932 |
+
/^includedir *=/s#=.*#=$includedir#
|
| 933 |
+
/^mandir *=/s#=.*#=$mandir#
|
| 934 |
+
/^OBJC *=/s#=.*#= $OBJC#
|
| 935 |
+
/^PIC_OBJC *=/s#=.*#= $PIC_OBJC#
|
| 936 |
+
/^all: */s#:.*#: $ALL#
|
| 937 |
+
/^test: */s#:.*#: $TEST#
|
| 938 |
+
" > Makefile
|
| 939 |
+
|
| 940 |
+
# create zlib.pc with the configure results
|
| 941 |
+
sed < ${SRCDIR}zlib.pc.in "
|
| 942 |
+
/^CC *=/s#=.*#=$CC#
|
| 943 |
+
/^CFLAGS *=/s#=.*#=$CFLAGS#
|
| 944 |
+
/^CPP *=/s#=.*#=$CPP#
|
| 945 |
+
/^LDSHARED *=/s#=.*#=$LDSHARED#
|
| 946 |
+
/^STATICLIB *=/s#=.*#=$STATICLIB#
|
| 947 |
+
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
|
| 948 |
+
/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
|
| 949 |
+
/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
|
| 950 |
+
/^AR *=/s#=.*#=$AR#
|
| 951 |
+
/^ARFLAGS *=/s#=.*#=$ARFLAGS#
|
| 952 |
+
/^RANLIB *=/s#=.*#=$RANLIB#
|
| 953 |
+
/^EXE *=/s#=.*#=$EXE#
|
| 954 |
+
/^prefix *=/s#=.*#=$prefix#
|
| 955 |
+
/^exec_prefix *=/s#=.*#=$exec_prefix#
|
| 956 |
+
/^libdir *=/s#=.*#=$libdir#
|
| 957 |
+
/^sharedlibdir *=/s#=.*#=$sharedlibdir#
|
| 958 |
+
/^includedir *=/s#=.*#=$includedir#
|
| 959 |
+
/^mandir *=/s#=.*#=$mandir#
|
| 960 |
+
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
|
| 961 |
+
" | sed -e "
|
| 962 |
+
s/\@VERSION\@/$VER/g;
|
| 963 |
+
" > zlib.pc
|
| 964 |
+
|
| 965 |
+
# done
|
| 966 |
+
leave 0
|
contrib/README.contrib
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
All files under this contrib directory are UNSUPPORTED. They were
|
| 2 |
+
provided by users of zlib and were not tested by the authors of zlib.
|
| 3 |
+
Use at your own risk. Please contact the authors of the contributions
|
| 4 |
+
for help about these, not the zlib authors. Thanks.
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
ada/ by Dmitriy Anisimkov <anisimkov@yahoo.com>
|
| 8 |
+
Support for Ada
|
| 9 |
+
See http://zlib-ada.sourceforge.net/
|
| 10 |
+
|
| 11 |
+
blast/ by Mark Adler <madler@alumni.caltech.edu>
|
| 12 |
+
Decompressor for output of PKWare Data Compression Library (DCL)
|
| 13 |
+
|
| 14 |
+
delphi/ by Cosmin Truta <cosmint@cs.ubbcluj.ro>
|
| 15 |
+
Support for Delphi and C++ Builder
|
| 16 |
+
|
| 17 |
+
dotzlib/ by Henrik Ravn <henrik@ravn.com>
|
| 18 |
+
Support for Microsoft .Net and Visual C++ .Net
|
| 19 |
+
|
| 20 |
+
gcc_gvmat64/by Gilles Vollant <info@winimage.com>
|
| 21 |
+
GCC Version of x86 64-bit (AMD64 and Intel EM64t) code for x64
|
| 22 |
+
assembler to replace longest_match() and inflate_fast()
|
| 23 |
+
|
| 24 |
+
infback9/ by Mark Adler <madler@alumni.caltech.edu>
|
| 25 |
+
Unsupported diffs to infback to decode the deflate64 format
|
| 26 |
+
|
| 27 |
+
iostream/ by Kevin Ruland <kevin@rodin.wustl.edu>
|
| 28 |
+
A C++ I/O streams interface to the zlib gz* functions
|
| 29 |
+
|
| 30 |
+
iostream2/ by Tyge Løvset <Tyge.Lovset@cmr.no>
|
| 31 |
+
Another C++ I/O streams interface
|
| 32 |
+
|
| 33 |
+
iostream3/ by Ludwig Schwardt <schwardt@sun.ac.za>
|
| 34 |
+
and Kevin Ruland <kevin@rodin.wustl.edu>
|
| 35 |
+
Yet another C++ I/O streams interface
|
| 36 |
+
|
| 37 |
+
minizip/ by Gilles Vollant <info@winimage.com>
|
| 38 |
+
Mini zip and unzip based on zlib
|
| 39 |
+
Includes Zip64 support by Mathias Svensson <mathias@result42.com>
|
| 40 |
+
See http://www.winimage.com/zLibDll/minizip.html
|
| 41 |
+
|
| 42 |
+
pascal/ by Bob Dellaca <bobdl@xtra.co.nz> et al.
|
| 43 |
+
Support for Pascal
|
| 44 |
+
|
| 45 |
+
puff/ by Mark Adler <madler@alumni.caltech.edu>
|
| 46 |
+
Small, low memory usage inflate. Also serves to provide an
|
| 47 |
+
unambiguous description of the deflate format.
|
| 48 |
+
|
| 49 |
+
testzlib/ by Gilles Vollant <info@winimage.com>
|
| 50 |
+
Example of the use of zlib
|
| 51 |
+
|
| 52 |
+
untgz/ by Pedro A. Aranda Gutierrez <paag@tid.es>
|
| 53 |
+
A very simple tar.gz file extractor using zlib
|
| 54 |
+
|
| 55 |
+
vstudio/ by Gilles Vollant <info@winimage.com>
|
| 56 |
+
Building a minizip-enhanced zlib with Microsoft Visual Studio
|
| 57 |
+
Includes vc11 from kreuzerkrieg and vc12 from davispuh
|
contrib/ada/buffer_demo.adb
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
----------------------------------------------------------------
|
| 2 |
+
-- ZLib for Ada thick binding. --
|
| 3 |
+
-- --
|
| 4 |
+
-- Copyright (C) 2002-2004 Dmitriy Anisimkov --
|
| 5 |
+
-- --
|
| 6 |
+
-- Open source license information is in the zlib.ads file. --
|
| 7 |
+
----------------------------------------------------------------
|
| 8 |
+
--
|
| 9 |
+
-- $Id: buffer_demo.adb,v 1.3 2004/09/06 06:55:35 vagul Exp $
|
| 10 |
+
|
| 11 |
+
-- This demo program provided by Dr Steve Sangwine <sjs@essex.ac.uk>
|
| 12 |
+
--
|
| 13 |
+
-- Demonstration of a problem with Zlib-Ada (already fixed) when a buffer
|
| 14 |
+
-- of exactly the correct size is used for decompressed data, and the last
|
| 15 |
+
-- few bytes passed in to Zlib are checksum bytes.
|
| 16 |
+
|
| 17 |
+
-- This program compresses a string of text, and then decompresses the
|
| 18 |
+
-- compressed text into a buffer of the same size as the original text.
|
| 19 |
+
|
| 20 |
+
with Ada.Streams; use Ada.Streams;
|
| 21 |
+
with Ada.Text_IO;
|
| 22 |
+
|
| 23 |
+
with ZLib; use ZLib;
|
| 24 |
+
|
| 25 |
+
procedure Buffer_Demo is
|
| 26 |
+
EOL : Character renames ASCII.LF;
|
| 27 |
+
Text : constant String
|
| 28 |
+
:= "Four score and seven years ago our fathers brought forth," & EOL &
|
| 29 |
+
"upon this continent, a new nation, conceived in liberty," & EOL &
|
| 30 |
+
"and dedicated to the proposition that `all men are created equal'.";
|
| 31 |
+
|
| 32 |
+
Source : Stream_Element_Array (1 .. Text'Length);
|
| 33 |
+
for Source'Address use Text'Address;
|
| 34 |
+
|
| 35 |
+
begin
|
| 36 |
+
Ada.Text_IO.Put (Text);
|
| 37 |
+
Ada.Text_IO.New_Line;
|
| 38 |
+
Ada.Text_IO.Put_Line
|
| 39 |
+
("Uncompressed size : " & Positive'Image (Text'Length) & " bytes");
|
| 40 |
+
|
| 41 |
+
declare
|
| 42 |
+
Compressed_Data : Stream_Element_Array (1 .. Text'Length);
|
| 43 |
+
L : Stream_Element_Offset;
|
| 44 |
+
begin
|
| 45 |
+
Compress : declare
|
| 46 |
+
Compressor : Filter_Type;
|
| 47 |
+
I : Stream_Element_Offset;
|
| 48 |
+
begin
|
| 49 |
+
Deflate_Init (Compressor);
|
| 50 |
+
|
| 51 |
+
-- Compress the whole of T at once.
|
| 52 |
+
|
| 53 |
+
Translate (Compressor, Source, I, Compressed_Data, L, Finish);
|
| 54 |
+
pragma Assert (I = Source'Last);
|
| 55 |
+
|
| 56 |
+
Close (Compressor);
|
| 57 |
+
|
| 58 |
+
Ada.Text_IO.Put_Line
|
| 59 |
+
("Compressed size : "
|
| 60 |
+
& Stream_Element_Offset'Image (L) & " bytes");
|
| 61 |
+
end Compress;
|
| 62 |
+
|
| 63 |
+
-- Now we decompress the data, passing short blocks of data to Zlib
|
| 64 |
+
-- (because this demonstrates the problem - the last block passed will
|
| 65 |
+
-- contain checksum information and there will be no output, only a
|
| 66 |
+
-- check inside Zlib that the checksum is correct).
|
| 67 |
+
|
| 68 |
+
Decompress : declare
|
| 69 |
+
Decompressor : Filter_Type;
|
| 70 |
+
|
| 71 |
+
Uncompressed_Data : Stream_Element_Array (1 .. Text'Length);
|
| 72 |
+
|
| 73 |
+
Block_Size : constant := 4;
|
| 74 |
+
-- This makes sure that the last block contains
|
| 75 |
+
-- only Adler checksum data.
|
| 76 |
+
|
| 77 |
+
P : Stream_Element_Offset := Compressed_Data'First - 1;
|
| 78 |
+
O : Stream_Element_Offset;
|
| 79 |
+
begin
|
| 80 |
+
Inflate_Init (Decompressor);
|
| 81 |
+
|
| 82 |
+
loop
|
| 83 |
+
Translate
|
| 84 |
+
(Decompressor,
|
| 85 |
+
Compressed_Data
|
| 86 |
+
(P + 1 .. Stream_Element_Offset'Min (P + Block_Size, L)),
|
| 87 |
+
P,
|
| 88 |
+
Uncompressed_Data
|
| 89 |
+
(Total_Out (Decompressor) + 1 .. Uncompressed_Data'Last),
|
| 90 |
+
O,
|
| 91 |
+
No_Flush);
|
| 92 |
+
|
| 93 |
+
Ada.Text_IO.Put_Line
|
| 94 |
+
("Total in : " & Count'Image (Total_In (Decompressor)) &
|
| 95 |
+
", out : " & Count'Image (Total_Out (Decompressor)));
|
| 96 |
+
|
| 97 |
+
exit when P = L;
|
| 98 |
+
end loop;
|
| 99 |
+
|
| 100 |
+
Ada.Text_IO.New_Line;
|
| 101 |
+
Ada.Text_IO.Put_Line
|
| 102 |
+
("Decompressed text matches original text : "
|
| 103 |
+
& Boolean'Image (Uncompressed_Data = Source));
|
| 104 |
+
end Decompress;
|
| 105 |
+
end;
|
| 106 |
+
end Buffer_Demo;
|
contrib/ada/mtest.adb
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
----------------------------------------------------------------
|
| 2 |
+
-- ZLib for Ada thick binding. --
|
| 3 |
+
-- --
|
| 4 |
+
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
|
| 5 |
+
-- --
|
| 6 |
+
-- Open source license information is in the zlib.ads file. --
|
| 7 |
+
----------------------------------------------------------------
|
| 8 |
+
-- Continuous test for ZLib multithreading. If the test would fail
|
| 9 |
+
-- we should provide thread safe allocation routines for the Z_Stream.
|
| 10 |
+
--
|
| 11 |
+
-- $Id: mtest.adb,v 1.4 2004/07/23 07:49:54 vagul Exp $
|
| 12 |
+
|
| 13 |
+
with ZLib;
|
| 14 |
+
with Ada.Streams;
|
| 15 |
+
with Ada.Numerics.Discrete_Random;
|
| 16 |
+
with Ada.Text_IO;
|
| 17 |
+
with Ada.Exceptions;
|
| 18 |
+
with Ada.Task_Identification;
|
| 19 |
+
|
| 20 |
+
procedure MTest is
|
| 21 |
+
use Ada.Streams;
|
| 22 |
+
use ZLib;
|
| 23 |
+
|
| 24 |
+
Stop : Boolean := False;
|
| 25 |
+
|
| 26 |
+
pragma Atomic (Stop);
|
| 27 |
+
|
| 28 |
+
subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#;
|
| 29 |
+
|
| 30 |
+
package Random_Elements is
|
| 31 |
+
new Ada.Numerics.Discrete_Random (Visible_Symbols);
|
| 32 |
+
|
| 33 |
+
task type Test_Task;
|
| 34 |
+
|
| 35 |
+
task body Test_Task is
|
| 36 |
+
Buffer : Stream_Element_Array (1 .. 100_000);
|
| 37 |
+
Gen : Random_Elements.Generator;
|
| 38 |
+
|
| 39 |
+
Buffer_First : Stream_Element_Offset;
|
| 40 |
+
Compare_First : Stream_Element_Offset;
|
| 41 |
+
|
| 42 |
+
Deflate : Filter_Type;
|
| 43 |
+
Inflate : Filter_Type;
|
| 44 |
+
|
| 45 |
+
procedure Further (Item : in Stream_Element_Array);
|
| 46 |
+
|
| 47 |
+
procedure Read_Buffer
|
| 48 |
+
(Item : out Ada.Streams.Stream_Element_Array;
|
| 49 |
+
Last : out Ada.Streams.Stream_Element_Offset);
|
| 50 |
+
|
| 51 |
+
-------------
|
| 52 |
+
-- Further --
|
| 53 |
+
-------------
|
| 54 |
+
|
| 55 |
+
procedure Further (Item : in Stream_Element_Array) is
|
| 56 |
+
|
| 57 |
+
procedure Compare (Item : in Stream_Element_Array);
|
| 58 |
+
|
| 59 |
+
-------------
|
| 60 |
+
-- Compare --
|
| 61 |
+
-------------
|
| 62 |
+
|
| 63 |
+
procedure Compare (Item : in Stream_Element_Array) is
|
| 64 |
+
Next_First : Stream_Element_Offset := Compare_First + Item'Length;
|
| 65 |
+
begin
|
| 66 |
+
if Buffer (Compare_First .. Next_First - 1) /= Item then
|
| 67 |
+
raise Program_Error;
|
| 68 |
+
end if;
|
| 69 |
+
|
| 70 |
+
Compare_First := Next_First;
|
| 71 |
+
end Compare;
|
| 72 |
+
|
| 73 |
+
procedure Compare_Write is new ZLib.Write (Write => Compare);
|
| 74 |
+
begin
|
| 75 |
+
Compare_Write (Inflate, Item, No_Flush);
|
| 76 |
+
end Further;
|
| 77 |
+
|
| 78 |
+
-----------------
|
| 79 |
+
-- Read_Buffer --
|
| 80 |
+
-----------------
|
| 81 |
+
|
| 82 |
+
procedure Read_Buffer
|
| 83 |
+
(Item : out Ada.Streams.Stream_Element_Array;
|
| 84 |
+
Last : out Ada.Streams.Stream_Element_Offset)
|
| 85 |
+
is
|
| 86 |
+
Buff_Diff : Stream_Element_Offset := Buffer'Last - Buffer_First;
|
| 87 |
+
Next_First : Stream_Element_Offset;
|
| 88 |
+
begin
|
| 89 |
+
if Item'Length <= Buff_Diff then
|
| 90 |
+
Last := Item'Last;
|
| 91 |
+
|
| 92 |
+
Next_First := Buffer_First + Item'Length;
|
| 93 |
+
|
| 94 |
+
Item := Buffer (Buffer_First .. Next_First - 1);
|
| 95 |
+
|
| 96 |
+
Buffer_First := Next_First;
|
| 97 |
+
else
|
| 98 |
+
Last := Item'First + Buff_Diff;
|
| 99 |
+
Item (Item'First .. Last) := Buffer (Buffer_First .. Buffer'Last);
|
| 100 |
+
Buffer_First := Buffer'Last + 1;
|
| 101 |
+
end if;
|
| 102 |
+
end Read_Buffer;
|
| 103 |
+
|
| 104 |
+
procedure Translate is new Generic_Translate
|
| 105 |
+
(Data_In => Read_Buffer,
|
| 106 |
+
Data_Out => Further);
|
| 107 |
+
|
| 108 |
+
begin
|
| 109 |
+
Random_Elements.Reset (Gen);
|
| 110 |
+
|
| 111 |
+
Buffer := (others => 20);
|
| 112 |
+
|
| 113 |
+
Main : loop
|
| 114 |
+
for J in Buffer'Range loop
|
| 115 |
+
Buffer (J) := Random_Elements.Random (Gen);
|
| 116 |
+
|
| 117 |
+
Deflate_Init (Deflate);
|
| 118 |
+
Inflate_Init (Inflate);
|
| 119 |
+
|
| 120 |
+
Buffer_First := Buffer'First;
|
| 121 |
+
Compare_First := Buffer'First;
|
| 122 |
+
|
| 123 |
+
Translate (Deflate);
|
| 124 |
+
|
| 125 |
+
if Compare_First /= Buffer'Last + 1 then
|
| 126 |
+
raise Program_Error;
|
| 127 |
+
end if;
|
| 128 |
+
|
| 129 |
+
Ada.Text_IO.Put_Line
|
| 130 |
+
(Ada.Task_Identification.Image
|
| 131 |
+
(Ada.Task_Identification.Current_Task)
|
| 132 |
+
& Stream_Element_Offset'Image (J)
|
| 133 |
+
& ZLib.Count'Image (Total_Out (Deflate)));
|
| 134 |
+
|
| 135 |
+
Close (Deflate);
|
| 136 |
+
Close (Inflate);
|
| 137 |
+
|
| 138 |
+
exit Main when Stop;
|
| 139 |
+
end loop;
|
| 140 |
+
end loop Main;
|
| 141 |
+
exception
|
| 142 |
+
when E : others =>
|
| 143 |
+
Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E));
|
| 144 |
+
Stop := True;
|
| 145 |
+
end Test_Task;
|
| 146 |
+
|
| 147 |
+
Test : array (1 .. 4) of Test_Task;
|
| 148 |
+
|
| 149 |
+
pragma Unreferenced (Test);
|
| 150 |
+
|
| 151 |
+
Dummy : Character;
|
| 152 |
+
|
| 153 |
+
begin
|
| 154 |
+
Ada.Text_IO.Get_Immediate (Dummy);
|
| 155 |
+
Stop := True;
|
| 156 |
+
end MTest;
|
contrib/ada/read.adb
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
----------------------------------------------------------------
|
| 2 |
+
-- ZLib for Ada thick binding. --
|
| 3 |
+
-- --
|
| 4 |
+
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
|
| 5 |
+
-- --
|
| 6 |
+
-- Open source license information is in the zlib.ads file. --
|
| 7 |
+
----------------------------------------------------------------
|
| 8 |
+
|
| 9 |
+
-- $Id: read.adb,v 1.8 2004/05/31 10:53:40 vagul Exp $
|
| 10 |
+
|
| 11 |
+
-- Test/demo program for the generic read interface.
|
| 12 |
+
|
| 13 |
+
with Ada.Numerics.Discrete_Random;
|
| 14 |
+
with Ada.Streams;
|
| 15 |
+
with Ada.Text_IO;
|
| 16 |
+
|
| 17 |
+
with ZLib;
|
| 18 |
+
|
| 19 |
+
procedure Read is
|
| 20 |
+
|
| 21 |
+
use Ada.Streams;
|
| 22 |
+
|
| 23 |
+
------------------------------------
|
| 24 |
+
-- Test configuration parameters --
|
| 25 |
+
------------------------------------
|
| 26 |
+
|
| 27 |
+
File_Size : Stream_Element_Offset := 100_000;
|
| 28 |
+
|
| 29 |
+
Continuous : constant Boolean := False;
|
| 30 |
+
-- If this constant is True, the test would be repeated again and again,
|
| 31 |
+
-- with increment File_Size for every iteration.
|
| 32 |
+
|
| 33 |
+
Header : constant ZLib.Header_Type := ZLib.Default;
|
| 34 |
+
-- Do not use Header other than Default in ZLib versions 1.1.4 and older.
|
| 35 |
+
|
| 36 |
+
Init_Random : constant := 8;
|
| 37 |
+
-- We are using the same random sequence, in case of we catch bug,
|
| 38 |
+
-- so we would be able to reproduce it.
|
| 39 |
+
|
| 40 |
+
-- End --
|
| 41 |
+
|
| 42 |
+
Pack_Size : Stream_Element_Offset;
|
| 43 |
+
Offset : Stream_Element_Offset;
|
| 44 |
+
|
| 45 |
+
Filter : ZLib.Filter_Type;
|
| 46 |
+
|
| 47 |
+
subtype Visible_Symbols
|
| 48 |
+
is Stream_Element range 16#20# .. 16#7E#;
|
| 49 |
+
|
| 50 |
+
package Random_Elements is new
|
| 51 |
+
Ada.Numerics.Discrete_Random (Visible_Symbols);
|
| 52 |
+
|
| 53 |
+
Gen : Random_Elements.Generator;
|
| 54 |
+
Period : constant Stream_Element_Offset := 200;
|
| 55 |
+
-- Period constant variable for random generator not to be very random.
|
| 56 |
+
-- Bigger period, harder random.
|
| 57 |
+
|
| 58 |
+
Read_Buffer : Stream_Element_Array (1 .. 2048);
|
| 59 |
+
Read_First : Stream_Element_Offset;
|
| 60 |
+
Read_Last : Stream_Element_Offset;
|
| 61 |
+
|
| 62 |
+
procedure Reset;
|
| 63 |
+
|
| 64 |
+
procedure Read
|
| 65 |
+
(Item : out Stream_Element_Array;
|
| 66 |
+
Last : out Stream_Element_Offset);
|
| 67 |
+
-- this procedure is for generic instantiation of
|
| 68 |
+
-- ZLib.Read
|
| 69 |
+
-- reading data from the File_In.
|
| 70 |
+
|
| 71 |
+
procedure Read is new ZLib.Read
|
| 72 |
+
(Read,
|
| 73 |
+
Read_Buffer,
|
| 74 |
+
Rest_First => Read_First,
|
| 75 |
+
Rest_Last => Read_Last);
|
| 76 |
+
|
| 77 |
+
----------
|
| 78 |
+
-- Read --
|
| 79 |
+
----------
|
| 80 |
+
|
| 81 |
+
procedure Read
|
| 82 |
+
(Item : out Stream_Element_Array;
|
| 83 |
+
Last : out Stream_Element_Offset) is
|
| 84 |
+
begin
|
| 85 |
+
Last := Stream_Element_Offset'Min
|
| 86 |
+
(Item'Last,
|
| 87 |
+
Item'First + File_Size - Offset);
|
| 88 |
+
|
| 89 |
+
for J in Item'First .. Last loop
|
| 90 |
+
if J < Item'First + Period then
|
| 91 |
+
Item (J) := Random_Elements.Random (Gen);
|
| 92 |
+
else
|
| 93 |
+
Item (J) := Item (J - Period);
|
| 94 |
+
end if;
|
| 95 |
+
|
| 96 |
+
Offset := Offset + 1;
|
| 97 |
+
end loop;
|
| 98 |
+
end Read;
|
| 99 |
+
|
| 100 |
+
-----------
|
| 101 |
+
-- Reset --
|
| 102 |
+
-----------
|
| 103 |
+
|
| 104 |
+
procedure Reset is
|
| 105 |
+
begin
|
| 106 |
+
Random_Elements.Reset (Gen, Init_Random);
|
| 107 |
+
Pack_Size := 0;
|
| 108 |
+
Offset := 1;
|
| 109 |
+
Read_First := Read_Buffer'Last + 1;
|
| 110 |
+
Read_Last := Read_Buffer'Last;
|
| 111 |
+
end Reset;
|
| 112 |
+
|
| 113 |
+
begin
|
| 114 |
+
Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version);
|
| 115 |
+
|
| 116 |
+
loop
|
| 117 |
+
for Level in ZLib.Compression_Level'Range loop
|
| 118 |
+
|
| 119 |
+
Ada.Text_IO.Put ("Level ="
|
| 120 |
+
& ZLib.Compression_Level'Image (Level));
|
| 121 |
+
|
| 122 |
+
-- Deflate using generic instantiation.
|
| 123 |
+
|
| 124 |
+
ZLib.Deflate_Init
|
| 125 |
+
(Filter,
|
| 126 |
+
Level,
|
| 127 |
+
Header => Header);
|
| 128 |
+
|
| 129 |
+
Reset;
|
| 130 |
+
|
| 131 |
+
Ada.Text_IO.Put
|
| 132 |
+
(Stream_Element_Offset'Image (File_Size) & " ->");
|
| 133 |
+
|
| 134 |
+
loop
|
| 135 |
+
declare
|
| 136 |
+
Buffer : Stream_Element_Array (1 .. 1024);
|
| 137 |
+
Last : Stream_Element_Offset;
|
| 138 |
+
begin
|
| 139 |
+
Read (Filter, Buffer, Last);
|
| 140 |
+
|
| 141 |
+
Pack_Size := Pack_Size + Last - Buffer'First + 1;
|
| 142 |
+
|
| 143 |
+
exit when Last < Buffer'Last;
|
| 144 |
+
end;
|
| 145 |
+
end loop;
|
| 146 |
+
|
| 147 |
+
Ada.Text_IO.Put_Line (Stream_Element_Offset'Image (Pack_Size));
|
| 148 |
+
|
| 149 |
+
ZLib.Close (Filter);
|
| 150 |
+
end loop;
|
| 151 |
+
|
| 152 |
+
exit when not Continuous;
|
| 153 |
+
|
| 154 |
+
File_Size := File_Size + 1;
|
| 155 |
+
end loop;
|
| 156 |
+
end Read;
|
contrib/ada/readme.txt
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ZLib for Ada thick binding (ZLib.Ada)
|
| 2 |
+
Release 1.3
|
| 3 |
+
|
| 4 |
+
ZLib.Ada is a thick binding interface to the popular ZLib data
|
| 5 |
+
compression library, available at https://zlib.net/.
|
| 6 |
+
It provides Ada-style access to the ZLib C library.
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
Here are the main changes since ZLib.Ada 1.2:
|
| 10 |
+
|
| 11 |
+
- Attention: ZLib.Read generic routine have a initialization requirement
|
| 12 |
+
for Read_Last parameter now. It is a bit incompatible with previous version,
|
| 13 |
+
but extends functionality, we could use new parameters Allow_Read_Some and
|
| 14 |
+
Flush now.
|
| 15 |
+
|
| 16 |
+
- Added Is_Open routines to ZLib and ZLib.Streams packages.
|
| 17 |
+
|
| 18 |
+
- Add pragma Assert to check Stream_Element is 8 bit.
|
| 19 |
+
|
| 20 |
+
- Fix extraction to buffer with exact known decompressed size. Error reported by
|
| 21 |
+
Steve Sangwine.
|
| 22 |
+
|
| 23 |
+
- Fix definition of ULong (changed to unsigned_long), fix regression on 64 bits
|
| 24 |
+
computers. Patch provided by Pascal Obry.
|
| 25 |
+
|
| 26 |
+
- Add Status_Error exception definition.
|
| 27 |
+
|
| 28 |
+
- Add pragma Assertion that Ada.Streams.Stream_Element size is 8 bit.
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
How to build ZLib.Ada under GNAT
|
| 32 |
+
|
| 33 |
+
You should have the ZLib library already build on your computer, before
|
| 34 |
+
building ZLib.Ada. Make the directory of ZLib.Ada sources current and
|
| 35 |
+
issue the command:
|
| 36 |
+
|
| 37 |
+
gnatmake test -largs -L<directory where libz.a is> -lz
|
| 38 |
+
|
| 39 |
+
Or use the GNAT project file build for GNAT 3.15 or later:
|
| 40 |
+
|
| 41 |
+
gnatmake -Pzlib.gpr -L<directory where libz.a is>
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
How to build ZLib.Ada under Aonix ObjectAda for Win32 7.2.2
|
| 45 |
+
|
| 46 |
+
1. Make a project with all *.ads and *.adb files from the distribution.
|
| 47 |
+
2. Build the libz.a library from the ZLib C sources.
|
| 48 |
+
3. Rename libz.a to z.lib.
|
| 49 |
+
4. Add the library z.lib to the project.
|
| 50 |
+
5. Add the libc.lib library from the ObjectAda distribution to the project.
|
| 51 |
+
6. Build the executable using test.adb as a main procedure.
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
How to use ZLib.Ada
|
| 55 |
+
|
| 56 |
+
The source files test.adb and read.adb are small demo programs that show
|
| 57 |
+
the main functionality of ZLib.Ada.
|
| 58 |
+
|
| 59 |
+
The routines from the package specifications are commented.
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
Homepage: http://zlib-ada.sourceforge.net/
|
| 63 |
+
Author: Dmitriy Anisimkov <anisimkov@yahoo.com>
|
| 64 |
+
|
| 65 |
+
Contributors: Pascal Obry <pascal@obry.org>, Steve Sangwine <sjs@essex.ac.uk>
|
contrib/ada/test.adb
ADDED
|
@@ -0,0 +1,463 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
----------------------------------------------------------------
|
| 2 |
+
-- ZLib for Ada thick binding. --
|
| 3 |
+
-- --
|
| 4 |
+
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
|
| 5 |
+
-- --
|
| 6 |
+
-- Open source license information is in the zlib.ads file. --
|
| 7 |
+
----------------------------------------------------------------
|
| 8 |
+
|
| 9 |
+
-- $Id: test.adb,v 1.17 2003/08/12 12:13:30 vagul Exp $
|
| 10 |
+
|
| 11 |
+
-- The program has a few aims.
|
| 12 |
+
-- 1. Test ZLib.Ada95 thick binding functionality.
|
| 13 |
+
-- 2. Show the example of use main functionality of the ZLib.Ada95 binding.
|
| 14 |
+
-- 3. Build this program automatically compile all ZLib.Ada95 packages under
|
| 15 |
+
-- GNAT Ada95 compiler.
|
| 16 |
+
|
| 17 |
+
with ZLib.Streams;
|
| 18 |
+
with Ada.Streams.Stream_IO;
|
| 19 |
+
with Ada.Numerics.Discrete_Random;
|
| 20 |
+
|
| 21 |
+
with Ada.Text_IO;
|
| 22 |
+
|
| 23 |
+
with Ada.Calendar;
|
| 24 |
+
|
| 25 |
+
procedure Test is
|
| 26 |
+
|
| 27 |
+
use Ada.Streams;
|
| 28 |
+
use Stream_IO;
|
| 29 |
+
|
| 30 |
+
------------------------------------
|
| 31 |
+
-- Test configuration parameters --
|
| 32 |
+
------------------------------------
|
| 33 |
+
|
| 34 |
+
File_Size : Count := 100_000;
|
| 35 |
+
Continuous : constant Boolean := False;
|
| 36 |
+
|
| 37 |
+
Header : constant ZLib.Header_Type := ZLib.Default;
|
| 38 |
+
-- ZLib.None;
|
| 39 |
+
-- ZLib.Auto;
|
| 40 |
+
-- ZLib.GZip;
|
| 41 |
+
-- Do not use Header other then Default in ZLib versions 1.1.4
|
| 42 |
+
-- and older.
|
| 43 |
+
|
| 44 |
+
Strategy : constant ZLib.Strategy_Type := ZLib.Default_Strategy;
|
| 45 |
+
Init_Random : constant := 10;
|
| 46 |
+
|
| 47 |
+
-- End --
|
| 48 |
+
|
| 49 |
+
In_File_Name : constant String := "testzlib.in";
|
| 50 |
+
-- Name of the input file
|
| 51 |
+
|
| 52 |
+
Z_File_Name : constant String := "testzlib.zlb";
|
| 53 |
+
-- Name of the compressed file.
|
| 54 |
+
|
| 55 |
+
Out_File_Name : constant String := "testzlib.out";
|
| 56 |
+
-- Name of the decompressed file.
|
| 57 |
+
|
| 58 |
+
File_In : File_Type;
|
| 59 |
+
File_Out : File_Type;
|
| 60 |
+
File_Back : File_Type;
|
| 61 |
+
File_Z : ZLib.Streams.Stream_Type;
|
| 62 |
+
|
| 63 |
+
Filter : ZLib.Filter_Type;
|
| 64 |
+
|
| 65 |
+
Time_Stamp : Ada.Calendar.Time;
|
| 66 |
+
|
| 67 |
+
procedure Generate_File;
|
| 68 |
+
-- Generate file of specified size with some random data.
|
| 69 |
+
-- The random data is repeatable, for the good compression.
|
| 70 |
+
|
| 71 |
+
procedure Compare_Streams
|
| 72 |
+
(Left, Right : in out Root_Stream_Type'Class);
|
| 73 |
+
-- The procedure comparing data in 2 streams.
|
| 74 |
+
-- It is for compare data before and after compression/decompression.
|
| 75 |
+
|
| 76 |
+
procedure Compare_Files (Left, Right : String);
|
| 77 |
+
-- Compare files. Based on the Compare_Streams.
|
| 78 |
+
|
| 79 |
+
procedure Copy_Streams
|
| 80 |
+
(Source, Target : in out Root_Stream_Type'Class;
|
| 81 |
+
Buffer_Size : in Stream_Element_Offset := 1024);
|
| 82 |
+
-- Copying data from one stream to another. It is for test stream
|
| 83 |
+
-- interface of the library.
|
| 84 |
+
|
| 85 |
+
procedure Data_In
|
| 86 |
+
(Item : out Stream_Element_Array;
|
| 87 |
+
Last : out Stream_Element_Offset);
|
| 88 |
+
-- this procedure is for generic instantiation of
|
| 89 |
+
-- ZLib.Generic_Translate.
|
| 90 |
+
-- reading data from the File_In.
|
| 91 |
+
|
| 92 |
+
procedure Data_Out (Item : in Stream_Element_Array);
|
| 93 |
+
-- this procedure is for generic instantiation of
|
| 94 |
+
-- ZLib.Generic_Translate.
|
| 95 |
+
-- writing data to the File_Out.
|
| 96 |
+
|
| 97 |
+
procedure Stamp;
|
| 98 |
+
-- Store the timestamp to the local variable.
|
| 99 |
+
|
| 100 |
+
procedure Print_Statistic (Msg : String; Data_Size : ZLib.Count);
|
| 101 |
+
-- Print the time statistic with the message.
|
| 102 |
+
|
| 103 |
+
procedure Translate is new ZLib.Generic_Translate
|
| 104 |
+
(Data_In => Data_In,
|
| 105 |
+
Data_Out => Data_Out);
|
| 106 |
+
-- This procedure is moving data from File_In to File_Out
|
| 107 |
+
-- with compression or decompression, depend on initialization of
|
| 108 |
+
-- Filter parameter.
|
| 109 |
+
|
| 110 |
+
-------------------
|
| 111 |
+
-- Compare_Files --
|
| 112 |
+
-------------------
|
| 113 |
+
|
| 114 |
+
procedure Compare_Files (Left, Right : String) is
|
| 115 |
+
Left_File, Right_File : File_Type;
|
| 116 |
+
begin
|
| 117 |
+
Open (Left_File, In_File, Left);
|
| 118 |
+
Open (Right_File, In_File, Right);
|
| 119 |
+
Compare_Streams (Stream (Left_File).all, Stream (Right_File).all);
|
| 120 |
+
Close (Left_File);
|
| 121 |
+
Close (Right_File);
|
| 122 |
+
end Compare_Files;
|
| 123 |
+
|
| 124 |
+
---------------------
|
| 125 |
+
-- Compare_Streams --
|
| 126 |
+
---------------------
|
| 127 |
+
|
| 128 |
+
procedure Compare_Streams
|
| 129 |
+
(Left, Right : in out Ada.Streams.Root_Stream_Type'Class)
|
| 130 |
+
is
|
| 131 |
+
Left_Buffer, Right_Buffer : Stream_Element_Array (0 .. 16#FFF#);
|
| 132 |
+
Left_Last, Right_Last : Stream_Element_Offset;
|
| 133 |
+
begin
|
| 134 |
+
loop
|
| 135 |
+
Read (Left, Left_Buffer, Left_Last);
|
| 136 |
+
Read (Right, Right_Buffer, Right_Last);
|
| 137 |
+
|
| 138 |
+
if Left_Last /= Right_Last then
|
| 139 |
+
Ada.Text_IO.Put_Line ("Compare error :"
|
| 140 |
+
& Stream_Element_Offset'Image (Left_Last)
|
| 141 |
+
& " /= "
|
| 142 |
+
& Stream_Element_Offset'Image (Right_Last));
|
| 143 |
+
|
| 144 |
+
raise Constraint_Error;
|
| 145 |
+
|
| 146 |
+
elsif Left_Buffer (0 .. Left_Last)
|
| 147 |
+
/= Right_Buffer (0 .. Right_Last)
|
| 148 |
+
then
|
| 149 |
+
Ada.Text_IO.Put_Line ("ERROR: IN and OUT files is not equal.");
|
| 150 |
+
raise Constraint_Error;
|
| 151 |
+
|
| 152 |
+
end if;
|
| 153 |
+
|
| 154 |
+
exit when Left_Last < Left_Buffer'Last;
|
| 155 |
+
end loop;
|
| 156 |
+
end Compare_Streams;
|
| 157 |
+
|
| 158 |
+
------------------
|
| 159 |
+
-- Copy_Streams --
|
| 160 |
+
------------------
|
| 161 |
+
|
| 162 |
+
procedure Copy_Streams
|
| 163 |
+
(Source, Target : in out Ada.Streams.Root_Stream_Type'Class;
|
| 164 |
+
Buffer_Size : in Stream_Element_Offset := 1024)
|
| 165 |
+
is
|
| 166 |
+
Buffer : Stream_Element_Array (1 .. Buffer_Size);
|
| 167 |
+
Last : Stream_Element_Offset;
|
| 168 |
+
begin
|
| 169 |
+
loop
|
| 170 |
+
Read (Source, Buffer, Last);
|
| 171 |
+
Write (Target, Buffer (1 .. Last));
|
| 172 |
+
|
| 173 |
+
exit when Last < Buffer'Last;
|
| 174 |
+
end loop;
|
| 175 |
+
end Copy_Streams;
|
| 176 |
+
|
| 177 |
+
-------------
|
| 178 |
+
-- Data_In --
|
| 179 |
+
-------------
|
| 180 |
+
|
| 181 |
+
procedure Data_In
|
| 182 |
+
(Item : out Stream_Element_Array;
|
| 183 |
+
Last : out Stream_Element_Offset) is
|
| 184 |
+
begin
|
| 185 |
+
Read (File_In, Item, Last);
|
| 186 |
+
end Data_In;
|
| 187 |
+
|
| 188 |
+
--------------
|
| 189 |
+
-- Data_Out --
|
| 190 |
+
--------------
|
| 191 |
+
|
| 192 |
+
procedure Data_Out (Item : in Stream_Element_Array) is
|
| 193 |
+
begin
|
| 194 |
+
Write (File_Out, Item);
|
| 195 |
+
end Data_Out;
|
| 196 |
+
|
| 197 |
+
-------------------
|
| 198 |
+
-- Generate_File --
|
| 199 |
+
-------------------
|
| 200 |
+
|
| 201 |
+
procedure Generate_File is
|
| 202 |
+
subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#;
|
| 203 |
+
|
| 204 |
+
package Random_Elements is
|
| 205 |
+
new Ada.Numerics.Discrete_Random (Visible_Symbols);
|
| 206 |
+
|
| 207 |
+
Gen : Random_Elements.Generator;
|
| 208 |
+
Buffer : Stream_Element_Array := (1 .. 77 => 16#20#) & 10;
|
| 209 |
+
|
| 210 |
+
Buffer_Count : constant Count := File_Size / Buffer'Length;
|
| 211 |
+
-- Number of same buffers in the packet.
|
| 212 |
+
|
| 213 |
+
Density : constant Count := 30; -- from 0 to Buffer'Length - 2;
|
| 214 |
+
|
| 215 |
+
procedure Fill_Buffer (J, D : in Count);
|
| 216 |
+
-- Change the part of the buffer.
|
| 217 |
+
|
| 218 |
+
-----------------
|
| 219 |
+
-- Fill_Buffer --
|
| 220 |
+
-----------------
|
| 221 |
+
|
| 222 |
+
procedure Fill_Buffer (J, D : in Count) is
|
| 223 |
+
begin
|
| 224 |
+
for K in 0 .. D loop
|
| 225 |
+
Buffer
|
| 226 |
+
(Stream_Element_Offset ((J + K) mod (Buffer'Length - 1) + 1))
|
| 227 |
+
:= Random_Elements.Random (Gen);
|
| 228 |
+
|
| 229 |
+
end loop;
|
| 230 |
+
end Fill_Buffer;
|
| 231 |
+
|
| 232 |
+
begin
|
| 233 |
+
Random_Elements.Reset (Gen, Init_Random);
|
| 234 |
+
|
| 235 |
+
Create (File_In, Out_File, In_File_Name);
|
| 236 |
+
|
| 237 |
+
Fill_Buffer (1, Buffer'Length - 2);
|
| 238 |
+
|
| 239 |
+
for J in 1 .. Buffer_Count loop
|
| 240 |
+
Write (File_In, Buffer);
|
| 241 |
+
|
| 242 |
+
Fill_Buffer (J, Density);
|
| 243 |
+
end loop;
|
| 244 |
+
|
| 245 |
+
-- fill remain size.
|
| 246 |
+
|
| 247 |
+
Write
|
| 248 |
+
(File_In,
|
| 249 |
+
Buffer
|
| 250 |
+
(1 .. Stream_Element_Offset
|
| 251 |
+
(File_Size - Buffer'Length * Buffer_Count)));
|
| 252 |
+
|
| 253 |
+
Flush (File_In);
|
| 254 |
+
Close (File_In);
|
| 255 |
+
end Generate_File;
|
| 256 |
+
|
| 257 |
+
---------------------
|
| 258 |
+
-- Print_Statistic --
|
| 259 |
+
---------------------
|
| 260 |
+
|
| 261 |
+
procedure Print_Statistic (Msg : String; Data_Size : ZLib.Count) is
|
| 262 |
+
use Ada.Calendar;
|
| 263 |
+
use Ada.Text_IO;
|
| 264 |
+
|
| 265 |
+
package Count_IO is new Integer_IO (ZLib.Count);
|
| 266 |
+
|
| 267 |
+
Curr_Dur : Duration := Clock - Time_Stamp;
|
| 268 |
+
begin
|
| 269 |
+
Put (Msg);
|
| 270 |
+
|
| 271 |
+
Set_Col (20);
|
| 272 |
+
Ada.Text_IO.Put ("size =");
|
| 273 |
+
|
| 274 |
+
Count_IO.Put
|
| 275 |
+
(Data_Size,
|
| 276 |
+
Width => Stream_IO.Count'Image (File_Size)'Length);
|
| 277 |
+
|
| 278 |
+
Put_Line (" duration =" & Duration'Image (Curr_Dur));
|
| 279 |
+
end Print_Statistic;
|
| 280 |
+
|
| 281 |
+
-----------
|
| 282 |
+
-- Stamp --
|
| 283 |
+
-----------
|
| 284 |
+
|
| 285 |
+
procedure Stamp is
|
| 286 |
+
begin
|
| 287 |
+
Time_Stamp := Ada.Calendar.Clock;
|
| 288 |
+
end Stamp;
|
| 289 |
+
|
| 290 |
+
begin
|
| 291 |
+
Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version);
|
| 292 |
+
|
| 293 |
+
loop
|
| 294 |
+
Generate_File;
|
| 295 |
+
|
| 296 |
+
for Level in ZLib.Compression_Level'Range loop
|
| 297 |
+
|
| 298 |
+
Ada.Text_IO.Put_Line ("Level ="
|
| 299 |
+
& ZLib.Compression_Level'Image (Level));
|
| 300 |
+
|
| 301 |
+
-- Test generic interface.
|
| 302 |
+
Open (File_In, In_File, In_File_Name);
|
| 303 |
+
Create (File_Out, Out_File, Z_File_Name);
|
| 304 |
+
|
| 305 |
+
Stamp;
|
| 306 |
+
|
| 307 |
+
-- Deflate using generic instantiation.
|
| 308 |
+
|
| 309 |
+
ZLib.Deflate_Init
|
| 310 |
+
(Filter => Filter,
|
| 311 |
+
Level => Level,
|
| 312 |
+
Strategy => Strategy,
|
| 313 |
+
Header => Header);
|
| 314 |
+
|
| 315 |
+
Translate (Filter);
|
| 316 |
+
Print_Statistic ("Generic compress", ZLib.Total_Out (Filter));
|
| 317 |
+
ZLib.Close (Filter);
|
| 318 |
+
|
| 319 |
+
Close (File_In);
|
| 320 |
+
Close (File_Out);
|
| 321 |
+
|
| 322 |
+
Open (File_In, In_File, Z_File_Name);
|
| 323 |
+
Create (File_Out, Out_File, Out_File_Name);
|
| 324 |
+
|
| 325 |
+
Stamp;
|
| 326 |
+
|
| 327 |
+
-- Inflate using generic instantiation.
|
| 328 |
+
|
| 329 |
+
ZLib.Inflate_Init (Filter, Header => Header);
|
| 330 |
+
|
| 331 |
+
Translate (Filter);
|
| 332 |
+
Print_Statistic ("Generic decompress", ZLib.Total_Out (Filter));
|
| 333 |
+
|
| 334 |
+
ZLib.Close (Filter);
|
| 335 |
+
|
| 336 |
+
Close (File_In);
|
| 337 |
+
Close (File_Out);
|
| 338 |
+
|
| 339 |
+
Compare_Files (In_File_Name, Out_File_Name);
|
| 340 |
+
|
| 341 |
+
-- Test stream interface.
|
| 342 |
+
|
| 343 |
+
-- Compress to the back stream.
|
| 344 |
+
|
| 345 |
+
Open (File_In, In_File, In_File_Name);
|
| 346 |
+
Create (File_Back, Out_File, Z_File_Name);
|
| 347 |
+
|
| 348 |
+
Stamp;
|
| 349 |
+
|
| 350 |
+
ZLib.Streams.Create
|
| 351 |
+
(Stream => File_Z,
|
| 352 |
+
Mode => ZLib.Streams.Out_Stream,
|
| 353 |
+
Back => ZLib.Streams.Stream_Access
|
| 354 |
+
(Stream (File_Back)),
|
| 355 |
+
Back_Compressed => True,
|
| 356 |
+
Level => Level,
|
| 357 |
+
Strategy => Strategy,
|
| 358 |
+
Header => Header);
|
| 359 |
+
|
| 360 |
+
Copy_Streams
|
| 361 |
+
(Source => Stream (File_In).all,
|
| 362 |
+
Target => File_Z);
|
| 363 |
+
|
| 364 |
+
-- Flushing internal buffers to the back stream.
|
| 365 |
+
|
| 366 |
+
ZLib.Streams.Flush (File_Z, ZLib.Finish);
|
| 367 |
+
|
| 368 |
+
Print_Statistic ("Write compress",
|
| 369 |
+
ZLib.Streams.Write_Total_Out (File_Z));
|
| 370 |
+
|
| 371 |
+
ZLib.Streams.Close (File_Z);
|
| 372 |
+
|
| 373 |
+
Close (File_In);
|
| 374 |
+
Close (File_Back);
|
| 375 |
+
|
| 376 |
+
-- Compare reading from original file and from
|
| 377 |
+
-- decompression stream.
|
| 378 |
+
|
| 379 |
+
Open (File_In, In_File, In_File_Name);
|
| 380 |
+
Open (File_Back, In_File, Z_File_Name);
|
| 381 |
+
|
| 382 |
+
ZLib.Streams.Create
|
| 383 |
+
(Stream => File_Z,
|
| 384 |
+
Mode => ZLib.Streams.In_Stream,
|
| 385 |
+
Back => ZLib.Streams.Stream_Access
|
| 386 |
+
(Stream (File_Back)),
|
| 387 |
+
Back_Compressed => True,
|
| 388 |
+
Header => Header);
|
| 389 |
+
|
| 390 |
+
Stamp;
|
| 391 |
+
Compare_Streams (Stream (File_In).all, File_Z);
|
| 392 |
+
|
| 393 |
+
Print_Statistic ("Read decompress",
|
| 394 |
+
ZLib.Streams.Read_Total_Out (File_Z));
|
| 395 |
+
|
| 396 |
+
ZLib.Streams.Close (File_Z);
|
| 397 |
+
Close (File_In);
|
| 398 |
+
Close (File_Back);
|
| 399 |
+
|
| 400 |
+
-- Compress by reading from compression stream.
|
| 401 |
+
|
| 402 |
+
Open (File_Back, In_File, In_File_Name);
|
| 403 |
+
Create (File_Out, Out_File, Z_File_Name);
|
| 404 |
+
|
| 405 |
+
ZLib.Streams.Create
|
| 406 |
+
(Stream => File_Z,
|
| 407 |
+
Mode => ZLib.Streams.In_Stream,
|
| 408 |
+
Back => ZLib.Streams.Stream_Access
|
| 409 |
+
(Stream (File_Back)),
|
| 410 |
+
Back_Compressed => False,
|
| 411 |
+
Level => Level,
|
| 412 |
+
Strategy => Strategy,
|
| 413 |
+
Header => Header);
|
| 414 |
+
|
| 415 |
+
Stamp;
|
| 416 |
+
Copy_Streams
|
| 417 |
+
(Source => File_Z,
|
| 418 |
+
Target => Stream (File_Out).all);
|
| 419 |
+
|
| 420 |
+
Print_Statistic ("Read compress",
|
| 421 |
+
ZLib.Streams.Read_Total_Out (File_Z));
|
| 422 |
+
|
| 423 |
+
ZLib.Streams.Close (File_Z);
|
| 424 |
+
|
| 425 |
+
Close (File_Out);
|
| 426 |
+
Close (File_Back);
|
| 427 |
+
|
| 428 |
+
-- Decompress to decompression stream.
|
| 429 |
+
|
| 430 |
+
Open (File_In, In_File, Z_File_Name);
|
| 431 |
+
Create (File_Back, Out_File, Out_File_Name);
|
| 432 |
+
|
| 433 |
+
ZLib.Streams.Create
|
| 434 |
+
(Stream => File_Z,
|
| 435 |
+
Mode => ZLib.Streams.Out_Stream,
|
| 436 |
+
Back => ZLib.Streams.Stream_Access
|
| 437 |
+
(Stream (File_Back)),
|
| 438 |
+
Back_Compressed => False,
|
| 439 |
+
Header => Header);
|
| 440 |
+
|
| 441 |
+
Stamp;
|
| 442 |
+
|
| 443 |
+
Copy_Streams
|
| 444 |
+
(Source => Stream (File_In).all,
|
| 445 |
+
Target => File_Z);
|
| 446 |
+
|
| 447 |
+
Print_Statistic ("Write decompress",
|
| 448 |
+
ZLib.Streams.Write_Total_Out (File_Z));
|
| 449 |
+
|
| 450 |
+
ZLib.Streams.Close (File_Z);
|
| 451 |
+
Close (File_In);
|
| 452 |
+
Close (File_Back);
|
| 453 |
+
|
| 454 |
+
Compare_Files (In_File_Name, Out_File_Name);
|
| 455 |
+
end loop;
|
| 456 |
+
|
| 457 |
+
Ada.Text_IO.Put_Line (Count'Image (File_Size) & " Ok.");
|
| 458 |
+
|
| 459 |
+
exit when not Continuous;
|
| 460 |
+
|
| 461 |
+
File_Size := File_Size + 1;
|
| 462 |
+
end loop;
|
| 463 |
+
end Test;
|
contrib/ada/zlib-streams.adb
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
----------------------------------------------------------------
|
| 2 |
+
-- ZLib for Ada thick binding. --
|
| 3 |
+
-- --
|
| 4 |
+
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
|
| 5 |
+
-- --
|
| 6 |
+
-- Open source license information is in the zlib.ads file. --
|
| 7 |
+
----------------------------------------------------------------
|
| 8 |
+
|
| 9 |
+
-- $Id: zlib-streams.adb,v 1.10 2004/05/31 10:53:40 vagul Exp $
|
| 10 |
+
|
| 11 |
+
with Ada.Unchecked_Deallocation;
|
| 12 |
+
|
| 13 |
+
package body ZLib.Streams is
|
| 14 |
+
|
| 15 |
+
-----------
|
| 16 |
+
-- Close --
|
| 17 |
+
-----------
|
| 18 |
+
|
| 19 |
+
procedure Close (Stream : in out Stream_Type) is
|
| 20 |
+
procedure Free is new Ada.Unchecked_Deallocation
|
| 21 |
+
(Stream_Element_Array, Buffer_Access);
|
| 22 |
+
begin
|
| 23 |
+
if Stream.Mode = Out_Stream or Stream.Mode = Duplex then
|
| 24 |
+
-- We should flush the data written by the writer.
|
| 25 |
+
|
| 26 |
+
Flush (Stream, Finish);
|
| 27 |
+
|
| 28 |
+
Close (Stream.Writer);
|
| 29 |
+
end if;
|
| 30 |
+
|
| 31 |
+
if Stream.Mode = In_Stream or Stream.Mode = Duplex then
|
| 32 |
+
Close (Stream.Reader);
|
| 33 |
+
Free (Stream.Buffer);
|
| 34 |
+
end if;
|
| 35 |
+
end Close;
|
| 36 |
+
|
| 37 |
+
------------
|
| 38 |
+
-- Create --
|
| 39 |
+
------------
|
| 40 |
+
|
| 41 |
+
procedure Create
|
| 42 |
+
(Stream : out Stream_Type;
|
| 43 |
+
Mode : in Stream_Mode;
|
| 44 |
+
Back : in Stream_Access;
|
| 45 |
+
Back_Compressed : in Boolean;
|
| 46 |
+
Level : in Compression_Level := Default_Compression;
|
| 47 |
+
Strategy : in Strategy_Type := Default_Strategy;
|
| 48 |
+
Header : in Header_Type := Default;
|
| 49 |
+
Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset
|
| 50 |
+
:= Default_Buffer_Size;
|
| 51 |
+
Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset
|
| 52 |
+
:= Default_Buffer_Size)
|
| 53 |
+
is
|
| 54 |
+
|
| 55 |
+
subtype Buffer_Subtype is Stream_Element_Array (1 .. Read_Buffer_Size);
|
| 56 |
+
|
| 57 |
+
procedure Init_Filter
|
| 58 |
+
(Filter : in out Filter_Type;
|
| 59 |
+
Compress : in Boolean);
|
| 60 |
+
|
| 61 |
+
-----------------
|
| 62 |
+
-- Init_Filter --
|
| 63 |
+
-----------------
|
| 64 |
+
|
| 65 |
+
procedure Init_Filter
|
| 66 |
+
(Filter : in out Filter_Type;
|
| 67 |
+
Compress : in Boolean) is
|
| 68 |
+
begin
|
| 69 |
+
if Compress then
|
| 70 |
+
Deflate_Init
|
| 71 |
+
(Filter, Level, Strategy, Header => Header);
|
| 72 |
+
else
|
| 73 |
+
Inflate_Init (Filter, Header => Header);
|
| 74 |
+
end if;
|
| 75 |
+
end Init_Filter;
|
| 76 |
+
|
| 77 |
+
begin
|
| 78 |
+
Stream.Back := Back;
|
| 79 |
+
Stream.Mode := Mode;
|
| 80 |
+
|
| 81 |
+
if Mode = Out_Stream or Mode = Duplex then
|
| 82 |
+
Init_Filter (Stream.Writer, Back_Compressed);
|
| 83 |
+
Stream.Buffer_Size := Write_Buffer_Size;
|
| 84 |
+
else
|
| 85 |
+
Stream.Buffer_Size := 0;
|
| 86 |
+
end if;
|
| 87 |
+
|
| 88 |
+
if Mode = In_Stream or Mode = Duplex then
|
| 89 |
+
Init_Filter (Stream.Reader, not Back_Compressed);
|
| 90 |
+
|
| 91 |
+
Stream.Buffer := new Buffer_Subtype;
|
| 92 |
+
Stream.Rest_First := Stream.Buffer'Last + 1;
|
| 93 |
+
Stream.Rest_Last := Stream.Buffer'Last;
|
| 94 |
+
end if;
|
| 95 |
+
end Create;
|
| 96 |
+
|
| 97 |
+
-----------
|
| 98 |
+
-- Flush --
|
| 99 |
+
-----------
|
| 100 |
+
|
| 101 |
+
procedure Flush
|
| 102 |
+
(Stream : in out Stream_Type;
|
| 103 |
+
Mode : in Flush_Mode := Sync_Flush)
|
| 104 |
+
is
|
| 105 |
+
Buffer : Stream_Element_Array (1 .. Stream.Buffer_Size);
|
| 106 |
+
Last : Stream_Element_Offset;
|
| 107 |
+
begin
|
| 108 |
+
loop
|
| 109 |
+
Flush (Stream.Writer, Buffer, Last, Mode);
|
| 110 |
+
|
| 111 |
+
Ada.Streams.Write (Stream.Back.all, Buffer (1 .. Last));
|
| 112 |
+
|
| 113 |
+
exit when Last < Buffer'Last;
|
| 114 |
+
end loop;
|
| 115 |
+
end Flush;
|
| 116 |
+
|
| 117 |
+
-------------
|
| 118 |
+
-- Is_Open --
|
| 119 |
+
-------------
|
| 120 |
+
|
| 121 |
+
function Is_Open (Stream : Stream_Type) return Boolean is
|
| 122 |
+
begin
|
| 123 |
+
return Is_Open (Stream.Reader) or else Is_Open (Stream.Writer);
|
| 124 |
+
end Is_Open;
|
| 125 |
+
|
| 126 |
+
----------
|
| 127 |
+
-- Read --
|
| 128 |
+
----------
|
| 129 |
+
|
| 130 |
+
procedure Read
|
| 131 |
+
(Stream : in out Stream_Type;
|
| 132 |
+
Item : out Stream_Element_Array;
|
| 133 |
+
Last : out Stream_Element_Offset)
|
| 134 |
+
is
|
| 135 |
+
|
| 136 |
+
procedure Read
|
| 137 |
+
(Item : out Stream_Element_Array;
|
| 138 |
+
Last : out Stream_Element_Offset);
|
| 139 |
+
|
| 140 |
+
----------
|
| 141 |
+
-- Read --
|
| 142 |
+
----------
|
| 143 |
+
|
| 144 |
+
procedure Read
|
| 145 |
+
(Item : out Stream_Element_Array;
|
| 146 |
+
Last : out Stream_Element_Offset) is
|
| 147 |
+
begin
|
| 148 |
+
Ada.Streams.Read (Stream.Back.all, Item, Last);
|
| 149 |
+
end Read;
|
| 150 |
+
|
| 151 |
+
procedure Read is new ZLib.Read
|
| 152 |
+
(Read => Read,
|
| 153 |
+
Buffer => Stream.Buffer.all,
|
| 154 |
+
Rest_First => Stream.Rest_First,
|
| 155 |
+
Rest_Last => Stream.Rest_Last);
|
| 156 |
+
|
| 157 |
+
begin
|
| 158 |
+
Read (Stream.Reader, Item, Last);
|
| 159 |
+
end Read;
|
| 160 |
+
|
| 161 |
+
-------------------
|
| 162 |
+
-- Read_Total_In --
|
| 163 |
+
-------------------
|
| 164 |
+
|
| 165 |
+
function Read_Total_In (Stream : in Stream_Type) return Count is
|
| 166 |
+
begin
|
| 167 |
+
return Total_In (Stream.Reader);
|
| 168 |
+
end Read_Total_In;
|
| 169 |
+
|
| 170 |
+
--------------------
|
| 171 |
+
-- Read_Total_Out --
|
| 172 |
+
--------------------
|
| 173 |
+
|
| 174 |
+
function Read_Total_Out (Stream : in Stream_Type) return Count is
|
| 175 |
+
begin
|
| 176 |
+
return Total_Out (Stream.Reader);
|
| 177 |
+
end Read_Total_Out;
|
| 178 |
+
|
| 179 |
+
-----------
|
| 180 |
+
-- Write --
|
| 181 |
+
-----------
|
| 182 |
+
|
| 183 |
+
procedure Write
|
| 184 |
+
(Stream : in out Stream_Type;
|
| 185 |
+
Item : in Stream_Element_Array)
|
| 186 |
+
is
|
| 187 |
+
|
| 188 |
+
procedure Write (Item : in Stream_Element_Array);
|
| 189 |
+
|
| 190 |
+
-----------
|
| 191 |
+
-- Write --
|
| 192 |
+
-----------
|
| 193 |
+
|
| 194 |
+
procedure Write (Item : in Stream_Element_Array) is
|
| 195 |
+
begin
|
| 196 |
+
Ada.Streams.Write (Stream.Back.all, Item);
|
| 197 |
+
end Write;
|
| 198 |
+
|
| 199 |
+
procedure Write is new ZLib.Write
|
| 200 |
+
(Write => Write,
|
| 201 |
+
Buffer_Size => Stream.Buffer_Size);
|
| 202 |
+
|
| 203 |
+
begin
|
| 204 |
+
Write (Stream.Writer, Item, No_Flush);
|
| 205 |
+
end Write;
|
| 206 |
+
|
| 207 |
+
--------------------
|
| 208 |
+
-- Write_Total_In --
|
| 209 |
+
--------------------
|
| 210 |
+
|
| 211 |
+
function Write_Total_In (Stream : in Stream_Type) return Count is
|
| 212 |
+
begin
|
| 213 |
+
return Total_In (Stream.Writer);
|
| 214 |
+
end Write_Total_In;
|
| 215 |
+
|
| 216 |
+
---------------------
|
| 217 |
+
-- Write_Total_Out --
|
| 218 |
+
---------------------
|
| 219 |
+
|
| 220 |
+
function Write_Total_Out (Stream : in Stream_Type) return Count is
|
| 221 |
+
begin
|
| 222 |
+
return Total_Out (Stream.Writer);
|
| 223 |
+
end Write_Total_Out;
|
| 224 |
+
|
| 225 |
+
end ZLib.Streams;
|
contrib/ada/zlib-streams.ads
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
----------------------------------------------------------------
|
| 2 |
+
-- ZLib for Ada thick binding. --
|
| 3 |
+
-- --
|
| 4 |
+
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
|
| 5 |
+
-- --
|
| 6 |
+
-- Open source license information is in the zlib.ads file. --
|
| 7 |
+
----------------------------------------------------------------
|
| 8 |
+
|
| 9 |
+
-- $Id: zlib-streams.ads,v 1.12 2004/05/31 10:53:40 vagul Exp $
|
| 10 |
+
|
| 11 |
+
package ZLib.Streams is
|
| 12 |
+
|
| 13 |
+
type Stream_Mode is (In_Stream, Out_Stream, Duplex);
|
| 14 |
+
|
| 15 |
+
type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class;
|
| 16 |
+
|
| 17 |
+
type Stream_Type is
|
| 18 |
+
new Ada.Streams.Root_Stream_Type with private;
|
| 19 |
+
|
| 20 |
+
procedure Read
|
| 21 |
+
(Stream : in out Stream_Type;
|
| 22 |
+
Item : out Ada.Streams.Stream_Element_Array;
|
| 23 |
+
Last : out Ada.Streams.Stream_Element_Offset);
|
| 24 |
+
|
| 25 |
+
procedure Write
|
| 26 |
+
(Stream : in out Stream_Type;
|
| 27 |
+
Item : in Ada.Streams.Stream_Element_Array);
|
| 28 |
+
|
| 29 |
+
procedure Flush
|
| 30 |
+
(Stream : in out Stream_Type;
|
| 31 |
+
Mode : in Flush_Mode := Sync_Flush);
|
| 32 |
+
-- Flush the written data to the back stream,
|
| 33 |
+
-- all data placed to the compressor is flushing to the Back stream.
|
| 34 |
+
-- Should not be used until necessary, because it is decreasing
|
| 35 |
+
-- compression.
|
| 36 |
+
|
| 37 |
+
function Read_Total_In (Stream : in Stream_Type) return Count;
|
| 38 |
+
pragma Inline (Read_Total_In);
|
| 39 |
+
-- Return total number of bytes read from back stream so far.
|
| 40 |
+
|
| 41 |
+
function Read_Total_Out (Stream : in Stream_Type) return Count;
|
| 42 |
+
pragma Inline (Read_Total_Out);
|
| 43 |
+
-- Return total number of bytes read so far.
|
| 44 |
+
|
| 45 |
+
function Write_Total_In (Stream : in Stream_Type) return Count;
|
| 46 |
+
pragma Inline (Write_Total_In);
|
| 47 |
+
-- Return total number of bytes written so far.
|
| 48 |
+
|
| 49 |
+
function Write_Total_Out (Stream : in Stream_Type) return Count;
|
| 50 |
+
pragma Inline (Write_Total_Out);
|
| 51 |
+
-- Return total number of bytes written to the back stream.
|
| 52 |
+
|
| 53 |
+
procedure Create
|
| 54 |
+
(Stream : out Stream_Type;
|
| 55 |
+
Mode : in Stream_Mode;
|
| 56 |
+
Back : in Stream_Access;
|
| 57 |
+
Back_Compressed : in Boolean;
|
| 58 |
+
Level : in Compression_Level := Default_Compression;
|
| 59 |
+
Strategy : in Strategy_Type := Default_Strategy;
|
| 60 |
+
Header : in Header_Type := Default;
|
| 61 |
+
Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset
|
| 62 |
+
:= Default_Buffer_Size;
|
| 63 |
+
Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset
|
| 64 |
+
:= Default_Buffer_Size);
|
| 65 |
+
-- Create the Compression/Decompression stream.
|
| 66 |
+
-- If mode is In_Stream then Write operation is disabled.
|
| 67 |
+
-- If mode is Out_Stream then Read operation is disabled.
|
| 68 |
+
|
| 69 |
+
-- If Back_Compressed is true then
|
| 70 |
+
-- Data written to the Stream is compressing to the Back stream
|
| 71 |
+
-- and data read from the Stream is decompressed data from the Back stream.
|
| 72 |
+
|
| 73 |
+
-- If Back_Compressed is false then
|
| 74 |
+
-- Data written to the Stream is decompressing to the Back stream
|
| 75 |
+
-- and data read from the Stream is compressed data from the Back stream.
|
| 76 |
+
|
| 77 |
+
-- !!! When the Need_Header is False ZLib-Ada is using undocumented
|
| 78 |
+
-- ZLib 1.1.4 functionality to do not create/wait for ZLib headers.
|
| 79 |
+
|
| 80 |
+
function Is_Open (Stream : Stream_Type) return Boolean;
|
| 81 |
+
|
| 82 |
+
procedure Close (Stream : in out Stream_Type);
|
| 83 |
+
|
| 84 |
+
private
|
| 85 |
+
|
| 86 |
+
use Ada.Streams;
|
| 87 |
+
|
| 88 |
+
type Buffer_Access is access all Stream_Element_Array;
|
| 89 |
+
|
| 90 |
+
type Stream_Type
|
| 91 |
+
is new Root_Stream_Type with
|
| 92 |
+
record
|
| 93 |
+
Mode : Stream_Mode;
|
| 94 |
+
|
| 95 |
+
Buffer : Buffer_Access;
|
| 96 |
+
Rest_First : Stream_Element_Offset;
|
| 97 |
+
Rest_Last : Stream_Element_Offset;
|
| 98 |
+
-- Buffer for Read operation.
|
| 99 |
+
-- We need to have this buffer in the record
|
| 100 |
+
-- because not all read data from back stream
|
| 101 |
+
-- could be processed during the read operation.
|
| 102 |
+
|
| 103 |
+
Buffer_Size : Stream_Element_Offset;
|
| 104 |
+
-- Buffer size for write operation.
|
| 105 |
+
-- We do not need to have this buffer
|
| 106 |
+
-- in the record because all data could be
|
| 107 |
+
-- processed in the write operation.
|
| 108 |
+
|
| 109 |
+
Back : Stream_Access;
|
| 110 |
+
Reader : Filter_Type;
|
| 111 |
+
Writer : Filter_Type;
|
| 112 |
+
end record;
|
| 113 |
+
|
| 114 |
+
end ZLib.Streams;
|
contrib/ada/zlib-thin.adb
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
----------------------------------------------------------------
|
| 2 |
+
-- ZLib for Ada thick binding. --
|
| 3 |
+
-- --
|
| 4 |
+
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
|
| 5 |
+
-- --
|
| 6 |
+
-- Open source license information is in the zlib.ads file. --
|
| 7 |
+
----------------------------------------------------------------
|
| 8 |
+
|
| 9 |
+
-- $Id: zlib-thin.adb,v 1.8 2003/12/14 18:27:31 vagul Exp $
|
| 10 |
+
|
| 11 |
+
package body ZLib.Thin is
|
| 12 |
+
|
| 13 |
+
ZLIB_VERSION : constant Chars_Ptr := zlibVersion;
|
| 14 |
+
|
| 15 |
+
Dummy : Z_Stream;
|
| 16 |
+
Z_Stream_Size : constant Int := Dummy'Size / System.Storage_Unit;
|
| 17 |
+
|
| 18 |
+
--------------
|
| 19 |
+
-- Avail_In --
|
| 20 |
+
--------------
|
| 21 |
+
|
| 22 |
+
function Avail_In (Strm : in Z_Stream) return UInt is
|
| 23 |
+
begin
|
| 24 |
+
return Strm.Avail_In;
|
| 25 |
+
end Avail_In;
|
| 26 |
+
|
| 27 |
+
---------------
|
| 28 |
+
-- Avail_Out --
|
| 29 |
+
---------------
|
| 30 |
+
|
| 31 |
+
function Avail_Out (Strm : in Z_Stream) return UInt is
|
| 32 |
+
begin
|
| 33 |
+
return Strm.Avail_Out;
|
| 34 |
+
end Avail_Out;
|
| 35 |
+
|
| 36 |
+
------------------
|
| 37 |
+
-- Deflate_Init --
|
| 38 |
+
------------------
|
| 39 |
+
|
| 40 |
+
function Deflate_Init
|
| 41 |
+
(strm : Z_Streamp;
|
| 42 |
+
level : Int;
|
| 43 |
+
method : Int;
|
| 44 |
+
windowBits : Int;
|
| 45 |
+
memLevel : Int;
|
| 46 |
+
strategy : Int)
|
| 47 |
+
return Int is
|
| 48 |
+
begin
|
| 49 |
+
return deflateInit2
|
| 50 |
+
(strm,
|
| 51 |
+
level,
|
| 52 |
+
method,
|
| 53 |
+
windowBits,
|
| 54 |
+
memLevel,
|
| 55 |
+
strategy,
|
| 56 |
+
ZLIB_VERSION,
|
| 57 |
+
Z_Stream_Size);
|
| 58 |
+
end Deflate_Init;
|
| 59 |
+
|
| 60 |
+
------------------
|
| 61 |
+
-- Inflate_Init --
|
| 62 |
+
------------------
|
| 63 |
+
|
| 64 |
+
function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int is
|
| 65 |
+
begin
|
| 66 |
+
return inflateInit2 (strm, windowBits, ZLIB_VERSION, Z_Stream_Size);
|
| 67 |
+
end Inflate_Init;
|
| 68 |
+
|
| 69 |
+
------------------------
|
| 70 |
+
-- Last_Error_Message --
|
| 71 |
+
------------------------
|
| 72 |
+
|
| 73 |
+
function Last_Error_Message (Strm : in Z_Stream) return String is
|
| 74 |
+
use Interfaces.C.Strings;
|
| 75 |
+
begin
|
| 76 |
+
if Strm.msg = Null_Ptr then
|
| 77 |
+
return "";
|
| 78 |
+
else
|
| 79 |
+
return Value (Strm.msg);
|
| 80 |
+
end if;
|
| 81 |
+
end Last_Error_Message;
|
| 82 |
+
|
| 83 |
+
------------
|
| 84 |
+
-- Set_In --
|
| 85 |
+
------------
|
| 86 |
+
|
| 87 |
+
procedure Set_In
|
| 88 |
+
(Strm : in out Z_Stream;
|
| 89 |
+
Buffer : in Voidp;
|
| 90 |
+
Size : in UInt) is
|
| 91 |
+
begin
|
| 92 |
+
Strm.Next_In := Buffer;
|
| 93 |
+
Strm.Avail_In := Size;
|
| 94 |
+
end Set_In;
|
| 95 |
+
|
| 96 |
+
------------------
|
| 97 |
+
-- Set_Mem_Func --
|
| 98 |
+
------------------
|
| 99 |
+
|
| 100 |
+
procedure Set_Mem_Func
|
| 101 |
+
(Strm : in out Z_Stream;
|
| 102 |
+
Opaque : in Voidp;
|
| 103 |
+
Alloc : in alloc_func;
|
| 104 |
+
Free : in free_func) is
|
| 105 |
+
begin
|
| 106 |
+
Strm.opaque := Opaque;
|
| 107 |
+
Strm.zalloc := Alloc;
|
| 108 |
+
Strm.zfree := Free;
|
| 109 |
+
end Set_Mem_Func;
|
| 110 |
+
|
| 111 |
+
-------------
|
| 112 |
+
-- Set_Out --
|
| 113 |
+
-------------
|
| 114 |
+
|
| 115 |
+
procedure Set_Out
|
| 116 |
+
(Strm : in out Z_Stream;
|
| 117 |
+
Buffer : in Voidp;
|
| 118 |
+
Size : in UInt) is
|
| 119 |
+
begin
|
| 120 |
+
Strm.Next_Out := Buffer;
|
| 121 |
+
Strm.Avail_Out := Size;
|
| 122 |
+
end Set_Out;
|
| 123 |
+
|
| 124 |
+
--------------
|
| 125 |
+
-- Total_In --
|
| 126 |
+
--------------
|
| 127 |
+
|
| 128 |
+
function Total_In (Strm : in Z_Stream) return ULong is
|
| 129 |
+
begin
|
| 130 |
+
return Strm.Total_In;
|
| 131 |
+
end Total_In;
|
| 132 |
+
|
| 133 |
+
---------------
|
| 134 |
+
-- Total_Out --
|
| 135 |
+
---------------
|
| 136 |
+
|
| 137 |
+
function Total_Out (Strm : in Z_Stream) return ULong is
|
| 138 |
+
begin
|
| 139 |
+
return Strm.Total_Out;
|
| 140 |
+
end Total_Out;
|
| 141 |
+
|
| 142 |
+
end ZLib.Thin;
|
contrib/ada/zlib-thin.ads
ADDED
|
@@ -0,0 +1,450 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
----------------------------------------------------------------
|
| 2 |
+
-- ZLib for Ada thick binding. --
|
| 3 |
+
-- --
|
| 4 |
+
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
|
| 5 |
+
-- --
|
| 6 |
+
-- Open source license information is in the zlib.ads file. --
|
| 7 |
+
----------------------------------------------------------------
|
| 8 |
+
|
| 9 |
+
-- $Id: zlib-thin.ads,v 1.11 2004/07/23 06:33:11 vagul Exp $
|
| 10 |
+
|
| 11 |
+
with Interfaces.C.Strings;
|
| 12 |
+
|
| 13 |
+
with System;
|
| 14 |
+
|
| 15 |
+
private package ZLib.Thin is
|
| 16 |
+
|
| 17 |
+
-- From zconf.h
|
| 18 |
+
|
| 19 |
+
MAX_MEM_LEVEL : constant := 9; -- zconf.h:105
|
| 20 |
+
-- zconf.h:105
|
| 21 |
+
MAX_WBITS : constant := 15; -- zconf.h:115
|
| 22 |
+
-- 32K LZ77 window
|
| 23 |
+
-- zconf.h:115
|
| 24 |
+
SEEK_SET : constant := 8#0000#; -- zconf.h:244
|
| 25 |
+
-- Seek from beginning of file.
|
| 26 |
+
-- zconf.h:244
|
| 27 |
+
SEEK_CUR : constant := 1; -- zconf.h:245
|
| 28 |
+
-- Seek from current position.
|
| 29 |
+
-- zconf.h:245
|
| 30 |
+
SEEK_END : constant := 2; -- zconf.h:246
|
| 31 |
+
-- Set file pointer to EOF plus "offset"
|
| 32 |
+
-- zconf.h:246
|
| 33 |
+
|
| 34 |
+
type Byte is new Interfaces.C.unsigned_char; -- 8 bits
|
| 35 |
+
-- zconf.h:214
|
| 36 |
+
type UInt is new Interfaces.C.unsigned; -- 16 bits or more
|
| 37 |
+
-- zconf.h:216
|
| 38 |
+
type Int is new Interfaces.C.int;
|
| 39 |
+
|
| 40 |
+
type ULong is new Interfaces.C.unsigned_long; -- 32 bits or more
|
| 41 |
+
-- zconf.h:217
|
| 42 |
+
subtype Chars_Ptr is Interfaces.C.Strings.chars_ptr;
|
| 43 |
+
|
| 44 |
+
type ULong_Access is access ULong;
|
| 45 |
+
type Int_Access is access Int;
|
| 46 |
+
|
| 47 |
+
subtype Voidp is System.Address; -- zconf.h:232
|
| 48 |
+
|
| 49 |
+
subtype Byte_Access is Voidp;
|
| 50 |
+
|
| 51 |
+
Nul : constant Voidp := System.Null_Address;
|
| 52 |
+
-- end from zconf
|
| 53 |
+
|
| 54 |
+
Z_NO_FLUSH : constant := 8#0000#; -- zlib.h:125
|
| 55 |
+
-- zlib.h:125
|
| 56 |
+
Z_PARTIAL_FLUSH : constant := 1; -- zlib.h:126
|
| 57 |
+
-- will be removed, use
|
| 58 |
+
-- Z_SYNC_FLUSH instead
|
| 59 |
+
-- zlib.h:126
|
| 60 |
+
Z_SYNC_FLUSH : constant := 2; -- zlib.h:127
|
| 61 |
+
-- zlib.h:127
|
| 62 |
+
Z_FULL_FLUSH : constant := 3; -- zlib.h:128
|
| 63 |
+
-- zlib.h:128
|
| 64 |
+
Z_FINISH : constant := 4; -- zlib.h:129
|
| 65 |
+
-- zlib.h:129
|
| 66 |
+
Z_OK : constant := 8#0000#; -- zlib.h:132
|
| 67 |
+
-- zlib.h:132
|
| 68 |
+
Z_STREAM_END : constant := 1; -- zlib.h:133
|
| 69 |
+
-- zlib.h:133
|
| 70 |
+
Z_NEED_DICT : constant := 2; -- zlib.h:134
|
| 71 |
+
-- zlib.h:134
|
| 72 |
+
Z_ERRNO : constant := -1; -- zlib.h:135
|
| 73 |
+
-- zlib.h:135
|
| 74 |
+
Z_STREAM_ERROR : constant := -2; -- zlib.h:136
|
| 75 |
+
-- zlib.h:136
|
| 76 |
+
Z_DATA_ERROR : constant := -3; -- zlib.h:137
|
| 77 |
+
-- zlib.h:137
|
| 78 |
+
Z_MEM_ERROR : constant := -4; -- zlib.h:138
|
| 79 |
+
-- zlib.h:138
|
| 80 |
+
Z_BUF_ERROR : constant := -5; -- zlib.h:139
|
| 81 |
+
-- zlib.h:139
|
| 82 |
+
Z_VERSION_ERROR : constant := -6; -- zlib.h:140
|
| 83 |
+
-- zlib.h:140
|
| 84 |
+
Z_NO_COMPRESSION : constant := 8#0000#; -- zlib.h:145
|
| 85 |
+
-- zlib.h:145
|
| 86 |
+
Z_BEST_SPEED : constant := 1; -- zlib.h:146
|
| 87 |
+
-- zlib.h:146
|
| 88 |
+
Z_BEST_COMPRESSION : constant := 9; -- zlib.h:147
|
| 89 |
+
-- zlib.h:147
|
| 90 |
+
Z_DEFAULT_COMPRESSION : constant := -1; -- zlib.h:148
|
| 91 |
+
-- zlib.h:148
|
| 92 |
+
Z_FILTERED : constant := 1; -- zlib.h:151
|
| 93 |
+
-- zlib.h:151
|
| 94 |
+
Z_HUFFMAN_ONLY : constant := 2; -- zlib.h:152
|
| 95 |
+
-- zlib.h:152
|
| 96 |
+
Z_DEFAULT_STRATEGY : constant := 8#0000#; -- zlib.h:153
|
| 97 |
+
-- zlib.h:153
|
| 98 |
+
Z_BINARY : constant := 8#0000#; -- zlib.h:156
|
| 99 |
+
-- zlib.h:156
|
| 100 |
+
Z_ASCII : constant := 1; -- zlib.h:157
|
| 101 |
+
-- zlib.h:157
|
| 102 |
+
Z_UNKNOWN : constant := 2; -- zlib.h:158
|
| 103 |
+
-- zlib.h:158
|
| 104 |
+
Z_DEFLATED : constant := 8; -- zlib.h:161
|
| 105 |
+
-- zlib.h:161
|
| 106 |
+
Z_NULL : constant := 8#0000#; -- zlib.h:164
|
| 107 |
+
-- for initializing zalloc, zfree, opaque
|
| 108 |
+
-- zlib.h:164
|
| 109 |
+
type gzFile is new Voidp; -- zlib.h:646
|
| 110 |
+
|
| 111 |
+
type Z_Stream is private;
|
| 112 |
+
|
| 113 |
+
type Z_Streamp is access all Z_Stream; -- zlib.h:89
|
| 114 |
+
|
| 115 |
+
type alloc_func is access function
|
| 116 |
+
(Opaque : Voidp;
|
| 117 |
+
Items : UInt;
|
| 118 |
+
Size : UInt)
|
| 119 |
+
return Voidp; -- zlib.h:63
|
| 120 |
+
|
| 121 |
+
type free_func is access procedure (opaque : Voidp; address : Voidp);
|
| 122 |
+
|
| 123 |
+
function zlibVersion return Chars_Ptr;
|
| 124 |
+
|
| 125 |
+
function Deflate (strm : Z_Streamp; flush : Int) return Int;
|
| 126 |
+
|
| 127 |
+
function DeflateEnd (strm : Z_Streamp) return Int;
|
| 128 |
+
|
| 129 |
+
function Inflate (strm : Z_Streamp; flush : Int) return Int;
|
| 130 |
+
|
| 131 |
+
function InflateEnd (strm : Z_Streamp) return Int;
|
| 132 |
+
|
| 133 |
+
function deflateSetDictionary
|
| 134 |
+
(strm : Z_Streamp;
|
| 135 |
+
dictionary : Byte_Access;
|
| 136 |
+
dictLength : UInt)
|
| 137 |
+
return Int;
|
| 138 |
+
|
| 139 |
+
function deflateCopy (dest : Z_Streamp; source : Z_Streamp) return Int;
|
| 140 |
+
-- zlib.h:478
|
| 141 |
+
|
| 142 |
+
function deflateReset (strm : Z_Streamp) return Int; -- zlib.h:495
|
| 143 |
+
|
| 144 |
+
function deflateParams
|
| 145 |
+
(strm : Z_Streamp;
|
| 146 |
+
level : Int;
|
| 147 |
+
strategy : Int)
|
| 148 |
+
return Int; -- zlib.h:506
|
| 149 |
+
|
| 150 |
+
function inflateSetDictionary
|
| 151 |
+
(strm : Z_Streamp;
|
| 152 |
+
dictionary : Byte_Access;
|
| 153 |
+
dictLength : UInt)
|
| 154 |
+
return Int; -- zlib.h:548
|
| 155 |
+
|
| 156 |
+
function inflateSync (strm : Z_Streamp) return Int; -- zlib.h:565
|
| 157 |
+
|
| 158 |
+
function inflateReset (strm : Z_Streamp) return Int; -- zlib.h:580
|
| 159 |
+
|
| 160 |
+
function compress
|
| 161 |
+
(dest : Byte_Access;
|
| 162 |
+
destLen : ULong_Access;
|
| 163 |
+
source : Byte_Access;
|
| 164 |
+
sourceLen : ULong)
|
| 165 |
+
return Int; -- zlib.h:601
|
| 166 |
+
|
| 167 |
+
function compress2
|
| 168 |
+
(dest : Byte_Access;
|
| 169 |
+
destLen : ULong_Access;
|
| 170 |
+
source : Byte_Access;
|
| 171 |
+
sourceLen : ULong;
|
| 172 |
+
level : Int)
|
| 173 |
+
return Int; -- zlib.h:615
|
| 174 |
+
|
| 175 |
+
function uncompress
|
| 176 |
+
(dest : Byte_Access;
|
| 177 |
+
destLen : ULong_Access;
|
| 178 |
+
source : Byte_Access;
|
| 179 |
+
sourceLen : ULong)
|
| 180 |
+
return Int;
|
| 181 |
+
|
| 182 |
+
function gzopen (path : Chars_Ptr; mode : Chars_Ptr) return gzFile;
|
| 183 |
+
|
| 184 |
+
function gzdopen (fd : Int; mode : Chars_Ptr) return gzFile;
|
| 185 |
+
|
| 186 |
+
function gzsetparams
|
| 187 |
+
(file : gzFile;
|
| 188 |
+
level : Int;
|
| 189 |
+
strategy : Int)
|
| 190 |
+
return Int;
|
| 191 |
+
|
| 192 |
+
function gzread
|
| 193 |
+
(file : gzFile;
|
| 194 |
+
buf : Voidp;
|
| 195 |
+
len : UInt)
|
| 196 |
+
return Int;
|
| 197 |
+
|
| 198 |
+
function gzwrite
|
| 199 |
+
(file : in gzFile;
|
| 200 |
+
buf : in Voidp;
|
| 201 |
+
len : in UInt)
|
| 202 |
+
return Int;
|
| 203 |
+
|
| 204 |
+
function gzprintf (file : in gzFile; format : in Chars_Ptr) return Int;
|
| 205 |
+
|
| 206 |
+
function gzputs (file : in gzFile; s : in Chars_Ptr) return Int;
|
| 207 |
+
|
| 208 |
+
function gzgets
|
| 209 |
+
(file : gzFile;
|
| 210 |
+
buf : Chars_Ptr;
|
| 211 |
+
len : Int)
|
| 212 |
+
return Chars_Ptr;
|
| 213 |
+
|
| 214 |
+
function gzputc (file : gzFile; char : Int) return Int;
|
| 215 |
+
|
| 216 |
+
function gzgetc (file : gzFile) return Int;
|
| 217 |
+
|
| 218 |
+
function gzflush (file : gzFile; flush : Int) return Int;
|
| 219 |
+
|
| 220 |
+
function gzseek
|
| 221 |
+
(file : gzFile;
|
| 222 |
+
offset : Int;
|
| 223 |
+
whence : Int)
|
| 224 |
+
return Int;
|
| 225 |
+
|
| 226 |
+
function gzrewind (file : gzFile) return Int;
|
| 227 |
+
|
| 228 |
+
function gztell (file : gzFile) return Int;
|
| 229 |
+
|
| 230 |
+
function gzeof (file : gzFile) return Int;
|
| 231 |
+
|
| 232 |
+
function gzclose (file : gzFile) return Int;
|
| 233 |
+
|
| 234 |
+
function gzerror (file : gzFile; errnum : Int_Access) return Chars_Ptr;
|
| 235 |
+
|
| 236 |
+
function adler32
|
| 237 |
+
(adler : ULong;
|
| 238 |
+
buf : Byte_Access;
|
| 239 |
+
len : UInt)
|
| 240 |
+
return ULong;
|
| 241 |
+
|
| 242 |
+
function crc32
|
| 243 |
+
(crc : ULong;
|
| 244 |
+
buf : Byte_Access;
|
| 245 |
+
len : UInt)
|
| 246 |
+
return ULong;
|
| 247 |
+
|
| 248 |
+
function deflateInit
|
| 249 |
+
(strm : Z_Streamp;
|
| 250 |
+
level : Int;
|
| 251 |
+
version : Chars_Ptr;
|
| 252 |
+
stream_size : Int)
|
| 253 |
+
return Int;
|
| 254 |
+
|
| 255 |
+
function deflateInit2
|
| 256 |
+
(strm : Z_Streamp;
|
| 257 |
+
level : Int;
|
| 258 |
+
method : Int;
|
| 259 |
+
windowBits : Int;
|
| 260 |
+
memLevel : Int;
|
| 261 |
+
strategy : Int;
|
| 262 |
+
version : Chars_Ptr;
|
| 263 |
+
stream_size : Int)
|
| 264 |
+
return Int;
|
| 265 |
+
|
| 266 |
+
function Deflate_Init
|
| 267 |
+
(strm : Z_Streamp;
|
| 268 |
+
level : Int;
|
| 269 |
+
method : Int;
|
| 270 |
+
windowBits : Int;
|
| 271 |
+
memLevel : Int;
|
| 272 |
+
strategy : Int)
|
| 273 |
+
return Int;
|
| 274 |
+
pragma Inline (Deflate_Init);
|
| 275 |
+
|
| 276 |
+
function inflateInit
|
| 277 |
+
(strm : Z_Streamp;
|
| 278 |
+
version : Chars_Ptr;
|
| 279 |
+
stream_size : Int)
|
| 280 |
+
return Int;
|
| 281 |
+
|
| 282 |
+
function inflateInit2
|
| 283 |
+
(strm : in Z_Streamp;
|
| 284 |
+
windowBits : in Int;
|
| 285 |
+
version : in Chars_Ptr;
|
| 286 |
+
stream_size : in Int)
|
| 287 |
+
return Int;
|
| 288 |
+
|
| 289 |
+
function inflateBackInit
|
| 290 |
+
(strm : in Z_Streamp;
|
| 291 |
+
windowBits : in Int;
|
| 292 |
+
window : in Byte_Access;
|
| 293 |
+
version : in Chars_Ptr;
|
| 294 |
+
stream_size : in Int)
|
| 295 |
+
return Int;
|
| 296 |
+
-- Size of window have to be 2**windowBits.
|
| 297 |
+
|
| 298 |
+
function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int;
|
| 299 |
+
pragma Inline (Inflate_Init);
|
| 300 |
+
|
| 301 |
+
function zError (err : Int) return Chars_Ptr;
|
| 302 |
+
|
| 303 |
+
function inflateSyncPoint (z : Z_Streamp) return Int;
|
| 304 |
+
|
| 305 |
+
function get_crc_table return ULong_Access;
|
| 306 |
+
|
| 307 |
+
-- Interface to the available fields of the z_stream structure.
|
| 308 |
+
-- The application must update next_in and avail_in when avail_in has
|
| 309 |
+
-- dropped to zero. It must update next_out and avail_out when avail_out
|
| 310 |
+
-- has dropped to zero. The application must initialize zalloc, zfree and
|
| 311 |
+
-- opaque before calling the init function.
|
| 312 |
+
|
| 313 |
+
procedure Set_In
|
| 314 |
+
(Strm : in out Z_Stream;
|
| 315 |
+
Buffer : in Voidp;
|
| 316 |
+
Size : in UInt);
|
| 317 |
+
pragma Inline (Set_In);
|
| 318 |
+
|
| 319 |
+
procedure Set_Out
|
| 320 |
+
(Strm : in out Z_Stream;
|
| 321 |
+
Buffer : in Voidp;
|
| 322 |
+
Size : in UInt);
|
| 323 |
+
pragma Inline (Set_Out);
|
| 324 |
+
|
| 325 |
+
procedure Set_Mem_Func
|
| 326 |
+
(Strm : in out Z_Stream;
|
| 327 |
+
Opaque : in Voidp;
|
| 328 |
+
Alloc : in alloc_func;
|
| 329 |
+
Free : in free_func);
|
| 330 |
+
pragma Inline (Set_Mem_Func);
|
| 331 |
+
|
| 332 |
+
function Last_Error_Message (Strm : in Z_Stream) return String;
|
| 333 |
+
pragma Inline (Last_Error_Message);
|
| 334 |
+
|
| 335 |
+
function Avail_Out (Strm : in Z_Stream) return UInt;
|
| 336 |
+
pragma Inline (Avail_Out);
|
| 337 |
+
|
| 338 |
+
function Avail_In (Strm : in Z_Stream) return UInt;
|
| 339 |
+
pragma Inline (Avail_In);
|
| 340 |
+
|
| 341 |
+
function Total_In (Strm : in Z_Stream) return ULong;
|
| 342 |
+
pragma Inline (Total_In);
|
| 343 |
+
|
| 344 |
+
function Total_Out (Strm : in Z_Stream) return ULong;
|
| 345 |
+
pragma Inline (Total_Out);
|
| 346 |
+
|
| 347 |
+
function inflateCopy
|
| 348 |
+
(dest : in Z_Streamp;
|
| 349 |
+
Source : in Z_Streamp)
|
| 350 |
+
return Int;
|
| 351 |
+
|
| 352 |
+
function compressBound (Source_Len : in ULong) return ULong;
|
| 353 |
+
|
| 354 |
+
function deflateBound
|
| 355 |
+
(Strm : in Z_Streamp;
|
| 356 |
+
Source_Len : in ULong)
|
| 357 |
+
return ULong;
|
| 358 |
+
|
| 359 |
+
function gzungetc (C : in Int; File : in gzFile) return Int;
|
| 360 |
+
|
| 361 |
+
function zlibCompileFlags return ULong;
|
| 362 |
+
|
| 363 |
+
private
|
| 364 |
+
|
| 365 |
+
type Z_Stream is record -- zlib.h:68
|
| 366 |
+
Next_In : Voidp := Nul; -- next input byte
|
| 367 |
+
Avail_In : UInt := 0; -- number of bytes available at next_in
|
| 368 |
+
Total_In : ULong := 0; -- total nb of input bytes read so far
|
| 369 |
+
Next_Out : Voidp := Nul; -- next output byte should be put there
|
| 370 |
+
Avail_Out : UInt := 0; -- remaining free space at next_out
|
| 371 |
+
Total_Out : ULong := 0; -- total nb of bytes output so far
|
| 372 |
+
msg : Chars_Ptr; -- last error message, NULL if no error
|
| 373 |
+
state : Voidp; -- not visible by applications
|
| 374 |
+
zalloc : alloc_func := null; -- used to allocate the internal state
|
| 375 |
+
zfree : free_func := null; -- used to free the internal state
|
| 376 |
+
opaque : Voidp; -- private data object passed to
|
| 377 |
+
-- zalloc and zfree
|
| 378 |
+
data_type : Int; -- best guess about the data type:
|
| 379 |
+
-- ascii or binary
|
| 380 |
+
adler : ULong; -- adler32 value of the uncompressed
|
| 381 |
+
-- data
|
| 382 |
+
reserved : ULong; -- reserved for future use
|
| 383 |
+
end record;
|
| 384 |
+
|
| 385 |
+
pragma Convention (C, Z_Stream);
|
| 386 |
+
|
| 387 |
+
pragma Import (C, zlibVersion, "zlibVersion");
|
| 388 |
+
pragma Import (C, Deflate, "deflate");
|
| 389 |
+
pragma Import (C, DeflateEnd, "deflateEnd");
|
| 390 |
+
pragma Import (C, Inflate, "inflate");
|
| 391 |
+
pragma Import (C, InflateEnd, "inflateEnd");
|
| 392 |
+
pragma Import (C, deflateSetDictionary, "deflateSetDictionary");
|
| 393 |
+
pragma Import (C, deflateCopy, "deflateCopy");
|
| 394 |
+
pragma Import (C, deflateReset, "deflateReset");
|
| 395 |
+
pragma Import (C, deflateParams, "deflateParams");
|
| 396 |
+
pragma Import (C, inflateSetDictionary, "inflateSetDictionary");
|
| 397 |
+
pragma Import (C, inflateSync, "inflateSync");
|
| 398 |
+
pragma Import (C, inflateReset, "inflateReset");
|
| 399 |
+
pragma Import (C, compress, "compress");
|
| 400 |
+
pragma Import (C, compress2, "compress2");
|
| 401 |
+
pragma Import (C, uncompress, "uncompress");
|
| 402 |
+
pragma Import (C, gzopen, "gzopen");
|
| 403 |
+
pragma Import (C, gzdopen, "gzdopen");
|
| 404 |
+
pragma Import (C, gzsetparams, "gzsetparams");
|
| 405 |
+
pragma Import (C, gzread, "gzread");
|
| 406 |
+
pragma Import (C, gzwrite, "gzwrite");
|
| 407 |
+
pragma Import (C, gzprintf, "gzprintf");
|
| 408 |
+
pragma Import (C, gzputs, "gzputs");
|
| 409 |
+
pragma Import (C, gzgets, "gzgets");
|
| 410 |
+
pragma Import (C, gzputc, "gzputc");
|
| 411 |
+
pragma Import (C, gzgetc, "gzgetc");
|
| 412 |
+
pragma Import (C, gzflush, "gzflush");
|
| 413 |
+
pragma Import (C, gzseek, "gzseek");
|
| 414 |
+
pragma Import (C, gzrewind, "gzrewind");
|
| 415 |
+
pragma Import (C, gztell, "gztell");
|
| 416 |
+
pragma Import (C, gzeof, "gzeof");
|
| 417 |
+
pragma Import (C, gzclose, "gzclose");
|
| 418 |
+
pragma Import (C, gzerror, "gzerror");
|
| 419 |
+
pragma Import (C, adler32, "adler32");
|
| 420 |
+
pragma Import (C, crc32, "crc32");
|
| 421 |
+
pragma Import (C, deflateInit, "deflateInit_");
|
| 422 |
+
pragma Import (C, inflateInit, "inflateInit_");
|
| 423 |
+
pragma Import (C, deflateInit2, "deflateInit2_");
|
| 424 |
+
pragma Import (C, inflateInit2, "inflateInit2_");
|
| 425 |
+
pragma Import (C, zError, "zError");
|
| 426 |
+
pragma Import (C, inflateSyncPoint, "inflateSyncPoint");
|
| 427 |
+
pragma Import (C, get_crc_table, "get_crc_table");
|
| 428 |
+
|
| 429 |
+
-- since zlib 1.2.0:
|
| 430 |
+
|
| 431 |
+
pragma Import (C, inflateCopy, "inflateCopy");
|
| 432 |
+
pragma Import (C, compressBound, "compressBound");
|
| 433 |
+
pragma Import (C, deflateBound, "deflateBound");
|
| 434 |
+
pragma Import (C, gzungetc, "gzungetc");
|
| 435 |
+
pragma Import (C, zlibCompileFlags, "zlibCompileFlags");
|
| 436 |
+
|
| 437 |
+
pragma Import (C, inflateBackInit, "inflateBackInit_");
|
| 438 |
+
|
| 439 |
+
-- I stopped binding the inflateBack routines, because realize that
|
| 440 |
+
-- it does not support zlib and gzip headers for now, and have no
|
| 441 |
+
-- symmetric deflateBack routines.
|
| 442 |
+
-- ZLib-Ada is symmetric regarding deflate/inflate data transformation
|
| 443 |
+
-- and has a similar generic callback interface for the
|
| 444 |
+
-- deflate/inflate transformation based on the regular Deflate/Inflate
|
| 445 |
+
-- routines.
|
| 446 |
+
|
| 447 |
+
-- pragma Import (C, inflateBack, "inflateBack");
|
| 448 |
+
-- pragma Import (C, inflateBackEnd, "inflateBackEnd");
|
| 449 |
+
|
| 450 |
+
end ZLib.Thin;
|
contrib/ada/zlib.adb
ADDED
|
@@ -0,0 +1,701 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
----------------------------------------------------------------
|
| 2 |
+
-- ZLib for Ada thick binding. --
|
| 3 |
+
-- --
|
| 4 |
+
-- Copyright (C) 2002-2004 Dmitriy Anisimkov --
|
| 5 |
+
-- --
|
| 6 |
+
-- Open source license information is in the zlib.ads file. --
|
| 7 |
+
----------------------------------------------------------------
|
| 8 |
+
|
| 9 |
+
-- $Id: zlib.adb,v 1.31 2004/09/06 06:53:19 vagul Exp $
|
| 10 |
+
|
| 11 |
+
with Ada.Exceptions;
|
| 12 |
+
with Ada.Unchecked_Conversion;
|
| 13 |
+
with Ada.Unchecked_Deallocation;
|
| 14 |
+
|
| 15 |
+
with Interfaces.C.Strings;
|
| 16 |
+
|
| 17 |
+
with ZLib.Thin;
|
| 18 |
+
|
| 19 |
+
package body ZLib is
|
| 20 |
+
|
| 21 |
+
use type Thin.Int;
|
| 22 |
+
|
| 23 |
+
type Z_Stream is new Thin.Z_Stream;
|
| 24 |
+
|
| 25 |
+
type Return_Code_Enum is
|
| 26 |
+
(OK,
|
| 27 |
+
STREAM_END,
|
| 28 |
+
NEED_DICT,
|
| 29 |
+
ERRNO,
|
| 30 |
+
STREAM_ERROR,
|
| 31 |
+
DATA_ERROR,
|
| 32 |
+
MEM_ERROR,
|
| 33 |
+
BUF_ERROR,
|
| 34 |
+
VERSION_ERROR);
|
| 35 |
+
|
| 36 |
+
type Flate_Step_Function is access
|
| 37 |
+
function (Strm : in Thin.Z_Streamp; Flush : in Thin.Int) return Thin.Int;
|
| 38 |
+
pragma Convention (C, Flate_Step_Function);
|
| 39 |
+
|
| 40 |
+
type Flate_End_Function is access
|
| 41 |
+
function (Ctrm : in Thin.Z_Streamp) return Thin.Int;
|
| 42 |
+
pragma Convention (C, Flate_End_Function);
|
| 43 |
+
|
| 44 |
+
type Flate_Type is record
|
| 45 |
+
Step : Flate_Step_Function;
|
| 46 |
+
Done : Flate_End_Function;
|
| 47 |
+
end record;
|
| 48 |
+
|
| 49 |
+
subtype Footer_Array is Stream_Element_Array (1 .. 8);
|
| 50 |
+
|
| 51 |
+
Simple_GZip_Header : constant Stream_Element_Array (1 .. 10)
|
| 52 |
+
:= (16#1f#, 16#8b#, -- Magic header
|
| 53 |
+
16#08#, -- Z_DEFLATED
|
| 54 |
+
16#00#, -- Flags
|
| 55 |
+
16#00#, 16#00#, 16#00#, 16#00#, -- Time
|
| 56 |
+
16#00#, -- XFlags
|
| 57 |
+
16#03# -- OS code
|
| 58 |
+
);
|
| 59 |
+
-- The simplest gzip header is not for informational, but just for
|
| 60 |
+
-- gzip format compatibility.
|
| 61 |
+
-- Note that some code below is using assumption
|
| 62 |
+
-- Simple_GZip_Header'Last > Footer_Array'Last, so do not make
|
| 63 |
+
-- Simple_GZip_Header'Last <= Footer_Array'Last.
|
| 64 |
+
|
| 65 |
+
Return_Code : constant array (Thin.Int range <>) of Return_Code_Enum
|
| 66 |
+
:= (0 => OK,
|
| 67 |
+
1 => STREAM_END,
|
| 68 |
+
2 => NEED_DICT,
|
| 69 |
+
-1 => ERRNO,
|
| 70 |
+
-2 => STREAM_ERROR,
|
| 71 |
+
-3 => DATA_ERROR,
|
| 72 |
+
-4 => MEM_ERROR,
|
| 73 |
+
-5 => BUF_ERROR,
|
| 74 |
+
-6 => VERSION_ERROR);
|
| 75 |
+
|
| 76 |
+
Flate : constant array (Boolean) of Flate_Type
|
| 77 |
+
:= (True => (Step => Thin.Deflate'Access,
|
| 78 |
+
Done => Thin.DeflateEnd'Access),
|
| 79 |
+
False => (Step => Thin.Inflate'Access,
|
| 80 |
+
Done => Thin.InflateEnd'Access));
|
| 81 |
+
|
| 82 |
+
Flush_Finish : constant array (Boolean) of Flush_Mode
|
| 83 |
+
:= (True => Finish, False => No_Flush);
|
| 84 |
+
|
| 85 |
+
procedure Raise_Error (Stream : in Z_Stream);
|
| 86 |
+
pragma Inline (Raise_Error);
|
| 87 |
+
|
| 88 |
+
procedure Raise_Error (Message : in String);
|
| 89 |
+
pragma Inline (Raise_Error);
|
| 90 |
+
|
| 91 |
+
procedure Check_Error (Stream : in Z_Stream; Code : in Thin.Int);
|
| 92 |
+
|
| 93 |
+
procedure Free is new Ada.Unchecked_Deallocation
|
| 94 |
+
(Z_Stream, Z_Stream_Access);
|
| 95 |
+
|
| 96 |
+
function To_Thin_Access is new Ada.Unchecked_Conversion
|
| 97 |
+
(Z_Stream_Access, Thin.Z_Streamp);
|
| 98 |
+
|
| 99 |
+
procedure Translate_GZip
|
| 100 |
+
(Filter : in out Filter_Type;
|
| 101 |
+
In_Data : in Ada.Streams.Stream_Element_Array;
|
| 102 |
+
In_Last : out Ada.Streams.Stream_Element_Offset;
|
| 103 |
+
Out_Data : out Ada.Streams.Stream_Element_Array;
|
| 104 |
+
Out_Last : out Ada.Streams.Stream_Element_Offset;
|
| 105 |
+
Flush : in Flush_Mode);
|
| 106 |
+
-- Separate translate routine for make gzip header.
|
| 107 |
+
|
| 108 |
+
procedure Translate_Auto
|
| 109 |
+
(Filter : in out Filter_Type;
|
| 110 |
+
In_Data : in Ada.Streams.Stream_Element_Array;
|
| 111 |
+
In_Last : out Ada.Streams.Stream_Element_Offset;
|
| 112 |
+
Out_Data : out Ada.Streams.Stream_Element_Array;
|
| 113 |
+
Out_Last : out Ada.Streams.Stream_Element_Offset;
|
| 114 |
+
Flush : in Flush_Mode);
|
| 115 |
+
-- translate routine without additional headers.
|
| 116 |
+
|
| 117 |
+
-----------------
|
| 118 |
+
-- Check_Error --
|
| 119 |
+
-----------------
|
| 120 |
+
|
| 121 |
+
procedure Check_Error (Stream : in Z_Stream; Code : in Thin.Int) is
|
| 122 |
+
use type Thin.Int;
|
| 123 |
+
begin
|
| 124 |
+
if Code /= Thin.Z_OK then
|
| 125 |
+
Raise_Error
|
| 126 |
+
(Return_Code_Enum'Image (Return_Code (Code))
|
| 127 |
+
& ": " & Last_Error_Message (Stream));
|
| 128 |
+
end if;
|
| 129 |
+
end Check_Error;
|
| 130 |
+
|
| 131 |
+
-----------
|
| 132 |
+
-- Close --
|
| 133 |
+
-----------
|
| 134 |
+
|
| 135 |
+
procedure Close
|
| 136 |
+
(Filter : in out Filter_Type;
|
| 137 |
+
Ignore_Error : in Boolean := False)
|
| 138 |
+
is
|
| 139 |
+
Code : Thin.Int;
|
| 140 |
+
begin
|
| 141 |
+
if not Ignore_Error and then not Is_Open (Filter) then
|
| 142 |
+
raise Status_Error;
|
| 143 |
+
end if;
|
| 144 |
+
|
| 145 |
+
Code := Flate (Filter.Compression).Done (To_Thin_Access (Filter.Strm));
|
| 146 |
+
|
| 147 |
+
if Ignore_Error or else Code = Thin.Z_OK then
|
| 148 |
+
Free (Filter.Strm);
|
| 149 |
+
else
|
| 150 |
+
declare
|
| 151 |
+
Error_Message : constant String
|
| 152 |
+
:= Last_Error_Message (Filter.Strm.all);
|
| 153 |
+
begin
|
| 154 |
+
Free (Filter.Strm);
|
| 155 |
+
Ada.Exceptions.Raise_Exception
|
| 156 |
+
(ZLib_Error'Identity,
|
| 157 |
+
Return_Code_Enum'Image (Return_Code (Code))
|
| 158 |
+
& ": " & Error_Message);
|
| 159 |
+
end;
|
| 160 |
+
end if;
|
| 161 |
+
end Close;
|
| 162 |
+
|
| 163 |
+
-----------
|
| 164 |
+
-- CRC32 --
|
| 165 |
+
-----------
|
| 166 |
+
|
| 167 |
+
function CRC32
|
| 168 |
+
(CRC : in Unsigned_32;
|
| 169 |
+
Data : in Ada.Streams.Stream_Element_Array)
|
| 170 |
+
return Unsigned_32
|
| 171 |
+
is
|
| 172 |
+
use Thin;
|
| 173 |
+
begin
|
| 174 |
+
return Unsigned_32 (crc32 (ULong (CRC),
|
| 175 |
+
Data'Address,
|
| 176 |
+
Data'Length));
|
| 177 |
+
end CRC32;
|
| 178 |
+
|
| 179 |
+
procedure CRC32
|
| 180 |
+
(CRC : in out Unsigned_32;
|
| 181 |
+
Data : in Ada.Streams.Stream_Element_Array) is
|
| 182 |
+
begin
|
| 183 |
+
CRC := CRC32 (CRC, Data);
|
| 184 |
+
end CRC32;
|
| 185 |
+
|
| 186 |
+
------------------
|
| 187 |
+
-- Deflate_Init --
|
| 188 |
+
------------------
|
| 189 |
+
|
| 190 |
+
procedure Deflate_Init
|
| 191 |
+
(Filter : in out Filter_Type;
|
| 192 |
+
Level : in Compression_Level := Default_Compression;
|
| 193 |
+
Strategy : in Strategy_Type := Default_Strategy;
|
| 194 |
+
Method : in Compression_Method := Deflated;
|
| 195 |
+
Window_Bits : in Window_Bits_Type := Default_Window_Bits;
|
| 196 |
+
Memory_Level : in Memory_Level_Type := Default_Memory_Level;
|
| 197 |
+
Header : in Header_Type := Default)
|
| 198 |
+
is
|
| 199 |
+
use type Thin.Int;
|
| 200 |
+
Win_Bits : Thin.Int := Thin.Int (Window_Bits);
|
| 201 |
+
begin
|
| 202 |
+
if Is_Open (Filter) then
|
| 203 |
+
raise Status_Error;
|
| 204 |
+
end if;
|
| 205 |
+
|
| 206 |
+
-- We allow ZLib to make header only in case of default header type.
|
| 207 |
+
-- Otherwise we would either do header by ourselves, or do not do
|
| 208 |
+
-- header at all.
|
| 209 |
+
|
| 210 |
+
if Header = None or else Header = GZip then
|
| 211 |
+
Win_Bits := -Win_Bits;
|
| 212 |
+
end if;
|
| 213 |
+
|
| 214 |
+
-- For the GZip CRC calculation and make headers.
|
| 215 |
+
|
| 216 |
+
if Header = GZip then
|
| 217 |
+
Filter.CRC := 0;
|
| 218 |
+
Filter.Offset := Simple_GZip_Header'First;
|
| 219 |
+
else
|
| 220 |
+
Filter.Offset := Simple_GZip_Header'Last + 1;
|
| 221 |
+
end if;
|
| 222 |
+
|
| 223 |
+
Filter.Strm := new Z_Stream;
|
| 224 |
+
Filter.Compression := True;
|
| 225 |
+
Filter.Stream_End := False;
|
| 226 |
+
Filter.Header := Header;
|
| 227 |
+
|
| 228 |
+
if Thin.Deflate_Init
|
| 229 |
+
(To_Thin_Access (Filter.Strm),
|
| 230 |
+
Level => Thin.Int (Level),
|
| 231 |
+
method => Thin.Int (Method),
|
| 232 |
+
windowBits => Win_Bits,
|
| 233 |
+
memLevel => Thin.Int (Memory_Level),
|
| 234 |
+
strategy => Thin.Int (Strategy)) /= Thin.Z_OK
|
| 235 |
+
then
|
| 236 |
+
Raise_Error (Filter.Strm.all);
|
| 237 |
+
end if;
|
| 238 |
+
end Deflate_Init;
|
| 239 |
+
|
| 240 |
+
-----------
|
| 241 |
+
-- Flush --
|
| 242 |
+
-----------
|
| 243 |
+
|
| 244 |
+
procedure Flush
|
| 245 |
+
(Filter : in out Filter_Type;
|
| 246 |
+
Out_Data : out Ada.Streams.Stream_Element_Array;
|
| 247 |
+
Out_Last : out Ada.Streams.Stream_Element_Offset;
|
| 248 |
+
Flush : in Flush_Mode)
|
| 249 |
+
is
|
| 250 |
+
No_Data : Stream_Element_Array := (1 .. 0 => 0);
|
| 251 |
+
Last : Stream_Element_Offset;
|
| 252 |
+
begin
|
| 253 |
+
Translate (Filter, No_Data, Last, Out_Data, Out_Last, Flush);
|
| 254 |
+
end Flush;
|
| 255 |
+
|
| 256 |
+
-----------------------
|
| 257 |
+
-- Generic_Translate --
|
| 258 |
+
-----------------------
|
| 259 |
+
|
| 260 |
+
procedure Generic_Translate
|
| 261 |
+
(Filter : in out ZLib.Filter_Type;
|
| 262 |
+
In_Buffer_Size : in Integer := Default_Buffer_Size;
|
| 263 |
+
Out_Buffer_Size : in Integer := Default_Buffer_Size)
|
| 264 |
+
is
|
| 265 |
+
In_Buffer : Stream_Element_Array
|
| 266 |
+
(1 .. Stream_Element_Offset (In_Buffer_Size));
|
| 267 |
+
Out_Buffer : Stream_Element_Array
|
| 268 |
+
(1 .. Stream_Element_Offset (Out_Buffer_Size));
|
| 269 |
+
Last : Stream_Element_Offset;
|
| 270 |
+
In_Last : Stream_Element_Offset;
|
| 271 |
+
In_First : Stream_Element_Offset;
|
| 272 |
+
Out_Last : Stream_Element_Offset;
|
| 273 |
+
begin
|
| 274 |
+
Main : loop
|
| 275 |
+
Data_In (In_Buffer, Last);
|
| 276 |
+
|
| 277 |
+
In_First := In_Buffer'First;
|
| 278 |
+
|
| 279 |
+
loop
|
| 280 |
+
Translate
|
| 281 |
+
(Filter => Filter,
|
| 282 |
+
In_Data => In_Buffer (In_First .. Last),
|
| 283 |
+
In_Last => In_Last,
|
| 284 |
+
Out_Data => Out_Buffer,
|
| 285 |
+
Out_Last => Out_Last,
|
| 286 |
+
Flush => Flush_Finish (Last < In_Buffer'First));
|
| 287 |
+
|
| 288 |
+
if Out_Buffer'First <= Out_Last then
|
| 289 |
+
Data_Out (Out_Buffer (Out_Buffer'First .. Out_Last));
|
| 290 |
+
end if;
|
| 291 |
+
|
| 292 |
+
exit Main when Stream_End (Filter);
|
| 293 |
+
|
| 294 |
+
-- The end of in buffer.
|
| 295 |
+
|
| 296 |
+
exit when In_Last = Last;
|
| 297 |
+
|
| 298 |
+
In_First := In_Last + 1;
|
| 299 |
+
end loop;
|
| 300 |
+
end loop Main;
|
| 301 |
+
|
| 302 |
+
end Generic_Translate;
|
| 303 |
+
|
| 304 |
+
------------------
|
| 305 |
+
-- Inflate_Init --
|
| 306 |
+
------------------
|
| 307 |
+
|
| 308 |
+
procedure Inflate_Init
|
| 309 |
+
(Filter : in out Filter_Type;
|
| 310 |
+
Window_Bits : in Window_Bits_Type := Default_Window_Bits;
|
| 311 |
+
Header : in Header_Type := Default)
|
| 312 |
+
is
|
| 313 |
+
use type Thin.Int;
|
| 314 |
+
Win_Bits : Thin.Int := Thin.Int (Window_Bits);
|
| 315 |
+
|
| 316 |
+
procedure Check_Version;
|
| 317 |
+
-- Check the latest header types compatibility.
|
| 318 |
+
|
| 319 |
+
procedure Check_Version is
|
| 320 |
+
begin
|
| 321 |
+
if Version <= "1.1.4" then
|
| 322 |
+
Raise_Error
|
| 323 |
+
("Inflate header type " & Header_Type'Image (Header)
|
| 324 |
+
& " incompatible with ZLib version " & Version);
|
| 325 |
+
end if;
|
| 326 |
+
end Check_Version;
|
| 327 |
+
|
| 328 |
+
begin
|
| 329 |
+
if Is_Open (Filter) then
|
| 330 |
+
raise Status_Error;
|
| 331 |
+
end if;
|
| 332 |
+
|
| 333 |
+
case Header is
|
| 334 |
+
when None =>
|
| 335 |
+
Check_Version;
|
| 336 |
+
|
| 337 |
+
-- Inflate data without headers determined
|
| 338 |
+
-- by negative Win_Bits.
|
| 339 |
+
|
| 340 |
+
Win_Bits := -Win_Bits;
|
| 341 |
+
when GZip =>
|
| 342 |
+
Check_Version;
|
| 343 |
+
|
| 344 |
+
-- Inflate gzip data defined by flag 16.
|
| 345 |
+
|
| 346 |
+
Win_Bits := Win_Bits + 16;
|
| 347 |
+
when Auto =>
|
| 348 |
+
Check_Version;
|
| 349 |
+
|
| 350 |
+
-- Inflate with automatic detection
|
| 351 |
+
-- of gzip or native header defined by flag 32.
|
| 352 |
+
|
| 353 |
+
Win_Bits := Win_Bits + 32;
|
| 354 |
+
when Default => null;
|
| 355 |
+
end case;
|
| 356 |
+
|
| 357 |
+
Filter.Strm := new Z_Stream;
|
| 358 |
+
Filter.Compression := False;
|
| 359 |
+
Filter.Stream_End := False;
|
| 360 |
+
Filter.Header := Header;
|
| 361 |
+
|
| 362 |
+
if Thin.Inflate_Init
|
| 363 |
+
(To_Thin_Access (Filter.Strm), Win_Bits) /= Thin.Z_OK
|
| 364 |
+
then
|
| 365 |
+
Raise_Error (Filter.Strm.all);
|
| 366 |
+
end if;
|
| 367 |
+
end Inflate_Init;
|
| 368 |
+
|
| 369 |
+
-------------
|
| 370 |
+
-- Is_Open --
|
| 371 |
+
-------------
|
| 372 |
+
|
| 373 |
+
function Is_Open (Filter : in Filter_Type) return Boolean is
|
| 374 |
+
begin
|
| 375 |
+
return Filter.Strm /= null;
|
| 376 |
+
end Is_Open;
|
| 377 |
+
|
| 378 |
+
-----------------
|
| 379 |
+
-- Raise_Error --
|
| 380 |
+
-----------------
|
| 381 |
+
|
| 382 |
+
procedure Raise_Error (Message : in String) is
|
| 383 |
+
begin
|
| 384 |
+
Ada.Exceptions.Raise_Exception (ZLib_Error'Identity, Message);
|
| 385 |
+
end Raise_Error;
|
| 386 |
+
|
| 387 |
+
procedure Raise_Error (Stream : in Z_Stream) is
|
| 388 |
+
begin
|
| 389 |
+
Raise_Error (Last_Error_Message (Stream));
|
| 390 |
+
end Raise_Error;
|
| 391 |
+
|
| 392 |
+
----------
|
| 393 |
+
-- Read --
|
| 394 |
+
----------
|
| 395 |
+
|
| 396 |
+
procedure Read
|
| 397 |
+
(Filter : in out Filter_Type;
|
| 398 |
+
Item : out Ada.Streams.Stream_Element_Array;
|
| 399 |
+
Last : out Ada.Streams.Stream_Element_Offset;
|
| 400 |
+
Flush : in Flush_Mode := No_Flush)
|
| 401 |
+
is
|
| 402 |
+
In_Last : Stream_Element_Offset;
|
| 403 |
+
Item_First : Ada.Streams.Stream_Element_Offset := Item'First;
|
| 404 |
+
V_Flush : Flush_Mode := Flush;
|
| 405 |
+
|
| 406 |
+
begin
|
| 407 |
+
pragma Assert (Rest_First in Buffer'First .. Buffer'Last + 1);
|
| 408 |
+
pragma Assert (Rest_Last in Buffer'First - 1 .. Buffer'Last);
|
| 409 |
+
|
| 410 |
+
loop
|
| 411 |
+
if Rest_Last = Buffer'First - 1 then
|
| 412 |
+
V_Flush := Finish;
|
| 413 |
+
|
| 414 |
+
elsif Rest_First > Rest_Last then
|
| 415 |
+
Read (Buffer, Rest_Last);
|
| 416 |
+
Rest_First := Buffer'First;
|
| 417 |
+
|
| 418 |
+
if Rest_Last < Buffer'First then
|
| 419 |
+
V_Flush := Finish;
|
| 420 |
+
end if;
|
| 421 |
+
end if;
|
| 422 |
+
|
| 423 |
+
Translate
|
| 424 |
+
(Filter => Filter,
|
| 425 |
+
In_Data => Buffer (Rest_First .. Rest_Last),
|
| 426 |
+
In_Last => In_Last,
|
| 427 |
+
Out_Data => Item (Item_First .. Item'Last),
|
| 428 |
+
Out_Last => Last,
|
| 429 |
+
Flush => V_Flush);
|
| 430 |
+
|
| 431 |
+
Rest_First := In_Last + 1;
|
| 432 |
+
|
| 433 |
+
exit when Stream_End (Filter)
|
| 434 |
+
or else Last = Item'Last
|
| 435 |
+
or else (Last >= Item'First and then Allow_Read_Some);
|
| 436 |
+
|
| 437 |
+
Item_First := Last + 1;
|
| 438 |
+
end loop;
|
| 439 |
+
end Read;
|
| 440 |
+
|
| 441 |
+
----------------
|
| 442 |
+
-- Stream_End --
|
| 443 |
+
----------------
|
| 444 |
+
|
| 445 |
+
function Stream_End (Filter : in Filter_Type) return Boolean is
|
| 446 |
+
begin
|
| 447 |
+
if Filter.Header = GZip and Filter.Compression then
|
| 448 |
+
return Filter.Stream_End
|
| 449 |
+
and then Filter.Offset = Footer_Array'Last + 1;
|
| 450 |
+
else
|
| 451 |
+
return Filter.Stream_End;
|
| 452 |
+
end if;
|
| 453 |
+
end Stream_End;
|
| 454 |
+
|
| 455 |
+
--------------
|
| 456 |
+
-- Total_In --
|
| 457 |
+
--------------
|
| 458 |
+
|
| 459 |
+
function Total_In (Filter : in Filter_Type) return Count is
|
| 460 |
+
begin
|
| 461 |
+
return Count (Thin.Total_In (To_Thin_Access (Filter.Strm).all));
|
| 462 |
+
end Total_In;
|
| 463 |
+
|
| 464 |
+
---------------
|
| 465 |
+
-- Total_Out --
|
| 466 |
+
---------------
|
| 467 |
+
|
| 468 |
+
function Total_Out (Filter : in Filter_Type) return Count is
|
| 469 |
+
begin
|
| 470 |
+
return Count (Thin.Total_Out (To_Thin_Access (Filter.Strm).all));
|
| 471 |
+
end Total_Out;
|
| 472 |
+
|
| 473 |
+
---------------
|
| 474 |
+
-- Translate --
|
| 475 |
+
---------------
|
| 476 |
+
|
| 477 |
+
procedure Translate
|
| 478 |
+
(Filter : in out Filter_Type;
|
| 479 |
+
In_Data : in Ada.Streams.Stream_Element_Array;
|
| 480 |
+
In_Last : out Ada.Streams.Stream_Element_Offset;
|
| 481 |
+
Out_Data : out Ada.Streams.Stream_Element_Array;
|
| 482 |
+
Out_Last : out Ada.Streams.Stream_Element_Offset;
|
| 483 |
+
Flush : in Flush_Mode) is
|
| 484 |
+
begin
|
| 485 |
+
if Filter.Header = GZip and then Filter.Compression then
|
| 486 |
+
Translate_GZip
|
| 487 |
+
(Filter => Filter,
|
| 488 |
+
In_Data => In_Data,
|
| 489 |
+
In_Last => In_Last,
|
| 490 |
+
Out_Data => Out_Data,
|
| 491 |
+
Out_Last => Out_Last,
|
| 492 |
+
Flush => Flush);
|
| 493 |
+
else
|
| 494 |
+
Translate_Auto
|
| 495 |
+
(Filter => Filter,
|
| 496 |
+
In_Data => In_Data,
|
| 497 |
+
In_Last => In_Last,
|
| 498 |
+
Out_Data => Out_Data,
|
| 499 |
+
Out_Last => Out_Last,
|
| 500 |
+
Flush => Flush);
|
| 501 |
+
end if;
|
| 502 |
+
end Translate;
|
| 503 |
+
|
| 504 |
+
--------------------
|
| 505 |
+
-- Translate_Auto --
|
| 506 |
+
--------------------
|
| 507 |
+
|
| 508 |
+
procedure Translate_Auto
|
| 509 |
+
(Filter : in out Filter_Type;
|
| 510 |
+
In_Data : in Ada.Streams.Stream_Element_Array;
|
| 511 |
+
In_Last : out Ada.Streams.Stream_Element_Offset;
|
| 512 |
+
Out_Data : out Ada.Streams.Stream_Element_Array;
|
| 513 |
+
Out_Last : out Ada.Streams.Stream_Element_Offset;
|
| 514 |
+
Flush : in Flush_Mode)
|
| 515 |
+
is
|
| 516 |
+
use type Thin.Int;
|
| 517 |
+
Code : Thin.Int;
|
| 518 |
+
|
| 519 |
+
begin
|
| 520 |
+
if not Is_Open (Filter) then
|
| 521 |
+
raise Status_Error;
|
| 522 |
+
end if;
|
| 523 |
+
|
| 524 |
+
if Out_Data'Length = 0 and then In_Data'Length = 0 then
|
| 525 |
+
raise Constraint_Error;
|
| 526 |
+
end if;
|
| 527 |
+
|
| 528 |
+
Set_Out (Filter.Strm.all, Out_Data'Address, Out_Data'Length);
|
| 529 |
+
Set_In (Filter.Strm.all, In_Data'Address, In_Data'Length);
|
| 530 |
+
|
| 531 |
+
Code := Flate (Filter.Compression).Step
|
| 532 |
+
(To_Thin_Access (Filter.Strm),
|
| 533 |
+
Thin.Int (Flush));
|
| 534 |
+
|
| 535 |
+
if Code = Thin.Z_STREAM_END then
|
| 536 |
+
Filter.Stream_End := True;
|
| 537 |
+
else
|
| 538 |
+
Check_Error (Filter.Strm.all, Code);
|
| 539 |
+
end if;
|
| 540 |
+
|
| 541 |
+
In_Last := In_Data'Last
|
| 542 |
+
- Stream_Element_Offset (Avail_In (Filter.Strm.all));
|
| 543 |
+
Out_Last := Out_Data'Last
|
| 544 |
+
- Stream_Element_Offset (Avail_Out (Filter.Strm.all));
|
| 545 |
+
end Translate_Auto;
|
| 546 |
+
|
| 547 |
+
--------------------
|
| 548 |
+
-- Translate_GZip --
|
| 549 |
+
--------------------
|
| 550 |
+
|
| 551 |
+
procedure Translate_GZip
|
| 552 |
+
(Filter : in out Filter_Type;
|
| 553 |
+
In_Data : in Ada.Streams.Stream_Element_Array;
|
| 554 |
+
In_Last : out Ada.Streams.Stream_Element_Offset;
|
| 555 |
+
Out_Data : out Ada.Streams.Stream_Element_Array;
|
| 556 |
+
Out_Last : out Ada.Streams.Stream_Element_Offset;
|
| 557 |
+
Flush : in Flush_Mode)
|
| 558 |
+
is
|
| 559 |
+
Out_First : Stream_Element_Offset;
|
| 560 |
+
|
| 561 |
+
procedure Add_Data (Data : in Stream_Element_Array);
|
| 562 |
+
-- Add data to stream from the Filter.Offset till necessary,
|
| 563 |
+
-- used for add gzip headr/footer.
|
| 564 |
+
|
| 565 |
+
procedure Put_32
|
| 566 |
+
(Item : in out Stream_Element_Array;
|
| 567 |
+
Data : in Unsigned_32);
|
| 568 |
+
pragma Inline (Put_32);
|
| 569 |
+
|
| 570 |
+
--------------
|
| 571 |
+
-- Add_Data --
|
| 572 |
+
--------------
|
| 573 |
+
|
| 574 |
+
procedure Add_Data (Data : in Stream_Element_Array) is
|
| 575 |
+
Data_First : Stream_Element_Offset renames Filter.Offset;
|
| 576 |
+
Data_Last : Stream_Element_Offset;
|
| 577 |
+
Data_Len : Stream_Element_Offset; -- -1
|
| 578 |
+
Out_Len : Stream_Element_Offset; -- -1
|
| 579 |
+
begin
|
| 580 |
+
Out_First := Out_Last + 1;
|
| 581 |
+
|
| 582 |
+
if Data_First > Data'Last then
|
| 583 |
+
return;
|
| 584 |
+
end if;
|
| 585 |
+
|
| 586 |
+
Data_Len := Data'Last - Data_First;
|
| 587 |
+
Out_Len := Out_Data'Last - Out_First;
|
| 588 |
+
|
| 589 |
+
if Data_Len <= Out_Len then
|
| 590 |
+
Out_Last := Out_First + Data_Len;
|
| 591 |
+
Data_Last := Data'Last;
|
| 592 |
+
else
|
| 593 |
+
Out_Last := Out_Data'Last;
|
| 594 |
+
Data_Last := Data_First + Out_Len;
|
| 595 |
+
end if;
|
| 596 |
+
|
| 597 |
+
Out_Data (Out_First .. Out_Last) := Data (Data_First .. Data_Last);
|
| 598 |
+
|
| 599 |
+
Data_First := Data_Last + 1;
|
| 600 |
+
Out_First := Out_Last + 1;
|
| 601 |
+
end Add_Data;
|
| 602 |
+
|
| 603 |
+
------------
|
| 604 |
+
-- Put_32 --
|
| 605 |
+
------------
|
| 606 |
+
|
| 607 |
+
procedure Put_32
|
| 608 |
+
(Item : in out Stream_Element_Array;
|
| 609 |
+
Data : in Unsigned_32)
|
| 610 |
+
is
|
| 611 |
+
D : Unsigned_32 := Data;
|
| 612 |
+
begin
|
| 613 |
+
for J in Item'First .. Item'First + 3 loop
|
| 614 |
+
Item (J) := Stream_Element (D and 16#FF#);
|
| 615 |
+
D := Shift_Right (D, 8);
|
| 616 |
+
end loop;
|
| 617 |
+
end Put_32;
|
| 618 |
+
|
| 619 |
+
begin
|
| 620 |
+
Out_Last := Out_Data'First - 1;
|
| 621 |
+
|
| 622 |
+
if not Filter.Stream_End then
|
| 623 |
+
Add_Data (Simple_GZip_Header);
|
| 624 |
+
|
| 625 |
+
Translate_Auto
|
| 626 |
+
(Filter => Filter,
|
| 627 |
+
In_Data => In_Data,
|
| 628 |
+
In_Last => In_Last,
|
| 629 |
+
Out_Data => Out_Data (Out_First .. Out_Data'Last),
|
| 630 |
+
Out_Last => Out_Last,
|
| 631 |
+
Flush => Flush);
|
| 632 |
+
|
| 633 |
+
CRC32 (Filter.CRC, In_Data (In_Data'First .. In_Last));
|
| 634 |
+
end if;
|
| 635 |
+
|
| 636 |
+
if Filter.Stream_End and then Out_Last <= Out_Data'Last then
|
| 637 |
+
-- This detection method would work only when
|
| 638 |
+
-- Simple_GZip_Header'Last > Footer_Array'Last
|
| 639 |
+
|
| 640 |
+
if Filter.Offset = Simple_GZip_Header'Last + 1 then
|
| 641 |
+
Filter.Offset := Footer_Array'First;
|
| 642 |
+
end if;
|
| 643 |
+
|
| 644 |
+
declare
|
| 645 |
+
Footer : Footer_Array;
|
| 646 |
+
begin
|
| 647 |
+
Put_32 (Footer, Filter.CRC);
|
| 648 |
+
Put_32 (Footer (Footer'First + 4 .. Footer'Last),
|
| 649 |
+
Unsigned_32 (Total_In (Filter)));
|
| 650 |
+
Add_Data (Footer);
|
| 651 |
+
end;
|
| 652 |
+
end if;
|
| 653 |
+
end Translate_GZip;
|
| 654 |
+
|
| 655 |
+
-------------
|
| 656 |
+
-- Version --
|
| 657 |
+
-------------
|
| 658 |
+
|
| 659 |
+
function Version return String is
|
| 660 |
+
begin
|
| 661 |
+
return Interfaces.C.Strings.Value (Thin.zlibVersion);
|
| 662 |
+
end Version;
|
| 663 |
+
|
| 664 |
+
-----------
|
| 665 |
+
-- Write --
|
| 666 |
+
-----------
|
| 667 |
+
|
| 668 |
+
procedure Write
|
| 669 |
+
(Filter : in out Filter_Type;
|
| 670 |
+
Item : in Ada.Streams.Stream_Element_Array;
|
| 671 |
+
Flush : in Flush_Mode := No_Flush)
|
| 672 |
+
is
|
| 673 |
+
Buffer : Stream_Element_Array (1 .. Buffer_Size);
|
| 674 |
+
In_Last : Stream_Element_Offset;
|
| 675 |
+
Out_Last : Stream_Element_Offset;
|
| 676 |
+
In_First : Stream_Element_Offset := Item'First;
|
| 677 |
+
begin
|
| 678 |
+
if Item'Length = 0 and Flush = No_Flush then
|
| 679 |
+
return;
|
| 680 |
+
end if;
|
| 681 |
+
|
| 682 |
+
loop
|
| 683 |
+
Translate
|
| 684 |
+
(Filter => Filter,
|
| 685 |
+
In_Data => Item (In_First .. Item'Last),
|
| 686 |
+
In_Last => In_Last,
|
| 687 |
+
Out_Data => Buffer,
|
| 688 |
+
Out_Last => Out_Last,
|
| 689 |
+
Flush => Flush);
|
| 690 |
+
|
| 691 |
+
if Out_Last >= Buffer'First then
|
| 692 |
+
Write (Buffer (1 .. Out_Last));
|
| 693 |
+
end if;
|
| 694 |
+
|
| 695 |
+
exit when In_Last = Item'Last or Stream_End (Filter);
|
| 696 |
+
|
| 697 |
+
In_First := In_Last + 1;
|
| 698 |
+
end loop;
|
| 699 |
+
end Write;
|
| 700 |
+
|
| 701 |
+
end ZLib;
|
contrib/ada/zlib.ads
ADDED
|
@@ -0,0 +1,328 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
------------------------------------------------------------------------------
|
| 2 |
+
-- ZLib for Ada thick binding. --
|
| 3 |
+
-- --
|
| 4 |
+
-- Copyright (C) 2002-2004 Dmitriy Anisimkov --
|
| 5 |
+
-- --
|
| 6 |
+
-- This library is free software; you can redistribute it and/or modify --
|
| 7 |
+
-- it under the terms of the GNU General Public License as published by --
|
| 8 |
+
-- the Free Software Foundation; either version 2 of the License, or (at --
|
| 9 |
+
-- your option) any later version. --
|
| 10 |
+
-- --
|
| 11 |
+
-- This library is distributed in the hope that it will be useful, but --
|
| 12 |
+
-- WITHOUT ANY WARRANTY; without even the implied warranty of --
|
| 13 |
+
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
|
| 14 |
+
-- General Public License for more details. --
|
| 15 |
+
-- --
|
| 16 |
+
-- You should have received a copy of the GNU General Public License --
|
| 17 |
+
-- along with this library; if not, write to the Free Software Foundation, --
|
| 18 |
+
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
|
| 19 |
+
-- --
|
| 20 |
+
-- As a special exception, if other files instantiate generics from this --
|
| 21 |
+
-- unit, or you link this unit with other files to produce an executable, --
|
| 22 |
+
-- this unit does not by itself cause the resulting executable to be --
|
| 23 |
+
-- covered by the GNU General Public License. This exception does not --
|
| 24 |
+
-- however invalidate any other reasons why the executable file might be --
|
| 25 |
+
-- covered by the GNU Public License. --
|
| 26 |
+
------------------------------------------------------------------------------
|
| 27 |
+
|
| 28 |
+
-- $Id: zlib.ads,v 1.26 2004/09/06 06:53:19 vagul Exp $
|
| 29 |
+
|
| 30 |
+
with Ada.Streams;
|
| 31 |
+
|
| 32 |
+
with Interfaces;
|
| 33 |
+
|
| 34 |
+
package ZLib is
|
| 35 |
+
|
| 36 |
+
ZLib_Error : exception;
|
| 37 |
+
Status_Error : exception;
|
| 38 |
+
|
| 39 |
+
type Compression_Level is new Integer range -1 .. 9;
|
| 40 |
+
|
| 41 |
+
type Flush_Mode is private;
|
| 42 |
+
|
| 43 |
+
type Compression_Method is private;
|
| 44 |
+
|
| 45 |
+
type Window_Bits_Type is new Integer range 8 .. 15;
|
| 46 |
+
|
| 47 |
+
type Memory_Level_Type is new Integer range 1 .. 9;
|
| 48 |
+
|
| 49 |
+
type Unsigned_32 is new Interfaces.Unsigned_32;
|
| 50 |
+
|
| 51 |
+
type Strategy_Type is private;
|
| 52 |
+
|
| 53 |
+
type Header_Type is (None, Auto, Default, GZip);
|
| 54 |
+
-- Header type usage have a some limitation for inflate.
|
| 55 |
+
-- See comment for Inflate_Init.
|
| 56 |
+
|
| 57 |
+
subtype Count is Ada.Streams.Stream_Element_Count;
|
| 58 |
+
|
| 59 |
+
Default_Memory_Level : constant Memory_Level_Type := 8;
|
| 60 |
+
Default_Window_Bits : constant Window_Bits_Type := 15;
|
| 61 |
+
|
| 62 |
+
----------------------------------
|
| 63 |
+
-- Compression method constants --
|
| 64 |
+
----------------------------------
|
| 65 |
+
|
| 66 |
+
Deflated : constant Compression_Method;
|
| 67 |
+
-- Only one method allowed in this ZLib version
|
| 68 |
+
|
| 69 |
+
---------------------------------
|
| 70 |
+
-- Compression level constants --
|
| 71 |
+
---------------------------------
|
| 72 |
+
|
| 73 |
+
No_Compression : constant Compression_Level := 0;
|
| 74 |
+
Best_Speed : constant Compression_Level := 1;
|
| 75 |
+
Best_Compression : constant Compression_Level := 9;
|
| 76 |
+
Default_Compression : constant Compression_Level := -1;
|
| 77 |
+
|
| 78 |
+
--------------------------
|
| 79 |
+
-- Flush mode constants --
|
| 80 |
+
--------------------------
|
| 81 |
+
|
| 82 |
+
No_Flush : constant Flush_Mode;
|
| 83 |
+
-- Regular way for compression, no flush
|
| 84 |
+
|
| 85 |
+
Partial_Flush : constant Flush_Mode;
|
| 86 |
+
-- Will be removed, use Z_SYNC_FLUSH instead
|
| 87 |
+
|
| 88 |
+
Sync_Flush : constant Flush_Mode;
|
| 89 |
+
-- All pending output is flushed to the output buffer and the output
|
| 90 |
+
-- is aligned on a byte boundary, so that the decompressor can get all
|
| 91 |
+
-- input data available so far. (In particular avail_in is zero after the
|
| 92 |
+
-- call if enough output space has been provided before the call.)
|
| 93 |
+
-- Flushing may degrade compression for some compression algorithms and so
|
| 94 |
+
-- it should be used only when necessary.
|
| 95 |
+
|
| 96 |
+
Block_Flush : constant Flush_Mode;
|
| 97 |
+
-- Z_BLOCK requests that inflate() stop
|
| 98 |
+
-- if and when it get to the next deflate block boundary. When decoding the
|
| 99 |
+
-- zlib or gzip format, this will cause inflate() to return immediately
|
| 100 |
+
-- after the header and before the first block. When doing a raw inflate,
|
| 101 |
+
-- inflate() will go ahead and process the first block, and will return
|
| 102 |
+
-- when it gets to the end of that block, or when it runs out of data.
|
| 103 |
+
|
| 104 |
+
Full_Flush : constant Flush_Mode;
|
| 105 |
+
-- All output is flushed as with SYNC_FLUSH, and the compression state
|
| 106 |
+
-- is reset so that decompression can restart from this point if previous
|
| 107 |
+
-- compressed data has been damaged or if random access is desired. Using
|
| 108 |
+
-- Full_Flush too often can seriously degrade the compression.
|
| 109 |
+
|
| 110 |
+
Finish : constant Flush_Mode;
|
| 111 |
+
-- Just for tell the compressor that input data is complete.
|
| 112 |
+
|
| 113 |
+
------------------------------------
|
| 114 |
+
-- Compression strategy constants --
|
| 115 |
+
------------------------------------
|
| 116 |
+
|
| 117 |
+
-- RLE strategy could be used only in version 1.2.0 and later.
|
| 118 |
+
|
| 119 |
+
Filtered : constant Strategy_Type;
|
| 120 |
+
Huffman_Only : constant Strategy_Type;
|
| 121 |
+
RLE : constant Strategy_Type;
|
| 122 |
+
Default_Strategy : constant Strategy_Type;
|
| 123 |
+
|
| 124 |
+
Default_Buffer_Size : constant := 4096;
|
| 125 |
+
|
| 126 |
+
type Filter_Type is tagged limited private;
|
| 127 |
+
-- The filter is for compression and for decompression.
|
| 128 |
+
-- The usage of the type is depend of its initialization.
|
| 129 |
+
|
| 130 |
+
function Version return String;
|
| 131 |
+
pragma Inline (Version);
|
| 132 |
+
-- Return string representation of the ZLib version.
|
| 133 |
+
|
| 134 |
+
procedure Deflate_Init
|
| 135 |
+
(Filter : in out Filter_Type;
|
| 136 |
+
Level : in Compression_Level := Default_Compression;
|
| 137 |
+
Strategy : in Strategy_Type := Default_Strategy;
|
| 138 |
+
Method : in Compression_Method := Deflated;
|
| 139 |
+
Window_Bits : in Window_Bits_Type := Default_Window_Bits;
|
| 140 |
+
Memory_Level : in Memory_Level_Type := Default_Memory_Level;
|
| 141 |
+
Header : in Header_Type := Default);
|
| 142 |
+
-- Compressor initialization.
|
| 143 |
+
-- When Header parameter is Auto or Default, then default zlib header
|
| 144 |
+
-- would be provided for compressed data.
|
| 145 |
+
-- When Header is GZip, then gzip header would be set instead of
|
| 146 |
+
-- default header.
|
| 147 |
+
-- When Header is None, no header would be set for compressed data.
|
| 148 |
+
|
| 149 |
+
procedure Inflate_Init
|
| 150 |
+
(Filter : in out Filter_Type;
|
| 151 |
+
Window_Bits : in Window_Bits_Type := Default_Window_Bits;
|
| 152 |
+
Header : in Header_Type := Default);
|
| 153 |
+
-- Decompressor initialization.
|
| 154 |
+
-- Default header type mean that ZLib default header is expecting in the
|
| 155 |
+
-- input compressed stream.
|
| 156 |
+
-- Header type None mean that no header is expecting in the input stream.
|
| 157 |
+
-- GZip header type mean that GZip header is expecting in the
|
| 158 |
+
-- input compressed stream.
|
| 159 |
+
-- Auto header type mean that header type (GZip or Native) would be
|
| 160 |
+
-- detected automatically in the input stream.
|
| 161 |
+
-- Note that header types parameter values None, GZip and Auto are
|
| 162 |
+
-- supported for inflate routine only in ZLib versions 1.2.0.2 and later.
|
| 163 |
+
-- Deflate_Init is supporting all header types.
|
| 164 |
+
|
| 165 |
+
function Is_Open (Filter : in Filter_Type) return Boolean;
|
| 166 |
+
pragma Inline (Is_Open);
|
| 167 |
+
-- Is the filter opened for compression or decompression.
|
| 168 |
+
|
| 169 |
+
procedure Close
|
| 170 |
+
(Filter : in out Filter_Type;
|
| 171 |
+
Ignore_Error : in Boolean := False);
|
| 172 |
+
-- Closing the compression or decompressor.
|
| 173 |
+
-- If stream is closing before the complete and Ignore_Error is False,
|
| 174 |
+
-- The exception would be raised.
|
| 175 |
+
|
| 176 |
+
generic
|
| 177 |
+
with procedure Data_In
|
| 178 |
+
(Item : out Ada.Streams.Stream_Element_Array;
|
| 179 |
+
Last : out Ada.Streams.Stream_Element_Offset);
|
| 180 |
+
with procedure Data_Out
|
| 181 |
+
(Item : in Ada.Streams.Stream_Element_Array);
|
| 182 |
+
procedure Generic_Translate
|
| 183 |
+
(Filter : in out Filter_Type;
|
| 184 |
+
In_Buffer_Size : in Integer := Default_Buffer_Size;
|
| 185 |
+
Out_Buffer_Size : in Integer := Default_Buffer_Size);
|
| 186 |
+
-- Compress/decompress data fetch from Data_In routine and pass the result
|
| 187 |
+
-- to the Data_Out routine. User should provide Data_In and Data_Out
|
| 188 |
+
-- for compression/decompression data flow.
|
| 189 |
+
-- Compression or decompression depend on Filter initialization.
|
| 190 |
+
|
| 191 |
+
function Total_In (Filter : in Filter_Type) return Count;
|
| 192 |
+
pragma Inline (Total_In);
|
| 193 |
+
-- Returns total number of input bytes read so far
|
| 194 |
+
|
| 195 |
+
function Total_Out (Filter : in Filter_Type) return Count;
|
| 196 |
+
pragma Inline (Total_Out);
|
| 197 |
+
-- Returns total number of bytes output so far
|
| 198 |
+
|
| 199 |
+
function CRC32
|
| 200 |
+
(CRC : in Unsigned_32;
|
| 201 |
+
Data : in Ada.Streams.Stream_Element_Array)
|
| 202 |
+
return Unsigned_32;
|
| 203 |
+
pragma Inline (CRC32);
|
| 204 |
+
-- Compute CRC32, it could be necessary for make gzip format
|
| 205 |
+
|
| 206 |
+
procedure CRC32
|
| 207 |
+
(CRC : in out Unsigned_32;
|
| 208 |
+
Data : in Ada.Streams.Stream_Element_Array);
|
| 209 |
+
pragma Inline (CRC32);
|
| 210 |
+
-- Compute CRC32, it could be necessary for make gzip format
|
| 211 |
+
|
| 212 |
+
-------------------------------------------------
|
| 213 |
+
-- Below is more complex low level routines. --
|
| 214 |
+
-------------------------------------------------
|
| 215 |
+
|
| 216 |
+
procedure Translate
|
| 217 |
+
(Filter : in out Filter_Type;
|
| 218 |
+
In_Data : in Ada.Streams.Stream_Element_Array;
|
| 219 |
+
In_Last : out Ada.Streams.Stream_Element_Offset;
|
| 220 |
+
Out_Data : out Ada.Streams.Stream_Element_Array;
|
| 221 |
+
Out_Last : out Ada.Streams.Stream_Element_Offset;
|
| 222 |
+
Flush : in Flush_Mode);
|
| 223 |
+
-- Compress/decompress the In_Data buffer and place the result into
|
| 224 |
+
-- Out_Data. In_Last is the index of last element from In_Data accepted by
|
| 225 |
+
-- the Filter. Out_Last is the last element of the received data from
|
| 226 |
+
-- Filter. To tell the filter that incoming data are complete put the
|
| 227 |
+
-- Flush parameter to Finish.
|
| 228 |
+
|
| 229 |
+
function Stream_End (Filter : in Filter_Type) return Boolean;
|
| 230 |
+
pragma Inline (Stream_End);
|
| 231 |
+
-- Return the true when the stream is complete.
|
| 232 |
+
|
| 233 |
+
procedure Flush
|
| 234 |
+
(Filter : in out Filter_Type;
|
| 235 |
+
Out_Data : out Ada.Streams.Stream_Element_Array;
|
| 236 |
+
Out_Last : out Ada.Streams.Stream_Element_Offset;
|
| 237 |
+
Flush : in Flush_Mode);
|
| 238 |
+
pragma Inline (Flush);
|
| 239 |
+
-- Flushing the data from the compressor.
|
| 240 |
+
|
| 241 |
+
generic
|
| 242 |
+
with procedure Write
|
| 243 |
+
(Item : in Ada.Streams.Stream_Element_Array);
|
| 244 |
+
-- User should provide this routine for accept
|
| 245 |
+
-- compressed/decompressed data.
|
| 246 |
+
|
| 247 |
+
Buffer_Size : in Ada.Streams.Stream_Element_Offset
|
| 248 |
+
:= Default_Buffer_Size;
|
| 249 |
+
-- Buffer size for Write user routine.
|
| 250 |
+
|
| 251 |
+
procedure Write
|
| 252 |
+
(Filter : in out Filter_Type;
|
| 253 |
+
Item : in Ada.Streams.Stream_Element_Array;
|
| 254 |
+
Flush : in Flush_Mode := No_Flush);
|
| 255 |
+
-- Compress/Decompress data from Item to the generic parameter procedure
|
| 256 |
+
-- Write. Output buffer size could be set in Buffer_Size generic parameter.
|
| 257 |
+
|
| 258 |
+
generic
|
| 259 |
+
with procedure Read
|
| 260 |
+
(Item : out Ada.Streams.Stream_Element_Array;
|
| 261 |
+
Last : out Ada.Streams.Stream_Element_Offset);
|
| 262 |
+
-- User should provide data for compression/decompression
|
| 263 |
+
-- thru this routine.
|
| 264 |
+
|
| 265 |
+
Buffer : in out Ada.Streams.Stream_Element_Array;
|
| 266 |
+
-- Buffer for keep remaining data from the previous
|
| 267 |
+
-- back read.
|
| 268 |
+
|
| 269 |
+
Rest_First, Rest_Last : in out Ada.Streams.Stream_Element_Offset;
|
| 270 |
+
-- Rest_First have to be initialized to Buffer'Last + 1
|
| 271 |
+
-- Rest_Last have to be initialized to Buffer'Last
|
| 272 |
+
-- before usage.
|
| 273 |
+
|
| 274 |
+
Allow_Read_Some : in Boolean := False;
|
| 275 |
+
-- Is it allowed to return Last < Item'Last before end of data.
|
| 276 |
+
|
| 277 |
+
procedure Read
|
| 278 |
+
(Filter : in out Filter_Type;
|
| 279 |
+
Item : out Ada.Streams.Stream_Element_Array;
|
| 280 |
+
Last : out Ada.Streams.Stream_Element_Offset;
|
| 281 |
+
Flush : in Flush_Mode := No_Flush);
|
| 282 |
+
-- Compress/Decompress data from generic parameter procedure Read to the
|
| 283 |
+
-- Item. User should provide Buffer and initialized Rest_First, Rest_Last
|
| 284 |
+
-- indicators. If Allow_Read_Some is True, Read routines could return
|
| 285 |
+
-- Last < Item'Last only at end of stream.
|
| 286 |
+
|
| 287 |
+
private
|
| 288 |
+
|
| 289 |
+
use Ada.Streams;
|
| 290 |
+
|
| 291 |
+
pragma Assert (Ada.Streams.Stream_Element'Size = 8);
|
| 292 |
+
pragma Assert (Ada.Streams.Stream_Element'Modulus = 2**8);
|
| 293 |
+
|
| 294 |
+
type Flush_Mode is new Integer range 0 .. 5;
|
| 295 |
+
|
| 296 |
+
type Compression_Method is new Integer range 8 .. 8;
|
| 297 |
+
|
| 298 |
+
type Strategy_Type is new Integer range 0 .. 3;
|
| 299 |
+
|
| 300 |
+
No_Flush : constant Flush_Mode := 0;
|
| 301 |
+
Partial_Flush : constant Flush_Mode := 1;
|
| 302 |
+
Sync_Flush : constant Flush_Mode := 2;
|
| 303 |
+
Full_Flush : constant Flush_Mode := 3;
|
| 304 |
+
Finish : constant Flush_Mode := 4;
|
| 305 |
+
Block_Flush : constant Flush_Mode := 5;
|
| 306 |
+
|
| 307 |
+
Filtered : constant Strategy_Type := 1;
|
| 308 |
+
Huffman_Only : constant Strategy_Type := 2;
|
| 309 |
+
RLE : constant Strategy_Type := 3;
|
| 310 |
+
Default_Strategy : constant Strategy_Type := 0;
|
| 311 |
+
|
| 312 |
+
Deflated : constant Compression_Method := 8;
|
| 313 |
+
|
| 314 |
+
type Z_Stream;
|
| 315 |
+
|
| 316 |
+
type Z_Stream_Access is access all Z_Stream;
|
| 317 |
+
|
| 318 |
+
type Filter_Type is tagged limited record
|
| 319 |
+
Strm : Z_Stream_Access;
|
| 320 |
+
Compression : Boolean;
|
| 321 |
+
Stream_End : Boolean;
|
| 322 |
+
Header : Header_Type;
|
| 323 |
+
CRC : Unsigned_32;
|
| 324 |
+
Offset : Stream_Element_Offset;
|
| 325 |
+
-- Offset for gzip header/footer output.
|
| 326 |
+
end record;
|
| 327 |
+
|
| 328 |
+
end ZLib;
|
contrib/ada/zlib.gpr
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
project Zlib is
|
| 2 |
+
|
| 3 |
+
for Languages use ("Ada");
|
| 4 |
+
for Source_Dirs use (".");
|
| 5 |
+
for Object_Dir use ".";
|
| 6 |
+
for Main use ("test.adb", "mtest.adb", "read.adb", "buffer_demo");
|
| 7 |
+
|
| 8 |
+
package Compiler is
|
| 9 |
+
for Default_Switches ("ada") use ("-gnatwcfilopru", "-gnatVcdfimorst", "-gnatyabcefhiklmnoprst");
|
| 10 |
+
end Compiler;
|
| 11 |
+
|
| 12 |
+
package Linker is
|
| 13 |
+
for Default_Switches ("ada") use ("-lz");
|
| 14 |
+
end Linker;
|
| 15 |
+
|
| 16 |
+
package Builder is
|
| 17 |
+
for Default_Switches ("ada") use ("-s", "-gnatQ");
|
| 18 |
+
end Builder;
|
| 19 |
+
|
| 20 |
+
end Zlib;
|
contrib/blast/Makefile
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
blast: blast.c blast.h
|
| 2 |
+
cc -DTEST -o blast blast.c
|
| 3 |
+
|
| 4 |
+
test: blast
|
| 5 |
+
blast < test.pk | cmp - test.txt
|
| 6 |
+
|
| 7 |
+
clean:
|
| 8 |
+
rm -f blast blast.o
|
contrib/blast/README
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Read blast.h for purpose and usage.
|
| 2 |
+
|
| 3 |
+
Mark Adler
|
| 4 |
+
madler@alumni.caltech.edu
|
contrib/blast/blast.c
ADDED
|
@@ -0,0 +1,466 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* blast.c
|
| 2 |
+
* Copyright (C) 2003, 2012, 2013 Mark Adler
|
| 3 |
+
* For conditions of distribution and use, see copyright notice in blast.h
|
| 4 |
+
* version 1.3, 24 Aug 2013
|
| 5 |
+
*
|
| 6 |
+
* blast.c decompresses data compressed by the PKWare Compression Library.
|
| 7 |
+
* This function provides functionality similar to the explode() function of
|
| 8 |
+
* the PKWare library, hence the name "blast".
|
| 9 |
+
*
|
| 10 |
+
* This decompressor is based on the excellent format description provided by
|
| 11 |
+
* Ben Rudiak-Gould in comp.compression on August 13, 2001. Interestingly, the
|
| 12 |
+
* example Ben provided in the post is incorrect. The distance 110001 should
|
| 13 |
+
* instead be 111000. When corrected, the example byte stream becomes:
|
| 14 |
+
*
|
| 15 |
+
* 00 04 82 24 25 8f 80 7f
|
| 16 |
+
*
|
| 17 |
+
* which decompresses to "AIAIAIAIAIAIA" (without the quotes).
|
| 18 |
+
*/
|
| 19 |
+
|
| 20 |
+
/*
|
| 21 |
+
* Change history:
|
| 22 |
+
*
|
| 23 |
+
* 1.0 12 Feb 2003 - First version
|
| 24 |
+
* 1.1 16 Feb 2003 - Fixed distance check for > 4 GB uncompressed data
|
| 25 |
+
* 1.2 24 Oct 2012 - Add note about using binary mode in stdio
|
| 26 |
+
* - Fix comparisons of differently signed integers
|
| 27 |
+
* 1.3 24 Aug 2013 - Return unused input from blast()
|
| 28 |
+
* - Fix test code to correctly report unused input
|
| 29 |
+
* - Enable the provision of initial input to blast()
|
| 30 |
+
*/
|
| 31 |
+
|
| 32 |
+
#include <stddef.h> /* for NULL */
|
| 33 |
+
#include <setjmp.h> /* for setjmp(), longjmp(), and jmp_buf */
|
| 34 |
+
#include "blast.h" /* prototype for blast() */
|
| 35 |
+
|
| 36 |
+
#define local static /* for local function definitions */
|
| 37 |
+
#define MAXBITS 13 /* maximum code length */
|
| 38 |
+
#define MAXWIN 4096 /* maximum window size */
|
| 39 |
+
|
| 40 |
+
/* input and output state */
|
| 41 |
+
struct state {
|
| 42 |
+
/* input state */
|
| 43 |
+
blast_in infun; /* input function provided by user */
|
| 44 |
+
void *inhow; /* opaque information passed to infun() */
|
| 45 |
+
unsigned char *in; /* next input location */
|
| 46 |
+
unsigned left; /* available input at in */
|
| 47 |
+
int bitbuf; /* bit buffer */
|
| 48 |
+
int bitcnt; /* number of bits in bit buffer */
|
| 49 |
+
|
| 50 |
+
/* input limit error return state for bits() and decode() */
|
| 51 |
+
jmp_buf env;
|
| 52 |
+
|
| 53 |
+
/* output state */
|
| 54 |
+
blast_out outfun; /* output function provided by user */
|
| 55 |
+
void *outhow; /* opaque information passed to outfun() */
|
| 56 |
+
unsigned next; /* index of next write location in out[] */
|
| 57 |
+
int first; /* true to check distances (for first 4K) */
|
| 58 |
+
unsigned char out[MAXWIN]; /* output buffer and sliding window */
|
| 59 |
+
};
|
| 60 |
+
|
| 61 |
+
/*
|
| 62 |
+
* Return need bits from the input stream. This always leaves less than
|
| 63 |
+
* eight bits in the buffer. bits() works properly for need == 0.
|
| 64 |
+
*
|
| 65 |
+
* Format notes:
|
| 66 |
+
*
|
| 67 |
+
* - Bits are stored in bytes from the least significant bit to the most
|
| 68 |
+
* significant bit. Therefore bits are dropped from the bottom of the bit
|
| 69 |
+
* buffer, using shift right, and new bytes are appended to the top of the
|
| 70 |
+
* bit buffer, using shift left.
|
| 71 |
+
*/
|
| 72 |
+
local int bits(struct state *s, int need)
|
| 73 |
+
{
|
| 74 |
+
int val; /* bit accumulator */
|
| 75 |
+
|
| 76 |
+
/* load at least need bits into val */
|
| 77 |
+
val = s->bitbuf;
|
| 78 |
+
while (s->bitcnt < need) {
|
| 79 |
+
if (s->left == 0) {
|
| 80 |
+
s->left = s->infun(s->inhow, &(s->in));
|
| 81 |
+
if (s->left == 0) longjmp(s->env, 1); /* out of input */
|
| 82 |
+
}
|
| 83 |
+
val |= (int)(*(s->in)++) << s->bitcnt; /* load eight bits */
|
| 84 |
+
s->left--;
|
| 85 |
+
s->bitcnt += 8;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
/* drop need bits and update buffer, always zero to seven bits left */
|
| 89 |
+
s->bitbuf = val >> need;
|
| 90 |
+
s->bitcnt -= need;
|
| 91 |
+
|
| 92 |
+
/* return need bits, zeroing the bits above that */
|
| 93 |
+
return val & ((1 << need) - 1);
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
/*
|
| 97 |
+
* Huffman code decoding tables. count[1..MAXBITS] is the number of symbols of
|
| 98 |
+
* each length, which for a canonical code are stepped through in order.
|
| 99 |
+
* symbol[] are the symbol values in canonical order, where the number of
|
| 100 |
+
* entries is the sum of the counts in count[]. The decoding process can be
|
| 101 |
+
* seen in the function decode() below.
|
| 102 |
+
*/
|
| 103 |
+
struct huffman {
|
| 104 |
+
short *count; /* number of symbols of each length */
|
| 105 |
+
short *symbol; /* canonically ordered symbols */
|
| 106 |
+
};
|
| 107 |
+
|
| 108 |
+
/*
|
| 109 |
+
* Decode a code from the stream s using huffman table h. Return the symbol or
|
| 110 |
+
* a negative value if there is an error. If all of the lengths are zero, i.e.
|
| 111 |
+
* an empty code, or if the code is incomplete and an invalid code is received,
|
| 112 |
+
* then -9 is returned after reading MAXBITS bits.
|
| 113 |
+
*
|
| 114 |
+
* Format notes:
|
| 115 |
+
*
|
| 116 |
+
* - The codes as stored in the compressed data are bit-reversed relative to
|
| 117 |
+
* a simple integer ordering of codes of the same lengths. Hence below the
|
| 118 |
+
* bits are pulled from the compressed data one at a time and used to
|
| 119 |
+
* build the code value reversed from what is in the stream in order to
|
| 120 |
+
* permit simple integer comparisons for decoding.
|
| 121 |
+
*
|
| 122 |
+
* - The first code for the shortest length is all ones. Subsequent codes of
|
| 123 |
+
* the same length are simply integer decrements of the previous code. When
|
| 124 |
+
* moving up a length, a one bit is appended to the code. For a complete
|
| 125 |
+
* code, the last code of the longest length will be all zeros. To support
|
| 126 |
+
* this ordering, the bits pulled during decoding are inverted to apply the
|
| 127 |
+
* more "natural" ordering starting with all zeros and incrementing.
|
| 128 |
+
*/
|
| 129 |
+
local int decode(struct state *s, struct huffman *h)
|
| 130 |
+
{
|
| 131 |
+
int len; /* current number of bits in code */
|
| 132 |
+
int code; /* len bits being decoded */
|
| 133 |
+
int first; /* first code of length len */
|
| 134 |
+
int count; /* number of codes of length len */
|
| 135 |
+
int index; /* index of first code of length len in symbol table */
|
| 136 |
+
int bitbuf; /* bits from stream */
|
| 137 |
+
int left; /* bits left in next or left to process */
|
| 138 |
+
short *next; /* next number of codes */
|
| 139 |
+
|
| 140 |
+
bitbuf = s->bitbuf;
|
| 141 |
+
left = s->bitcnt;
|
| 142 |
+
code = first = index = 0;
|
| 143 |
+
len = 1;
|
| 144 |
+
next = h->count + 1;
|
| 145 |
+
while (1) {
|
| 146 |
+
while (left--) {
|
| 147 |
+
code |= (bitbuf & 1) ^ 1; /* invert code */
|
| 148 |
+
bitbuf >>= 1;
|
| 149 |
+
count = *next++;
|
| 150 |
+
if (code < first + count) { /* if length len, return symbol */
|
| 151 |
+
s->bitbuf = bitbuf;
|
| 152 |
+
s->bitcnt = (s->bitcnt - len) & 7;
|
| 153 |
+
return h->symbol[index + (code - first)];
|
| 154 |
+
}
|
| 155 |
+
index += count; /* else update for next length */
|
| 156 |
+
first += count;
|
| 157 |
+
first <<= 1;
|
| 158 |
+
code <<= 1;
|
| 159 |
+
len++;
|
| 160 |
+
}
|
| 161 |
+
left = (MAXBITS+1) - len;
|
| 162 |
+
if (left == 0) break;
|
| 163 |
+
if (s->left == 0) {
|
| 164 |
+
s->left = s->infun(s->inhow, &(s->in));
|
| 165 |
+
if (s->left == 0) longjmp(s->env, 1); /* out of input */
|
| 166 |
+
}
|
| 167 |
+
bitbuf = *(s->in)++;
|
| 168 |
+
s->left--;
|
| 169 |
+
if (left > 8) left = 8;
|
| 170 |
+
}
|
| 171 |
+
return -9; /* ran out of codes */
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
/*
|
| 175 |
+
* Given a list of repeated code lengths rep[0..n-1], where each byte is a
|
| 176 |
+
* count (high four bits + 1) and a code length (low four bits), generate the
|
| 177 |
+
* list of code lengths. This compaction reduces the size of the object code.
|
| 178 |
+
* Then given the list of code lengths length[0..n-1] representing a canonical
|
| 179 |
+
* Huffman code for n symbols, construct the tables required to decode those
|
| 180 |
+
* codes. Those tables are the number of codes of each length, and the symbols
|
| 181 |
+
* sorted by length, retaining their original order within each length. The
|
| 182 |
+
* return value is zero for a complete code set, negative for an over-
|
| 183 |
+
* subscribed code set, and positive for an incomplete code set. The tables
|
| 184 |
+
* can be used if the return value is zero or positive, but they cannot be used
|
| 185 |
+
* if the return value is negative. If the return value is zero, it is not
|
| 186 |
+
* possible for decode() using that table to return an error--any stream of
|
| 187 |
+
* enough bits will resolve to a symbol. If the return value is positive, then
|
| 188 |
+
* it is possible for decode() using that table to return an error for received
|
| 189 |
+
* codes past the end of the incomplete lengths.
|
| 190 |
+
*/
|
| 191 |
+
local int construct(struct huffman *h, const unsigned char *rep, int n)
|
| 192 |
+
{
|
| 193 |
+
int symbol; /* current symbol when stepping through length[] */
|
| 194 |
+
int len; /* current length when stepping through h->count[] */
|
| 195 |
+
int left; /* number of possible codes left of current length */
|
| 196 |
+
short offs[MAXBITS+1]; /* offsets in symbol table for each length */
|
| 197 |
+
short length[256]; /* code lengths */
|
| 198 |
+
|
| 199 |
+
/* convert compact repeat counts into symbol bit length list */
|
| 200 |
+
symbol = 0;
|
| 201 |
+
do {
|
| 202 |
+
len = *rep++;
|
| 203 |
+
left = (len >> 4) + 1;
|
| 204 |
+
len &= 15;
|
| 205 |
+
do {
|
| 206 |
+
length[symbol++] = len;
|
| 207 |
+
} while (--left);
|
| 208 |
+
} while (--n);
|
| 209 |
+
n = symbol;
|
| 210 |
+
|
| 211 |
+
/* count number of codes of each length */
|
| 212 |
+
for (len = 0; len <= MAXBITS; len++)
|
| 213 |
+
h->count[len] = 0;
|
| 214 |
+
for (symbol = 0; symbol < n; symbol++)
|
| 215 |
+
(h->count[length[symbol]])++; /* assumes lengths are within bounds */
|
| 216 |
+
if (h->count[0] == n) /* no codes! */
|
| 217 |
+
return 0; /* complete, but decode() will fail */
|
| 218 |
+
|
| 219 |
+
/* check for an over-subscribed or incomplete set of lengths */
|
| 220 |
+
left = 1; /* one possible code of zero length */
|
| 221 |
+
for (len = 1; len <= MAXBITS; len++) {
|
| 222 |
+
left <<= 1; /* one more bit, double codes left */
|
| 223 |
+
left -= h->count[len]; /* deduct count from possible codes */
|
| 224 |
+
if (left < 0) return left; /* over-subscribed--return negative */
|
| 225 |
+
} /* left > 0 means incomplete */
|
| 226 |
+
|
| 227 |
+
/* generate offsets into symbol table for each length for sorting */
|
| 228 |
+
offs[1] = 0;
|
| 229 |
+
for (len = 1; len < MAXBITS; len++)
|
| 230 |
+
offs[len + 1] = offs[len] + h->count[len];
|
| 231 |
+
|
| 232 |
+
/*
|
| 233 |
+
* put symbols in table sorted by length, by symbol order within each
|
| 234 |
+
* length
|
| 235 |
+
*/
|
| 236 |
+
for (symbol = 0; symbol < n; symbol++)
|
| 237 |
+
if (length[symbol] != 0)
|
| 238 |
+
h->symbol[offs[length[symbol]]++] = symbol;
|
| 239 |
+
|
| 240 |
+
/* return zero for complete set, positive for incomplete set */
|
| 241 |
+
return left;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
/*
|
| 245 |
+
* Decode PKWare Compression Library stream.
|
| 246 |
+
*
|
| 247 |
+
* Format notes:
|
| 248 |
+
*
|
| 249 |
+
* - First byte is 0 if literals are uncoded or 1 if they are coded. Second
|
| 250 |
+
* byte is 4, 5, or 6 for the number of extra bits in the distance code.
|
| 251 |
+
* This is the base-2 logarithm of the dictionary size minus six.
|
| 252 |
+
*
|
| 253 |
+
* - Compressed data is a combination of literals and length/distance pairs
|
| 254 |
+
* terminated by an end code. Literals are either Huffman coded or
|
| 255 |
+
* uncoded bytes. A length/distance pair is a coded length followed by a
|
| 256 |
+
* coded distance to represent a string that occurs earlier in the
|
| 257 |
+
* uncompressed data that occurs again at the current location.
|
| 258 |
+
*
|
| 259 |
+
* - A bit preceding a literal or length/distance pair indicates which comes
|
| 260 |
+
* next, 0 for literals, 1 for length/distance.
|
| 261 |
+
*
|
| 262 |
+
* - If literals are uncoded, then the next eight bits are the literal, in the
|
| 263 |
+
* normal bit order in the stream, i.e. no bit-reversal is needed. Similarly,
|
| 264 |
+
* no bit reversal is needed for either the length extra bits or the distance
|
| 265 |
+
* extra bits.
|
| 266 |
+
*
|
| 267 |
+
* - Literal bytes are simply written to the output. A length/distance pair is
|
| 268 |
+
* an instruction to copy previously uncompressed bytes to the output. The
|
| 269 |
+
* copy is from distance bytes back in the output stream, copying for length
|
| 270 |
+
* bytes.
|
| 271 |
+
*
|
| 272 |
+
* - Distances pointing before the beginning of the output data are not
|
| 273 |
+
* permitted.
|
| 274 |
+
*
|
| 275 |
+
* - Overlapped copies, where the length is greater than the distance, are
|
| 276 |
+
* allowed and common. For example, a distance of one and a length of 518
|
| 277 |
+
* simply copies the last byte 518 times. A distance of four and a length of
|
| 278 |
+
* twelve copies the last four bytes three times. A simple forward copy
|
| 279 |
+
* ignoring whether the length is greater than the distance or not implements
|
| 280 |
+
* this correctly.
|
| 281 |
+
*/
|
| 282 |
+
local int decomp(struct state *s)
|
| 283 |
+
{
|
| 284 |
+
int lit; /* true if literals are coded */
|
| 285 |
+
int dict; /* log2(dictionary size) - 6 */
|
| 286 |
+
int symbol; /* decoded symbol, extra bits for distance */
|
| 287 |
+
int len; /* length for copy */
|
| 288 |
+
unsigned dist; /* distance for copy */
|
| 289 |
+
int copy; /* copy counter */
|
| 290 |
+
unsigned char *from, *to; /* copy pointers */
|
| 291 |
+
static int virgin = 1; /* build tables once */
|
| 292 |
+
static short litcnt[MAXBITS+1], litsym[256]; /* litcode memory */
|
| 293 |
+
static short lencnt[MAXBITS+1], lensym[16]; /* lencode memory */
|
| 294 |
+
static short distcnt[MAXBITS+1], distsym[64]; /* distcode memory */
|
| 295 |
+
static struct huffman litcode = {litcnt, litsym}; /* length code */
|
| 296 |
+
static struct huffman lencode = {lencnt, lensym}; /* length code */
|
| 297 |
+
static struct huffman distcode = {distcnt, distsym};/* distance code */
|
| 298 |
+
/* bit lengths of literal codes */
|
| 299 |
+
static const unsigned char litlen[] = {
|
| 300 |
+
11, 124, 8, 7, 28, 7, 188, 13, 76, 4, 10, 8, 12, 10, 12, 10, 8, 23, 8,
|
| 301 |
+
9, 7, 6, 7, 8, 7, 6, 55, 8, 23, 24, 12, 11, 7, 9, 11, 12, 6, 7, 22, 5,
|
| 302 |
+
7, 24, 6, 11, 9, 6, 7, 22, 7, 11, 38, 7, 9, 8, 25, 11, 8, 11, 9, 12,
|
| 303 |
+
8, 12, 5, 38, 5, 38, 5, 11, 7, 5, 6, 21, 6, 10, 53, 8, 7, 24, 10, 27,
|
| 304 |
+
44, 253, 253, 253, 252, 252, 252, 13, 12, 45, 12, 45, 12, 61, 12, 45,
|
| 305 |
+
44, 173};
|
| 306 |
+
/* bit lengths of length codes 0..15 */
|
| 307 |
+
static const unsigned char lenlen[] = {2, 35, 36, 53, 38, 23};
|
| 308 |
+
/* bit lengths of distance codes 0..63 */
|
| 309 |
+
static const unsigned char distlen[] = {2, 20, 53, 230, 247, 151, 248};
|
| 310 |
+
static const short base[16] = { /* base for length codes */
|
| 311 |
+
3, 2, 4, 5, 6, 7, 8, 9, 10, 12, 16, 24, 40, 72, 136, 264};
|
| 312 |
+
static const char extra[16] = { /* extra bits for length codes */
|
| 313 |
+
0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8};
|
| 314 |
+
|
| 315 |
+
/* set up decoding tables (once--might not be thread-safe) */
|
| 316 |
+
if (virgin) {
|
| 317 |
+
construct(&litcode, litlen, sizeof(litlen));
|
| 318 |
+
construct(&lencode, lenlen, sizeof(lenlen));
|
| 319 |
+
construct(&distcode, distlen, sizeof(distlen));
|
| 320 |
+
virgin = 0;
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
/* read header */
|
| 324 |
+
lit = bits(s, 8);
|
| 325 |
+
if (lit > 1) return -1;
|
| 326 |
+
dict = bits(s, 8);
|
| 327 |
+
if (dict < 4 || dict > 6) return -2;
|
| 328 |
+
|
| 329 |
+
/* decode literals and length/distance pairs */
|
| 330 |
+
do {
|
| 331 |
+
if (bits(s, 1)) {
|
| 332 |
+
/* get length */
|
| 333 |
+
symbol = decode(s, &lencode);
|
| 334 |
+
len = base[symbol] + bits(s, extra[symbol]);
|
| 335 |
+
if (len == 519) break; /* end code */
|
| 336 |
+
|
| 337 |
+
/* get distance */
|
| 338 |
+
symbol = len == 2 ? 2 : dict;
|
| 339 |
+
dist = decode(s, &distcode) << symbol;
|
| 340 |
+
dist += bits(s, symbol);
|
| 341 |
+
dist++;
|
| 342 |
+
if (s->first && dist > s->next)
|
| 343 |
+
return -3; /* distance too far back */
|
| 344 |
+
|
| 345 |
+
/* copy length bytes from distance bytes back */
|
| 346 |
+
do {
|
| 347 |
+
to = s->out + s->next;
|
| 348 |
+
from = to - dist;
|
| 349 |
+
copy = MAXWIN;
|
| 350 |
+
if (s->next < dist) {
|
| 351 |
+
from += copy;
|
| 352 |
+
copy = dist;
|
| 353 |
+
}
|
| 354 |
+
copy -= s->next;
|
| 355 |
+
if (copy > len) copy = len;
|
| 356 |
+
len -= copy;
|
| 357 |
+
s->next += copy;
|
| 358 |
+
do {
|
| 359 |
+
*to++ = *from++;
|
| 360 |
+
} while (--copy);
|
| 361 |
+
if (s->next == MAXWIN) {
|
| 362 |
+
if (s->outfun(s->outhow, s->out, s->next)) return 1;
|
| 363 |
+
s->next = 0;
|
| 364 |
+
s->first = 0;
|
| 365 |
+
}
|
| 366 |
+
} while (len != 0);
|
| 367 |
+
}
|
| 368 |
+
else {
|
| 369 |
+
/* get literal and write it */
|
| 370 |
+
symbol = lit ? decode(s, &litcode) : bits(s, 8);
|
| 371 |
+
s->out[s->next++] = symbol;
|
| 372 |
+
if (s->next == MAXWIN) {
|
| 373 |
+
if (s->outfun(s->outhow, s->out, s->next)) return 1;
|
| 374 |
+
s->next = 0;
|
| 375 |
+
s->first = 0;
|
| 376 |
+
}
|
| 377 |
+
}
|
| 378 |
+
} while (1);
|
| 379 |
+
return 0;
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
/* See comments in blast.h */
|
| 383 |
+
int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow,
|
| 384 |
+
unsigned *left, unsigned char **in)
|
| 385 |
+
{
|
| 386 |
+
struct state s; /* input/output state */
|
| 387 |
+
int err; /* return value */
|
| 388 |
+
|
| 389 |
+
/* initialize input state */
|
| 390 |
+
s.infun = infun;
|
| 391 |
+
s.inhow = inhow;
|
| 392 |
+
if (left != NULL && *left) {
|
| 393 |
+
s.left = *left;
|
| 394 |
+
s.in = *in;
|
| 395 |
+
}
|
| 396 |
+
else
|
| 397 |
+
s.left = 0;
|
| 398 |
+
s.bitbuf = 0;
|
| 399 |
+
s.bitcnt = 0;
|
| 400 |
+
|
| 401 |
+
/* initialize output state */
|
| 402 |
+
s.outfun = outfun;
|
| 403 |
+
s.outhow = outhow;
|
| 404 |
+
s.next = 0;
|
| 405 |
+
s.first = 1;
|
| 406 |
+
|
| 407 |
+
/* return if bits() or decode() tries to read past available input */
|
| 408 |
+
if (setjmp(s.env) != 0) /* if came back here via longjmp(), */
|
| 409 |
+
err = 2; /* then skip decomp(), return error */
|
| 410 |
+
else
|
| 411 |
+
err = decomp(&s); /* decompress */
|
| 412 |
+
|
| 413 |
+
/* return unused input */
|
| 414 |
+
if (left != NULL)
|
| 415 |
+
*left = s.left;
|
| 416 |
+
if (in != NULL)
|
| 417 |
+
*in = s.left ? s.in : NULL;
|
| 418 |
+
|
| 419 |
+
/* write any leftover output and update the error code if needed */
|
| 420 |
+
if (err != 1 && s.next && s.outfun(s.outhow, s.out, s.next) && err == 0)
|
| 421 |
+
err = 1;
|
| 422 |
+
return err;
|
| 423 |
+
}
|
| 424 |
+
|
| 425 |
+
#ifdef TEST
|
| 426 |
+
/* Example of how to use blast() */
|
| 427 |
+
#include <stdio.h>
|
| 428 |
+
#include <stdlib.h>
|
| 429 |
+
|
| 430 |
+
#define CHUNK 16384
|
| 431 |
+
|
| 432 |
+
local unsigned inf(void *how, unsigned char **buf)
|
| 433 |
+
{
|
| 434 |
+
static unsigned char hold[CHUNK];
|
| 435 |
+
|
| 436 |
+
*buf = hold;
|
| 437 |
+
return fread(hold, 1, CHUNK, (FILE *)how);
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
local int outf(void *how, unsigned char *buf, unsigned len)
|
| 441 |
+
{
|
| 442 |
+
return fwrite(buf, 1, len, (FILE *)how) != len;
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
/* Decompress a PKWare Compression Library stream from stdin to stdout */
|
| 446 |
+
int main(void)
|
| 447 |
+
{
|
| 448 |
+
int ret;
|
| 449 |
+
unsigned left;
|
| 450 |
+
|
| 451 |
+
/* decompress to stdout */
|
| 452 |
+
left = 0;
|
| 453 |
+
ret = blast(inf, stdin, outf, stdout, &left, NULL);
|
| 454 |
+
if (ret != 0)
|
| 455 |
+
fprintf(stderr, "blast error: %d\n", ret);
|
| 456 |
+
|
| 457 |
+
/* count any leftover bytes */
|
| 458 |
+
while (getchar() != EOF)
|
| 459 |
+
left++;
|
| 460 |
+
if (left)
|
| 461 |
+
fprintf(stderr, "blast warning: %u unused bytes of input\n", left);
|
| 462 |
+
|
| 463 |
+
/* return blast() error code */
|
| 464 |
+
return ret;
|
| 465 |
+
}
|
| 466 |
+
#endif
|
contrib/blast/blast.h
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* blast.h -- interface for blast.c
|
| 2 |
+
Copyright (C) 2003, 2012, 2013 Mark Adler
|
| 3 |
+
version 1.3, 24 Aug 2013
|
| 4 |
+
|
| 5 |
+
This software is provided 'as-is', without any express or implied
|
| 6 |
+
warranty. In no event will the author be held liable for any damages
|
| 7 |
+
arising from the use of this software.
|
| 8 |
+
|
| 9 |
+
Permission is granted to anyone to use this software for any purpose,
|
| 10 |
+
including commercial applications, and to alter it and redistribute it
|
| 11 |
+
freely, subject to the following restrictions:
|
| 12 |
+
|
| 13 |
+
1. The origin of this software must not be misrepresented; you must not
|
| 14 |
+
claim that you wrote the original software. If you use this software
|
| 15 |
+
in a product, an acknowledgment in the product documentation would be
|
| 16 |
+
appreciated but is not required.
|
| 17 |
+
2. Altered source versions must be plainly marked as such, and must not be
|
| 18 |
+
misrepresented as being the original software.
|
| 19 |
+
3. This notice may not be removed or altered from any source distribution.
|
| 20 |
+
|
| 21 |
+
Mark Adler madler@alumni.caltech.edu
|
| 22 |
+
*/
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
/*
|
| 26 |
+
* blast() decompresses the PKWare Data Compression Library (DCL) compressed
|
| 27 |
+
* format. It provides the same functionality as the explode() function in
|
| 28 |
+
* that library. (Note: PKWare overused the "implode" verb, and the format
|
| 29 |
+
* used by their library implode() function is completely different and
|
| 30 |
+
* incompatible with the implode compression method supported by PKZIP.)
|
| 31 |
+
*
|
| 32 |
+
* The binary mode for stdio functions should be used to assure that the
|
| 33 |
+
* compressed data is not corrupted when read or written. For example:
|
| 34 |
+
* fopen(..., "rb") and fopen(..., "wb").
|
| 35 |
+
*/
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
typedef unsigned (*blast_in)(void *how, unsigned char **buf);
|
| 39 |
+
typedef int (*blast_out)(void *how, unsigned char *buf, unsigned len);
|
| 40 |
+
/* Definitions for input/output functions passed to blast(). See below for
|
| 41 |
+
* what the provided functions need to do.
|
| 42 |
+
*/
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow,
|
| 46 |
+
unsigned *left, unsigned char **in);
|
| 47 |
+
/* Decompress input to output using the provided infun() and outfun() calls.
|
| 48 |
+
* On success, the return value of blast() is zero. If there is an error in
|
| 49 |
+
* the source data, i.e. it is not in the proper format, then a negative value
|
| 50 |
+
* is returned. If there is not enough input available or there is not enough
|
| 51 |
+
* output space, then a positive error is returned.
|
| 52 |
+
*
|
| 53 |
+
* The input function is invoked: len = infun(how, &buf), where buf is set by
|
| 54 |
+
* infun() to point to the input buffer, and infun() returns the number of
|
| 55 |
+
* available bytes there. If infun() returns zero, then blast() returns with
|
| 56 |
+
* an input error. (blast() only asks for input if it needs it.) inhow is for
|
| 57 |
+
* use by the application to pass an input descriptor to infun(), if desired.
|
| 58 |
+
*
|
| 59 |
+
* If left and in are not NULL and *left is not zero when blast() is called,
|
| 60 |
+
* then the *left bytes at *in are consumed for input before infun() is used.
|
| 61 |
+
*
|
| 62 |
+
* The output function is invoked: err = outfun(how, buf, len), where the bytes
|
| 63 |
+
* to be written are buf[0..len-1]. If err is not zero, then blast() returns
|
| 64 |
+
* with an output error. outfun() is always called with len <= 4096. outhow
|
| 65 |
+
* is for use by the application to pass an output descriptor to outfun(), if
|
| 66 |
+
* desired.
|
| 67 |
+
*
|
| 68 |
+
* If there is any unused input, *left is set to the number of bytes that were
|
| 69 |
+
* read and *in points to them. Otherwise *left is set to zero and *in is set
|
| 70 |
+
* to NULL. If left or in are NULL, then they are not set.
|
| 71 |
+
*
|
| 72 |
+
* The return codes are:
|
| 73 |
+
*
|
| 74 |
+
* 2: ran out of input before completing decompression
|
| 75 |
+
* 1: output error before completing decompression
|
| 76 |
+
* 0: successful decompression
|
| 77 |
+
* -1: literal flag not zero or one
|
| 78 |
+
* -2: dictionary size not in 4..6
|
| 79 |
+
* -3: distance is too far back
|
| 80 |
+
*
|
| 81 |
+
* At the bottom of blast.c is an example program that uses blast() that can be
|
| 82 |
+
* compiled to produce a command-line decompression filter by defining TEST.
|
| 83 |
+
*/
|
contrib/blast/test.pk
ADDED
|
Binary file (8 Bytes). View file
|
|
|
contrib/blast/test.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
AIAIAIAIAIAI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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{*******************************************************}
|
| 2 |
+
{ }
|
| 3 |
+
{ Borland Delphi Supplemental Components }
|
| 4 |
+
{ ZLIB Data Compression Interface Unit }
|
| 5 |
+
{ }
|
| 6 |
+
{ Copyright (c) 1997,99 Borland Corporation }
|
| 7 |
+
{ }
|
| 8 |
+
{*******************************************************}
|
| 9 |
+
|
| 10 |
+
{ Updated for zlib 1.2.x by Cosmin Truta <cosmint@cs.ubbcluj.ro> }
|
| 11 |
+
|
| 12 |
+
unit ZLib;
|
| 13 |
+
|
| 14 |
+
interface
|
| 15 |
+
|
| 16 |
+
uses SysUtils, Classes;
|
| 17 |
+
|
| 18 |
+
type
|
| 19 |
+
TAlloc = function (AppData: Pointer; Items, Size: Integer): Pointer; cdecl;
|
| 20 |
+
TFree = procedure (AppData, Block: Pointer); cdecl;
|
| 21 |
+
|
| 22 |
+
// Internal structure. Ignore.
|
| 23 |
+
TZStreamRec = packed record
|
| 24 |
+
next_in: PChar; // next input byte
|
| 25 |
+
avail_in: Integer; // number of bytes available at next_in
|
| 26 |
+
total_in: Longint; // total nb of input bytes read so far
|
| 27 |
+
|
| 28 |
+
next_out: PChar; // next output byte should be put here
|
| 29 |
+
avail_out: Integer; // remaining free space at next_out
|
| 30 |
+
total_out: Longint; // total nb of bytes output so far
|
| 31 |
+
|
| 32 |
+
msg: PChar; // last error message, NULL if no error
|
| 33 |
+
internal: Pointer; // not visible by applications
|
| 34 |
+
|
| 35 |
+
zalloc: TAlloc; // used to allocate the internal state
|
| 36 |
+
zfree: TFree; // used to free the internal state
|
| 37 |
+
AppData: Pointer; // private data object passed to zalloc and zfree
|
| 38 |
+
|
| 39 |
+
data_type: Integer; // best guess about the data type: ascii or binary
|
| 40 |
+
adler: Longint; // adler32 value of the uncompressed data
|
| 41 |
+
reserved: Longint; // reserved for future use
|
| 42 |
+
end;
|
| 43 |
+
|
| 44 |
+
// Abstract ancestor class
|
| 45 |
+
TCustomZlibStream = class(TStream)
|
| 46 |
+
private
|
| 47 |
+
FStrm: TStream;
|
| 48 |
+
FStrmPos: Integer;
|
| 49 |
+
FOnProgress: TNotifyEvent;
|
| 50 |
+
FZRec: TZStreamRec;
|
| 51 |
+
FBuffer: array [Word] of Char;
|
| 52 |
+
protected
|
| 53 |
+
procedure Progress(Sender: TObject); dynamic;
|
| 54 |
+
property OnProgress: TNotifyEvent read FOnProgress write FOnProgress;
|
| 55 |
+
constructor Create(Strm: TStream);
|
| 56 |
+
end;
|
| 57 |
+
|
| 58 |
+
{ TCompressionStream compresses data on the fly as data is written to it, and
|
| 59 |
+
stores the compressed data to another stream.
|
| 60 |
+
|
| 61 |
+
TCompressionStream is write-only and strictly sequential. Reading from the
|
| 62 |
+
stream will raise an exception. Using Seek to move the stream pointer
|
| 63 |
+
will raise an exception.
|
| 64 |
+
|
| 65 |
+
Output data is cached internally, written to the output stream only when
|
| 66 |
+
the internal output buffer is full. All pending output data is flushed
|
| 67 |
+
when the stream is destroyed.
|
| 68 |
+
|
| 69 |
+
The Position property returns the number of uncompressed bytes of
|
| 70 |
+
data that have been written to the stream so far.
|
| 71 |
+
|
| 72 |
+
CompressionRate returns the on-the-fly percentage by which the original
|
| 73 |
+
data has been compressed: (1 - (CompressedBytes / UncompressedBytes)) * 100
|
| 74 |
+
If raw data size = 100 and compressed data size = 25, the CompressionRate
|
| 75 |
+
is 75%
|
| 76 |
+
|
| 77 |
+
The OnProgress event is called each time the output buffer is filled and
|
| 78 |
+
written to the output stream. This is useful for updating a progress
|
| 79 |
+
indicator when you are writing a large chunk of data to the compression
|
| 80 |
+
stream in a single call.}
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
TCompressionLevel = (clNone, clFastest, clDefault, clMax);
|
| 84 |
+
|
| 85 |
+
TCompressionStream = class(TCustomZlibStream)
|
| 86 |
+
private
|
| 87 |
+
function GetCompressionRate: Single;
|
| 88 |
+
public
|
| 89 |
+
constructor Create(CompressionLevel: TCompressionLevel; Dest: TStream);
|
| 90 |
+
destructor Destroy; override;
|
| 91 |
+
function Read(var Buffer; Count: Longint): Longint; override;
|
| 92 |
+
function Write(const Buffer; Count: Longint): Longint; override;
|
| 93 |
+
function Seek(Offset: Longint; Origin: Word): Longint; override;
|
| 94 |
+
property CompressionRate: Single read GetCompressionRate;
|
| 95 |
+
property OnProgress;
|
| 96 |
+
end;
|
| 97 |
+
|
| 98 |
+
{ TDecompressionStream decompresses data on the fly as data is read from it.
|
| 99 |
+
|
| 100 |
+
Compressed data comes from a separate source stream. TDecompressionStream
|
| 101 |
+
is read-only and unidirectional; you can seek forward in the stream, but not
|
| 102 |
+
backwards. The special case of setting the stream position to zero is
|
| 103 |
+
allowed. Seeking forward decompresses data until the requested position in
|
| 104 |
+
the uncompressed data has been reached. Seeking backwards, seeking relative
|
| 105 |
+
to the end of the stream, requesting the size of the stream, and writing to
|
| 106 |
+
the stream will raise an exception.
|
| 107 |
+
|
| 108 |
+
The Position property returns the number of bytes of uncompressed data that
|
| 109 |
+
have been read from the stream so far.
|
| 110 |
+
|
| 111 |
+
The OnProgress event is called each time the internal input buffer of
|
| 112 |
+
compressed data is exhausted and the next block is read from the input stream.
|
| 113 |
+
This is useful for updating a progress indicator when you are reading a
|
| 114 |
+
large chunk of data from the decompression stream in a single call.}
|
| 115 |
+
|
| 116 |
+
TDecompressionStream = class(TCustomZlibStream)
|
| 117 |
+
public
|
| 118 |
+
constructor Create(Source: TStream);
|
| 119 |
+
destructor Destroy; override;
|
| 120 |
+
function Read(var Buffer; Count: Longint): Longint; override;
|
| 121 |
+
function Write(const Buffer; Count: Longint): Longint; override;
|
| 122 |
+
function Seek(Offset: Longint; Origin: Word): Longint; override;
|
| 123 |
+
property OnProgress;
|
| 124 |
+
end;
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
{ CompressBuf compresses data, buffer to buffer, in one call.
|
| 129 |
+
In: InBuf = ptr to compressed data
|
| 130 |
+
InBytes = number of bytes in InBuf
|
| 131 |
+
Out: OutBuf = ptr to newly allocated buffer containing decompressed data
|
| 132 |
+
OutBytes = number of bytes in OutBuf }
|
| 133 |
+
procedure CompressBuf(const InBuf: Pointer; InBytes: Integer;
|
| 134 |
+
out OutBuf: Pointer; out OutBytes: Integer);
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
{ DecompressBuf decompresses data, buffer to buffer, in one call.
|
| 138 |
+
In: InBuf = ptr to compressed data
|
| 139 |
+
InBytes = number of bytes in InBuf
|
| 140 |
+
OutEstimate = zero, or est. size of the decompressed data
|
| 141 |
+
Out: OutBuf = ptr to newly allocated buffer containing decompressed data
|
| 142 |
+
OutBytes = number of bytes in OutBuf }
|
| 143 |
+
procedure DecompressBuf(const InBuf: Pointer; InBytes: Integer;
|
| 144 |
+
OutEstimate: Integer; out OutBuf: Pointer; out OutBytes: Integer);
|
| 145 |
+
|
| 146 |
+
{ DecompressToUserBuf decompresses data, buffer to buffer, in one call.
|
| 147 |
+
In: InBuf = ptr to compressed data
|
| 148 |
+
InBytes = number of bytes in InBuf
|
| 149 |
+
Out: OutBuf = ptr to user-allocated buffer to contain decompressed data
|
| 150 |
+
BufSize = number of bytes in OutBuf }
|
| 151 |
+
procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer;
|
| 152 |
+
const OutBuf: Pointer; BufSize: Integer);
|
| 153 |
+
|
| 154 |
+
const
|
| 155 |
+
zlib_version = '1.3.1.1';
|
| 156 |
+
|
| 157 |
+
type
|
| 158 |
+
EZlibError = class(Exception);
|
| 159 |
+
ECompressionError = class(EZlibError);
|
| 160 |
+
EDecompressionError = class(EZlibError);
|
| 161 |
+
|
| 162 |
+
implementation
|
| 163 |
+
|
| 164 |
+
uses ZLibConst;
|
| 165 |
+
|
| 166 |
+
const
|
| 167 |
+
Z_NO_FLUSH = 0;
|
| 168 |
+
Z_PARTIAL_FLUSH = 1;
|
| 169 |
+
Z_SYNC_FLUSH = 2;
|
| 170 |
+
Z_FULL_FLUSH = 3;
|
| 171 |
+
Z_FINISH = 4;
|
| 172 |
+
|
| 173 |
+
Z_OK = 0;
|
| 174 |
+
Z_STREAM_END = 1;
|
| 175 |
+
Z_NEED_DICT = 2;
|
| 176 |
+
Z_ERRNO = (-1);
|
| 177 |
+
Z_STREAM_ERROR = (-2);
|
| 178 |
+
Z_DATA_ERROR = (-3);
|
| 179 |
+
Z_MEM_ERROR = (-4);
|
| 180 |
+
Z_BUF_ERROR = (-5);
|
| 181 |
+
Z_VERSION_ERROR = (-6);
|
| 182 |
+
|
| 183 |
+
Z_NO_COMPRESSION = 0;
|
| 184 |
+
Z_BEST_SPEED = 1;
|
| 185 |
+
Z_BEST_COMPRESSION = 9;
|
| 186 |
+
Z_DEFAULT_COMPRESSION = (-1);
|
| 187 |
+
|
| 188 |
+
Z_FILTERED = 1;
|
| 189 |
+
Z_HUFFMAN_ONLY = 2;
|
| 190 |
+
Z_RLE = 3;
|
| 191 |
+
Z_DEFAULT_STRATEGY = 0;
|
| 192 |
+
|
| 193 |
+
Z_BINARY = 0;
|
| 194 |
+
Z_ASCII = 1;
|
| 195 |
+
Z_UNKNOWN = 2;
|
| 196 |
+
|
| 197 |
+
Z_DEFLATED = 8;
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
{$L adler32.obj}
|
| 201 |
+
{$L compress.obj}
|
| 202 |
+
{$L crc32.obj}
|
| 203 |
+
{$L deflate.obj}
|
| 204 |
+
{$L infback.obj}
|
| 205 |
+
{$L inffast.obj}
|
| 206 |
+
{$L inflate.obj}
|
| 207 |
+
{$L inftrees.obj}
|
| 208 |
+
{$L trees.obj}
|
| 209 |
+
{$L uncompr.obj}
|
| 210 |
+
{$L zutil.obj}
|
| 211 |
+
|
| 212 |
+
procedure adler32; external;
|
| 213 |
+
procedure compressBound; external;
|
| 214 |
+
procedure crc32; external;
|
| 215 |
+
procedure deflateInit2_; external;
|
| 216 |
+
procedure deflateParams; external;
|
| 217 |
+
|
| 218 |
+
function _malloc(Size: Integer): Pointer; cdecl;
|
| 219 |
+
begin
|
| 220 |
+
Result := AllocMem(Size);
|
| 221 |
+
end;
|
| 222 |
+
|
| 223 |
+
procedure _free(Block: Pointer); cdecl;
|
| 224 |
+
begin
|
| 225 |
+
FreeMem(Block);
|
| 226 |
+
end;
|
| 227 |
+
|
| 228 |
+
procedure _memset(P: Pointer; B: Byte; count: Integer); cdecl;
|
| 229 |
+
begin
|
| 230 |
+
FillChar(P^, count, B);
|
| 231 |
+
end;
|
| 232 |
+
|
| 233 |
+
procedure _memcpy(dest, source: Pointer; count: Integer); cdecl;
|
| 234 |
+
begin
|
| 235 |
+
Move(source^, dest^, count);
|
| 236 |
+
end;
|
| 237 |
+
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
// deflate compresses data
|
| 241 |
+
function deflateInit_(var strm: TZStreamRec; level: Integer; version: PChar;
|
| 242 |
+
recsize: Integer): Integer; external;
|
| 243 |
+
function deflate(var strm: TZStreamRec; flush: Integer): Integer; external;
|
| 244 |
+
function deflateEnd(var strm: TZStreamRec): Integer; external;
|
| 245 |
+
|
| 246 |
+
// inflate decompresses data
|
| 247 |
+
function inflateInit_(var strm: TZStreamRec; version: PChar;
|
| 248 |
+
recsize: Integer): Integer; external;
|
| 249 |
+
function inflate(var strm: TZStreamRec; flush: Integer): Integer; external;
|
| 250 |
+
function inflateEnd(var strm: TZStreamRec): Integer; external;
|
| 251 |
+
function inflateReset(var strm: TZStreamRec): Integer; external;
|
| 252 |
+
|
| 253 |
+
|
| 254 |
+
function zlibAllocMem(AppData: Pointer; Items, Size: Integer): Pointer; cdecl;
|
| 255 |
+
begin
|
| 256 |
+
// GetMem(Result, Items*Size);
|
| 257 |
+
Result := AllocMem(Items * Size);
|
| 258 |
+
end;
|
| 259 |
+
|
| 260 |
+
procedure zlibFreeMem(AppData, Block: Pointer); cdecl;
|
| 261 |
+
begin
|
| 262 |
+
FreeMem(Block);
|
| 263 |
+
end;
|
| 264 |
+
|
| 265 |
+
{function zlibCheck(code: Integer): Integer;
|
| 266 |
+
begin
|
| 267 |
+
Result := code;
|
| 268 |
+
if code < 0 then
|
| 269 |
+
raise EZlibError.Create('error'); //!!
|
| 270 |
+
end;}
|
| 271 |
+
|
| 272 |
+
function CCheck(code: Integer): Integer;
|
| 273 |
+
begin
|
| 274 |
+
Result := code;
|
| 275 |
+
if code < 0 then
|
| 276 |
+
raise ECompressionError.Create('error'); //!!
|
| 277 |
+
end;
|
| 278 |
+
|
| 279 |
+
function DCheck(code: Integer): Integer;
|
| 280 |
+
begin
|
| 281 |
+
Result := code;
|
| 282 |
+
if code < 0 then
|
| 283 |
+
raise EDecompressionError.Create('error'); //!!
|
| 284 |
+
end;
|
| 285 |
+
|
| 286 |
+
procedure CompressBuf(const InBuf: Pointer; InBytes: Integer;
|
| 287 |
+
out OutBuf: Pointer; out OutBytes: Integer);
|
| 288 |
+
var
|
| 289 |
+
strm: TZStreamRec;
|
| 290 |
+
P: Pointer;
|
| 291 |
+
begin
|
| 292 |
+
FillChar(strm, sizeof(strm), 0);
|
| 293 |
+
strm.zalloc := zlibAllocMem;
|
| 294 |
+
strm.zfree := zlibFreeMem;
|
| 295 |
+
OutBytes := ((InBytes + (InBytes div 10) + 12) + 255) and not 255;
|
| 296 |
+
GetMem(OutBuf, OutBytes);
|
| 297 |
+
try
|
| 298 |
+
strm.next_in := InBuf;
|
| 299 |
+
strm.avail_in := InBytes;
|
| 300 |
+
strm.next_out := OutBuf;
|
| 301 |
+
strm.avail_out := OutBytes;
|
| 302 |
+
CCheck(deflateInit_(strm, Z_BEST_COMPRESSION, zlib_version, sizeof(strm)));
|
| 303 |
+
try
|
| 304 |
+
while CCheck(deflate(strm, Z_FINISH)) <> Z_STREAM_END do
|
| 305 |
+
begin
|
| 306 |
+
P := OutBuf;
|
| 307 |
+
Inc(OutBytes, 256);
|
| 308 |
+
ReallocMem(OutBuf, OutBytes);
|
| 309 |
+
strm.next_out := PChar(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P)));
|
| 310 |
+
strm.avail_out := 256;
|
| 311 |
+
end;
|
| 312 |
+
finally
|
| 313 |
+
CCheck(deflateEnd(strm));
|
| 314 |
+
end;
|
| 315 |
+
ReallocMem(OutBuf, strm.total_out);
|
| 316 |
+
OutBytes := strm.total_out;
|
| 317 |
+
except
|
| 318 |
+
FreeMem(OutBuf);
|
| 319 |
+
raise
|
| 320 |
+
end;
|
| 321 |
+
end;
|
| 322 |
+
|
| 323 |
+
|
| 324 |
+
procedure DecompressBuf(const InBuf: Pointer; InBytes: Integer;
|
| 325 |
+
OutEstimate: Integer; out OutBuf: Pointer; out OutBytes: Integer);
|
| 326 |
+
var
|
| 327 |
+
strm: TZStreamRec;
|
| 328 |
+
P: Pointer;
|
| 329 |
+
BufInc: Integer;
|
| 330 |
+
begin
|
| 331 |
+
FillChar(strm, sizeof(strm), 0);
|
| 332 |
+
strm.zalloc := zlibAllocMem;
|
| 333 |
+
strm.zfree := zlibFreeMem;
|
| 334 |
+
BufInc := (InBytes + 255) and not 255;
|
| 335 |
+
if OutEstimate = 0 then
|
| 336 |
+
OutBytes := BufInc
|
| 337 |
+
else
|
| 338 |
+
OutBytes := OutEstimate;
|
| 339 |
+
GetMem(OutBuf, OutBytes);
|
| 340 |
+
try
|
| 341 |
+
strm.next_in := InBuf;
|
| 342 |
+
strm.avail_in := InBytes;
|
| 343 |
+
strm.next_out := OutBuf;
|
| 344 |
+
strm.avail_out := OutBytes;
|
| 345 |
+
DCheck(inflateInit_(strm, zlib_version, sizeof(strm)));
|
| 346 |
+
try
|
| 347 |
+
while DCheck(inflate(strm, Z_NO_FLUSH)) <> Z_STREAM_END do
|
| 348 |
+
begin
|
| 349 |
+
P := OutBuf;
|
| 350 |
+
Inc(OutBytes, BufInc);
|
| 351 |
+
ReallocMem(OutBuf, OutBytes);
|
| 352 |
+
strm.next_out := PChar(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P)));
|
| 353 |
+
strm.avail_out := BufInc;
|
| 354 |
+
end;
|
| 355 |
+
finally
|
| 356 |
+
DCheck(inflateEnd(strm));
|
| 357 |
+
end;
|
| 358 |
+
ReallocMem(OutBuf, strm.total_out);
|
| 359 |
+
OutBytes := strm.total_out;
|
| 360 |
+
except
|
| 361 |
+
FreeMem(OutBuf);
|
| 362 |
+
raise
|
| 363 |
+
end;
|
| 364 |
+
end;
|
| 365 |
+
|
| 366 |
+
procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer;
|
| 367 |
+
const OutBuf: Pointer; BufSize: Integer);
|
| 368 |
+
var
|
| 369 |
+
strm: TZStreamRec;
|
| 370 |
+
begin
|
| 371 |
+
FillChar(strm, sizeof(strm), 0);
|
| 372 |
+
strm.zalloc := zlibAllocMem;
|
| 373 |
+
strm.zfree := zlibFreeMem;
|
| 374 |
+
strm.next_in := InBuf;
|
| 375 |
+
strm.avail_in := InBytes;
|
| 376 |
+
strm.next_out := OutBuf;
|
| 377 |
+
strm.avail_out := BufSize;
|
| 378 |
+
DCheck(inflateInit_(strm, zlib_version, sizeof(strm)));
|
| 379 |
+
try
|
| 380 |
+
if DCheck(inflate(strm, Z_FINISH)) <> Z_STREAM_END then
|
| 381 |
+
raise EZlibError.CreateRes(@sTargetBufferTooSmall);
|
| 382 |
+
finally
|
| 383 |
+
DCheck(inflateEnd(strm));
|
| 384 |
+
end;
|
| 385 |
+
end;
|
| 386 |
+
|
| 387 |
+
// TCustomZlibStream
|
| 388 |
+
|
| 389 |
+
constructor TCustomZLibStream.Create(Strm: TStream);
|
| 390 |
+
begin
|
| 391 |
+
inherited Create;
|
| 392 |
+
FStrm := Strm;
|
| 393 |
+
FStrmPos := Strm.Position;
|
| 394 |
+
FZRec.zalloc := zlibAllocMem;
|
| 395 |
+
FZRec.zfree := zlibFreeMem;
|
| 396 |
+
end;
|
| 397 |
+
|
| 398 |
+
procedure TCustomZLibStream.Progress(Sender: TObject);
|
| 399 |
+
begin
|
| 400 |
+
if Assigned(FOnProgress) then FOnProgress(Sender);
|
| 401 |
+
end;
|
| 402 |
+
|
| 403 |
+
|
| 404 |
+
// TCompressionStream
|
| 405 |
+
|
| 406 |
+
constructor TCompressionStream.Create(CompressionLevel: TCompressionLevel;
|
| 407 |
+
Dest: TStream);
|
| 408 |
+
const
|
| 409 |
+
Levels: array [TCompressionLevel] of ShortInt =
|
| 410 |
+
(Z_NO_COMPRESSION, Z_BEST_SPEED, Z_DEFAULT_COMPRESSION, Z_BEST_COMPRESSION);
|
| 411 |
+
begin
|
| 412 |
+
inherited Create(Dest);
|
| 413 |
+
FZRec.next_out := FBuffer;
|
| 414 |
+
FZRec.avail_out := sizeof(FBuffer);
|
| 415 |
+
CCheck(deflateInit_(FZRec, Levels[CompressionLevel], zlib_version, sizeof(FZRec)));
|
| 416 |
+
end;
|
| 417 |
+
|
| 418 |
+
destructor TCompressionStream.Destroy;
|
| 419 |
+
begin
|
| 420 |
+
FZRec.next_in := nil;
|
| 421 |
+
FZRec.avail_in := 0;
|
| 422 |
+
try
|
| 423 |
+
if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos;
|
| 424 |
+
while (CCheck(deflate(FZRec, Z_FINISH)) <> Z_STREAM_END)
|
| 425 |
+
and (FZRec.avail_out = 0) do
|
| 426 |
+
begin
|
| 427 |
+
FStrm.WriteBuffer(FBuffer, sizeof(FBuffer));
|
| 428 |
+
FZRec.next_out := FBuffer;
|
| 429 |
+
FZRec.avail_out := sizeof(FBuffer);
|
| 430 |
+
end;
|
| 431 |
+
if FZRec.avail_out < sizeof(FBuffer) then
|
| 432 |
+
FStrm.WriteBuffer(FBuffer, sizeof(FBuffer) - FZRec.avail_out);
|
| 433 |
+
finally
|
| 434 |
+
deflateEnd(FZRec);
|
| 435 |
+
end;
|
| 436 |
+
inherited Destroy;
|
| 437 |
+
end;
|
| 438 |
+
|
| 439 |
+
function TCompressionStream.Read(var Buffer; Count: Longint): Longint;
|
| 440 |
+
begin
|
| 441 |
+
raise ECompressionError.CreateRes(@sInvalidStreamOp);
|
| 442 |
+
end;
|
| 443 |
+
|
| 444 |
+
function TCompressionStream.Write(const Buffer; Count: Longint): Longint;
|
| 445 |
+
begin
|
| 446 |
+
FZRec.next_in := @Buffer;
|
| 447 |
+
FZRec.avail_in := Count;
|
| 448 |
+
if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos;
|
| 449 |
+
while (FZRec.avail_in > 0) do
|
| 450 |
+
begin
|
| 451 |
+
CCheck(deflate(FZRec, 0));
|
| 452 |
+
if FZRec.avail_out = 0 then
|
| 453 |
+
begin
|
| 454 |
+
FStrm.WriteBuffer(FBuffer, sizeof(FBuffer));
|
| 455 |
+
FZRec.next_out := FBuffer;
|
| 456 |
+
FZRec.avail_out := sizeof(FBuffer);
|
| 457 |
+
FStrmPos := FStrm.Position;
|
| 458 |
+
Progress(Self);
|
| 459 |
+
end;
|
| 460 |
+
end;
|
| 461 |
+
Result := Count;
|
| 462 |
+
end;
|
| 463 |
+
|
| 464 |
+
function TCompressionStream.Seek(Offset: Longint; Origin: Word): Longint;
|
| 465 |
+
begin
|
| 466 |
+
if (Offset = 0) and (Origin = soFromCurrent) then
|
| 467 |
+
Result := FZRec.total_in
|
| 468 |
+
else
|
| 469 |
+
raise ECompressionError.CreateRes(@sInvalidStreamOp);
|
| 470 |
+
end;
|
| 471 |
+
|
| 472 |
+
function TCompressionStream.GetCompressionRate: Single;
|
| 473 |
+
begin
|
| 474 |
+
if FZRec.total_in = 0 then
|
| 475 |
+
Result := 0
|
| 476 |
+
else
|
| 477 |
+
Result := (1.0 - (FZRec.total_out / FZRec.total_in)) * 100.0;
|
| 478 |
+
end;
|
| 479 |
+
|
| 480 |
+
|
| 481 |
+
// TDecompressionStream
|
| 482 |
+
|
| 483 |
+
constructor TDecompressionStream.Create(Source: TStream);
|
| 484 |
+
begin
|
| 485 |
+
inherited Create(Source);
|
| 486 |
+
FZRec.next_in := FBuffer;
|
| 487 |
+
FZRec.avail_in := 0;
|
| 488 |
+
DCheck(inflateInit_(FZRec, zlib_version, sizeof(FZRec)));
|
| 489 |
+
end;
|
| 490 |
+
|
| 491 |
+
destructor TDecompressionStream.Destroy;
|
| 492 |
+
begin
|
| 493 |
+
FStrm.Seek(-FZRec.avail_in, 1);
|
| 494 |
+
inflateEnd(FZRec);
|
| 495 |
+
inherited Destroy;
|
| 496 |
+
end;
|
| 497 |
+
|
| 498 |
+
function TDecompressionStream.Read(var Buffer; Count: Longint): Longint;
|
| 499 |
+
begin
|
| 500 |
+
FZRec.next_out := @Buffer;
|
| 501 |
+
FZRec.avail_out := Count;
|
| 502 |
+
if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos;
|
| 503 |
+
while (FZRec.avail_out > 0) do
|
| 504 |
+
begin
|
| 505 |
+
if FZRec.avail_in = 0 then
|
| 506 |
+
begin
|
| 507 |
+
FZRec.avail_in := FStrm.Read(FBuffer, sizeof(FBuffer));
|
| 508 |
+
if FZRec.avail_in = 0 then
|
| 509 |
+
begin
|
| 510 |
+
Result := Count - FZRec.avail_out;
|
| 511 |
+
Exit;
|
| 512 |
+
end;
|
| 513 |
+
FZRec.next_in := FBuffer;
|
| 514 |
+
FStrmPos := FStrm.Position;
|
| 515 |
+
Progress(Self);
|
| 516 |
+
end;
|
| 517 |
+
CCheck(inflate(FZRec, 0));
|
| 518 |
+
end;
|
| 519 |
+
Result := Count;
|
| 520 |
+
end;
|
| 521 |
+
|
| 522 |
+
function TDecompressionStream.Write(const Buffer; Count: Longint): Longint;
|
| 523 |
+
begin
|
| 524 |
+
raise EDecompressionError.CreateRes(@sInvalidStreamOp);
|
| 525 |
+
end;
|
| 526 |
+
|
| 527 |
+
function TDecompressionStream.Seek(Offset: Longint; Origin: Word): Longint;
|
| 528 |
+
var
|
| 529 |
+
I: Integer;
|
| 530 |
+
Buf: array [0..4095] of Char;
|
| 531 |
+
begin
|
| 532 |
+
if (Offset = 0) and (Origin = soFromBeginning) then
|
| 533 |
+
begin
|
| 534 |
+
DCheck(inflateReset(FZRec));
|
| 535 |
+
FZRec.next_in := FBuffer;
|
| 536 |
+
FZRec.avail_in := 0;
|
| 537 |
+
FStrm.Position := 0;
|
| 538 |
+
FStrmPos := 0;
|
| 539 |
+
end
|
| 540 |
+
else if ( (Offset >= 0) and (Origin = soFromCurrent)) or
|
| 541 |
+
( ((Offset - FZRec.total_out) > 0) and (Origin = soFromBeginning)) then
|
| 542 |
+
begin
|
| 543 |
+
if Origin = soFromBeginning then Dec(Offset, FZRec.total_out);
|
| 544 |
+
if Offset > 0 then
|
| 545 |
+
begin
|
| 546 |
+
for I := 1 to Offset div sizeof(Buf) do
|
| 547 |
+
ReadBuffer(Buf, sizeof(Buf));
|
| 548 |
+
ReadBuffer(Buf, Offset mod sizeof(Buf));
|
| 549 |
+
end;
|
| 550 |
+
end
|
| 551 |
+
else
|
| 552 |
+
raise EDecompressionError.CreateRes(@sInvalidStreamOp);
|
| 553 |
+
Result := FZRec.total_out;
|
| 554 |
+
end;
|
| 555 |
+
|
| 556 |
+
|
| 557 |
+
end.
|
contrib/delphi/ZLibConst.pas
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
unit ZLibConst;
|
| 2 |
+
|
| 3 |
+
interface
|
| 4 |
+
|
| 5 |
+
resourcestring
|
| 6 |
+
sTargetBufferTooSmall = 'ZLib error: target buffer may be too small';
|
| 7 |
+
sInvalidStreamOp = 'Invalid stream operation';
|
| 8 |
+
|
| 9 |
+
implementation
|
| 10 |
+
|
| 11 |
+
end.
|
contrib/delphi/readme.txt
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Overview
|
| 3 |
+
========
|
| 4 |
+
|
| 5 |
+
This directory contains an update to the ZLib interface unit,
|
| 6 |
+
distributed by Borland as a Delphi supplemental component.
|
| 7 |
+
|
| 8 |
+
The original ZLib unit is Copyright (c) 1997,99 Borland Corp.,
|
| 9 |
+
and is based on zlib version 1.0.4. There are a series of bugs
|
| 10 |
+
and security problems associated with that old zlib version, and
|
| 11 |
+
we recommend the users to update their ZLib unit.
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
Summary of modifications
|
| 15 |
+
========================
|
| 16 |
+
|
| 17 |
+
- Improved makefile, adapted to zlib version 1.2.1.
|
| 18 |
+
|
| 19 |
+
- Some field types from TZStreamRec are changed from Integer to
|
| 20 |
+
Longint, for consistency with the zlib.h header, and for 64-bit
|
| 21 |
+
readiness.
|
| 22 |
+
|
| 23 |
+
- The zlib_version constant is updated.
|
| 24 |
+
|
| 25 |
+
- The new Z_RLE strategy has its corresponding symbolic constant.
|
| 26 |
+
|
| 27 |
+
- The allocation and deallocation functions and function types
|
| 28 |
+
(TAlloc, TFree, zlibAllocMem and zlibFreeMem) are now cdecl,
|
| 29 |
+
and _malloc and _free are added as C RTL stubs. As a result,
|
| 30 |
+
the original C sources of zlib can be compiled out of the box,
|
| 31 |
+
and linked to the ZLib unit.
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
Suggestions for improvements
|
| 35 |
+
============================
|
| 36 |
+
|
| 37 |
+
Currently, the ZLib unit provides only a limited wrapper around
|
| 38 |
+
the zlib library, and much of the original zlib functionality is
|
| 39 |
+
missing. Handling compressed file formats like ZIP/GZIP or PNG
|
| 40 |
+
cannot be implemented without having this functionality.
|
| 41 |
+
Applications that handle these formats are either using their own,
|
| 42 |
+
duplicated code, or not using the ZLib unit at all.
|
| 43 |
+
|
| 44 |
+
Here are a few suggestions:
|
| 45 |
+
|
| 46 |
+
- Checksum class wrappers around adler32() and crc32(), similar
|
| 47 |
+
to the Java classes that implement the java.util.zip.Checksum
|
| 48 |
+
interface.
|
| 49 |
+
|
| 50 |
+
- The ability to read and write raw deflate streams, without the
|
| 51 |
+
zlib stream header and trailer. Raw deflate streams are used
|
| 52 |
+
in the ZIP file format.
|
| 53 |
+
|
| 54 |
+
- The ability to read and write gzip streams, used in the GZIP
|
| 55 |
+
file format, and normally produced by the gzip program.
|
| 56 |
+
|
| 57 |
+
- The ability to select a different compression strategy, useful
|
| 58 |
+
to PNG and MNG image compression, and to multimedia compression
|
| 59 |
+
in general. Besides the compression level
|
| 60 |
+
|
| 61 |
+
TCompressionLevel = (clNone, clFastest, clDefault, clMax);
|
| 62 |
+
|
| 63 |
+
which, in fact, could have used the 'z' prefix and avoided
|
| 64 |
+
TColor-like symbols
|
| 65 |
+
|
| 66 |
+
TCompressionLevel = (zcNone, zcFastest, zcDefault, zcMax);
|
| 67 |
+
|
| 68 |
+
there could be a compression strategy
|
| 69 |
+
|
| 70 |
+
TCompressionStrategy = (zsDefault, zsFiltered, zsHuffmanOnly, zsRle);
|
| 71 |
+
|
| 72 |
+
- ZIP and GZIP stream handling via TStreams.
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
--
|
| 76 |
+
Cosmin Truta <cosmint@cs.ubbcluj.ro>
|
contrib/delphi/zlibd32.mak
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Makefile for zlib
|
| 2 |
+
# For use with Delphi and C++ Builder under Win32
|
| 3 |
+
# Updated for zlib 1.2.x by Cosmin Truta
|
| 4 |
+
|
| 5 |
+
# ------------ Borland C++ ------------
|
| 6 |
+
|
| 7 |
+
# This project uses the Delphi (fastcall/register) calling convention:
|
| 8 |
+
LOC = -DZEXPORT=__fastcall -DZEXPORTVA=__cdecl
|
| 9 |
+
|
| 10 |
+
CC = bcc32
|
| 11 |
+
LD = bcc32
|
| 12 |
+
AR = tlib
|
| 13 |
+
# do not use "-pr" in CFLAGS
|
| 14 |
+
CFLAGS = -a -d -k- -O2 $(LOC)
|
| 15 |
+
LDFLAGS =
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
# variables
|
| 19 |
+
ZLIB_LIB = zlib.lib
|
| 20 |
+
|
| 21 |
+
OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj
|
| 22 |
+
OBJ2 = gzwrite.obj infback.obj inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj
|
| 23 |
+
OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzclose.obj+gzlib.obj+gzread.obj
|
| 24 |
+
OBJP2 = +gzwrite.obj+infback.obj+inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
# targets
|
| 28 |
+
all: $(ZLIB_LIB) example.exe minigzip.exe
|
| 29 |
+
|
| 30 |
+
.c.obj:
|
| 31 |
+
$(CC) -c $(CFLAGS) $*.c
|
| 32 |
+
|
| 33 |
+
adler32.obj: adler32.c zlib.h zconf.h
|
| 34 |
+
|
| 35 |
+
compress.obj: compress.c zlib.h zconf.h
|
| 36 |
+
|
| 37 |
+
crc32.obj: crc32.c zlib.h zconf.h crc32.h
|
| 38 |
+
|
| 39 |
+
deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h
|
| 40 |
+
|
| 41 |
+
gzclose.obj: gzclose.c zlib.h zconf.h gzguts.h
|
| 42 |
+
|
| 43 |
+
gzlib.obj: gzlib.c zlib.h zconf.h gzguts.h
|
| 44 |
+
|
| 45 |
+
gzread.obj: gzread.c zlib.h zconf.h gzguts.h
|
| 46 |
+
|
| 47 |
+
gzwrite.obj: gzwrite.c zlib.h zconf.h gzguts.h
|
| 48 |
+
|
| 49 |
+
infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
|
| 50 |
+
inffast.h inffixed.h
|
| 51 |
+
|
| 52 |
+
inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
|
| 53 |
+
inffast.h
|
| 54 |
+
|
| 55 |
+
inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \
|
| 56 |
+
inffast.h inffixed.h
|
| 57 |
+
|
| 58 |
+
inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h
|
| 59 |
+
|
| 60 |
+
trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h
|
| 61 |
+
|
| 62 |
+
uncompr.obj: uncompr.c zlib.h zconf.h
|
| 63 |
+
|
| 64 |
+
zutil.obj: zutil.c zutil.h zlib.h zconf.h
|
| 65 |
+
|
| 66 |
+
example.obj: test/example.c zlib.h zconf.h
|
| 67 |
+
|
| 68 |
+
minigzip.obj: test/minigzip.c zlib.h zconf.h
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
# For the sake of the old Borland make,
|
| 72 |
+
# the command line is cut to fit in the MS-DOS 128 byte limit:
|
| 73 |
+
$(ZLIB_LIB): $(OBJ1) $(OBJ2)
|
| 74 |
+
-del $(ZLIB_LIB)
|
| 75 |
+
$(AR) $(ZLIB_LIB) $(OBJP1)
|
| 76 |
+
$(AR) $(ZLIB_LIB) $(OBJP2)
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
# testing
|
| 80 |
+
test: example.exe minigzip.exe
|
| 81 |
+
example
|
| 82 |
+
echo hello world | minigzip | minigzip -d
|
| 83 |
+
|
| 84 |
+
example.exe: example.obj $(ZLIB_LIB)
|
| 85 |
+
$(LD) $(LDFLAGS) example.obj $(ZLIB_LIB)
|
| 86 |
+
|
| 87 |
+
minigzip.exe: minigzip.obj $(ZLIB_LIB)
|
| 88 |
+
$(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB)
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
# cleanup
|
| 92 |
+
clean:
|
| 93 |
+
-del *.obj
|
| 94 |
+
-del *.exe
|
| 95 |
+
-del *.lib
|
| 96 |
+
-del *.tds
|
| 97 |
+
-del zlib.bak
|
| 98 |
+
-del foo.gz
|
| 99 |
+
|
contrib/dotzlib/DotZLib.build
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="utf-8" ?>
|
| 2 |
+
<project name="DotZLib" default="build" basedir="./DotZLib">
|
| 3 |
+
<description>A .Net wrapper library around ZLib1.dll</description>
|
| 4 |
+
|
| 5 |
+
<property name="nunit.location" value="c:/program files/NUnit V2.1/bin" />
|
| 6 |
+
<property name="build.root" value="bin" />
|
| 7 |
+
|
| 8 |
+
<property name="debug" value="true" />
|
| 9 |
+
<property name="nunit" value="true" />
|
| 10 |
+
|
| 11 |
+
<property name="build.folder" value="${build.root}/debug/" if="${debug}" />
|
| 12 |
+
<property name="build.folder" value="${build.root}/release/" unless="${debug}" />
|
| 13 |
+
|
| 14 |
+
<target name="clean" description="Remove all generated files">
|
| 15 |
+
<delete dir="${build.root}" failonerror="false" />
|
| 16 |
+
</target>
|
| 17 |
+
|
| 18 |
+
<target name="build" description="compiles the source code">
|
| 19 |
+
|
| 20 |
+
<mkdir dir="${build.folder}" />
|
| 21 |
+
<csc target="library" output="${build.folder}DotZLib.dll" debug="${debug}">
|
| 22 |
+
<references basedir="${nunit.location}">
|
| 23 |
+
<includes if="${nunit}" name="nunit.framework.dll" />
|
| 24 |
+
</references>
|
| 25 |
+
<sources>
|
| 26 |
+
<includes name="*.cs" />
|
| 27 |
+
<excludes name="UnitTests.cs" unless="${nunit}" />
|
| 28 |
+
</sources>
|
| 29 |
+
<arg value="/d:nunit" if="${nunit}" />
|
| 30 |
+
</csc>
|
| 31 |
+
</target>
|
| 32 |
+
|
| 33 |
+
</project>
|
contrib/dotzlib/DotZLib.chm
ADDED
|
Binary file (72.7 kB). View file
|
|
|
contrib/dotzlib/DotZLib.sln
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Microsoft Visual Studio Solution File, Format Version 8.00
|
| 2 |
+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotZLib", "DotZLib\DotZLib.csproj", "{BB1EE0B1-1808-46CB-B786-949D91117FC5}"
|
| 3 |
+
ProjectSection(ProjectDependencies) = postProject
|
| 4 |
+
EndProjectSection
|
| 5 |
+
EndProject
|
| 6 |
+
Global
|
| 7 |
+
GlobalSection(SolutionConfiguration) = preSolution
|
| 8 |
+
Debug = Debug
|
| 9 |
+
Release = Release
|
| 10 |
+
EndGlobalSection
|
| 11 |
+
GlobalSection(ProjectConfiguration) = postSolution
|
| 12 |
+
{BB1EE0B1-1808-46CB-B786-949D91117FC5}.Debug.ActiveCfg = Debug|.NET
|
| 13 |
+
{BB1EE0B1-1808-46CB-B786-949D91117FC5}.Debug.Build.0 = Debug|.NET
|
| 14 |
+
{BB1EE0B1-1808-46CB-B786-949D91117FC5}.Release.ActiveCfg = Release|.NET
|
| 15 |
+
{BB1EE0B1-1808-46CB-B786-949D91117FC5}.Release.Build.0 = Release|.NET
|
| 16 |
+
EndGlobalSection
|
| 17 |
+
GlobalSection(ExtensibilityGlobals) = postSolution
|
| 18 |
+
EndGlobalSection
|
| 19 |
+
GlobalSection(ExtensibilityAddIns) = postSolution
|
| 20 |
+
EndGlobalSection
|
| 21 |
+
EndGlobal
|
contrib/dotzlib/DotZLib/AssemblyInfo.cs
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using System.Reflection;
|
| 2 |
+
using System.Runtime.CompilerServices;
|
| 3 |
+
|
| 4 |
+
//
|
| 5 |
+
// General Information about an assembly is controlled through the following
|
| 6 |
+
// set of attributes. Change these attribute values to modify the information
|
| 7 |
+
// associated with an assembly.
|
| 8 |
+
//
|
| 9 |
+
[assembly: AssemblyTitle("DotZLib")]
|
| 10 |
+
[assembly: AssemblyDescription(".Net bindings for ZLib compression dll 1.2.x")]
|
| 11 |
+
[assembly: AssemblyConfiguration("")]
|
| 12 |
+
[assembly: AssemblyCompany("Henrik Ravn")]
|
| 13 |
+
[assembly: AssemblyProduct("")]
|
| 14 |
+
[assembly: AssemblyCopyright("(c) 2004 by Henrik Ravn")]
|
| 15 |
+
[assembly: AssemblyTrademark("")]
|
| 16 |
+
[assembly: AssemblyCulture("")]
|
| 17 |
+
|
| 18 |
+
//
|
| 19 |
+
// Version information for an assembly consists of the following four values:
|
| 20 |
+
//
|
| 21 |
+
// Major Version
|
| 22 |
+
// Minor Version
|
| 23 |
+
// Build Number
|
| 24 |
+
// Revision
|
| 25 |
+
//
|
| 26 |
+
// You can specify all the values or you can default the Revision and Build Numbers
|
| 27 |
+
// by using the '*' as shown below:
|
| 28 |
+
|
| 29 |
+
[assembly: AssemblyVersion("1.0.*")]
|
| 30 |
+
|
| 31 |
+
//
|
| 32 |
+
// In order to sign your assembly you must specify a key to use. Refer to the
|
| 33 |
+
// Microsoft .NET Framework documentation for more information on assembly signing.
|
| 34 |
+
//
|
| 35 |
+
// Use the attributes below to control which key is used for signing.
|
| 36 |
+
//
|
| 37 |
+
// Notes:
|
| 38 |
+
// (*) If no key is specified, the assembly is not signed.
|
| 39 |
+
// (*) KeyName refers to a key that has been installed in the Crypto Service
|
| 40 |
+
// Provider (CSP) on your machine. KeyFile refers to a file which contains
|
| 41 |
+
// a key.
|
| 42 |
+
// (*) If the KeyFile and the KeyName values are both specified, the
|
| 43 |
+
// following processing occurs:
|
| 44 |
+
// (1) If the KeyName can be found in the CSP, that key is used.
|
| 45 |
+
// (2) If the KeyName does not exist and the KeyFile does exist, the key
|
| 46 |
+
// in the KeyFile is installed into the CSP and used.
|
| 47 |
+
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
|
| 48 |
+
// When specifying the KeyFile, the location of the KeyFile should be
|
| 49 |
+
// relative to the project output directory which is
|
| 50 |
+
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
|
| 51 |
+
// located in the project directory, you would specify the AssemblyKeyFile
|
| 52 |
+
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
|
| 53 |
+
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
|
| 54 |
+
// documentation for more information on this.
|
| 55 |
+
//
|
| 56 |
+
[assembly: AssemblyDelaySign(false)]
|
| 57 |
+
[assembly: AssemblyKeyFile("")]
|
| 58 |
+
[assembly: AssemblyKeyName("")]
|