Fossil SCM
Merge updates from trunk.
Commit
e3df21cdf1f1e6c44879345b59fe5a99f0799cb0577e5724d77b877f9546f71f
Parent
6f3640a71d41419…
344 files changed
+2
+63
-84
+40
-18
+1
-1
+3
-39
+18
-6
+22
+5
-408
+8
-12
+2
-2
+3
-3
+46
-51
+1
-1
-90
-145
-147
-65
-450
-217
-106
-133
-442
-693
-301
-20
-452
-51
-357
+1
-1
+1
-1
+2
-2
+1
-1
-1157
-1241
-2
-553
-186
-396
-28
-2
-1080
-479
-24
+1
-1
+1
-1
+11
-11
+1
-1
+5
+1
-1
+3
-3
+3
-1
+1
-6
+1
-1
+1
-1
+2
-2
+1
-1
+1
-4
+1
-1
+1
-1
+8
-16
+1
-4
+1
-1
+3
-3
+13
-37
-3
+17
-41
-3
+8
-16
+3
-3
+13
-21
+17
-41
+8
-16
+3
-3
+13
-21
+17
-41
+8
-16
+3
-3
+13
-21
+17
-41
+1
-1
+1
-1
+5
-61
+1
-1
+3
-3
+11
-65
+13
-69
+21
-12
+114
-108
+2
-2
+1
-1
+2
-2
+1
-1
+2
-2
+1
-1
+1
-1
+1
-1
+3
-5
+1
-1
+10
-7
+5
-2
+2
-2
+1
-1
+2
-2
+3
-3
+8
+3
-3
+5
-5
+2
-1
+1
-1
+2
-2
+61
-62
+2
-2
+2
-2
+1
-1
+18
-5
+16
-3
+16
-3
+2
-2
+10
-10
+2
-2
+9
-7
+1
-11
-1200
+1
-1
+1018
-1007
+158
-164
+5640
-1547
+9926
-4266
+365
-141
+1
-1
+8
+10
-1
-4421
-3
-42
-73
+17
-1
+3
+7
+27
-28
+2
-2
+53
-23
+42
-14
+17
-19
+61
-31
+4
-4
+7
-7
+8
-7
+116
-4
+29
-29
+4
-10
+2
-2
+1
-1
+3
-3
+2
-2
+92
-18
+65
-12
+84
-80
+17
-17
+21
-8
+2
-2
+20
-14
+56
-28
+7
-9
+12
-2
+20
-24
+162
-80
+16
-6
+11
-10
+3
-2
+1
-1
+15
-20
+16
-2
+17
-12
+11
-11
+11
-4
+1
-1
+11
-11
+8
-7
+4
-3
+29
-29
+56
-57
+30
-10
+3
-2
+83
-41
+35
-18
+45
-7
+25
-5
-28
+2
-2
+3
-2
+16
-16
+55
-60
+1
-1
+35
-27
+2
-2
+5
-5
+219
-5
+2
-2
+1
-1
+4
-4
+1
-1
+4
-4
+1
-1
+11
-11
+9
-9
+9
-9
+7
-7
+13
-13
+1
-1
+558
-52
+115
-1
+76
-32
+10
-6
+20
-8
+19
-31
+1
-1
+3
-3
+20
-43
+1
-1
+307
-41
+21
-17
+4
-4
+15
-16
+14
-9
+2
-3
+2
-2
+1
-1
+1
-1
+89
-14
-2
+1
-1
+171
-51
+6
-5
+16
-11
+543
-38
+46
-1
+160
-128
+41
-40
+1
-1
-1
+18
-15
+11
-12
+5
-6
+3
-5
+5
-5
+3
-4
+86
-15
+48
-34
+3
+1
-1
+24
-17
+12
-12
+31
-28
+35
-5
+13
+2
-2
+62
-33
+62
-33
+134
-31
+268
-72
+31
-32
+2
-2
+6
-4
+25
-25
+40
-14
+22
-4
+2
-2
+6
-6
+45
-37
+17
-15
+11
-3
+37
-24
+6
-6
+40
-30
+1
-2
+18
-17
+2
-1
+2
-2
+4
-12
+4
-12
+4
-10
+25
-24
+1
-1
+5
-4
+31
-11
+1
-1
+6
-6
+68
-56
+1
-1
+2
-2
+8
-4
+86
-19
+3
-3
+22
-24
+614
-514
+22
-24
+14
-14
+1
-1
+38
-44
+5
-5
+6
-5
+4
-4
+4
-4
+60
-35
+1
-2
+27
-27
+81
-88
+168
-40
+3
-1
+116
-24
+3
-3
+23
-24
+7
-7
+127
+1
+52
-59
+3
-5
+2
-2
+3
-5
+68
-71
+13
+20
-20
+122
-143
+2
-2
+3
-2
+18
-9
+4
-4
+66
-33
+63
-28
+2
-2
+22
-12
+12
+6
-6
+49
-50
+14
-11
+193
-202
+8
+8
+42
-27
+10
-5
~
.fossil-settings/ignore-glob
~
Dockerfile
~
Makefile.in
~
VERSION
~
compat/zlib/CMakeLists.txt
~
compat/zlib/ChangeLog
~
compat/zlib/LICENSE
~
compat/zlib/Makefile
~
compat/zlib/Makefile.in
~
compat/zlib/README
~
compat/zlib/compress.c
~
compat/zlib/configure
~
compat/zlib/contrib/README.contrib
-
compat/zlib/contrib/ada/buffer_demo.adb
-
compat/zlib/contrib/ada/mtest.adb
-
compat/zlib/contrib/ada/read.adb
-
compat/zlib/contrib/ada/readme.txt
-
compat/zlib/contrib/ada/test.adb
-
compat/zlib/contrib/ada/zlib-streams.adb
-
compat/zlib/contrib/ada/zlib-streams.ads
-
compat/zlib/contrib/ada/zlib-thin.adb
-
compat/zlib/contrib/ada/zlib-thin.ads
-
compat/zlib/contrib/ada/zlib.adb
-
compat/zlib/contrib/ada/zlib.ads
-
compat/zlib/contrib/ada/zlib.gpr
-
compat/zlib/contrib/amd64/amd64-match.S
-
compat/zlib/contrib/asm686/README.686
-
compat/zlib/contrib/asm686/match.S
~
compat/zlib/contrib/delphi/ZLib.pas
~
compat/zlib/contrib/dotzlib/DotZLib/UnitTests.cs
~
compat/zlib/contrib/infback9/inftree9.c
~
compat/zlib/contrib/infback9/inftree9.h
-
compat/zlib/contrib/inflate86/inffas86.c
-
compat/zlib/contrib/inflate86/inffast.S
-
compat/zlib/contrib/masmx64/bld_ml64.bat
-
compat/zlib/contrib/masmx64/gvmat64.asm
-
compat/zlib/contrib/masmx64/inffas8664.c
-
compat/zlib/contrib/masmx64/inffasx64.asm
-
compat/zlib/contrib/masmx64/readme.txt
-
compat/zlib/contrib/masmx86/bld_ml32.bat
-
compat/zlib/contrib/masmx86/inffas32.asm
-
compat/zlib/contrib/masmx86/match686.asm
-
compat/zlib/contrib/masmx86/readme.txt
~
compat/zlib/contrib/minizip/configure.ac
~
compat/zlib/contrib/minizip/crypt.h
~
compat/zlib/contrib/minizip/ioapi.c
~
compat/zlib/contrib/minizip/ioapi.h
~
compat/zlib/contrib/minizip/iowin32.c
~
compat/zlib/contrib/minizip/miniunz.c
~
compat/zlib/contrib/minizip/minizip.c
~
compat/zlib/contrib/minizip/unzip.c
~
compat/zlib/contrib/minizip/zip.c
~
compat/zlib/contrib/pascal/zlibpas.pas
~
compat/zlib/contrib/puff/README
~
compat/zlib/contrib/puff/puff.c
~
compat/zlib/contrib/puff/pufftest.c
~
compat/zlib/contrib/vstudio/readme.txt
~
compat/zlib/contrib/vstudio/vc10/miniunz.vcxproj.filters
~
compat/zlib/contrib/vstudio/vc10/minizip.vcxproj.filters
~
compat/zlib/contrib/vstudio/vc10/testzlib.vcxproj
~
compat/zlib/contrib/vstudio/vc10/testzlib.vcxproj.filters
~
compat/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj.filters
~
compat/zlib/contrib/vstudio/vc10/zlib.rc
~
compat/zlib/contrib/vstudio/vc10/zlibstat.vcxproj
~
compat/zlib/contrib/vstudio/vc10/zlibstat.vcxproj.filters
~
compat/zlib/contrib/vstudio/vc10/zlibvc.vcxproj
~
compat/zlib/contrib/vstudio/vc10/zlibvc.vcxproj.filters
~
compat/zlib/contrib/vstudio/vc11/testzlib.vcxproj
~
compat/zlib/contrib/vstudio/vc11/zlib.rc
~
compat/zlib/contrib/vstudio/vc11/zlibstat.vcxproj
~
compat/zlib/contrib/vstudio/vc11/zlibvc.vcxproj
~
compat/zlib/contrib/vstudio/vc12/testzlib.vcxproj
~
compat/zlib/contrib/vstudio/vc12/zlib.rc
~
compat/zlib/contrib/vstudio/vc12/zlibstat.vcxproj
~
compat/zlib/contrib/vstudio/vc12/zlibvc.vcxproj
~
compat/zlib/contrib/vstudio/vc14/testzlib.vcxproj
~
compat/zlib/contrib/vstudio/vc14/zlib.rc
~
compat/zlib/contrib/vstudio/vc14/zlibstat.vcxproj
~
compat/zlib/contrib/vstudio/vc14/zlibvc.vcxproj
~
compat/zlib/contrib/vstudio/vc9/miniunz.vcproj
~
compat/zlib/contrib/vstudio/vc9/minizip.vcproj
~
compat/zlib/contrib/vstudio/vc9/testzlib.vcproj
~
compat/zlib/contrib/vstudio/vc9/testzlibdll.vcproj
~
compat/zlib/contrib/vstudio/vc9/zlib.rc
~
compat/zlib/contrib/vstudio/vc9/zlibstat.vcproj
~
compat/zlib/contrib/vstudio/vc9/zlibvc.vcproj
~
compat/zlib/crc32.c
~
compat/zlib/deflate.c
~
compat/zlib/deflate.h
~
compat/zlib/examples/enough.c
~
compat/zlib/examples/fitblk.c
~
compat/zlib/examples/gun.c
~
compat/zlib/examples/gzappend.c
~
compat/zlib/examples/gzlog.h
~
compat/zlib/examples/zran.c
~
compat/zlib/gzlib.c
~
compat/zlib/gzread.c
~
compat/zlib/gzwrite.c
~
compat/zlib/infback.c
~
compat/zlib/inflate.c
~
compat/zlib/inftrees.c
~
compat/zlib/inftrees.h
~
compat/zlib/make_vms.com
~
compat/zlib/os400/README400
~
compat/zlib/os400/bndsrc
~
compat/zlib/os400/zlib.inc
~
compat/zlib/qnx/package.qpg
~
compat/zlib/test/example.c
~
compat/zlib/test/minigzip.c
~
compat/zlib/treebuild.xml
~
compat/zlib/trees.c
~
compat/zlib/uncompr.c
~
compat/zlib/win32/README-WIN32.txt
~
compat/zlib/win32/zlib1.rc
~
compat/zlib/zconf.h
~
compat/zlib/zconf.h.cmakein
~
compat/zlib/zconf.h.in
~
compat/zlib/zlib.3
~
compat/zlib/zlib.3.pdf
~
compat/zlib/zlib.h
~
compat/zlib/zlib2ansi
~
compat/zlib/zutil.c
~
compat/zlib/zutil.h
-
containers/Dockerfile-nojail.patch
-
containers/busybox-config
~
extsrc/cson_amalgamation.c
~
extsrc/pikchr.c
~
extsrc/pikchr.js
~
extsrc/pikchr.wasm
~
extsrc/shell.c
~
extsrc/sqlite3.c
~
extsrc/sqlite3.h
~
skins/README.md
~
skins/ardoise/css.txt
~
skins/blitz/css.txt
-
skins/bootstrap/css.txt
-
skins/bootstrap/details.txt
-
skins/bootstrap/footer.txt
-
skins/bootstrap/header.txt
~
skins/darkmode/css.txt
~
skins/eagle/css.txt
~
skins/xekri/css.txt
~
src/add.c
~
src/ajax.c
~
src/alerts.c
~
src/allrepo.c
~
src/attach.c
~
src/backlink.c
~
src/backoffice.c
~
src/bag.c
~
src/bisect.c
~
src/blob.c
~
src/branch.c
~
src/browse.c
~
src/builtin.c
~
src/cache.c
~
src/capabilities.c
~
src/captcha.c
~
src/cgi.c
~
src/chat.c
~
src/checkin.c
~
src/checkout.c
~
src/clone.c
~
src/color.c
~
src/comformat.c
~
src/configure.c
~
src/content.c
~
src/cookies.c
~
src/copybtn.js
~
src/db.c
~
src/default.css
~
src/delta.c
~
src/deltacmd.c
~
src/descendants.c
~
src/diff.c
~
src/diff.tcl
~
src/diffcmd.c
~
src/dispatch.c
~
src/doc.c
~
src/encode.c
~
src/event.c
~
src/export.c
~
src/extcgi.c
~
src/file.c
~
src/fileedit.c
~
src/finfo.c
~
src/foci.c
~
src/forum.c
~
src/fossil.diff.js
~
src/fossil.page.chat.js
~
src/http.c
~
src/http_socket.c
~
src/http_ssl.c
~
src/http_transport.c
~
src/import.c
~
src/info.c
~
src/interwiki.c
~
src/json.c
~
src/json_artifact.c
~
src/json_branch.c
~
src/json_config.c
~
src/json_detail.h
~
src/json_diff.c
~
src/json_dir.c
~
src/json_finfo.c
~
src/json_login.c
~
src/json_query.c
~
src/json_report.c
~
src/json_tag.c
~
src/json_timeline.c
~
src/json_user.c
~
src/json_wiki.c
~
src/loadctrl.c
~
src/login.c
~
src/lookslike.c
~
src/main.c
~
src/main.mk
~
src/manifest.c
~
src/markdown.c
~
src/markdown.md
~
src/markdown_html.c
~
src/merge.c
~
src/merge3.c
~
src/name.c
~
src/patch.c
~
src/piechart.c
~
src/pikchrshow.c
~
src/pivot.c
~
src/popen.c
~
src/printf.c
~
src/publish.c
~
src/purge.c
~
src/rebuild.c
~
src/regexp.c
~
src/repolist.c
~
src/report.c
~
src/rss.c
~
src/schema.c
~
src/search.c
~
src/security_audit.c
~
src/setup.c
~
src/setupuser.c
~
src/sha1.c
~
src/sha3.c
~
src/shun.c
~
src/skins.c
~
src/smtp.c
~
src/sqlcmd.c
~
src/stash.c
~
src/stat.c
~
src/statrep.c
~
src/style.c
~
src/style.chat.css
~
src/style.pikchrshow.css
~
src/sync.c
~
src/tag.c
~
src/tar.c
~
src/th.c
~
src/th.h
~
src/th_lang.c
~
src/th_main.c
~
src/th_main.c
~
src/timeline.c
~
src/tkt.c
~
src/tktsetup.c
~
src/undo.c
~
src/unversioned.c
~
src/update.c
~
src/url.c
~
src/user.c
~
src/util.c
~
src/vfile.c
~
src/wiki.c
~
src/wikiformat.c
~
src/winhttp.c
~
src/xfer.c
~
src/xfersetup.c
~
src/zip.c
~
test/markdown-test3.md
~
tools/makemake.tcl
~
tools/mkindex.c
~
win/Makefile.dmc
~
win/Makefile.mingw
~
win/Makefile.mingw.mistachkin
~
win/Makefile.msc
~
www/aboutcgi.wiki
~
www/adding_code.wiki
~
www/alerts.md
~
www/backup.md
~
www/blockchain.md
~
www/branching.wiki
~
www/build.wiki
~
www/caps/admin-v-setup.md
~
www/caps/impl.md
~
www/caps/index.md
~
www/changes.wiki
~
www/checkin_names.wiki
~
www/concepts.wiki
~
www/containers.md
~
www/custom_ticket.wiki
~
www/customskin.md
~
www/delta_encoder_algorithm.wiki
~
www/delta_format.wiki
~
www/embeddeddoc.wiki
~
www/encryptedrepos.wiki
~
www/faq.tcl
~
www/faq.wiki
~
www/fiveminutes.wiki
~
www/forum.wiki
~
www/foss-cklist.wiki
~
www/fossil-v-git.wiki
~
www/gitusers.md
~
www/globs.md
~
www/glossary.md
~
www/hints.wiki
~
www/image-format-vs-repo-size.md
~
www/index.wiki
~
www/json-api/api-settings.md
~
www/json-api/index.md
~
www/mirrortogithub.md
~
www/mkindex.tcl
~
www/newrepo.wiki
~
www/permutedindex.html
~
www/pop.wiki
~
www/private.wiki
~
www/qandc.wiki
~
www/quickstart.wiki
~
www/quotes.wiki
~
www/rebaseharm.md
~
www/relatedwork.md
~
www/server/any/althttpd.md
~
www/server/debian/nginx.md
~
www/server/debian/service.md
~
www/server/index.html
~
www/server/whyuseaserver.wiki
~
www/server/windows/service.md
~
www/settings.wiki
~
www/shunning.wiki
~
www/ssl.wiki
~
www/sync.wiki
~
www/th1.md
~
www/th1.md
~
www/unvers.wiki
~
www/wikitheory.wiki
| --- .fossil-settings/ignore-glob | ||
| +++ .fossil-settings/ignore-glob | ||
| @@ -1,7 +1,9 @@ | ||
| 1 | 1 | compat/openssl* |
| 2 | 2 | compat/tcl* |
| 3 | +compat/zlib/contrib/ada/* | |
| 4 | +compat/zlib/doc/* | |
| 3 | 5 | fossil |
| 4 | 6 | fossil.exe |
| 5 | 7 | win/fossil.exe |
| 6 | 8 | *shell-see.* |
| 7 | 9 | *sqlite3-see.* |
| 8 | 10 |
| --- .fossil-settings/ignore-glob | |
| +++ .fossil-settings/ignore-glob | |
| @@ -1,7 +1,9 @@ | |
| 1 | compat/openssl* |
| 2 | compat/tcl* |
| 3 | fossil |
| 4 | fossil.exe |
| 5 | win/fossil.exe |
| 6 | *shell-see.* |
| 7 | *sqlite3-see.* |
| 8 |
| --- .fossil-settings/ignore-glob | |
| +++ .fossil-settings/ignore-glob | |
| @@ -1,7 +1,9 @@ | |
| 1 | compat/openssl* |
| 2 | compat/tcl* |
| 3 | compat/zlib/contrib/ada/* |
| 4 | compat/zlib/doc/* |
| 5 | fossil |
| 6 | fossil.exe |
| 7 | win/fossil.exe |
| 8 | *shell-see.* |
| 9 | *sqlite3-see.* |
| 10 |
+63
-84
| --- Dockerfile | ||
| +++ Dockerfile | ||
| @@ -1,111 +1,90 @@ | ||
| 1 | +# syntax=docker/dockerfile:1.3 | |
| 1 | 2 | # See www/containers.md for documentation on how to use this file. |
| 2 | 3 | |
| 3 | 4 | ## --------------------------------------------------------------------- |
| 4 | -## STAGE 1: Build static Fossil & BusyBox binaries atop Alpine Linux | |
| 5 | +## STAGE 1: Build static Fossil binary | |
| 5 | 6 | ## --------------------------------------------------------------------- |
| 6 | 7 | |
| 7 | -FROM alpine:latest AS builder | |
| 8 | -WORKDIR /tmp | |
| 9 | - | |
| 10 | -### Bake the basic Alpine Linux into a base layer so we never have to | |
| 11 | -### repeat that step unless we change the package set. Although we're | |
| 12 | -### going to throw this layer away below, we still pass --no-cache | |
| 13 | -### because that cache is of no use in an immutable layer. Note that | |
| 14 | -### we allow the UPX step to fail: it isn't in the ARM distros. We'll | |
| 15 | -### check whether this optional piece exists before using it below. | |
| 8 | +### We aren't pinning to a more stable version of Alpine because we want | |
| 9 | +### to build with the latest tools and libraries available in case they | |
| 10 | +### fixed something that matters to us since the last build. Everything | |
| 11 | +### below depends on this layer, and so, alas, we toss this container's | |
| 12 | +### cache on Alpine's release schedule, roughly once a month. | |
| 13 | +FROM alpine:latest AS bld | |
| 14 | +WORKDIR /fsl | |
| 15 | + | |
| 16 | +### Bake the basic Alpine Linux into a base layer so it only changes | |
| 17 | +### when the upstream image is updated or we change the package set. | |
| 16 | 18 | RUN set -x \ |
| 17 | 19 | && apk update \ |
| 18 | 20 | && apk upgrade --no-cache \ |
| 19 | 21 | && apk add --no-cache \ |
| 20 | - gcc make moreutils \ | |
| 22 | + gcc make \ | |
| 21 | 23 | linux-headers musl-dev \ |
| 22 | 24 | openssl-dev openssl-libs-static \ |
| 23 | - zlib-dev zlib-static \ | |
| 24 | - ; apk add --no-cache upx | |
| 25 | - | |
| 26 | -### Bake the custom BusyBox into another layer. The intent is that this | |
| 27 | -### changes only when we change BBXVER. That will force an update of | |
| 28 | -### the layers below, but this is a rare occurrence. | |
| 29 | -ARG BBXVER="1_35_0" | |
| 30 | -ENV BBXURL "https://github.com/mirror/busybox/tarball/${BBXVER}" | |
| 31 | -COPY containers/busybox-config /tmp/bbx/.config | |
| 32 | -ADD $BBXURL /tmp/bbx/src.tar.gz | |
| 33 | -RUN set -x \ | |
| 34 | - && tar --strip-components=1 -C bbx -xzf bbx/src.tar.gz \ | |
| 35 | - && ( cd bbx && yes "" | make oldconfig && make -j11 ) \ | |
| 36 | - && if [ -x /usr/bin/upx ] ; then upx -9q bbx/busybox ; fi | |
| 37 | - | |
| 38 | -### The changeable Fossil layer is the only one in the first stage that | |
| 39 | -### changes often, so add it last, to make it independent of the others. | |
| 25 | + zlib-dev zlib-static | |
| 26 | + | |
| 27 | +### Build Fossil as a separate layer so we don't have to rebuild the | |
| 28 | +### Alpine environment for each iteration of Fossil's dev cycle. | |
| 40 | 29 | ### |
| 41 | -### $FSLSTB can be either a file or a directory due to a ADD's bizarre | |
| 42 | -### behavior: it unpacks tarballs when added from a local file but not | |
| 43 | -### from a URL! It matters because we default to a URL in case you're | |
| 44 | -### building outside a Fossil checkout, but when building via the | |
| 45 | -### container-image target, we can avoid a costly hit on the Fossil | |
| 46 | -### project's home site by pulling the data from the local repo via the | |
| 47 | -### "tarball" command. This is a DVCS, after all! | |
| 30 | +### We must cope with a bizarre ADD misfeature here: it unpacks tarballs | |
| 31 | +### automatically when you give it a local file name but not if you give | |
| 32 | +### it a /tarball URL! It matters because we default to a URL in case | |
| 33 | +### you're building outside a Fossil checkout, but when building via the | |
| 34 | +### container-image target, we avoid a costly hit on fossil-scm.org | |
| 35 | +### by leveraging its DVCS nature via the "tarball" command and passing | |
| 36 | +### the resulting file's name in. | |
| 37 | +ARG FSLCFG="" | |
| 48 | 38 | ARG FSLVER="trunk" |
| 49 | 39 | ARG FSLURL="https://fossil-scm.org/home/tarball/src?r=${FSLVER}" |
| 50 | -ENV FSLSTB=/tmp/fsl/src.tar.gz | |
| 40 | +ENV FSLSTB=/fsl/src.tar.gz | |
| 51 | 41 | ADD $FSLURL $FSLSTB |
| 52 | -RUN set -x \ | |
| 53 | - && if [ -d $FSLSTB ] ; then mv $FSLSTB/src fsl ; \ | |
| 54 | - else tar -C fsl -xzf fsl/src.tar.gz ; fi \ | |
| 55 | - && m=fsl/src/src/main.mk \ | |
| 56 | - && grep -v '/skins/[a-ce-z]' $m | sponge $m \ | |
| 57 | - && fsl/src/configure --static CFLAGS='-Os -s' && make -j11 \ | |
| 58 | - && if [ -x /usr/bin/upx ] ; then upx -9q fossil ; fi | |
| 42 | +RUN set -x \ | |
| 43 | + && if [ -d $FSLSTB ] ; \ | |
| 44 | + then mv $FSLSTB/src . ; \ | |
| 45 | + else tar -xf src.tar.gz ; fi \ | |
| 46 | + && src/configure --static CFLAGS='-Os -s' $FSLCFG && make -j16 | |
| 59 | 47 | |
| 60 | 48 | |
| 61 | 49 | ## --------------------------------------------------------------------- |
| 62 | 50 | ## STAGE 2: Pare that back to the bare essentials. |
| 63 | 51 | ## --------------------------------------------------------------------- |
| 64 | 52 | |
| 65 | -FROM scratch | |
| 66 | -WORKDIR /jail | |
| 53 | +FROM busybox AS os | |
| 67 | 54 | ARG UID=499 |
| 68 | -ENV PATH "/bin:/jail/bin" | |
| 69 | - | |
| 70 | -### Lay BusyBox down as the first base layer. Coupled with the host's | |
| 71 | -### kernel, this is the "OS." | |
| 72 | -COPY --from=builder /tmp/bbx/busybox /bin/ | |
| 73 | -RUN [ "/bin/busybox", "--install", "/bin" ] | |
| 74 | 55 | |
| 75 | 56 | ### Set up that base OS for our specific use without tying it to |
| 76 | 57 | ### anything likely to change often. So long as the user leaves |
| 77 | 58 | ### UID alone, this layer will be durable. |
| 78 | 59 | RUN set -x \ |
| 79 | - && echo 'root:x:0:0:SysAdmin:/:/bin/nologin' > /etc/passwd \ | |
| 80 | - && echo 'root:x:0:root' > /etc/group \ | |
| 81 | - && addgroup -S -g ${UID} fossil \ | |
| 82 | - && adduser -S -h `pwd` -g 'Fossil User' -G fossil -u ${UID} fossil \ | |
| 83 | - && install -d -m 700 -o fossil -g fossil log museum \ | |
| 84 | - && install -d -m 755 -o fossil -g fossil dev \ | |
| 85 | - && mknod -m 666 dev/null c 1 3 \ | |
| 86 | - && mknod -m 444 dev/urandom c 1 9 | |
| 87 | - | |
| 88 | -### Do Fossil-specific things atop those base layers; this will change | |
| 89 | -### as often as the Fossil build-from-source layer above. | |
| 90 | -COPY --from=builder /tmp/fossil bin/ | |
| 91 | -RUN set -x \ | |
| 92 | - && ln -s /jail/bin/fossil /bin/f \ | |
| 93 | - && echo -e '#!/bin/sh\nfossil sha1sum "$@"' > /bin/sha1sum \ | |
| 94 | - && echo -e '#!/bin/sh\nfossil sha3sum "$@"' > /bin/sha3sum \ | |
| 95 | - && echo -e '#!/bin/sh\nfossil sqlite3 --no-repository "$@"' > \ | |
| 96 | - /bin/sqlite3 \ | |
| 97 | - && chmod +x /bin/sha?sum /bin/sqlite3 | |
| 98 | - | |
| 99 | - | |
| 100 | -## --------------------------------------------------------------------- | |
| 101 | -## STAGE 3: Run! | |
| 102 | -## --------------------------------------------------------------------- | |
| 103 | - | |
| 104 | -EXPOSE 8080/tcp | |
| 105 | -CMD [ \ | |
| 106 | - "bin/fossil", "server", \ | |
| 107 | - "--chroot", "/jail", \ | |
| 108 | - "--create", \ | |
| 109 | - "--jsmode", "bundled", \ | |
| 110 | - "--user", "admin", \ | |
| 111 | - "museum/repo.fossil"] | |
| 60 | + && mkdir e log museum \ | |
| 61 | + && echo "root:x:0:0:Admin:/:/false" > /e/passwd \ | |
| 62 | + && echo "root:x:0:root" > /e/group \ | |
| 63 | + && echo "fossil:x:${UID}:${UID}:User:/museum:/false" >> /e/passwd \ | |
| 64 | + && echo "fossil:x:${UID}:fossil" >> /e/group | |
| 65 | + | |
| 66 | + | |
| 67 | +## --------------------------------------------------------------------- | |
| 68 | +## STAGE 3: Drop BusyBox, too, now that we're done with its /bin/sh &c | |
| 69 | +## --------------------------------------------------------------------- | |
| 70 | + | |
| 71 | +FROM scratch AS run | |
| 72 | +COPY --from=bld --chmod=755 /fsl/fossil /bin/ | |
| 73 | +COPY --from=os --chmod=600 /e/* /etc/ | |
| 74 | +COPY --from=os --chmod=1777 /tmp /tmp/ | |
| 75 | +COPY --from=os --chown=fossil:fossil /log /log/ | |
| 76 | +COPY --from=os --chown=fossil:fossil /museum /museum/ | |
| 77 | + | |
| 78 | + | |
| 79 | +## --------------------------------------------------------------------- | |
| 80 | +## RUN! | |
| 81 | +## --------------------------------------------------------------------- | |
| 82 | + | |
| 83 | +ENV PATH "/bin" | |
| 84 | +EXPOSE 8080/tcp | |
| 85 | +USER fossil | |
| 86 | +ENTRYPOINT [ "fossil", "server", "museum/repo.fossil" ] | |
| 87 | +CMD [ \ | |
| 88 | + "--create", \ | |
| 89 | + "--jsmode", "bundled", \ | |
| 90 | + "--user", "admin" ] | |
| 112 | 91 |
| --- Dockerfile | |
| +++ Dockerfile | |
| @@ -1,111 +1,90 @@ | |
| 1 | # See www/containers.md for documentation on how to use this file. |
| 2 | |
| 3 | ## --------------------------------------------------------------------- |
| 4 | ## STAGE 1: Build static Fossil & BusyBox binaries atop Alpine Linux |
| 5 | ## --------------------------------------------------------------------- |
| 6 | |
| 7 | FROM alpine:latest AS builder |
| 8 | WORKDIR /tmp |
| 9 | |
| 10 | ### Bake the basic Alpine Linux into a base layer so we never have to |
| 11 | ### repeat that step unless we change the package set. Although we're |
| 12 | ### going to throw this layer away below, we still pass --no-cache |
| 13 | ### because that cache is of no use in an immutable layer. Note that |
| 14 | ### we allow the UPX step to fail: it isn't in the ARM distros. We'll |
| 15 | ### check whether this optional piece exists before using it below. |
| 16 | RUN set -x \ |
| 17 | && apk update \ |
| 18 | && apk upgrade --no-cache \ |
| 19 | && apk add --no-cache \ |
| 20 | gcc make moreutils \ |
| 21 | linux-headers musl-dev \ |
| 22 | openssl-dev openssl-libs-static \ |
| 23 | zlib-dev zlib-static \ |
| 24 | ; apk add --no-cache upx |
| 25 | |
| 26 | ### Bake the custom BusyBox into another layer. The intent is that this |
| 27 | ### changes only when we change BBXVER. That will force an update of |
| 28 | ### the layers below, but this is a rare occurrence. |
| 29 | ARG BBXVER="1_35_0" |
| 30 | ENV BBXURL "https://github.com/mirror/busybox/tarball/${BBXVER}" |
| 31 | COPY containers/busybox-config /tmp/bbx/.config |
| 32 | ADD $BBXURL /tmp/bbx/src.tar.gz |
| 33 | RUN set -x \ |
| 34 | && tar --strip-components=1 -C bbx -xzf bbx/src.tar.gz \ |
| 35 | && ( cd bbx && yes "" | make oldconfig && make -j11 ) \ |
| 36 | && if [ -x /usr/bin/upx ] ; then upx -9q bbx/busybox ; fi |
| 37 | |
| 38 | ### The changeable Fossil layer is the only one in the first stage that |
| 39 | ### changes often, so add it last, to make it independent of the others. |
| 40 | ### |
| 41 | ### $FSLSTB can be either a file or a directory due to a ADD's bizarre |
| 42 | ### behavior: it unpacks tarballs when added from a local file but not |
| 43 | ### from a URL! It matters because we default to a URL in case you're |
| 44 | ### building outside a Fossil checkout, but when building via the |
| 45 | ### container-image target, we can avoid a costly hit on the Fossil |
| 46 | ### project's home site by pulling the data from the local repo via the |
| 47 | ### "tarball" command. This is a DVCS, after all! |
| 48 | ARG FSLVER="trunk" |
| 49 | ARG FSLURL="https://fossil-scm.org/home/tarball/src?r=${FSLVER}" |
| 50 | ENV FSLSTB=/tmp/fsl/src.tar.gz |
| 51 | ADD $FSLURL $FSLSTB |
| 52 | RUN set -x \ |
| 53 | && if [ -d $FSLSTB ] ; then mv $FSLSTB/src fsl ; \ |
| 54 | else tar -C fsl -xzf fsl/src.tar.gz ; fi \ |
| 55 | && m=fsl/src/src/main.mk \ |
| 56 | && grep -v '/skins/[a-ce-z]' $m | sponge $m \ |
| 57 | && fsl/src/configure --static CFLAGS='-Os -s' && make -j11 \ |
| 58 | && if [ -x /usr/bin/upx ] ; then upx -9q fossil ; fi |
| 59 | |
| 60 | |
| 61 | ## --------------------------------------------------------------------- |
| 62 | ## STAGE 2: Pare that back to the bare essentials. |
| 63 | ## --------------------------------------------------------------------- |
| 64 | |
| 65 | FROM scratch |
| 66 | WORKDIR /jail |
| 67 | ARG UID=499 |
| 68 | ENV PATH "/bin:/jail/bin" |
| 69 | |
| 70 | ### Lay BusyBox down as the first base layer. Coupled with the host's |
| 71 | ### kernel, this is the "OS." |
| 72 | COPY --from=builder /tmp/bbx/busybox /bin/ |
| 73 | RUN [ "/bin/busybox", "--install", "/bin" ] |
| 74 | |
| 75 | ### Set up that base OS for our specific use without tying it to |
| 76 | ### anything likely to change often. So long as the user leaves |
| 77 | ### UID alone, this layer will be durable. |
| 78 | RUN set -x \ |
| 79 | && echo 'root:x:0:0:SysAdmin:/:/bin/nologin' > /etc/passwd \ |
| 80 | && echo 'root:x:0:root' > /etc/group \ |
| 81 | && addgroup -S -g ${UID} fossil \ |
| 82 | && adduser -S -h `pwd` -g 'Fossil User' -G fossil -u ${UID} fossil \ |
| 83 | && install -d -m 700 -o fossil -g fossil log museum \ |
| 84 | && install -d -m 755 -o fossil -g fossil dev \ |
| 85 | && mknod -m 666 dev/null c 1 3 \ |
| 86 | && mknod -m 444 dev/urandom c 1 9 |
| 87 | |
| 88 | ### Do Fossil-specific things atop those base layers; this will change |
| 89 | ### as often as the Fossil build-from-source layer above. |
| 90 | COPY --from=builder /tmp/fossil bin/ |
| 91 | RUN set -x \ |
| 92 | && ln -s /jail/bin/fossil /bin/f \ |
| 93 | && echo -e '#!/bin/sh\nfossil sha1sum "$@"' > /bin/sha1sum \ |
| 94 | && echo -e '#!/bin/sh\nfossil sha3sum "$@"' > /bin/sha3sum \ |
| 95 | && echo -e '#!/bin/sh\nfossil sqlite3 --no-repository "$@"' > \ |
| 96 | /bin/sqlite3 \ |
| 97 | && chmod +x /bin/sha?sum /bin/sqlite3 |
| 98 | |
| 99 | |
| 100 | ## --------------------------------------------------------------------- |
| 101 | ## STAGE 3: Run! |
| 102 | ## --------------------------------------------------------------------- |
| 103 | |
| 104 | EXPOSE 8080/tcp |
| 105 | CMD [ \ |
| 106 | "bin/fossil", "server", \ |
| 107 | "--chroot", "/jail", \ |
| 108 | "--create", \ |
| 109 | "--jsmode", "bundled", \ |
| 110 | "--user", "admin", \ |
| 111 | "museum/repo.fossil"] |
| 112 |
| --- Dockerfile | |
| +++ Dockerfile | |
| @@ -1,111 +1,90 @@ | |
| 1 | # syntax=docker/dockerfile:1.3 |
| 2 | # See www/containers.md for documentation on how to use this file. |
| 3 | |
| 4 | ## --------------------------------------------------------------------- |
| 5 | ## STAGE 1: Build static Fossil binary |
| 6 | ## --------------------------------------------------------------------- |
| 7 | |
| 8 | ### We aren't pinning to a more stable version of Alpine because we want |
| 9 | ### to build with the latest tools and libraries available in case they |
| 10 | ### fixed something that matters to us since the last build. Everything |
| 11 | ### below depends on this layer, and so, alas, we toss this container's |
| 12 | ### cache on Alpine's release schedule, roughly once a month. |
| 13 | FROM alpine:latest AS bld |
| 14 | WORKDIR /fsl |
| 15 | |
| 16 | ### Bake the basic Alpine Linux into a base layer so it only changes |
| 17 | ### when the upstream image is updated or we change the package set. |
| 18 | RUN set -x \ |
| 19 | && apk update \ |
| 20 | && apk upgrade --no-cache \ |
| 21 | && apk add --no-cache \ |
| 22 | gcc make \ |
| 23 | linux-headers musl-dev \ |
| 24 | openssl-dev openssl-libs-static \ |
| 25 | zlib-dev zlib-static |
| 26 | |
| 27 | ### Build Fossil as a separate layer so we don't have to rebuild the |
| 28 | ### Alpine environment for each iteration of Fossil's dev cycle. |
| 29 | ### |
| 30 | ### We must cope with a bizarre ADD misfeature here: it unpacks tarballs |
| 31 | ### automatically when you give it a local file name but not if you give |
| 32 | ### it a /tarball URL! It matters because we default to a URL in case |
| 33 | ### you're building outside a Fossil checkout, but when building via the |
| 34 | ### container-image target, we avoid a costly hit on fossil-scm.org |
| 35 | ### by leveraging its DVCS nature via the "tarball" command and passing |
| 36 | ### the resulting file's name in. |
| 37 | ARG FSLCFG="" |
| 38 | ARG FSLVER="trunk" |
| 39 | ARG FSLURL="https://fossil-scm.org/home/tarball/src?r=${FSLVER}" |
| 40 | ENV FSLSTB=/fsl/src.tar.gz |
| 41 | ADD $FSLURL $FSLSTB |
| 42 | RUN set -x \ |
| 43 | && if [ -d $FSLSTB ] ; \ |
| 44 | then mv $FSLSTB/src . ; \ |
| 45 | else tar -xf src.tar.gz ; fi \ |
| 46 | && src/configure --static CFLAGS='-Os -s' $FSLCFG && make -j16 |
| 47 | |
| 48 | |
| 49 | ## --------------------------------------------------------------------- |
| 50 | ## STAGE 2: Pare that back to the bare essentials. |
| 51 | ## --------------------------------------------------------------------- |
| 52 | |
| 53 | FROM busybox AS os |
| 54 | ARG UID=499 |
| 55 | |
| 56 | ### Set up that base OS for our specific use without tying it to |
| 57 | ### anything likely to change often. So long as the user leaves |
| 58 | ### UID alone, this layer will be durable. |
| 59 | RUN set -x \ |
| 60 | && mkdir e log museum \ |
| 61 | && echo "root:x:0:0:Admin:/:/false" > /e/passwd \ |
| 62 | && echo "root:x:0:root" > /e/group \ |
| 63 | && echo "fossil:x:${UID}:${UID}:User:/museum:/false" >> /e/passwd \ |
| 64 | && echo "fossil:x:${UID}:fossil" >> /e/group |
| 65 | |
| 66 | |
| 67 | ## --------------------------------------------------------------------- |
| 68 | ## STAGE 3: Drop BusyBox, too, now that we're done with its /bin/sh &c |
| 69 | ## --------------------------------------------------------------------- |
| 70 | |
| 71 | FROM scratch AS run |
| 72 | COPY --from=bld --chmod=755 /fsl/fossil /bin/ |
| 73 | COPY --from=os --chmod=600 /e/* /etc/ |
| 74 | COPY --from=os --chmod=1777 /tmp /tmp/ |
| 75 | COPY --from=os --chown=fossil:fossil /log /log/ |
| 76 | COPY --from=os --chown=fossil:fossil /museum /museum/ |
| 77 | |
| 78 | |
| 79 | ## --------------------------------------------------------------------- |
| 80 | ## RUN! |
| 81 | ## --------------------------------------------------------------------- |
| 82 | |
| 83 | ENV PATH "/bin" |
| 84 | EXPOSE 8080/tcp |
| 85 | USER fossil |
| 86 | ENTRYPOINT [ "fossil", "server", "museum/repo.fossil" ] |
| 87 | CMD [ \ |
| 88 | "--create", \ |
| 89 | "--jsmode", "bundled", \ |
| 90 | "--user", "admin" ] |
| 91 |
+40
-18
| --- Makefile.in | ||
| +++ Makefile.in | ||
| @@ -46,11 +46,11 @@ | ||
| 46 | 46 | |
| 47 | 47 | CFLAGS = @CFLAGS@ |
| 48 | 48 | CFLAGS_INCLUDE = @CFLAGS_INCLUDE@ |
| 49 | 49 | LIB = @LDFLAGS@ @EXTRA_LDFLAGS@ @LIBS@ |
| 50 | 50 | BCCFLAGS = @CPPFLAGS@ $(CFLAGS) |
| 51 | -TCCFLAGS = @EXTRA_CFLAGS@ @CPPFLAGS@ $(CFLAGS) -DHAVE_AUTOCONFIG_H -D_HAVE_SQLITE_CONFIG_H | |
| 51 | +TCCFLAGS = @EXTRA_CFLAGS@ @CPPFLAGS@ $(CFLAGS) -DHAVE_AUTOCONFIG_H | |
| 52 | 52 | # |
| 53 | 53 | # Fuzzing may be enable by appending -fsanitize=fuzzer -DFOSSIL_FUZZ |
| 54 | 54 | # to the TCCFLAGS variable. |
| 55 | 55 | # For more thorouth (but also slower) investigation |
| 56 | 56 | # -fsanitize=fuzzer,undefined,address |
| @@ -119,28 +119,50 @@ | ||
| 119 | 119 | @AUTOREMAKE@ |
| 120 | 120 | touch @builddir@/Makefile |
| 121 | 121 | |
| 122 | 122 | # Container stuff |
| 123 | 123 | SRCTB := src-@[email protected] |
| 124 | +IMGVER := fossil:@FOSSIL_CI_PFX@ | |
| 125 | +CNTVER := fossil-@FOSSIL_CI_PFX@ | |
| 126 | +CENGINE := docker | |
| 127 | +container: | |
| 128 | + $(CENGINE) image inspect $(IMGVER) > /dev/null 2>&1 || \ | |
| 129 | + $(MAKE) container-image | |
| 130 | + $(CENGINE) container inspect $(CNTVER) > /dev/null 2>&1 || \ | |
| 131 | + $(CENGINE) create \ | |
| 132 | + --name $(CNTVER) \ | |
| 133 | + --cap-drop AUDIT_WRITE \ | |
| 134 | + --cap-drop CHOWN \ | |
| 135 | + --cap-drop FSETID \ | |
| 136 | + --cap-drop KILL \ | |
| 137 | + --cap-drop MKNOD \ | |
| 138 | + --cap-drop NET_BIND_SERVICE \ | |
| 139 | + --cap-drop NET_RAW \ | |
| 140 | + --cap-drop SETFCAP \ | |
| 141 | + --cap-drop SETPCAP \ | |
| 142 | + --publish 8080:8080 \ | |
| 143 | + $(DCFLAGS) $(IMGVER) $(DCCMD) | |
| 144 | + | |
| 145 | +container-clean: | |
| 146 | + -$(CENGINE) container kill $(CNTVER) | |
| 147 | + -$(CENGINE) container rm $(CNTVER) | |
| 148 | + -$(CENGINE) image rm $(IMGVER) | |
| 149 | + | |
| 124 | 150 | container-image: |
| 125 | 151 | $(APPNAME) tarball --name src @FOSSIL_CI_PFX@ $(SRCTB) |
| 126 | - docker build \ | |
| 127 | - --tag fossil:@FOSSIL_CI_PFX@ \ | |
| 152 | + $(CENGINE) buildx build \ | |
| 153 | + --load \ | |
| 154 | + --tag $(IMGVER) \ | |
| 128 | 155 | --build-arg FSLURL=$(SRCTB) \ |
| 129 | 156 | $(DBFLAGS) @srcdir@ |
| 130 | 157 | rm -f $(SRCTB) |
| 131 | 158 | |
| 132 | -container-run: container-image | |
| 133 | - docker run \ | |
| 134 | - --name fossil-@FOSSIL_CI_PFX@ \ | |
| 135 | - --cap-drop AUDIT_WRITE \ | |
| 136 | - --cap-drop CHOWN \ | |
| 137 | - --cap-drop FSETID \ | |
| 138 | - --cap-drop KILL \ | |
| 139 | - --cap-drop MKNOD \ | |
| 140 | - --cap-drop NET_BIND_SERVICE \ | |
| 141 | - --cap-drop NET_RAW \ | |
| 142 | - --cap-drop SETFCAP \ | |
| 143 | - --cap-drop SETPCAP \ | |
| 144 | - --detach --publish 8080:8080 \ | |
| 145 | - $(DRFLAGS) fossil:@FOSSIL_CI_PFX@ | |
| 146 | - docker container logs fossil-@FOSSIL_CI_PFX@ | |
| 159 | +container-run container-start: container | |
| 160 | + $(CENGINE) start $(DSFLAGS) $(CNTVER) | |
| 161 | + @sleep 1 # decrease likelihood of logging race condition | |
| 162 | + $(CENGINE) container logs $(CNTVER) | |
| 163 | + | |
| 164 | +container-stop: | |
| 165 | + $(CENGINE) stop $(CNTVER) | |
| 166 | + | |
| 167 | +container-version: | |
| 168 | + @echo $(CNTVER) | |
| 147 | 169 |
| --- Makefile.in | |
| +++ Makefile.in | |
| @@ -46,11 +46,11 @@ | |
| 46 | |
| 47 | CFLAGS = @CFLAGS@ |
| 48 | CFLAGS_INCLUDE = @CFLAGS_INCLUDE@ |
| 49 | LIB = @LDFLAGS@ @EXTRA_LDFLAGS@ @LIBS@ |
| 50 | BCCFLAGS = @CPPFLAGS@ $(CFLAGS) |
| 51 | TCCFLAGS = @EXTRA_CFLAGS@ @CPPFLAGS@ $(CFLAGS) -DHAVE_AUTOCONFIG_H -D_HAVE_SQLITE_CONFIG_H |
| 52 | # |
| 53 | # Fuzzing may be enable by appending -fsanitize=fuzzer -DFOSSIL_FUZZ |
| 54 | # to the TCCFLAGS variable. |
| 55 | # For more thorouth (but also slower) investigation |
| 56 | # -fsanitize=fuzzer,undefined,address |
| @@ -119,28 +119,50 @@ | |
| 119 | @AUTOREMAKE@ |
| 120 | touch @builddir@/Makefile |
| 121 | |
| 122 | # Container stuff |
| 123 | SRCTB := src-@[email protected] |
| 124 | container-image: |
| 125 | $(APPNAME) tarball --name src @FOSSIL_CI_PFX@ $(SRCTB) |
| 126 | docker build \ |
| 127 | --tag fossil:@FOSSIL_CI_PFX@ \ |
| 128 | --build-arg FSLURL=$(SRCTB) \ |
| 129 | $(DBFLAGS) @srcdir@ |
| 130 | rm -f $(SRCTB) |
| 131 | |
| 132 | container-run: container-image |
| 133 | docker run \ |
| 134 | --name fossil-@FOSSIL_CI_PFX@ \ |
| 135 | --cap-drop AUDIT_WRITE \ |
| 136 | --cap-drop CHOWN \ |
| 137 | --cap-drop FSETID \ |
| 138 | --cap-drop KILL \ |
| 139 | --cap-drop MKNOD \ |
| 140 | --cap-drop NET_BIND_SERVICE \ |
| 141 | --cap-drop NET_RAW \ |
| 142 | --cap-drop SETFCAP \ |
| 143 | --cap-drop SETPCAP \ |
| 144 | --detach --publish 8080:8080 \ |
| 145 | $(DRFLAGS) fossil:@FOSSIL_CI_PFX@ |
| 146 | docker container logs fossil-@FOSSIL_CI_PFX@ |
| 147 |
| --- Makefile.in | |
| +++ Makefile.in | |
| @@ -46,11 +46,11 @@ | |
| 46 | |
| 47 | CFLAGS = @CFLAGS@ |
| 48 | CFLAGS_INCLUDE = @CFLAGS_INCLUDE@ |
| 49 | LIB = @LDFLAGS@ @EXTRA_LDFLAGS@ @LIBS@ |
| 50 | BCCFLAGS = @CPPFLAGS@ $(CFLAGS) |
| 51 | TCCFLAGS = @EXTRA_CFLAGS@ @CPPFLAGS@ $(CFLAGS) -DHAVE_AUTOCONFIG_H |
| 52 | # |
| 53 | # Fuzzing may be enable by appending -fsanitize=fuzzer -DFOSSIL_FUZZ |
| 54 | # to the TCCFLAGS variable. |
| 55 | # For more thorouth (but also slower) investigation |
| 56 | # -fsanitize=fuzzer,undefined,address |
| @@ -119,28 +119,50 @@ | |
| 119 | @AUTOREMAKE@ |
| 120 | touch @builddir@/Makefile |
| 121 | |
| 122 | # Container stuff |
| 123 | SRCTB := src-@[email protected] |
| 124 | IMGVER := fossil:@FOSSIL_CI_PFX@ |
| 125 | CNTVER := fossil-@FOSSIL_CI_PFX@ |
| 126 | CENGINE := docker |
| 127 | container: |
| 128 | $(CENGINE) image inspect $(IMGVER) > /dev/null 2>&1 || \ |
| 129 | $(MAKE) container-image |
| 130 | $(CENGINE) container inspect $(CNTVER) > /dev/null 2>&1 || \ |
| 131 | $(CENGINE) create \ |
| 132 | --name $(CNTVER) \ |
| 133 | --cap-drop AUDIT_WRITE \ |
| 134 | --cap-drop CHOWN \ |
| 135 | --cap-drop FSETID \ |
| 136 | --cap-drop KILL \ |
| 137 | --cap-drop MKNOD \ |
| 138 | --cap-drop NET_BIND_SERVICE \ |
| 139 | --cap-drop NET_RAW \ |
| 140 | --cap-drop SETFCAP \ |
| 141 | --cap-drop SETPCAP \ |
| 142 | --publish 8080:8080 \ |
| 143 | $(DCFLAGS) $(IMGVER) $(DCCMD) |
| 144 | |
| 145 | container-clean: |
| 146 | -$(CENGINE) container kill $(CNTVER) |
| 147 | -$(CENGINE) container rm $(CNTVER) |
| 148 | -$(CENGINE) image rm $(IMGVER) |
| 149 | |
| 150 | container-image: |
| 151 | $(APPNAME) tarball --name src @FOSSIL_CI_PFX@ $(SRCTB) |
| 152 | $(CENGINE) buildx build \ |
| 153 | --load \ |
| 154 | --tag $(IMGVER) \ |
| 155 | --build-arg FSLURL=$(SRCTB) \ |
| 156 | $(DBFLAGS) @srcdir@ |
| 157 | rm -f $(SRCTB) |
| 158 | |
| 159 | container-run container-start: container |
| 160 | $(CENGINE) start $(DSFLAGS) $(CNTVER) |
| 161 | @sleep 1 # decrease likelihood of logging race condition |
| 162 | $(CENGINE) container logs $(CNTVER) |
| 163 | |
| 164 | container-stop: |
| 165 | $(CENGINE) stop $(CNTVER) |
| 166 | |
| 167 | container-version: |
| 168 | @echo $(CNTVER) |
| 169 |
M
VERSION
+1
-1
| --- VERSION | ||
| +++ VERSION | ||
| @@ -1,1 +1,1 @@ | ||
| 1 | -2.20 | |
| 1 | +2.22 | |
| 2 | 2 |
| --- VERSION | |
| +++ VERSION | |
| @@ -1,1 +1,1 @@ | |
| 1 | 2.20 |
| 2 |
| --- VERSION | |
| +++ VERSION | |
| @@ -1,1 +1,1 @@ | |
| 1 | 2.22 |
| 2 |
+3
-39
| --- compat/zlib/CMakeLists.txt | ||
| +++ compat/zlib/CMakeLists.txt | ||
| @@ -1,14 +1,11 @@ | ||
| 1 | 1 | cmake_minimum_required(VERSION 2.4.4) |
| 2 | 2 | set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) |
| 3 | 3 | |
| 4 | 4 | project(zlib C) |
| 5 | 5 | |
| 6 | -set(VERSION "1.2.12") | |
| 7 | - | |
| 8 | -option(ASM686 "Enable building i686 assembly implementation") | |
| 9 | -option(AMD64 "Enable building amd64 assembly implementation") | |
| 6 | +set(VERSION "1.2.13") | |
| 10 | 7 | |
| 11 | 8 | set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") |
| 12 | 9 | set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") |
| 13 | 10 | set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") |
| 14 | 11 | set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages") |
| @@ -127,43 +124,10 @@ | ||
| 127 | 124 | set(ZLIB_DLL_SRCS |
| 128 | 125 | win32/zlib1.rc # If present will override custom build rule below. |
| 129 | 126 | ) |
| 130 | 127 | endif() |
| 131 | 128 | |
| 132 | -if(CMAKE_COMPILER_IS_GNUCC) | |
| 133 | - if(ASM686) | |
| 134 | - set(ZLIB_ASMS contrib/asm686/match.S) | |
| 135 | - elseif (AMD64) | |
| 136 | - set(ZLIB_ASMS contrib/amd64/amd64-match.S) | |
| 137 | - endif () | |
| 138 | - | |
| 139 | - if(ZLIB_ASMS) | |
| 140 | - add_definitions(-DASMV) | |
| 141 | - set_source_files_properties(${ZLIB_ASMS} PROPERTIES LANGUAGE C COMPILE_FLAGS -DNO_UNDERLINE) | |
| 142 | - endif() | |
| 143 | -endif() | |
| 144 | - | |
| 145 | -if(MSVC) | |
| 146 | - if(ASM686) | |
| 147 | - ENABLE_LANGUAGE(ASM_MASM) | |
| 148 | - set(ZLIB_ASMS | |
| 149 | - contrib/masmx86/inffas32.asm | |
| 150 | - contrib/masmx86/match686.asm | |
| 151 | - ) | |
| 152 | - elseif (AMD64) | |
| 153 | - ENABLE_LANGUAGE(ASM_MASM) | |
| 154 | - set(ZLIB_ASMS | |
| 155 | - contrib/masmx64/gvmat64.asm | |
| 156 | - contrib/masmx64/inffasx64.asm | |
| 157 | - ) | |
| 158 | - endif() | |
| 159 | - | |
| 160 | - if(ZLIB_ASMS) | |
| 161 | - add_definitions(-DASMV -DASMINF) | |
| 162 | - endif() | |
| 163 | -endif() | |
| 164 | - | |
| 165 | 129 | # parse the full version number from zlib.h and include in ZLIB_FULL_VERSION |
| 166 | 130 | file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents) |
| 167 | 131 | string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" |
| 168 | 132 | "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) |
| 169 | 133 | |
| @@ -181,12 +145,12 @@ | ||
| 181 | 145 | -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj |
| 182 | 146 | -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc) |
| 183 | 147 | set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) |
| 184 | 148 | endif(MINGW) |
| 185 | 149 | |
| 186 | -add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) | |
| 187 | -add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) | |
| 150 | +add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) | |
| 151 | +add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) | |
| 188 | 152 | set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) |
| 189 | 153 | set_target_properties(zlib PROPERTIES SOVERSION 1) |
| 190 | 154 | |
| 191 | 155 | if(NOT CYGWIN) |
| 192 | 156 | # This property causes shared libraries on Linux to have the full version |
| 193 | 157 |
| --- compat/zlib/CMakeLists.txt | |
| +++ compat/zlib/CMakeLists.txt | |
| @@ -1,14 +1,11 @@ | |
| 1 | cmake_minimum_required(VERSION 2.4.4) |
| 2 | set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) |
| 3 | |
| 4 | project(zlib C) |
| 5 | |
| 6 | set(VERSION "1.2.12") |
| 7 | |
| 8 | option(ASM686 "Enable building i686 assembly implementation") |
| 9 | option(AMD64 "Enable building amd64 assembly implementation") |
| 10 | |
| 11 | set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") |
| 12 | set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") |
| 13 | set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") |
| 14 | set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages") |
| @@ -127,43 +124,10 @@ | |
| 127 | set(ZLIB_DLL_SRCS |
| 128 | win32/zlib1.rc # If present will override custom build rule below. |
| 129 | ) |
| 130 | endif() |
| 131 | |
| 132 | if(CMAKE_COMPILER_IS_GNUCC) |
| 133 | if(ASM686) |
| 134 | set(ZLIB_ASMS contrib/asm686/match.S) |
| 135 | elseif (AMD64) |
| 136 | set(ZLIB_ASMS contrib/amd64/amd64-match.S) |
| 137 | endif () |
| 138 | |
| 139 | if(ZLIB_ASMS) |
| 140 | add_definitions(-DASMV) |
| 141 | set_source_files_properties(${ZLIB_ASMS} PROPERTIES LANGUAGE C COMPILE_FLAGS -DNO_UNDERLINE) |
| 142 | endif() |
| 143 | endif() |
| 144 | |
| 145 | if(MSVC) |
| 146 | if(ASM686) |
| 147 | ENABLE_LANGUAGE(ASM_MASM) |
| 148 | set(ZLIB_ASMS |
| 149 | contrib/masmx86/inffas32.asm |
| 150 | contrib/masmx86/match686.asm |
| 151 | ) |
| 152 | elseif (AMD64) |
| 153 | ENABLE_LANGUAGE(ASM_MASM) |
| 154 | set(ZLIB_ASMS |
| 155 | contrib/masmx64/gvmat64.asm |
| 156 | contrib/masmx64/inffasx64.asm |
| 157 | ) |
| 158 | endif() |
| 159 | |
| 160 | if(ZLIB_ASMS) |
| 161 | add_definitions(-DASMV -DASMINF) |
| 162 | endif() |
| 163 | endif() |
| 164 | |
| 165 | # parse the full version number from zlib.h and include in ZLIB_FULL_VERSION |
| 166 | file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents) |
| 167 | string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" |
| 168 | "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) |
| 169 | |
| @@ -181,12 +145,12 @@ | |
| 181 | -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj |
| 182 | -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc) |
| 183 | set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) |
| 184 | endif(MINGW) |
| 185 | |
| 186 | add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) |
| 187 | add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) |
| 188 | set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) |
| 189 | set_target_properties(zlib PROPERTIES SOVERSION 1) |
| 190 | |
| 191 | if(NOT CYGWIN) |
| 192 | # This property causes shared libraries on Linux to have the full version |
| 193 |
| --- compat/zlib/CMakeLists.txt | |
| +++ compat/zlib/CMakeLists.txt | |
| @@ -1,14 +1,11 @@ | |
| 1 | cmake_minimum_required(VERSION 2.4.4) |
| 2 | set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) |
| 3 | |
| 4 | project(zlib C) |
| 5 | |
| 6 | set(VERSION "1.2.13") |
| 7 | |
| 8 | set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") |
| 9 | set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") |
| 10 | set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") |
| 11 | set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages") |
| @@ -127,43 +124,10 @@ | |
| 124 | set(ZLIB_DLL_SRCS |
| 125 | win32/zlib1.rc # If present will override custom build rule below. |
| 126 | ) |
| 127 | endif() |
| 128 | |
| 129 | # parse the full version number from zlib.h and include in ZLIB_FULL_VERSION |
| 130 | file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents) |
| 131 | string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" |
| 132 | "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) |
| 133 | |
| @@ -181,12 +145,12 @@ | |
| 145 | -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj |
| 146 | -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc) |
| 147 | set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) |
| 148 | endif(MINGW) |
| 149 | |
| 150 | add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) |
| 151 | add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) |
| 152 | set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) |
| 153 | set_target_properties(zlib PROPERTIES SOVERSION 1) |
| 154 | |
| 155 | if(NOT CYGWIN) |
| 156 | # This property causes shared libraries on Linux to have the full version |
| 157 |
+18
-6
| --- compat/zlib/ChangeLog | ||
| +++ compat/zlib/ChangeLog | ||
| @@ -1,8 +1,20 @@ | ||
| 1 | 1 | |
| 2 | 2 | ChangeLog file for zlib |
| 3 | 3 | |
| 4 | +Changes in 1.2.13 (13 Oct 2022) | |
| 5 | +- Fix configure issue that discarded provided CC definition | |
| 6 | +- Correct incorrect inputs provided to the CRC functions | |
| 7 | +- Repair prototypes and exporting of new CRC functions | |
| 8 | +- Fix inflateBack to detect invalid input with distances too far | |
| 9 | +- Have infback() deliver all of the available output up to any error | |
| 10 | +- Fix a bug when getting a gzip header extra field with inflate() | |
| 11 | +- Fix bug in block type selection when Z_FIXED used | |
| 12 | +- Tighten deflateBound bounds | |
| 13 | +- Remove deleted assembler code references | |
| 14 | +- Various portability and appearance improvements | |
| 15 | + | |
| 4 | 16 | Changes in 1.2.12 (27 Mar 2022) |
| 5 | 17 | - Cygwin does not have _wopen(), so do not create gzopen_w() there |
| 6 | 18 | - Permit a deflateParams() parameter change as soon as possible |
| 7 | 19 | - Limit hash table inserts after switch from stored deflate |
| 8 | 20 | - Fix bug when window full in deflate_stored() |
| @@ -157,11 +169,11 @@ | ||
| 157 | 169 | - Don't specify --version-script on Apple platforms in CMakeLists.txt |
| 158 | 170 | - Fix casting error in contrib/testzlib/testzlib.c |
| 159 | 171 | - Fix types in contrib/minizip to match result of get_crc_table() |
| 160 | 172 | - Simplify contrib/vstudio/vc10 with 'd' suffix |
| 161 | 173 | - Add TOP support to win32/Makefile.msc |
| 162 | -- Suport i686 and amd64 assembler builds in CMakeLists.txt | |
| 174 | +- Support i686 and amd64 assembler builds in CMakeLists.txt | |
| 163 | 175 | - Fix typos in the use of _LARGEFILE64_SOURCE in zconf.h |
| 164 | 176 | - Add vc11 and vc12 build files to contrib/vstudio |
| 165 | 177 | - Add gzvprintf() as an undocumented function in zlib |
| 166 | 178 | - Fix configure for Sun shell |
| 167 | 179 | - Remove runtime check in configure for four-byte integer type |
| @@ -357,18 +369,18 @@ | ||
| 357 | 369 | - Clarify the use of Z_FINISH with deflateBound() amount of space |
| 358 | 370 | - Set binary for output file in puff.c |
| 359 | 371 | - Use u4 type for crc_table to avoid conversion warnings |
| 360 | 372 | - Apply casts in zlib.h to avoid conversion warnings |
| 361 | 373 | - Add OF to prototypes for adler32_combine_ and crc32_combine_ [Miller] |
| 362 | -- Improve inflateSync() documentation to note indeterminancy | |
| 374 | +- Improve inflateSync() documentation to note indeterminacy | |
| 363 | 375 | - Add deflatePending() function to return the amount of pending output |
| 364 | 376 | - Correct the spelling of "specification" in FAQ [Randers-Pehrson] |
| 365 | 377 | - Add a check in configure for stdarg.h, use for gzprintf() |
| 366 | 378 | - Check that pointers fit in ints when gzprint() compiled old style |
| 367 | 379 | - Add dummy name before $(SHAREDLIBV) in Makefile [Bar-Lev, Bowler] |
| 368 | 380 | - Delete line in configure that adds -L. libz.a to LDFLAGS [Weigelt] |
| 369 | -- Add debug records in assmebler code [Londer] | |
| 381 | +- Add debug records in assembler code [Londer] | |
| 370 | 382 | - Update RFC references to use http://tools.ietf.org/html/... [Li] |
| 371 | 383 | - Add --archs option, use of libtool to configure for Mac OS X [Borstel] |
| 372 | 384 | |
| 373 | 385 | Changes in 1.2.5 (19 Apr 2010) |
| 374 | 386 | - Disable visibility attribute in win32/Makefile.gcc [Bar-Lev] |
| @@ -1031,11 +1043,11 @@ | ||
| 1031 | 1043 | - Refine detection of Turbo C need for dummy returns |
| 1032 | 1044 | - Refine ZLIB_DLL compilation |
| 1033 | 1045 | - Include additional header file on VMS for off_t typedef |
| 1034 | 1046 | - Try to use _vsnprintf where it supplants vsprintf [Vollant] |
| 1035 | 1047 | - Add some casts in inffast.c |
| 1036 | -- Enchance comments in zlib.h on what happens if gzprintf() tries to | |
| 1048 | +- Enhance comments in zlib.h on what happens if gzprintf() tries to | |
| 1037 | 1049 | write more than 4095 bytes before compression |
| 1038 | 1050 | - Remove unused state from inflateBackEnd() |
| 1039 | 1051 | - Remove exit(0) from minigzip.c, example.c |
| 1040 | 1052 | - Get rid of all those darn tabs |
| 1041 | 1053 | - Add "check" target to Makefile.in that does the same thing as "test" |
| @@ -1209,11 +1221,11 @@ | ||
| 1209 | 1221 | . Simplify Z_FINISH check in inflate() |
| 1210 | 1222 | |
| 1211 | 1223 | - Avoid gcc 2.8.0 comparison bug a little differently than zlib 1.0.8 |
| 1212 | 1224 | - in inftrees.c, avoid cc -O bug on HP (Farshid Elahi) |
| 1213 | 1225 | - in zconf.h move the ZLIB_DLL stuff earlier to avoid problems with |
| 1214 | - the declaration of FAR (Gilles VOllant) | |
| 1226 | + the declaration of FAR (Gilles Vollant) | |
| 1215 | 1227 | - install libz.so* with mode 755 (executable) instead of 644 (Marc Lehmann) |
| 1216 | 1228 | - read_buf buf parameter of type Bytef* instead of charf* |
| 1217 | 1229 | - zmemcpy parameters are of type Bytef*, not charf* (Joseph Strout) |
| 1218 | 1230 | - do not redeclare unlink in minigzip.c for WIN32 (John Bowler) |
| 1219 | 1231 | - fix check for presence of directories in "make install" (Ian Willis) |
| @@ -1565,14 +1577,14 @@ | ||
| 1565 | 1577 | if compression method == 8 |
| 1566 | 1578 | - added adler32 and crc32 |
| 1567 | 1579 | - renamed deflateOptions as deflateInit2, call one or the other but not both |
| 1568 | 1580 | - added the method parameter for deflateInit2 |
| 1569 | 1581 | - added inflateInit2 |
| 1570 | -- simplied considerably deflateInit and inflateInit by not supporting | |
| 1582 | +- simplified considerably deflateInit and inflateInit by not supporting | |
| 1571 | 1583 | user-provided history buffer. This is supported only in deflateInit2 |
| 1572 | 1584 | and inflateInit2 |
| 1573 | 1585 | |
| 1574 | 1586 | Changes in 0.3: |
| 1575 | 1587 | - prefix all macro names with Z_ |
| 1576 | 1588 | - use Z_FINISH instead of deflateEnd to finish compression |
| 1577 | 1589 | - added Z_HUFFMAN_ONLY |
| 1578 | 1590 | - added gzerror() |
| 1579 | 1591 | |
| 1580 | 1592 | ADDED compat/zlib/LICENSE |
| --- compat/zlib/ChangeLog | |
| +++ compat/zlib/ChangeLog | |
| @@ -1,8 +1,20 @@ | |
| 1 | |
| 2 | ChangeLog file for zlib |
| 3 | |
| 4 | Changes in 1.2.12 (27 Mar 2022) |
| 5 | - Cygwin does not have _wopen(), so do not create gzopen_w() there |
| 6 | - Permit a deflateParams() parameter change as soon as possible |
| 7 | - Limit hash table inserts after switch from stored deflate |
| 8 | - Fix bug when window full in deflate_stored() |
| @@ -157,11 +169,11 @@ | |
| 157 | - Don't specify --version-script on Apple platforms in CMakeLists.txt |
| 158 | - Fix casting error in contrib/testzlib/testzlib.c |
| 159 | - Fix types in contrib/minizip to match result of get_crc_table() |
| 160 | - Simplify contrib/vstudio/vc10 with 'd' suffix |
| 161 | - Add TOP support to win32/Makefile.msc |
| 162 | - Suport i686 and amd64 assembler builds in CMakeLists.txt |
| 163 | - Fix typos in the use of _LARGEFILE64_SOURCE in zconf.h |
| 164 | - Add vc11 and vc12 build files to contrib/vstudio |
| 165 | - Add gzvprintf() as an undocumented function in zlib |
| 166 | - Fix configure for Sun shell |
| 167 | - Remove runtime check in configure for four-byte integer type |
| @@ -357,18 +369,18 @@ | |
| 357 | - Clarify the use of Z_FINISH with deflateBound() amount of space |
| 358 | - Set binary for output file in puff.c |
| 359 | - Use u4 type for crc_table to avoid conversion warnings |
| 360 | - Apply casts in zlib.h to avoid conversion warnings |
| 361 | - Add OF to prototypes for adler32_combine_ and crc32_combine_ [Miller] |
| 362 | - Improve inflateSync() documentation to note indeterminancy |
| 363 | - Add deflatePending() function to return the amount of pending output |
| 364 | - Correct the spelling of "specification" in FAQ [Randers-Pehrson] |
| 365 | - Add a check in configure for stdarg.h, use for gzprintf() |
| 366 | - Check that pointers fit in ints when gzprint() compiled old style |
| 367 | - Add dummy name before $(SHAREDLIBV) in Makefile [Bar-Lev, Bowler] |
| 368 | - Delete line in configure that adds -L. libz.a to LDFLAGS [Weigelt] |
| 369 | - Add debug records in assmebler code [Londer] |
| 370 | - Update RFC references to use http://tools.ietf.org/html/... [Li] |
| 371 | - Add --archs option, use of libtool to configure for Mac OS X [Borstel] |
| 372 | |
| 373 | Changes in 1.2.5 (19 Apr 2010) |
| 374 | - Disable visibility attribute in win32/Makefile.gcc [Bar-Lev] |
| @@ -1031,11 +1043,11 @@ | |
| 1031 | - Refine detection of Turbo C need for dummy returns |
| 1032 | - Refine ZLIB_DLL compilation |
| 1033 | - Include additional header file on VMS for off_t typedef |
| 1034 | - Try to use _vsnprintf where it supplants vsprintf [Vollant] |
| 1035 | - Add some casts in inffast.c |
| 1036 | - Enchance comments in zlib.h on what happens if gzprintf() tries to |
| 1037 | write more than 4095 bytes before compression |
| 1038 | - Remove unused state from inflateBackEnd() |
| 1039 | - Remove exit(0) from minigzip.c, example.c |
| 1040 | - Get rid of all those darn tabs |
| 1041 | - Add "check" target to Makefile.in that does the same thing as "test" |
| @@ -1209,11 +1221,11 @@ | |
| 1209 | . Simplify Z_FINISH check in inflate() |
| 1210 | |
| 1211 | - Avoid gcc 2.8.0 comparison bug a little differently than zlib 1.0.8 |
| 1212 | - in inftrees.c, avoid cc -O bug on HP (Farshid Elahi) |
| 1213 | - in zconf.h move the ZLIB_DLL stuff earlier to avoid problems with |
| 1214 | the declaration of FAR (Gilles VOllant) |
| 1215 | - install libz.so* with mode 755 (executable) instead of 644 (Marc Lehmann) |
| 1216 | - read_buf buf parameter of type Bytef* instead of charf* |
| 1217 | - zmemcpy parameters are of type Bytef*, not charf* (Joseph Strout) |
| 1218 | - do not redeclare unlink in minigzip.c for WIN32 (John Bowler) |
| 1219 | - fix check for presence of directories in "make install" (Ian Willis) |
| @@ -1565,14 +1577,14 @@ | |
| 1565 | if compression method == 8 |
| 1566 | - added adler32 and crc32 |
| 1567 | - renamed deflateOptions as deflateInit2, call one or the other but not both |
| 1568 | - added the method parameter for deflateInit2 |
| 1569 | - added inflateInit2 |
| 1570 | - simplied considerably deflateInit and inflateInit by not supporting |
| 1571 | user-provided history buffer. This is supported only in deflateInit2 |
| 1572 | and inflateInit2 |
| 1573 | |
| 1574 | Changes in 0.3: |
| 1575 | - prefix all macro names with Z_ |
| 1576 | - use Z_FINISH instead of deflateEnd to finish compression |
| 1577 | - added Z_HUFFMAN_ONLY |
| 1578 | - added gzerror() |
| 1579 | |
| 1580 | DDED compat/zlib/LICENSE |
| --- compat/zlib/ChangeLog | |
| +++ compat/zlib/ChangeLog | |
| @@ -1,8 +1,20 @@ | |
| 1 | |
| 2 | ChangeLog file for zlib |
| 3 | |
| 4 | Changes in 1.2.13 (13 Oct 2022) |
| 5 | - Fix configure issue that discarded provided CC definition |
| 6 | - Correct incorrect inputs provided to the CRC functions |
| 7 | - Repair prototypes and exporting of new CRC functions |
| 8 | - Fix inflateBack to detect invalid input with distances too far |
| 9 | - Have infback() deliver all of the available output up to any error |
| 10 | - Fix a bug when getting a gzip header extra field with inflate() |
| 11 | - Fix bug in block type selection when Z_FIXED used |
| 12 | - Tighten deflateBound bounds |
| 13 | - Remove deleted assembler code references |
| 14 | - Various portability and appearance improvements |
| 15 | |
| 16 | Changes in 1.2.12 (27 Mar 2022) |
| 17 | - Cygwin does not have _wopen(), so do not create gzopen_w() there |
| 18 | - Permit a deflateParams() parameter change as soon as possible |
| 19 | - Limit hash table inserts after switch from stored deflate |
| 20 | - Fix bug when window full in deflate_stored() |
| @@ -157,11 +169,11 @@ | |
| 169 | - Don't specify --version-script on Apple platforms in CMakeLists.txt |
| 170 | - Fix casting error in contrib/testzlib/testzlib.c |
| 171 | - Fix types in contrib/minizip to match result of get_crc_table() |
| 172 | - Simplify contrib/vstudio/vc10 with 'd' suffix |
| 173 | - Add TOP support to win32/Makefile.msc |
| 174 | - Support i686 and amd64 assembler builds in CMakeLists.txt |
| 175 | - Fix typos in the use of _LARGEFILE64_SOURCE in zconf.h |
| 176 | - Add vc11 and vc12 build files to contrib/vstudio |
| 177 | - Add gzvprintf() as an undocumented function in zlib |
| 178 | - Fix configure for Sun shell |
| 179 | - Remove runtime check in configure for four-byte integer type |
| @@ -357,18 +369,18 @@ | |
| 369 | - Clarify the use of Z_FINISH with deflateBound() amount of space |
| 370 | - Set binary for output file in puff.c |
| 371 | - Use u4 type for crc_table to avoid conversion warnings |
| 372 | - Apply casts in zlib.h to avoid conversion warnings |
| 373 | - Add OF to prototypes for adler32_combine_ and crc32_combine_ [Miller] |
| 374 | - Improve inflateSync() documentation to note indeterminacy |
| 375 | - Add deflatePending() function to return the amount of pending output |
| 376 | - Correct the spelling of "specification" in FAQ [Randers-Pehrson] |
| 377 | - Add a check in configure for stdarg.h, use for gzprintf() |
| 378 | - Check that pointers fit in ints when gzprint() compiled old style |
| 379 | - Add dummy name before $(SHAREDLIBV) in Makefile [Bar-Lev, Bowler] |
| 380 | - Delete line in configure that adds -L. libz.a to LDFLAGS [Weigelt] |
| 381 | - Add debug records in assembler code [Londer] |
| 382 | - Update RFC references to use http://tools.ietf.org/html/... [Li] |
| 383 | - Add --archs option, use of libtool to configure for Mac OS X [Borstel] |
| 384 | |
| 385 | Changes in 1.2.5 (19 Apr 2010) |
| 386 | - Disable visibility attribute in win32/Makefile.gcc [Bar-Lev] |
| @@ -1031,11 +1043,11 @@ | |
| 1043 | - Refine detection of Turbo C need for dummy returns |
| 1044 | - Refine ZLIB_DLL compilation |
| 1045 | - Include additional header file on VMS for off_t typedef |
| 1046 | - Try to use _vsnprintf where it supplants vsprintf [Vollant] |
| 1047 | - Add some casts in inffast.c |
| 1048 | - Enhance comments in zlib.h on what happens if gzprintf() tries to |
| 1049 | write more than 4095 bytes before compression |
| 1050 | - Remove unused state from inflateBackEnd() |
| 1051 | - Remove exit(0) from minigzip.c, example.c |
| 1052 | - Get rid of all those darn tabs |
| 1053 | - Add "check" target to Makefile.in that does the same thing as "test" |
| @@ -1209,11 +1221,11 @@ | |
| 1221 | . Simplify Z_FINISH check in inflate() |
| 1222 | |
| 1223 | - Avoid gcc 2.8.0 comparison bug a little differently than zlib 1.0.8 |
| 1224 | - in inftrees.c, avoid cc -O bug on HP (Farshid Elahi) |
| 1225 | - in zconf.h move the ZLIB_DLL stuff earlier to avoid problems with |
| 1226 | the declaration of FAR (Gilles Vollant) |
| 1227 | - install libz.so* with mode 755 (executable) instead of 644 (Marc Lehmann) |
| 1228 | - read_buf buf parameter of type Bytef* instead of charf* |
| 1229 | - zmemcpy parameters are of type Bytef*, not charf* (Joseph Strout) |
| 1230 | - do not redeclare unlink in minigzip.c for WIN32 (John Bowler) |
| 1231 | - fix check for presence of directories in "make install" (Ian Willis) |
| @@ -1565,14 +1577,14 @@ | |
| 1577 | if compression method == 8 |
| 1578 | - added adler32 and crc32 |
| 1579 | - renamed deflateOptions as deflateInit2, call one or the other but not both |
| 1580 | - added the method parameter for deflateInit2 |
| 1581 | - added inflateInit2 |
| 1582 | - simplified considerably deflateInit and inflateInit by not supporting |
| 1583 | user-provided history buffer. This is supported only in deflateInit2 |
| 1584 | and inflateInit2 |
| 1585 | |
| 1586 | Changes in 0.3: |
| 1587 | - prefix all macro names with Z_ |
| 1588 | - use Z_FINISH instead of deflateEnd to finish compression |
| 1589 | - added Z_HUFFMAN_ONLY |
| 1590 | - added gzerror() |
| 1591 | |
| 1592 | DDED compat/zlib/LICENSE |
+22
| --- a/compat/zlib/LICENSE | ||
| +++ b/compat/zlib/LICENSE | ||
| @@ -0,0 +1,22 @@ | ||
| 1 | +Copyright notice: | |
| 2 | + | |
| 3 | + (C) 1995-2022 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 | + [email protected] |
| --- a/compat/zlib/LICENSE | |
| +++ b/compat/zlib/LICENSE | |
| @@ -0,0 +1,22 @@ | |
| --- a/compat/zlib/LICENSE | |
| +++ b/compat/zlib/LICENSE | |
| @@ -0,0 +1,22 @@ | |
| 1 | Copyright notice: |
| 2 | |
| 3 | (C) 1995-2022 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 | [email protected] |
+5
-408
| --- compat/zlib/Makefile | ||
| +++ compat/zlib/Makefile | ||
| @@ -1,408 +1,5 @@ | ||
| 1 | -# Makefile for zlib | |
| 2 | -# Copyright (C) 1995-2017 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 use the asm code, type: | |
| 11 | -# cp contrib/asm?86/match.S ./match.S | |
| 12 | -# make LOC=-DASMV OBJA=match.o | |
| 13 | - | |
| 14 | -# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type: | |
| 15 | -# make install | |
| 16 | -# To install in $HOME instead of /usr/local, use: | |
| 17 | -# make install prefix=$HOME | |
| 18 | - | |
| 19 | -CC=gcc | |
| 20 | - | |
| 21 | -CFLAGS=-O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN | |
| 22 | -#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 | |
| 23 | -#CFLAGS=-g -DZLIB_DEBUG | |
| 24 | -#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ | |
| 25 | -# -Wstrict-prototypes -Wmissing-prototypes | |
| 26 | - | |
| 27 | -SFLAGS=-O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN | |
| 28 | -LDFLAGS= | |
| 29 | -TEST_LDFLAGS=-L. libz.a | |
| 30 | -LDSHARED=gcc | |
| 31 | -CPP=gcc -E | |
| 32 | - | |
| 33 | -STATICLIB=libz.a | |
| 34 | -SHAREDLIB= | |
| 35 | -SHAREDLIBV= | |
| 36 | -SHAREDLIBM= | |
| 37 | -LIBS=$(STATICLIB) $(SHAREDLIBV) | |
| 38 | - | |
| 39 | -AR=ar | |
| 40 | -ARFLAGS=rc | |
| 41 | -RANLIB=ranlib | |
| 42 | -LDCONFIG=ldconfig | |
| 43 | -LDSHAREDLIBC=-lc | |
| 44 | -TAR=tar | |
| 45 | -SHELL=/bin/sh | |
| 46 | -EXE= | |
| 47 | - | |
| 48 | -prefix =/usr/local | |
| 49 | -exec_prefix =${prefix} | |
| 50 | -libdir =${exec_prefix}/lib | |
| 51 | -sharedlibdir =${libdir} | |
| 52 | -includedir =${prefix}/include | |
| 53 | -mandir =${prefix}/share/man | |
| 54 | -man3dir = ${mandir}/man3 | |
| 55 | -pkgconfigdir = ${libdir}/pkgconfig | |
| 56 | -SRCDIR= | |
| 57 | -ZINC= | |
| 58 | -ZINCOUT=-I. | |
| 59 | - | |
| 60 | -OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o | |
| 61 | -OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o | |
| 62 | -OBJC = $(OBJZ) $(OBJG) | |
| 63 | - | |
| 64 | -PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo | |
| 65 | -PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo | |
| 66 | -PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG) | |
| 67 | - | |
| 68 | -# to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo | |
| 69 | -OBJA = | |
| 70 | -PIC_OBJA = | |
| 71 | - | |
| 72 | -OBJS = $(OBJC) $(OBJA) | |
| 73 | - | |
| 74 | -PIC_OBJS = $(PIC_OBJC) $(PIC_OBJA) | |
| 75 | - | |
| 76 | -all: static all64 | |
| 77 | - | |
| 78 | -static: example$(EXE) minigzip$(EXE) | |
| 79 | - | |
| 80 | -shared: examplesh$(EXE) minigzipsh$(EXE) | |
| 81 | - | |
| 82 | -all64: example64$(EXE) minigzip64$(EXE) | |
| 83 | - | |
| 84 | -check: test | |
| 85 | - | |
| 86 | -test: all teststatic test64 | |
| 87 | - | |
| 88 | -teststatic: static | |
| 89 | - @TMPST=tmpst_$$; \ | |
| 90 | - if echo hello world | ./minigzip | ./minigzip -d && ./example $$TMPST ; then \ | |
| 91 | - echo ' *** zlib test OK ***'; \ | |
| 92 | - else \ | |
| 93 | - echo ' *** zlib test FAILED ***'; false; \ | |
| 94 | - fi | |
| 95 | - @rm -f tmpst_$$ | |
| 96 | - | |
| 97 | -testshared: shared | |
| 98 | - @LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ | |
| 99 | - LD_LIBRARYN32_PATH=`pwd`:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \ | |
| 100 | - DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \ | |
| 101 | - SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \ | |
| 102 | - TMPSH=tmpsh_$$; \ | |
| 103 | - if echo hello world | ./minigzipsh | ./minigzipsh -d && ./examplesh $$TMPSH; then \ | |
| 104 | - echo ' *** zlib shared test OK ***'; \ | |
| 105 | - else \ | |
| 106 | - echo ' *** zlib shared test FAILED ***'; false; \ | |
| 107 | - fi | |
| 108 | - @rm -f tmpsh_$$ | |
| 109 | - | |
| 110 | -test64: all64 | |
| 111 | - @TMP64=tmp64_$$; \ | |
| 112 | - if echo hello world | ./minigzip64 | ./minigzip64 -d && ./example64 $$TMP64; then \ | |
| 113 | - echo ' *** zlib 64-bit test OK ***'; \ | |
| 114 | - else \ | |
| 115 | - echo ' *** zlib 64-bit test FAILED ***'; false; \ | |
| 116 | - fi | |
| 117 | - @rm -f tmp64_$$ | |
| 118 | - | |
| 119 | -infcover.o: $(SRCDIR)test/infcover.c $(SRCDIR)zlib.h zconf.h | |
| 120 | - $(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/infcover.c | |
| 121 | - | |
| 122 | -infcover: infcover.o libz.a | |
| 123 | - $(CC) $(CFLAGS) -o $@ infcover.o libz.a | |
| 124 | - | |
| 125 | -cover: infcover | |
| 126 | - rm -f *.gcda | |
| 127 | - ./infcover | |
| 128 | - gcov inf*.c | |
| 129 | - | |
| 130 | -libz.a: $(OBJS) | |
| 131 | - $(AR) $(ARFLAGS) $@ $(OBJS) | |
| 132 | - -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 | |
| 133 | - | |
| 134 | -match.o: match.S | |
| 135 | - $(CPP) match.S > _match.s | |
| 136 | - $(CC) -c _match.s | |
| 137 | - mv _match.o match.o | |
| 138 | - rm -f _match.s | |
| 139 | - | |
| 140 | -match.lo: match.S | |
| 141 | - $(CPP) match.S > _match.s | |
| 142 | - $(CC) -c -fPIC _match.s | |
| 143 | - mv _match.o match.lo | |
| 144 | - rm -f _match.s | |
| 145 | - | |
| 146 | -example.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h | |
| 147 | - $(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/example.c | |
| 148 | - | |
| 149 | -minigzip.o: $(SRCDIR)test/minigzip.c $(SRCDIR)zlib.h zconf.h | |
| 150 | - $(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/minigzip.c | |
| 151 | - | |
| 152 | -example64.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h | |
| 153 | - $(CC) $(CFLAGS) $(ZINCOUT) -D_FILE_OFFSET_BITS=64 -c -o $@ $(SRCDIR)test/example.c | |
| 154 | - | |
| 155 | -minigzip64.o: $(SRCDIR)test/minigzip.c $(SRCDIR)zlib.h zconf.h | |
| 156 | - $(CC) $(CFLAGS) $(ZINCOUT) -D_FILE_OFFSET_BITS=64 -c -o $@ $(SRCDIR)test/minigzip.c | |
| 157 | - | |
| 158 | - | |
| 159 | -adler32.o: $(SRCDIR)adler32.c | |
| 160 | - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)adler32.c | |
| 161 | - | |
| 162 | -crc32.o: $(SRCDIR)crc32.c | |
| 163 | - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)crc32.c | |
| 164 | - | |
| 165 | -deflate.o: $(SRCDIR)deflate.c | |
| 166 | - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)deflate.c | |
| 167 | - | |
| 168 | -infback.o: $(SRCDIR)infback.c | |
| 169 | - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)infback.c | |
| 170 | - | |
| 171 | -inffast.o: $(SRCDIR)inffast.c | |
| 172 | - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inffast.c | |
| 173 | - | |
| 174 | -inflate.o: $(SRCDIR)inflate.c | |
| 175 | - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inflate.c | |
| 176 | - | |
| 177 | -inftrees.o: $(SRCDIR)inftrees.c | |
| 178 | - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inftrees.c | |
| 179 | - | |
| 180 | -trees.o: $(SRCDIR)trees.c | |
| 181 | - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)trees.c | |
| 182 | - | |
| 183 | -zutil.o: $(SRCDIR)zutil.c | |
| 184 | - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)zutil.c | |
| 185 | - | |
| 186 | -compress.o: $(SRCDIR)compress.c | |
| 187 | - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)compress.c | |
| 188 | - | |
| 189 | -uncompr.o: $(SRCDIR)uncompr.c | |
| 190 | - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)uncompr.c | |
| 191 | - | |
| 192 | -gzclose.o: $(SRCDIR)gzclose.c | |
| 193 | - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzclose.c | |
| 194 | - | |
| 195 | -gzlib.o: $(SRCDIR)gzlib.c | |
| 196 | - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzlib.c | |
| 197 | - | |
| 198 | -gzread.o: $(SRCDIR)gzread.c | |
| 199 | - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzread.c | |
| 200 | - | |
| 201 | -gzwrite.o: $(SRCDIR)gzwrite.c | |
| 202 | - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzwrite.c | |
| 203 | - | |
| 204 | - | |
| 205 | -adler32.lo: $(SRCDIR)adler32.c | |
| 206 | - -@mkdir objs 2>/dev/null || test -d objs | |
| 207 | - $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/adler32.o $(SRCDIR)adler32.c | |
| 208 | - -@mv objs/adler32.o $@ | |
| 209 | - | |
| 210 | -crc32.lo: $(SRCDIR)crc32.c | |
| 211 | - -@mkdir objs 2>/dev/null || test -d objs | |
| 212 | - $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/crc32.o $(SRCDIR)crc32.c | |
| 213 | - -@mv objs/crc32.o $@ | |
| 214 | - | |
| 215 | -deflate.lo: $(SRCDIR)deflate.c | |
| 216 | - -@mkdir objs 2>/dev/null || test -d objs | |
| 217 | - $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/deflate.o $(SRCDIR)deflate.c | |
| 218 | - -@mv objs/deflate.o $@ | |
| 219 | - | |
| 220 | -infback.lo: $(SRCDIR)infback.c | |
| 221 | - -@mkdir objs 2>/dev/null || test -d objs | |
| 222 | - $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/infback.o $(SRCDIR)infback.c | |
| 223 | - -@mv objs/infback.o $@ | |
| 224 | - | |
| 225 | -inffast.lo: $(SRCDIR)inffast.c | |
| 226 | - -@mkdir objs 2>/dev/null || test -d objs | |
| 227 | - $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/inffast.o $(SRCDIR)inffast.c | |
| 228 | - -@mv objs/inffast.o $@ | |
| 229 | - | |
| 230 | -inflate.lo: $(SRCDIR)inflate.c | |
| 231 | - -@mkdir objs 2>/dev/null || test -d objs | |
| 232 | - $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/inflate.o $(SRCDIR)inflate.c | |
| 233 | - -@mv objs/inflate.o $@ | |
| 234 | - | |
| 235 | -inftrees.lo: $(SRCDIR)inftrees.c | |
| 236 | - -@mkdir objs 2>/dev/null || test -d objs | |
| 237 | - $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/inftrees.o $(SRCDIR)inftrees.c | |
| 238 | - -@mv objs/inftrees.o $@ | |
| 239 | - | |
| 240 | -trees.lo: $(SRCDIR)trees.c | |
| 241 | - -@mkdir objs 2>/dev/null || test -d objs | |
| 242 | - $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/trees.o $(SRCDIR)trees.c | |
| 243 | - -@mv objs/trees.o $@ | |
| 244 | - | |
| 245 | -zutil.lo: $(SRCDIR)zutil.c | |
| 246 | - -@mkdir objs 2>/dev/null || test -d objs | |
| 247 | - $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/zutil.o $(SRCDIR)zutil.c | |
| 248 | - -@mv objs/zutil.o $@ | |
| 249 | - | |
| 250 | -compress.lo: $(SRCDIR)compress.c | |
| 251 | - -@mkdir objs 2>/dev/null || test -d objs | |
| 252 | - $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/compress.o $(SRCDIR)compress.c | |
| 253 | - -@mv objs/compress.o $@ | |
| 254 | - | |
| 255 | -uncompr.lo: $(SRCDIR)uncompr.c | |
| 256 | - -@mkdir objs 2>/dev/null || test -d objs | |
| 257 | - $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/uncompr.o $(SRCDIR)uncompr.c | |
| 258 | - -@mv objs/uncompr.o $@ | |
| 259 | - | |
| 260 | -gzclose.lo: $(SRCDIR)gzclose.c | |
| 261 | - -@mkdir objs 2>/dev/null || test -d objs | |
| 262 | - $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/gzclose.o $(SRCDIR)gzclose.c | |
| 263 | - -@mv objs/gzclose.o $@ | |
| 264 | - | |
| 265 | -gzlib.lo: $(SRCDIR)gzlib.c | |
| 266 | - -@mkdir objs 2>/dev/null || test -d objs | |
| 267 | - $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/gzlib.o $(SRCDIR)gzlib.c | |
| 268 | - -@mv objs/gzlib.o $@ | |
| 269 | - | |
| 270 | -gzread.lo: $(SRCDIR)gzread.c | |
| 271 | - -@mkdir objs 2>/dev/null || test -d objs | |
| 272 | - $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/gzread.o $(SRCDIR)gzread.c | |
| 273 | - -@mv objs/gzread.o $@ | |
| 274 | - | |
| 275 | -gzwrite.lo: $(SRCDIR)gzwrite.c | |
| 276 | - -@mkdir objs 2>/dev/null || test -d objs | |
| 277 | - $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/gzwrite.o $(SRCDIR)gzwrite.c | |
| 278 | - -@mv objs/gzwrite.o $@ | |
| 279 | - | |
| 280 | - | |
| 281 | -placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a | |
| 282 | - $(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS) | |
| 283 | - rm -f $(SHAREDLIB) $(SHAREDLIBM) | |
| 284 | - ln -s $@ $(SHAREDLIB) | |
| 285 | - ln -s $@ $(SHAREDLIBM) | |
| 286 | - -@rmdir objs | |
| 287 | - | |
| 288 | -example$(EXE): example.o $(STATICLIB) | |
| 289 | - $(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS) | |
| 290 | - | |
| 291 | -minigzip$(EXE): minigzip.o $(STATICLIB) | |
| 292 | - $(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS) | |
| 293 | - | |
| 294 | -examplesh$(EXE): example.o $(SHAREDLIBV) | |
| 295 | - $(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV) | |
| 296 | - | |
| 297 | -minigzipsh$(EXE): minigzip.o $(SHAREDLIBV) | |
| 298 | - $(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV) | |
| 299 | - | |
| 300 | -example64$(EXE): example64.o $(STATICLIB) | |
| 301 | - $(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS) | |
| 302 | - | |
| 303 | -minigzip64$(EXE): minigzip64.o $(STATICLIB) | |
| 304 | - $(CC) $(CFLAGS) -o $@ minigzip64.o $(TEST_LDFLAGS) | |
| 305 | - | |
| 306 | -install-libs: $(LIBS) | |
| 307 | - -@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi | |
| 308 | - -@if [ ! -d $(DESTDIR)$(libdir) ]; then mkdir -p $(DESTDIR)$(libdir); fi | |
| 309 | - -@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi | |
| 310 | - -@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi | |
| 311 | - -@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi | |
| 312 | - rm -f $(DESTDIR)$(libdir)/$(STATICLIB) | |
| 313 | - cp $(STATICLIB) $(DESTDIR)$(libdir) | |
| 314 | - chmod 644 $(DESTDIR)$(libdir)/$(STATICLIB) | |
| 315 | - -@($(RANLIB) $(DESTDIR)$(libdir)/libz.a || true) >/dev/null 2>&1 | |
| 316 | - -@if test -n "$(SHAREDLIBV)"; then \ | |
| 317 | - rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \ | |
| 318 | - cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir); \ | |
| 319 | - echo "cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)"; \ | |
| 320 | - chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \ | |
| 321 | - echo "chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV)"; \ | |
| 322 | - rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \ | |
| 323 | - ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB); \ | |
| 324 | - ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \ | |
| 325 | - ($(LDCONFIG) || true) >/dev/null 2>&1; \ | |
| 326 | - fi | |
| 327 | - rm -f $(DESTDIR)$(man3dir)/zlib.3 | |
| 328 | - cp $(SRCDIR)zlib.3 $(DESTDIR)$(man3dir) | |
| 329 | - chmod 644 $(DESTDIR)$(man3dir)/zlib.3 | |
| 330 | - rm -f $(DESTDIR)$(pkgconfigdir)/zlib.pc | |
| 331 | - cp zlib.pc $(DESTDIR)$(pkgconfigdir) | |
| 332 | - chmod 644 $(DESTDIR)$(pkgconfigdir)/zlib.pc | |
| 333 | -# The ranlib in install is needed on NeXTSTEP which checks file times | |
| 334 | -# ldconfig is for Linux | |
| 335 | - | |
| 336 | -install: install-libs | |
| 337 | - -@if [ ! -d $(DESTDIR)$(includedir) ]; then mkdir -p $(DESTDIR)$(includedir); fi | |
| 338 | - rm -f $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h | |
| 339 | - cp $(SRCDIR)zlib.h zconf.h $(DESTDIR)$(includedir) | |
| 340 | - chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h | |
| 341 | - | |
| 342 | -uninstall: | |
| 343 | - cd $(DESTDIR)$(includedir) && rm -f zlib.h zconf.h | |
| 344 | - cd $(DESTDIR)$(libdir) && rm -f libz.a; \ | |
| 345 | - if test -n "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \ | |
| 346 | - rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \ | |
| 347 | - fi | |
| 348 | - cd $(DESTDIR)$(man3dir) && rm -f zlib.3 | |
| 349 | - cd $(DESTDIR)$(pkgconfigdir) && rm -f zlib.pc | |
| 350 | - | |
| 351 | -docs: zlib.3.pdf | |
| 352 | - | |
| 353 | -zlib.3.pdf: $(SRCDIR)zlib.3 | |
| 354 | - groff -mandoc -f H -T ps $(SRCDIR)zlib.3 | ps2pdf - $@ | |
| 355 | - | |
| 356 | -zconf.h.cmakein: $(SRCDIR)zconf.h.in | |
| 357 | - -@ TEMPFILE=zconfh_$$; \ | |
| 358 | - echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" >> $$TEMPFILE &&\ | |
| 359 | - sed -f $$TEMPFILE $(SRCDIR)zconf.h.in > $@ &&\ | |
| 360 | - touch -r $(SRCDIR)zconf.h.in $@ &&\ | |
| 361 | - rm $$TEMPFILE | |
| 362 | - | |
| 363 | -zconf: $(SRCDIR)zconf.h.in | |
| 364 | - cp -p $(SRCDIR)zconf.h.in zconf.h | |
| 365 | - | |
| 366 | -mostlyclean: clean | |
| 367 | -clean: | |
| 368 | - rm -f *.o *.lo *~ \ | |
| 369 | - example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \ | |
| 370 | - example64$(EXE) minigzip64$(EXE) \ | |
| 371 | - infcover \ | |
| 372 | - libz.* foo.gz so_locations \ | |
| 373 | - _match.s maketree contrib/infback9/*.o | |
| 374 | - rm -rf objs | |
| 375 | - rm -f *.gcda *.gcno *.gcov | |
| 376 | - rm -f contrib/infback9/*.gcda contrib/infback9/*.gcno contrib/infback9/*.gcov | |
| 377 | - | |
| 378 | -maintainer-clean: distclean | |
| 379 | -distclean: clean zconf zconf.h.cmakein | |
| 380 | - rm -f Makefile zlib.pc configure.log | |
| 381 | - -@rm -f .DS_Store | |
| 382 | - @if [ -f Makefile.in ]; then \ | |
| 383 | - printf 'all:\n\t-@echo "Please use ./configure first. Thank you."\n' > Makefile ; \ | |
| 384 | - printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile ; \ | |
| 385 | - touch -r $(SRCDIR)Makefile.in Makefile ; fi | |
| 386 | - | |
| 387 | -tags: | |
| 388 | - etags $(SRCDIR)*.[ch] | |
| 389 | - | |
| 390 | -adler32.o zutil.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h | |
| 391 | -gzclose.o gzlib.o gzread.o gzwrite.o: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h | |
| 392 | -compress.o example.o minigzip.o uncompr.o: $(SRCDIR)zlib.h zconf.h | |
| 393 | -crc32.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h | |
| 394 | -deflate.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h | |
| 395 | -infback.o inflate.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h $(SRCDIR)inffixed.h | |
| 396 | -inffast.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h | |
| 397 | -inftrees.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h | |
| 398 | -trees.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h | |
| 399 | - | |
| 400 | -adler32.lo zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h | |
| 401 | -gzclose.lo gzlib.lo gzread.lo gzwrite.lo: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h | |
| 402 | -compress.lo example.lo minigzip.lo uncompr.lo: $(SRCDIR)zlib.h zconf.h | |
| 403 | -crc32.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h | |
| 404 | -deflate.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h | |
| 405 | -infback.lo inflate.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h $(SRCDIR)inffixed.h | |
| 406 | -inffast.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h | |
| 407 | -inftrees.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h | |
| 408 | -trees.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h | |
| 1 | +all: | |
| 2 | + -@echo "Please use ./configure first. Thank you." | |
| 3 | + | |
| 4 | +distclean: | |
| 5 | + make -f Makefile.in distclean | |
| 409 | 6 |
| --- compat/zlib/Makefile | |
| +++ compat/zlib/Makefile | |
| @@ -1,408 +1,5 @@ | |
| 1 | # Makefile for zlib |
| 2 | # Copyright (C) 1995-2017 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 use the asm code, type: |
| 11 | # cp contrib/asm?86/match.S ./match.S |
| 12 | # make LOC=-DASMV OBJA=match.o |
| 13 | |
| 14 | # To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type: |
| 15 | # make install |
| 16 | # To install in $HOME instead of /usr/local, use: |
| 17 | # make install prefix=$HOME |
| 18 | |
| 19 | CC=gcc |
| 20 | |
| 21 | CFLAGS=-O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN |
| 22 | #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 |
| 23 | #CFLAGS=-g -DZLIB_DEBUG |
| 24 | #CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ |
| 25 | # -Wstrict-prototypes -Wmissing-prototypes |
| 26 | |
| 27 | SFLAGS=-O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN |
| 28 | LDFLAGS= |
| 29 | TEST_LDFLAGS=-L. libz.a |
| 30 | LDSHARED=gcc |
| 31 | CPP=gcc -E |
| 32 | |
| 33 | STATICLIB=libz.a |
| 34 | SHAREDLIB= |
| 35 | SHAREDLIBV= |
| 36 | SHAREDLIBM= |
| 37 | LIBS=$(STATICLIB) $(SHAREDLIBV) |
| 38 | |
| 39 | AR=ar |
| 40 | ARFLAGS=rc |
| 41 | RANLIB=ranlib |
| 42 | LDCONFIG=ldconfig |
| 43 | LDSHAREDLIBC=-lc |
| 44 | TAR=tar |
| 45 | SHELL=/bin/sh |
| 46 | EXE= |
| 47 | |
| 48 | prefix =/usr/local |
| 49 | exec_prefix =${prefix} |
| 50 | libdir =${exec_prefix}/lib |
| 51 | sharedlibdir =${libdir} |
| 52 | includedir =${prefix}/include |
| 53 | mandir =${prefix}/share/man |
| 54 | man3dir = ${mandir}/man3 |
| 55 | pkgconfigdir = ${libdir}/pkgconfig |
| 56 | SRCDIR= |
| 57 | ZINC= |
| 58 | ZINCOUT=-I. |
| 59 | |
| 60 | OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o |
| 61 | OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o |
| 62 | OBJC = $(OBJZ) $(OBJG) |
| 63 | |
| 64 | PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo |
| 65 | PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo |
| 66 | PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG) |
| 67 | |
| 68 | # to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo |
| 69 | OBJA = |
| 70 | PIC_OBJA = |
| 71 | |
| 72 | OBJS = $(OBJC) $(OBJA) |
| 73 | |
| 74 | PIC_OBJS = $(PIC_OBJC) $(PIC_OBJA) |
| 75 | |
| 76 | all: static all64 |
| 77 | |
| 78 | static: example$(EXE) minigzip$(EXE) |
| 79 | |
| 80 | shared: examplesh$(EXE) minigzipsh$(EXE) |
| 81 | |
| 82 | all64: example64$(EXE) minigzip64$(EXE) |
| 83 | |
| 84 | check: test |
| 85 | |
| 86 | test: all teststatic test64 |
| 87 | |
| 88 | teststatic: static |
| 89 | @TMPST=tmpst_$$; \ |
| 90 | if echo hello world | ./minigzip | ./minigzip -d && ./example $$TMPST ; then \ |
| 91 | echo ' *** zlib test OK ***'; \ |
| 92 | else \ |
| 93 | echo ' *** zlib test FAILED ***'; false; \ |
| 94 | fi |
| 95 | @rm -f tmpst_$$ |
| 96 | |
| 97 | testshared: shared |
| 98 | @LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ |
| 99 | LD_LIBRARYN32_PATH=`pwd`:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \ |
| 100 | DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \ |
| 101 | SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \ |
| 102 | TMPSH=tmpsh_$$; \ |
| 103 | if echo hello world | ./minigzipsh | ./minigzipsh -d && ./examplesh $$TMPSH; then \ |
| 104 | echo ' *** zlib shared test OK ***'; \ |
| 105 | else \ |
| 106 | echo ' *** zlib shared test FAILED ***'; false; \ |
| 107 | fi |
| 108 | @rm -f tmpsh_$$ |
| 109 | |
| 110 | test64: all64 |
| 111 | @TMP64=tmp64_$$; \ |
| 112 | if echo hello world | ./minigzip64 | ./minigzip64 -d && ./example64 $$TMP64; then \ |
| 113 | echo ' *** zlib 64-bit test OK ***'; \ |
| 114 | else \ |
| 115 | echo ' *** zlib 64-bit test FAILED ***'; false; \ |
| 116 | fi |
| 117 | @rm -f tmp64_$$ |
| 118 | |
| 119 | infcover.o: $(SRCDIR)test/infcover.c $(SRCDIR)zlib.h zconf.h |
| 120 | $(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/infcover.c |
| 121 | |
| 122 | infcover: infcover.o libz.a |
| 123 | $(CC) $(CFLAGS) -o $@ infcover.o libz.a |
| 124 | |
| 125 | cover: infcover |
| 126 | rm -f *.gcda |
| 127 | ./infcover |
| 128 | gcov inf*.c |
| 129 | |
| 130 | libz.a: $(OBJS) |
| 131 | $(AR) $(ARFLAGS) $@ $(OBJS) |
| 132 | -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 |
| 133 | |
| 134 | match.o: match.S |
| 135 | $(CPP) match.S > _match.s |
| 136 | $(CC) -c _match.s |
| 137 | mv _match.o match.o |
| 138 | rm -f _match.s |
| 139 | |
| 140 | match.lo: match.S |
| 141 | $(CPP) match.S > _match.s |
| 142 | $(CC) -c -fPIC _match.s |
| 143 | mv _match.o match.lo |
| 144 | rm -f _match.s |
| 145 | |
| 146 | example.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h |
| 147 | $(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/example.c |
| 148 | |
| 149 | minigzip.o: $(SRCDIR)test/minigzip.c $(SRCDIR)zlib.h zconf.h |
| 150 | $(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/minigzip.c |
| 151 | |
| 152 | example64.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h |
| 153 | $(CC) $(CFLAGS) $(ZINCOUT) -D_FILE_OFFSET_BITS=64 -c -o $@ $(SRCDIR)test/example.c |
| 154 | |
| 155 | minigzip64.o: $(SRCDIR)test/minigzip.c $(SRCDIR)zlib.h zconf.h |
| 156 | $(CC) $(CFLAGS) $(ZINCOUT) -D_FILE_OFFSET_BITS=64 -c -o $@ $(SRCDIR)test/minigzip.c |
| 157 | |
| 158 | |
| 159 | adler32.o: $(SRCDIR)adler32.c |
| 160 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)adler32.c |
| 161 | |
| 162 | crc32.o: $(SRCDIR)crc32.c |
| 163 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)crc32.c |
| 164 | |
| 165 | deflate.o: $(SRCDIR)deflate.c |
| 166 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)deflate.c |
| 167 | |
| 168 | infback.o: $(SRCDIR)infback.c |
| 169 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)infback.c |
| 170 | |
| 171 | inffast.o: $(SRCDIR)inffast.c |
| 172 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inffast.c |
| 173 | |
| 174 | inflate.o: $(SRCDIR)inflate.c |
| 175 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inflate.c |
| 176 | |
| 177 | inftrees.o: $(SRCDIR)inftrees.c |
| 178 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inftrees.c |
| 179 | |
| 180 | trees.o: $(SRCDIR)trees.c |
| 181 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)trees.c |
| 182 | |
| 183 | zutil.o: $(SRCDIR)zutil.c |
| 184 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)zutil.c |
| 185 | |
| 186 | compress.o: $(SRCDIR)compress.c |
| 187 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)compress.c |
| 188 | |
| 189 | uncompr.o: $(SRCDIR)uncompr.c |
| 190 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)uncompr.c |
| 191 | |
| 192 | gzclose.o: $(SRCDIR)gzclose.c |
| 193 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzclose.c |
| 194 | |
| 195 | gzlib.o: $(SRCDIR)gzlib.c |
| 196 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzlib.c |
| 197 | |
| 198 | gzread.o: $(SRCDIR)gzread.c |
| 199 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzread.c |
| 200 | |
| 201 | gzwrite.o: $(SRCDIR)gzwrite.c |
| 202 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzwrite.c |
| 203 | |
| 204 | |
| 205 | adler32.lo: $(SRCDIR)adler32.c |
| 206 | -@mkdir objs 2>/dev/null || test -d objs |
| 207 | $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/adler32.o $(SRCDIR)adler32.c |
| 208 | -@mv objs/adler32.o $@ |
| 209 | |
| 210 | crc32.lo: $(SRCDIR)crc32.c |
| 211 | -@mkdir objs 2>/dev/null || test -d objs |
| 212 | $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/crc32.o $(SRCDIR)crc32.c |
| 213 | -@mv objs/crc32.o $@ |
| 214 | |
| 215 | deflate.lo: $(SRCDIR)deflate.c |
| 216 | -@mkdir objs 2>/dev/null || test -d objs |
| 217 | $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/deflate.o $(SRCDIR)deflate.c |
| 218 | -@mv objs/deflate.o $@ |
| 219 | |
| 220 | infback.lo: $(SRCDIR)infback.c |
| 221 | -@mkdir objs 2>/dev/null || test -d objs |
| 222 | $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/infback.o $(SRCDIR)infback.c |
| 223 | -@mv objs/infback.o $@ |
| 224 | |
| 225 | inffast.lo: $(SRCDIR)inffast.c |
| 226 | -@mkdir objs 2>/dev/null || test -d objs |
| 227 | $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/inffast.o $(SRCDIR)inffast.c |
| 228 | -@mv objs/inffast.o $@ |
| 229 | |
| 230 | inflate.lo: $(SRCDIR)inflate.c |
| 231 | -@mkdir objs 2>/dev/null || test -d objs |
| 232 | $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/inflate.o $(SRCDIR)inflate.c |
| 233 | -@mv objs/inflate.o $@ |
| 234 | |
| 235 | inftrees.lo: $(SRCDIR)inftrees.c |
| 236 | -@mkdir objs 2>/dev/null || test -d objs |
| 237 | $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/inftrees.o $(SRCDIR)inftrees.c |
| 238 | -@mv objs/inftrees.o $@ |
| 239 | |
| 240 | trees.lo: $(SRCDIR)trees.c |
| 241 | -@mkdir objs 2>/dev/null || test -d objs |
| 242 | $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/trees.o $(SRCDIR)trees.c |
| 243 | -@mv objs/trees.o $@ |
| 244 | |
| 245 | zutil.lo: $(SRCDIR)zutil.c |
| 246 | -@mkdir objs 2>/dev/null || test -d objs |
| 247 | $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/zutil.o $(SRCDIR)zutil.c |
| 248 | -@mv objs/zutil.o $@ |
| 249 | |
| 250 | compress.lo: $(SRCDIR)compress.c |
| 251 | -@mkdir objs 2>/dev/null || test -d objs |
| 252 | $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/compress.o $(SRCDIR)compress.c |
| 253 | -@mv objs/compress.o $@ |
| 254 | |
| 255 | uncompr.lo: $(SRCDIR)uncompr.c |
| 256 | -@mkdir objs 2>/dev/null || test -d objs |
| 257 | $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/uncompr.o $(SRCDIR)uncompr.c |
| 258 | -@mv objs/uncompr.o $@ |
| 259 | |
| 260 | gzclose.lo: $(SRCDIR)gzclose.c |
| 261 | -@mkdir objs 2>/dev/null || test -d objs |
| 262 | $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/gzclose.o $(SRCDIR)gzclose.c |
| 263 | -@mv objs/gzclose.o $@ |
| 264 | |
| 265 | gzlib.lo: $(SRCDIR)gzlib.c |
| 266 | -@mkdir objs 2>/dev/null || test -d objs |
| 267 | $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/gzlib.o $(SRCDIR)gzlib.c |
| 268 | -@mv objs/gzlib.o $@ |
| 269 | |
| 270 | gzread.lo: $(SRCDIR)gzread.c |
| 271 | -@mkdir objs 2>/dev/null || test -d objs |
| 272 | $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/gzread.o $(SRCDIR)gzread.c |
| 273 | -@mv objs/gzread.o $@ |
| 274 | |
| 275 | gzwrite.lo: $(SRCDIR)gzwrite.c |
| 276 | -@mkdir objs 2>/dev/null || test -d objs |
| 277 | $(CC) $(SFLAGS) $(ZINC) -fPIC -c -o objs/gzwrite.o $(SRCDIR)gzwrite.c |
| 278 | -@mv objs/gzwrite.o $@ |
| 279 | |
| 280 | |
| 281 | placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a |
| 282 | $(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS) |
| 283 | rm -f $(SHAREDLIB) $(SHAREDLIBM) |
| 284 | ln -s $@ $(SHAREDLIB) |
| 285 | ln -s $@ $(SHAREDLIBM) |
| 286 | -@rmdir objs |
| 287 | |
| 288 | example$(EXE): example.o $(STATICLIB) |
| 289 | $(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS) |
| 290 | |
| 291 | minigzip$(EXE): minigzip.o $(STATICLIB) |
| 292 | $(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS) |
| 293 | |
| 294 | examplesh$(EXE): example.o $(SHAREDLIBV) |
| 295 | $(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV) |
| 296 | |
| 297 | minigzipsh$(EXE): minigzip.o $(SHAREDLIBV) |
| 298 | $(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV) |
| 299 | |
| 300 | example64$(EXE): example64.o $(STATICLIB) |
| 301 | $(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS) |
| 302 | |
| 303 | minigzip64$(EXE): minigzip64.o $(STATICLIB) |
| 304 | $(CC) $(CFLAGS) -o $@ minigzip64.o $(TEST_LDFLAGS) |
| 305 | |
| 306 | install-libs: $(LIBS) |
| 307 | -@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi |
| 308 | -@if [ ! -d $(DESTDIR)$(libdir) ]; then mkdir -p $(DESTDIR)$(libdir); fi |
| 309 | -@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi |
| 310 | -@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi |
| 311 | -@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi |
| 312 | rm -f $(DESTDIR)$(libdir)/$(STATICLIB) |
| 313 | cp $(STATICLIB) $(DESTDIR)$(libdir) |
| 314 | chmod 644 $(DESTDIR)$(libdir)/$(STATICLIB) |
| 315 | -@($(RANLIB) $(DESTDIR)$(libdir)/libz.a || true) >/dev/null 2>&1 |
| 316 | -@if test -n "$(SHAREDLIBV)"; then \ |
| 317 | rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \ |
| 318 | cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir); \ |
| 319 | echo "cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)"; \ |
| 320 | chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \ |
| 321 | echo "chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV)"; \ |
| 322 | rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \ |
| 323 | ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB); \ |
| 324 | ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \ |
| 325 | ($(LDCONFIG) || true) >/dev/null 2>&1; \ |
| 326 | fi |
| 327 | rm -f $(DESTDIR)$(man3dir)/zlib.3 |
| 328 | cp $(SRCDIR)zlib.3 $(DESTDIR)$(man3dir) |
| 329 | chmod 644 $(DESTDIR)$(man3dir)/zlib.3 |
| 330 | rm -f $(DESTDIR)$(pkgconfigdir)/zlib.pc |
| 331 | cp zlib.pc $(DESTDIR)$(pkgconfigdir) |
| 332 | chmod 644 $(DESTDIR)$(pkgconfigdir)/zlib.pc |
| 333 | # The ranlib in install is needed on NeXTSTEP which checks file times |
| 334 | # ldconfig is for Linux |
| 335 | |
| 336 | install: install-libs |
| 337 | -@if [ ! -d $(DESTDIR)$(includedir) ]; then mkdir -p $(DESTDIR)$(includedir); fi |
| 338 | rm -f $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h |
| 339 | cp $(SRCDIR)zlib.h zconf.h $(DESTDIR)$(includedir) |
| 340 | chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h |
| 341 | |
| 342 | uninstall: |
| 343 | cd $(DESTDIR)$(includedir) && rm -f zlib.h zconf.h |
| 344 | cd $(DESTDIR)$(libdir) && rm -f libz.a; \ |
| 345 | if test -n "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \ |
| 346 | rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \ |
| 347 | fi |
| 348 | cd $(DESTDIR)$(man3dir) && rm -f zlib.3 |
| 349 | cd $(DESTDIR)$(pkgconfigdir) && rm -f zlib.pc |
| 350 | |
| 351 | docs: zlib.3.pdf |
| 352 | |
| 353 | zlib.3.pdf: $(SRCDIR)zlib.3 |
| 354 | groff -mandoc -f H -T ps $(SRCDIR)zlib.3 | ps2pdf - $@ |
| 355 | |
| 356 | zconf.h.cmakein: $(SRCDIR)zconf.h.in |
| 357 | -@ TEMPFILE=zconfh_$$; \ |
| 358 | echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" >> $$TEMPFILE &&\ |
| 359 | sed -f $$TEMPFILE $(SRCDIR)zconf.h.in > $@ &&\ |
| 360 | touch -r $(SRCDIR)zconf.h.in $@ &&\ |
| 361 | rm $$TEMPFILE |
| 362 | |
| 363 | zconf: $(SRCDIR)zconf.h.in |
| 364 | cp -p $(SRCDIR)zconf.h.in zconf.h |
| 365 | |
| 366 | mostlyclean: clean |
| 367 | clean: |
| 368 | rm -f *.o *.lo *~ \ |
| 369 | example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \ |
| 370 | example64$(EXE) minigzip64$(EXE) \ |
| 371 | infcover \ |
| 372 | libz.* foo.gz so_locations \ |
| 373 | _match.s maketree contrib/infback9/*.o |
| 374 | rm -rf objs |
| 375 | rm -f *.gcda *.gcno *.gcov |
| 376 | rm -f contrib/infback9/*.gcda contrib/infback9/*.gcno contrib/infback9/*.gcov |
| 377 | |
| 378 | maintainer-clean: distclean |
| 379 | distclean: clean zconf zconf.h.cmakein |
| 380 | rm -f Makefile zlib.pc configure.log |
| 381 | -@rm -f .DS_Store |
| 382 | @if [ -f Makefile.in ]; then \ |
| 383 | printf 'all:\n\t-@echo "Please use ./configure first. Thank you."\n' > Makefile ; \ |
| 384 | printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile ; \ |
| 385 | touch -r $(SRCDIR)Makefile.in Makefile ; fi |
| 386 | |
| 387 | tags: |
| 388 | etags $(SRCDIR)*.[ch] |
| 389 | |
| 390 | adler32.o zutil.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h |
| 391 | gzclose.o gzlib.o gzread.o gzwrite.o: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h |
| 392 | compress.o example.o minigzip.o uncompr.o: $(SRCDIR)zlib.h zconf.h |
| 393 | crc32.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h |
| 394 | deflate.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h |
| 395 | infback.o inflate.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h $(SRCDIR)inffixed.h |
| 396 | inffast.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h |
| 397 | inftrees.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h |
| 398 | trees.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h |
| 399 | |
| 400 | adler32.lo zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h |
| 401 | gzclose.lo gzlib.lo gzread.lo gzwrite.lo: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h |
| 402 | compress.lo example.lo minigzip.lo uncompr.lo: $(SRCDIR)zlib.h zconf.h |
| 403 | crc32.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h |
| 404 | deflate.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h |
| 405 | infback.lo inflate.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h $(SRCDIR)inffixed.h |
| 406 | inffast.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h |
| 407 | inftrees.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h |
| 408 | trees.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h |
| 409 |
| --- compat/zlib/Makefile | |
| +++ compat/zlib/Makefile | |
| @@ -1,408 +1,5 @@ | |
| 1 | all: |
| 2 | -@echo "Please use ./configure first. Thank you." |
| 3 | |
| 4 | distclean: |
| 5 | make -f Makefile.in distclean |
| 6 |
+8
-12
| --- compat/zlib/Makefile.in | ||
| +++ compat/zlib/Makefile.in | ||
| @@ -5,14 +5,10 @@ | ||
| 5 | 5 | # To compile and test, type: |
| 6 | 6 | # ./configure; make test |
| 7 | 7 | # Normally configure builds both a static and a shared library. |
| 8 | 8 | # If you want to build just a static library, use: ./configure --static |
| 9 | 9 | |
| 10 | -# To use the asm code, type: | |
| 11 | -# cp contrib/asm?86/match.S ./match.S | |
| 12 | -# make LOC=-DASMV OBJA=match.o | |
| 13 | - | |
| 14 | 10 | # To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type: |
| 15 | 11 | # make install |
| 16 | 12 | # To install in $HOME instead of /usr/local, use: |
| 17 | 13 | # make install prefix=$HOME |
| 18 | 14 | |
| @@ -24,17 +20,17 @@ | ||
| 24 | 20 | #CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ |
| 25 | 21 | # -Wstrict-prototypes -Wmissing-prototypes |
| 26 | 22 | |
| 27 | 23 | SFLAGS=-O |
| 28 | 24 | LDFLAGS= |
| 29 | -TEST_LDFLAGS=-L. libz.a | |
| 25 | +TEST_LDFLAGS=$(LDFLAGS) -L. libz.a | |
| 30 | 26 | LDSHARED=$(CC) |
| 31 | 27 | CPP=$(CC) -E |
| 32 | 28 | |
| 33 | 29 | STATICLIB=libz.a |
| 34 | 30 | SHAREDLIB=libz.so |
| 35 | -SHAREDLIBV=libz.so.1.2.12 | |
| 31 | +SHAREDLIBV=libz.so.1.2.13 | |
| 36 | 32 | SHAREDLIBM=libz.so.1 |
| 37 | 33 | LIBS=$(STATICLIB) $(SHAREDLIBV) |
| 38 | 34 | |
| 39 | 35 | AR=ar |
| 40 | 36 | ARFLAGS=rc |
| @@ -85,11 +81,11 @@ | ||
| 85 | 81 | |
| 86 | 82 | test: all teststatic testshared |
| 87 | 83 | |
| 88 | 84 | teststatic: static |
| 89 | 85 | @TMPST=tmpst_$$; \ |
| 90 | - if echo hello world | ./minigzip | ./minigzip -d && ./example $$TMPST ; then \ | |
| 86 | + if echo hello world | ${QEMU_RUN} ./minigzip | ${QEMU_RUN} ./minigzip -d && ${QEMU_RUN} ./example $$TMPST ; then \ | |
| 91 | 87 | echo ' *** zlib test OK ***'; \ |
| 92 | 88 | else \ |
| 93 | 89 | echo ' *** zlib test FAILED ***'; false; \ |
| 94 | 90 | fi |
| 95 | 91 | @rm -f tmpst_$$ |
| @@ -98,20 +94,20 @@ | ||
| 98 | 94 | @LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ |
| 99 | 95 | LD_LIBRARYN32_PATH=`pwd`:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \ |
| 100 | 96 | DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \ |
| 101 | 97 | SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \ |
| 102 | 98 | TMPSH=tmpsh_$$; \ |
| 103 | - if echo hello world | ./minigzipsh | ./minigzipsh -d && ./examplesh $$TMPSH; then \ | |
| 99 | + if echo hello world | ${QEMU_RUN} ./minigzipsh | ${QEMU_RUN} ./minigzipsh -d && ${QEMU_RUN} ./examplesh $$TMPSH; then \ | |
| 104 | 100 | echo ' *** zlib shared test OK ***'; \ |
| 105 | 101 | else \ |
| 106 | 102 | echo ' *** zlib shared test FAILED ***'; false; \ |
| 107 | 103 | fi |
| 108 | 104 | @rm -f tmpsh_$$ |
| 109 | 105 | |
| 110 | 106 | test64: all64 |
| 111 | 107 | @TMP64=tmp64_$$; \ |
| 112 | - if echo hello world | ./minigzip64 | ./minigzip64 -d && ./example64 $$TMP64; then \ | |
| 108 | + if echo hello world | ${QEMU_RUN} ./minigzip64 | ${QEMU_RUN} ./minigzip64 -d && ${QEMU_RUN} ./example64 $$TMP64; then \ | |
| 113 | 109 | echo ' *** zlib 64-bit test OK ***'; \ |
| 114 | 110 | else \ |
| 115 | 111 | echo ' *** zlib 64-bit test FAILED ***'; false; \ |
| 116 | 112 | fi |
| 117 | 113 | @rm -f tmp64_$$ |
| @@ -122,11 +118,11 @@ | ||
| 122 | 118 | infcover: infcover.o libz.a |
| 123 | 119 | $(CC) $(CFLAGS) -o $@ infcover.o libz.a |
| 124 | 120 | |
| 125 | 121 | cover: infcover |
| 126 | 122 | rm -f *.gcda |
| 127 | - ./infcover | |
| 123 | + ${QEMU_RUN} ./infcover | |
| 128 | 124 | gcov inf*.c |
| 129 | 125 | |
| 130 | 126 | libz.a: $(OBJS) |
| 131 | 127 | $(AR) $(ARFLAGS) $@ $(OBJS) |
| 132 | 128 | -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 |
| @@ -290,14 +286,14 @@ | ||
| 290 | 286 | |
| 291 | 287 | minigzip$(EXE): minigzip.o $(STATICLIB) |
| 292 | 288 | $(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS) |
| 293 | 289 | |
| 294 | 290 | examplesh$(EXE): example.o $(SHAREDLIBV) |
| 295 | - $(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV) | |
| 291 | + $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS) -L. $(SHAREDLIBV) | |
| 296 | 292 | |
| 297 | 293 | minigzipsh$(EXE): minigzip.o $(SHAREDLIBV) |
| 298 | - $(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV) | |
| 294 | + $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) -L. $(SHAREDLIBV) | |
| 299 | 295 | |
| 300 | 296 | example64$(EXE): example64.o $(STATICLIB) |
| 301 | 297 | $(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS) |
| 302 | 298 | |
| 303 | 299 | minigzip64$(EXE): minigzip64.o $(STATICLIB) |
| 304 | 300 |
| --- compat/zlib/Makefile.in | |
| +++ compat/zlib/Makefile.in | |
| @@ -5,14 +5,10 @@ | |
| 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 use the asm code, type: |
| 11 | # cp contrib/asm?86/match.S ./match.S |
| 12 | # make LOC=-DASMV OBJA=match.o |
| 13 | |
| 14 | # To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type: |
| 15 | # make install |
| 16 | # To install in $HOME instead of /usr/local, use: |
| 17 | # make install prefix=$HOME |
| 18 | |
| @@ -24,17 +20,17 @@ | |
| 24 | #CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ |
| 25 | # -Wstrict-prototypes -Wmissing-prototypes |
| 26 | |
| 27 | SFLAGS=-O |
| 28 | LDFLAGS= |
| 29 | TEST_LDFLAGS=-L. libz.a |
| 30 | LDSHARED=$(CC) |
| 31 | CPP=$(CC) -E |
| 32 | |
| 33 | STATICLIB=libz.a |
| 34 | SHAREDLIB=libz.so |
| 35 | SHAREDLIBV=libz.so.1.2.12 |
| 36 | SHAREDLIBM=libz.so.1 |
| 37 | LIBS=$(STATICLIB) $(SHAREDLIBV) |
| 38 | |
| 39 | AR=ar |
| 40 | ARFLAGS=rc |
| @@ -85,11 +81,11 @@ | |
| 85 | |
| 86 | test: all teststatic testshared |
| 87 | |
| 88 | teststatic: static |
| 89 | @TMPST=tmpst_$$; \ |
| 90 | if echo hello world | ./minigzip | ./minigzip -d && ./example $$TMPST ; then \ |
| 91 | echo ' *** zlib test OK ***'; \ |
| 92 | else \ |
| 93 | echo ' *** zlib test FAILED ***'; false; \ |
| 94 | fi |
| 95 | @rm -f tmpst_$$ |
| @@ -98,20 +94,20 @@ | |
| 98 | @LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ |
| 99 | LD_LIBRARYN32_PATH=`pwd`:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \ |
| 100 | DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \ |
| 101 | SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \ |
| 102 | TMPSH=tmpsh_$$; \ |
| 103 | if echo hello world | ./minigzipsh | ./minigzipsh -d && ./examplesh $$TMPSH; then \ |
| 104 | echo ' *** zlib shared test OK ***'; \ |
| 105 | else \ |
| 106 | echo ' *** zlib shared test FAILED ***'; false; \ |
| 107 | fi |
| 108 | @rm -f tmpsh_$$ |
| 109 | |
| 110 | test64: all64 |
| 111 | @TMP64=tmp64_$$; \ |
| 112 | if echo hello world | ./minigzip64 | ./minigzip64 -d && ./example64 $$TMP64; then \ |
| 113 | echo ' *** zlib 64-bit test OK ***'; \ |
| 114 | else \ |
| 115 | echo ' *** zlib 64-bit test FAILED ***'; false; \ |
| 116 | fi |
| 117 | @rm -f tmp64_$$ |
| @@ -122,11 +118,11 @@ | |
| 122 | infcover: infcover.o libz.a |
| 123 | $(CC) $(CFLAGS) -o $@ infcover.o libz.a |
| 124 | |
| 125 | cover: infcover |
| 126 | rm -f *.gcda |
| 127 | ./infcover |
| 128 | gcov inf*.c |
| 129 | |
| 130 | libz.a: $(OBJS) |
| 131 | $(AR) $(ARFLAGS) $@ $(OBJS) |
| 132 | -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 |
| @@ -290,14 +286,14 @@ | |
| 290 | |
| 291 | minigzip$(EXE): minigzip.o $(STATICLIB) |
| 292 | $(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS) |
| 293 | |
| 294 | examplesh$(EXE): example.o $(SHAREDLIBV) |
| 295 | $(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV) |
| 296 | |
| 297 | minigzipsh$(EXE): minigzip.o $(SHAREDLIBV) |
| 298 | $(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV) |
| 299 | |
| 300 | example64$(EXE): example64.o $(STATICLIB) |
| 301 | $(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS) |
| 302 | |
| 303 | minigzip64$(EXE): minigzip64.o $(STATICLIB) |
| 304 |
| --- compat/zlib/Makefile.in | |
| +++ compat/zlib/Makefile.in | |
| @@ -5,14 +5,10 @@ | |
| 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 | |
| @@ -24,17 +20,17 @@ | |
| 20 | #CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ |
| 21 | # -Wstrict-prototypes -Wmissing-prototypes |
| 22 | |
| 23 | SFLAGS=-O |
| 24 | LDFLAGS= |
| 25 | TEST_LDFLAGS=$(LDFLAGS) -L. libz.a |
| 26 | LDSHARED=$(CC) |
| 27 | CPP=$(CC) -E |
| 28 | |
| 29 | STATICLIB=libz.a |
| 30 | SHAREDLIB=libz.so |
| 31 | SHAREDLIBV=libz.so.1.2.13 |
| 32 | SHAREDLIBM=libz.so.1 |
| 33 | LIBS=$(STATICLIB) $(SHAREDLIBV) |
| 34 | |
| 35 | AR=ar |
| 36 | ARFLAGS=rc |
| @@ -85,11 +81,11 @@ | |
| 81 | |
| 82 | test: all teststatic testshared |
| 83 | |
| 84 | teststatic: static |
| 85 | @TMPST=tmpst_$$; \ |
| 86 | if echo hello world | ${QEMU_RUN} ./minigzip | ${QEMU_RUN} ./minigzip -d && ${QEMU_RUN} ./example $$TMPST ; then \ |
| 87 | echo ' *** zlib test OK ***'; \ |
| 88 | else \ |
| 89 | echo ' *** zlib test FAILED ***'; false; \ |
| 90 | fi |
| 91 | @rm -f tmpst_$$ |
| @@ -98,20 +94,20 @@ | |
| 94 | @LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ |
| 95 | LD_LIBRARYN32_PATH=`pwd`:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \ |
| 96 | DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \ |
| 97 | SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \ |
| 98 | TMPSH=tmpsh_$$; \ |
| 99 | if echo hello world | ${QEMU_RUN} ./minigzipsh | ${QEMU_RUN} ./minigzipsh -d && ${QEMU_RUN} ./examplesh $$TMPSH; then \ |
| 100 | echo ' *** zlib shared test OK ***'; \ |
| 101 | else \ |
| 102 | echo ' *** zlib shared test FAILED ***'; false; \ |
| 103 | fi |
| 104 | @rm -f tmpsh_$$ |
| 105 | |
| 106 | test64: all64 |
| 107 | @TMP64=tmp64_$$; \ |
| 108 | if echo hello world | ${QEMU_RUN} ./minigzip64 | ${QEMU_RUN} ./minigzip64 -d && ${QEMU_RUN} ./example64 $$TMP64; then \ |
| 109 | echo ' *** zlib 64-bit test OK ***'; \ |
| 110 | else \ |
| 111 | echo ' *** zlib 64-bit test FAILED ***'; false; \ |
| 112 | fi |
| 113 | @rm -f tmp64_$$ |
| @@ -122,11 +118,11 @@ | |
| 118 | infcover: infcover.o libz.a |
| 119 | $(CC) $(CFLAGS) -o $@ infcover.o libz.a |
| 120 | |
| 121 | cover: infcover |
| 122 | rm -f *.gcda |
| 123 | ${QEMU_RUN} ./infcover |
| 124 | gcov inf*.c |
| 125 | |
| 126 | libz.a: $(OBJS) |
| 127 | $(AR) $(ARFLAGS) $@ $(OBJS) |
| 128 | -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 |
| @@ -290,14 +286,14 @@ | |
| 286 | |
| 287 | minigzip$(EXE): minigzip.o $(STATICLIB) |
| 288 | $(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS) |
| 289 | |
| 290 | examplesh$(EXE): example.o $(SHAREDLIBV) |
| 291 | $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS) -L. $(SHAREDLIBV) |
| 292 | |
| 293 | minigzipsh$(EXE): minigzip.o $(SHAREDLIBV) |
| 294 | $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) -L. $(SHAREDLIBV) |
| 295 | |
| 296 | example64$(EXE): example64.o $(STATICLIB) |
| 297 | $(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS) |
| 298 | |
| 299 | minigzip64$(EXE): minigzip64.o $(STATICLIB) |
| 300 |
+2
-2
| --- compat/zlib/README | ||
| +++ compat/zlib/README | ||
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | ZLIB DATA COMPRESSION LIBRARY |
| 2 | 2 | |
| 3 | -zlib 1.2.12 is a general purpose data compression library. All the code is | |
| 3 | +zlib 1.2.13 is a general purpose data compression library. All the code is | |
| 4 | 4 | thread safe. The data format used by the zlib library is described by RFCs |
| 5 | 5 | (Request for Comments) 1950 to 1952 in the files |
| 6 | 6 | http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and |
| 7 | 7 | rfc1952 (gzip format). |
| 8 | 8 | |
| @@ -29,11 +29,11 @@ | ||
| 29 | 29 | |
| 30 | 30 | Mark Nelson <[email protected]> wrote an article about zlib for the Jan. 1997 |
| 31 | 31 | issue of Dr. Dobb's Journal; a copy of the article is available at |
| 32 | 32 | http://marknelson.us/1997/01/01/zlib-engine/ . |
| 33 | 33 | |
| 34 | -The changes made in version 1.2.12 are documented in the file ChangeLog. | |
| 34 | +The changes made in version 1.2.13 are documented in the file ChangeLog. | |
| 35 | 35 | |
| 36 | 36 | Unsupported third party contributions are provided in directory contrib/ . |
| 37 | 37 | |
| 38 | 38 | zlib is available in Java using the java.util.zip package, documented at |
| 39 | 39 | http://java.sun.com/developer/technicalArticles/Programming/compression/ . |
| 40 | 40 |
| --- compat/zlib/README | |
| +++ compat/zlib/README | |
| @@ -1,8 +1,8 @@ | |
| 1 | ZLIB DATA COMPRESSION LIBRARY |
| 2 | |
| 3 | zlib 1.2.12 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 | |
| @@ -29,11 +29,11 @@ | |
| 29 | |
| 30 | Mark Nelson <[email protected]> wrote an article about zlib for the Jan. 1997 |
| 31 | issue of Dr. Dobb's Journal; a copy of the article is available at |
| 32 | http://marknelson.us/1997/01/01/zlib-engine/ . |
| 33 | |
| 34 | The changes made in version 1.2.12 are documented in the file ChangeLog. |
| 35 | |
| 36 | Unsupported third party contributions are provided in directory contrib/ . |
| 37 | |
| 38 | zlib is available in Java using the java.util.zip package, documented at |
| 39 | http://java.sun.com/developer/technicalArticles/Programming/compression/ . |
| 40 |
| --- compat/zlib/README | |
| +++ compat/zlib/README | |
| @@ -1,8 +1,8 @@ | |
| 1 | ZLIB DATA COMPRESSION LIBRARY |
| 2 | |
| 3 | zlib 1.2.13 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 | |
| @@ -29,11 +29,11 @@ | |
| 29 | |
| 30 | Mark Nelson <[email protected]> wrote an article about zlib for the Jan. 1997 |
| 31 | issue of Dr. Dobb's Journal; a copy of the article is available at |
| 32 | http://marknelson.us/1997/01/01/zlib-engine/ . |
| 33 | |
| 34 | The changes made in version 1.2.13 are documented in the file ChangeLog. |
| 35 | |
| 36 | Unsupported third party contributions are provided in directory contrib/ . |
| 37 | |
| 38 | zlib is available in Java using the java.util.zip package, documented at |
| 39 | http://java.sun.com/developer/technicalArticles/Programming/compression/ . |
| 40 |
+3
-3
| --- compat/zlib/compress.c | ||
| +++ compat/zlib/compress.c | ||
| @@ -17,11 +17,11 @@ | ||
| 17 | 17 | |
| 18 | 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough |
| 19 | 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, |
| 20 | 20 | Z_STREAM_ERROR if the level parameter is invalid. |
| 21 | 21 | */ |
| 22 | -int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) | |
| 22 | +int ZEXPORT compress2(dest, destLen, source, sourceLen, level) | |
| 23 | 23 | Bytef *dest; |
| 24 | 24 | uLongf *destLen; |
| 25 | 25 | const Bytef *source; |
| 26 | 26 | uLong sourceLen; |
| 27 | 27 | int level; |
| @@ -63,11 +63,11 @@ | ||
| 63 | 63 | return err == Z_STREAM_END ? Z_OK : err; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /* =========================================================================== |
| 67 | 67 | */ |
| 68 | -int ZEXPORT compress (dest, destLen, source, sourceLen) | |
| 68 | +int ZEXPORT compress(dest, destLen, source, sourceLen) | |
| 69 | 69 | Bytef *dest; |
| 70 | 70 | uLongf *destLen; |
| 71 | 71 | const Bytef *source; |
| 72 | 72 | uLong sourceLen; |
| 73 | 73 | { |
| @@ -76,11 +76,11 @@ | ||
| 76 | 76 | |
| 77 | 77 | /* =========================================================================== |
| 78 | 78 | If the default memLevel or windowBits for deflateInit() is changed, then |
| 79 | 79 | this function needs to be updated. |
| 80 | 80 | */ |
| 81 | -uLong ZEXPORT compressBound (sourceLen) | |
| 81 | +uLong ZEXPORT compressBound(sourceLen) | |
| 82 | 82 | uLong sourceLen; |
| 83 | 83 | { |
| 84 | 84 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + |
| 85 | 85 | (sourceLen >> 25) + 13; |
| 86 | 86 | } |
| 87 | 87 |
| --- compat/zlib/compress.c | |
| +++ compat/zlib/compress.c | |
| @@ -17,11 +17,11 @@ | |
| 17 | |
| 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough |
| 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, |
| 20 | Z_STREAM_ERROR if the level parameter is invalid. |
| 21 | */ |
| 22 | int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) |
| 23 | Bytef *dest; |
| 24 | uLongf *destLen; |
| 25 | const Bytef *source; |
| 26 | uLong sourceLen; |
| 27 | int level; |
| @@ -63,11 +63,11 @@ | |
| 63 | return err == Z_STREAM_END ? Z_OK : err; |
| 64 | } |
| 65 | |
| 66 | /* =========================================================================== |
| 67 | */ |
| 68 | int ZEXPORT compress (dest, destLen, source, sourceLen) |
| 69 | Bytef *dest; |
| 70 | uLongf *destLen; |
| 71 | const Bytef *source; |
| 72 | uLong sourceLen; |
| 73 | { |
| @@ -76,11 +76,11 @@ | |
| 76 | |
| 77 | /* =========================================================================== |
| 78 | If the default memLevel or windowBits for deflateInit() is changed, then |
| 79 | this function needs to be updated. |
| 80 | */ |
| 81 | uLong ZEXPORT compressBound (sourceLen) |
| 82 | uLong sourceLen; |
| 83 | { |
| 84 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + |
| 85 | (sourceLen >> 25) + 13; |
| 86 | } |
| 87 |
| --- compat/zlib/compress.c | |
| +++ compat/zlib/compress.c | |
| @@ -17,11 +17,11 @@ | |
| 17 | |
| 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough |
| 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, |
| 20 | Z_STREAM_ERROR if the level parameter is invalid. |
| 21 | */ |
| 22 | int ZEXPORT compress2(dest, destLen, source, sourceLen, level) |
| 23 | Bytef *dest; |
| 24 | uLongf *destLen; |
| 25 | const Bytef *source; |
| 26 | uLong sourceLen; |
| 27 | int level; |
| @@ -63,11 +63,11 @@ | |
| 63 | return err == Z_STREAM_END ? Z_OK : err; |
| 64 | } |
| 65 | |
| 66 | /* =========================================================================== |
| 67 | */ |
| 68 | int ZEXPORT compress(dest, destLen, source, sourceLen) |
| 69 | Bytef *dest; |
| 70 | uLongf *destLen; |
| 71 | const Bytef *source; |
| 72 | uLong sourceLen; |
| 73 | { |
| @@ -76,11 +76,11 @@ | |
| 76 | |
| 77 | /* =========================================================================== |
| 78 | If the default memLevel or windowBits for deflateInit() is changed, then |
| 79 | this function needs to be updated. |
| 80 | */ |
| 81 | uLong ZEXPORT compressBound(sourceLen) |
| 82 | uLong sourceLen; |
| 83 | { |
| 84 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + |
| 85 | (sourceLen >> 25) + 13; |
| 86 | } |
| 87 |
+46
-51
| --- compat/zlib/configure | ||
| +++ compat/zlib/configure | ||
| @@ -30,12 +30,15 @@ | ||
| 30 | 30 | SRCDIR="$SRCDIR/" |
| 31 | 31 | fi |
| 32 | 32 | |
| 33 | 33 | # set command prefix for cross-compilation |
| 34 | 34 | if [ -n "${CHOST}" ]; then |
| 35 | - uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`" | |
| 35 | + uname=${CHOST} | |
| 36 | + mname=${CHOST} | |
| 36 | 37 | CROSS_PREFIX="${CHOST}-" |
| 38 | +else | |
| 39 | + mname=`(uname -a || echo unknown) 2>/dev/null` | |
| 37 | 40 | fi |
| 38 | 41 | |
| 39 | 42 | # destination name for static library |
| 40 | 43 | STATICLIB=libz.a |
| 41 | 44 | |
| @@ -172,13 +175,14 @@ | ||
| 172 | 175 | if ${CROSS_PREFIX}gcc -v >/dev/null 2>&1; then |
| 173 | 176 | cc=${CROSS_PREFIX}gcc |
| 174 | 177 | else |
| 175 | 178 | cc=${CROSS_PREFIX}cc |
| 176 | 179 | fi |
| 180 | +else | |
| 181 | + cc=${CC} | |
| 177 | 182 | fi |
| 178 | -cflags=${CFLAGS-"-O3"} | |
| 179 | -# to force the asm version use: CFLAGS="-O3 -DASMV" ./configure | |
| 183 | + | |
| 180 | 184 | case "$cc" in |
| 181 | 185 | *gcc*) gcc=1 ;; |
| 182 | 186 | *clang*) gcc=1 ;; |
| 183 | 187 | esac |
| 184 | 188 | case `$cc -v 2>&1` in |
| @@ -200,67 +204,72 @@ | ||
| 200 | 204 | CFLAGS="${CFLAGS} -m64" |
| 201 | 205 | SFLAGS="${SFLAGS} -m64" |
| 202 | 206 | fi |
| 203 | 207 | if test "$warn" -eq 1; then |
| 204 | 208 | if test "$zconst" -eq 1; then |
| 205 | - CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -pedantic -DZLIB_CONST" | |
| 209 | + CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -DZLIB_CONST" | |
| 206 | 210 | else |
| 207 | - CFLAGS="${CFLAGS} -Wall -Wextra -pedantic" | |
| 211 | + CFLAGS="${CFLAGS} -Wall -Wextra" | |
| 208 | 212 | fi |
| 209 | 213 | fi |
| 210 | 214 | if test $sanitize -eq 1; then |
| 211 | - CFLAGS="${CFLAGS} -fsanitize=address" | |
| 215 | + CFLAGS="${CFLAGS} -g -fsanitize=address" | |
| 212 | 216 | fi |
| 213 | 217 | if test $debug -eq 1; then |
| 214 | 218 | CFLAGS="${CFLAGS} -DZLIB_DEBUG" |
| 215 | 219 | SFLAGS="${SFLAGS} -DZLIB_DEBUG" |
| 216 | 220 | fi |
| 217 | 221 | if test -z "$uname"; then |
| 218 | 222 | uname=`(uname -s || echo unknown) 2>/dev/null` |
| 219 | 223 | fi |
| 220 | 224 | case "$uname" in |
| 221 | - Linux* | linux* | GNU | GNU/* | solaris*) | |
| 225 | + Linux* | linux* | *-linux* | GNU | GNU/* | solaris*) | |
| 226 | + case "$mname" in | |
| 227 | + *sparc*) | |
| 228 | + LDFLAGS="${LDFLAGS} -Wl,--no-warn-rwx-segments" ;; | |
| 229 | + esac | |
| 222 | 230 | LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;; |
| 223 | 231 | *BSD | *bsd* | DragonFly) |
| 224 | 232 | LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} |
| 225 | 233 | LDCONFIG="ldconfig -m" ;; |
| 226 | - CYGWIN* | Cygwin* | cygwin* | OS/2*) | |
| 234 | + CYGWIN* | Cygwin* | cygwin* | *-cygwin* | OS/2*) | |
| 227 | 235 | EXE='.exe' ;; |
| 228 | - MINGW* | mingw*) | |
| 229 | -# temporary bypass | |
| 236 | + MINGW* | mingw* | *-mingw*) | |
| 230 | 237 | rm -f $test.[co] $test $test$shared_ext |
| 231 | - echo "Please use win32/Makefile.gcc instead." | tee -a configure.log | |
| 232 | - leave 1 | |
| 238 | + echo "If this doesn't work for you, try win32/Makefile.gcc." | tee -a configure.log | |
| 233 | 239 | LDSHARED=${LDSHARED-"$cc -shared"} |
| 234 | 240 | LDSHAREDLIBC="" |
| 235 | 241 | EXE='.exe' ;; |
| 236 | - QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4 | |
| 237 | - # ([email protected]) | |
| 238 | - LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;; | |
| 242 | + QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4 | |
| 243 | + # ([email protected]) | |
| 244 | + LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;; | |
| 239 | 245 | HP-UX*) |
| 240 | - LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"} | |
| 241 | - case `(uname -m || echo unknown) 2>/dev/null` in | |
| 242 | - ia64) | |
| 243 | - shared_ext='.so' | |
| 244 | - SHAREDLIB='libz.so' ;; | |
| 245 | - *) | |
| 246 | - shared_ext='.sl' | |
| 247 | - SHAREDLIB='libz.sl' ;; | |
| 248 | - esac ;; | |
| 249 | - Darwin* | darwin*) | |
| 250 | - shared_ext='.dylib' | |
| 251 | - SHAREDLIB=libz$shared_ext | |
| 252 | - SHAREDLIBV=libz.$VER$shared_ext | |
| 253 | - SHAREDLIBM=libz.$VER1$shared_ext | |
| 254 | - LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"} | |
| 255 | - if libtool -V 2>&1 | grep Apple > /dev/null; then | |
| 256 | - AR="libtool" | |
| 257 | - else | |
| 258 | - AR="/usr/bin/libtool" | |
| 259 | - fi | |
| 260 | - ARFLAGS="-o" ;; | |
| 261 | - *) LDSHARED=${LDSHARED-"$cc -shared"} ;; | |
| 246 | + LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"} | |
| 247 | + case `(uname -m || echo unknown) 2>/dev/null` in | |
| 248 | + ia64) | |
| 249 | + shared_ext='.so' | |
| 250 | + SHAREDLIB='libz.so' ;; | |
| 251 | + *) | |
| 252 | + shared_ext='.sl' | |
| 253 | + SHAREDLIB='libz.sl' ;; | |
| 254 | + esac ;; | |
| 255 | + AIX*) | |
| 256 | + LDFLAGS="${LDFLAGS} -Wl,-brtl" ;; | |
| 257 | + Darwin* | darwin* | *-darwin*) | |
| 258 | + shared_ext='.dylib' | |
| 259 | + SHAREDLIB=libz$shared_ext | |
| 260 | + SHAREDLIBV=libz.$VER$shared_ext | |
| 261 | + SHAREDLIBM=libz.$VER1$shared_ext | |
| 262 | + LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"} | |
| 263 | + if libtool -V 2>&1 | grep Apple > /dev/null; then | |
| 264 | + AR="libtool" | |
| 265 | + else | |
| 266 | + AR="/usr/bin/libtool" | |
| 267 | + fi | |
| 268 | + ARFLAGS="-o" ;; | |
| 269 | + *) | |
| 270 | + LDSHARED=${LDSHARED-"$cc -shared"} ;; | |
| 262 | 271 | esac |
| 263 | 272 | else |
| 264 | 273 | # find system name and corresponding cc options |
| 265 | 274 | CC=${CC-cc} |
| 266 | 275 | gcc=0 |
| @@ -448,24 +457,10 @@ | ||
| 448 | 457 | else |
| 449 | 458 | ALL="static shared" |
| 450 | 459 | TEST="all teststatic testshared" |
| 451 | 460 | fi |
| 452 | 461 | |
| 453 | -# check for underscores in external names for use by assembler code | |
| 454 | -CPP=${CPP-"$CC -E"} | |
| 455 | -case $CFLAGS in | |
| 456 | - *ASMV*) | |
| 457 | - echo >> configure.log | |
| 458 | - show "$NM $test.o | grep _hello" | |
| 459 | - if test "`$NM $test.o | grep _hello | tee -a configure.log`" = ""; then | |
| 460 | - CPP="$CPP -DNO_UNDERLINE" | |
| 461 | - echo Checking for underline in external names... No. | tee -a configure.log | |
| 462 | - else | |
| 463 | - echo Checking for underline in external names... Yes. | tee -a configure.log | |
| 464 | - fi ;; | |
| 465 | -esac | |
| 466 | - | |
| 467 | 462 | echo >> configure.log |
| 468 | 463 | |
| 469 | 464 | # check for size_t |
| 470 | 465 | cat > $test.c <<EOF |
| 471 | 466 | #include <stdio.h> |
| 472 | 467 |
| --- compat/zlib/configure | |
| +++ compat/zlib/configure | |
| @@ -30,12 +30,15 @@ | |
| 30 | SRCDIR="$SRCDIR/" |
| 31 | fi |
| 32 | |
| 33 | # set command prefix for cross-compilation |
| 34 | if [ -n "${CHOST}" ]; then |
| 35 | uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`" |
| 36 | CROSS_PREFIX="${CHOST}-" |
| 37 | fi |
| 38 | |
| 39 | # destination name for static library |
| 40 | STATICLIB=libz.a |
| 41 | |
| @@ -172,13 +175,14 @@ | |
| 172 | if ${CROSS_PREFIX}gcc -v >/dev/null 2>&1; then |
| 173 | cc=${CROSS_PREFIX}gcc |
| 174 | else |
| 175 | cc=${CROSS_PREFIX}cc |
| 176 | fi |
| 177 | fi |
| 178 | cflags=${CFLAGS-"-O3"} |
| 179 | # to force the asm version use: CFLAGS="-O3 -DASMV" ./configure |
| 180 | case "$cc" in |
| 181 | *gcc*) gcc=1 ;; |
| 182 | *clang*) gcc=1 ;; |
| 183 | esac |
| 184 | case `$cc -v 2>&1` in |
| @@ -200,67 +204,72 @@ | |
| 200 | CFLAGS="${CFLAGS} -m64" |
| 201 | SFLAGS="${SFLAGS} -m64" |
| 202 | fi |
| 203 | if test "$warn" -eq 1; then |
| 204 | if test "$zconst" -eq 1; then |
| 205 | CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -pedantic -DZLIB_CONST" |
| 206 | else |
| 207 | CFLAGS="${CFLAGS} -Wall -Wextra -pedantic" |
| 208 | fi |
| 209 | fi |
| 210 | if test $sanitize -eq 1; then |
| 211 | CFLAGS="${CFLAGS} -fsanitize=address" |
| 212 | fi |
| 213 | if test $debug -eq 1; then |
| 214 | CFLAGS="${CFLAGS} -DZLIB_DEBUG" |
| 215 | SFLAGS="${SFLAGS} -DZLIB_DEBUG" |
| 216 | fi |
| 217 | if test -z "$uname"; then |
| 218 | uname=`(uname -s || echo unknown) 2>/dev/null` |
| 219 | fi |
| 220 | case "$uname" in |
| 221 | Linux* | linux* | GNU | GNU/* | solaris*) |
| 222 | LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;; |
| 223 | *BSD | *bsd* | DragonFly) |
| 224 | LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} |
| 225 | LDCONFIG="ldconfig -m" ;; |
| 226 | CYGWIN* | Cygwin* | cygwin* | OS/2*) |
| 227 | EXE='.exe' ;; |
| 228 | MINGW* | mingw*) |
| 229 | # temporary bypass |
| 230 | rm -f $test.[co] $test $test$shared_ext |
| 231 | echo "Please use win32/Makefile.gcc instead." | tee -a configure.log |
| 232 | leave 1 |
| 233 | LDSHARED=${LDSHARED-"$cc -shared"} |
| 234 | LDSHAREDLIBC="" |
| 235 | EXE='.exe' ;; |
| 236 | QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4 |
| 237 | # ([email protected]) |
| 238 | LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;; |
| 239 | HP-UX*) |
| 240 | LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"} |
| 241 | case `(uname -m || echo unknown) 2>/dev/null` in |
| 242 | ia64) |
| 243 | shared_ext='.so' |
| 244 | SHAREDLIB='libz.so' ;; |
| 245 | *) |
| 246 | shared_ext='.sl' |
| 247 | SHAREDLIB='libz.sl' ;; |
| 248 | esac ;; |
| 249 | Darwin* | darwin*) |
| 250 | shared_ext='.dylib' |
| 251 | SHAREDLIB=libz$shared_ext |
| 252 | SHAREDLIBV=libz.$VER$shared_ext |
| 253 | SHAREDLIBM=libz.$VER1$shared_ext |
| 254 | LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"} |
| 255 | if libtool -V 2>&1 | grep Apple > /dev/null; then |
| 256 | AR="libtool" |
| 257 | else |
| 258 | AR="/usr/bin/libtool" |
| 259 | fi |
| 260 | ARFLAGS="-o" ;; |
| 261 | *) LDSHARED=${LDSHARED-"$cc -shared"} ;; |
| 262 | esac |
| 263 | else |
| 264 | # find system name and corresponding cc options |
| 265 | CC=${CC-cc} |
| 266 | gcc=0 |
| @@ -448,24 +457,10 @@ | |
| 448 | else |
| 449 | ALL="static shared" |
| 450 | TEST="all teststatic testshared" |
| 451 | fi |
| 452 | |
| 453 | # check for underscores in external names for use by assembler code |
| 454 | CPP=${CPP-"$CC -E"} |
| 455 | case $CFLAGS in |
| 456 | *ASMV*) |
| 457 | echo >> configure.log |
| 458 | show "$NM $test.o | grep _hello" |
| 459 | if test "`$NM $test.o | grep _hello | tee -a configure.log`" = ""; then |
| 460 | CPP="$CPP -DNO_UNDERLINE" |
| 461 | echo Checking for underline in external names... No. | tee -a configure.log |
| 462 | else |
| 463 | echo Checking for underline in external names... Yes. | tee -a configure.log |
| 464 | fi ;; |
| 465 | esac |
| 466 | |
| 467 | echo >> configure.log |
| 468 | |
| 469 | # check for size_t |
| 470 | cat > $test.c <<EOF |
| 471 | #include <stdio.h> |
| 472 |
| --- compat/zlib/configure | |
| +++ compat/zlib/configure | |
| @@ -30,12 +30,15 @@ | |
| 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 | |
| @@ -172,13 +175,14 @@ | |
| 175 | if ${CROSS_PREFIX}gcc -v >/dev/null 2>&1; then |
| 176 | cc=${CROSS_PREFIX}gcc |
| 177 | else |
| 178 | cc=${CROSS_PREFIX}cc |
| 179 | fi |
| 180 | else |
| 181 | cc=${CC} |
| 182 | fi |
| 183 | |
| 184 | case "$cc" in |
| 185 | *gcc*) gcc=1 ;; |
| 186 | *clang*) gcc=1 ;; |
| 187 | esac |
| 188 | case `$cc -v 2>&1` in |
| @@ -200,67 +204,72 @@ | |
| 204 | CFLAGS="${CFLAGS} -m64" |
| 205 | SFLAGS="${SFLAGS} -m64" |
| 206 | fi |
| 207 | if test "$warn" -eq 1; then |
| 208 | if test "$zconst" -eq 1; then |
| 209 | CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -DZLIB_CONST" |
| 210 | else |
| 211 | CFLAGS="${CFLAGS} -Wall -Wextra" |
| 212 | fi |
| 213 | fi |
| 214 | if test $sanitize -eq 1; then |
| 215 | CFLAGS="${CFLAGS} -g -fsanitize=address" |
| 216 | fi |
| 217 | if test $debug -eq 1; then |
| 218 | CFLAGS="${CFLAGS} -DZLIB_DEBUG" |
| 219 | SFLAGS="${SFLAGS} -DZLIB_DEBUG" |
| 220 | fi |
| 221 | if test -z "$uname"; then |
| 222 | uname=`(uname -s || echo unknown) 2>/dev/null` |
| 223 | fi |
| 224 | case "$uname" in |
| 225 | Linux* | linux* | *-linux* | GNU | GNU/* | solaris*) |
| 226 | case "$mname" in |
| 227 | *sparc*) |
| 228 | LDFLAGS="${LDFLAGS} -Wl,--no-warn-rwx-segments" ;; |
| 229 | esac |
| 230 | LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;; |
| 231 | *BSD | *bsd* | DragonFly) |
| 232 | LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} |
| 233 | LDCONFIG="ldconfig -m" ;; |
| 234 | CYGWIN* | Cygwin* | cygwin* | *-cygwin* | OS/2*) |
| 235 | EXE='.exe' ;; |
| 236 | MINGW* | mingw* | *-mingw*) |
| 237 | rm -f $test.[co] $test $test$shared_ext |
| 238 | echo "If this doesn't work for you, try win32/Makefile.gcc." | tee -a configure.log |
| 239 | LDSHARED=${LDSHARED-"$cc -shared"} |
| 240 | LDSHAREDLIBC="" |
| 241 | EXE='.exe' ;; |
| 242 | QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4 |
| 243 | # ([email protected]) |
| 244 | LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;; |
| 245 | HP-UX*) |
| 246 | LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"} |
| 247 | case `(uname -m || echo unknown) 2>/dev/null` in |
| 248 | ia64) |
| 249 | shared_ext='.so' |
| 250 | SHAREDLIB='libz.so' ;; |
| 251 | *) |
| 252 | shared_ext='.sl' |
| 253 | SHAREDLIB='libz.sl' ;; |
| 254 | esac ;; |
| 255 | AIX*) |
| 256 | LDFLAGS="${LDFLAGS} -Wl,-brtl" ;; |
| 257 | Darwin* | darwin* | *-darwin*) |
| 258 | shared_ext='.dylib' |
| 259 | SHAREDLIB=libz$shared_ext |
| 260 | SHAREDLIBV=libz.$VER$shared_ext |
| 261 | SHAREDLIBM=libz.$VER1$shared_ext |
| 262 | LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"} |
| 263 | if libtool -V 2>&1 | grep Apple > /dev/null; then |
| 264 | AR="libtool" |
| 265 | else |
| 266 | AR="/usr/bin/libtool" |
| 267 | fi |
| 268 | ARFLAGS="-o" ;; |
| 269 | *) |
| 270 | LDSHARED=${LDSHARED-"$cc -shared"} ;; |
| 271 | esac |
| 272 | else |
| 273 | # find system name and corresponding cc options |
| 274 | CC=${CC-cc} |
| 275 | gcc=0 |
| @@ -448,24 +457,10 @@ | |
| 457 | else |
| 458 | ALL="static shared" |
| 459 | TEST="all teststatic testshared" |
| 460 | fi |
| 461 | |
| 462 | echo >> configure.log |
| 463 | |
| 464 | # check for size_t |
| 465 | cat > $test.c <<EOF |
| 466 | #include <stdio.h> |
| 467 |
| --- compat/zlib/contrib/README.contrib | ||
| +++ compat/zlib/contrib/README.contrib | ||
| @@ -1,6 +1,6 @@ | ||
| 1 | -All files under this contrib directory are UNSUPPORTED. There were | |
| 1 | +All files under this contrib directory are UNSUPPORTED. They were | |
| 2 | 2 | provided by users of zlib and were not tested by the authors of zlib. |
| 3 | 3 | Use at your own risk. Please contact the authors of the contributions |
| 4 | 4 | for help about these, not the zlib authors. Thanks. |
| 5 | 5 | |
| 6 | 6 | |
| 7 | 7 | |
| 8 | 8 | DELETED compat/zlib/contrib/ada/buffer_demo.adb |
| 9 | 9 | DELETED compat/zlib/contrib/ada/mtest.adb |
| 10 | 10 | DELETED compat/zlib/contrib/ada/read.adb |
| 11 | 11 | DELETED compat/zlib/contrib/ada/readme.txt |
| 12 | 12 | DELETED compat/zlib/contrib/ada/test.adb |
| 13 | 13 | DELETED compat/zlib/contrib/ada/zlib-streams.adb |
| 14 | 14 | DELETED compat/zlib/contrib/ada/zlib-streams.ads |
| 15 | 15 | DELETED compat/zlib/contrib/ada/zlib-thin.adb |
| 16 | 16 | DELETED compat/zlib/contrib/ada/zlib-thin.ads |
| 17 | 17 | DELETED compat/zlib/contrib/ada/zlib.adb |
| 18 | 18 | DELETED compat/zlib/contrib/ada/zlib.ads |
| 19 | 19 | DELETED compat/zlib/contrib/ada/zlib.gpr |
| 20 | 20 | DELETED compat/zlib/contrib/amd64/amd64-match.S |
| 21 | 21 | DELETED compat/zlib/contrib/asm686/README.686 |
| 22 | 22 | DELETED compat/zlib/contrib/asm686/match.S |
| --- compat/zlib/contrib/README.contrib | |
| +++ compat/zlib/contrib/README.contrib | |
| @@ -1,6 +1,6 @@ | |
| 1 | All files under this contrib directory are UNSUPPORTED. There 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 | |
| 8 | ELETED compat/zlib/contrib/ada/buffer_demo.adb |
| 9 | ELETED compat/zlib/contrib/ada/mtest.adb |
| 10 | ELETED compat/zlib/contrib/ada/read.adb |
| 11 | ELETED compat/zlib/contrib/ada/readme.txt |
| 12 | ELETED compat/zlib/contrib/ada/test.adb |
| 13 | ELETED compat/zlib/contrib/ada/zlib-streams.adb |
| 14 | ELETED compat/zlib/contrib/ada/zlib-streams.ads |
| 15 | ELETED compat/zlib/contrib/ada/zlib-thin.adb |
| 16 | ELETED compat/zlib/contrib/ada/zlib-thin.ads |
| 17 | ELETED compat/zlib/contrib/ada/zlib.adb |
| 18 | ELETED compat/zlib/contrib/ada/zlib.ads |
| 19 | ELETED compat/zlib/contrib/ada/zlib.gpr |
| 20 | ELETED compat/zlib/contrib/amd64/amd64-match.S |
| 21 | ELETED compat/zlib/contrib/asm686/README.686 |
| 22 | ELETED compat/zlib/contrib/asm686/match.S |
| --- compat/zlib/contrib/README.contrib | |
| +++ compat/zlib/contrib/README.contrib | |
| @@ -1,6 +1,6 @@ | |
| 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 | |
| 8 | ELETED compat/zlib/contrib/ada/buffer_demo.adb |
| 9 | ELETED compat/zlib/contrib/ada/mtest.adb |
| 10 | ELETED compat/zlib/contrib/ada/read.adb |
| 11 | ELETED compat/zlib/contrib/ada/readme.txt |
| 12 | ELETED compat/zlib/contrib/ada/test.adb |
| 13 | ELETED compat/zlib/contrib/ada/zlib-streams.adb |
| 14 | ELETED compat/zlib/contrib/ada/zlib-streams.ads |
| 15 | ELETED compat/zlib/contrib/ada/zlib-thin.adb |
| 16 | ELETED compat/zlib/contrib/ada/zlib-thin.ads |
| 17 | ELETED compat/zlib/contrib/ada/zlib.adb |
| 18 | ELETED compat/zlib/contrib/ada/zlib.ads |
| 19 | ELETED compat/zlib/contrib/ada/zlib.gpr |
| 20 | ELETED compat/zlib/contrib/amd64/amd64-match.S |
| 21 | ELETED compat/zlib/contrib/asm686/README.686 |
| 22 | ELETED compat/zlib/contrib/asm686/match.S |
D
compat/zlib/contrib/ada/buffer_demo.adb
-90
| --- a/compat/zlib/contrib/ada/buffer_demo.adb | ||
| +++ b/compat/zlib/contrib/ada/buffer_demo.adb | ||
| @@ -1,106 +0,0 @@ | ||
| ----------------------------------------------------------------- | ||
| --- ZLib for Ada thick binding. -- | ||
| --- -- | ||
| --- Copyright (C) 2002-2004 Dmitriy Anisimkov -- | ||
| --- -- | ||
| --- Open source license information is in the zlib.ads file. -- | ||
| ----------------------------------------------------------------- | ||
| --- | ||
| --- $Id: buffer_demo.adb,v 1.3 2004/09/06 06:55:35 vagul Exp $ | ||
| 1 | - | |
| --- This demo program provided by Dr Steve Sangwine <[email protected]> | ||
| --- | ||
| --- Demonstration of a problem with Zlib-Ada (already fixed) when a buffer | ||
| --- of exactly the correct size is used for decompressed data, and the last | ||
| --- few bytes passed in to Zlib are checksum bytes. | ||
| 2 | - | |
| --- This program compresses a string of text, and then decompresses the | ||
| --- compressed text into a buffer of the same size as the original text. | ||
| 3 | - | |
| 4 | -with Ada.Streams; use Ada.Streams; | |
| 5 | -with Ada.Text_IO; | |
| 6 | - | |
| 7 | -with ZLib; use ZLib; | |
| 8 | - | |
| 9 | -procedure Buffer_Demo is | |
| 10 | - EOL : Character renames ASCII.LF; | |
| 11 | - Text : constant String | |
| 12 | - := "Four score and seven years ago our fathers brought forth," & EOL & | |
| 13 | - "upon this continent, a new nation, conceived in liberty," & EOL & | |
| 14 | - "and dedicated to the proposition that `all men are created equal'."; | |
| 15 | - | |
| 16 | - Source : Stream_Element_Array (1 .. Text'Length); | |
| 17 | - for Source'Address use Text'Address; | |
| 18 | - | |
| 19 | -begin | |
| 20 | - Ada.Text_IO.Put (Text); | |
| 21 | - Ada.Text_IO.New_Line; | |
| 22 | - Ada.Text_IO.Put_Line | |
| 23 | - ("Uncompressed size : " & Positive'Image (Text'Length) & " bytes"); | |
| 24 | - | |
| 25 | - declare | |
| 26 | - Compressed_Data : Stream_Element_Array (1 .. Text'Length); | |
| 27 | - L : Stream_Element_Offset; | |
| 28 | - begin | |
| 29 | - Compress : declare | |
| 30 | - Compressor : Filter_Type; | |
| 31 | - I : Stream_Element_Offset; | |
| 32 | - begin | |
| 33 | - Deflate_Init (Compressor); | |
| 34 | - | |
| 35 | - -- Compress the whole of T at once. | |
| 36 | - | |
| 37 | - Translate (Compressor, Source, I, Compressed_Data, L, Finish); | |
| 38 | - pragma Assert (I = Source'Last); | |
| 39 | - | |
| 40 | - Close (Compressor); | |
| 41 | - | |
| 42 | - Ada.Text_IO.Put_Line | |
| 43 | - ("Compressed size : " | |
| 44 | - & Stream_Element_Offset'Image (L) & " bytes"); | |
| 45 | - end Compress; | |
| 46 | - | |
| 47 | - -- Now we decompress the data, passing short blocks of data to Zlib | |
| 48 | - -- (because this demonstrates the problem - the last block passed will | |
| 49 | - -- contain checksum information and there will be no output, only a | |
| 50 | - -- check inside Zlib that the checksum is correct). | |
| 51 | - | |
| 52 | - Decompress : declare | |
| 53 | - Decompressor : Filter_Type; | |
| 54 | - | |
| 55 | - Uncompressed_Data : Stream_Element_Array (1 .. Text'Length); | |
| 56 | - | |
| 57 | - Block_Size : constant := 4; | |
| 58 | - -- This makes sure that the last block contains | |
| 59 | - -- only Adler checksum data. | |
| 60 | - | |
| 61 | - P : Stream_Element_Offset := Compressed_Data'First - 1; | |
| 62 | - O : Stream_Element_Offset; | |
| 63 | - begin | |
| 64 | - Inflate_Init (Decompressor); | |
| 65 | - | |
| 66 | - loop | |
| 67 | - Translate | |
| 68 | - (Decompressor, | |
| 69 | - Compressed_Data | |
| 70 | - (P + 1 .. Stream_Element_Offset'Min (P + Block_Size, L)), | |
| 71 | - P, | |
| 72 | - Uncompressed_Data | |
| 73 | - (Total_Out (Decompressor) + 1 .. Uncompressed_Data'Last), | |
| 74 | - O, | |
| 75 | - No_Flush); | |
| 76 | - | |
| 77 | - Ada.Text_IO.Put_Line | |
| 78 | - ("Total in : " & Count'Image (Total_In (Decompressor)) & | |
| 79 | - ", out : " & Count'Image (Total_Out (Decompressor))); | |
| 80 | - | |
| 81 | - exit when P = L; | |
| 82 | - end loop; | |
| 83 | - | |
| 84 | - Ada.Text_IO.New_Line; | |
| 85 | - Ada.Text_IO.Put_Line | |
| 86 | - ("Decompressed text matches original text : " | |
| 87 | - & Boolean'Image (Uncompressed_Data = Source)); | |
| 88 | - end Decompress; | |
| 89 | - end; | |
| 90 | -end Buffer_Demo; |
| --- a/compat/zlib/contrib/ada/buffer_demo.adb | |
| +++ b/compat/zlib/contrib/ada/buffer_demo.adb | |
| @@ -1,106 +0,0 @@ | |
| ----------------------------------------------------------------- | |
| --- ZLib for Ada thick binding. -- | |
| --- -- | |
| --- Copyright (C) 2002-2004 Dmitriy Anisimkov -- | |
| --- -- | |
| --- Open source license information is in the zlib.ads file. -- | |
| ----------------------------------------------------------------- | |
| --- | |
| --- $Id: buffer_demo.adb,v 1.3 2004/09/06 06:55:35 vagul Exp $ | |
| 1 | |
| --- This demo program provided by Dr Steve Sangwine <[email protected]> | |
| --- | |
| --- Demonstration of a problem with Zlib-Ada (already fixed) when a buffer | |
| --- of exactly the correct size is used for decompressed data, and the last | |
| --- few bytes passed in to Zlib are checksum bytes. | |
| 2 | |
| --- This program compresses a string of text, and then decompresses the | |
| --- compressed text into a buffer of the same size as the original text. | |
| 3 | |
| 4 | with Ada.Streams; use Ada.Streams; |
| 5 | with Ada.Text_IO; |
| 6 | |
| 7 | with ZLib; use ZLib; |
| 8 | |
| 9 | procedure Buffer_Demo is |
| 10 | EOL : Character renames ASCII.LF; |
| 11 | Text : constant String |
| 12 | := "Four score and seven years ago our fathers brought forth," & EOL & |
| 13 | "upon this continent, a new nation, conceived in liberty," & EOL & |
| 14 | "and dedicated to the proposition that `all men are created equal'."; |
| 15 | |
| 16 | Source : Stream_Element_Array (1 .. Text'Length); |
| 17 | for Source'Address use Text'Address; |
| 18 | |
| 19 | begin |
| 20 | Ada.Text_IO.Put (Text); |
| 21 | Ada.Text_IO.New_Line; |
| 22 | Ada.Text_IO.Put_Line |
| 23 | ("Uncompressed size : " & Positive'Image (Text'Length) & " bytes"); |
| 24 | |
| 25 | declare |
| 26 | Compressed_Data : Stream_Element_Array (1 .. Text'Length); |
| 27 | L : Stream_Element_Offset; |
| 28 | begin |
| 29 | Compress : declare |
| 30 | Compressor : Filter_Type; |
| 31 | I : Stream_Element_Offset; |
| 32 | begin |
| 33 | Deflate_Init (Compressor); |
| 34 | |
| 35 | -- Compress the whole of T at once. |
| 36 | |
| 37 | Translate (Compressor, Source, I, Compressed_Data, L, Finish); |
| 38 | pragma Assert (I = Source'Last); |
| 39 | |
| 40 | Close (Compressor); |
| 41 | |
| 42 | Ada.Text_IO.Put_Line |
| 43 | ("Compressed size : " |
| 44 | & Stream_Element_Offset'Image (L) & " bytes"); |
| 45 | end Compress; |
| 46 | |
| 47 | -- Now we decompress the data, passing short blocks of data to Zlib |
| 48 | -- (because this demonstrates the problem - the last block passed will |
| 49 | -- contain checksum information and there will be no output, only a |
| 50 | -- check inside Zlib that the checksum is correct). |
| 51 | |
| 52 | Decompress : declare |
| 53 | Decompressor : Filter_Type; |
| 54 | |
| 55 | Uncompressed_Data : Stream_Element_Array (1 .. Text'Length); |
| 56 | |
| 57 | Block_Size : constant := 4; |
| 58 | -- This makes sure that the last block contains |
| 59 | -- only Adler checksum data. |
| 60 | |
| 61 | P : Stream_Element_Offset := Compressed_Data'First - 1; |
| 62 | O : Stream_Element_Offset; |
| 63 | begin |
| 64 | Inflate_Init (Decompressor); |
| 65 | |
| 66 | loop |
| 67 | Translate |
| 68 | (Decompressor, |
| 69 | Compressed_Data |
| 70 | (P + 1 .. Stream_Element_Offset'Min (P + Block_Size, L)), |
| 71 | P, |
| 72 | Uncompressed_Data |
| 73 | (Total_Out (Decompressor) + 1 .. Uncompressed_Data'Last), |
| 74 | O, |
| 75 | No_Flush); |
| 76 | |
| 77 | Ada.Text_IO.Put_Line |
| 78 | ("Total in : " & Count'Image (Total_In (Decompressor)) & |
| 79 | ", out : " & Count'Image (Total_Out (Decompressor))); |
| 80 | |
| 81 | exit when P = L; |
| 82 | end loop; |
| 83 | |
| 84 | Ada.Text_IO.New_Line; |
| 85 | Ada.Text_IO.Put_Line |
| 86 | ("Decompressed text matches original text : " |
| 87 | & Boolean'Image (Uncompressed_Data = Source)); |
| 88 | end Decompress; |
| 89 | end; |
| 90 | end Buffer_Demo; |
| --- a/compat/zlib/contrib/ada/buffer_demo.adb | |
| +++ b/compat/zlib/contrib/ada/buffer_demo.adb | |
| @@ -1,106 +0,0 @@ | |
| ----------------------------------------------------------------- | |
| --- ZLib for Ada thick binding. -- | |
| --- -- | |
| --- Copyright (C) 2002-2004 Dmitriy Anisimkov -- | |
| --- -- | |
| --- Open source license information is in the zlib.ads file. -- | |
| ----------------------------------------------------------------- | |
| --- | |
| --- $Id: buffer_demo.adb,v 1.3 2004/09/06 06:55:35 vagul Exp $ | |
| --- This demo program provided by Dr Steve Sangwine <[email protected]> | |
| --- | |
| --- Demonstration of a problem with Zlib-Ada (already fixed) when a buffer | |
| --- of exactly the correct size is used for decompressed data, and the last | |
| --- few bytes passed in to Zlib are checksum bytes. | |
| --- This program compresses a string of text, and then decompresses the | |
| --- compressed text into a buffer of the same size as the original text. | |
D
compat/zlib/contrib/ada/mtest.adb
-145
| --- a/compat/zlib/contrib/ada/mtest.adb | ||
| +++ b/compat/zlib/contrib/ada/mtest.adb | ||
| @@ -1,156 +0,0 @@ | ||
| ----------------------------------------------------------------- | ||
| --- ZLib for Ada thick binding. -- | ||
| --- -- | ||
| --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | ||
| --- -- | ||
| --- Open source license information is in the zlib.ads file. -- | ||
| ----------------------------------------------------------------- | ||
| --- Continuous test for ZLib multithreading. If the test would fail | ||
| --- we should provide thread safe allocation routines for the Z_Stream. | ||
| --- | ||
| --- $Id: mtest.adb,v 1.4 2004/07/23 07:49:54 vagul Exp $ | ||
| 1 | - | |
| 2 | -with ZLib; | |
| 3 | -with Ada.Streams; | |
| 4 | -with Ada.Numerics.Discrete_Random; | |
| 5 | -with Ada.Text_IO; | |
| 6 | -with Ada.Exceptions; | |
| 7 | -with Ada.Task_Identification; | |
| 8 | - | |
| 9 | -procedure MTest is | |
| 10 | - use Ada.Streams; | |
| 11 | - use ZLib; | |
| 12 | - | |
| 13 | - Stop : Boolean := False; | |
| 14 | - | |
| 15 | - pragma Atomic (Stop); | |
| 16 | - | |
| 17 | - subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#; | |
| 18 | - | |
| 19 | - package Random_Elements is | |
| 20 | - new Ada.Numerics.Discrete_Random (Visible_Symbols); | |
| 21 | - | |
| 22 | - task type Test_Task; | |
| 23 | - | |
| 24 | - task body Test_Task is | |
| 25 | - Buffer : Stream_Element_Array (1 .. 100_000); | |
| 26 | - Gen : Random_Elements.Generator; | |
| 27 | - | |
| 28 | - Buffer_First : Stream_Element_Offset; | |
| 29 | - Compare_First : Stream_Element_Offset; | |
| 30 | - | |
| 31 | - Deflate : Filter_Type; | |
| 32 | - Inflate : Filter_Type; | |
| 33 | - | |
| 34 | - procedure Further (Item : in Stream_Element_Array); | |
| 35 | - | |
| 36 | - procedure Read_Buffer | |
| 37 | - (Item : out Ada.Streams.Stream_Element_Array; | |
| 38 | - Last : out Ada.Streams.Stream_Element_Offset); | |
| 39 | - | |
| 40 | - ------------- | |
| 41 | - -- Further -- | |
| 42 | - ------------- | |
| 43 | - | |
| 44 | - procedure Further (Item : in Stream_Element_Array) is | |
| 45 | - | |
| 46 | - procedure Compare (Item : in Stream_Element_Array); | |
| 47 | - | |
| 48 | - ------------- | |
| 49 | - -- Compare -- | |
| 50 | - ------------- | |
| 51 | - | |
| 52 | - procedure Compare (Item : in Stream_Element_Array) is | |
| 53 | - Next_First : Stream_Element_Offset := Compare_First + Item'Length; | |
| 54 | - begin | |
| 55 | - if Buffer (Compare_First .. Next_First - 1) /= Item then | |
| 56 | - raise Program_Error; | |
| 57 | - end if; | |
| 58 | - | |
| 59 | - Compare_First := Next_First; | |
| 60 | - end Compare; | |
| 61 | - | |
| 62 | - procedure Compare_Write is new ZLib.Write (Write => Compare); | |
| 63 | - begin | |
| 64 | - Compare_Write (Inflate, Item, No_Flush); | |
| 65 | - end Further; | |
| 66 | - | |
| 67 | - ----------------- | |
| 68 | - -- Read_Buffer -- | |
| 69 | - ----------------- | |
| 70 | - | |
| 71 | - procedure Read_Buffer | |
| 72 | - (Item : out Ada.Streams.Stream_Element_Array; | |
| 73 | - Last : out Ada.Streams.Stream_Element_Offset) | |
| 74 | - is | |
| 75 | - Buff_Diff : Stream_Element_Offset := Buffer'Last - Buffer_First; | |
| 76 | - Next_First : Stream_Element_Offset; | |
| 77 | - begin | |
| 78 | - if Item'Length <= Buff_Diff then | |
| 79 | - Last := Item'Last; | |
| 80 | - | |
| 81 | - Next_First := Buffer_First + Item'Length; | |
| 82 | - | |
| 83 | - Item := Buffer (Buffer_First .. Next_First - 1); | |
| 84 | - | |
| 85 | - Buffer_First := Next_First; | |
| 86 | - else | |
| 87 | - Last := Item'First + Buff_Diff; | |
| 88 | - Item (Item'First .. Last) := Buffer (Buffer_First .. Buffer'Last); | |
| 89 | - Buffer_First := Buffer'Last + 1; | |
| 90 | - end if; | |
| 91 | - end Read_Buffer; | |
| 92 | - | |
| 93 | - procedure Translate is new Generic_Translate | |
| 94 | - (Data_In => Read_Buffer, | |
| 95 | - Data_Out => Further); | |
| 96 | - | |
| 97 | - begin | |
| 98 | - Random_Elements.Reset (Gen); | |
| 99 | - | |
| 100 | - Buffer := (others => 20); | |
| 101 | - | |
| 102 | - Main : loop | |
| 103 | - for J in Buffer'Range loop | |
| 104 | - Buffer (J) := Random_Elements.Random (Gen); | |
| 105 | - | |
| 106 | - Deflate_Init (Deflate); | |
| 107 | - Inflate_Init (Inflate); | |
| 108 | - | |
| 109 | - Buffer_First := Buffer'First; | |
| 110 | - Compare_First := Buffer'First; | |
| 111 | - | |
| 112 | - Translate (Deflate); | |
| 113 | - | |
| 114 | - if Compare_First /= Buffer'Last + 1 then | |
| 115 | - raise Program_Error; | |
| 116 | - end if; | |
| 117 | - | |
| 118 | - Ada.Text_IO.Put_Line | |
| 119 | - (Ada.Task_Identification.Image | |
| 120 | - (Ada.Task_Identification.Current_Task) | |
| 121 | - & Stream_Element_Offset'Image (J) | |
| 122 | - & ZLib.Count'Image (Total_Out (Deflate))); | |
| 123 | - | |
| 124 | - Close (Deflate); | |
| 125 | - Close (Inflate); | |
| 126 | - | |
| 127 | - exit Main when Stop; | |
| 128 | - end loop; | |
| 129 | - end loop Main; | |
| 130 | - exception | |
| 131 | - when E : others => | |
| 132 | - Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E)); | |
| 133 | - Stop := True; | |
| 134 | - end Test_Task; | |
| 135 | - | |
| 136 | - Test : array (1 .. 4) of Test_Task; | |
| 137 | - | |
| 138 | - pragma Unreferenced (Test); | |
| 139 | - | |
| 140 | - Dummy : Character; | |
| 141 | - | |
| 142 | -begin | |
| 143 | - Ada.Text_IO.Get_Immediate (Dummy); | |
| 144 | - Stop := True; | |
| 145 | -end MTest; |
| --- a/compat/zlib/contrib/ada/mtest.adb | |
| +++ b/compat/zlib/contrib/ada/mtest.adb | |
| @@ -1,156 +0,0 @@ | |
| ----------------------------------------------------------------- | |
| --- ZLib for Ada thick binding. -- | |
| --- -- | |
| --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | |
| --- -- | |
| --- Open source license information is in the zlib.ads file. -- | |
| ----------------------------------------------------------------- | |
| --- Continuous test for ZLib multithreading. If the test would fail | |
| --- we should provide thread safe allocation routines for the Z_Stream. | |
| --- | |
| --- $Id: mtest.adb,v 1.4 2004/07/23 07:49:54 vagul Exp $ | |
| 1 | |
| 2 | with ZLib; |
| 3 | with Ada.Streams; |
| 4 | with Ada.Numerics.Discrete_Random; |
| 5 | with Ada.Text_IO; |
| 6 | with Ada.Exceptions; |
| 7 | with Ada.Task_Identification; |
| 8 | |
| 9 | procedure MTest is |
| 10 | use Ada.Streams; |
| 11 | use ZLib; |
| 12 | |
| 13 | Stop : Boolean := False; |
| 14 | |
| 15 | pragma Atomic (Stop); |
| 16 | |
| 17 | subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#; |
| 18 | |
| 19 | package Random_Elements is |
| 20 | new Ada.Numerics.Discrete_Random (Visible_Symbols); |
| 21 | |
| 22 | task type Test_Task; |
| 23 | |
| 24 | task body Test_Task is |
| 25 | Buffer : Stream_Element_Array (1 .. 100_000); |
| 26 | Gen : Random_Elements.Generator; |
| 27 | |
| 28 | Buffer_First : Stream_Element_Offset; |
| 29 | Compare_First : Stream_Element_Offset; |
| 30 | |
| 31 | Deflate : Filter_Type; |
| 32 | Inflate : Filter_Type; |
| 33 | |
| 34 | procedure Further (Item : in Stream_Element_Array); |
| 35 | |
| 36 | procedure Read_Buffer |
| 37 | (Item : out Ada.Streams.Stream_Element_Array; |
| 38 | Last : out Ada.Streams.Stream_Element_Offset); |
| 39 | |
| 40 | ------------- |
| 41 | -- Further -- |
| 42 | ------------- |
| 43 | |
| 44 | procedure Further (Item : in Stream_Element_Array) is |
| 45 | |
| 46 | procedure Compare (Item : in Stream_Element_Array); |
| 47 | |
| 48 | ------------- |
| 49 | -- Compare -- |
| 50 | ------------- |
| 51 | |
| 52 | procedure Compare (Item : in Stream_Element_Array) is |
| 53 | Next_First : Stream_Element_Offset := Compare_First + Item'Length; |
| 54 | begin |
| 55 | if Buffer (Compare_First .. Next_First - 1) /= Item then |
| 56 | raise Program_Error; |
| 57 | end if; |
| 58 | |
| 59 | Compare_First := Next_First; |
| 60 | end Compare; |
| 61 | |
| 62 | procedure Compare_Write is new ZLib.Write (Write => Compare); |
| 63 | begin |
| 64 | Compare_Write (Inflate, Item, No_Flush); |
| 65 | end Further; |
| 66 | |
| 67 | ----------------- |
| 68 | -- Read_Buffer -- |
| 69 | ----------------- |
| 70 | |
| 71 | procedure Read_Buffer |
| 72 | (Item : out Ada.Streams.Stream_Element_Array; |
| 73 | Last : out Ada.Streams.Stream_Element_Offset) |
| 74 | is |
| 75 | Buff_Diff : Stream_Element_Offset := Buffer'Last - Buffer_First; |
| 76 | Next_First : Stream_Element_Offset; |
| 77 | begin |
| 78 | if Item'Length <= Buff_Diff then |
| 79 | Last := Item'Last; |
| 80 | |
| 81 | Next_First := Buffer_First + Item'Length; |
| 82 | |
| 83 | Item := Buffer (Buffer_First .. Next_First - 1); |
| 84 | |
| 85 | Buffer_First := Next_First; |
| 86 | else |
| 87 | Last := Item'First + Buff_Diff; |
| 88 | Item (Item'First .. Last) := Buffer (Buffer_First .. Buffer'Last); |
| 89 | Buffer_First := Buffer'Last + 1; |
| 90 | end if; |
| 91 | end Read_Buffer; |
| 92 | |
| 93 | procedure Translate is new Generic_Translate |
| 94 | (Data_In => Read_Buffer, |
| 95 | Data_Out => Further); |
| 96 | |
| 97 | begin |
| 98 | Random_Elements.Reset (Gen); |
| 99 | |
| 100 | Buffer := (others => 20); |
| 101 | |
| 102 | Main : loop |
| 103 | for J in Buffer'Range loop |
| 104 | Buffer (J) := Random_Elements.Random (Gen); |
| 105 | |
| 106 | Deflate_Init (Deflate); |
| 107 | Inflate_Init (Inflate); |
| 108 | |
| 109 | Buffer_First := Buffer'First; |
| 110 | Compare_First := Buffer'First; |
| 111 | |
| 112 | Translate (Deflate); |
| 113 | |
| 114 | if Compare_First /= Buffer'Last + 1 then |
| 115 | raise Program_Error; |
| 116 | end if; |
| 117 | |
| 118 | Ada.Text_IO.Put_Line |
| 119 | (Ada.Task_Identification.Image |
| 120 | (Ada.Task_Identification.Current_Task) |
| 121 | & Stream_Element_Offset'Image (J) |
| 122 | & ZLib.Count'Image (Total_Out (Deflate))); |
| 123 | |
| 124 | Close (Deflate); |
| 125 | Close (Inflate); |
| 126 | |
| 127 | exit Main when Stop; |
| 128 | end loop; |
| 129 | end loop Main; |
| 130 | exception |
| 131 | when E : others => |
| 132 | Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E)); |
| 133 | Stop := True; |
| 134 | end Test_Task; |
| 135 | |
| 136 | Test : array (1 .. 4) of Test_Task; |
| 137 | |
| 138 | pragma Unreferenced (Test); |
| 139 | |
| 140 | Dummy : Character; |
| 141 | |
| 142 | begin |
| 143 | Ada.Text_IO.Get_Immediate (Dummy); |
| 144 | Stop := True; |
| 145 | end MTest; |
| --- a/compat/zlib/contrib/ada/mtest.adb | |
| +++ b/compat/zlib/contrib/ada/mtest.adb | |
| @@ -1,156 +0,0 @@ | |
| ----------------------------------------------------------------- | |
| --- ZLib for Ada thick binding. -- | |
| --- -- | |
| --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | |
| --- -- | |
| --- Open source license information is in the zlib.ads file. -- | |
| ----------------------------------------------------------------- | |
| --- Continuous test for ZLib multithreading. If the test would fail | |
| --- we should provide thread safe allocation routines for the Z_Stream. | |
| --- | |
| --- $Id: mtest.adb,v 1.4 2004/07/23 07:49:54 vagul Exp $ | |
D
compat/zlib/contrib/ada/read.adb
-147
| --- a/compat/zlib/contrib/ada/read.adb | ||
| +++ b/compat/zlib/contrib/ada/read.adb | ||
| @@ -1,156 +0,0 @@ | ||
| ----------------------------------------------------------------- | ||
| --- ZLib for Ada thick binding. -- | ||
| --- -- | ||
| --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | ||
| --- -- | ||
| --- Open source license information is in the zlib.ads file. -- | ||
| ----------------------------------------------------------------- | ||
| 1 | - | |
| --- $Id: read.adb,v 1.8 2004/05/31 10:53:40 vagul Exp $ | ||
| 2 | - | |
| --- Test/demo program for the generic read interface. | ||
| 3 | - | |
| 4 | -with Ada.Numerics.Discrete_Random; | |
| 5 | -with Ada.Streams; | |
| 6 | -with Ada.Text_IO; | |
| 7 | - | |
| 8 | -with ZLib; | |
| 9 | - | |
| 10 | -procedure Read is | |
| 11 | - | |
| 12 | - use Ada.Streams; | |
| 13 | - | |
| 14 | - ------------------------------------ | |
| 15 | - -- Test configuration parameters -- | |
| 16 | - ------------------------------------ | |
| 17 | - | |
| 18 | - File_Size : Stream_Element_Offset := 100_000; | |
| 19 | - | |
| 20 | - Continuous : constant Boolean := False; | |
| 21 | - -- If this constant is True, the test would be repeated again and again, | |
| 22 | - -- with increment File_Size for every iteration. | |
| 23 | - | |
| 24 | - Header : constant ZLib.Header_Type := ZLib.Default; | |
| 25 | - -- Do not use Header other than Default in ZLib versions 1.1.4 and older. | |
| 26 | - | |
| 27 | - Init_Random : constant := 8; | |
| 28 | - -- We are using the same random sequence, in case of we catch bug, | |
| 29 | - -- so we would be able to reproduce it. | |
| 30 | - | |
| 31 | - -- End -- | |
| 32 | - | |
| 33 | - Pack_Size : Stream_Element_Offset; | |
| 34 | - Offset : Stream_Element_Offset; | |
| 35 | - | |
| 36 | - Filter : ZLib.Filter_Type; | |
| 37 | - | |
| 38 | - subtype Visible_Symbols | |
| 39 | - is Stream_Element range 16#20# .. 16#7E#; | |
| 40 | - | |
| 41 | - package Random_Elements is new | |
| 42 | - Ada.Numerics.Discrete_Random (Visible_Symbols); | |
| 43 | - | |
| 44 | - Gen : Random_Elements.Generator; | |
| 45 | - Period : constant Stream_Element_Offset := 200; | |
| 46 | - -- Period constant variable for random generator not to be very random. | |
| 47 | - -- Bigger period, harder random. | |
| 48 | - | |
| 49 | - Read_Buffer : Stream_Element_Array (1 .. 2048); | |
| 50 | - Read_First : Stream_Element_Offset; | |
| 51 | - Read_Last : Stream_Element_Offset; | |
| 52 | - | |
| 53 | - procedure Reset; | |
| 54 | - | |
| 55 | - procedure Read | |
| 56 | - (Item : out Stream_Element_Array; | |
| 57 | - Last : out Stream_Element_Offset); | |
| 58 | - -- this procedure is for generic instantiation of | |
| 59 | - -- ZLib.Read | |
| 60 | - -- reading data from the File_In. | |
| 61 | - | |
| 62 | - procedure Read is new ZLib.Read | |
| 63 | - (Read, | |
| 64 | - Read_Buffer, | |
| 65 | - Rest_First => Read_First, | |
| 66 | - Rest_Last => Read_Last); | |
| 67 | - | |
| 68 | - ---------- | |
| 69 | - -- Read -- | |
| 70 | - ---------- | |
| 71 | - | |
| 72 | - procedure Read | |
| 73 | - (Item : out Stream_Element_Array; | |
| 74 | - Last : out Stream_Element_Offset) is | |
| 75 | - begin | |
| 76 | - Last := Stream_Element_Offset'Min | |
| 77 | - (Item'Last, | |
| 78 | - Item'First + File_Size - Offset); | |
| 79 | - | |
| 80 | - for J in Item'First .. Last loop | |
| 81 | - if J < Item'First + Period then | |
| 82 | - Item (J) := Random_Elements.Random (Gen); | |
| 83 | - else | |
| 84 | - Item (J) := Item (J - Period); | |
| 85 | - end if; | |
| 86 | - | |
| 87 | - Offset := Offset + 1; | |
| 88 | - end loop; | |
| 89 | - end Read; | |
| 90 | - | |
| 91 | - ----------- | |
| 92 | - -- Reset -- | |
| 93 | - ----------- | |
| 94 | - | |
| 95 | - procedure Reset is | |
| 96 | - begin | |
| 97 | - Random_Elements.Reset (Gen, Init_Random); | |
| 98 | - Pack_Size := 0; | |
| 99 | - Offset := 1; | |
| 100 | - Read_First := Read_Buffer'Last + 1; | |
| 101 | - Read_Last := Read_Buffer'Last; | |
| 102 | - end Reset; | |
| 103 | - | |
| 104 | -begin | |
| 105 | - Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version); | |
| 106 | - | |
| 107 | - loop | |
| 108 | - for Level in ZLib.Compression_Level'Range loop | |
| 109 | - | |
| 110 | - Ada.Text_IO.Put ("Level =" | |
| 111 | - & ZLib.Compression_Level'Image (Level)); | |
| 112 | - | |
| 113 | - -- Deflate using generic instantiation. | |
| 114 | - | |
| 115 | - ZLib.Deflate_Init | |
| 116 | - (Filter, | |
| 117 | - Level, | |
| 118 | - Header => Header); | |
| 119 | - | |
| 120 | - Reset; | |
| 121 | - | |
| 122 | - Ada.Text_IO.Put | |
| 123 | - (Stream_Element_Offset'Image (File_Size) & " ->"); | |
| 124 | - | |
| 125 | - loop | |
| 126 | - declare | |
| 127 | - Buffer : Stream_Element_Array (1 .. 1024); | |
| 128 | - Last : Stream_Element_Offset; | |
| 129 | - begin | |
| 130 | - Read (Filter, Buffer, Last); | |
| 131 | - | |
| 132 | - Pack_Size := Pack_Size + Last - Buffer'First + 1; | |
| 133 | - | |
| 134 | - exit when Last < Buffer'Last; | |
| 135 | - end; | |
| 136 | - end loop; | |
| 137 | - | |
| 138 | - Ada.Text_IO.Put_Line (Stream_Element_Offset'Image (Pack_Size)); | |
| 139 | - | |
| 140 | - ZLib.Close (Filter); | |
| 141 | - end loop; | |
| 142 | - | |
| 143 | - exit when not Continuous; | |
| 144 | - | |
| 145 | - File_Size := File_Size + 1; | |
| 146 | - end loop; | |
| 147 | -end Read; |
| --- a/compat/zlib/contrib/ada/read.adb | |
| +++ b/compat/zlib/contrib/ada/read.adb | |
| @@ -1,156 +0,0 @@ | |
| ----------------------------------------------------------------- | |
| --- ZLib for Ada thick binding. -- | |
| --- -- | |
| --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | |
| --- -- | |
| --- Open source license information is in the zlib.ads file. -- | |
| ----------------------------------------------------------------- | |
| 1 | |
| --- $Id: read.adb,v 1.8 2004/05/31 10:53:40 vagul Exp $ | |
| 2 | |
| --- Test/demo program for the generic read interface. | |
| 3 | |
| 4 | with Ada.Numerics.Discrete_Random; |
| 5 | with Ada.Streams; |
| 6 | with Ada.Text_IO; |
| 7 | |
| 8 | with ZLib; |
| 9 | |
| 10 | procedure Read is |
| 11 | |
| 12 | use Ada.Streams; |
| 13 | |
| 14 | ------------------------------------ |
| 15 | -- Test configuration parameters -- |
| 16 | ------------------------------------ |
| 17 | |
| 18 | File_Size : Stream_Element_Offset := 100_000; |
| 19 | |
| 20 | Continuous : constant Boolean := False; |
| 21 | -- If this constant is True, the test would be repeated again and again, |
| 22 | -- with increment File_Size for every iteration. |
| 23 | |
| 24 | Header : constant ZLib.Header_Type := ZLib.Default; |
| 25 | -- Do not use Header other than Default in ZLib versions 1.1.4 and older. |
| 26 | |
| 27 | Init_Random : constant := 8; |
| 28 | -- We are using the same random sequence, in case of we catch bug, |
| 29 | -- so we would be able to reproduce it. |
| 30 | |
| 31 | -- End -- |
| 32 | |
| 33 | Pack_Size : Stream_Element_Offset; |
| 34 | Offset : Stream_Element_Offset; |
| 35 | |
| 36 | Filter : ZLib.Filter_Type; |
| 37 | |
| 38 | subtype Visible_Symbols |
| 39 | is Stream_Element range 16#20# .. 16#7E#; |
| 40 | |
| 41 | package Random_Elements is new |
| 42 | Ada.Numerics.Discrete_Random (Visible_Symbols); |
| 43 | |
| 44 | Gen : Random_Elements.Generator; |
| 45 | Period : constant Stream_Element_Offset := 200; |
| 46 | -- Period constant variable for random generator not to be very random. |
| 47 | -- Bigger period, harder random. |
| 48 | |
| 49 | Read_Buffer : Stream_Element_Array (1 .. 2048); |
| 50 | Read_First : Stream_Element_Offset; |
| 51 | Read_Last : Stream_Element_Offset; |
| 52 | |
| 53 | procedure Reset; |
| 54 | |
| 55 | procedure Read |
| 56 | (Item : out Stream_Element_Array; |
| 57 | Last : out Stream_Element_Offset); |
| 58 | -- this procedure is for generic instantiation of |
| 59 | -- ZLib.Read |
| 60 | -- reading data from the File_In. |
| 61 | |
| 62 | procedure Read is new ZLib.Read |
| 63 | (Read, |
| 64 | Read_Buffer, |
| 65 | Rest_First => Read_First, |
| 66 | Rest_Last => Read_Last); |
| 67 | |
| 68 | ---------- |
| 69 | -- Read -- |
| 70 | ---------- |
| 71 | |
| 72 | procedure Read |
| 73 | (Item : out Stream_Element_Array; |
| 74 | Last : out Stream_Element_Offset) is |
| 75 | begin |
| 76 | Last := Stream_Element_Offset'Min |
| 77 | (Item'Last, |
| 78 | Item'First + File_Size - Offset); |
| 79 | |
| 80 | for J in Item'First .. Last loop |
| 81 | if J < Item'First + Period then |
| 82 | Item (J) := Random_Elements.Random (Gen); |
| 83 | else |
| 84 | Item (J) := Item (J - Period); |
| 85 | end if; |
| 86 | |
| 87 | Offset := Offset + 1; |
| 88 | end loop; |
| 89 | end Read; |
| 90 | |
| 91 | ----------- |
| 92 | -- Reset -- |
| 93 | ----------- |
| 94 | |
| 95 | procedure Reset is |
| 96 | begin |
| 97 | Random_Elements.Reset (Gen, Init_Random); |
| 98 | Pack_Size := 0; |
| 99 | Offset := 1; |
| 100 | Read_First := Read_Buffer'Last + 1; |
| 101 | Read_Last := Read_Buffer'Last; |
| 102 | end Reset; |
| 103 | |
| 104 | begin |
| 105 | Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version); |
| 106 | |
| 107 | loop |
| 108 | for Level in ZLib.Compression_Level'Range loop |
| 109 | |
| 110 | Ada.Text_IO.Put ("Level =" |
| 111 | & ZLib.Compression_Level'Image (Level)); |
| 112 | |
| 113 | -- Deflate using generic instantiation. |
| 114 | |
| 115 | ZLib.Deflate_Init |
| 116 | (Filter, |
| 117 | Level, |
| 118 | Header => Header); |
| 119 | |
| 120 | Reset; |
| 121 | |
| 122 | Ada.Text_IO.Put |
| 123 | (Stream_Element_Offset'Image (File_Size) & " ->"); |
| 124 | |
| 125 | loop |
| 126 | declare |
| 127 | Buffer : Stream_Element_Array (1 .. 1024); |
| 128 | Last : Stream_Element_Offset; |
| 129 | begin |
| 130 | Read (Filter, Buffer, Last); |
| 131 | |
| 132 | Pack_Size := Pack_Size + Last - Buffer'First + 1; |
| 133 | |
| 134 | exit when Last < Buffer'Last; |
| 135 | end; |
| 136 | end loop; |
| 137 | |
| 138 | Ada.Text_IO.Put_Line (Stream_Element_Offset'Image (Pack_Size)); |
| 139 | |
| 140 | ZLib.Close (Filter); |
| 141 | end loop; |
| 142 | |
| 143 | exit when not Continuous; |
| 144 | |
| 145 | File_Size := File_Size + 1; |
| 146 | end loop; |
| 147 | end Read; |
| --- a/compat/zlib/contrib/ada/read.adb | |
| +++ b/compat/zlib/contrib/ada/read.adb | |
| @@ -1,156 +0,0 @@ | |
| ----------------------------------------------------------------- | |
| --- ZLib for Ada thick binding. -- | |
| --- -- | |
| --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | |
| --- -- | |
| --- Open source license information is in the zlib.ads file. -- | |
| ----------------------------------------------------------------- | |
| --- $Id: read.adb,v 1.8 2004/05/31 10:53:40 vagul Exp $ | |
| --- Test/demo program for the generic read interface. | |
D
compat/zlib/contrib/ada/readme.txt
-65
| --- a/compat/zlib/contrib/ada/readme.txt | ||
| +++ b/compat/zlib/contrib/ada/readme.txt | ||
| @@ -1,65 +0,0 @@ | ||
| 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 http://www.gzip.org/zlib/. | |
| 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 | -- Attension: ZLib.Read generic routine have a initialization requirement | |
| 12 | - for Read_Last parameter now. It is a bit incompartible 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 <[email protected]> | |
| 64 | - | |
| 65 | -Contributors: Pascal Obry <[email protected]>, Steve Sangwine <[email protected]> |
| --- a/compat/zlib/contrib/ada/readme.txt | |
| +++ b/compat/zlib/contrib/ada/readme.txt | |
| @@ -1,65 +0,0 @@ | |
| 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 http://www.gzip.org/zlib/. |
| 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 | - Attension: ZLib.Read generic routine have a initialization requirement |
| 12 | for Read_Last parameter now. It is a bit incompartible 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 <[email protected]> |
| 64 | |
| 65 | Contributors: Pascal Obry <[email protected]>, Steve Sangwine <[email protected]> |
| --- a/compat/zlib/contrib/ada/readme.txt | |
| +++ b/compat/zlib/contrib/ada/readme.txt | |
| @@ -1,65 +0,0 @@ | |
D
compat/zlib/contrib/ada/test.adb
-450
| --- a/compat/zlib/contrib/ada/test.adb | ||
| +++ b/compat/zlib/contrib/ada/test.adb | ||
| @@ -1,463 +0,0 @@ | ||
| ----------------------------------------------------------------- | ||
| --- ZLib for Ada thick binding. -- | ||
| --- -- | ||
| --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | ||
| --- -- | ||
| --- Open source license information is in the zlib.ads file. -- | ||
| ----------------------------------------------------------------- | ||
| 1 | - | |
| --- $Id: test.adb,v 1.17 2003/08/12 12:13:30 vagul Exp $ | ||
| 2 | - | |
| --- The program has a few aims. | ||
| --- 1. Test ZLib.Ada95 thick binding functionality. | ||
| --- 2. Show the example of use main functionality of the ZLib.Ada95 binding. | ||
| --- 3. Build this program automatically compile all ZLib.Ada95 packages under | ||
| --- GNAT Ada95 compiler. | ||
| 3 | - | |
| 4 | -with ZLib.Streams; | |
| 5 | -with Ada.Streams.Stream_IO; | |
| 6 | -with Ada.Numerics.Discrete_Random; | |
| 7 | - | |
| 8 | -with Ada.Text_IO; | |
| 9 | - | |
| 10 | -with Ada.Calendar; | |
| 11 | - | |
| 12 | -procedure Test is | |
| 13 | - | |
| 14 | - use Ada.Streams; | |
| 15 | - use Stream_IO; | |
| 16 | - | |
| 17 | - ------------------------------------ | |
| 18 | - -- Test configuration parameters -- | |
| 19 | - ------------------------------------ | |
| 20 | - | |
| 21 | - File_Size : Count := 100_000; | |
| 22 | - Continuous : constant Boolean := False; | |
| 23 | - | |
| 24 | - Header : constant ZLib.Header_Type := ZLib.Default; | |
| 25 | - -- ZLib.None; | |
| 26 | - -- ZLib.Auto; | |
| 27 | - -- ZLib.GZip; | |
| 28 | - -- Do not use Header other then Default in ZLib versions 1.1.4 | |
| 29 | - -- and older. | |
| 30 | - | |
| 31 | - Strategy : constant ZLib.Strategy_Type := ZLib.Default_Strategy; | |
| 32 | - Init_Random : constant := 10; | |
| 33 | - | |
| 34 | - -- End -- | |
| 35 | - | |
| 36 | - In_File_Name : constant String := "testzlib.in"; | |
| 37 | - -- Name of the input file | |
| 38 | - | |
| 39 | - Z_File_Name : constant String := "testzlib.zlb"; | |
| 40 | - -- Name of the compressed file. | |
| 41 | - | |
| 42 | - Out_File_Name : constant String := "testzlib.out"; | |
| 43 | - -- Name of the decompressed file. | |
| 44 | - | |
| 45 | - File_In : File_Type; | |
| 46 | - File_Out : File_Type; | |
| 47 | - File_Back : File_Type; | |
| 48 | - File_Z : ZLib.Streams.Stream_Type; | |
| 49 | - | |
| 50 | - Filter : ZLib.Filter_Type; | |
| 51 | - | |
| 52 | - Time_Stamp : Ada.Calendar.Time; | |
| 53 | - | |
| 54 | - procedure Generate_File; | |
| 55 | - -- Generate file of spetsified size with some random data. | |
| 56 | - -- The random data is repeatable, for the good compression. | |
| 57 | - | |
| 58 | - procedure Compare_Streams | |
| 59 | - (Left, Right : in out Root_Stream_Type'Class); | |
| 60 | - -- The procedure compearing data in 2 streams. | |
| 61 | - -- It is for compare data before and after compression/decompression. | |
| 62 | - | |
| 63 | - procedure Compare_Files (Left, Right : String); | |
| 64 | - -- Compare files. Based on the Compare_Streams. | |
| 65 | - | |
| 66 | - procedure Copy_Streams | |
| 67 | - (Source, Target : in out Root_Stream_Type'Class; | |
| 68 | - Buffer_Size : in Stream_Element_Offset := 1024); | |
| 69 | - -- Copying data from one stream to another. It is for test stream | |
| 70 | - -- interface of the library. | |
| 71 | - | |
| 72 | - procedure Data_In | |
| 73 | - (Item : out Stream_Element_Array; | |
| 74 | - Last : out Stream_Element_Offset); | |
| 75 | - -- this procedure is for generic instantiation of | |
| 76 | - -- ZLib.Generic_Translate. | |
| 77 | - -- reading data from the File_In. | |
| 78 | - | |
| 79 | - procedure Data_Out (Item : in Stream_Element_Array); | |
| 80 | - -- this procedure is for generic instantiation of | |
| 81 | - -- ZLib.Generic_Translate. | |
| 82 | - -- writing data to the File_Out. | |
| 83 | - | |
| 84 | - procedure Stamp; | |
| 85 | - -- Store the timestamp to the local variable. | |
| 86 | - | |
| 87 | - procedure Print_Statistic (Msg : String; Data_Size : ZLib.Count); | |
| 88 | - -- Print the time statistic with the message. | |
| 89 | - | |
| 90 | - procedure Translate is new ZLib.Generic_Translate | |
| 91 | - (Data_In => Data_In, | |
| 92 | - Data_Out => Data_Out); | |
| 93 | - -- This procedure is moving data from File_In to File_Out | |
| 94 | - -- with compression or decompression, depend on initialization of | |
| 95 | - -- Filter parameter. | |
| 96 | - | |
| 97 | - ------------------- | |
| 98 | - -- Compare_Files -- | |
| 99 | - ------------------- | |
| 100 | - | |
| 101 | - procedure Compare_Files (Left, Right : String) is | |
| 102 | - Left_File, Right_File : File_Type; | |
| 103 | - begin | |
| 104 | - Open (Left_File, In_File, Left); | |
| 105 | - Open (Right_File, In_File, Right); | |
| 106 | - Compare_Streams (Stream (Left_File).all, Stream (Right_File).all); | |
| 107 | - Close (Left_File); | |
| 108 | - Close (Right_File); | |
| 109 | - end Compare_Files; | |
| 110 | - | |
| 111 | - --------------------- | |
| 112 | - -- Compare_Streams -- | |
| 113 | - --------------------- | |
| 114 | - | |
| 115 | - procedure Compare_Streams | |
| 116 | - (Left, Right : in out Ada.Streams.Root_Stream_Type'Class) | |
| 117 | - is | |
| 118 | - Left_Buffer, Right_Buffer : Stream_Element_Array (0 .. 16#FFF#); | |
| 119 | - Left_Last, Right_Last : Stream_Element_Offset; | |
| 120 | - begin | |
| 121 | - loop | |
| 122 | - Read (Left, Left_Buffer, Left_Last); | |
| 123 | - Read (Right, Right_Buffer, Right_Last); | |
| 124 | - | |
| 125 | - if Left_Last /= Right_Last then | |
| 126 | - Ada.Text_IO.Put_Line ("Compare error :" | |
| 127 | - & Stream_Element_Offset'Image (Left_Last) | |
| 128 | - & " /= " | |
| 129 | - & Stream_Element_Offset'Image (Right_Last)); | |
| 130 | - | |
| 131 | - raise Constraint_Error; | |
| 132 | - | |
| 133 | - elsif Left_Buffer (0 .. Left_Last) | |
| 134 | - /= Right_Buffer (0 .. Right_Last) | |
| 135 | - then | |
| 136 | - Ada.Text_IO.Put_Line ("ERROR: IN and OUT files is not equal."); | |
| 137 | - raise Constraint_Error; | |
| 138 | - | |
| 139 | - end if; | |
| 140 | - | |
| 141 | - exit when Left_Last < Left_Buffer'Last; | |
| 142 | - end loop; | |
| 143 | - end Compare_Streams; | |
| 144 | - | |
| 145 | - ------------------ | |
| 146 | - -- Copy_Streams -- | |
| 147 | - ------------------ | |
| 148 | - | |
| 149 | - procedure Copy_Streams | |
| 150 | - (Source, Target : in out Ada.Streams.Root_Stream_Type'Class; | |
| 151 | - Buffer_Size : in Stream_Element_Offset := 1024) | |
| 152 | - is | |
| 153 | - Buffer : Stream_Element_Array (1 .. Buffer_Size); | |
| 154 | - Last : Stream_Element_Offset; | |
| 155 | - begin | |
| 156 | - loop | |
| 157 | - Read (Source, Buffer, Last); | |
| 158 | - Write (Target, Buffer (1 .. Last)); | |
| 159 | - | |
| 160 | - exit when Last < Buffer'Last; | |
| 161 | - end loop; | |
| 162 | - end Copy_Streams; | |
| 163 | - | |
| 164 | - ------------- | |
| 165 | - -- Data_In -- | |
| 166 | - ------------- | |
| 167 | - | |
| 168 | - procedure Data_In | |
| 169 | - (Item : out Stream_Element_Array; | |
| 170 | - Last : out Stream_Element_Offset) is | |
| 171 | - begin | |
| 172 | - Read (File_In, Item, Last); | |
| 173 | - end Data_In; | |
| 174 | - | |
| 175 | - -------------- | |
| 176 | - -- Data_Out -- | |
| 177 | - -------------- | |
| 178 | - | |
| 179 | - procedure Data_Out (Item : in Stream_Element_Array) is | |
| 180 | - begin | |
| 181 | - Write (File_Out, Item); | |
| 182 | - end Data_Out; | |
| 183 | - | |
| 184 | - ------------------- | |
| 185 | - -- Generate_File -- | |
| 186 | - ------------------- | |
| 187 | - | |
| 188 | - procedure Generate_File is | |
| 189 | - subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#; | |
| 190 | - | |
| 191 | - package Random_Elements is | |
| 192 | - new Ada.Numerics.Discrete_Random (Visible_Symbols); | |
| 193 | - | |
| 194 | - Gen : Random_Elements.Generator; | |
| 195 | - Buffer : Stream_Element_Array := (1 .. 77 => 16#20#) & 10; | |
| 196 | - | |
| 197 | - Buffer_Count : constant Count := File_Size / Buffer'Length; | |
| 198 | - -- Number of same buffers in the packet. | |
| 199 | - | |
| 200 | - Density : constant Count := 30; -- from 0 to Buffer'Length - 2; | |
| 201 | - | |
| 202 | - procedure Fill_Buffer (J, D : in Count); | |
| 203 | - -- Change the part of the buffer. | |
| 204 | - | |
| 205 | - ----------------- | |
| 206 | - -- Fill_Buffer -- | |
| 207 | - ----------------- | |
| 208 | - | |
| 209 | - procedure Fill_Buffer (J, D : in Count) is | |
| 210 | - begin | |
| 211 | - for K in 0 .. D loop | |
| 212 | - Buffer | |
| 213 | - (Stream_Element_Offset ((J + K) mod (Buffer'Length - 1) + 1)) | |
| 214 | - := Random_Elements.Random (Gen); | |
| 215 | - | |
| 216 | - end loop; | |
| 217 | - end Fill_Buffer; | |
| 218 | - | |
| 219 | - begin | |
| 220 | - Random_Elements.Reset (Gen, Init_Random); | |
| 221 | - | |
| 222 | - Create (File_In, Out_File, In_File_Name); | |
| 223 | - | |
| 224 | - Fill_Buffer (1, Buffer'Length - 2); | |
| 225 | - | |
| 226 | - for J in 1 .. Buffer_Count loop | |
| 227 | - Write (File_In, Buffer); | |
| 228 | - | |
| 229 | - Fill_Buffer (J, Density); | |
| 230 | - end loop; | |
| 231 | - | |
| 232 | - -- fill remain size. | |
| 233 | - | |
| 234 | - Write | |
| 235 | - (File_In, | |
| 236 | - Buffer | |
| 237 | - (1 .. Stream_Element_Offset | |
| 238 | - (File_Size - Buffer'Length * Buffer_Count))); | |
| 239 | - | |
| 240 | - Flush (File_In); | |
| 241 | - Close (File_In); | |
| 242 | - end Generate_File; | |
| 243 | - | |
| 244 | - --------------------- | |
| 245 | - -- Print_Statistic -- | |
| 246 | - --------------------- | |
| 247 | - | |
| 248 | - procedure Print_Statistic (Msg : String; Data_Size : ZLib.Count) is | |
| 249 | - use Ada.Calendar; | |
| 250 | - use Ada.Text_IO; | |
| 251 | - | |
| 252 | - package Count_IO is new Integer_IO (ZLib.Count); | |
| 253 | - | |
| 254 | - Curr_Dur : Duration := Clock - Time_Stamp; | |
| 255 | - begin | |
| 256 | - Put (Msg); | |
| 257 | - | |
| 258 | - Set_Col (20); | |
| 259 | - Ada.Text_IO.Put ("size ="); | |
| 260 | - | |
| 261 | - Count_IO.Put | |
| 262 | - (Data_Size, | |
| 263 | - Width => Stream_IO.Count'Image (File_Size)'Length); | |
| 264 | - | |
| 265 | - Put_Line (" duration =" & Duration'Image (Curr_Dur)); | |
| 266 | - end Print_Statistic; | |
| 267 | - | |
| 268 | - ----------- | |
| 269 | - -- Stamp -- | |
| 270 | - ----------- | |
| 271 | - | |
| 272 | - procedure Stamp is | |
| 273 | - begin | |
| 274 | - Time_Stamp := Ada.Calendar.Clock; | |
| 275 | - end Stamp; | |
| 276 | - | |
| 277 | -begin | |
| 278 | - Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version); | |
| 279 | - | |
| 280 | - loop | |
| 281 | - Generate_File; | |
| 282 | - | |
| 283 | - for Level in ZLib.Compression_Level'Range loop | |
| 284 | - | |
| 285 | - Ada.Text_IO.Put_Line ("Level =" | |
| 286 | - & ZLib.Compression_Level'Image (Level)); | |
| 287 | - | |
| 288 | - -- Test generic interface. | |
| 289 | - Open (File_In, In_File, In_File_Name); | |
| 290 | - Create (File_Out, Out_File, Z_File_Name); | |
| 291 | - | |
| 292 | - Stamp; | |
| 293 | - | |
| 294 | - -- Deflate using generic instantiation. | |
| 295 | - | |
| 296 | - ZLib.Deflate_Init | |
| 297 | - (Filter => Filter, | |
| 298 | - Level => Level, | |
| 299 | - Strategy => Strategy, | |
| 300 | - Header => Header); | |
| 301 | - | |
| 302 | - Translate (Filter); | |
| 303 | - Print_Statistic ("Generic compress", ZLib.Total_Out (Filter)); | |
| 304 | - ZLib.Close (Filter); | |
| 305 | - | |
| 306 | - Close (File_In); | |
| 307 | - Close (File_Out); | |
| 308 | - | |
| 309 | - Open (File_In, In_File, Z_File_Name); | |
| 310 | - Create (File_Out, Out_File, Out_File_Name); | |
| 311 | - | |
| 312 | - Stamp; | |
| 313 | - | |
| 314 | - -- Inflate using generic instantiation. | |
| 315 | - | |
| 316 | - ZLib.Inflate_Init (Filter, Header => Header); | |
| 317 | - | |
| 318 | - Translate (Filter); | |
| 319 | - Print_Statistic ("Generic decompress", ZLib.Total_Out (Filter)); | |
| 320 | - | |
| 321 | - ZLib.Close (Filter); | |
| 322 | - | |
| 323 | - Close (File_In); | |
| 324 | - Close (File_Out); | |
| 325 | - | |
| 326 | - Compare_Files (In_File_Name, Out_File_Name); | |
| 327 | - | |
| 328 | - -- Test stream interface. | |
| 329 | - | |
| 330 | - -- Compress to the back stream. | |
| 331 | - | |
| 332 | - Open (File_In, In_File, In_File_Name); | |
| 333 | - Create (File_Back, Out_File, Z_File_Name); | |
| 334 | - | |
| 335 | - Stamp; | |
| 336 | - | |
| 337 | - ZLib.Streams.Create | |
| 338 | - (Stream => File_Z, | |
| 339 | - Mode => ZLib.Streams.Out_Stream, | |
| 340 | - Back => ZLib.Streams.Stream_Access | |
| 341 | - (Stream (File_Back)), | |
| 342 | - Back_Compressed => True, | |
| 343 | - Level => Level, | |
| 344 | - Strategy => Strategy, | |
| 345 | - Header => Header); | |
| 346 | - | |
| 347 | - Copy_Streams | |
| 348 | - (Source => Stream (File_In).all, | |
| 349 | - Target => File_Z); | |
| 350 | - | |
| 351 | - -- Flushing internal buffers to the back stream. | |
| 352 | - | |
| 353 | - ZLib.Streams.Flush (File_Z, ZLib.Finish); | |
| 354 | - | |
| 355 | - Print_Statistic ("Write compress", | |
| 356 | - ZLib.Streams.Write_Total_Out (File_Z)); | |
| 357 | - | |
| 358 | - ZLib.Streams.Close (File_Z); | |
| 359 | - | |
| 360 | - Close (File_In); | |
| 361 | - Close (File_Back); | |
| 362 | - | |
| 363 | - -- Compare reading from original file and from | |
| 364 | - -- decompression stream. | |
| 365 | - | |
| 366 | - Open (File_In, In_File, In_File_Name); | |
| 367 | - Open (File_Back, In_File, Z_File_Name); | |
| 368 | - | |
| 369 | - ZLib.Streams.Create | |
| 370 | - (Stream => File_Z, | |
| 371 | - Mode => ZLib.Streams.In_Stream, | |
| 372 | - Back => ZLib.Streams.Stream_Access | |
| 373 | - (Stream (File_Back)), | |
| 374 | - Back_Compressed => True, | |
| 375 | - Header => Header); | |
| 376 | - | |
| 377 | - Stamp; | |
| 378 | - Compare_Streams (Stream (File_In).all, File_Z); | |
| 379 | - | |
| 380 | - Print_Statistic ("Read decompress", | |
| 381 | - ZLib.Streams.Read_Total_Out (File_Z)); | |
| 382 | - | |
| 383 | - ZLib.Streams.Close (File_Z); | |
| 384 | - Close (File_In); | |
| 385 | - Close (File_Back); | |
| 386 | - | |
| 387 | - -- Compress by reading from compression stream. | |
| 388 | - | |
| 389 | - Open (File_Back, In_File, In_File_Name); | |
| 390 | - Create (File_Out, Out_File, Z_File_Name); | |
| 391 | - | |
| 392 | - ZLib.Streams.Create | |
| 393 | - (Stream => File_Z, | |
| 394 | - Mode => ZLib.Streams.In_Stream, | |
| 395 | - Back => ZLib.Streams.Stream_Access | |
| 396 | - (Stream (File_Back)), | |
| 397 | - Back_Compressed => False, | |
| 398 | - Level => Level, | |
| 399 | - Strategy => Strategy, | |
| 400 | - Header => Header); | |
| 401 | - | |
| 402 | - Stamp; | |
| 403 | - Copy_Streams | |
| 404 | - (Source => File_Z, | |
| 405 | - Target => Stream (File_Out).all); | |
| 406 | - | |
| 407 | - Print_Statistic ("Read compress", | |
| 408 | - ZLib.Streams.Read_Total_Out (File_Z)); | |
| 409 | - | |
| 410 | - ZLib.Streams.Close (File_Z); | |
| 411 | - | |
| 412 | - Close (File_Out); | |
| 413 | - Close (File_Back); | |
| 414 | - | |
| 415 | - -- Decompress to decompression stream. | |
| 416 | - | |
| 417 | - Open (File_In, In_File, Z_File_Name); | |
| 418 | - Create (File_Back, Out_File, Out_File_Name); | |
| 419 | - | |
| 420 | - ZLib.Streams.Create | |
| 421 | - (Stream => File_Z, | |
| 422 | - Mode => ZLib.Streams.Out_Stream, | |
| 423 | - Back => ZLib.Streams.Stream_Access | |
| 424 | - (Stream (File_Back)), | |
| 425 | - Back_Compressed => False, | |
| 426 | - Header => Header); | |
| 427 | - | |
| 428 | - Stamp; | |
| 429 | - | |
| 430 | - Copy_Streams | |
| 431 | - (Source => Stream (File_In).all, | |
| 432 | - Target => File_Z); | |
| 433 | - | |
| 434 | - Print_Statistic ("Write decompress", | |
| 435 | - ZLib.Streams.Write_Total_Out (File_Z)); | |
| 436 | - | |
| 437 | - ZLib.Streams.Close (File_Z); | |
| 438 | - Close (File_In); | |
| 439 | - Close (File_Back); | |
| 440 | - | |
| 441 | - Compare_Files (In_File_Name, Out_File_Name); | |
| 442 | - end loop; | |
| 443 | - | |
| 444 | - Ada.Text_IO.Put_Line (Count'Image (File_Size) & " Ok."); | |
| 445 | - | |
| 446 | - exit when not Continuous; | |
| 447 | - | |
| 448 | - File_Size := File_Size + 1; | |
| 449 | - end loop; | |
| 450 | -end Test; |
| --- a/compat/zlib/contrib/ada/test.adb | |
| +++ b/compat/zlib/contrib/ada/test.adb | |
| @@ -1,463 +0,0 @@ | |
| ----------------------------------------------------------------- | |
| --- ZLib for Ada thick binding. -- | |
| --- -- | |
| --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | |
| --- -- | |
| --- Open source license information is in the zlib.ads file. -- | |
| ----------------------------------------------------------------- | |
| 1 | |
| --- $Id: test.adb,v 1.17 2003/08/12 12:13:30 vagul Exp $ | |
| 2 | |
| --- The program has a few aims. | |
| --- 1. Test ZLib.Ada95 thick binding functionality. | |
| --- 2. Show the example of use main functionality of the ZLib.Ada95 binding. | |
| --- 3. Build this program automatically compile all ZLib.Ada95 packages under | |
| --- GNAT Ada95 compiler. | |
| 3 | |
| 4 | with ZLib.Streams; |
| 5 | with Ada.Streams.Stream_IO; |
| 6 | with Ada.Numerics.Discrete_Random; |
| 7 | |
| 8 | with Ada.Text_IO; |
| 9 | |
| 10 | with Ada.Calendar; |
| 11 | |
| 12 | procedure Test is |
| 13 | |
| 14 | use Ada.Streams; |
| 15 | use Stream_IO; |
| 16 | |
| 17 | ------------------------------------ |
| 18 | -- Test configuration parameters -- |
| 19 | ------------------------------------ |
| 20 | |
| 21 | File_Size : Count := 100_000; |
| 22 | Continuous : constant Boolean := False; |
| 23 | |
| 24 | Header : constant ZLib.Header_Type := ZLib.Default; |
| 25 | -- ZLib.None; |
| 26 | -- ZLib.Auto; |
| 27 | -- ZLib.GZip; |
| 28 | -- Do not use Header other then Default in ZLib versions 1.1.4 |
| 29 | -- and older. |
| 30 | |
| 31 | Strategy : constant ZLib.Strategy_Type := ZLib.Default_Strategy; |
| 32 | Init_Random : constant := 10; |
| 33 | |
| 34 | -- End -- |
| 35 | |
| 36 | In_File_Name : constant String := "testzlib.in"; |
| 37 | -- Name of the input file |
| 38 | |
| 39 | Z_File_Name : constant String := "testzlib.zlb"; |
| 40 | -- Name of the compressed file. |
| 41 | |
| 42 | Out_File_Name : constant String := "testzlib.out"; |
| 43 | -- Name of the decompressed file. |
| 44 | |
| 45 | File_In : File_Type; |
| 46 | File_Out : File_Type; |
| 47 | File_Back : File_Type; |
| 48 | File_Z : ZLib.Streams.Stream_Type; |
| 49 | |
| 50 | Filter : ZLib.Filter_Type; |
| 51 | |
| 52 | Time_Stamp : Ada.Calendar.Time; |
| 53 | |
| 54 | procedure Generate_File; |
| 55 | -- Generate file of spetsified size with some random data. |
| 56 | -- The random data is repeatable, for the good compression. |
| 57 | |
| 58 | procedure Compare_Streams |
| 59 | (Left, Right : in out Root_Stream_Type'Class); |
| 60 | -- The procedure compearing data in 2 streams. |
| 61 | -- It is for compare data before and after compression/decompression. |
| 62 | |
| 63 | procedure Compare_Files (Left, Right : String); |
| 64 | -- Compare files. Based on the Compare_Streams. |
| 65 | |
| 66 | procedure Copy_Streams |
| 67 | (Source, Target : in out Root_Stream_Type'Class; |
| 68 | Buffer_Size : in Stream_Element_Offset := 1024); |
| 69 | -- Copying data from one stream to another. It is for test stream |
| 70 | -- interface of the library. |
| 71 | |
| 72 | procedure Data_In |
| 73 | (Item : out Stream_Element_Array; |
| 74 | Last : out Stream_Element_Offset); |
| 75 | -- this procedure is for generic instantiation of |
| 76 | -- ZLib.Generic_Translate. |
| 77 | -- reading data from the File_In. |
| 78 | |
| 79 | procedure Data_Out (Item : in Stream_Element_Array); |
| 80 | -- this procedure is for generic instantiation of |
| 81 | -- ZLib.Generic_Translate. |
| 82 | -- writing data to the File_Out. |
| 83 | |
| 84 | procedure Stamp; |
| 85 | -- Store the timestamp to the local variable. |
| 86 | |
| 87 | procedure Print_Statistic (Msg : String; Data_Size : ZLib.Count); |
| 88 | -- Print the time statistic with the message. |
| 89 | |
| 90 | procedure Translate is new ZLib.Generic_Translate |
| 91 | (Data_In => Data_In, |
| 92 | Data_Out => Data_Out); |
| 93 | -- This procedure is moving data from File_In to File_Out |
| 94 | -- with compression or decompression, depend on initialization of |
| 95 | -- Filter parameter. |
| 96 | |
| 97 | ------------------- |
| 98 | -- Compare_Files -- |
| 99 | ------------------- |
| 100 | |
| 101 | procedure Compare_Files (Left, Right : String) is |
| 102 | Left_File, Right_File : File_Type; |
| 103 | begin |
| 104 | Open (Left_File, In_File, Left); |
| 105 | Open (Right_File, In_File, Right); |
| 106 | Compare_Streams (Stream (Left_File).all, Stream (Right_File).all); |
| 107 | Close (Left_File); |
| 108 | Close (Right_File); |
| 109 | end Compare_Files; |
| 110 | |
| 111 | --------------------- |
| 112 | -- Compare_Streams -- |
| 113 | --------------------- |
| 114 | |
| 115 | procedure Compare_Streams |
| 116 | (Left, Right : in out Ada.Streams.Root_Stream_Type'Class) |
| 117 | is |
| 118 | Left_Buffer, Right_Buffer : Stream_Element_Array (0 .. 16#FFF#); |
| 119 | Left_Last, Right_Last : Stream_Element_Offset; |
| 120 | begin |
| 121 | loop |
| 122 | Read (Left, Left_Buffer, Left_Last); |
| 123 | Read (Right, Right_Buffer, Right_Last); |
| 124 | |
| 125 | if Left_Last /= Right_Last then |
| 126 | Ada.Text_IO.Put_Line ("Compare error :" |
| 127 | & Stream_Element_Offset'Image (Left_Last) |
| 128 | & " /= " |
| 129 | & Stream_Element_Offset'Image (Right_Last)); |
| 130 | |
| 131 | raise Constraint_Error; |
| 132 | |
| 133 | elsif Left_Buffer (0 .. Left_Last) |
| 134 | /= Right_Buffer (0 .. Right_Last) |
| 135 | then |
| 136 | Ada.Text_IO.Put_Line ("ERROR: IN and OUT files is not equal."); |
| 137 | raise Constraint_Error; |
| 138 | |
| 139 | end if; |
| 140 | |
| 141 | exit when Left_Last < Left_Buffer'Last; |
| 142 | end loop; |
| 143 | end Compare_Streams; |
| 144 | |
| 145 | ------------------ |
| 146 | -- Copy_Streams -- |
| 147 | ------------------ |
| 148 | |
| 149 | procedure Copy_Streams |
| 150 | (Source, Target : in out Ada.Streams.Root_Stream_Type'Class; |
| 151 | Buffer_Size : in Stream_Element_Offset := 1024) |
| 152 | is |
| 153 | Buffer : Stream_Element_Array (1 .. Buffer_Size); |
| 154 | Last : Stream_Element_Offset; |
| 155 | begin |
| 156 | loop |
| 157 | Read (Source, Buffer, Last); |
| 158 | Write (Target, Buffer (1 .. Last)); |
| 159 | |
| 160 | exit when Last < Buffer'Last; |
| 161 | end loop; |
| 162 | end Copy_Streams; |
| 163 | |
| 164 | ------------- |
| 165 | -- Data_In -- |
| 166 | ------------- |
| 167 | |
| 168 | procedure Data_In |
| 169 | (Item : out Stream_Element_Array; |
| 170 | Last : out Stream_Element_Offset) is |
| 171 | begin |
| 172 | Read (File_In, Item, Last); |
| 173 | end Data_In; |
| 174 | |
| 175 | -------------- |
| 176 | -- Data_Out -- |
| 177 | -------------- |
| 178 | |
| 179 | procedure Data_Out (Item : in Stream_Element_Array) is |
| 180 | begin |
| 181 | Write (File_Out, Item); |
| 182 | end Data_Out; |
| 183 | |
| 184 | ------------------- |
| 185 | -- Generate_File -- |
| 186 | ------------------- |
| 187 | |
| 188 | procedure Generate_File is |
| 189 | subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#; |
| 190 | |
| 191 | package Random_Elements is |
| 192 | new Ada.Numerics.Discrete_Random (Visible_Symbols); |
| 193 | |
| 194 | Gen : Random_Elements.Generator; |
| 195 | Buffer : Stream_Element_Array := (1 .. 77 => 16#20#) & 10; |
| 196 | |
| 197 | Buffer_Count : constant Count := File_Size / Buffer'Length; |
| 198 | -- Number of same buffers in the packet. |
| 199 | |
| 200 | Density : constant Count := 30; -- from 0 to Buffer'Length - 2; |
| 201 | |
| 202 | procedure Fill_Buffer (J, D : in Count); |
| 203 | -- Change the part of the buffer. |
| 204 | |
| 205 | ----------------- |
| 206 | -- Fill_Buffer -- |
| 207 | ----------------- |
| 208 | |
| 209 | procedure Fill_Buffer (J, D : in Count) is |
| 210 | begin |
| 211 | for K in 0 .. D loop |
| 212 | Buffer |
| 213 | (Stream_Element_Offset ((J + K) mod (Buffer'Length - 1) + 1)) |
| 214 | := Random_Elements.Random (Gen); |
| 215 | |
| 216 | end loop; |
| 217 | end Fill_Buffer; |
| 218 | |
| 219 | begin |
| 220 | Random_Elements.Reset (Gen, Init_Random); |
| 221 | |
| 222 | Create (File_In, Out_File, In_File_Name); |
| 223 | |
| 224 | Fill_Buffer (1, Buffer'Length - 2); |
| 225 | |
| 226 | for J in 1 .. Buffer_Count loop |
| 227 | Write (File_In, Buffer); |
| 228 | |
| 229 | Fill_Buffer (J, Density); |
| 230 | end loop; |
| 231 | |
| 232 | -- fill remain size. |
| 233 | |
| 234 | Write |
| 235 | (File_In, |
| 236 | Buffer |
| 237 | (1 .. Stream_Element_Offset |
| 238 | (File_Size - Buffer'Length * Buffer_Count))); |
| 239 | |
| 240 | Flush (File_In); |
| 241 | Close (File_In); |
| 242 | end Generate_File; |
| 243 | |
| 244 | --------------------- |
| 245 | -- Print_Statistic -- |
| 246 | --------------------- |
| 247 | |
| 248 | procedure Print_Statistic (Msg : String; Data_Size : ZLib.Count) is |
| 249 | use Ada.Calendar; |
| 250 | use Ada.Text_IO; |
| 251 | |
| 252 | package Count_IO is new Integer_IO (ZLib.Count); |
| 253 | |
| 254 | Curr_Dur : Duration := Clock - Time_Stamp; |
| 255 | begin |
| 256 | Put (Msg); |
| 257 | |
| 258 | Set_Col (20); |
| 259 | Ada.Text_IO.Put ("size ="); |
| 260 | |
| 261 | Count_IO.Put |
| 262 | (Data_Size, |
| 263 | Width => Stream_IO.Count'Image (File_Size)'Length); |
| 264 | |
| 265 | Put_Line (" duration =" & Duration'Image (Curr_Dur)); |
| 266 | end Print_Statistic; |
| 267 | |
| 268 | ----------- |
| 269 | -- Stamp -- |
| 270 | ----------- |
| 271 | |
| 272 | procedure Stamp is |
| 273 | begin |
| 274 | Time_Stamp := Ada.Calendar.Clock; |
| 275 | end Stamp; |
| 276 | |
| 277 | begin |
| 278 | Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version); |
| 279 | |
| 280 | loop |
| 281 | Generate_File; |
| 282 | |
| 283 | for Level in ZLib.Compression_Level'Range loop |
| 284 | |
| 285 | Ada.Text_IO.Put_Line ("Level =" |
| 286 | & ZLib.Compression_Level'Image (Level)); |
| 287 | |
| 288 | -- Test generic interface. |
| 289 | Open (File_In, In_File, In_File_Name); |
| 290 | Create (File_Out, Out_File, Z_File_Name); |
| 291 | |
| 292 | Stamp; |
| 293 | |
| 294 | -- Deflate using generic instantiation. |
| 295 | |
| 296 | ZLib.Deflate_Init |
| 297 | (Filter => Filter, |
| 298 | Level => Level, |
| 299 | Strategy => Strategy, |
| 300 | Header => Header); |
| 301 | |
| 302 | Translate (Filter); |
| 303 | Print_Statistic ("Generic compress", ZLib.Total_Out (Filter)); |
| 304 | ZLib.Close (Filter); |
| 305 | |
| 306 | Close (File_In); |
| 307 | Close (File_Out); |
| 308 | |
| 309 | Open (File_In, In_File, Z_File_Name); |
| 310 | Create (File_Out, Out_File, Out_File_Name); |
| 311 | |
| 312 | Stamp; |
| 313 | |
| 314 | -- Inflate using generic instantiation. |
| 315 | |
| 316 | ZLib.Inflate_Init (Filter, Header => Header); |
| 317 | |
| 318 | Translate (Filter); |
| 319 | Print_Statistic ("Generic decompress", ZLib.Total_Out (Filter)); |
| 320 | |
| 321 | ZLib.Close (Filter); |
| 322 | |
| 323 | Close (File_In); |
| 324 | Close (File_Out); |
| 325 | |
| 326 | Compare_Files (In_File_Name, Out_File_Name); |
| 327 | |
| 328 | -- Test stream interface. |
| 329 | |
| 330 | -- Compress to the back stream. |
| 331 | |
| 332 | Open (File_In, In_File, In_File_Name); |
| 333 | Create (File_Back, Out_File, Z_File_Name); |
| 334 | |
| 335 | Stamp; |
| 336 | |
| 337 | ZLib.Streams.Create |
| 338 | (Stream => File_Z, |
| 339 | Mode => ZLib.Streams.Out_Stream, |
| 340 | Back => ZLib.Streams.Stream_Access |
| 341 | (Stream (File_Back)), |
| 342 | Back_Compressed => True, |
| 343 | Level => Level, |
| 344 | Strategy => Strategy, |
| 345 | Header => Header); |
| 346 | |
| 347 | Copy_Streams |
| 348 | (Source => Stream (File_In).all, |
| 349 | Target => File_Z); |
| 350 | |
| 351 | -- Flushing internal buffers to the back stream. |
| 352 | |
| 353 | ZLib.Streams.Flush (File_Z, ZLib.Finish); |
| 354 | |
| 355 | Print_Statistic ("Write compress", |
| 356 | ZLib.Streams.Write_Total_Out (File_Z)); |
| 357 | |
| 358 | ZLib.Streams.Close (File_Z); |
| 359 | |
| 360 | Close (File_In); |
| 361 | Close (File_Back); |
| 362 | |
| 363 | -- Compare reading from original file and from |
| 364 | -- decompression stream. |
| 365 | |
| 366 | Open (File_In, In_File, In_File_Name); |
| 367 | Open (File_Back, In_File, Z_File_Name); |
| 368 | |
| 369 | ZLib.Streams.Create |
| 370 | (Stream => File_Z, |
| 371 | Mode => ZLib.Streams.In_Stream, |
| 372 | Back => ZLib.Streams.Stream_Access |
| 373 | (Stream (File_Back)), |
| 374 | Back_Compressed => True, |
| 375 | Header => Header); |
| 376 | |
| 377 | Stamp; |
| 378 | Compare_Streams (Stream (File_In).all, File_Z); |
| 379 | |
| 380 | Print_Statistic ("Read decompress", |
| 381 | ZLib.Streams.Read_Total_Out (File_Z)); |
| 382 | |
| 383 | ZLib.Streams.Close (File_Z); |
| 384 | Close (File_In); |
| 385 | Close (File_Back); |
| 386 | |
| 387 | -- Compress by reading from compression stream. |
| 388 | |
| 389 | Open (File_Back, In_File, In_File_Name); |
| 390 | Create (File_Out, Out_File, Z_File_Name); |
| 391 | |
| 392 | ZLib.Streams.Create |
| 393 | (Stream => File_Z, |
| 394 | Mode => ZLib.Streams.In_Stream, |
| 395 | Back => ZLib.Streams.Stream_Access |
| 396 | (Stream (File_Back)), |
| 397 | Back_Compressed => False, |
| 398 | Level => Level, |
| 399 | Strategy => Strategy, |
| 400 | Header => Header); |
| 401 | |
| 402 | Stamp; |
| 403 | Copy_Streams |
| 404 | (Source => File_Z, |
| 405 | Target => Stream (File_Out).all); |
| 406 | |
| 407 | Print_Statistic ("Read compress", |
| 408 | ZLib.Streams.Read_Total_Out (File_Z)); |
| 409 | |
| 410 | ZLib.Streams.Close (File_Z); |
| 411 | |
| 412 | Close (File_Out); |
| 413 | Close (File_Back); |
| 414 | |
| 415 | -- Decompress to decompression stream. |
| 416 | |
| 417 | Open (File_In, In_File, Z_File_Name); |
| 418 | Create (File_Back, Out_File, Out_File_Name); |
| 419 | |
| 420 | ZLib.Streams.Create |
| 421 | (Stream => File_Z, |
| 422 | Mode => ZLib.Streams.Out_Stream, |
| 423 | Back => ZLib.Streams.Stream_Access |
| 424 | (Stream (File_Back)), |
| 425 | Back_Compressed => False, |
| 426 | Header => Header); |
| 427 | |
| 428 | Stamp; |
| 429 | |
| 430 | Copy_Streams |
| 431 | (Source => Stream (File_In).all, |
| 432 | Target => File_Z); |
| 433 | |
| 434 | Print_Statistic ("Write decompress", |
| 435 | ZLib.Streams.Write_Total_Out (File_Z)); |
| 436 | |
| 437 | ZLib.Streams.Close (File_Z); |
| 438 | Close (File_In); |
| 439 | Close (File_Back); |
| 440 | |
| 441 | Compare_Files (In_File_Name, Out_File_Name); |
| 442 | end loop; |
| 443 | |
| 444 | Ada.Text_IO.Put_Line (Count'Image (File_Size) & " Ok."); |
| 445 | |
| 446 | exit when not Continuous; |
| 447 | |
| 448 | File_Size := File_Size + 1; |
| 449 | end loop; |
| 450 | end Test; |
| --- a/compat/zlib/contrib/ada/test.adb | |
| +++ b/compat/zlib/contrib/ada/test.adb | |
| @@ -1,463 +0,0 @@ | |
| ----------------------------------------------------------------- | |
| --- ZLib for Ada thick binding. -- | |
| --- -- | |
| --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | |
| --- -- | |
| --- Open source license information is in the zlib.ads file. -- | |
| ----------------------------------------------------------------- | |
| --- $Id: test.adb,v 1.17 2003/08/12 12:13:30 vagul Exp $ | |
| --- The program has a few aims. | |
| --- 1. Test ZLib.Ada95 thick binding functionality. | |
| --- 2. Show the example of use main functionality of the ZLib.Ada95 binding. | |
| --- 3. Build this program automatically compile all ZLib.Ada95 packages under | |
| --- GNAT Ada95 compiler. | |
D
compat/zlib/contrib/ada/zlib-streams.adb
-217
| --- a/compat/zlib/contrib/ada/zlib-streams.adb | ||
| +++ b/compat/zlib/contrib/ada/zlib-streams.adb | ||
| @@ -1,225 +0,0 @@ | ||
| ----------------------------------------------------------------- | ||
| --- ZLib for Ada thick binding. -- | ||
| --- -- | ||
| --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | ||
| --- -- | ||
| --- Open source license information is in the zlib.ads file. -- | ||
| ----------------------------------------------------------------- | ||
| 1 | - | |
| --- $Id: zlib-streams.adb,v 1.10 2004/05/31 10:53:40 vagul Exp $ | ||
| 2 | - | |
| 3 | -with Ada.Unchecked_Deallocation; | |
| 4 | - | |
| 5 | -package body ZLib.Streams is | |
| 6 | - | |
| 7 | - ----------- | |
| 8 | - -- Close -- | |
| 9 | - ----------- | |
| 10 | - | |
| 11 | - procedure Close (Stream : in out Stream_Type) is | |
| 12 | - procedure Free is new Ada.Unchecked_Deallocation | |
| 13 | - (Stream_Element_Array, Buffer_Access); | |
| 14 | - begin | |
| 15 | - if Stream.Mode = Out_Stream or Stream.Mode = Duplex then | |
| 16 | - -- We should flush the data written by the writer. | |
| 17 | - | |
| 18 | - Flush (Stream, Finish); | |
| 19 | - | |
| 20 | - Close (Stream.Writer); | |
| 21 | - end if; | |
| 22 | - | |
| 23 | - if Stream.Mode = In_Stream or Stream.Mode = Duplex then | |
| 24 | - Close (Stream.Reader); | |
| 25 | - Free (Stream.Buffer); | |
| 26 | - end if; | |
| 27 | - end Close; | |
| 28 | - | |
| 29 | - ------------ | |
| 30 | - -- Create -- | |
| 31 | - ------------ | |
| 32 | - | |
| 33 | - procedure Create | |
| 34 | - (Stream : out Stream_Type; | |
| 35 | - Mode : in Stream_Mode; | |
| 36 | - Back : in Stream_Access; | |
| 37 | - Back_Compressed : in Boolean; | |
| 38 | - Level : in Compression_Level := Default_Compression; | |
| 39 | - Strategy : in Strategy_Type := Default_Strategy; | |
| 40 | - Header : in Header_Type := Default; | |
| 41 | - Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset | |
| 42 | - := Default_Buffer_Size; | |
| 43 | - Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset | |
| 44 | - := Default_Buffer_Size) | |
| 45 | - is | |
| 46 | - | |
| 47 | - subtype Buffer_Subtype is Stream_Element_Array (1 .. Read_Buffer_Size); | |
| 48 | - | |
| 49 | - procedure Init_Filter | |
| 50 | - (Filter : in out Filter_Type; | |
| 51 | - Compress : in Boolean); | |
| 52 | - | |
| 53 | - ----------------- | |
| 54 | - -- Init_Filter -- | |
| 55 | - ----------------- | |
| 56 | - | |
| 57 | - procedure Init_Filter | |
| 58 | - (Filter : in out Filter_Type; | |
| 59 | - Compress : in Boolean) is | |
| 60 | - begin | |
| 61 | - if Compress then | |
| 62 | - Deflate_Init | |
| 63 | - (Filter, Level, Strategy, Header => Header); | |
| 64 | - else | |
| 65 | - Inflate_Init (Filter, Header => Header); | |
| 66 | - end if; | |
| 67 | - end Init_Filter; | |
| 68 | - | |
| 69 | - begin | |
| 70 | - Stream.Back := Back; | |
| 71 | - Stream.Mode := Mode; | |
| 72 | - | |
| 73 | - if Mode = Out_Stream or Mode = Duplex then | |
| 74 | - Init_Filter (Stream.Writer, Back_Compressed); | |
| 75 | - Stream.Buffer_Size := Write_Buffer_Size; | |
| 76 | - else | |
| 77 | - Stream.Buffer_Size := 0; | |
| 78 | - end if; | |
| 79 | - | |
| 80 | - if Mode = In_Stream or Mode = Duplex then | |
| 81 | - Init_Filter (Stream.Reader, not Back_Compressed); | |
| 82 | - | |
| 83 | - Stream.Buffer := new Buffer_Subtype; | |
| 84 | - Stream.Rest_First := Stream.Buffer'Last + 1; | |
| 85 | - Stream.Rest_Last := Stream.Buffer'Last; | |
| 86 | - end if; | |
| 87 | - end Create; | |
| 88 | - | |
| 89 | - ----------- | |
| 90 | - -- Flush -- | |
| 91 | - ----------- | |
| 92 | - | |
| 93 | - procedure Flush | |
| 94 | - (Stream : in out Stream_Type; | |
| 95 | - Mode : in Flush_Mode := Sync_Flush) | |
| 96 | - is | |
| 97 | - Buffer : Stream_Element_Array (1 .. Stream.Buffer_Size); | |
| 98 | - Last : Stream_Element_Offset; | |
| 99 | - begin | |
| 100 | - loop | |
| 101 | - Flush (Stream.Writer, Buffer, Last, Mode); | |
| 102 | - | |
| 103 | - Ada.Streams.Write (Stream.Back.all, Buffer (1 .. Last)); | |
| 104 | - | |
| 105 | - exit when Last < Buffer'Last; | |
| 106 | - end loop; | |
| 107 | - end Flush; | |
| 108 | - | |
| 109 | - ------------- | |
| 110 | - -- Is_Open -- | |
| 111 | - ------------- | |
| 112 | - | |
| 113 | - function Is_Open (Stream : Stream_Type) return Boolean is | |
| 114 | - begin | |
| 115 | - return Is_Open (Stream.Reader) or else Is_Open (Stream.Writer); | |
| 116 | - end Is_Open; | |
| 117 | - | |
| 118 | - ---------- | |
| 119 | - -- Read -- | |
| 120 | - ---------- | |
| 121 | - | |
| 122 | - procedure Read | |
| 123 | - (Stream : in out Stream_Type; | |
| 124 | - Item : out Stream_Element_Array; | |
| 125 | - Last : out Stream_Element_Offset) | |
| 126 | - is | |
| 127 | - | |
| 128 | - procedure Read | |
| 129 | - (Item : out Stream_Element_Array; | |
| 130 | - Last : out Stream_Element_Offset); | |
| 131 | - | |
| 132 | - ---------- | |
| 133 | - -- Read -- | |
| 134 | - ---------- | |
| 135 | - | |
| 136 | - procedure Read | |
| 137 | - (Item : out Stream_Element_Array; | |
| 138 | - Last : out Stream_Element_Offset) is | |
| 139 | - begin | |
| 140 | - Ada.Streams.Read (Stream.Back.all, Item, Last); | |
| 141 | - end Read; | |
| 142 | - | |
| 143 | - procedure Read is new ZLib.Read | |
| 144 | - (Read => Read, | |
| 145 | - Buffer => Stream.Buffer.all, | |
| 146 | - Rest_First => Stream.Rest_First, | |
| 147 | - Rest_Last => Stream.Rest_Last); | |
| 148 | - | |
| 149 | - begin | |
| 150 | - Read (Stream.Reader, Item, Last); | |
| 151 | - end Read; | |
| 152 | - | |
| 153 | - ------------------- | |
| 154 | - -- Read_Total_In -- | |
| 155 | - ------------------- | |
| 156 | - | |
| 157 | - function Read_Total_In (Stream : in Stream_Type) return Count is | |
| 158 | - begin | |
| 159 | - return Total_In (Stream.Reader); | |
| 160 | - end Read_Total_In; | |
| 161 | - | |
| 162 | - -------------------- | |
| 163 | - -- Read_Total_Out -- | |
| 164 | - -------------------- | |
| 165 | - | |
| 166 | - function Read_Total_Out (Stream : in Stream_Type) return Count is | |
| 167 | - begin | |
| 168 | - return Total_Out (Stream.Reader); | |
| 169 | - end Read_Total_Out; | |
| 170 | - | |
| 171 | - ----------- | |
| 172 | - -- Write -- | |
| 173 | - ----------- | |
| 174 | - | |
| 175 | - procedure Write | |
| 176 | - (Stream : in out Stream_Type; | |
| 177 | - Item : in Stream_Element_Array) | |
| 178 | - is | |
| 179 | - | |
| 180 | - procedure Write (Item : in Stream_Element_Array); | |
| 181 | - | |
| 182 | - ----------- | |
| 183 | - -- Write -- | |
| 184 | - ----------- | |
| 185 | - | |
| 186 | - procedure Write (Item : in Stream_Element_Array) is | |
| 187 | - begin | |
| 188 | - Ada.Streams.Write (Stream.Back.all, Item); | |
| 189 | - end Write; | |
| 190 | - | |
| 191 | - procedure Write is new ZLib.Write | |
| 192 | - (Write => Write, | |
| 193 | - Buffer_Size => Stream.Buffer_Size); | |
| 194 | - | |
| 195 | - begin | |
| 196 | - Write (Stream.Writer, Item, No_Flush); | |
| 197 | - end Write; | |
| 198 | - | |
| 199 | - -------------------- | |
| 200 | - -- Write_Total_In -- | |
| 201 | - -------------------- | |
| 202 | - | |
| 203 | - function Write_Total_In (Stream : in Stream_Type) return Count is | |
| 204 | - begin | |
| 205 | - return Total_In (Stream.Writer); | |
| 206 | - end Write_Total_In; | |
| 207 | - | |
| 208 | - --------------------- | |
| 209 | - -- Write_Total_Out -- | |
| 210 | - --------------------- | |
| 211 | - | |
| 212 | - function Write_Total_Out (Stream : in Stream_Type) return Count is | |
| 213 | - begin | |
| 214 | - return Total_Out (Stream.Writer); | |
| 215 | - end Write_Total_Out; | |
| 216 | - | |
| 217 | -end ZLib.Streams; |
| --- a/compat/zlib/contrib/ada/zlib-streams.adb | |
| +++ b/compat/zlib/contrib/ada/zlib-streams.adb | |
| @@ -1,225 +0,0 @@ | |
| ----------------------------------------------------------------- | |
| --- ZLib for Ada thick binding. -- | |
| --- -- | |
| --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | |
| --- -- | |
| --- Open source license information is in the zlib.ads file. -- | |
| ----------------------------------------------------------------- | |
| 1 | |
| --- $Id: zlib-streams.adb,v 1.10 2004/05/31 10:53:40 vagul Exp $ | |
| 2 | |
| 3 | with Ada.Unchecked_Deallocation; |
| 4 | |
| 5 | package body ZLib.Streams is |
| 6 | |
| 7 | ----------- |
| 8 | -- Close -- |
| 9 | ----------- |
| 10 | |
| 11 | procedure Close (Stream : in out Stream_Type) is |
| 12 | procedure Free is new Ada.Unchecked_Deallocation |
| 13 | (Stream_Element_Array, Buffer_Access); |
| 14 | begin |
| 15 | if Stream.Mode = Out_Stream or Stream.Mode = Duplex then |
| 16 | -- We should flush the data written by the writer. |
| 17 | |
| 18 | Flush (Stream, Finish); |
| 19 | |
| 20 | Close (Stream.Writer); |
| 21 | end if; |
| 22 | |
| 23 | if Stream.Mode = In_Stream or Stream.Mode = Duplex then |
| 24 | Close (Stream.Reader); |
| 25 | Free (Stream.Buffer); |
| 26 | end if; |
| 27 | end Close; |
| 28 | |
| 29 | ------------ |
| 30 | -- Create -- |
| 31 | ------------ |
| 32 | |
| 33 | procedure Create |
| 34 | (Stream : out Stream_Type; |
| 35 | Mode : in Stream_Mode; |
| 36 | Back : in Stream_Access; |
| 37 | Back_Compressed : in Boolean; |
| 38 | Level : in Compression_Level := Default_Compression; |
| 39 | Strategy : in Strategy_Type := Default_Strategy; |
| 40 | Header : in Header_Type := Default; |
| 41 | Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset |
| 42 | := Default_Buffer_Size; |
| 43 | Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset |
| 44 | := Default_Buffer_Size) |
| 45 | is |
| 46 | |
| 47 | subtype Buffer_Subtype is Stream_Element_Array (1 .. Read_Buffer_Size); |
| 48 | |
| 49 | procedure Init_Filter |
| 50 | (Filter : in out Filter_Type; |
| 51 | Compress : in Boolean); |
| 52 | |
| 53 | ----------------- |
| 54 | -- Init_Filter -- |
| 55 | ----------------- |
| 56 | |
| 57 | procedure Init_Filter |
| 58 | (Filter : in out Filter_Type; |
| 59 | Compress : in Boolean) is |
| 60 | begin |
| 61 | if Compress then |
| 62 | Deflate_Init |
| 63 | (Filter, Level, Strategy, Header => Header); |
| 64 | else |
| 65 | Inflate_Init (Filter, Header => Header); |
| 66 | end if; |
| 67 | end Init_Filter; |
| 68 | |
| 69 | begin |
| 70 | Stream.Back := Back; |
| 71 | Stream.Mode := Mode; |
| 72 | |
| 73 | if Mode = Out_Stream or Mode = Duplex then |
| 74 | Init_Filter (Stream.Writer, Back_Compressed); |
| 75 | Stream.Buffer_Size := Write_Buffer_Size; |
| 76 | else |
| 77 | Stream.Buffer_Size := 0; |
| 78 | end if; |
| 79 | |
| 80 | if Mode = In_Stream or Mode = Duplex then |
| 81 | Init_Filter (Stream.Reader, not Back_Compressed); |
| 82 | |
| 83 | Stream.Buffer := new Buffer_Subtype; |
| 84 | Stream.Rest_First := Stream.Buffer'Last + 1; |
| 85 | Stream.Rest_Last := Stream.Buffer'Last; |
| 86 | end if; |
| 87 | end Create; |
| 88 | |
| 89 | ----------- |
| 90 | -- Flush -- |
| 91 | ----------- |
| 92 | |
| 93 | procedure Flush |
| 94 | (Stream : in out Stream_Type; |
| 95 | Mode : in Flush_Mode := Sync_Flush) |
| 96 | is |
| 97 | Buffer : Stream_Element_Array (1 .. Stream.Buffer_Size); |
| 98 | Last : Stream_Element_Offset; |
| 99 | begin |
| 100 | loop |
| 101 | Flush (Stream.Writer, Buffer, Last, Mode); |
| 102 | |
| 103 | Ada.Streams.Write (Stream.Back.all, Buffer (1 .. Last)); |
| 104 | |
| 105 | exit when Last < Buffer'Last; |
| 106 | end loop; |
| 107 | end Flush; |
| 108 | |
| 109 | ------------- |
| 110 | -- Is_Open -- |
| 111 | ------------- |
| 112 | |
| 113 | function Is_Open (Stream : Stream_Type) return Boolean is |
| 114 | begin |
| 115 | return Is_Open (Stream.Reader) or else Is_Open (Stream.Writer); |
| 116 | end Is_Open; |
| 117 | |
| 118 | ---------- |
| 119 | -- Read -- |
| 120 | ---------- |
| 121 | |
| 122 | procedure Read |
| 123 | (Stream : in out Stream_Type; |
| 124 | Item : out Stream_Element_Array; |
| 125 | Last : out Stream_Element_Offset) |
| 126 | is |
| 127 | |
| 128 | procedure Read |
| 129 | (Item : out Stream_Element_Array; |
| 130 | Last : out Stream_Element_Offset); |
| 131 | |
| 132 | ---------- |
| 133 | -- Read -- |
| 134 | ---------- |
| 135 | |
| 136 | procedure Read |
| 137 | (Item : out Stream_Element_Array; |
| 138 | Last : out Stream_Element_Offset) is |
| 139 | begin |
| 140 | Ada.Streams.Read (Stream.Back.all, Item, Last); |
| 141 | end Read; |
| 142 | |
| 143 | procedure Read is new ZLib.Read |
| 144 | (Read => Read, |
| 145 | Buffer => Stream.Buffer.all, |
| 146 | Rest_First => Stream.Rest_First, |
| 147 | Rest_Last => Stream.Rest_Last); |
| 148 | |
| 149 | begin |
| 150 | Read (Stream.Reader, Item, Last); |
| 151 | end Read; |
| 152 | |
| 153 | ------------------- |
| 154 | -- Read_Total_In -- |
| 155 | ------------------- |
| 156 | |
| 157 | function Read_Total_In (Stream : in Stream_Type) return Count is |
| 158 | begin |
| 159 | return Total_In (Stream.Reader); |
| 160 | end Read_Total_In; |
| 161 | |
| 162 | -------------------- |
| 163 | -- Read_Total_Out -- |
| 164 | -------------------- |
| 165 | |
| 166 | function Read_Total_Out (Stream : in Stream_Type) return Count is |
| 167 | begin |
| 168 | return Total_Out (Stream.Reader); |
| 169 | end Read_Total_Out; |
| 170 | |
| 171 | ----------- |
| 172 | -- Write -- |
| 173 | ----------- |
| 174 | |
| 175 | procedure Write |
| 176 | (Stream : in out Stream_Type; |
| 177 | Item : in Stream_Element_Array) |
| 178 | is |
| 179 | |
| 180 | procedure Write (Item : in Stream_Element_Array); |
| 181 | |
| 182 | ----------- |
| 183 | -- Write -- |
| 184 | ----------- |
| 185 | |
| 186 | procedure Write (Item : in Stream_Element_Array) is |
| 187 | begin |
| 188 | Ada.Streams.Write (Stream.Back.all, Item); |
| 189 | end Write; |
| 190 | |
| 191 | procedure Write is new ZLib.Write |
| 192 | (Write => Write, |
| 193 | Buffer_Size => Stream.Buffer_Size); |
| 194 | |
| 195 | begin |
| 196 | Write (Stream.Writer, Item, No_Flush); |
| 197 | end Write; |
| 198 | |
| 199 | -------------------- |
| 200 | -- Write_Total_In -- |
| 201 | -------------------- |
| 202 | |
| 203 | function Write_Total_In (Stream : in Stream_Type) return Count is |
| 204 | begin |
| 205 | return Total_In (Stream.Writer); |
| 206 | end Write_Total_In; |
| 207 | |
| 208 | --------------------- |
| 209 | -- Write_Total_Out -- |
| 210 | --------------------- |
| 211 | |
| 212 | function Write_Total_Out (Stream : in Stream_Type) return Count is |
| 213 | begin |
| 214 | return Total_Out (Stream.Writer); |
| 215 | end Write_Total_Out; |
| 216 | |
| 217 | end ZLib.Streams; |
| --- a/compat/zlib/contrib/ada/zlib-streams.adb | |
| +++ b/compat/zlib/contrib/ada/zlib-streams.adb | |
| @@ -1,225 +0,0 @@ | |
| ----------------------------------------------------------------- | |
| --- ZLib for Ada thick binding. -- | |
| --- -- | |
| --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | |
| --- -- | |
| --- Open source license information is in the zlib.ads file. -- | |
| ----------------------------------------------------------------- | |
| --- $Id: zlib-streams.adb,v 1.10 2004/05/31 10:53:40 vagul Exp $ | |
D
compat/zlib/contrib/ada/zlib-streams.ads
-106
| --- a/compat/zlib/contrib/ada/zlib-streams.ads | ||
| +++ b/compat/zlib/contrib/ada/zlib-streams.ads | ||
| @@ -1,114 +0,0 @@ | ||
| ----------------------------------------------------------------- | ||
| --- ZLib for Ada thick binding. -- | ||
| --- -- | ||
| --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | ||
| --- -- | ||
| --- Open source license information is in the zlib.ads file. -- | ||
| ----------------------------------------------------------------- | ||
| 1 | - | |
| --- $Id: zlib-streams.ads,v 1.12 2004/05/31 10:53:40 vagul Exp $ | ||
| 2 | - | |
| 3 | -package ZLib.Streams is | |
| 4 | - | |
| 5 | - type Stream_Mode is (In_Stream, Out_Stream, Duplex); | |
| 6 | - | |
| 7 | - type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class; | |
| 8 | - | |
| 9 | - type Stream_Type is | |
| 10 | - new Ada.Streams.Root_Stream_Type with private; | |
| 11 | - | |
| 12 | - procedure Read | |
| 13 | - (Stream : in out Stream_Type; | |
| 14 | - Item : out Ada.Streams.Stream_Element_Array; | |
| 15 | - Last : out Ada.Streams.Stream_Element_Offset); | |
| 16 | - | |
| 17 | - procedure Write | |
| 18 | - (Stream : in out Stream_Type; | |
| 19 | - Item : in Ada.Streams.Stream_Element_Array); | |
| 20 | - | |
| 21 | - procedure Flush | |
| 22 | - (Stream : in out Stream_Type; | |
| 23 | - Mode : in Flush_Mode := Sync_Flush); | |
| 24 | - -- Flush the written data to the back stream, | |
| 25 | - -- all data placed to the compressor is flushing to the Back stream. | |
| 26 | - -- Should not be used until necessary, because it is decreasing | |
| 27 | - -- compression. | |
| 28 | - | |
| 29 | - function Read_Total_In (Stream : in Stream_Type) return Count; | |
| 30 | - pragma Inline (Read_Total_In); | |
| 31 | - -- Return total number of bytes read from back stream so far. | |
| 32 | - | |
| 33 | - function Read_Total_Out (Stream : in Stream_Type) return Count; | |
| 34 | - pragma Inline (Read_Total_Out); | |
| 35 | - -- Return total number of bytes read so far. | |
| 36 | - | |
| 37 | - function Write_Total_In (Stream : in Stream_Type) return Count; | |
| 38 | - pragma Inline (Write_Total_In); | |
| 39 | - -- Return total number of bytes written so far. | |
| 40 | - | |
| 41 | - function Write_Total_Out (Stream : in Stream_Type) return Count; | |
| 42 | - pragma Inline (Write_Total_Out); | |
| 43 | - -- Return total number of bytes written to the back stream. | |
| 44 | - | |
| 45 | - procedure Create | |
| 46 | - (Stream : out Stream_Type; | |
| 47 | - Mode : in Stream_Mode; | |
| 48 | - Back : in Stream_Access; | |
| 49 | - Back_Compressed : in Boolean; | |
| 50 | - Level : in Compression_Level := Default_Compression; | |
| 51 | - Strategy : in Strategy_Type := Default_Strategy; | |
| 52 | - Header : in Header_Type := Default; | |
| 53 | - Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset | |
| 54 | - := Default_Buffer_Size; | |
| 55 | - Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset | |
| 56 | - := Default_Buffer_Size); | |
| 57 | - -- Create the Comression/Decompression stream. | |
| 58 | - -- If mode is In_Stream then Write operation is disabled. | |
| 59 | - -- If mode is Out_Stream then Read operation is disabled. | |
| 60 | - | |
| 61 | - -- If Back_Compressed is true then | |
| 62 | - -- Data written to the Stream is compressing to the Back stream | |
| 63 | - -- and data read from the Stream is decompressed data from the Back stream. | |
| 64 | - | |
| 65 | - -- If Back_Compressed is false then | |
| 66 | - -- Data written to the Stream is decompressing to the Back stream | |
| 67 | - -- and data read from the Stream is compressed data from the Back stream. | |
| 68 | - | |
| 69 | - -- !!! When the Need_Header is False ZLib-Ada is using undocumented | |
| 70 | - -- ZLib 1.1.4 functionality to do not create/wait for ZLib headers. | |
| 71 | - | |
| 72 | - function Is_Open (Stream : Stream_Type) return Boolean; | |
| 73 | - | |
| 74 | - procedure Close (Stream : in out Stream_Type); | |
| 75 | - | |
| 76 | -private | |
| 77 | - | |
| 78 | - use Ada.Streams; | |
| 79 | - | |
| 80 | - type Buffer_Access is access all Stream_Element_Array; | |
| 81 | - | |
| 82 | - type Stream_Type | |
| 83 | - is new Root_Stream_Type with | |
| 84 | - record | |
| 85 | - Mode : Stream_Mode; | |
| 86 | - | |
| 87 | - Buffer : Buffer_Access; | |
| 88 | - Rest_First : Stream_Element_Offset; | |
| 89 | - Rest_Last : Stream_Element_Offset; | |
| 90 | - -- Buffer for Read operation. | |
| 91 | - -- We need to have this buffer in the record | |
| 92 | - -- because not all read data from back stream | |
| 93 | - -- could be processed during the read operation. | |
| 94 | - | |
| 95 | - Buffer_Size : Stream_Element_Offset; | |
| 96 | - -- Buffer size for write operation. | |
| 97 | - -- We do not need to have this buffer | |
| 98 | - -- in the record because all data could be | |
| 99 | - -- processed in the write operation. | |
| 100 | - | |
| 101 | - Back : Stream_Access; | |
| 102 | - Reader : Filter_Type; | |
| 103 | - Writer : Filter_Type; | |
| 104 | - end record; | |
| 105 | - | |
| 106 | -end ZLib.Streams; |
| --- a/compat/zlib/contrib/ada/zlib-streams.ads | |
| +++ b/compat/zlib/contrib/ada/zlib-streams.ads | |
| @@ -1,114 +0,0 @@ | |
| ----------------------------------------------------------------- | |
| --- ZLib for Ada thick binding. -- | |
| --- -- | |
| --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | |
| --- -- | |
| --- Open source license information is in the zlib.ads file. -- | |
| ----------------------------------------------------------------- | |
| 1 | |
| --- $Id: zlib-streams.ads,v 1.12 2004/05/31 10:53:40 vagul Exp $ | |
| 2 | |
| 3 | package ZLib.Streams is |
| 4 | |
| 5 | type Stream_Mode is (In_Stream, Out_Stream, Duplex); |
| 6 | |
| 7 | type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class; |
| 8 | |
| 9 | type Stream_Type is |
| 10 | new Ada.Streams.Root_Stream_Type with private; |
| 11 | |
| 12 | procedure Read |
| 13 | (Stream : in out Stream_Type; |
| 14 | Item : out Ada.Streams.Stream_Element_Array; |
| 15 | Last : out Ada.Streams.Stream_Element_Offset); |
| 16 | |
| 17 | procedure Write |
| 18 | (Stream : in out Stream_Type; |
| 19 | Item : in Ada.Streams.Stream_Element_Array); |
| 20 | |
| 21 | procedure Flush |
| 22 | (Stream : in out Stream_Type; |
| 23 | Mode : in Flush_Mode := Sync_Flush); |
| 24 | -- Flush the written data to the back stream, |
| 25 | -- all data placed to the compressor is flushing to the Back stream. |
| 26 | -- Should not be used until necessary, because it is decreasing |
| 27 | -- compression. |
| 28 | |
| 29 | function Read_Total_In (Stream : in Stream_Type) return Count; |
| 30 | pragma Inline (Read_Total_In); |
| 31 | -- Return total number of bytes read from back stream so far. |
| 32 | |
| 33 | function Read_Total_Out (Stream : in Stream_Type) return Count; |
| 34 | pragma Inline (Read_Total_Out); |
| 35 | -- Return total number of bytes read so far. |
| 36 | |
| 37 | function Write_Total_In (Stream : in Stream_Type) return Count; |
| 38 | pragma Inline (Write_Total_In); |
| 39 | -- Return total number of bytes written so far. |
| 40 | |
| 41 | function Write_Total_Out (Stream : in Stream_Type) return Count; |
| 42 | pragma Inline (Write_Total_Out); |
| 43 | -- Return total number of bytes written to the back stream. |
| 44 | |
| 45 | procedure Create |
| 46 | (Stream : out Stream_Type; |
| 47 | Mode : in Stream_Mode; |
| 48 | Back : in Stream_Access; |
| 49 | Back_Compressed : in Boolean; |
| 50 | Level : in Compression_Level := Default_Compression; |
| 51 | Strategy : in Strategy_Type := Default_Strategy; |
| 52 | Header : in Header_Type := Default; |
| 53 | Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset |
| 54 | := Default_Buffer_Size; |
| 55 | Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset |
| 56 | := Default_Buffer_Size); |
| 57 | -- Create the Comression/Decompression stream. |
| 58 | -- If mode is In_Stream then Write operation is disabled. |
| 59 | -- If mode is Out_Stream then Read operation is disabled. |
| 60 | |
| 61 | -- If Back_Compressed is true then |
| 62 | -- Data written to the Stream is compressing to the Back stream |
| 63 | -- and data read from the Stream is decompressed data from the Back stream. |
| 64 | |
| 65 | -- If Back_Compressed is false then |
| 66 | -- Data written to the Stream is decompressing to the Back stream |
| 67 | -- and data read from the Stream is compressed data from the Back stream. |
| 68 | |
| 69 | -- !!! When the Need_Header is False ZLib-Ada is using undocumented |
| 70 | -- ZLib 1.1.4 functionality to do not create/wait for ZLib headers. |
| 71 | |
| 72 | function Is_Open (Stream : Stream_Type) return Boolean; |
| 73 | |
| 74 | procedure Close (Stream : in out Stream_Type); |
| 75 | |
| 76 | private |
| 77 | |
| 78 | use Ada.Streams; |
| 79 | |
| 80 | type Buffer_Access is access all Stream_Element_Array; |
| 81 | |
| 82 | type Stream_Type |
| 83 | is new Root_Stream_Type with |
| 84 | record |
| 85 | Mode : Stream_Mode; |
| 86 | |
| 87 | Buffer : Buffer_Access; |
| 88 | Rest_First : Stream_Element_Offset; |
| 89 | Rest_Last : Stream_Element_Offset; |
| 90 | -- Buffer for Read operation. |
| 91 | -- We need to have this buffer in the record |
| 92 | -- because not all read data from back stream |
| 93 | -- could be processed during the read operation. |
| 94 | |
| 95 | Buffer_Size : Stream_Element_Offset; |
| 96 | -- Buffer size for write operation. |
| 97 | -- We do not need to have this buffer |
| 98 | -- in the record because all data could be |
| 99 | -- processed in the write operation. |
| 100 | |
| 101 | Back : Stream_Access; |
| 102 | Reader : Filter_Type; |
| 103 | Writer : Filter_Type; |
| 104 | end record; |
| 105 | |
| 106 | end ZLib.Streams; |
| --- a/compat/zlib/contrib/ada/zlib-streams.ads | |
| +++ b/compat/zlib/contrib/ada/zlib-streams.ads | |
| @@ -1,114 +0,0 @@ | |
| ----------------------------------------------------------------- | |
| --- ZLib for Ada thick binding. -- | |
| --- -- | |
| --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | |
| --- -- | |
| --- Open source license information is in the zlib.ads file. -- | |
| ----------------------------------------------------------------- | |
| --- $Id: zlib-streams.ads,v 1.12 2004/05/31 10:53:40 vagul Exp $ | |
D
compat/zlib/contrib/ada/zlib-thin.adb
-133
| --- a/compat/zlib/contrib/ada/zlib-thin.adb | ||
| +++ b/compat/zlib/contrib/ada/zlib-thin.adb | ||
| @@ -1,141 +0,0 @@ | ||
| ----------------------------------------------------------------- | ||
| --- ZLib for Ada thick binding. -- | ||
| --- -- | ||
| --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | ||
| --- -- | ||
| --- Open source license information is in the zlib.ads file. -- | ||
| ----------------------------------------------------------------- | ||
| 1 | - | |
| --- $Id: zlib-thin.adb,v 1.8 2003/12/14 18:27:31 vagul Exp $ | ||
| 2 | - | |
| 3 | -package body ZLib.Thin is | |
| 4 | - | |
| 5 | - ZLIB_VERSION : constant Chars_Ptr := zlibVersion; | |
| 6 | - | |
| 7 | - Z_Stream_Size : constant Int := Z_Stream'Size / System.Storage_Unit; | |
| 8 | - | |
| 9 | - -------------- | |
| 10 | - -- Avail_In -- | |
| 11 | - -------------- | |
| 12 | - | |
| 13 | - function Avail_In (Strm : in Z_Stream) return UInt is | |
| 14 | - begin | |
| 15 | - return Strm.Avail_In; | |
| 16 | - end Avail_In; | |
| 17 | - | |
| 18 | - --------------- | |
| 19 | - -- Avail_Out -- | |
| 20 | - --------------- | |
| 21 | - | |
| 22 | - function Avail_Out (Strm : in Z_Stream) return UInt is | |
| 23 | - begin | |
| 24 | - return Strm.Avail_Out; | |
| 25 | - end Avail_Out; | |
| 26 | - | |
| 27 | - ------------------ | |
| 28 | - -- Deflate_Init -- | |
| 29 | - ------------------ | |
| 30 | - | |
| 31 | - function Deflate_Init | |
| 32 | - (strm : Z_Streamp; | |
| 33 | - level : Int; | |
| 34 | - method : Int; | |
| 35 | - windowBits : Int; | |
| 36 | - memLevel : Int; | |
| 37 | - strategy : Int) | |
| 38 | - return Int is | |
| 39 | - begin | |
| 40 | - return deflateInit2 | |
| 41 | - (strm, | |
| 42 | - level, | |
| 43 | - method, | |
| 44 | - windowBits, | |
| 45 | - memLevel, | |
| 46 | - strategy, | |
| 47 | - ZLIB_VERSION, | |
| 48 | - Z_Stream_Size); | |
| 49 | - end Deflate_Init; | |
| 50 | - | |
| 51 | - ------------------ | |
| 52 | - -- Inflate_Init -- | |
| 53 | - ------------------ | |
| 54 | - | |
| 55 | - function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int is | |
| 56 | - begin | |
| 57 | - return inflateInit2 (strm, windowBits, ZLIB_VERSION, Z_Stream_Size); | |
| 58 | - end Inflate_Init; | |
| 59 | - | |
| 60 | - ------------------------ | |
| 61 | - -- Last_Error_Message -- | |
| 62 | - ------------------------ | |
| 63 | - | |
| 64 | - function Last_Error_Message (Strm : in Z_Stream) return String is | |
| 65 | - use Interfaces.C.Strings; | |
| 66 | - begin | |
| 67 | - if Strm.msg = Null_Ptr then | |
| 68 | - return ""; | |
| 69 | - else | |
| 70 | - return Value (Strm.msg); | |
| 71 | - end if; | |
| 72 | - end Last_Error_Message; | |
| 73 | - | |
| 74 | - ------------ | |
| 75 | - -- Set_In -- | |
| 76 | - ------------ | |
| 77 | - | |
| 78 | - procedure Set_In | |
| 79 | - (Strm : in out Z_Stream; | |
| 80 | - Buffer : in Voidp; | |
| 81 | - Size : in UInt) is | |
| 82 | - begin | |
| 83 | - Strm.Next_In := Buffer; | |
| 84 | - Strm.Avail_In := Size; | |
| 85 | - end Set_In; | |
| 86 | - | |
| 87 | - ------------------ | |
| 88 | - -- Set_Mem_Func -- | |
| 89 | - ------------------ | |
| 90 | - | |
| 91 | - procedure Set_Mem_Func | |
| 92 | - (Strm : in out Z_Stream; | |
| 93 | - Opaque : in Voidp; | |
| 94 | - Alloc : in alloc_func; | |
| 95 | - Free : in free_func) is | |
| 96 | - begin | |
| 97 | - Strm.opaque := Opaque; | |
| 98 | - Strm.zalloc := Alloc; | |
| 99 | - Strm.zfree := Free; | |
| 100 | - end Set_Mem_Func; | |
| 101 | - | |
| 102 | - ------------- | |
| 103 | - -- Set_Out -- | |
| 104 | - ------------- | |
| 105 | - | |
| 106 | - procedure Set_Out | |
| 107 | - (Strm : in out Z_Stream; | |
| 108 | - Buffer : in Voidp; | |
| 109 | - Size : in UInt) is | |
| 110 | - begin | |
| 111 | - Strm.Next_Out := Buffer; | |
| 112 | - Strm.Avail_Out := Size; | |
| 113 | - end Set_Out; | |
| 114 | - | |
| 115 | - -------------- | |
| 116 | - -- Total_In -- | |
| 117 | - -------------- | |
| 118 | - | |
| 119 | - function Total_In (Strm : in Z_Stream) return ULong is | |
| 120 | - begin | |
| 121 | - return Strm.Total_In; | |
| 122 | - end Total_In; | |
| 123 | - | |
| 124 | - --------------- | |
| 125 | - -- Total_Out -- | |
| 126 | - --------------- | |
| 127 | - | |
| 128 | - function Total_Out (Strm : in Z_Stream) return ULong is | |
| 129 | - begin | |
| 130 | - return Strm.Total_Out; | |
| 131 | - end Total_Out; | |
| 132 | - | |
| 133 | -end ZLib.Thin; |
| --- a/compat/zlib/contrib/ada/zlib-thin.adb | |
| +++ b/compat/zlib/contrib/ada/zlib-thin.adb | |
| @@ -1,141 +0,0 @@ | |
| ----------------------------------------------------------------- | |
| --- ZLib for Ada thick binding. -- | |
| --- -- | |
| --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | |
| --- -- | |
| --- Open source license information is in the zlib.ads file. -- | |
| ----------------------------------------------------------------- | |
| 1 | |
| --- $Id: zlib-thin.adb,v 1.8 2003/12/14 18:27:31 vagul Exp $ | |
| 2 | |
| 3 | package body ZLib.Thin is |
| 4 | |
| 5 | ZLIB_VERSION : constant Chars_Ptr := zlibVersion; |
| 6 | |
| 7 | Z_Stream_Size : constant Int := Z_Stream'Size / System.Storage_Unit; |
| 8 | |
| 9 | -------------- |
| 10 | -- Avail_In -- |
| 11 | -------------- |
| 12 | |
| 13 | function Avail_In (Strm : in Z_Stream) return UInt is |
| 14 | begin |
| 15 | return Strm.Avail_In; |
| 16 | end Avail_In; |
| 17 | |
| 18 | --------------- |
| 19 | -- Avail_Out -- |
| 20 | --------------- |
| 21 | |
| 22 | function Avail_Out (Strm : in Z_Stream) return UInt is |
| 23 | begin |
| 24 | return Strm.Avail_Out; |
| 25 | end Avail_Out; |
| 26 | |
| 27 | ------------------ |
| 28 | -- Deflate_Init -- |
| 29 | ------------------ |
| 30 | |
| 31 | function Deflate_Init |
| 32 | (strm : Z_Streamp; |
| 33 | level : Int; |
| 34 | method : Int; |
| 35 | windowBits : Int; |
| 36 | memLevel : Int; |
| 37 | strategy : Int) |
| 38 | return Int is |
| 39 | begin |
| 40 | return deflateInit2 |
| 41 | (strm, |
| 42 | level, |
| 43 | method, |
| 44 | windowBits, |
| 45 | memLevel, |
| 46 | strategy, |
| 47 | ZLIB_VERSION, |
| 48 | Z_Stream_Size); |
| 49 | end Deflate_Init; |
| 50 | |
| 51 | ------------------ |
| 52 | -- Inflate_Init -- |
| 53 | ------------------ |
| 54 | |
| 55 | function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int is |
| 56 | begin |
| 57 | return inflateInit2 (strm, windowBits, ZLIB_VERSION, Z_Stream_Size); |
| 58 | end Inflate_Init; |
| 59 | |
| 60 | ------------------------ |
| 61 | -- Last_Error_Message -- |
| 62 | ------------------------ |
| 63 | |
| 64 | function Last_Error_Message (Strm : in Z_Stream) return String is |
| 65 | use Interfaces.C.Strings; |
| 66 | begin |
| 67 | if Strm.msg = Null_Ptr then |
| 68 | return ""; |
| 69 | else |
| 70 | return Value (Strm.msg); |
| 71 | end if; |
| 72 | end Last_Error_Message; |
| 73 | |
| 74 | ------------ |
| 75 | -- Set_In -- |
| 76 | ------------ |
| 77 | |
| 78 | procedure Set_In |
| 79 | (Strm : in out Z_Stream; |
| 80 | Buffer : in Voidp; |
| 81 | Size : in UInt) is |
| 82 | begin |
| 83 | Strm.Next_In := Buffer; |
| 84 | Strm.Avail_In := Size; |
| 85 | end Set_In; |
| 86 | |
| 87 | ------------------ |
| 88 | -- Set_Mem_Func -- |
| 89 | ------------------ |
| 90 | |
| 91 | procedure Set_Mem_Func |
| 92 | (Strm : in out Z_Stream; |
| 93 | Opaque : in Voidp; |
| 94 | Alloc : in alloc_func; |
| 95 | Free : in free_func) is |
| 96 | begin |
| 97 | Strm.opaque := Opaque; |
| 98 | Strm.zalloc := Alloc; |
| 99 | Strm.zfree := Free; |
| 100 | end Set_Mem_Func; |
| 101 | |
| 102 | ------------- |
| 103 | -- Set_Out -- |
| 104 | ------------- |
| 105 | |
| 106 | procedure Set_Out |
| 107 | (Strm : in out Z_Stream; |
| 108 | Buffer : in Voidp; |
| 109 | Size : in UInt) is |
| 110 | begin |
| 111 | Strm.Next_Out := Buffer; |
| 112 | Strm.Avail_Out := Size; |
| 113 | end Set_Out; |
| 114 | |
| 115 | -------------- |
| 116 | -- Total_In -- |
| 117 | -------------- |
| 118 | |
| 119 | function Total_In (Strm : in Z_Stream) return ULong is |
| 120 | begin |
| 121 | return Strm.Total_In; |
| 122 | end Total_In; |
| 123 | |
| 124 | --------------- |
| 125 | -- Total_Out -- |
| 126 | --------------- |
| 127 | |
| 128 | function Total_Out (Strm : in Z_Stream) return ULong is |
| 129 | begin |
| 130 | return Strm.Total_Out; |
| 131 | end Total_Out; |
| 132 | |
| 133 | end ZLib.Thin; |
| --- a/compat/zlib/contrib/ada/zlib-thin.adb | |
| +++ b/compat/zlib/contrib/ada/zlib-thin.adb | |
| @@ -1,141 +0,0 @@ | |
| ----------------------------------------------------------------- | |
| --- ZLib for Ada thick binding. -- | |
| --- -- | |
| --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | |
| --- -- | |
| --- Open source license information is in the zlib.ads file. -- | |
| ----------------------------------------------------------------- | |
| --- $Id: zlib-thin.adb,v 1.8 2003/12/14 18:27:31 vagul Exp $ | |
D
compat/zlib/contrib/ada/zlib-thin.ads
-442
| --- a/compat/zlib/contrib/ada/zlib-thin.ads | ||
| +++ b/compat/zlib/contrib/ada/zlib-thin.ads | ||
| @@ -1,450 +0,0 @@ | ||
| ----------------------------------------------------------------- | ||
| --- ZLib for Ada thick binding. -- | ||
| --- -- | ||
| --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | ||
| --- -- | ||
| --- Open source license information is in the zlib.ads file. -- | ||
| ----------------------------------------------------------------- | ||
| 1 | - | |
| --- $Id: zlib-thin.ads,v 1.11 2004/07/23 06:33:11 vagul Exp $ | ||
| 2 | - | |
| 3 | -with Interfaces.C.Strings; | |
| 4 | - | |
| 5 | -with System; | |
| 6 | - | |
| 7 | -private package ZLib.Thin is | |
| 8 | - | |
| 9 | - -- From zconf.h | |
| 10 | - | |
| 11 | - MAX_MEM_LEVEL : constant := 9; -- zconf.h:105 | |
| 12 | - -- zconf.h:105 | |
| 13 | - MAX_WBITS : constant := 15; -- zconf.h:115 | |
| 14 | - -- 32K LZ77 window | |
| 15 | - -- zconf.h:115 | |
| 16 | - SEEK_SET : constant := 8#0000#; -- zconf.h:244 | |
| 17 | - -- Seek from beginning of file. | |
| 18 | - -- zconf.h:244 | |
| 19 | - SEEK_CUR : constant := 1; -- zconf.h:245 | |
| 20 | - -- Seek from current position. | |
| 21 | - -- zconf.h:245 | |
| 22 | - SEEK_END : constant := 2; -- zconf.h:246 | |
| 23 | - -- Set file pointer to EOF plus "offset" | |
| 24 | - -- zconf.h:246 | |
| 25 | - | |
| 26 | - type Byte is new Interfaces.C.unsigned_char; -- 8 bits | |
| 27 | - -- zconf.h:214 | |
| 28 | - type UInt is new Interfaces.C.unsigned; -- 16 bits or more | |
| 29 | - -- zconf.h:216 | |
| 30 | - type Int is new Interfaces.C.int; | |
| 31 | - | |
| 32 | - type ULong is new Interfaces.C.unsigned_long; -- 32 bits or more | |
| 33 | - -- zconf.h:217 | |
| 34 | - subtype Chars_Ptr is Interfaces.C.Strings.chars_ptr; | |
| 35 | - | |
| 36 | - type ULong_Access is access ULong; | |
| 37 | - type Int_Access is access Int; | |
| 38 | - | |
| 39 | - subtype Voidp is System.Address; -- zconf.h:232 | |
| 40 | - | |
| 41 | - subtype Byte_Access is Voidp; | |
| 42 | - | |
| 43 | - Nul : constant Voidp := System.Null_Address; | |
| 44 | - -- end from zconf | |
| 45 | - | |
| 46 | - Z_NO_FLUSH : constant := 8#0000#; -- zlib.h:125 | |
| 47 | - -- zlib.h:125 | |
| 48 | - Z_PARTIAL_FLUSH : constant := 1; -- zlib.h:126 | |
| 49 | - -- will be removed, use | |
| 50 | - -- Z_SYNC_FLUSH instead | |
| 51 | - -- zlib.h:126 | |
| 52 | - Z_SYNC_FLUSH : constant := 2; -- zlib.h:127 | |
| 53 | - -- zlib.h:127 | |
| 54 | - Z_FULL_FLUSH : constant := 3; -- zlib.h:128 | |
| 55 | - -- zlib.h:128 | |
| 56 | - Z_FINISH : constant := 4; -- zlib.h:129 | |
| 57 | - -- zlib.h:129 | |
| 58 | - Z_OK : constant := 8#0000#; -- zlib.h:132 | |
| 59 | - -- zlib.h:132 | |
| 60 | - Z_STREAM_END : constant := 1; -- zlib.h:133 | |
| 61 | - -- zlib.h:133 | |
| 62 | - Z_NEED_DICT : constant := 2; -- zlib.h:134 | |
| 63 | - -- zlib.h:134 | |
| 64 | - Z_ERRNO : constant := -1; -- zlib.h:135 | |
| 65 | - -- zlib.h:135 | |
| 66 | - Z_STREAM_ERROR : constant := -2; -- zlib.h:136 | |
| 67 | - -- zlib.h:136 | |
| 68 | - Z_DATA_ERROR : constant := -3; -- zlib.h:137 | |
| 69 | - -- zlib.h:137 | |
| 70 | - Z_MEM_ERROR : constant := -4; -- zlib.h:138 | |
| 71 | - -- zlib.h:138 | |
| 72 | - Z_BUF_ERROR : constant := -5; -- zlib.h:139 | |
| 73 | - -- zlib.h:139 | |
| 74 | - Z_VERSION_ERROR : constant := -6; -- zlib.h:140 | |
| 75 | - -- zlib.h:140 | |
| 76 | - Z_NO_COMPRESSION : constant := 8#0000#; -- zlib.h:145 | |
| 77 | - -- zlib.h:145 | |
| 78 | - Z_BEST_SPEED : constant := 1; -- zlib.h:146 | |
| 79 | - -- zlib.h:146 | |
| 80 | - Z_BEST_COMPRESSION : constant := 9; -- zlib.h:147 | |
| 81 | - -- zlib.h:147 | |
| 82 | - Z_DEFAULT_COMPRESSION : constant := -1; -- zlib.h:148 | |
| 83 | - -- zlib.h:148 | |
| 84 | - Z_FILTERED : constant := 1; -- zlib.h:151 | |
| 85 | - -- zlib.h:151 | |
| 86 | - Z_HUFFMAN_ONLY : constant := 2; -- zlib.h:152 | |
| 87 | - -- zlib.h:152 | |
| 88 | - Z_DEFAULT_STRATEGY : constant := 8#0000#; -- zlib.h:153 | |
| 89 | - -- zlib.h:153 | |
| 90 | - Z_BINARY : constant := 8#0000#; -- zlib.h:156 | |
| 91 | - -- zlib.h:156 | |
| 92 | - Z_ASCII : constant := 1; -- zlib.h:157 | |
| 93 | - -- zlib.h:157 | |
| 94 | - Z_UNKNOWN : constant := 2; -- zlib.h:158 | |
| 95 | - -- zlib.h:158 | |
| 96 | - Z_DEFLATED : constant := 8; -- zlib.h:161 | |
| 97 | - -- zlib.h:161 | |
| 98 | - Z_NULL : constant := 8#0000#; -- zlib.h:164 | |
| 99 | - -- for initializing zalloc, zfree, opaque | |
| 100 | - -- zlib.h:164 | |
| 101 | - type gzFile is new Voidp; -- zlib.h:646 | |
| 102 | - | |
| 103 | - type Z_Stream is private; | |
| 104 | - | |
| 105 | - type Z_Streamp is access all Z_Stream; -- zlib.h:89 | |
| 106 | - | |
| 107 | - type alloc_func is access function | |
| 108 | - (Opaque : Voidp; | |
| 109 | - Items : UInt; | |
| 110 | - Size : UInt) | |
| 111 | - return Voidp; -- zlib.h:63 | |
| 112 | - | |
| 113 | - type free_func is access procedure (opaque : Voidp; address : Voidp); | |
| 114 | - | |
| 115 | - function zlibVersion return Chars_Ptr; | |
| 116 | - | |
| 117 | - function Deflate (strm : Z_Streamp; flush : Int) return Int; | |
| 118 | - | |
| 119 | - function DeflateEnd (strm : Z_Streamp) return Int; | |
| 120 | - | |
| 121 | - function Inflate (strm : Z_Streamp; flush : Int) return Int; | |
| 122 | - | |
| 123 | - function InflateEnd (strm : Z_Streamp) return Int; | |
| 124 | - | |
| 125 | - function deflateSetDictionary | |
| 126 | - (strm : Z_Streamp; | |
| 127 | - dictionary : Byte_Access; | |
| 128 | - dictLength : UInt) | |
| 129 | - return Int; | |
| 130 | - | |
| 131 | - function deflateCopy (dest : Z_Streamp; source : Z_Streamp) return Int; | |
| 132 | - -- zlib.h:478 | |
| 133 | - | |
| 134 | - function deflateReset (strm : Z_Streamp) return Int; -- zlib.h:495 | |
| 135 | - | |
| 136 | - function deflateParams | |
| 137 | - (strm : Z_Streamp; | |
| 138 | - level : Int; | |
| 139 | - strategy : Int) | |
| 140 | - return Int; -- zlib.h:506 | |
| 141 | - | |
| 142 | - function inflateSetDictionary | |
| 143 | - (strm : Z_Streamp; | |
| 144 | - dictionary : Byte_Access; | |
| 145 | - dictLength : UInt) | |
| 146 | - return Int; -- zlib.h:548 | |
| 147 | - | |
| 148 | - function inflateSync (strm : Z_Streamp) return Int; -- zlib.h:565 | |
| 149 | - | |
| 150 | - function inflateReset (strm : Z_Streamp) return Int; -- zlib.h:580 | |
| 151 | - | |
| 152 | - function compress | |
| 153 | - (dest : Byte_Access; | |
| 154 | - destLen : ULong_Access; | |
| 155 | - source : Byte_Access; | |
| 156 | - sourceLen : ULong) | |
| 157 | - return Int; -- zlib.h:601 | |
| 158 | - | |
| 159 | - function compress2 | |
| 160 | - (dest : Byte_Access; | |
| 161 | - destLen : ULong_Access; | |
| 162 | - source : Byte_Access; | |
| 163 | - sourceLen : ULong; | |
| 164 | - level : Int) | |
| 165 | - return Int; -- zlib.h:615 | |
| 166 | - | |
| 167 | - function uncompress | |
| 168 | - (dest : Byte_Access; | |
| 169 | - destLen : ULong_Access; | |
| 170 | - source : Byte_Access; | |
| 171 | - sourceLen : ULong) | |
| 172 | - return Int; | |
| 173 | - | |
| 174 | - function gzopen (path : Chars_Ptr; mode : Chars_Ptr) return gzFile; | |
| 175 | - | |
| 176 | - function gzdopen (fd : Int; mode : Chars_Ptr) return gzFile; | |
| 177 | - | |
| 178 | - function gzsetparams | |
| 179 | - (file : gzFile; | |
| 180 | - level : Int; | |
| 181 | - strategy : Int) | |
| 182 | - return Int; | |
| 183 | - | |
| 184 | - function gzread | |
| 185 | - (file : gzFile; | |
| 186 | - buf : Voidp; | |
| 187 | - len : UInt) | |
| 188 | - return Int; | |
| 189 | - | |
| 190 | - function gzwrite | |
| 191 | - (file : in gzFile; | |
| 192 | - buf : in Voidp; | |
| 193 | - len : in UInt) | |
| 194 | - return Int; | |
| 195 | - | |
| 196 | - function gzprintf (file : in gzFile; format : in Chars_Ptr) return Int; | |
| 197 | - | |
| 198 | - function gzputs (file : in gzFile; s : in Chars_Ptr) return Int; | |
| 199 | - | |
| 200 | - function gzgets | |
| 201 | - (file : gzFile; | |
| 202 | - buf : Chars_Ptr; | |
| 203 | - len : Int) | |
| 204 | - return Chars_Ptr; | |
| 205 | - | |
| 206 | - function gzputc (file : gzFile; char : Int) return Int; | |
| 207 | - | |
| 208 | - function gzgetc (file : gzFile) return Int; | |
| 209 | - | |
| 210 | - function gzflush (file : gzFile; flush : Int) return Int; | |
| 211 | - | |
| 212 | - function gzseek | |
| 213 | - (file : gzFile; | |
| 214 | - offset : Int; | |
| 215 | - whence : Int) | |
| 216 | - return Int; | |
| 217 | - | |
| 218 | - function gzrewind (file : gzFile) return Int; | |
| 219 | - | |
| 220 | - function gztell (file : gzFile) return Int; | |
| 221 | - | |
| 222 | - function gzeof (file : gzFile) return Int; | |
| 223 | - | |
| 224 | - function gzclose (file : gzFile) return Int; | |
| 225 | - | |
| 226 | - function gzerror (file : gzFile; errnum : Int_Access) return Chars_Ptr; | |
| 227 | - | |
| 228 | - function adler32 | |
| 229 | - (adler : ULong; | |
| 230 | - buf : Byte_Access; | |
| 231 | - len : UInt) | |
| 232 | - return ULong; | |
| 233 | - | |
| 234 | - function crc32 | |
| 235 | - (crc : ULong; | |
| 236 | - buf : Byte_Access; | |
| 237 | - len : UInt) | |
| 238 | - return ULong; | |
| 239 | - | |
| 240 | - function deflateInit | |
| 241 | - (strm : Z_Streamp; | |
| 242 | - level : Int; | |
| 243 | - version : Chars_Ptr; | |
| 244 | - stream_size : Int) | |
| 245 | - return Int; | |
| 246 | - | |
| 247 | - function deflateInit2 | |
| 248 | - (strm : Z_Streamp; | |
| 249 | - level : Int; | |
| 250 | - method : Int; | |
| 251 | - windowBits : Int; | |
| 252 | - memLevel : Int; | |
| 253 | - strategy : Int; | |
| 254 | - version : Chars_Ptr; | |
| 255 | - stream_size : Int) | |
| 256 | - return Int; | |
| 257 | - | |
| 258 | - function Deflate_Init | |
| 259 | - (strm : Z_Streamp; | |
| 260 | - level : Int; | |
| 261 | - method : Int; | |
| 262 | - windowBits : Int; | |
| 263 | - memLevel : Int; | |
| 264 | - strategy : Int) | |
| 265 | - return Int; | |
| 266 | - pragma Inline (Deflate_Init); | |
| 267 | - | |
| 268 | - function inflateInit | |
| 269 | - (strm : Z_Streamp; | |
| 270 | - version : Chars_Ptr; | |
| 271 | - stream_size : Int) | |
| 272 | - return Int; | |
| 273 | - | |
| 274 | - function inflateInit2 | |
| 275 | - (strm : in Z_Streamp; | |
| 276 | - windowBits : in Int; | |
| 277 | - version : in Chars_Ptr; | |
| 278 | - stream_size : in Int) | |
| 279 | - return Int; | |
| 280 | - | |
| 281 | - function inflateBackInit | |
| 282 | - (strm : in Z_Streamp; | |
| 283 | - windowBits : in Int; | |
| 284 | - window : in Byte_Access; | |
| 285 | - version : in Chars_Ptr; | |
| 286 | - stream_size : in Int) | |
| 287 | - return Int; | |
| 288 | - -- Size of window have to be 2**windowBits. | |
| 289 | - | |
| 290 | - function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int; | |
| 291 | - pragma Inline (Inflate_Init); | |
| 292 | - | |
| 293 | - function zError (err : Int) return Chars_Ptr; | |
| 294 | - | |
| 295 | - function inflateSyncPoint (z : Z_Streamp) return Int; | |
| 296 | - | |
| 297 | - function get_crc_table return ULong_Access; | |
| 298 | - | |
| 299 | - -- Interface to the available fields of the z_stream structure. | |
| 300 | - -- The application must update next_in and avail_in when avail_in has | |
| 301 | - -- dropped to zero. It must update next_out and avail_out when avail_out | |
| 302 | - -- has dropped to zero. The application must initialize zalloc, zfree and | |
| 303 | - -- opaque before calling the init function. | |
| 304 | - | |
| 305 | - procedure Set_In | |
| 306 | - (Strm : in out Z_Stream; | |
| 307 | - Buffer : in Voidp; | |
| 308 | - Size : in UInt); | |
| 309 | - pragma Inline (Set_In); | |
| 310 | - | |
| 311 | - procedure Set_Out | |
| 312 | - (Strm : in out Z_Stream; | |
| 313 | - Buffer : in Voidp; | |
| 314 | - Size : in UInt); | |
| 315 | - pragma Inline (Set_Out); | |
| 316 | - | |
| 317 | - procedure Set_Mem_Func | |
| 318 | - (Strm : in out Z_Stream; | |
| 319 | - Opaque : in Voidp; | |
| 320 | - Alloc : in alloc_func; | |
| 321 | - Free : in free_func); | |
| 322 | - pragma Inline (Set_Mem_Func); | |
| 323 | - | |
| 324 | - function Last_Error_Message (Strm : in Z_Stream) return String; | |
| 325 | - pragma Inline (Last_Error_Message); | |
| 326 | - | |
| 327 | - function Avail_Out (Strm : in Z_Stream) return UInt; | |
| 328 | - pragma Inline (Avail_Out); | |
| 329 | - | |
| 330 | - function Avail_In (Strm : in Z_Stream) return UInt; | |
| 331 | - pragma Inline (Avail_In); | |
| 332 | - | |
| 333 | - function Total_In (Strm : in Z_Stream) return ULong; | |
| 334 | - pragma Inline (Total_In); | |
| 335 | - | |
| 336 | - function Total_Out (Strm : in Z_Stream) return ULong; | |
| 337 | - pragma Inline (Total_Out); | |
| 338 | - | |
| 339 | - function inflateCopy | |
| 340 | - (dest : in Z_Streamp; | |
| 341 | - Source : in Z_Streamp) | |
| 342 | - return Int; | |
| 343 | - | |
| 344 | - function compressBound (Source_Len : in ULong) return ULong; | |
| 345 | - | |
| 346 | - function deflateBound | |
| 347 | - (Strm : in Z_Streamp; | |
| 348 | - Source_Len : in ULong) | |
| 349 | - return ULong; | |
| 350 | - | |
| 351 | - function gzungetc (C : in Int; File : in gzFile) return Int; | |
| 352 | - | |
| 353 | - function zlibCompileFlags return ULong; | |
| 354 | - | |
| 355 | -private | |
| 356 | - | |
| 357 | - type Z_Stream is record -- zlib.h:68 | |
| 358 | - Next_In : Voidp := Nul; -- next input byte | |
| 359 | - Avail_In : UInt := 0; -- number of bytes available at next_in | |
| 360 | - Total_In : ULong := 0; -- total nb of input bytes read so far | |
| 361 | - Next_Out : Voidp := Nul; -- next output byte should be put there | |
| 362 | - Avail_Out : UInt := 0; -- remaining free space at next_out | |
| 363 | - Total_Out : ULong := 0; -- total nb of bytes output so far | |
| 364 | - msg : Chars_Ptr; -- last error message, NULL if no error | |
| 365 | - state : Voidp; -- not visible by applications | |
| 366 | - zalloc : alloc_func := null; -- used to allocate the internal state | |
| 367 | - zfree : free_func := null; -- used to free the internal state | |
| 368 | - opaque : Voidp; -- private data object passed to | |
| 369 | - -- zalloc and zfree | |
| 370 | - data_type : Int; -- best guess about the data type: | |
| 371 | - -- ascii or binary | |
| 372 | - adler : ULong; -- adler32 value of the uncompressed | |
| 373 | - -- data | |
| 374 | - reserved : ULong; -- reserved for future use | |
| 375 | - end record; | |
| 376 | - | |
| 377 | - pragma Convention (C, Z_Stream); | |
| 378 | - | |
| 379 | - pragma Import (C, zlibVersion, "zlibVersion"); | |
| 380 | - pragma Import (C, Deflate, "deflate"); | |
| 381 | - pragma Import (C, DeflateEnd, "deflateEnd"); | |
| 382 | - pragma Import (C, Inflate, "inflate"); | |
| 383 | - pragma Import (C, InflateEnd, "inflateEnd"); | |
| 384 | - pragma Import (C, deflateSetDictionary, "deflateSetDictionary"); | |
| 385 | - pragma Import (C, deflateCopy, "deflateCopy"); | |
| 386 | - pragma Import (C, deflateReset, "deflateReset"); | |
| 387 | - pragma Import (C, deflateParams, "deflateParams"); | |
| 388 | - pragma Import (C, inflateSetDictionary, "inflateSetDictionary"); | |
| 389 | - pragma Import (C, inflateSync, "inflateSync"); | |
| 390 | - pragma Import (C, inflateReset, "inflateReset"); | |
| 391 | - pragma Import (C, compress, "compress"); | |
| 392 | - pragma Import (C, compress2, "compress2"); | |
| 393 | - pragma Import (C, uncompress, "uncompress"); | |
| 394 | - pragma Import (C, gzopen, "gzopen"); | |
| 395 | - pragma Import (C, gzdopen, "gzdopen"); | |
| 396 | - pragma Import (C, gzsetparams, "gzsetparams"); | |
| 397 | - pragma Import (C, gzread, "gzread"); | |
| 398 | - pragma Import (C, gzwrite, "gzwrite"); | |
| 399 | - pragma Import (C, gzprintf, "gzprintf"); | |
| 400 | - pragma Import (C, gzputs, "gzputs"); | |
| 401 | - pragma Import (C, gzgets, "gzgets"); | |
| 402 | - pragma Import (C, gzputc, "gzputc"); | |
| 403 | - pragma Import (C, gzgetc, "gzgetc"); | |
| 404 | - pragma Import (C, gzflush, "gzflush"); | |
| 405 | - pragma Import (C, gzseek, "gzseek"); | |
| 406 | - pragma Import (C, gzrewind, "gzrewind"); | |
| 407 | - pragma Import (C, gztell, "gztell"); | |
| 408 | - pragma Import (C, gzeof, "gzeof"); | |
| 409 | - pragma Import (C, gzclose, "gzclose"); | |
| 410 | - pragma Import (C, gzerror, "gzerror"); | |
| 411 | - pragma Import (C, adler32, "adler32"); | |
| 412 | - pragma Import (C, crc32, "crc32"); | |
| 413 | - pragma Import (C, deflateInit, "deflateInit_"); | |
| 414 | - pragma Import (C, inflateInit, "inflateInit_"); | |
| 415 | - pragma Import (C, deflateInit2, "deflateInit2_"); | |
| 416 | - pragma Import (C, inflateInit2, "inflateInit2_"); | |
| 417 | - pragma Import (C, zError, "zError"); | |
| 418 | - pragma Import (C, inflateSyncPoint, "inflateSyncPoint"); | |
| 419 | - pragma Import (C, get_crc_table, "get_crc_table"); | |
| 420 | - | |
| 421 | - -- since zlib 1.2.0: | |
| 422 | - | |
| 423 | - pragma Import (C, inflateCopy, "inflateCopy"); | |
| 424 | - pragma Import (C, compressBound, "compressBound"); | |
| 425 | - pragma Import (C, deflateBound, "deflateBound"); | |
| 426 | - pragma Import (C, gzungetc, "gzungetc"); | |
| 427 | - pragma Import (C, zlibCompileFlags, "zlibCompileFlags"); | |
| 428 | - | |
| 429 | - pragma Import (C, inflateBackInit, "inflateBackInit_"); | |
| 430 | - | |
| 431 | - -- I stopped binding the inflateBack routines, because realize that | |
| 432 | - -- it does not support zlib and gzip headers for now, and have no | |
| 433 | - -- symmetric deflateBack routines. | |
| 434 | - -- ZLib-Ada is symmetric regarding deflate/inflate data transformation | |
| 435 | - -- and has a similar generic callback interface for the | |
| 436 | - -- deflate/inflate transformation based on the regular Deflate/Inflate | |
| 437 | - -- routines. | |
| 438 | - | |
| 439 | - -- pragma Import (C, inflateBack, "inflateBack"); | |
| 440 | - -- pragma Import (C, inflateBackEnd, "inflateBackEnd"); | |
| 441 | - | |
| 442 | -end ZLib.Thin; |
| --- a/compat/zlib/contrib/ada/zlib-thin.ads | |
| +++ b/compat/zlib/contrib/ada/zlib-thin.ads | |
| @@ -1,450 +0,0 @@ | |
| ----------------------------------------------------------------- | |
| --- ZLib for Ada thick binding. -- | |
| --- -- | |
| --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | |
| --- -- | |
| --- Open source license information is in the zlib.ads file. -- | |
| ----------------------------------------------------------------- | |
| 1 | |
| --- $Id: zlib-thin.ads,v 1.11 2004/07/23 06:33:11 vagul Exp $ | |
| 2 | |
| 3 | with Interfaces.C.Strings; |
| 4 | |
| 5 | with System; |
| 6 | |
| 7 | private package ZLib.Thin is |
| 8 | |
| 9 | -- From zconf.h |
| 10 | |
| 11 | MAX_MEM_LEVEL : constant := 9; -- zconf.h:105 |
| 12 | -- zconf.h:105 |
| 13 | MAX_WBITS : constant := 15; -- zconf.h:115 |
| 14 | -- 32K LZ77 window |
| 15 | -- zconf.h:115 |
| 16 | SEEK_SET : constant := 8#0000#; -- zconf.h:244 |
| 17 | -- Seek from beginning of file. |
| 18 | -- zconf.h:244 |
| 19 | SEEK_CUR : constant := 1; -- zconf.h:245 |
| 20 | -- Seek from current position. |
| 21 | -- zconf.h:245 |
| 22 | SEEK_END : constant := 2; -- zconf.h:246 |
| 23 | -- Set file pointer to EOF plus "offset" |
| 24 | -- zconf.h:246 |
| 25 | |
| 26 | type Byte is new Interfaces.C.unsigned_char; -- 8 bits |
| 27 | -- zconf.h:214 |
| 28 | type UInt is new Interfaces.C.unsigned; -- 16 bits or more |
| 29 | -- zconf.h:216 |
| 30 | type Int is new Interfaces.C.int; |
| 31 | |
| 32 | type ULong is new Interfaces.C.unsigned_long; -- 32 bits or more |
| 33 | -- zconf.h:217 |
| 34 | subtype Chars_Ptr is Interfaces.C.Strings.chars_ptr; |
| 35 | |
| 36 | type ULong_Access is access ULong; |
| 37 | type Int_Access is access Int; |
| 38 | |
| 39 | subtype Voidp is System.Address; -- zconf.h:232 |
| 40 | |
| 41 | subtype Byte_Access is Voidp; |
| 42 | |
| 43 | Nul : constant Voidp := System.Null_Address; |
| 44 | -- end from zconf |
| 45 | |
| 46 | Z_NO_FLUSH : constant := 8#0000#; -- zlib.h:125 |
| 47 | -- zlib.h:125 |
| 48 | Z_PARTIAL_FLUSH : constant := 1; -- zlib.h:126 |
| 49 | -- will be removed, use |
| 50 | -- Z_SYNC_FLUSH instead |
| 51 | -- zlib.h:126 |
| 52 | Z_SYNC_FLUSH : constant := 2; -- zlib.h:127 |
| 53 | -- zlib.h:127 |
| 54 | Z_FULL_FLUSH : constant := 3; -- zlib.h:128 |
| 55 | -- zlib.h:128 |
| 56 | Z_FINISH : constant := 4; -- zlib.h:129 |
| 57 | -- zlib.h:129 |
| 58 | Z_OK : constant := 8#0000#; -- zlib.h:132 |
| 59 | -- zlib.h:132 |
| 60 | Z_STREAM_END : constant := 1; -- zlib.h:133 |
| 61 | -- zlib.h:133 |
| 62 | Z_NEED_DICT : constant := 2; -- zlib.h:134 |
| 63 | -- zlib.h:134 |
| 64 | Z_ERRNO : constant := -1; -- zlib.h:135 |
| 65 | -- zlib.h:135 |
| 66 | Z_STREAM_ERROR : constant := -2; -- zlib.h:136 |
| 67 | -- zlib.h:136 |
| 68 | Z_DATA_ERROR : constant := -3; -- zlib.h:137 |
| 69 | -- zlib.h:137 |
| 70 | Z_MEM_ERROR : constant := -4; -- zlib.h:138 |
| 71 | -- zlib.h:138 |
| 72 | Z_BUF_ERROR : constant := -5; -- zlib.h:139 |
| 73 | -- zlib.h:139 |
| 74 | Z_VERSION_ERROR : constant := -6; -- zlib.h:140 |
| 75 | -- zlib.h:140 |
| 76 | Z_NO_COMPRESSION : constant := 8#0000#; -- zlib.h:145 |
| 77 | -- zlib.h:145 |
| 78 | Z_BEST_SPEED : constant := 1; -- zlib.h:146 |
| 79 | -- zlib.h:146 |
| 80 | Z_BEST_COMPRESSION : constant := 9; -- zlib.h:147 |
| 81 | -- zlib.h:147 |
| 82 | Z_DEFAULT_COMPRESSION : constant := -1; -- zlib.h:148 |
| 83 | -- zlib.h:148 |
| 84 | Z_FILTERED : constant := 1; -- zlib.h:151 |
| 85 | -- zlib.h:151 |
| 86 | Z_HUFFMAN_ONLY : constant := 2; -- zlib.h:152 |
| 87 | -- zlib.h:152 |
| 88 | Z_DEFAULT_STRATEGY : constant := 8#0000#; -- zlib.h:153 |
| 89 | -- zlib.h:153 |
| 90 | Z_BINARY : constant := 8#0000#; -- zlib.h:156 |
| 91 | -- zlib.h:156 |
| 92 | Z_ASCII : constant := 1; -- zlib.h:157 |
| 93 | -- zlib.h:157 |
| 94 | Z_UNKNOWN : constant := 2; -- zlib.h:158 |
| 95 | -- zlib.h:158 |
| 96 | Z_DEFLATED : constant := 8; -- zlib.h:161 |
| 97 | -- zlib.h:161 |
| 98 | Z_NULL : constant := 8#0000#; -- zlib.h:164 |
| 99 | -- for initializing zalloc, zfree, opaque |
| 100 | -- zlib.h:164 |
| 101 | type gzFile is new Voidp; -- zlib.h:646 |
| 102 | |
| 103 | type Z_Stream is private; |
| 104 | |
| 105 | type Z_Streamp is access all Z_Stream; -- zlib.h:89 |
| 106 | |
| 107 | type alloc_func is access function |
| 108 | (Opaque : Voidp; |
| 109 | Items : UInt; |
| 110 | Size : UInt) |
| 111 | return Voidp; -- zlib.h:63 |
| 112 | |
| 113 | type free_func is access procedure (opaque : Voidp; address : Voidp); |
| 114 | |
| 115 | function zlibVersion return Chars_Ptr; |
| 116 | |
| 117 | function Deflate (strm : Z_Streamp; flush : Int) return Int; |
| 118 | |
| 119 | function DeflateEnd (strm : Z_Streamp) return Int; |
| 120 | |
| 121 | function Inflate (strm : Z_Streamp; flush : Int) return Int; |
| 122 | |
| 123 | function InflateEnd (strm : Z_Streamp) return Int; |
| 124 | |
| 125 | function deflateSetDictionary |
| 126 | (strm : Z_Streamp; |
| 127 | dictionary : Byte_Access; |
| 128 | dictLength : UInt) |
| 129 | return Int; |
| 130 | |
| 131 | function deflateCopy (dest : Z_Streamp; source : Z_Streamp) return Int; |
| 132 | -- zlib.h:478 |
| 133 | |
| 134 | function deflateReset (strm : Z_Streamp) return Int; -- zlib.h:495 |
| 135 | |
| 136 | function deflateParams |
| 137 | (strm : Z_Streamp; |
| 138 | level : Int; |
| 139 | strategy : Int) |
| 140 | return Int; -- zlib.h:506 |
| 141 | |
| 142 | function inflateSetDictionary |
| 143 | (strm : Z_Streamp; |
| 144 | dictionary : Byte_Access; |
| 145 | dictLength : UInt) |
| 146 | return Int; -- zlib.h:548 |
| 147 | |
| 148 | function inflateSync (strm : Z_Streamp) return Int; -- zlib.h:565 |
| 149 | |
| 150 | function inflateReset (strm : Z_Streamp) return Int; -- zlib.h:580 |
| 151 | |
| 152 | function compress |
| 153 | (dest : Byte_Access; |
| 154 | destLen : ULong_Access; |
| 155 | source : Byte_Access; |
| 156 | sourceLen : ULong) |
| 157 | return Int; -- zlib.h:601 |
| 158 | |
| 159 | function compress2 |
| 160 | (dest : Byte_Access; |
| 161 | destLen : ULong_Access; |
| 162 | source : Byte_Access; |
| 163 | sourceLen : ULong; |
| 164 | level : Int) |
| 165 | return Int; -- zlib.h:615 |
| 166 | |
| 167 | function uncompress |
| 168 | (dest : Byte_Access; |
| 169 | destLen : ULong_Access; |
| 170 | source : Byte_Access; |
| 171 | sourceLen : ULong) |
| 172 | return Int; |
| 173 | |
| 174 | function gzopen (path : Chars_Ptr; mode : Chars_Ptr) return gzFile; |
| 175 | |
| 176 | function gzdopen (fd : Int; mode : Chars_Ptr) return gzFile; |
| 177 | |
| 178 | function gzsetparams |
| 179 | (file : gzFile; |
| 180 | level : Int; |
| 181 | strategy : Int) |
| 182 | return Int; |
| 183 | |
| 184 | function gzread |
| 185 | (file : gzFile; |
| 186 | buf : Voidp; |
| 187 | len : UInt) |
| 188 | return Int; |
| 189 | |
| 190 | function gzwrite |
| 191 | (file : in gzFile; |
| 192 | buf : in Voidp; |
| 193 | len : in UInt) |
| 194 | return Int; |
| 195 | |
| 196 | function gzprintf (file : in gzFile; format : in Chars_Ptr) return Int; |
| 197 | |
| 198 | function gzputs (file : in gzFile; s : in Chars_Ptr) return Int; |
| 199 | |
| 200 | function gzgets |
| 201 | (file : gzFile; |
| 202 | buf : Chars_Ptr; |
| 203 | len : Int) |
| 204 | return Chars_Ptr; |
| 205 | |
| 206 | function gzputc (file : gzFile; char : Int) return Int; |
| 207 | |
| 208 | function gzgetc (file : gzFile) return Int; |
| 209 | |
| 210 | function gzflush (file : gzFile; flush : Int) return Int; |
| 211 | |
| 212 | function gzseek |
| 213 | (file : gzFile; |
| 214 | offset : Int; |
| 215 | whence : Int) |
| 216 | return Int; |
| 217 | |
| 218 | function gzrewind (file : gzFile) return Int; |
| 219 | |
| 220 | function gztell (file : gzFile) return Int; |
| 221 | |
| 222 | function gzeof (file : gzFile) return Int; |
| 223 | |
| 224 | function gzclose (file : gzFile) return Int; |
| 225 | |
| 226 | function gzerror (file : gzFile; errnum : Int_Access) return Chars_Ptr; |
| 227 | |
| 228 | function adler32 |
| 229 | (adler : ULong; |
| 230 | buf : Byte_Access; |
| 231 | len : UInt) |
| 232 | return ULong; |
| 233 | |
| 234 | function crc32 |
| 235 | (crc : ULong; |
| 236 | buf : Byte_Access; |
| 237 | len : UInt) |
| 238 | return ULong; |
| 239 | |
| 240 | function deflateInit |
| 241 | (strm : Z_Streamp; |
| 242 | level : Int; |
| 243 | version : Chars_Ptr; |
| 244 | stream_size : Int) |
| 245 | return Int; |
| 246 | |
| 247 | function deflateInit2 |
| 248 | (strm : Z_Streamp; |
| 249 | level : Int; |
| 250 | method : Int; |
| 251 | windowBits : Int; |
| 252 | memLevel : Int; |
| 253 | strategy : Int; |
| 254 | version : Chars_Ptr; |
| 255 | stream_size : Int) |
| 256 | return Int; |
| 257 | |
| 258 | function Deflate_Init |
| 259 | (strm : Z_Streamp; |
| 260 | level : Int; |
| 261 | method : Int; |
| 262 | windowBits : Int; |
| 263 | memLevel : Int; |
| 264 | strategy : Int) |
| 265 | return Int; |
| 266 | pragma Inline (Deflate_Init); |
| 267 | |
| 268 | function inflateInit |
| 269 | (strm : Z_Streamp; |
| 270 | version : Chars_Ptr; |
| 271 | stream_size : Int) |
| 272 | return Int; |
| 273 | |
| 274 | function inflateInit2 |
| 275 | (strm : in Z_Streamp; |
| 276 | windowBits : in Int; |
| 277 | version : in Chars_Ptr; |
| 278 | stream_size : in Int) |
| 279 | return Int; |
| 280 | |
| 281 | function inflateBackInit |
| 282 | (strm : in Z_Streamp; |
| 283 | windowBits : in Int; |
| 284 | window : in Byte_Access; |
| 285 | version : in Chars_Ptr; |
| 286 | stream_size : in Int) |
| 287 | return Int; |
| 288 | -- Size of window have to be 2**windowBits. |
| 289 | |
| 290 | function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int; |
| 291 | pragma Inline (Inflate_Init); |
| 292 | |
| 293 | function zError (err : Int) return Chars_Ptr; |
| 294 | |
| 295 | function inflateSyncPoint (z : Z_Streamp) return Int; |
| 296 | |
| 297 | function get_crc_table return ULong_Access; |
| 298 | |
| 299 | -- Interface to the available fields of the z_stream structure. |
| 300 | -- The application must update next_in and avail_in when avail_in has |
| 301 | -- dropped to zero. It must update next_out and avail_out when avail_out |
| 302 | -- has dropped to zero. The application must initialize zalloc, zfree and |
| 303 | -- opaque before calling the init function. |
| 304 | |
| 305 | procedure Set_In |
| 306 | (Strm : in out Z_Stream; |
| 307 | Buffer : in Voidp; |
| 308 | Size : in UInt); |
| 309 | pragma Inline (Set_In); |
| 310 | |
| 311 | procedure Set_Out |
| 312 | (Strm : in out Z_Stream; |
| 313 | Buffer : in Voidp; |
| 314 | Size : in UInt); |
| 315 | pragma Inline (Set_Out); |
| 316 | |
| 317 | procedure Set_Mem_Func |
| 318 | (Strm : in out Z_Stream; |
| 319 | Opaque : in Voidp; |
| 320 | Alloc : in alloc_func; |
| 321 | Free : in free_func); |
| 322 | pragma Inline (Set_Mem_Func); |
| 323 | |
| 324 | function Last_Error_Message (Strm : in Z_Stream) return String; |
| 325 | pragma Inline (Last_Error_Message); |
| 326 | |
| 327 | function Avail_Out (Strm : in Z_Stream) return UInt; |
| 328 | pragma Inline (Avail_Out); |
| 329 | |
| 330 | function Avail_In (Strm : in Z_Stream) return UInt; |
| 331 | pragma Inline (Avail_In); |
| 332 | |
| 333 | function Total_In (Strm : in Z_Stream) return ULong; |
| 334 | pragma Inline (Total_In); |
| 335 | |
| 336 | function Total_Out (Strm : in Z_Stream) return ULong; |
| 337 | pragma Inline (Total_Out); |
| 338 | |
| 339 | function inflateCopy |
| 340 | (dest : in Z_Streamp; |
| 341 | Source : in Z_Streamp) |
| 342 | return Int; |
| 343 | |
| 344 | function compressBound (Source_Len : in ULong) return ULong; |
| 345 | |
| 346 | function deflateBound |
| 347 | (Strm : in Z_Streamp; |
| 348 | Source_Len : in ULong) |
| 349 | return ULong; |
| 350 | |
| 351 | function gzungetc (C : in Int; File : in gzFile) return Int; |
| 352 | |
| 353 | function zlibCompileFlags return ULong; |
| 354 | |
| 355 | private |
| 356 | |
| 357 | type Z_Stream is record -- zlib.h:68 |
| 358 | Next_In : Voidp := Nul; -- next input byte |
| 359 | Avail_In : UInt := 0; -- number of bytes available at next_in |
| 360 | Total_In : ULong := 0; -- total nb of input bytes read so far |
| 361 | Next_Out : Voidp := Nul; -- next output byte should be put there |
| 362 | Avail_Out : UInt := 0; -- remaining free space at next_out |
| 363 | Total_Out : ULong := 0; -- total nb of bytes output so far |
| 364 | msg : Chars_Ptr; -- last error message, NULL if no error |
| 365 | state : Voidp; -- not visible by applications |
| 366 | zalloc : alloc_func := null; -- used to allocate the internal state |
| 367 | zfree : free_func := null; -- used to free the internal state |
| 368 | opaque : Voidp; -- private data object passed to |
| 369 | -- zalloc and zfree |
| 370 | data_type : Int; -- best guess about the data type: |
| 371 | -- ascii or binary |
| 372 | adler : ULong; -- adler32 value of the uncompressed |
| 373 | -- data |
| 374 | reserved : ULong; -- reserved for future use |
| 375 | end record; |
| 376 | |
| 377 | pragma Convention (C, Z_Stream); |
| 378 | |
| 379 | pragma Import (C, zlibVersion, "zlibVersion"); |
| 380 | pragma Import (C, Deflate, "deflate"); |
| 381 | pragma Import (C, DeflateEnd, "deflateEnd"); |
| 382 | pragma Import (C, Inflate, "inflate"); |
| 383 | pragma Import (C, InflateEnd, "inflateEnd"); |
| 384 | pragma Import (C, deflateSetDictionary, "deflateSetDictionary"); |
| 385 | pragma Import (C, deflateCopy, "deflateCopy"); |
| 386 | pragma Import (C, deflateReset, "deflateReset"); |
| 387 | pragma Import (C, deflateParams, "deflateParams"); |
| 388 | pragma Import (C, inflateSetDictionary, "inflateSetDictionary"); |
| 389 | pragma Import (C, inflateSync, "inflateSync"); |
| 390 | pragma Import (C, inflateReset, "inflateReset"); |
| 391 | pragma Import (C, compress, "compress"); |
| 392 | pragma Import (C, compress2, "compress2"); |
| 393 | pragma Import (C, uncompress, "uncompress"); |
| 394 | pragma Import (C, gzopen, "gzopen"); |
| 395 | pragma Import (C, gzdopen, "gzdopen"); |
| 396 | pragma Import (C, gzsetparams, "gzsetparams"); |
| 397 | pragma Import (C, gzread, "gzread"); |
| 398 | pragma Import (C, gzwrite, "gzwrite"); |
| 399 | pragma Import (C, gzprintf, "gzprintf"); |
| 400 | pragma Import (C, gzputs, "gzputs"); |
| 401 | pragma Import (C, gzgets, "gzgets"); |
| 402 | pragma Import (C, gzputc, "gzputc"); |
| 403 | pragma Import (C, gzgetc, "gzgetc"); |
| 404 | pragma Import (C, gzflush, "gzflush"); |
| 405 | pragma Import (C, gzseek, "gzseek"); |
| 406 | pragma Import (C, gzrewind, "gzrewind"); |
| 407 | pragma Import (C, gztell, "gztell"); |
| 408 | pragma Import (C, gzeof, "gzeof"); |
| 409 | pragma Import (C, gzclose, "gzclose"); |
| 410 | pragma Import (C, gzerror, "gzerror"); |
| 411 | pragma Import (C, adler32, "adler32"); |
| 412 | pragma Import (C, crc32, "crc32"); |
| 413 | pragma Import (C, deflateInit, "deflateInit_"); |
| 414 | pragma Import (C, inflateInit, "inflateInit_"); |
| 415 | pragma Import (C, deflateInit2, "deflateInit2_"); |
| 416 | pragma Import (C, inflateInit2, "inflateInit2_"); |
| 417 | pragma Import (C, zError, "zError"); |
| 418 | pragma Import (C, inflateSyncPoint, "inflateSyncPoint"); |
| 419 | pragma Import (C, get_crc_table, "get_crc_table"); |
| 420 | |
| 421 | -- since zlib 1.2.0: |
| 422 | |
| 423 | pragma Import (C, inflateCopy, "inflateCopy"); |
| 424 | pragma Import (C, compressBound, "compressBound"); |
| 425 | pragma Import (C, deflateBound, "deflateBound"); |
| 426 | pragma Import (C, gzungetc, "gzungetc"); |
| 427 | pragma Import (C, zlibCompileFlags, "zlibCompileFlags"); |
| 428 | |
| 429 | pragma Import (C, inflateBackInit, "inflateBackInit_"); |
| 430 | |
| 431 | -- I stopped binding the inflateBack routines, because realize that |
| 432 | -- it does not support zlib and gzip headers for now, and have no |
| 433 | -- symmetric deflateBack routines. |
| 434 | -- ZLib-Ada is symmetric regarding deflate/inflate data transformation |
| 435 | -- and has a similar generic callback interface for the |
| 436 | -- deflate/inflate transformation based on the regular Deflate/Inflate |
| 437 | -- routines. |
| 438 | |
| 439 | -- pragma Import (C, inflateBack, "inflateBack"); |
| 440 | -- pragma Import (C, inflateBackEnd, "inflateBackEnd"); |
| 441 | |
| 442 | end ZLib.Thin; |
| --- a/compat/zlib/contrib/ada/zlib-thin.ads | |
| +++ b/compat/zlib/contrib/ada/zlib-thin.ads | |
| @@ -1,450 +0,0 @@ | |
| ----------------------------------------------------------------- | |
| --- ZLib for Ada thick binding. -- | |
| --- -- | |
| --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | |
| --- -- | |
| --- Open source license information is in the zlib.ads file. -- | |
| ----------------------------------------------------------------- | |
| --- $Id: zlib-thin.ads,v 1.11 2004/07/23 06:33:11 vagul Exp $ | |
D
compat/zlib/contrib/ada/zlib.adb
-693
| --- a/compat/zlib/contrib/ada/zlib.adb | ||
| +++ b/compat/zlib/contrib/ada/zlib.adb | ||
| @@ -1,701 +0,0 @@ | ||
| ----------------------------------------------------------------- | ||
| --- ZLib for Ada thick binding. -- | ||
| --- -- | ||
| --- Copyright (C) 2002-2004 Dmitriy Anisimkov -- | ||
| --- -- | ||
| --- Open source license information is in the zlib.ads file. -- | ||
| ----------------------------------------------------------------- | ||
| 1 | - | |
| --- $Id: zlib.adb,v 1.31 2004/09/06 06:53:19 vagul Exp $ | ||
| 2 | - | |
| 3 | -with Ada.Exceptions; | |
| 4 | -with Ada.Unchecked_Conversion; | |
| 5 | -with Ada.Unchecked_Deallocation; | |
| 6 | - | |
| 7 | -with Interfaces.C.Strings; | |
| 8 | - | |
| 9 | -with ZLib.Thin; | |
| 10 | - | |
| 11 | -package body ZLib is | |
| 12 | - | |
| 13 | - use type Thin.Int; | |
| 14 | - | |
| 15 | - type Z_Stream is new Thin.Z_Stream; | |
| 16 | - | |
| 17 | - type Return_Code_Enum is | |
| 18 | - (OK, | |
| 19 | - STREAM_END, | |
| 20 | - NEED_DICT, | |
| 21 | - ERRNO, | |
| 22 | - STREAM_ERROR, | |
| 23 | - DATA_ERROR, | |
| 24 | - MEM_ERROR, | |
| 25 | - BUF_ERROR, | |
| 26 | - VERSION_ERROR); | |
| 27 | - | |
| 28 | - type Flate_Step_Function is access | |
| 29 | - function (Strm : in Thin.Z_Streamp; Flush : in Thin.Int) return Thin.Int; | |
| 30 | - pragma Convention (C, Flate_Step_Function); | |
| 31 | - | |
| 32 | - type Flate_End_Function is access | |
| 33 | - function (Ctrm : in Thin.Z_Streamp) return Thin.Int; | |
| 34 | - pragma Convention (C, Flate_End_Function); | |
| 35 | - | |
| 36 | - type Flate_Type is record | |
| 37 | - Step : Flate_Step_Function; | |
| 38 | - Done : Flate_End_Function; | |
| 39 | - end record; | |
| 40 | - | |
| 41 | - subtype Footer_Array is Stream_Element_Array (1 .. 8); | |
| 42 | - | |
| 43 | - Simple_GZip_Header : constant Stream_Element_Array (1 .. 10) | |
| 44 | - := (16#1f#, 16#8b#, -- Magic header | |
| 45 | - 16#08#, -- Z_DEFLATED | |
| 46 | - 16#00#, -- Flags | |
| 47 | - 16#00#, 16#00#, 16#00#, 16#00#, -- Time | |
| 48 | - 16#00#, -- XFlags | |
| 49 | - 16#03# -- OS code | |
| 50 | - ); | |
| 51 | - -- The simplest gzip header is not for informational, but just for | |
| 52 | - -- gzip format compatibility. | |
| 53 | - -- Note that some code below is using assumption | |
| 54 | - -- Simple_GZip_Header'Last > Footer_Array'Last, so do not make | |
| 55 | - -- Simple_GZip_Header'Last <= Footer_Array'Last. | |
| 56 | - | |
| 57 | - Return_Code : constant array (Thin.Int range <>) of Return_Code_Enum | |
| 58 | - := (0 => OK, | |
| 59 | - 1 => STREAM_END, | |
| 60 | - 2 => NEED_DICT, | |
| 61 | - -1 => ERRNO, | |
| 62 | - -2 => STREAM_ERROR, | |
| 63 | - -3 => DATA_ERROR, | |
| 64 | - -4 => MEM_ERROR, | |
| 65 | - -5 => BUF_ERROR, | |
| 66 | - -6 => VERSION_ERROR); | |
| 67 | - | |
| 68 | - Flate : constant array (Boolean) of Flate_Type | |
| 69 | - := (True => (Step => Thin.Deflate'Access, | |
| 70 | - Done => Thin.DeflateEnd'Access), | |
| 71 | - False => (Step => Thin.Inflate'Access, | |
| 72 | - Done => Thin.InflateEnd'Access)); | |
| 73 | - | |
| 74 | - Flush_Finish : constant array (Boolean) of Flush_Mode | |
| 75 | - := (True => Finish, False => No_Flush); | |
| 76 | - | |
| 77 | - procedure Raise_Error (Stream : in Z_Stream); | |
| 78 | - pragma Inline (Raise_Error); | |
| 79 | - | |
| 80 | - procedure Raise_Error (Message : in String); | |
| 81 | - pragma Inline (Raise_Error); | |
| 82 | - | |
| 83 | - procedure Check_Error (Stream : in Z_Stream; Code : in Thin.Int); | |
| 84 | - | |
| 85 | - procedure Free is new Ada.Unchecked_Deallocation | |
| 86 | - (Z_Stream, Z_Stream_Access); | |
| 87 | - | |
| 88 | - function To_Thin_Access is new Ada.Unchecked_Conversion | |
| 89 | - (Z_Stream_Access, Thin.Z_Streamp); | |
| 90 | - | |
| 91 | - procedure Translate_GZip | |
| 92 | - (Filter : in out Filter_Type; | |
| 93 | - In_Data : in Ada.Streams.Stream_Element_Array; | |
| 94 | - In_Last : out Ada.Streams.Stream_Element_Offset; | |
| 95 | - Out_Data : out Ada.Streams.Stream_Element_Array; | |
| 96 | - Out_Last : out Ada.Streams.Stream_Element_Offset; | |
| 97 | - Flush : in Flush_Mode); | |
| 98 | - -- Separate translate routine for make gzip header. | |
| 99 | - | |
| 100 | - procedure Translate_Auto | |
| 101 | - (Filter : in out Filter_Type; | |
| 102 | - In_Data : in Ada.Streams.Stream_Element_Array; | |
| 103 | - In_Last : out Ada.Streams.Stream_Element_Offset; | |
| 104 | - Out_Data : out Ada.Streams.Stream_Element_Array; | |
| 105 | - Out_Last : out Ada.Streams.Stream_Element_Offset; | |
| 106 | - Flush : in Flush_Mode); | |
| 107 | - -- translate routine without additional headers. | |
| 108 | - | |
| 109 | - ----------------- | |
| 110 | - -- Check_Error -- | |
| 111 | - ----------------- | |
| 112 | - | |
| 113 | - procedure Check_Error (Stream : in Z_Stream; Code : in Thin.Int) is | |
| 114 | - use type Thin.Int; | |
| 115 | - begin | |
| 116 | - if Code /= Thin.Z_OK then | |
| 117 | - Raise_Error | |
| 118 | - (Return_Code_Enum'Image (Return_Code (Code)) | |
| 119 | - & ": " & Last_Error_Message (Stream)); | |
| 120 | - end if; | |
| 121 | - end Check_Error; | |
| 122 | - | |
| 123 | - ----------- | |
| 124 | - -- Close -- | |
| 125 | - ----------- | |
| 126 | - | |
| 127 | - procedure Close | |
| 128 | - (Filter : in out Filter_Type; | |
| 129 | - Ignore_Error : in Boolean := False) | |
| 130 | - is | |
| 131 | - Code : Thin.Int; | |
| 132 | - begin | |
| 133 | - if not Ignore_Error and then not Is_Open (Filter) then | |
| 134 | - raise Status_Error; | |
| 135 | - end if; | |
| 136 | - | |
| 137 | - Code := Flate (Filter.Compression).Done (To_Thin_Access (Filter.Strm)); | |
| 138 | - | |
| 139 | - if Ignore_Error or else Code = Thin.Z_OK then | |
| 140 | - Free (Filter.Strm); | |
| 141 | - else | |
| 142 | - declare | |
| 143 | - Error_Message : constant String | |
| 144 | - := Last_Error_Message (Filter.Strm.all); | |
| 145 | - begin | |
| 146 | - Free (Filter.Strm); | |
| 147 | - Ada.Exceptions.Raise_Exception | |
| 148 | - (ZLib_Error'Identity, | |
| 149 | - Return_Code_Enum'Image (Return_Code (Code)) | |
| 150 | - & ": " & Error_Message); | |
| 151 | - end; | |
| 152 | - end if; | |
| 153 | - end Close; | |
| 154 | - | |
| 155 | - ----------- | |
| 156 | - -- CRC32 -- | |
| 157 | - ----------- | |
| 158 | - | |
| 159 | - function CRC32 | |
| 160 | - (CRC : in Unsigned_32; | |
| 161 | - Data : in Ada.Streams.Stream_Element_Array) | |
| 162 | - return Unsigned_32 | |
| 163 | - is | |
| 164 | - use Thin; | |
| 165 | - begin | |
| 166 | - return Unsigned_32 (crc32 (ULong (CRC), | |
| 167 | - Data'Address, | |
| 168 | - Data'Length)); | |
| 169 | - end CRC32; | |
| 170 | - | |
| 171 | - procedure CRC32 | |
| 172 | - (CRC : in out Unsigned_32; | |
| 173 | - Data : in Ada.Streams.Stream_Element_Array) is | |
| 174 | - begin | |
| 175 | - CRC := CRC32 (CRC, Data); | |
| 176 | - end CRC32; | |
| 177 | - | |
| 178 | - ------------------ | |
| 179 | - -- Deflate_Init -- | |
| 180 | - ------------------ | |
| 181 | - | |
| 182 | - procedure Deflate_Init | |
| 183 | - (Filter : in out Filter_Type; | |
| 184 | - Level : in Compression_Level := Default_Compression; | |
| 185 | - Strategy : in Strategy_Type := Default_Strategy; | |
| 186 | - Method : in Compression_Method := Deflated; | |
| 187 | - Window_Bits : in Window_Bits_Type := Default_Window_Bits; | |
| 188 | - Memory_Level : in Memory_Level_Type := Default_Memory_Level; | |
| 189 | - Header : in Header_Type := Default) | |
| 190 | - is | |
| 191 | - use type Thin.Int; | |
| 192 | - Win_Bits : Thin.Int := Thin.Int (Window_Bits); | |
| 193 | - begin | |
| 194 | - if Is_Open (Filter) then | |
| 195 | - raise Status_Error; | |
| 196 | - end if; | |
| 197 | - | |
| 198 | - -- We allow ZLib to make header only in case of default header type. | |
| 199 | - -- Otherwise we would either do header by ourselfs, or do not do | |
| 200 | - -- header at all. | |
| 201 | - | |
| 202 | - if Header = None or else Header = GZip then | |
| 203 | - Win_Bits := -Win_Bits; | |
| 204 | - end if; | |
| 205 | - | |
| 206 | - -- For the GZip CRC calculation and make headers. | |
| 207 | - | |
| 208 | - if Header = GZip then | |
| 209 | - Filter.CRC := 0; | |
| 210 | - Filter.Offset := Simple_GZip_Header'First; | |
| 211 | - else | |
| 212 | - Filter.Offset := Simple_GZip_Header'Last + 1; | |
| 213 | - end if; | |
| 214 | - | |
| 215 | - Filter.Strm := new Z_Stream; | |
| 216 | - Filter.Compression := True; | |
| 217 | - Filter.Stream_End := False; | |
| 218 | - Filter.Header := Header; | |
| 219 | - | |
| 220 | - if Thin.Deflate_Init | |
| 221 | - (To_Thin_Access (Filter.Strm), | |
| 222 | - Level => Thin.Int (Level), | |
| 223 | - method => Thin.Int (Method), | |
| 224 | - windowBits => Win_Bits, | |
| 225 | - memLevel => Thin.Int (Memory_Level), | |
| 226 | - strategy => Thin.Int (Strategy)) /= Thin.Z_OK | |
| 227 | - then | |
| 228 | - Raise_Error (Filter.Strm.all); | |
| 229 | - end if; | |
| 230 | - end Deflate_Init; | |
| 231 | - | |
| 232 | - ----------- | |
| 233 | - -- Flush -- | |
| 234 | - ----------- | |
| 235 | - | |
| 236 | - procedure Flush | |
| 237 | - (Filter : in out Filter_Type; | |
| 238 | - Out_Data : out Ada.Streams.Stream_Element_Array; | |
| 239 | - Out_Last : out Ada.Streams.Stream_Element_Offset; | |
| 240 | - Flush : in Flush_Mode) | |
| 241 | - is | |
| 242 | - No_Data : Stream_Element_Array := (1 .. 0 => 0); | |
| 243 | - Last : Stream_Element_Offset; | |
| 244 | - begin | |
| 245 | - Translate (Filter, No_Data, Last, Out_Data, Out_Last, Flush); | |
| 246 | - end Flush; | |
| 247 | - | |
| 248 | - ----------------------- | |
| 249 | - -- Generic_Translate -- | |
| 250 | - ----------------------- | |
| 251 | - | |
| 252 | - procedure Generic_Translate | |
| 253 | - (Filter : in out ZLib.Filter_Type; | |
| 254 | - In_Buffer_Size : in Integer := Default_Buffer_Size; | |
| 255 | - Out_Buffer_Size : in Integer := Default_Buffer_Size) | |
| 256 | - is | |
| 257 | - In_Buffer : Stream_Element_Array | |
| 258 | - (1 .. Stream_Element_Offset (In_Buffer_Size)); | |
| 259 | - Out_Buffer : Stream_Element_Array | |
| 260 | - (1 .. Stream_Element_Offset (Out_Buffer_Size)); | |
| 261 | - Last : Stream_Element_Offset; | |
| 262 | - In_Last : Stream_Element_Offset; | |
| 263 | - In_First : Stream_Element_Offset; | |
| 264 | - Out_Last : Stream_Element_Offset; | |
| 265 | - begin | |
| 266 | - Main : loop | |
| 267 | - Data_In (In_Buffer, Last); | |
| 268 | - | |
| 269 | - In_First := In_Buffer'First; | |
| 270 | - | |
| 271 | - loop | |
| 272 | - Translate | |
| 273 | - (Filter => Filter, | |
| 274 | - In_Data => In_Buffer (In_First .. Last), | |
| 275 | - In_Last => In_Last, | |
| 276 | - Out_Data => Out_Buffer, | |
| 277 | - Out_Last => Out_Last, | |
| 278 | - Flush => Flush_Finish (Last < In_Buffer'First)); | |
| 279 | - | |
| 280 | - if Out_Buffer'First <= Out_Last then | |
| 281 | - Data_Out (Out_Buffer (Out_Buffer'First .. Out_Last)); | |
| 282 | - end if; | |
| 283 | - | |
| 284 | - exit Main when Stream_End (Filter); | |
| 285 | - | |
| 286 | - -- The end of in buffer. | |
| 287 | - | |
| 288 | - exit when In_Last = Last; | |
| 289 | - | |
| 290 | - In_First := In_Last + 1; | |
| 291 | - end loop; | |
| 292 | - end loop Main; | |
| 293 | - | |
| 294 | - end Generic_Translate; | |
| 295 | - | |
| 296 | - ------------------ | |
| 297 | - -- Inflate_Init -- | |
| 298 | - ------------------ | |
| 299 | - | |
| 300 | - procedure Inflate_Init | |
| 301 | - (Filter : in out Filter_Type; | |
| 302 | - Window_Bits : in Window_Bits_Type := Default_Window_Bits; | |
| 303 | - Header : in Header_Type := Default) | |
| 304 | - is | |
| 305 | - use type Thin.Int; | |
| 306 | - Win_Bits : Thin.Int := Thin.Int (Window_Bits); | |
| 307 | - | |
| 308 | - procedure Check_Version; | |
| 309 | - -- Check the latest header types compatibility. | |
| 310 | - | |
| 311 | - procedure Check_Version is | |
| 312 | - begin | |
| 313 | - if Version <= "1.1.4" then | |
| 314 | - Raise_Error | |
| 315 | - ("Inflate header type " & Header_Type'Image (Header) | |
| 316 | - & " incompatible with ZLib version " & Version); | |
| 317 | - end if; | |
| 318 | - end Check_Version; | |
| 319 | - | |
| 320 | - begin | |
| 321 | - if Is_Open (Filter) then | |
| 322 | - raise Status_Error; | |
| 323 | - end if; | |
| 324 | - | |
| 325 | - case Header is | |
| 326 | - when None => | |
| 327 | - Check_Version; | |
| 328 | - | |
| 329 | - -- Inflate data without headers determined | |
| 330 | - -- by negative Win_Bits. | |
| 331 | - | |
| 332 | - Win_Bits := -Win_Bits; | |
| 333 | - when GZip => | |
| 334 | - Check_Version; | |
| 335 | - | |
| 336 | - -- Inflate gzip data defined by flag 16. | |
| 337 | - | |
| 338 | - Win_Bits := Win_Bits + 16; | |
| 339 | - when Auto => | |
| 340 | - Check_Version; | |
| 341 | - | |
| 342 | - -- Inflate with automatic detection | |
| 343 | - -- of gzip or native header defined by flag 32. | |
| 344 | - | |
| 345 | - Win_Bits := Win_Bits + 32; | |
| 346 | - when Default => null; | |
| 347 | - end case; | |
| 348 | - | |
| 349 | - Filter.Strm := new Z_Stream; | |
| 350 | - Filter.Compression := False; | |
| 351 | - Filter.Stream_End := False; | |
| 352 | - Filter.Header := Header; | |
| 353 | - | |
| 354 | - if Thin.Inflate_Init | |
| 355 | - (To_Thin_Access (Filter.Strm), Win_Bits) /= Thin.Z_OK | |
| 356 | - then | |
| 357 | - Raise_Error (Filter.Strm.all); | |
| 358 | - end if; | |
| 359 | - end Inflate_Init; | |
| 360 | - | |
| 361 | - ------------- | |
| 362 | - -- Is_Open -- | |
| 363 | - ------------- | |
| 364 | - | |
| 365 | - function Is_Open (Filter : in Filter_Type) return Boolean is | |
| 366 | - begin | |
| 367 | - return Filter.Strm /= null; | |
| 368 | - end Is_Open; | |
| 369 | - | |
| 370 | - ----------------- | |
| 371 | - -- Raise_Error -- | |
| 372 | - ----------------- | |
| 373 | - | |
| 374 | - procedure Raise_Error (Message : in String) is | |
| 375 | - begin | |
| 376 | - Ada.Exceptions.Raise_Exception (ZLib_Error'Identity, Message); | |
| 377 | - end Raise_Error; | |
| 378 | - | |
| 379 | - procedure Raise_Error (Stream : in Z_Stream) is | |
| 380 | - begin | |
| 381 | - Raise_Error (Last_Error_Message (Stream)); | |
| 382 | - end Raise_Error; | |
| 383 | - | |
| 384 | - ---------- | |
| 385 | - -- Read -- | |
| 386 | - ---------- | |
| 387 | - | |
| 388 | - procedure Read | |
| 389 | - (Filter : in out Filter_Type; | |
| 390 | - Item : out Ada.Streams.Stream_Element_Array; | |
| 391 | - Last : out Ada.Streams.Stream_Element_Offset; | |
| 392 | - Flush : in Flush_Mode := No_Flush) | |
| 393 | - is | |
| 394 | - In_Last : Stream_Element_Offset; | |
| 395 | - Item_First : Ada.Streams.Stream_Element_Offset := Item'First; | |
| 396 | - V_Flush : Flush_Mode := Flush; | |
| 397 | - | |
| 398 | - begin | |
| 399 | - pragma Assert (Rest_First in Buffer'First .. Buffer'Last + 1); | |
| 400 | - pragma Assert (Rest_Last in Buffer'First - 1 .. Buffer'Last); | |
| 401 | - | |
| 402 | - loop | |
| 403 | - if Rest_Last = Buffer'First - 1 then | |
| 404 | - V_Flush := Finish; | |
| 405 | - | |
| 406 | - elsif Rest_First > Rest_Last then | |
| 407 | - Read (Buffer, Rest_Last); | |
| 408 | - Rest_First := Buffer'First; | |
| 409 | - | |
| 410 | - if Rest_Last < Buffer'First then | |
| 411 | - V_Flush := Finish; | |
| 412 | - end if; | |
| 413 | - end if; | |
| 414 | - | |
| 415 | - Translate | |
| 416 | - (Filter => Filter, | |
| 417 | - In_Data => Buffer (Rest_First .. Rest_Last), | |
| 418 | - In_Last => In_Last, | |
| 419 | - Out_Data => Item (Item_First .. Item'Last), | |
| 420 | - Out_Last => Last, | |
| 421 | - Flush => V_Flush); | |
| 422 | - | |
| 423 | - Rest_First := In_Last + 1; | |
| 424 | - | |
| 425 | - exit when Stream_End (Filter) | |
| 426 | - or else Last = Item'Last | |
| 427 | - or else (Last >= Item'First and then Allow_Read_Some); | |
| 428 | - | |
| 429 | - Item_First := Last + 1; | |
| 430 | - end loop; | |
| 431 | - end Read; | |
| 432 | - | |
| 433 | - ---------------- | |
| 434 | - -- Stream_End -- | |
| 435 | - ---------------- | |
| 436 | - | |
| 437 | - function Stream_End (Filter : in Filter_Type) return Boolean is | |
| 438 | - begin | |
| 439 | - if Filter.Header = GZip and Filter.Compression then | |
| 440 | - return Filter.Stream_End | |
| 441 | - and then Filter.Offset = Footer_Array'Last + 1; | |
| 442 | - else | |
| 443 | - return Filter.Stream_End; | |
| 444 | - end if; | |
| 445 | - end Stream_End; | |
| 446 | - | |
| 447 | - -------------- | |
| 448 | - -- Total_In -- | |
| 449 | - -------------- | |
| 450 | - | |
| 451 | - function Total_In (Filter : in Filter_Type) return Count is | |
| 452 | - begin | |
| 453 | - return Count (Thin.Total_In (To_Thin_Access (Filter.Strm).all)); | |
| 454 | - end Total_In; | |
| 455 | - | |
| 456 | - --------------- | |
| 457 | - -- Total_Out -- | |
| 458 | - --------------- | |
| 459 | - | |
| 460 | - function Total_Out (Filter : in Filter_Type) return Count is | |
| 461 | - begin | |
| 462 | - return Count (Thin.Total_Out (To_Thin_Access (Filter.Strm).all)); | |
| 463 | - end Total_Out; | |
| 464 | - | |
| 465 | - --------------- | |
| 466 | - -- Translate -- | |
| 467 | - --------------- | |
| 468 | - | |
| 469 | - procedure Translate | |
| 470 | - (Filter : in out Filter_Type; | |
| 471 | - In_Data : in Ada.Streams.Stream_Element_Array; | |
| 472 | - In_Last : out Ada.Streams.Stream_Element_Offset; | |
| 473 | - Out_Data : out Ada.Streams.Stream_Element_Array; | |
| 474 | - Out_Last : out Ada.Streams.Stream_Element_Offset; | |
| 475 | - Flush : in Flush_Mode) is | |
| 476 | - begin | |
| 477 | - if Filter.Header = GZip and then Filter.Compression then | |
| 478 | - Translate_GZip | |
| 479 | - (Filter => Filter, | |
| 480 | - In_Data => In_Data, | |
| 481 | - In_Last => In_Last, | |
| 482 | - Out_Data => Out_Data, | |
| 483 | - Out_Last => Out_Last, | |
| 484 | - Flush => Flush); | |
| 485 | - else | |
| 486 | - Translate_Auto | |
| 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 | - end if; | |
| 494 | - end Translate; | |
| 495 | - | |
| 496 | - -------------------- | |
| 497 | - -- Translate_Auto -- | |
| 498 | - -------------------- | |
| 499 | - | |
| 500 | - procedure Translate_Auto | |
| 501 | - (Filter : in out Filter_Type; | |
| 502 | - In_Data : in Ada.Streams.Stream_Element_Array; | |
| 503 | - In_Last : out Ada.Streams.Stream_Element_Offset; | |
| 504 | - Out_Data : out Ada.Streams.Stream_Element_Array; | |
| 505 | - Out_Last : out Ada.Streams.Stream_Element_Offset; | |
| 506 | - Flush : in Flush_Mode) | |
| 507 | - is | |
| 508 | - use type Thin.Int; | |
| 509 | - Code : Thin.Int; | |
| 510 | - | |
| 511 | - begin | |
| 512 | - if not Is_Open (Filter) then | |
| 513 | - raise Status_Error; | |
| 514 | - end if; | |
| 515 | - | |
| 516 | - if Out_Data'Length = 0 and then In_Data'Length = 0 then | |
| 517 | - raise Constraint_Error; | |
| 518 | - end if; | |
| 519 | - | |
| 520 | - Set_Out (Filter.Strm.all, Out_Data'Address, Out_Data'Length); | |
| 521 | - Set_In (Filter.Strm.all, In_Data'Address, In_Data'Length); | |
| 522 | - | |
| 523 | - Code := Flate (Filter.Compression).Step | |
| 524 | - (To_Thin_Access (Filter.Strm), | |
| 525 | - Thin.Int (Flush)); | |
| 526 | - | |
| 527 | - if Code = Thin.Z_STREAM_END then | |
| 528 | - Filter.Stream_End := True; | |
| 529 | - else | |
| 530 | - Check_Error (Filter.Strm.all, Code); | |
| 531 | - end if; | |
| 532 | - | |
| 533 | - In_Last := In_Data'Last | |
| 534 | - - Stream_Element_Offset (Avail_In (Filter.Strm.all)); | |
| 535 | - Out_Last := Out_Data'Last | |
| 536 | - - Stream_Element_Offset (Avail_Out (Filter.Strm.all)); | |
| 537 | - end Translate_Auto; | |
| 538 | - | |
| 539 | - -------------------- | |
| 540 | - -- Translate_GZip -- | |
| 541 | - -------------------- | |
| 542 | - | |
| 543 | - procedure Translate_GZip | |
| 544 | - (Filter : in out Filter_Type; | |
| 545 | - In_Data : in Ada.Streams.Stream_Element_Array; | |
| 546 | - In_Last : out Ada.Streams.Stream_Element_Offset; | |
| 547 | - Out_Data : out Ada.Streams.Stream_Element_Array; | |
| 548 | - Out_Last : out Ada.Streams.Stream_Element_Offset; | |
| 549 | - Flush : in Flush_Mode) | |
| 550 | - is | |
| 551 | - Out_First : Stream_Element_Offset; | |
| 552 | - | |
| 553 | - procedure Add_Data (Data : in Stream_Element_Array); | |
| 554 | - -- Add data to stream from the Filter.Offset till necessary, | |
| 555 | - -- used for add gzip headr/footer. | |
| 556 | - | |
| 557 | - procedure Put_32 | |
| 558 | - (Item : in out Stream_Element_Array; | |
| 559 | - Data : in Unsigned_32); | |
| 560 | - pragma Inline (Put_32); | |
| 561 | - | |
| 562 | - -------------- | |
| 563 | - -- Add_Data -- | |
| 564 | - -------------- | |
| 565 | - | |
| 566 | - procedure Add_Data (Data : in Stream_Element_Array) is | |
| 567 | - Data_First : Stream_Element_Offset renames Filter.Offset; | |
| 568 | - Data_Last : Stream_Element_Offset; | |
| 569 | - Data_Len : Stream_Element_Offset; -- -1 | |
| 570 | - Out_Len : Stream_Element_Offset; -- -1 | |
| 571 | - begin | |
| 572 | - Out_First := Out_Last + 1; | |
| 573 | - | |
| 574 | - if Data_First > Data'Last then | |
| 575 | - return; | |
| 576 | - end if; | |
| 577 | - | |
| 578 | - Data_Len := Data'Last - Data_First; | |
| 579 | - Out_Len := Out_Data'Last - Out_First; | |
| 580 | - | |
| 581 | - if Data_Len <= Out_Len then | |
| 582 | - Out_Last := Out_First + Data_Len; | |
| 583 | - Data_Last := Data'Last; | |
| 584 | - else | |
| 585 | - Out_Last := Out_Data'Last; | |
| 586 | - Data_Last := Data_First + Out_Len; | |
| 587 | - end if; | |
| 588 | - | |
| 589 | - Out_Data (Out_First .. Out_Last) := Data (Data_First .. Data_Last); | |
| 590 | - | |
| 591 | - Data_First := Data_Last + 1; | |
| 592 | - Out_First := Out_Last + 1; | |
| 593 | - end Add_Data; | |
| 594 | - | |
| 595 | - ------------ | |
| 596 | - -- Put_32 -- | |
| 597 | - ------------ | |
| 598 | - | |
| 599 | - procedure Put_32 | |
| 600 | - (Item : in out Stream_Element_Array; | |
| 601 | - Data : in Unsigned_32) | |
| 602 | - is | |
| 603 | - D : Unsigned_32 := Data; | |
| 604 | - begin | |
| 605 | - for J in Item'First .. Item'First + 3 loop | |
| 606 | - Item (J) := Stream_Element (D and 16#FF#); | |
| 607 | - D := Shift_Right (D, 8); | |
| 608 | - end loop; | |
| 609 | - end Put_32; | |
| 610 | - | |
| 611 | - begin | |
| 612 | - Out_Last := Out_Data'First - 1; | |
| 613 | - | |
| 614 | - if not Filter.Stream_End then | |
| 615 | - Add_Data (Simple_GZip_Header); | |
| 616 | - | |
| 617 | - Translate_Auto | |
| 618 | - (Filter => Filter, | |
| 619 | - In_Data => In_Data, | |
| 620 | - In_Last => In_Last, | |
| 621 | - Out_Data => Out_Data (Out_First .. Out_Data'Last), | |
| 622 | - Out_Last => Out_Last, | |
| 623 | - Flush => Flush); | |
| 624 | - | |
| 625 | - CRC32 (Filter.CRC, In_Data (In_Data'First .. In_Last)); | |
| 626 | - end if; | |
| 627 | - | |
| 628 | - if Filter.Stream_End and then Out_Last <= Out_Data'Last then | |
| 629 | - -- This detection method would work only when | |
| 630 | - -- Simple_GZip_Header'Last > Footer_Array'Last | |
| 631 | - | |
| 632 | - if Filter.Offset = Simple_GZip_Header'Last + 1 then | |
| 633 | - Filter.Offset := Footer_Array'First; | |
| 634 | - end if; | |
| 635 | - | |
| 636 | - declare | |
| 637 | - Footer : Footer_Array; | |
| 638 | - begin | |
| 639 | - Put_32 (Footer, Filter.CRC); | |
| 640 | - Put_32 (Footer (Footer'First + 4 .. Footer'Last), | |
| 641 | - Unsigned_32 (Total_In (Filter))); | |
| 642 | - Add_Data (Footer); | |
| 643 | - end; | |
| 644 | - end if; | |
| 645 | - end Translate_GZip; | |
| 646 | - | |
| 647 | - ------------- | |
| 648 | - -- Version -- | |
| 649 | - ------------- | |
| 650 | - | |
| 651 | - function Version return String is | |
| 652 | - begin | |
| 653 | - return Interfaces.C.Strings.Value (Thin.zlibVersion); | |
| 654 | - end Version; | |
| 655 | - | |
| 656 | - ----------- | |
| 657 | - -- Write -- | |
| 658 | - ----------- | |
| 659 | - | |
| 660 | - procedure Write | |
| 661 | - (Filter : in out Filter_Type; | |
| 662 | - Item : in Ada.Streams.Stream_Element_Array; | |
| 663 | - Flush : in Flush_Mode := No_Flush) | |
| 664 | - is | |
| 665 | - Buffer : Stream_Element_Array (1 .. Buffer_Size); | |
| 666 | - In_Last : Stream_Element_Offset; | |
| 667 | - Out_Last : Stream_Element_Offset; | |
| 668 | - In_First : Stream_Element_Offset := Item'First; | |
| 669 | - begin | |
| 670 | - if Item'Length = 0 and Flush = No_Flush then | |
| 671 | - return; | |
| 672 | - end if; | |
| 673 | - | |
| 674 | - loop | |
| 675 | - Translate | |
| 676 | - (Filter => Filter, | |
| 677 | - In_Data => Item (In_First .. Item'Last), | |
| 678 | - In_Last => In_Last, | |
| 679 | - Out_Data => Buffer, | |
| 680 | - Out_Last => Out_Last, | |
| 681 | - Flush => Flush); | |
| 682 | - | |
| 683 | - if Out_Last >= Buffer'First then | |
| 684 | - Write (Buffer (1 .. Out_Last)); | |
| 685 | - end if; | |
| 686 | - | |
| 687 | - exit when In_Last = Item'Last or Stream_End (Filter); | |
| 688 | - | |
| 689 | - In_First := In_Last + 1; | |
| 690 | - end loop; | |
| 691 | - end Write; | |
| 692 | - | |
| 693 | -end ZLib; |
| --- a/compat/zlib/contrib/ada/zlib.adb | |
| +++ b/compat/zlib/contrib/ada/zlib.adb | |
| @@ -1,701 +0,0 @@ | |
| ----------------------------------------------------------------- | |
| --- ZLib for Ada thick binding. -- | |
| --- -- | |
| --- Copyright (C) 2002-2004 Dmitriy Anisimkov -- | |
| --- -- | |
| --- Open source license information is in the zlib.ads file. -- | |
| ----------------------------------------------------------------- | |
| 1 | |
| --- $Id: zlib.adb,v 1.31 2004/09/06 06:53:19 vagul Exp $ | |
| 2 | |
| 3 | with Ada.Exceptions; |
| 4 | with Ada.Unchecked_Conversion; |
| 5 | with Ada.Unchecked_Deallocation; |
| 6 | |
| 7 | with Interfaces.C.Strings; |
| 8 | |
| 9 | with ZLib.Thin; |
| 10 | |
| 11 | package body ZLib is |
| 12 | |
| 13 | use type Thin.Int; |
| 14 | |
| 15 | type Z_Stream is new Thin.Z_Stream; |
| 16 | |
| 17 | type Return_Code_Enum is |
| 18 | (OK, |
| 19 | STREAM_END, |
| 20 | NEED_DICT, |
| 21 | ERRNO, |
| 22 | STREAM_ERROR, |
| 23 | DATA_ERROR, |
| 24 | MEM_ERROR, |
| 25 | BUF_ERROR, |
| 26 | VERSION_ERROR); |
| 27 | |
| 28 | type Flate_Step_Function is access |
| 29 | function (Strm : in Thin.Z_Streamp; Flush : in Thin.Int) return Thin.Int; |
| 30 | pragma Convention (C, Flate_Step_Function); |
| 31 | |
| 32 | type Flate_End_Function is access |
| 33 | function (Ctrm : in Thin.Z_Streamp) return Thin.Int; |
| 34 | pragma Convention (C, Flate_End_Function); |
| 35 | |
| 36 | type Flate_Type is record |
| 37 | Step : Flate_Step_Function; |
| 38 | Done : Flate_End_Function; |
| 39 | end record; |
| 40 | |
| 41 | subtype Footer_Array is Stream_Element_Array (1 .. 8); |
| 42 | |
| 43 | Simple_GZip_Header : constant Stream_Element_Array (1 .. 10) |
| 44 | := (16#1f#, 16#8b#, -- Magic header |
| 45 | 16#08#, -- Z_DEFLATED |
| 46 | 16#00#, -- Flags |
| 47 | 16#00#, 16#00#, 16#00#, 16#00#, -- Time |
| 48 | 16#00#, -- XFlags |
| 49 | 16#03# -- OS code |
| 50 | ); |
| 51 | -- The simplest gzip header is not for informational, but just for |
| 52 | -- gzip format compatibility. |
| 53 | -- Note that some code below is using assumption |
| 54 | -- Simple_GZip_Header'Last > Footer_Array'Last, so do not make |
| 55 | -- Simple_GZip_Header'Last <= Footer_Array'Last. |
| 56 | |
| 57 | Return_Code : constant array (Thin.Int range <>) of Return_Code_Enum |
| 58 | := (0 => OK, |
| 59 | 1 => STREAM_END, |
| 60 | 2 => NEED_DICT, |
| 61 | -1 => ERRNO, |
| 62 | -2 => STREAM_ERROR, |
| 63 | -3 => DATA_ERROR, |
| 64 | -4 => MEM_ERROR, |
| 65 | -5 => BUF_ERROR, |
| 66 | -6 => VERSION_ERROR); |
| 67 | |
| 68 | Flate : constant array (Boolean) of Flate_Type |
| 69 | := (True => (Step => Thin.Deflate'Access, |
| 70 | Done => Thin.DeflateEnd'Access), |
| 71 | False => (Step => Thin.Inflate'Access, |
| 72 | Done => Thin.InflateEnd'Access)); |
| 73 | |
| 74 | Flush_Finish : constant array (Boolean) of Flush_Mode |
| 75 | := (True => Finish, False => No_Flush); |
| 76 | |
| 77 | procedure Raise_Error (Stream : in Z_Stream); |
| 78 | pragma Inline (Raise_Error); |
| 79 | |
| 80 | procedure Raise_Error (Message : in String); |
| 81 | pragma Inline (Raise_Error); |
| 82 | |
| 83 | procedure Check_Error (Stream : in Z_Stream; Code : in Thin.Int); |
| 84 | |
| 85 | procedure Free is new Ada.Unchecked_Deallocation |
| 86 | (Z_Stream, Z_Stream_Access); |
| 87 | |
| 88 | function To_Thin_Access is new Ada.Unchecked_Conversion |
| 89 | (Z_Stream_Access, Thin.Z_Streamp); |
| 90 | |
| 91 | procedure Translate_GZip |
| 92 | (Filter : in out Filter_Type; |
| 93 | In_Data : in Ada.Streams.Stream_Element_Array; |
| 94 | In_Last : out Ada.Streams.Stream_Element_Offset; |
| 95 | Out_Data : out Ada.Streams.Stream_Element_Array; |
| 96 | Out_Last : out Ada.Streams.Stream_Element_Offset; |
| 97 | Flush : in Flush_Mode); |
| 98 | -- Separate translate routine for make gzip header. |
| 99 | |
| 100 | procedure Translate_Auto |
| 101 | (Filter : in out Filter_Type; |
| 102 | In_Data : in Ada.Streams.Stream_Element_Array; |
| 103 | In_Last : out Ada.Streams.Stream_Element_Offset; |
| 104 | Out_Data : out Ada.Streams.Stream_Element_Array; |
| 105 | Out_Last : out Ada.Streams.Stream_Element_Offset; |
| 106 | Flush : in Flush_Mode); |
| 107 | -- translate routine without additional headers. |
| 108 | |
| 109 | ----------------- |
| 110 | -- Check_Error -- |
| 111 | ----------------- |
| 112 | |
| 113 | procedure Check_Error (Stream : in Z_Stream; Code : in Thin.Int) is |
| 114 | use type Thin.Int; |
| 115 | begin |
| 116 | if Code /= Thin.Z_OK then |
| 117 | Raise_Error |
| 118 | (Return_Code_Enum'Image (Return_Code (Code)) |
| 119 | & ": " & Last_Error_Message (Stream)); |
| 120 | end if; |
| 121 | end Check_Error; |
| 122 | |
| 123 | ----------- |
| 124 | -- Close -- |
| 125 | ----------- |
| 126 | |
| 127 | procedure Close |
| 128 | (Filter : in out Filter_Type; |
| 129 | Ignore_Error : in Boolean := False) |
| 130 | is |
| 131 | Code : Thin.Int; |
| 132 | begin |
| 133 | if not Ignore_Error and then not Is_Open (Filter) then |
| 134 | raise Status_Error; |
| 135 | end if; |
| 136 | |
| 137 | Code := Flate (Filter.Compression).Done (To_Thin_Access (Filter.Strm)); |
| 138 | |
| 139 | if Ignore_Error or else Code = Thin.Z_OK then |
| 140 | Free (Filter.Strm); |
| 141 | else |
| 142 | declare |
| 143 | Error_Message : constant String |
| 144 | := Last_Error_Message (Filter.Strm.all); |
| 145 | begin |
| 146 | Free (Filter.Strm); |
| 147 | Ada.Exceptions.Raise_Exception |
| 148 | (ZLib_Error'Identity, |
| 149 | Return_Code_Enum'Image (Return_Code (Code)) |
| 150 | & ": " & Error_Message); |
| 151 | end; |
| 152 | end if; |
| 153 | end Close; |
| 154 | |
| 155 | ----------- |
| 156 | -- CRC32 -- |
| 157 | ----------- |
| 158 | |
| 159 | function CRC32 |
| 160 | (CRC : in Unsigned_32; |
| 161 | Data : in Ada.Streams.Stream_Element_Array) |
| 162 | return Unsigned_32 |
| 163 | is |
| 164 | use Thin; |
| 165 | begin |
| 166 | return Unsigned_32 (crc32 (ULong (CRC), |
| 167 | Data'Address, |
| 168 | Data'Length)); |
| 169 | end CRC32; |
| 170 | |
| 171 | procedure CRC32 |
| 172 | (CRC : in out Unsigned_32; |
| 173 | Data : in Ada.Streams.Stream_Element_Array) is |
| 174 | begin |
| 175 | CRC := CRC32 (CRC, Data); |
| 176 | end CRC32; |
| 177 | |
| 178 | ------------------ |
| 179 | -- Deflate_Init -- |
| 180 | ------------------ |
| 181 | |
| 182 | procedure Deflate_Init |
| 183 | (Filter : in out Filter_Type; |
| 184 | Level : in Compression_Level := Default_Compression; |
| 185 | Strategy : in Strategy_Type := Default_Strategy; |
| 186 | Method : in Compression_Method := Deflated; |
| 187 | Window_Bits : in Window_Bits_Type := Default_Window_Bits; |
| 188 | Memory_Level : in Memory_Level_Type := Default_Memory_Level; |
| 189 | Header : in Header_Type := Default) |
| 190 | is |
| 191 | use type Thin.Int; |
| 192 | Win_Bits : Thin.Int := Thin.Int (Window_Bits); |
| 193 | begin |
| 194 | if Is_Open (Filter) then |
| 195 | raise Status_Error; |
| 196 | end if; |
| 197 | |
| 198 | -- We allow ZLib to make header only in case of default header type. |
| 199 | -- Otherwise we would either do header by ourselfs, or do not do |
| 200 | -- header at all. |
| 201 | |
| 202 | if Header = None or else Header = GZip then |
| 203 | Win_Bits := -Win_Bits; |
| 204 | end if; |
| 205 | |
| 206 | -- For the GZip CRC calculation and make headers. |
| 207 | |
| 208 | if Header = GZip then |
| 209 | Filter.CRC := 0; |
| 210 | Filter.Offset := Simple_GZip_Header'First; |
| 211 | else |
| 212 | Filter.Offset := Simple_GZip_Header'Last + 1; |
| 213 | end if; |
| 214 | |
| 215 | Filter.Strm := new Z_Stream; |
| 216 | Filter.Compression := True; |
| 217 | Filter.Stream_End := False; |
| 218 | Filter.Header := Header; |
| 219 | |
| 220 | if Thin.Deflate_Init |
| 221 | (To_Thin_Access (Filter.Strm), |
| 222 | Level => Thin.Int (Level), |
| 223 | method => Thin.Int (Method), |
| 224 | windowBits => Win_Bits, |
| 225 | memLevel => Thin.Int (Memory_Level), |
| 226 | strategy => Thin.Int (Strategy)) /= Thin.Z_OK |
| 227 | then |
| 228 | Raise_Error (Filter.Strm.all); |
| 229 | end if; |
| 230 | end Deflate_Init; |
| 231 | |
| 232 | ----------- |
| 233 | -- Flush -- |
| 234 | ----------- |
| 235 | |
| 236 | procedure Flush |
| 237 | (Filter : in out Filter_Type; |
| 238 | Out_Data : out Ada.Streams.Stream_Element_Array; |
| 239 | Out_Last : out Ada.Streams.Stream_Element_Offset; |
| 240 | Flush : in Flush_Mode) |
| 241 | is |
| 242 | No_Data : Stream_Element_Array := (1 .. 0 => 0); |
| 243 | Last : Stream_Element_Offset; |
| 244 | begin |
| 245 | Translate (Filter, No_Data, Last, Out_Data, Out_Last, Flush); |
| 246 | end Flush; |
| 247 | |
| 248 | ----------------------- |
| 249 | -- Generic_Translate -- |
| 250 | ----------------------- |
| 251 | |
| 252 | procedure Generic_Translate |
| 253 | (Filter : in out ZLib.Filter_Type; |
| 254 | In_Buffer_Size : in Integer := Default_Buffer_Size; |
| 255 | Out_Buffer_Size : in Integer := Default_Buffer_Size) |
| 256 | is |
| 257 | In_Buffer : Stream_Element_Array |
| 258 | (1 .. Stream_Element_Offset (In_Buffer_Size)); |
| 259 | Out_Buffer : Stream_Element_Array |
| 260 | (1 .. Stream_Element_Offset (Out_Buffer_Size)); |
| 261 | Last : Stream_Element_Offset; |
| 262 | In_Last : Stream_Element_Offset; |
| 263 | In_First : Stream_Element_Offset; |
| 264 | Out_Last : Stream_Element_Offset; |
| 265 | begin |
| 266 | Main : loop |
| 267 | Data_In (In_Buffer, Last); |
| 268 | |
| 269 | In_First := In_Buffer'First; |
| 270 | |
| 271 | loop |
| 272 | Translate |
| 273 | (Filter => Filter, |
| 274 | In_Data => In_Buffer (In_First .. Last), |
| 275 | In_Last => In_Last, |
| 276 | Out_Data => Out_Buffer, |
| 277 | Out_Last => Out_Last, |
| 278 | Flush => Flush_Finish (Last < In_Buffer'First)); |
| 279 | |
| 280 | if Out_Buffer'First <= Out_Last then |
| 281 | Data_Out (Out_Buffer (Out_Buffer'First .. Out_Last)); |
| 282 | end if; |
| 283 | |
| 284 | exit Main when Stream_End (Filter); |
| 285 | |
| 286 | -- The end of in buffer. |
| 287 | |
| 288 | exit when In_Last = Last; |
| 289 | |
| 290 | In_First := In_Last + 1; |
| 291 | end loop; |
| 292 | end loop Main; |
| 293 | |
| 294 | end Generic_Translate; |
| 295 | |
| 296 | ------------------ |
| 297 | -- Inflate_Init -- |
| 298 | ------------------ |
| 299 | |
| 300 | procedure Inflate_Init |
| 301 | (Filter : in out Filter_Type; |
| 302 | Window_Bits : in Window_Bits_Type := Default_Window_Bits; |
| 303 | Header : in Header_Type := Default) |
| 304 | is |
| 305 | use type Thin.Int; |
| 306 | Win_Bits : Thin.Int := Thin.Int (Window_Bits); |
| 307 | |
| 308 | procedure Check_Version; |
| 309 | -- Check the latest header types compatibility. |
| 310 | |
| 311 | procedure Check_Version is |
| 312 | begin |
| 313 | if Version <= "1.1.4" then |
| 314 | Raise_Error |
| 315 | ("Inflate header type " & Header_Type'Image (Header) |
| 316 | & " incompatible with ZLib version " & Version); |
| 317 | end if; |
| 318 | end Check_Version; |
| 319 | |
| 320 | begin |
| 321 | if Is_Open (Filter) then |
| 322 | raise Status_Error; |
| 323 | end if; |
| 324 | |
| 325 | case Header is |
| 326 | when None => |
| 327 | Check_Version; |
| 328 | |
| 329 | -- Inflate data without headers determined |
| 330 | -- by negative Win_Bits. |
| 331 | |
| 332 | Win_Bits := -Win_Bits; |
| 333 | when GZip => |
| 334 | Check_Version; |
| 335 | |
| 336 | -- Inflate gzip data defined by flag 16. |
| 337 | |
| 338 | Win_Bits := Win_Bits + 16; |
| 339 | when Auto => |
| 340 | Check_Version; |
| 341 | |
| 342 | -- Inflate with automatic detection |
| 343 | -- of gzip or native header defined by flag 32. |
| 344 | |
| 345 | Win_Bits := Win_Bits + 32; |
| 346 | when Default => null; |
| 347 | end case; |
| 348 | |
| 349 | Filter.Strm := new Z_Stream; |
| 350 | Filter.Compression := False; |
| 351 | Filter.Stream_End := False; |
| 352 | Filter.Header := Header; |
| 353 | |
| 354 | if Thin.Inflate_Init |
| 355 | (To_Thin_Access (Filter.Strm), Win_Bits) /= Thin.Z_OK |
| 356 | then |
| 357 | Raise_Error (Filter.Strm.all); |
| 358 | end if; |
| 359 | end Inflate_Init; |
| 360 | |
| 361 | ------------- |
| 362 | -- Is_Open -- |
| 363 | ------------- |
| 364 | |
| 365 | function Is_Open (Filter : in Filter_Type) return Boolean is |
| 366 | begin |
| 367 | return Filter.Strm /= null; |
| 368 | end Is_Open; |
| 369 | |
| 370 | ----------------- |
| 371 | -- Raise_Error -- |
| 372 | ----------------- |
| 373 | |
| 374 | procedure Raise_Error (Message : in String) is |
| 375 | begin |
| 376 | Ada.Exceptions.Raise_Exception (ZLib_Error'Identity, Message); |
| 377 | end Raise_Error; |
| 378 | |
| 379 | procedure Raise_Error (Stream : in Z_Stream) is |
| 380 | begin |
| 381 | Raise_Error (Last_Error_Message (Stream)); |
| 382 | end Raise_Error; |
| 383 | |
| 384 | ---------- |
| 385 | -- Read -- |
| 386 | ---------- |
| 387 | |
| 388 | procedure Read |
| 389 | (Filter : in out Filter_Type; |
| 390 | Item : out Ada.Streams.Stream_Element_Array; |
| 391 | Last : out Ada.Streams.Stream_Element_Offset; |
| 392 | Flush : in Flush_Mode := No_Flush) |
| 393 | is |
| 394 | In_Last : Stream_Element_Offset; |
| 395 | Item_First : Ada.Streams.Stream_Element_Offset := Item'First; |
| 396 | V_Flush : Flush_Mode := Flush; |
| 397 | |
| 398 | begin |
| 399 | pragma Assert (Rest_First in Buffer'First .. Buffer'Last + 1); |
| 400 | pragma Assert (Rest_Last in Buffer'First - 1 .. Buffer'Last); |
| 401 | |
| 402 | loop |
| 403 | if Rest_Last = Buffer'First - 1 then |
| 404 | V_Flush := Finish; |
| 405 | |
| 406 | elsif Rest_First > Rest_Last then |
| 407 | Read (Buffer, Rest_Last); |
| 408 | Rest_First := Buffer'First; |
| 409 | |
| 410 | if Rest_Last < Buffer'First then |
| 411 | V_Flush := Finish; |
| 412 | end if; |
| 413 | end if; |
| 414 | |
| 415 | Translate |
| 416 | (Filter => Filter, |
| 417 | In_Data => Buffer (Rest_First .. Rest_Last), |
| 418 | In_Last => In_Last, |
| 419 | Out_Data => Item (Item_First .. Item'Last), |
| 420 | Out_Last => Last, |
| 421 | Flush => V_Flush); |
| 422 | |
| 423 | Rest_First := In_Last + 1; |
| 424 | |
| 425 | exit when Stream_End (Filter) |
| 426 | or else Last = Item'Last |
| 427 | or else (Last >= Item'First and then Allow_Read_Some); |
| 428 | |
| 429 | Item_First := Last + 1; |
| 430 | end loop; |
| 431 | end Read; |
| 432 | |
| 433 | ---------------- |
| 434 | -- Stream_End -- |
| 435 | ---------------- |
| 436 | |
| 437 | function Stream_End (Filter : in Filter_Type) return Boolean is |
| 438 | begin |
| 439 | if Filter.Header = GZip and Filter.Compression then |
| 440 | return Filter.Stream_End |
| 441 | and then Filter.Offset = Footer_Array'Last + 1; |
| 442 | else |
| 443 | return Filter.Stream_End; |
| 444 | end if; |
| 445 | end Stream_End; |
| 446 | |
| 447 | -------------- |
| 448 | -- Total_In -- |
| 449 | -------------- |
| 450 | |
| 451 | function Total_In (Filter : in Filter_Type) return Count is |
| 452 | begin |
| 453 | return Count (Thin.Total_In (To_Thin_Access (Filter.Strm).all)); |
| 454 | end Total_In; |
| 455 | |
| 456 | --------------- |
| 457 | -- Total_Out -- |
| 458 | --------------- |
| 459 | |
| 460 | function Total_Out (Filter : in Filter_Type) return Count is |
| 461 | begin |
| 462 | return Count (Thin.Total_Out (To_Thin_Access (Filter.Strm).all)); |
| 463 | end Total_Out; |
| 464 | |
| 465 | --------------- |
| 466 | -- Translate -- |
| 467 | --------------- |
| 468 | |
| 469 | procedure Translate |
| 470 | (Filter : in out Filter_Type; |
| 471 | In_Data : in Ada.Streams.Stream_Element_Array; |
| 472 | In_Last : out Ada.Streams.Stream_Element_Offset; |
| 473 | Out_Data : out Ada.Streams.Stream_Element_Array; |
| 474 | Out_Last : out Ada.Streams.Stream_Element_Offset; |
| 475 | Flush : in Flush_Mode) is |
| 476 | begin |
| 477 | if Filter.Header = GZip and then Filter.Compression then |
| 478 | Translate_GZip |
| 479 | (Filter => Filter, |
| 480 | In_Data => In_Data, |
| 481 | In_Last => In_Last, |
| 482 | Out_Data => Out_Data, |
| 483 | Out_Last => Out_Last, |
| 484 | Flush => Flush); |
| 485 | else |
| 486 | Translate_Auto |
| 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 | end if; |
| 494 | end Translate; |
| 495 | |
| 496 | -------------------- |
| 497 | -- Translate_Auto -- |
| 498 | -------------------- |
| 499 | |
| 500 | procedure Translate_Auto |
| 501 | (Filter : in out Filter_Type; |
| 502 | In_Data : in Ada.Streams.Stream_Element_Array; |
| 503 | In_Last : out Ada.Streams.Stream_Element_Offset; |
| 504 | Out_Data : out Ada.Streams.Stream_Element_Array; |
| 505 | Out_Last : out Ada.Streams.Stream_Element_Offset; |
| 506 | Flush : in Flush_Mode) |
| 507 | is |
| 508 | use type Thin.Int; |
| 509 | Code : Thin.Int; |
| 510 | |
| 511 | begin |
| 512 | if not Is_Open (Filter) then |
| 513 | raise Status_Error; |
| 514 | end if; |
| 515 | |
| 516 | if Out_Data'Length = 0 and then In_Data'Length = 0 then |
| 517 | raise Constraint_Error; |
| 518 | end if; |
| 519 | |
| 520 | Set_Out (Filter.Strm.all, Out_Data'Address, Out_Data'Length); |
| 521 | Set_In (Filter.Strm.all, In_Data'Address, In_Data'Length); |
| 522 | |
| 523 | Code := Flate (Filter.Compression).Step |
| 524 | (To_Thin_Access (Filter.Strm), |
| 525 | Thin.Int (Flush)); |
| 526 | |
| 527 | if Code = Thin.Z_STREAM_END then |
| 528 | Filter.Stream_End := True; |
| 529 | else |
| 530 | Check_Error (Filter.Strm.all, Code); |
| 531 | end if; |
| 532 | |
| 533 | In_Last := In_Data'Last |
| 534 | - Stream_Element_Offset (Avail_In (Filter.Strm.all)); |
| 535 | Out_Last := Out_Data'Last |
| 536 | - Stream_Element_Offset (Avail_Out (Filter.Strm.all)); |
| 537 | end Translate_Auto; |
| 538 | |
| 539 | -------------------- |
| 540 | -- Translate_GZip -- |
| 541 | -------------------- |
| 542 | |
| 543 | procedure Translate_GZip |
| 544 | (Filter : in out Filter_Type; |
| 545 | In_Data : in Ada.Streams.Stream_Element_Array; |
| 546 | In_Last : out Ada.Streams.Stream_Element_Offset; |
| 547 | Out_Data : out Ada.Streams.Stream_Element_Array; |
| 548 | Out_Last : out Ada.Streams.Stream_Element_Offset; |
| 549 | Flush : in Flush_Mode) |
| 550 | is |
| 551 | Out_First : Stream_Element_Offset; |
| 552 | |
| 553 | procedure Add_Data (Data : in Stream_Element_Array); |
| 554 | -- Add data to stream from the Filter.Offset till necessary, |
| 555 | -- used for add gzip headr/footer. |
| 556 | |
| 557 | procedure Put_32 |
| 558 | (Item : in out Stream_Element_Array; |
| 559 | Data : in Unsigned_32); |
| 560 | pragma Inline (Put_32); |
| 561 | |
| 562 | -------------- |
| 563 | -- Add_Data -- |
| 564 | -------------- |
| 565 | |
| 566 | procedure Add_Data (Data : in Stream_Element_Array) is |
| 567 | Data_First : Stream_Element_Offset renames Filter.Offset; |
| 568 | Data_Last : Stream_Element_Offset; |
| 569 | Data_Len : Stream_Element_Offset; -- -1 |
| 570 | Out_Len : Stream_Element_Offset; -- -1 |
| 571 | begin |
| 572 | Out_First := Out_Last + 1; |
| 573 | |
| 574 | if Data_First > Data'Last then |
| 575 | return; |
| 576 | end if; |
| 577 | |
| 578 | Data_Len := Data'Last - Data_First; |
| 579 | Out_Len := Out_Data'Last - Out_First; |
| 580 | |
| 581 | if Data_Len <= Out_Len then |
| 582 | Out_Last := Out_First + Data_Len; |
| 583 | Data_Last := Data'Last; |
| 584 | else |
| 585 | Out_Last := Out_Data'Last; |
| 586 | Data_Last := Data_First + Out_Len; |
| 587 | end if; |
| 588 | |
| 589 | Out_Data (Out_First .. Out_Last) := Data (Data_First .. Data_Last); |
| 590 | |
| 591 | Data_First := Data_Last + 1; |
| 592 | Out_First := Out_Last + 1; |
| 593 | end Add_Data; |
| 594 | |
| 595 | ------------ |
| 596 | -- Put_32 -- |
| 597 | ------------ |
| 598 | |
| 599 | procedure Put_32 |
| 600 | (Item : in out Stream_Element_Array; |
| 601 | Data : in Unsigned_32) |
| 602 | is |
| 603 | D : Unsigned_32 := Data; |
| 604 | begin |
| 605 | for J in Item'First .. Item'First + 3 loop |
| 606 | Item (J) := Stream_Element (D and 16#FF#); |
| 607 | D := Shift_Right (D, 8); |
| 608 | end loop; |
| 609 | end Put_32; |
| 610 | |
| 611 | begin |
| 612 | Out_Last := Out_Data'First - 1; |
| 613 | |
| 614 | if not Filter.Stream_End then |
| 615 | Add_Data (Simple_GZip_Header); |
| 616 | |
| 617 | Translate_Auto |
| 618 | (Filter => Filter, |
| 619 | In_Data => In_Data, |
| 620 | In_Last => In_Last, |
| 621 | Out_Data => Out_Data (Out_First .. Out_Data'Last), |
| 622 | Out_Last => Out_Last, |
| 623 | Flush => Flush); |
| 624 | |
| 625 | CRC32 (Filter.CRC, In_Data (In_Data'First .. In_Last)); |
| 626 | end if; |
| 627 | |
| 628 | if Filter.Stream_End and then Out_Last <= Out_Data'Last then |
| 629 | -- This detection method would work only when |
| 630 | -- Simple_GZip_Header'Last > Footer_Array'Last |
| 631 | |
| 632 | if Filter.Offset = Simple_GZip_Header'Last + 1 then |
| 633 | Filter.Offset := Footer_Array'First; |
| 634 | end if; |
| 635 | |
| 636 | declare |
| 637 | Footer : Footer_Array; |
| 638 | begin |
| 639 | Put_32 (Footer, Filter.CRC); |
| 640 | Put_32 (Footer (Footer'First + 4 .. Footer'Last), |
| 641 | Unsigned_32 (Total_In (Filter))); |
| 642 | Add_Data (Footer); |
| 643 | end; |
| 644 | end if; |
| 645 | end Translate_GZip; |
| 646 | |
| 647 | ------------- |
| 648 | -- Version -- |
| 649 | ------------- |
| 650 | |
| 651 | function Version return String is |
| 652 | begin |
| 653 | return Interfaces.C.Strings.Value (Thin.zlibVersion); |
| 654 | end Version; |
| 655 | |
| 656 | ----------- |
| 657 | -- Write -- |
| 658 | ----------- |
| 659 | |
| 660 | procedure Write |
| 661 | (Filter : in out Filter_Type; |
| 662 | Item : in Ada.Streams.Stream_Element_Array; |
| 663 | Flush : in Flush_Mode := No_Flush) |
| 664 | is |
| 665 | Buffer : Stream_Element_Array (1 .. Buffer_Size); |
| 666 | In_Last : Stream_Element_Offset; |
| 667 | Out_Last : Stream_Element_Offset; |
| 668 | In_First : Stream_Element_Offset := Item'First; |
| 669 | begin |
| 670 | if Item'Length = 0 and Flush = No_Flush then |
| 671 | return; |
| 672 | end if; |
| 673 | |
| 674 | loop |
| 675 | Translate |
| 676 | (Filter => Filter, |
| 677 | In_Data => Item (In_First .. Item'Last), |
| 678 | In_Last => In_Last, |
| 679 | Out_Data => Buffer, |
| 680 | Out_Last => Out_Last, |
| 681 | Flush => Flush); |
| 682 | |
| 683 | if Out_Last >= Buffer'First then |
| 684 | Write (Buffer (1 .. Out_Last)); |
| 685 | end if; |
| 686 | |
| 687 | exit when In_Last = Item'Last or Stream_End (Filter); |
| 688 | |
| 689 | In_First := In_Last + 1; |
| 690 | end loop; |
| 691 | end Write; |
| 692 | |
| 693 | end ZLib; |
| --- a/compat/zlib/contrib/ada/zlib.adb | |
| +++ b/compat/zlib/contrib/ada/zlib.adb | |
| @@ -1,701 +0,0 @@ | |
| ----------------------------------------------------------------- | |
| --- ZLib for Ada thick binding. -- | |
| --- -- | |
| --- Copyright (C) 2002-2004 Dmitriy Anisimkov -- | |
| --- -- | |
| --- Open source license information is in the zlib.ads file. -- | |
| ----------------------------------------------------------------- | |
| --- $Id: zlib.adb,v 1.31 2004/09/06 06:53:19 vagul Exp $ | |
D
compat/zlib/contrib/ada/zlib.ads
-301
| --- a/compat/zlib/contrib/ada/zlib.ads | ||
| +++ b/compat/zlib/contrib/ada/zlib.ads | ||
| @@ -1,328 +0,0 @@ | ||
| ------------------------------------------------------------------------------- | ||
| --- ZLib for Ada thick binding. -- | ||
| --- -- | ||
| --- Copyright (C) 2002-2004 Dmitriy Anisimkov -- | ||
| --- -- | ||
| --- This library is free software; you can redistribute it and/or modify -- | ||
| --- it under the terms of the GNU General Public License as published by -- | ||
| --- the Free Software Foundation; either version 2 of the License, or (at -- | ||
| --- your option) any later version. -- | ||
| --- -- | ||
| --- This library is distributed in the hope that it will be useful, but -- | ||
| --- WITHOUT ANY WARRANTY; without even the implied warranty of -- | ||
| --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- | ||
| --- General Public License for more details. -- | ||
| --- -- | ||
| --- You should have received a copy of the GNU General Public License -- | ||
| --- along with this library; if not, write to the Free Software Foundation, -- | ||
| --- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- | ||
| --- -- | ||
| --- As a special exception, if other files instantiate generics from this -- | ||
| --- unit, or you link this unit with other files to produce an executable, -- | ||
| --- this unit does not by itself cause the resulting executable to be -- | ||
| --- covered by the GNU General Public License. This exception does not -- | ||
| --- however invalidate any other reasons why the executable file might be -- | ||
| --- covered by the GNU Public License. -- | ||
| ------------------------------------------------------------------------------- | ||
| 1 | - | |
| --- $Id: zlib.ads,v 1.26 2004/09/06 06:53:19 vagul Exp $ | ||
| 2 | - | |
| 3 | -with Ada.Streams; | |
| 4 | - | |
| 5 | -with Interfaces; | |
| 6 | - | |
| 7 | -package ZLib is | |
| 8 | - | |
| 9 | - ZLib_Error : exception; | |
| 10 | - Status_Error : exception; | |
| 11 | - | |
| 12 | - type Compression_Level is new Integer range -1 .. 9; | |
| 13 | - | |
| 14 | - type Flush_Mode is private; | |
| 15 | - | |
| 16 | - type Compression_Method is private; | |
| 17 | - | |
| 18 | - type Window_Bits_Type is new Integer range 8 .. 15; | |
| 19 | - | |
| 20 | - type Memory_Level_Type is new Integer range 1 .. 9; | |
| 21 | - | |
| 22 | - type Unsigned_32 is new Interfaces.Unsigned_32; | |
| 23 | - | |
| 24 | - type Strategy_Type is private; | |
| 25 | - | |
| 26 | - type Header_Type is (None, Auto, Default, GZip); | |
| 27 | - -- Header type usage have a some limitation for inflate. | |
| 28 | - -- See comment for Inflate_Init. | |
| 29 | - | |
| 30 | - subtype Count is Ada.Streams.Stream_Element_Count; | |
| 31 | - | |
| 32 | - Default_Memory_Level : constant Memory_Level_Type := 8; | |
| 33 | - Default_Window_Bits : constant Window_Bits_Type := 15; | |
| 34 | - | |
| 35 | - ---------------------------------- | |
| 36 | - -- Compression method constants -- | |
| 37 | - ---------------------------------- | |
| 38 | - | |
| 39 | - Deflated : constant Compression_Method; | |
| 40 | - -- Only one method allowed in this ZLib version | |
| 41 | - | |
| 42 | - --------------------------------- | |
| 43 | - -- Compression level constants -- | |
| 44 | - --------------------------------- | |
| 45 | - | |
| 46 | - No_Compression : constant Compression_Level := 0; | |
| 47 | - Best_Speed : constant Compression_Level := 1; | |
| 48 | - Best_Compression : constant Compression_Level := 9; | |
| 49 | - Default_Compression : constant Compression_Level := -1; | |
| 50 | - | |
| 51 | - -------------------------- | |
| 52 | - -- Flush mode constants -- | |
| 53 | - -------------------------- | |
| 54 | - | |
| 55 | - No_Flush : constant Flush_Mode; | |
| 56 | - -- Regular way for compression, no flush | |
| 57 | - | |
| 58 | - Partial_Flush : constant Flush_Mode; | |
| 59 | - -- Will be removed, use Z_SYNC_FLUSH instead | |
| 60 | - | |
| 61 | - Sync_Flush : constant Flush_Mode; | |
| 62 | - -- All pending output is flushed to the output buffer and the output | |
| 63 | - -- is aligned on a byte boundary, so that the decompressor can get all | |
| 64 | - -- input data available so far. (In particular avail_in is zero after the | |
| 65 | - -- call if enough output space has been provided before the call.) | |
| 66 | - -- Flushing may degrade compression for some compression algorithms and so | |
| 67 | - -- it should be used only when necessary. | |
| 68 | - | |
| 69 | - Block_Flush : constant Flush_Mode; | |
| 70 | - -- Z_BLOCK requests that inflate() stop | |
| 71 | - -- if and when it get to the next deflate block boundary. When decoding the | |
| 72 | - -- zlib or gzip format, this will cause inflate() to return immediately | |
| 73 | - -- after the header and before the first block. When doing a raw inflate, | |
| 74 | - -- inflate() will go ahead and process the first block, and will return | |
| 75 | - -- when it gets to the end of that block, or when it runs out of data. | |
| 76 | - | |
| 77 | - Full_Flush : constant Flush_Mode; | |
| 78 | - -- All output is flushed as with SYNC_FLUSH, and the compression state | |
| 79 | - -- is reset so that decompression can restart from this point if previous | |
| 80 | - -- compressed data has been damaged or if random access is desired. Using | |
| 81 | - -- Full_Flush too often can seriously degrade the compression. | |
| 82 | - | |
| 83 | - Finish : constant Flush_Mode; | |
| 84 | - -- Just for tell the compressor that input data is complete. | |
| 85 | - | |
| 86 | - ------------------------------------ | |
| 87 | - -- Compression strategy constants -- | |
| 88 | - ------------------------------------ | |
| 89 | - | |
| 90 | - -- RLE stategy could be used only in version 1.2.0 and later. | |
| 91 | - | |
| 92 | - Filtered : constant Strategy_Type; | |
| 93 | - Huffman_Only : constant Strategy_Type; | |
| 94 | - RLE : constant Strategy_Type; | |
| 95 | - Default_Strategy : constant Strategy_Type; | |
| 96 | - | |
| 97 | - Default_Buffer_Size : constant := 4096; | |
| 98 | - | |
| 99 | - type Filter_Type is tagged limited private; | |
| 100 | - -- The filter is for compression and for decompression. | |
| 101 | - -- The usage of the type is depend of its initialization. | |
| 102 | - | |
| 103 | - function Version return String; | |
| 104 | - pragma Inline (Version); | |
| 105 | - -- Return string representation of the ZLib version. | |
| 106 | - | |
| 107 | - procedure Deflate_Init | |
| 108 | - (Filter : in out Filter_Type; | |
| 109 | - Level : in Compression_Level := Default_Compression; | |
| 110 | - Strategy : in Strategy_Type := Default_Strategy; | |
| 111 | - Method : in Compression_Method := Deflated; | |
| 112 | - Window_Bits : in Window_Bits_Type := Default_Window_Bits; | |
| 113 | - Memory_Level : in Memory_Level_Type := Default_Memory_Level; | |
| 114 | - Header : in Header_Type := Default); | |
| 115 | - -- Compressor initialization. | |
| 116 | - -- When Header parameter is Auto or Default, then default zlib header | |
| 117 | - -- would be provided for compressed data. | |
| 118 | - -- When Header is GZip, then gzip header would be set instead of | |
| 119 | - -- default header. | |
| 120 | - -- When Header is None, no header would be set for compressed data. | |
| 121 | - | |
| 122 | - procedure Inflate_Init | |
| 123 | - (Filter : in out Filter_Type; | |
| 124 | - Window_Bits : in Window_Bits_Type := Default_Window_Bits; | |
| 125 | - Header : in Header_Type := Default); | |
| 126 | - -- Decompressor initialization. | |
| 127 | - -- Default header type mean that ZLib default header is expecting in the | |
| 128 | - -- input compressed stream. | |
| 129 | - -- Header type None mean that no header is expecting in the input stream. | |
| 130 | - -- GZip header type mean that GZip header is expecting in the | |
| 131 | - -- input compressed stream. | |
| 132 | - -- Auto header type mean that header type (GZip or Native) would be | |
| 133 | - -- detected automatically in the input stream. | |
| 134 | - -- Note that header types parameter values None, GZip and Auto are | |
| 135 | - -- supported for inflate routine only in ZLib versions 1.2.0.2 and later. | |
| 136 | - -- Deflate_Init is supporting all header types. | |
| 137 | - | |
| 138 | - function Is_Open (Filter : in Filter_Type) return Boolean; | |
| 139 | - pragma Inline (Is_Open); | |
| 140 | - -- Is the filter opened for compression or decompression. | |
| 141 | - | |
| 142 | - procedure Close | |
| 143 | - (Filter : in out Filter_Type; | |
| 144 | - Ignore_Error : in Boolean := False); | |
| 145 | - -- Closing the compression or decompressor. | |
| 146 | - -- If stream is closing before the complete and Ignore_Error is False, | |
| 147 | - -- The exception would be raised. | |
| 148 | - | |
| 149 | - generic | |
| 150 | - with procedure Data_In | |
| 151 | - (Item : out Ada.Streams.Stream_Element_Array; | |
| 152 | - Last : out Ada.Streams.Stream_Element_Offset); | |
| 153 | - with procedure Data_Out | |
| 154 | - (Item : in Ada.Streams.Stream_Element_Array); | |
| 155 | - procedure Generic_Translate | |
| 156 | - (Filter : in out Filter_Type; | |
| 157 | - In_Buffer_Size : in Integer := Default_Buffer_Size; | |
| 158 | - Out_Buffer_Size : in Integer := Default_Buffer_Size); | |
| 159 | - -- Compress/decompress data fetch from Data_In routine and pass the result | |
| 160 | - -- to the Data_Out routine. User should provide Data_In and Data_Out | |
| 161 | - -- for compression/decompression data flow. | |
| 162 | - -- Compression or decompression depend on Filter initialization. | |
| 163 | - | |
| 164 | - function Total_In (Filter : in Filter_Type) return Count; | |
| 165 | - pragma Inline (Total_In); | |
| 166 | - -- Returns total number of input bytes read so far | |
| 167 | - | |
| 168 | - function Total_Out (Filter : in Filter_Type) return Count; | |
| 169 | - pragma Inline (Total_Out); | |
| 170 | - -- Returns total number of bytes output so far | |
| 171 | - | |
| 172 | - function CRC32 | |
| 173 | - (CRC : in Unsigned_32; | |
| 174 | - Data : in Ada.Streams.Stream_Element_Array) | |
| 175 | - return Unsigned_32; | |
| 176 | - pragma Inline (CRC32); | |
| 177 | - -- Compute CRC32, it could be necessary for make gzip format | |
| 178 | - | |
| 179 | - procedure CRC32 | |
| 180 | - (CRC : in out Unsigned_32; | |
| 181 | - Data : in Ada.Streams.Stream_Element_Array); | |
| 182 | - pragma Inline (CRC32); | |
| 183 | - -- Compute CRC32, it could be necessary for make gzip format | |
| 184 | - | |
| 185 | - ------------------------------------------------- | |
| 186 | - -- Below is more complex low level routines. -- | |
| 187 | - ------------------------------------------------- | |
| 188 | - | |
| 189 | - procedure Translate | |
| 190 | - (Filter : in out Filter_Type; | |
| 191 | - In_Data : in Ada.Streams.Stream_Element_Array; | |
| 192 | - In_Last : out Ada.Streams.Stream_Element_Offset; | |
| 193 | - Out_Data : out Ada.Streams.Stream_Element_Array; | |
| 194 | - Out_Last : out Ada.Streams.Stream_Element_Offset; | |
| 195 | - Flush : in Flush_Mode); | |
| 196 | - -- Compress/decompress the In_Data buffer and place the result into | |
| 197 | - -- Out_Data. In_Last is the index of last element from In_Data accepted by | |
| 198 | - -- the Filter. Out_Last is the last element of the received data from | |
| 199 | - -- Filter. To tell the filter that incoming data are complete put the | |
| 200 | - -- Flush parameter to Finish. | |
| 201 | - | |
| 202 | - function Stream_End (Filter : in Filter_Type) return Boolean; | |
| 203 | - pragma Inline (Stream_End); | |
| 204 | - -- Return the true when the stream is complete. | |
| 205 | - | |
| 206 | - procedure Flush | |
| 207 | - (Filter : in out Filter_Type; | |
| 208 | - Out_Data : out Ada.Streams.Stream_Element_Array; | |
| 209 | - Out_Last : out Ada.Streams.Stream_Element_Offset; | |
| 210 | - Flush : in Flush_Mode); | |
| 211 | - pragma Inline (Flush); | |
| 212 | - -- Flushing the data from the compressor. | |
| 213 | - | |
| 214 | - generic | |
| 215 | - with procedure Write | |
| 216 | - (Item : in Ada.Streams.Stream_Element_Array); | |
| 217 | - -- User should provide this routine for accept | |
| 218 | - -- compressed/decompressed data. | |
| 219 | - | |
| 220 | - Buffer_Size : in Ada.Streams.Stream_Element_Offset | |
| 221 | - := Default_Buffer_Size; | |
| 222 | - -- Buffer size for Write user routine. | |
| 223 | - | |
| 224 | - procedure Write | |
| 225 | - (Filter : in out Filter_Type; | |
| 226 | - Item : in Ada.Streams.Stream_Element_Array; | |
| 227 | - Flush : in Flush_Mode := No_Flush); | |
| 228 | - -- Compress/Decompress data from Item to the generic parameter procedure | |
| 229 | - -- Write. Output buffer size could be set in Buffer_Size generic parameter. | |
| 230 | - | |
| 231 | - generic | |
| 232 | - with procedure Read | |
| 233 | - (Item : out Ada.Streams.Stream_Element_Array; | |
| 234 | - Last : out Ada.Streams.Stream_Element_Offset); | |
| 235 | - -- User should provide data for compression/decompression | |
| 236 | - -- thru this routine. | |
| 237 | - | |
| 238 | - Buffer : in out Ada.Streams.Stream_Element_Array; | |
| 239 | - -- Buffer for keep remaining data from the previous | |
| 240 | - -- back read. | |
| 241 | - | |
| 242 | - Rest_First, Rest_Last : in out Ada.Streams.Stream_Element_Offset; | |
| 243 | - -- Rest_First have to be initialized to Buffer'Last + 1 | |
| 244 | - -- Rest_Last have to be initialized to Buffer'Last | |
| 245 | - -- before usage. | |
| 246 | - | |
| 247 | - Allow_Read_Some : in Boolean := False; | |
| 248 | - -- Is it allowed to return Last < Item'Last before end of data. | |
| 249 | - | |
| 250 | - procedure Read | |
| 251 | - (Filter : in out Filter_Type; | |
| 252 | - Item : out Ada.Streams.Stream_Element_Array; | |
| 253 | - Last : out Ada.Streams.Stream_Element_Offset; | |
| 254 | - Flush : in Flush_Mode := No_Flush); | |
| 255 | - -- Compress/Decompress data from generic parameter procedure Read to the | |
| 256 | - -- Item. User should provide Buffer and initialized Rest_First, Rest_Last | |
| 257 | - -- indicators. If Allow_Read_Some is True, Read routines could return | |
| 258 | - -- Last < Item'Last only at end of stream. | |
| 259 | - | |
| 260 | -private | |
| 261 | - | |
| 262 | - use Ada.Streams; | |
| 263 | - | |
| 264 | - pragma Assert (Ada.Streams.Stream_Element'Size = 8); | |
| 265 | - pragma Assert (Ada.Streams.Stream_Element'Modulus = 2**8); | |
| 266 | - | |
| 267 | - type Flush_Mode is new Integer range 0 .. 5; | |
| 268 | - | |
| 269 | - type Compression_Method is new Integer range 8 .. 8; | |
| 270 | - | |
| 271 | - type Strategy_Type is new Integer range 0 .. 3; | |
| 272 | - | |
| 273 | - No_Flush : constant Flush_Mode := 0; | |
| 274 | - Partial_Flush : constant Flush_Mode := 1; | |
| 275 | - Sync_Flush : constant Flush_Mode := 2; | |
| 276 | - Full_Flush : constant Flush_Mode := 3; | |
| 277 | - Finish : constant Flush_Mode := 4; | |
| 278 | - Block_Flush : constant Flush_Mode := 5; | |
| 279 | - | |
| 280 | - Filtered : constant Strategy_Type := 1; | |
| 281 | - Huffman_Only : constant Strategy_Type := 2; | |
| 282 | - RLE : constant Strategy_Type := 3; | |
| 283 | - Default_Strategy : constant Strategy_Type := 0; | |
| 284 | - | |
| 285 | - Deflated : constant Compression_Method := 8; | |
| 286 | - | |
| 287 | - type Z_Stream; | |
| 288 | - | |
| 289 | - type Z_Stream_Access is access all Z_Stream; | |
| 290 | - | |
| 291 | - type Filter_Type is tagged limited record | |
| 292 | - Strm : Z_Stream_Access; | |
| 293 | - Compression : Boolean; | |
| 294 | - Stream_End : Boolean; | |
| 295 | - Header : Header_Type; | |
| 296 | - CRC : Unsigned_32; | |
| 297 | - Offset : Stream_Element_Offset; | |
| 298 | - -- Offset for gzip header/footer output. | |
| 299 | - end record; | |
| 300 | - | |
| 301 | -end ZLib; |
| --- a/compat/zlib/contrib/ada/zlib.ads | |
| +++ b/compat/zlib/contrib/ada/zlib.ads | |
| @@ -1,328 +0,0 @@ | |
| ------------------------------------------------------------------------------- | |
| --- ZLib for Ada thick binding. -- | |
| --- -- | |
| --- Copyright (C) 2002-2004 Dmitriy Anisimkov -- | |
| --- -- | |
| --- This library is free software; you can redistribute it and/or modify -- | |
| --- it under the terms of the GNU General Public License as published by -- | |
| --- the Free Software Foundation; either version 2 of the License, or (at -- | |
| --- your option) any later version. -- | |
| --- -- | |
| --- This library is distributed in the hope that it will be useful, but -- | |
| --- WITHOUT ANY WARRANTY; without even the implied warranty of -- | |
| --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- | |
| --- General Public License for more details. -- | |
| --- -- | |
| --- You should have received a copy of the GNU General Public License -- | |
| --- along with this library; if not, write to the Free Software Foundation, -- | |
| --- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- | |
| --- -- | |
| --- As a special exception, if other files instantiate generics from this -- | |
| --- unit, or you link this unit with other files to produce an executable, -- | |
| --- this unit does not by itself cause the resulting executable to be -- | |
| --- covered by the GNU General Public License. This exception does not -- | |
| --- however invalidate any other reasons why the executable file might be -- | |
| --- covered by the GNU Public License. -- | |
| ------------------------------------------------------------------------------- | |
| 1 | |
| --- $Id: zlib.ads,v 1.26 2004/09/06 06:53:19 vagul Exp $ | |
| 2 | |
| 3 | with Ada.Streams; |
| 4 | |
| 5 | with Interfaces; |
| 6 | |
| 7 | package ZLib is |
| 8 | |
| 9 | ZLib_Error : exception; |
| 10 | Status_Error : exception; |
| 11 | |
| 12 | type Compression_Level is new Integer range -1 .. 9; |
| 13 | |
| 14 | type Flush_Mode is private; |
| 15 | |
| 16 | type Compression_Method is private; |
| 17 | |
| 18 | type Window_Bits_Type is new Integer range 8 .. 15; |
| 19 | |
| 20 | type Memory_Level_Type is new Integer range 1 .. 9; |
| 21 | |
| 22 | type Unsigned_32 is new Interfaces.Unsigned_32; |
| 23 | |
| 24 | type Strategy_Type is private; |
| 25 | |
| 26 | type Header_Type is (None, Auto, Default, GZip); |
| 27 | -- Header type usage have a some limitation for inflate. |
| 28 | -- See comment for Inflate_Init. |
| 29 | |
| 30 | subtype Count is Ada.Streams.Stream_Element_Count; |
| 31 | |
| 32 | Default_Memory_Level : constant Memory_Level_Type := 8; |
| 33 | Default_Window_Bits : constant Window_Bits_Type := 15; |
| 34 | |
| 35 | ---------------------------------- |
| 36 | -- Compression method constants -- |
| 37 | ---------------------------------- |
| 38 | |
| 39 | Deflated : constant Compression_Method; |
| 40 | -- Only one method allowed in this ZLib version |
| 41 | |
| 42 | --------------------------------- |
| 43 | -- Compression level constants -- |
| 44 | --------------------------------- |
| 45 | |
| 46 | No_Compression : constant Compression_Level := 0; |
| 47 | Best_Speed : constant Compression_Level := 1; |
| 48 | Best_Compression : constant Compression_Level := 9; |
| 49 | Default_Compression : constant Compression_Level := -1; |
| 50 | |
| 51 | -------------------------- |
| 52 | -- Flush mode constants -- |
| 53 | -------------------------- |
| 54 | |
| 55 | No_Flush : constant Flush_Mode; |
| 56 | -- Regular way for compression, no flush |
| 57 | |
| 58 | Partial_Flush : constant Flush_Mode; |
| 59 | -- Will be removed, use Z_SYNC_FLUSH instead |
| 60 | |
| 61 | Sync_Flush : constant Flush_Mode; |
| 62 | -- All pending output is flushed to the output buffer and the output |
| 63 | -- is aligned on a byte boundary, so that the decompressor can get all |
| 64 | -- input data available so far. (In particular avail_in is zero after the |
| 65 | -- call if enough output space has been provided before the call.) |
| 66 | -- Flushing may degrade compression for some compression algorithms and so |
| 67 | -- it should be used only when necessary. |
| 68 | |
| 69 | Block_Flush : constant Flush_Mode; |
| 70 | -- Z_BLOCK requests that inflate() stop |
| 71 | -- if and when it get to the next deflate block boundary. When decoding the |
| 72 | -- zlib or gzip format, this will cause inflate() to return immediately |
| 73 | -- after the header and before the first block. When doing a raw inflate, |
| 74 | -- inflate() will go ahead and process the first block, and will return |
| 75 | -- when it gets to the end of that block, or when it runs out of data. |
| 76 | |
| 77 | Full_Flush : constant Flush_Mode; |
| 78 | -- All output is flushed as with SYNC_FLUSH, and the compression state |
| 79 | -- is reset so that decompression can restart from this point if previous |
| 80 | -- compressed data has been damaged or if random access is desired. Using |
| 81 | -- Full_Flush too often can seriously degrade the compression. |
| 82 | |
| 83 | Finish : constant Flush_Mode; |
| 84 | -- Just for tell the compressor that input data is complete. |
| 85 | |
| 86 | ------------------------------------ |
| 87 | -- Compression strategy constants -- |
| 88 | ------------------------------------ |
| 89 | |
| 90 | -- RLE stategy could be used only in version 1.2.0 and later. |
| 91 | |
| 92 | Filtered : constant Strategy_Type; |
| 93 | Huffman_Only : constant Strategy_Type; |
| 94 | RLE : constant Strategy_Type; |
| 95 | Default_Strategy : constant Strategy_Type; |
| 96 | |
| 97 | Default_Buffer_Size : constant := 4096; |
| 98 | |
| 99 | type Filter_Type is tagged limited private; |
| 100 | -- The filter is for compression and for decompression. |
| 101 | -- The usage of the type is depend of its initialization. |
| 102 | |
| 103 | function Version return String; |
| 104 | pragma Inline (Version); |
| 105 | -- Return string representation of the ZLib version. |
| 106 | |
| 107 | procedure Deflate_Init |
| 108 | (Filter : in out Filter_Type; |
| 109 | Level : in Compression_Level := Default_Compression; |
| 110 | Strategy : in Strategy_Type := Default_Strategy; |
| 111 | Method : in Compression_Method := Deflated; |
| 112 | Window_Bits : in Window_Bits_Type := Default_Window_Bits; |
| 113 | Memory_Level : in Memory_Level_Type := Default_Memory_Level; |
| 114 | Header : in Header_Type := Default); |
| 115 | -- Compressor initialization. |
| 116 | -- When Header parameter is Auto or Default, then default zlib header |
| 117 | -- would be provided for compressed data. |
| 118 | -- When Header is GZip, then gzip header would be set instead of |
| 119 | -- default header. |
| 120 | -- When Header is None, no header would be set for compressed data. |
| 121 | |
| 122 | procedure Inflate_Init |
| 123 | (Filter : in out Filter_Type; |
| 124 | Window_Bits : in Window_Bits_Type := Default_Window_Bits; |
| 125 | Header : in Header_Type := Default); |
| 126 | -- Decompressor initialization. |
| 127 | -- Default header type mean that ZLib default header is expecting in the |
| 128 | -- input compressed stream. |
| 129 | -- Header type None mean that no header is expecting in the input stream. |
| 130 | -- GZip header type mean that GZip header is expecting in the |
| 131 | -- input compressed stream. |
| 132 | -- Auto header type mean that header type (GZip or Native) would be |
| 133 | -- detected automatically in the input stream. |
| 134 | -- Note that header types parameter values None, GZip and Auto are |
| 135 | -- supported for inflate routine only in ZLib versions 1.2.0.2 and later. |
| 136 | -- Deflate_Init is supporting all header types. |
| 137 | |
| 138 | function Is_Open (Filter : in Filter_Type) return Boolean; |
| 139 | pragma Inline (Is_Open); |
| 140 | -- Is the filter opened for compression or decompression. |
| 141 | |
| 142 | procedure Close |
| 143 | (Filter : in out Filter_Type; |
| 144 | Ignore_Error : in Boolean := False); |
| 145 | -- Closing the compression or decompressor. |
| 146 | -- If stream is closing before the complete and Ignore_Error is False, |
| 147 | -- The exception would be raised. |
| 148 | |
| 149 | generic |
| 150 | with procedure Data_In |
| 151 | (Item : out Ada.Streams.Stream_Element_Array; |
| 152 | Last : out Ada.Streams.Stream_Element_Offset); |
| 153 | with procedure Data_Out |
| 154 | (Item : in Ada.Streams.Stream_Element_Array); |
| 155 | procedure Generic_Translate |
| 156 | (Filter : in out Filter_Type; |
| 157 | In_Buffer_Size : in Integer := Default_Buffer_Size; |
| 158 | Out_Buffer_Size : in Integer := Default_Buffer_Size); |
| 159 | -- Compress/decompress data fetch from Data_In routine and pass the result |
| 160 | -- to the Data_Out routine. User should provide Data_In and Data_Out |
| 161 | -- for compression/decompression data flow. |
| 162 | -- Compression or decompression depend on Filter initialization. |
| 163 | |
| 164 | function Total_In (Filter : in Filter_Type) return Count; |
| 165 | pragma Inline (Total_In); |
| 166 | -- Returns total number of input bytes read so far |
| 167 | |
| 168 | function Total_Out (Filter : in Filter_Type) return Count; |
| 169 | pragma Inline (Total_Out); |
| 170 | -- Returns total number of bytes output so far |
| 171 | |
| 172 | function CRC32 |
| 173 | (CRC : in Unsigned_32; |
| 174 | Data : in Ada.Streams.Stream_Element_Array) |
| 175 | return Unsigned_32; |
| 176 | pragma Inline (CRC32); |
| 177 | -- Compute CRC32, it could be necessary for make gzip format |
| 178 | |
| 179 | procedure CRC32 |
| 180 | (CRC : in out Unsigned_32; |
| 181 | Data : in Ada.Streams.Stream_Element_Array); |
| 182 | pragma Inline (CRC32); |
| 183 | -- Compute CRC32, it could be necessary for make gzip format |
| 184 | |
| 185 | ------------------------------------------------- |
| 186 | -- Below is more complex low level routines. -- |
| 187 | ------------------------------------------------- |
| 188 | |
| 189 | procedure Translate |
| 190 | (Filter : in out Filter_Type; |
| 191 | In_Data : in Ada.Streams.Stream_Element_Array; |
| 192 | In_Last : out Ada.Streams.Stream_Element_Offset; |
| 193 | Out_Data : out Ada.Streams.Stream_Element_Array; |
| 194 | Out_Last : out Ada.Streams.Stream_Element_Offset; |
| 195 | Flush : in Flush_Mode); |
| 196 | -- Compress/decompress the In_Data buffer and place the result into |
| 197 | -- Out_Data. In_Last is the index of last element from In_Data accepted by |
| 198 | -- the Filter. Out_Last is the last element of the received data from |
| 199 | -- Filter. To tell the filter that incoming data are complete put the |
| 200 | -- Flush parameter to Finish. |
| 201 | |
| 202 | function Stream_End (Filter : in Filter_Type) return Boolean; |
| 203 | pragma Inline (Stream_End); |
| 204 | -- Return the true when the stream is complete. |
| 205 | |
| 206 | procedure Flush |
| 207 | (Filter : in out Filter_Type; |
| 208 | Out_Data : out Ada.Streams.Stream_Element_Array; |
| 209 | Out_Last : out Ada.Streams.Stream_Element_Offset; |
| 210 | Flush : in Flush_Mode); |
| 211 | pragma Inline (Flush); |
| 212 | -- Flushing the data from the compressor. |
| 213 | |
| 214 | generic |
| 215 | with procedure Write |
| 216 | (Item : in Ada.Streams.Stream_Element_Array); |
| 217 | -- User should provide this routine for accept |
| 218 | -- compressed/decompressed data. |
| 219 | |
| 220 | Buffer_Size : in Ada.Streams.Stream_Element_Offset |
| 221 | := Default_Buffer_Size; |
| 222 | -- Buffer size for Write user routine. |
| 223 | |
| 224 | procedure Write |
| 225 | (Filter : in out Filter_Type; |
| 226 | Item : in Ada.Streams.Stream_Element_Array; |
| 227 | Flush : in Flush_Mode := No_Flush); |
| 228 | -- Compress/Decompress data from Item to the generic parameter procedure |
| 229 | -- Write. Output buffer size could be set in Buffer_Size generic parameter. |
| 230 | |
| 231 | generic |
| 232 | with procedure Read |
| 233 | (Item : out Ada.Streams.Stream_Element_Array; |
| 234 | Last : out Ada.Streams.Stream_Element_Offset); |
| 235 | -- User should provide data for compression/decompression |
| 236 | -- thru this routine. |
| 237 | |
| 238 | Buffer : in out Ada.Streams.Stream_Element_Array; |
| 239 | -- Buffer for keep remaining data from the previous |
| 240 | -- back read. |
| 241 | |
| 242 | Rest_First, Rest_Last : in out Ada.Streams.Stream_Element_Offset; |
| 243 | -- Rest_First have to be initialized to Buffer'Last + 1 |
| 244 | -- Rest_Last have to be initialized to Buffer'Last |
| 245 | -- before usage. |
| 246 | |
| 247 | Allow_Read_Some : in Boolean := False; |
| 248 | -- Is it allowed to return Last < Item'Last before end of data. |
| 249 | |
| 250 | procedure Read |
| 251 | (Filter : in out Filter_Type; |
| 252 | Item : out Ada.Streams.Stream_Element_Array; |
| 253 | Last : out Ada.Streams.Stream_Element_Offset; |
| 254 | Flush : in Flush_Mode := No_Flush); |
| 255 | -- Compress/Decompress data from generic parameter procedure Read to the |
| 256 | -- Item. User should provide Buffer and initialized Rest_First, Rest_Last |
| 257 | -- indicators. If Allow_Read_Some is True, Read routines could return |
| 258 | -- Last < Item'Last only at end of stream. |
| 259 | |
| 260 | private |
| 261 | |
| 262 | use Ada.Streams; |
| 263 | |
| 264 | pragma Assert (Ada.Streams.Stream_Element'Size = 8); |
| 265 | pragma Assert (Ada.Streams.Stream_Element'Modulus = 2**8); |
| 266 | |
| 267 | type Flush_Mode is new Integer range 0 .. 5; |
| 268 | |
| 269 | type Compression_Method is new Integer range 8 .. 8; |
| 270 | |
| 271 | type Strategy_Type is new Integer range 0 .. 3; |
| 272 | |
| 273 | No_Flush : constant Flush_Mode := 0; |
| 274 | Partial_Flush : constant Flush_Mode := 1; |
| 275 | Sync_Flush : constant Flush_Mode := 2; |
| 276 | Full_Flush : constant Flush_Mode := 3; |
| 277 | Finish : constant Flush_Mode := 4; |
| 278 | Block_Flush : constant Flush_Mode := 5; |
| 279 | |
| 280 | Filtered : constant Strategy_Type := 1; |
| 281 | Huffman_Only : constant Strategy_Type := 2; |
| 282 | RLE : constant Strategy_Type := 3; |
| 283 | Default_Strategy : constant Strategy_Type := 0; |
| 284 | |
| 285 | Deflated : constant Compression_Method := 8; |
| 286 | |
| 287 | type Z_Stream; |
| 288 | |
| 289 | type Z_Stream_Access is access all Z_Stream; |
| 290 | |
| 291 | type Filter_Type is tagged limited record |
| 292 | Strm : Z_Stream_Access; |
| 293 | Compression : Boolean; |
| 294 | Stream_End : Boolean; |
| 295 | Header : Header_Type; |
| 296 | CRC : Unsigned_32; |
| 297 | Offset : Stream_Element_Offset; |
| 298 | -- Offset for gzip header/footer output. |
| 299 | end record; |
| 300 | |
| 301 | end ZLib; |
| --- a/compat/zlib/contrib/ada/zlib.ads | |
| +++ b/compat/zlib/contrib/ada/zlib.ads | |
| @@ -1,328 +0,0 @@ | |
| ------------------------------------------------------------------------------- | |
| --- ZLib for Ada thick binding. -- | |
| --- -- | |
| --- Copyright (C) 2002-2004 Dmitriy Anisimkov -- | |
| --- -- | |
| --- This library is free software; you can redistribute it and/or modify -- | |
| --- it under the terms of the GNU General Public License as published by -- | |
| --- the Free Software Foundation; either version 2 of the License, or (at -- | |
| --- your option) any later version. -- | |
| --- -- | |
| --- This library is distributed in the hope that it will be useful, but -- | |
| --- WITHOUT ANY WARRANTY; without even the implied warranty of -- | |
| --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- | |
| --- General Public License for more details. -- | |
| --- -- | |
| --- You should have received a copy of the GNU General Public License -- | |
| --- along with this library; if not, write to the Free Software Foundation, -- | |
| --- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- | |
| --- -- | |
| --- As a special exception, if other files instantiate generics from this -- | |
| --- unit, or you link this unit with other files to produce an executable, -- | |
| --- this unit does not by itself cause the resulting executable to be -- | |
| --- covered by the GNU General Public License. This exception does not -- | |
| --- however invalidate any other reasons why the executable file might be -- | |
| --- covered by the GNU Public License. -- | |
| ------------------------------------------------------------------------------- | |
| --- $Id: zlib.ads,v 1.26 2004/09/06 06:53:19 vagul Exp $ | |
D
compat/zlib/contrib/ada/zlib.gpr
-20
| --- a/compat/zlib/contrib/ada/zlib.gpr | ||
| +++ b/compat/zlib/contrib/ada/zlib.gpr | ||
| @@ -1,20 +0,0 @@ | ||
| 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; |
| --- a/compat/zlib/contrib/ada/zlib.gpr | |
| +++ b/compat/zlib/contrib/ada/zlib.gpr | |
| @@ -1,20 +0,0 @@ | |
| 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; |
| --- a/compat/zlib/contrib/ada/zlib.gpr | |
| +++ b/compat/zlib/contrib/ada/zlib.gpr | |
| @@ -1,20 +0,0 @@ | |
D
compat/zlib/contrib/amd64/amd64-match.S
-452
| --- a/compat/zlib/contrib/amd64/amd64-match.S | ||
| +++ b/compat/zlib/contrib/amd64/amd64-match.S | ||
| @@ -1,452 +0,0 @@ | ||
| 1 | -/* | |
| 2 | - * match.S -- optimized version of longest_match() | |
| 3 | - * based on the similar work by Gilles Vollant, and Brian Raiter, written 1998 | |
| 4 | - * | |
| 5 | - * This is free software; you can redistribute it and/or modify it | |
| 6 | - * under the terms of the BSD License. Use by owners of Che Guevarra | |
| 7 | - * parafernalia is prohibited, where possible, and highly discouraged | |
| 8 | - * elsewhere. | |
| 9 | - */ | |
| 10 | - | |
| 11 | -#ifndef NO_UNDERLINE | |
| 12 | -# define match_init _match_init | |
| 13 | -# define longest_match _longest_match | |
| 14 | -#endif | |
| 15 | - | |
| 16 | -#define scanend ebx | |
| 17 | -#define scanendw bx | |
| 18 | -#define chainlenwmask edx /* high word: current chain len low word: s->wmask */ | |
| 19 | -#define curmatch rsi | |
| 20 | -#define curmatchd esi | |
| 21 | -#define windowbestlen r8 | |
| 22 | -#define scanalign r9 | |
| 23 | -#define scanalignd r9d | |
| 24 | -#define window r10 | |
| 25 | -#define bestlen r11 | |
| 26 | -#define bestlend r11d | |
| 27 | -#define scanstart r12d | |
| 28 | -#define scanstartw r12w | |
| 29 | -#define scan r13 | |
| 30 | -#define nicematch r14d | |
| 31 | -#define limit r15 | |
| 32 | -#define limitd r15d | |
| 33 | -#define prev rcx | |
| 34 | - | |
| 35 | -/* | |
| 36 | - * The 258 is a "magic number, not a parameter -- changing it | |
| 37 | - * breaks the hell loose | |
| 38 | - */ | |
| 39 | -#define MAX_MATCH (258) | |
| 40 | -#define MIN_MATCH (3) | |
| 41 | -#define MIN_LOOKAHEAD (MAX_MATCH + MIN_MATCH + 1) | |
| 42 | -#define MAX_MATCH_8 ((MAX_MATCH + 7) & ~7) | |
| 43 | - | |
| 44 | -/* stack frame offsets */ | |
| 45 | -#define LocalVarsSize (112) | |
| 46 | -#define _chainlenwmask ( 8-LocalVarsSize)(%rsp) | |
| 47 | -#define _windowbestlen (16-LocalVarsSize)(%rsp) | |
| 48 | -#define save_r14 (24-LocalVarsSize)(%rsp) | |
| 49 | -#define save_rsi (32-LocalVarsSize)(%rsp) | |
| 50 | -#define save_rbx (40-LocalVarsSize)(%rsp) | |
| 51 | -#define save_r12 (56-LocalVarsSize)(%rsp) | |
| 52 | -#define save_r13 (64-LocalVarsSize)(%rsp) | |
| 53 | -#define save_r15 (80-LocalVarsSize)(%rsp) | |
| 54 | - | |
| 55 | - | |
| 56 | -.globl match_init, longest_match | |
| 57 | - | |
| 58 | -/* | |
| 59 | - * On AMD64 the first argument of a function (in our case -- the pointer to | |
| 60 | - * deflate_state structure) is passed in %rdi, hence our offsets below are | |
| 61 | - * all off of that. | |
| 62 | - */ | |
| 63 | - | |
| 64 | -/* you can check the structure offset by running | |
| 65 | - | |
| 66 | -#include <stdlib.h> | |
| 67 | -#include <stdio.h> | |
| 68 | -#include "deflate.h" | |
| 69 | - | |
| 70 | -void print_depl() | |
| 71 | -{ | |
| 72 | -deflate_state ds; | |
| 73 | -deflate_state *s=&ds; | |
| 74 | -printf("size pointer=%u\n",(int)sizeof(void*)); | |
| 75 | - | |
| 76 | -printf("#define dsWSize (%3u)(%%rdi)\n",(int)(((char*)&(s->w_size))-((char*)s))); | |
| 77 | -printf("#define dsWMask (%3u)(%%rdi)\n",(int)(((char*)&(s->w_mask))-((char*)s))); | |
| 78 | -printf("#define dsWindow (%3u)(%%rdi)\n",(int)(((char*)&(s->window))-((char*)s))); | |
| 79 | -printf("#define dsPrev (%3u)(%%rdi)\n",(int)(((char*)&(s->prev))-((char*)s))); | |
| 80 | -printf("#define dsMatchLen (%3u)(%%rdi)\n",(int)(((char*)&(s->match_length))-((char*)s))); | |
| 81 | -printf("#define dsPrevMatch (%3u)(%%rdi)\n",(int)(((char*)&(s->prev_match))-((char*)s))); | |
| 82 | -printf("#define dsStrStart (%3u)(%%rdi)\n",(int)(((char*)&(s->strstart))-((char*)s))); | |
| 83 | -printf("#define dsMatchStart (%3u)(%%rdi)\n",(int)(((char*)&(s->match_start))-((char*)s))); | |
| 84 | -printf("#define dsLookahead (%3u)(%%rdi)\n",(int)(((char*)&(s->lookahead))-((char*)s))); | |
| 85 | -printf("#define dsPrevLen (%3u)(%%rdi)\n",(int)(((char*)&(s->prev_length))-((char*)s))); | |
| 86 | -printf("#define dsMaxChainLen (%3u)(%%rdi)\n",(int)(((char*)&(s->max_chain_length))-((char*)s))); | |
| 87 | -printf("#define dsGoodMatch (%3u)(%%rdi)\n",(int)(((char*)&(s->good_match))-((char*)s))); | |
| 88 | -printf("#define dsNiceMatch (%3u)(%%rdi)\n",(int)(((char*)&(s->nice_match))-((char*)s))); | |
| 89 | -} | |
| 90 | - | |
| 91 | -*/ | |
| 92 | - | |
| 93 | - | |
| 94 | -/* | |
| 95 | - to compile for XCode 3.2 on MacOSX x86_64 | |
| 96 | - - run "gcc -g -c -DXCODE_MAC_X64_STRUCTURE amd64-match.S" | |
| 97 | - */ | |
| 98 | - | |
| 99 | - | |
| 100 | -#ifndef CURRENT_LINX_XCODE_MAC_X64_STRUCTURE | |
| 101 | -#define dsWSize ( 68)(%rdi) | |
| 102 | -#define dsWMask ( 76)(%rdi) | |
| 103 | -#define dsWindow ( 80)(%rdi) | |
| 104 | -#define dsPrev ( 96)(%rdi) | |
| 105 | -#define dsMatchLen (144)(%rdi) | |
| 106 | -#define dsPrevMatch (148)(%rdi) | |
| 107 | -#define dsStrStart (156)(%rdi) | |
| 108 | -#define dsMatchStart (160)(%rdi) | |
| 109 | -#define dsLookahead (164)(%rdi) | |
| 110 | -#define dsPrevLen (168)(%rdi) | |
| 111 | -#define dsMaxChainLen (172)(%rdi) | |
| 112 | -#define dsGoodMatch (188)(%rdi) | |
| 113 | -#define dsNiceMatch (192)(%rdi) | |
| 114 | - | |
| 115 | -#else | |
| 116 | - | |
| 117 | -#ifndef STRUCT_OFFSET | |
| 118 | -# define STRUCT_OFFSET (0) | |
| 119 | -#endif | |
| 120 | - | |
| 121 | - | |
| 122 | -#define dsWSize ( 56 + STRUCT_OFFSET)(%rdi) | |
| 123 | -#define dsWMask ( 64 + STRUCT_OFFSET)(%rdi) | |
| 124 | -#define dsWindow ( 72 + STRUCT_OFFSET)(%rdi) | |
| 125 | -#define dsPrev ( 88 + STRUCT_OFFSET)(%rdi) | |
| 126 | -#define dsMatchLen (136 + STRUCT_OFFSET)(%rdi) | |
| 127 | -#define dsPrevMatch (140 + STRUCT_OFFSET)(%rdi) | |
| 128 | -#define dsStrStart (148 + STRUCT_OFFSET)(%rdi) | |
| 129 | -#define dsMatchStart (152 + STRUCT_OFFSET)(%rdi) | |
| 130 | -#define dsLookahead (156 + STRUCT_OFFSET)(%rdi) | |
| 131 | -#define dsPrevLen (160 + STRUCT_OFFSET)(%rdi) | |
| 132 | -#define dsMaxChainLen (164 + STRUCT_OFFSET)(%rdi) | |
| 133 | -#define dsGoodMatch (180 + STRUCT_OFFSET)(%rdi) | |
| 134 | -#define dsNiceMatch (184 + STRUCT_OFFSET)(%rdi) | |
| 135 | - | |
| 136 | -#endif | |
| 137 | - | |
| 138 | - | |
| 139 | - | |
| 140 | - | |
| 141 | -.text | |
| 142 | - | |
| 143 | -/* uInt longest_match(deflate_state *deflatestate, IPos curmatch) */ | |
| 144 | - | |
| 145 | -longest_match: | |
| 146 | -/* | |
| 147 | - * Retrieve the function arguments. %curmatch will hold cur_match | |
| 148 | - * throughout the entire function (passed via rsi on amd64). | |
| 149 | - * rdi will hold the pointer to the deflate_state (first arg on amd64) | |
| 150 | - */ | |
| 151 | - mov %rsi, save_rsi | |
| 152 | - mov %rbx, save_rbx | |
| 153 | - mov %r12, save_r12 | |
| 154 | - mov %r13, save_r13 | |
| 155 | - mov %r14, save_r14 | |
| 156 | - mov %r15, save_r15 | |
| 157 | - | |
| 158 | -/* uInt wmask = s->w_mask; */ | |
| 159 | -/* unsigned chain_length = s->max_chain_length; */ | |
| 160 | -/* if (s->prev_length >= s->good_match) { */ | |
| 161 | -/* chain_length >>= 2; */ | |
| 162 | -/* } */ | |
| 163 | - | |
| 164 | - movl dsPrevLen, %eax | |
| 165 | - movl dsGoodMatch, %ebx | |
| 166 | - cmpl %ebx, %eax | |
| 167 | - movl dsWMask, %eax | |
| 168 | - movl dsMaxChainLen, %chainlenwmask | |
| 169 | - jl LastMatchGood | |
| 170 | - shrl $2, %chainlenwmask | |
| 171 | -LastMatchGood: | |
| 172 | - | |
| 173 | -/* chainlen is decremented once beforehand so that the function can */ | |
| 174 | -/* use the sign flag instead of the zero flag for the exit test. */ | |
| 175 | -/* It is then shifted into the high word, to make room for the wmask */ | |
| 176 | -/* value, which it will always accompany. */ | |
| 177 | - | |
| 178 | - decl %chainlenwmask | |
| 179 | - shll $16, %chainlenwmask | |
| 180 | - orl %eax, %chainlenwmask | |
| 181 | - | |
| 182 | -/* if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; */ | |
| 183 | - | |
| 184 | - movl dsNiceMatch, %eax | |
| 185 | - movl dsLookahead, %ebx | |
| 186 | - cmpl %eax, %ebx | |
| 187 | - jl LookaheadLess | |
| 188 | - movl %eax, %ebx | |
| 189 | -LookaheadLess: movl %ebx, %nicematch | |
| 190 | - | |
| 191 | -/* register Bytef *scan = s->window + s->strstart; */ | |
| 192 | - | |
| 193 | - mov dsWindow, %window | |
| 194 | - movl dsStrStart, %limitd | |
| 195 | - lea (%limit, %window), %scan | |
| 196 | - | |
| 197 | -/* Determine how many bytes the scan ptr is off from being */ | |
| 198 | -/* dword-aligned. */ | |
| 199 | - | |
| 200 | - mov %scan, %scanalign | |
| 201 | - negl %scanalignd | |
| 202 | - andl $3, %scanalignd | |
| 203 | - | |
| 204 | -/* IPos limit = s->strstart > (IPos)MAX_DIST(s) ? */ | |
| 205 | -/* s->strstart - (IPos)MAX_DIST(s) : NIL; */ | |
| 206 | - | |
| 207 | - movl dsWSize, %eax | |
| 208 | - subl $MIN_LOOKAHEAD, %eax | |
| 209 | - xorl %ecx, %ecx | |
| 210 | - subl %eax, %limitd | |
| 211 | - cmovng %ecx, %limitd | |
| 212 | - | |
| 213 | -/* int best_len = s->prev_length; */ | |
| 214 | - | |
| 215 | - movl dsPrevLen, %bestlend | |
| 216 | - | |
| 217 | -/* Store the sum of s->window + best_len in %windowbestlen locally, and in memory. */ | |
| 218 | - | |
| 219 | - lea (%window, %bestlen), %windowbestlen | |
| 220 | - mov %windowbestlen, _windowbestlen | |
| 221 | - | |
| 222 | -/* register ush scan_start = *(ushf*)scan; */ | |
| 223 | -/* register ush scan_end = *(ushf*)(scan+best_len-1); */ | |
| 224 | -/* Posf *prev = s->prev; */ | |
| 225 | - | |
| 226 | - movzwl (%scan), %scanstart | |
| 227 | - movzwl -1(%scan, %bestlen), %scanend | |
| 228 | - mov dsPrev, %prev | |
| 229 | - | |
| 230 | -/* Jump into the main loop. */ | |
| 231 | - | |
| 232 | - movl %chainlenwmask, _chainlenwmask | |
| 233 | - jmp LoopEntry | |
| 234 | - | |
| 235 | -.balign 16 | |
| 236 | - | |
| 237 | -/* do { | |
| 238 | - * match = s->window + cur_match; | |
| 239 | - * if (*(ushf*)(match+best_len-1) != scan_end || | |
| 240 | - * *(ushf*)match != scan_start) continue; | |
| 241 | - * [...] | |
| 242 | - * } while ((cur_match = prev[cur_match & wmask]) > limit | |
| 243 | - * && --chain_length != 0); | |
| 244 | - * | |
| 245 | - * Here is the inner loop of the function. The function will spend the | |
| 246 | - * majority of its time in this loop, and majority of that time will | |
| 247 | - * be spent in the first ten instructions. | |
| 248 | - */ | |
| 249 | -LookupLoop: | |
| 250 | - andl %chainlenwmask, %curmatchd | |
| 251 | - movzwl (%prev, %curmatch, 2), %curmatchd | |
| 252 | - cmpl %limitd, %curmatchd | |
| 253 | - jbe LeaveNow | |
| 254 | - subl $0x00010000, %chainlenwmask | |
| 255 | - js LeaveNow | |
| 256 | -LoopEntry: cmpw -1(%windowbestlen, %curmatch), %scanendw | |
| 257 | - jne LookupLoop | |
| 258 | - cmpw %scanstartw, (%window, %curmatch) | |
| 259 | - jne LookupLoop | |
| 260 | - | |
| 261 | -/* Store the current value of chainlen. */ | |
| 262 | - movl %chainlenwmask, _chainlenwmask | |
| 263 | - | |
| 264 | -/* %scan is the string under scrutiny, and %prev to the string we */ | |
| 265 | -/* are hoping to match it up with. In actuality, %esi and %edi are */ | |
| 266 | -/* both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and %edx is */ | |
| 267 | -/* initialized to -(MAX_MATCH_8 - scanalign). */ | |
| 268 | - | |
| 269 | - mov $(-MAX_MATCH_8), %rdx | |
| 270 | - lea (%curmatch, %window), %windowbestlen | |
| 271 | - lea MAX_MATCH_8(%windowbestlen, %scanalign), %windowbestlen | |
| 272 | - lea MAX_MATCH_8(%scan, %scanalign), %prev | |
| 273 | - | |
| 274 | -/* the prefetching below makes very little difference... */ | |
| 275 | - prefetcht1 (%windowbestlen, %rdx) | |
| 276 | - prefetcht1 (%prev, %rdx) | |
| 277 | - | |
| 278 | -/* | |
| 279 | - * Test the strings for equality, 8 bytes at a time. At the end, | |
| 280 | - * adjust %rdx so that it is offset to the exact byte that mismatched. | |
| 281 | - * | |
| 282 | - * It should be confessed that this loop usually does not represent | |
| 283 | - * much of the total running time. Replacing it with a more | |
| 284 | - * straightforward "rep cmpsb" would not drastically degrade | |
| 285 | - * performance -- unrolling it, for example, makes no difference. | |
| 286 | - */ | |
| 287 | - | |
| 288 | -#undef USE_SSE /* works, but is 6-7% slower, than non-SSE... */ | |
| 289 | - | |
| 290 | -LoopCmps: | |
| 291 | -#ifdef USE_SSE | |
| 292 | - /* Preload the SSE registers */ | |
| 293 | - movdqu (%windowbestlen, %rdx), %xmm1 | |
| 294 | - movdqu (%prev, %rdx), %xmm2 | |
| 295 | - pcmpeqb %xmm2, %xmm1 | |
| 296 | - movdqu 16(%windowbestlen, %rdx), %xmm3 | |
| 297 | - movdqu 16(%prev, %rdx), %xmm4 | |
| 298 | - pcmpeqb %xmm4, %xmm3 | |
| 299 | - movdqu 32(%windowbestlen, %rdx), %xmm5 | |
| 300 | - movdqu 32(%prev, %rdx), %xmm6 | |
| 301 | - pcmpeqb %xmm6, %xmm5 | |
| 302 | - movdqu 48(%windowbestlen, %rdx), %xmm7 | |
| 303 | - movdqu 48(%prev, %rdx), %xmm8 | |
| 304 | - pcmpeqb %xmm8, %xmm7 | |
| 305 | - | |
| 306 | - /* Check the comparisions' results */ | |
| 307 | - pmovmskb %xmm1, %rax | |
| 308 | - notw %ax | |
| 309 | - bsfw %ax, %ax | |
| 310 | - jnz LeaveLoopCmps | |
| 311 | - | |
| 312 | - /* this is the only iteration of the loop with a possibility of having | |
| 313 | - incremented rdx by 0x108 (each loop iteration add 16*4 = 0x40 | |
| 314 | - and (0x40*4)+8=0x108 */ | |
| 315 | - add $8, %rdx | |
| 316 | - jz LenMaximum | |
| 317 | - add $8, %rdx | |
| 318 | - | |
| 319 | - | |
| 320 | - pmovmskb %xmm3, %rax | |
| 321 | - notw %ax | |
| 322 | - bsfw %ax, %ax | |
| 323 | - jnz LeaveLoopCmps | |
| 324 | - | |
| 325 | - | |
| 326 | - add $16, %rdx | |
| 327 | - | |
| 328 | - | |
| 329 | - pmovmskb %xmm5, %rax | |
| 330 | - notw %ax | |
| 331 | - bsfw %ax, %ax | |
| 332 | - jnz LeaveLoopCmps | |
| 333 | - | |
| 334 | - add $16, %rdx | |
| 335 | - | |
| 336 | - | |
| 337 | - pmovmskb %xmm7, %rax | |
| 338 | - notw %ax | |
| 339 | - bsfw %ax, %ax | |
| 340 | - jnz LeaveLoopCmps | |
| 341 | - | |
| 342 | - add $16, %rdx | |
| 343 | - | |
| 344 | - jmp LoopCmps | |
| 345 | -LeaveLoopCmps: add %rax, %rdx | |
| 346 | -#else | |
| 347 | - mov (%windowbestlen, %rdx), %rax | |
| 348 | - xor (%prev, %rdx), %rax | |
| 349 | - jnz LeaveLoopCmps | |
| 350 | - | |
| 351 | - mov 8(%windowbestlen, %rdx), %rax | |
| 352 | - xor 8(%prev, %rdx), %rax | |
| 353 | - jnz LeaveLoopCmps8 | |
| 354 | - | |
| 355 | - mov 16(%windowbestlen, %rdx), %rax | |
| 356 | - xor 16(%prev, %rdx), %rax | |
| 357 | - jnz LeaveLoopCmps16 | |
| 358 | - | |
| 359 | - add $24, %rdx | |
| 360 | - jnz LoopCmps | |
| 361 | - jmp LenMaximum | |
| 362 | -# if 0 | |
| 363 | -/* | |
| 364 | - * This three-liner is tantalizingly simple, but bsf is a slow instruction, | |
| 365 | - * and the complicated alternative down below is quite a bit faster. Sad... | |
| 366 | - */ | |
| 367 | - | |
| 368 | -LeaveLoopCmps: bsf %rax, %rax /* find the first non-zero bit */ | |
| 369 | - shrl $3, %eax /* divide by 8 to get the byte */ | |
| 370 | - add %rax, %rdx | |
| 371 | -# else | |
| 372 | -LeaveLoopCmps16: | |
| 373 | - add $8, %rdx | |
| 374 | -LeaveLoopCmps8: | |
| 375 | - add $8, %rdx | |
| 376 | -LeaveLoopCmps: testl $0xFFFFFFFF, %eax /* Check the first 4 bytes */ | |
| 377 | - jnz Check16 | |
| 378 | - add $4, %rdx | |
| 379 | - shr $32, %rax | |
| 380 | -Check16: testw $0xFFFF, %ax | |
| 381 | - jnz LenLower | |
| 382 | - add $2, %rdx | |
| 383 | - shrl $16, %eax | |
| 384 | -LenLower: subb $1, %al | |
| 385 | - adc $0, %rdx | |
| 386 | -# endif | |
| 387 | -#endif | |
| 388 | - | |
| 389 | -/* Calculate the length of the match. If it is longer than MAX_MATCH, */ | |
| 390 | -/* then automatically accept it as the best possible match and leave. */ | |
| 391 | - | |
| 392 | - lea (%prev, %rdx), %rax | |
| 393 | - sub %scan, %rax | |
| 394 | - cmpl $MAX_MATCH, %eax | |
| 395 | - jge LenMaximum | |
| 396 | - | |
| 397 | -/* If the length of the match is not longer than the best match we */ | |
| 398 | -/* have so far, then forget it and return to the lookup loop. */ | |
| 399 | - | |
| 400 | - cmpl %bestlend, %eax | |
| 401 | - jg LongerMatch | |
| 402 | - mov _windowbestlen, %windowbestlen | |
| 403 | - mov dsPrev, %prev | |
| 404 | - movl _chainlenwmask, %edx | |
| 405 | - jmp LookupLoop | |
| 406 | - | |
| 407 | -/* s->match_start = cur_match; */ | |
| 408 | -/* best_len = len; */ | |
| 409 | -/* if (len >= nice_match) break; */ | |
| 410 | -/* scan_end = *(ushf*)(scan+best_len-1); */ | |
| 411 | - | |
| 412 | -LongerMatch: | |
| 413 | - movl %eax, %bestlend | |
| 414 | - movl %curmatchd, dsMatchStart | |
| 415 | - cmpl %nicematch, %eax | |
| 416 | - jge LeaveNow | |
| 417 | - | |
| 418 | - lea (%window, %bestlen), %windowbestlen | |
| 419 | - mov %windowbestlen, _windowbestlen | |
| 420 | - | |
| 421 | - movzwl -1(%scan, %rax), %scanend | |
| 422 | - mov dsPrev, %prev | |
| 423 | - movl _chainlenwmask, %chainlenwmask | |
| 424 | - jmp LookupLoop | |
| 425 | - | |
| 426 | -/* Accept the current string, with the maximum possible length. */ | |
| 427 | - | |
| 428 | -LenMaximum: | |
| 429 | - movl $MAX_MATCH, %bestlend | |
| 430 | - movl %curmatchd, dsMatchStart | |
| 431 | - | |
| 432 | -/* if ((uInt)best_len <= s->lookahead) return (uInt)best_len; */ | |
| 433 | -/* return s->lookahead; */ | |
| 434 | - | |
| 435 | -LeaveNow: | |
| 436 | - movl dsLookahead, %eax | |
| 437 | - cmpl %eax, %bestlend | |
| 438 | - cmovngl %bestlend, %eax | |
| 439 | -LookaheadRet: | |
| 440 | - | |
| 441 | -/* Restore the registers and return from whence we came. */ | |
| 442 | - | |
| 443 | - mov save_rsi, %rsi | |
| 444 | - mov save_rbx, %rbx | |
| 445 | - mov save_r12, %r12 | |
| 446 | - mov save_r13, %r13 | |
| 447 | - mov save_r14, %r14 | |
| 448 | - mov save_r15, %r15 | |
| 449 | - | |
| 450 | - ret | |
| 451 | - | |
| 452 | -match_init: ret |
| --- a/compat/zlib/contrib/amd64/amd64-match.S | |
| +++ b/compat/zlib/contrib/amd64/amd64-match.S | |
| @@ -1,452 +0,0 @@ | |
| 1 | /* |
| 2 | * match.S -- optimized version of longest_match() |
| 3 | * based on the similar work by Gilles Vollant, and Brian Raiter, written 1998 |
| 4 | * |
| 5 | * This is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the BSD License. Use by owners of Che Guevarra |
| 7 | * parafernalia is prohibited, where possible, and highly discouraged |
| 8 | * elsewhere. |
| 9 | */ |
| 10 | |
| 11 | #ifndef NO_UNDERLINE |
| 12 | # define match_init _match_init |
| 13 | # define longest_match _longest_match |
| 14 | #endif |
| 15 | |
| 16 | #define scanend ebx |
| 17 | #define scanendw bx |
| 18 | #define chainlenwmask edx /* high word: current chain len low word: s->wmask */ |
| 19 | #define curmatch rsi |
| 20 | #define curmatchd esi |
| 21 | #define windowbestlen r8 |
| 22 | #define scanalign r9 |
| 23 | #define scanalignd r9d |
| 24 | #define window r10 |
| 25 | #define bestlen r11 |
| 26 | #define bestlend r11d |
| 27 | #define scanstart r12d |
| 28 | #define scanstartw r12w |
| 29 | #define scan r13 |
| 30 | #define nicematch r14d |
| 31 | #define limit r15 |
| 32 | #define limitd r15d |
| 33 | #define prev rcx |
| 34 | |
| 35 | /* |
| 36 | * The 258 is a "magic number, not a parameter -- changing it |
| 37 | * breaks the hell loose |
| 38 | */ |
| 39 | #define MAX_MATCH (258) |
| 40 | #define MIN_MATCH (3) |
| 41 | #define MIN_LOOKAHEAD (MAX_MATCH + MIN_MATCH + 1) |
| 42 | #define MAX_MATCH_8 ((MAX_MATCH + 7) & ~7) |
| 43 | |
| 44 | /* stack frame offsets */ |
| 45 | #define LocalVarsSize (112) |
| 46 | #define _chainlenwmask ( 8-LocalVarsSize)(%rsp) |
| 47 | #define _windowbestlen (16-LocalVarsSize)(%rsp) |
| 48 | #define save_r14 (24-LocalVarsSize)(%rsp) |
| 49 | #define save_rsi (32-LocalVarsSize)(%rsp) |
| 50 | #define save_rbx (40-LocalVarsSize)(%rsp) |
| 51 | #define save_r12 (56-LocalVarsSize)(%rsp) |
| 52 | #define save_r13 (64-LocalVarsSize)(%rsp) |
| 53 | #define save_r15 (80-LocalVarsSize)(%rsp) |
| 54 | |
| 55 | |
| 56 | .globl match_init, longest_match |
| 57 | |
| 58 | /* |
| 59 | * On AMD64 the first argument of a function (in our case -- the pointer to |
| 60 | * deflate_state structure) is passed in %rdi, hence our offsets below are |
| 61 | * all off of that. |
| 62 | */ |
| 63 | |
| 64 | /* you can check the structure offset by running |
| 65 | |
| 66 | #include <stdlib.h> |
| 67 | #include <stdio.h> |
| 68 | #include "deflate.h" |
| 69 | |
| 70 | void print_depl() |
| 71 | { |
| 72 | deflate_state ds; |
| 73 | deflate_state *s=&ds; |
| 74 | printf("size pointer=%u\n",(int)sizeof(void*)); |
| 75 | |
| 76 | printf("#define dsWSize (%3u)(%%rdi)\n",(int)(((char*)&(s->w_size))-((char*)s))); |
| 77 | printf("#define dsWMask (%3u)(%%rdi)\n",(int)(((char*)&(s->w_mask))-((char*)s))); |
| 78 | printf("#define dsWindow (%3u)(%%rdi)\n",(int)(((char*)&(s->window))-((char*)s))); |
| 79 | printf("#define dsPrev (%3u)(%%rdi)\n",(int)(((char*)&(s->prev))-((char*)s))); |
| 80 | printf("#define dsMatchLen (%3u)(%%rdi)\n",(int)(((char*)&(s->match_length))-((char*)s))); |
| 81 | printf("#define dsPrevMatch (%3u)(%%rdi)\n",(int)(((char*)&(s->prev_match))-((char*)s))); |
| 82 | printf("#define dsStrStart (%3u)(%%rdi)\n",(int)(((char*)&(s->strstart))-((char*)s))); |
| 83 | printf("#define dsMatchStart (%3u)(%%rdi)\n",(int)(((char*)&(s->match_start))-((char*)s))); |
| 84 | printf("#define dsLookahead (%3u)(%%rdi)\n",(int)(((char*)&(s->lookahead))-((char*)s))); |
| 85 | printf("#define dsPrevLen (%3u)(%%rdi)\n",(int)(((char*)&(s->prev_length))-((char*)s))); |
| 86 | printf("#define dsMaxChainLen (%3u)(%%rdi)\n",(int)(((char*)&(s->max_chain_length))-((char*)s))); |
| 87 | printf("#define dsGoodMatch (%3u)(%%rdi)\n",(int)(((char*)&(s->good_match))-((char*)s))); |
| 88 | printf("#define dsNiceMatch (%3u)(%%rdi)\n",(int)(((char*)&(s->nice_match))-((char*)s))); |
| 89 | } |
| 90 | |
| 91 | */ |
| 92 | |
| 93 | |
| 94 | /* |
| 95 | to compile for XCode 3.2 on MacOSX x86_64 |
| 96 | - run "gcc -g -c -DXCODE_MAC_X64_STRUCTURE amd64-match.S" |
| 97 | */ |
| 98 | |
| 99 | |
| 100 | #ifndef CURRENT_LINX_XCODE_MAC_X64_STRUCTURE |
| 101 | #define dsWSize ( 68)(%rdi) |
| 102 | #define dsWMask ( 76)(%rdi) |
| 103 | #define dsWindow ( 80)(%rdi) |
| 104 | #define dsPrev ( 96)(%rdi) |
| 105 | #define dsMatchLen (144)(%rdi) |
| 106 | #define dsPrevMatch (148)(%rdi) |
| 107 | #define dsStrStart (156)(%rdi) |
| 108 | #define dsMatchStart (160)(%rdi) |
| 109 | #define dsLookahead (164)(%rdi) |
| 110 | #define dsPrevLen (168)(%rdi) |
| 111 | #define dsMaxChainLen (172)(%rdi) |
| 112 | #define dsGoodMatch (188)(%rdi) |
| 113 | #define dsNiceMatch (192)(%rdi) |
| 114 | |
| 115 | #else |
| 116 | |
| 117 | #ifndef STRUCT_OFFSET |
| 118 | # define STRUCT_OFFSET (0) |
| 119 | #endif |
| 120 | |
| 121 | |
| 122 | #define dsWSize ( 56 + STRUCT_OFFSET)(%rdi) |
| 123 | #define dsWMask ( 64 + STRUCT_OFFSET)(%rdi) |
| 124 | #define dsWindow ( 72 + STRUCT_OFFSET)(%rdi) |
| 125 | #define dsPrev ( 88 + STRUCT_OFFSET)(%rdi) |
| 126 | #define dsMatchLen (136 + STRUCT_OFFSET)(%rdi) |
| 127 | #define dsPrevMatch (140 + STRUCT_OFFSET)(%rdi) |
| 128 | #define dsStrStart (148 + STRUCT_OFFSET)(%rdi) |
| 129 | #define dsMatchStart (152 + STRUCT_OFFSET)(%rdi) |
| 130 | #define dsLookahead (156 + STRUCT_OFFSET)(%rdi) |
| 131 | #define dsPrevLen (160 + STRUCT_OFFSET)(%rdi) |
| 132 | #define dsMaxChainLen (164 + STRUCT_OFFSET)(%rdi) |
| 133 | #define dsGoodMatch (180 + STRUCT_OFFSET)(%rdi) |
| 134 | #define dsNiceMatch (184 + STRUCT_OFFSET)(%rdi) |
| 135 | |
| 136 | #endif |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | .text |
| 142 | |
| 143 | /* uInt longest_match(deflate_state *deflatestate, IPos curmatch) */ |
| 144 | |
| 145 | longest_match: |
| 146 | /* |
| 147 | * Retrieve the function arguments. %curmatch will hold cur_match |
| 148 | * throughout the entire function (passed via rsi on amd64). |
| 149 | * rdi will hold the pointer to the deflate_state (first arg on amd64) |
| 150 | */ |
| 151 | mov %rsi, save_rsi |
| 152 | mov %rbx, save_rbx |
| 153 | mov %r12, save_r12 |
| 154 | mov %r13, save_r13 |
| 155 | mov %r14, save_r14 |
| 156 | mov %r15, save_r15 |
| 157 | |
| 158 | /* uInt wmask = s->w_mask; */ |
| 159 | /* unsigned chain_length = s->max_chain_length; */ |
| 160 | /* if (s->prev_length >= s->good_match) { */ |
| 161 | /* chain_length >>= 2; */ |
| 162 | /* } */ |
| 163 | |
| 164 | movl dsPrevLen, %eax |
| 165 | movl dsGoodMatch, %ebx |
| 166 | cmpl %ebx, %eax |
| 167 | movl dsWMask, %eax |
| 168 | movl dsMaxChainLen, %chainlenwmask |
| 169 | jl LastMatchGood |
| 170 | shrl $2, %chainlenwmask |
| 171 | LastMatchGood: |
| 172 | |
| 173 | /* chainlen is decremented once beforehand so that the function can */ |
| 174 | /* use the sign flag instead of the zero flag for the exit test. */ |
| 175 | /* It is then shifted into the high word, to make room for the wmask */ |
| 176 | /* value, which it will always accompany. */ |
| 177 | |
| 178 | decl %chainlenwmask |
| 179 | shll $16, %chainlenwmask |
| 180 | orl %eax, %chainlenwmask |
| 181 | |
| 182 | /* if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; */ |
| 183 | |
| 184 | movl dsNiceMatch, %eax |
| 185 | movl dsLookahead, %ebx |
| 186 | cmpl %eax, %ebx |
| 187 | jl LookaheadLess |
| 188 | movl %eax, %ebx |
| 189 | LookaheadLess: movl %ebx, %nicematch |
| 190 | |
| 191 | /* register Bytef *scan = s->window + s->strstart; */ |
| 192 | |
| 193 | mov dsWindow, %window |
| 194 | movl dsStrStart, %limitd |
| 195 | lea (%limit, %window), %scan |
| 196 | |
| 197 | /* Determine how many bytes the scan ptr is off from being */ |
| 198 | /* dword-aligned. */ |
| 199 | |
| 200 | mov %scan, %scanalign |
| 201 | negl %scanalignd |
| 202 | andl $3, %scanalignd |
| 203 | |
| 204 | /* IPos limit = s->strstart > (IPos)MAX_DIST(s) ? */ |
| 205 | /* s->strstart - (IPos)MAX_DIST(s) : NIL; */ |
| 206 | |
| 207 | movl dsWSize, %eax |
| 208 | subl $MIN_LOOKAHEAD, %eax |
| 209 | xorl %ecx, %ecx |
| 210 | subl %eax, %limitd |
| 211 | cmovng %ecx, %limitd |
| 212 | |
| 213 | /* int best_len = s->prev_length; */ |
| 214 | |
| 215 | movl dsPrevLen, %bestlend |
| 216 | |
| 217 | /* Store the sum of s->window + best_len in %windowbestlen locally, and in memory. */ |
| 218 | |
| 219 | lea (%window, %bestlen), %windowbestlen |
| 220 | mov %windowbestlen, _windowbestlen |
| 221 | |
| 222 | /* register ush scan_start = *(ushf*)scan; */ |
| 223 | /* register ush scan_end = *(ushf*)(scan+best_len-1); */ |
| 224 | /* Posf *prev = s->prev; */ |
| 225 | |
| 226 | movzwl (%scan), %scanstart |
| 227 | movzwl -1(%scan, %bestlen), %scanend |
| 228 | mov dsPrev, %prev |
| 229 | |
| 230 | /* Jump into the main loop. */ |
| 231 | |
| 232 | movl %chainlenwmask, _chainlenwmask |
| 233 | jmp LoopEntry |
| 234 | |
| 235 | .balign 16 |
| 236 | |
| 237 | /* do { |
| 238 | * match = s->window + cur_match; |
| 239 | * if (*(ushf*)(match+best_len-1) != scan_end || |
| 240 | * *(ushf*)match != scan_start) continue; |
| 241 | * [...] |
| 242 | * } while ((cur_match = prev[cur_match & wmask]) > limit |
| 243 | * && --chain_length != 0); |
| 244 | * |
| 245 | * Here is the inner loop of the function. The function will spend the |
| 246 | * majority of its time in this loop, and majority of that time will |
| 247 | * be spent in the first ten instructions. |
| 248 | */ |
| 249 | LookupLoop: |
| 250 | andl %chainlenwmask, %curmatchd |
| 251 | movzwl (%prev, %curmatch, 2), %curmatchd |
| 252 | cmpl %limitd, %curmatchd |
| 253 | jbe LeaveNow |
| 254 | subl $0x00010000, %chainlenwmask |
| 255 | js LeaveNow |
| 256 | LoopEntry: cmpw -1(%windowbestlen, %curmatch), %scanendw |
| 257 | jne LookupLoop |
| 258 | cmpw %scanstartw, (%window, %curmatch) |
| 259 | jne LookupLoop |
| 260 | |
| 261 | /* Store the current value of chainlen. */ |
| 262 | movl %chainlenwmask, _chainlenwmask |
| 263 | |
| 264 | /* %scan is the string under scrutiny, and %prev to the string we */ |
| 265 | /* are hoping to match it up with. In actuality, %esi and %edi are */ |
| 266 | /* both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and %edx is */ |
| 267 | /* initialized to -(MAX_MATCH_8 - scanalign). */ |
| 268 | |
| 269 | mov $(-MAX_MATCH_8), %rdx |
| 270 | lea (%curmatch, %window), %windowbestlen |
| 271 | lea MAX_MATCH_8(%windowbestlen, %scanalign), %windowbestlen |
| 272 | lea MAX_MATCH_8(%scan, %scanalign), %prev |
| 273 | |
| 274 | /* the prefetching below makes very little difference... */ |
| 275 | prefetcht1 (%windowbestlen, %rdx) |
| 276 | prefetcht1 (%prev, %rdx) |
| 277 | |
| 278 | /* |
| 279 | * Test the strings for equality, 8 bytes at a time. At the end, |
| 280 | * adjust %rdx so that it is offset to the exact byte that mismatched. |
| 281 | * |
| 282 | * It should be confessed that this loop usually does not represent |
| 283 | * much of the total running time. Replacing it with a more |
| 284 | * straightforward "rep cmpsb" would not drastically degrade |
| 285 | * performance -- unrolling it, for example, makes no difference. |
| 286 | */ |
| 287 | |
| 288 | #undef USE_SSE /* works, but is 6-7% slower, than non-SSE... */ |
| 289 | |
| 290 | LoopCmps: |
| 291 | #ifdef USE_SSE |
| 292 | /* Preload the SSE registers */ |
| 293 | movdqu (%windowbestlen, %rdx), %xmm1 |
| 294 | movdqu (%prev, %rdx), %xmm2 |
| 295 | pcmpeqb %xmm2, %xmm1 |
| 296 | movdqu 16(%windowbestlen, %rdx), %xmm3 |
| 297 | movdqu 16(%prev, %rdx), %xmm4 |
| 298 | pcmpeqb %xmm4, %xmm3 |
| 299 | movdqu 32(%windowbestlen, %rdx), %xmm5 |
| 300 | movdqu 32(%prev, %rdx), %xmm6 |
| 301 | pcmpeqb %xmm6, %xmm5 |
| 302 | movdqu 48(%windowbestlen, %rdx), %xmm7 |
| 303 | movdqu 48(%prev, %rdx), %xmm8 |
| 304 | pcmpeqb %xmm8, %xmm7 |
| 305 | |
| 306 | /* Check the comparisions' results */ |
| 307 | pmovmskb %xmm1, %rax |
| 308 | notw %ax |
| 309 | bsfw %ax, %ax |
| 310 | jnz LeaveLoopCmps |
| 311 | |
| 312 | /* this is the only iteration of the loop with a possibility of having |
| 313 | incremented rdx by 0x108 (each loop iteration add 16*4 = 0x40 |
| 314 | and (0x40*4)+8=0x108 */ |
| 315 | add $8, %rdx |
| 316 | jz LenMaximum |
| 317 | add $8, %rdx |
| 318 | |
| 319 | |
| 320 | pmovmskb %xmm3, %rax |
| 321 | notw %ax |
| 322 | bsfw %ax, %ax |
| 323 | jnz LeaveLoopCmps |
| 324 | |
| 325 | |
| 326 | add $16, %rdx |
| 327 | |
| 328 | |
| 329 | pmovmskb %xmm5, %rax |
| 330 | notw %ax |
| 331 | bsfw %ax, %ax |
| 332 | jnz LeaveLoopCmps |
| 333 | |
| 334 | add $16, %rdx |
| 335 | |
| 336 | |
| 337 | pmovmskb %xmm7, %rax |
| 338 | notw %ax |
| 339 | bsfw %ax, %ax |
| 340 | jnz LeaveLoopCmps |
| 341 | |
| 342 | add $16, %rdx |
| 343 | |
| 344 | jmp LoopCmps |
| 345 | LeaveLoopCmps: add %rax, %rdx |
| 346 | #else |
| 347 | mov (%windowbestlen, %rdx), %rax |
| 348 | xor (%prev, %rdx), %rax |
| 349 | jnz LeaveLoopCmps |
| 350 | |
| 351 | mov 8(%windowbestlen, %rdx), %rax |
| 352 | xor 8(%prev, %rdx), %rax |
| 353 | jnz LeaveLoopCmps8 |
| 354 | |
| 355 | mov 16(%windowbestlen, %rdx), %rax |
| 356 | xor 16(%prev, %rdx), %rax |
| 357 | jnz LeaveLoopCmps16 |
| 358 | |
| 359 | add $24, %rdx |
| 360 | jnz LoopCmps |
| 361 | jmp LenMaximum |
| 362 | # if 0 |
| 363 | /* |
| 364 | * This three-liner is tantalizingly simple, but bsf is a slow instruction, |
| 365 | * and the complicated alternative down below is quite a bit faster. Sad... |
| 366 | */ |
| 367 | |
| 368 | LeaveLoopCmps: bsf %rax, %rax /* find the first non-zero bit */ |
| 369 | shrl $3, %eax /* divide by 8 to get the byte */ |
| 370 | add %rax, %rdx |
| 371 | # else |
| 372 | LeaveLoopCmps16: |
| 373 | add $8, %rdx |
| 374 | LeaveLoopCmps8: |
| 375 | add $8, %rdx |
| 376 | LeaveLoopCmps: testl $0xFFFFFFFF, %eax /* Check the first 4 bytes */ |
| 377 | jnz Check16 |
| 378 | add $4, %rdx |
| 379 | shr $32, %rax |
| 380 | Check16: testw $0xFFFF, %ax |
| 381 | jnz LenLower |
| 382 | add $2, %rdx |
| 383 | shrl $16, %eax |
| 384 | LenLower: subb $1, %al |
| 385 | adc $0, %rdx |
| 386 | # endif |
| 387 | #endif |
| 388 | |
| 389 | /* Calculate the length of the match. If it is longer than MAX_MATCH, */ |
| 390 | /* then automatically accept it as the best possible match and leave. */ |
| 391 | |
| 392 | lea (%prev, %rdx), %rax |
| 393 | sub %scan, %rax |
| 394 | cmpl $MAX_MATCH, %eax |
| 395 | jge LenMaximum |
| 396 | |
| 397 | /* If the length of the match is not longer than the best match we */ |
| 398 | /* have so far, then forget it and return to the lookup loop. */ |
| 399 | |
| 400 | cmpl %bestlend, %eax |
| 401 | jg LongerMatch |
| 402 | mov _windowbestlen, %windowbestlen |
| 403 | mov dsPrev, %prev |
| 404 | movl _chainlenwmask, %edx |
| 405 | jmp LookupLoop |
| 406 | |
| 407 | /* s->match_start = cur_match; */ |
| 408 | /* best_len = len; */ |
| 409 | /* if (len >= nice_match) break; */ |
| 410 | /* scan_end = *(ushf*)(scan+best_len-1); */ |
| 411 | |
| 412 | LongerMatch: |
| 413 | movl %eax, %bestlend |
| 414 | movl %curmatchd, dsMatchStart |
| 415 | cmpl %nicematch, %eax |
| 416 | jge LeaveNow |
| 417 | |
| 418 | lea (%window, %bestlen), %windowbestlen |
| 419 | mov %windowbestlen, _windowbestlen |
| 420 | |
| 421 | movzwl -1(%scan, %rax), %scanend |
| 422 | mov dsPrev, %prev |
| 423 | movl _chainlenwmask, %chainlenwmask |
| 424 | jmp LookupLoop |
| 425 | |
| 426 | /* Accept the current string, with the maximum possible length. */ |
| 427 | |
| 428 | LenMaximum: |
| 429 | movl $MAX_MATCH, %bestlend |
| 430 | movl %curmatchd, dsMatchStart |
| 431 | |
| 432 | /* if ((uInt)best_len <= s->lookahead) return (uInt)best_len; */ |
| 433 | /* return s->lookahead; */ |
| 434 | |
| 435 | LeaveNow: |
| 436 | movl dsLookahead, %eax |
| 437 | cmpl %eax, %bestlend |
| 438 | cmovngl %bestlend, %eax |
| 439 | LookaheadRet: |
| 440 | |
| 441 | /* Restore the registers and return from whence we came. */ |
| 442 | |
| 443 | mov save_rsi, %rsi |
| 444 | mov save_rbx, %rbx |
| 445 | mov save_r12, %r12 |
| 446 | mov save_r13, %r13 |
| 447 | mov save_r14, %r14 |
| 448 | mov save_r15, %r15 |
| 449 | |
| 450 | ret |
| 451 | |
| 452 | match_init: ret |
| --- a/compat/zlib/contrib/amd64/amd64-match.S | |
| +++ b/compat/zlib/contrib/amd64/amd64-match.S | |
| @@ -1,452 +0,0 @@ | |