finishm 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.gitmodules +3 -0
- data/.rspec +1 -0
- data/Gemfile +31 -0
- data/LICENSE.txt +20 -0
- data/README.md +59 -0
- data/Rakefile +51 -0
- data/VERSION +1 -0
- data/bin/assembly_visualiser +106 -0
- data/bin/check_primer_combinations.rb +73 -0
- data/bin/contig_joiner.rb +244 -0
- data/bin/contigs_against_assembly.rb +153 -0
- data/bin/finishm +143 -0
- data/bin/finishm_assembler +55 -0
- data/bin/finishm_gap_closer.rb +241 -0
- data/bin/kmer_abundance_file_tool.rb +49 -0
- data/bin/kmer_pattern_to_assembly.rb +377 -0
- data/bin/kmer_profile_finder.rb +92 -0
- data/bin/kmers_count_parse.d +52 -0
- data/bin/kmers_count_tabulate.d +123 -0
- data/bin/kmers_count_tabulate.rb +84 -0
- data/bin/pcr_result_parser.rb +108 -0
- data/bin/primer_finder.rb +119 -0
- data/bin/read_selection_by_kmer.d +174 -0
- data/bin/scaffold_by_pattern.rb +119 -0
- data/bin/scaffold_connection_possibilities_to_knowns.rb +193 -0
- data/bin/scaffold_end_coverages.rb +69 -0
- data/bin/trail_validator.rb +84 -0
- data/ext/mkrf_conf.rb +56 -0
- data/ext/src/Makefile +140 -0
- data/ext/src/src/allocArray.c +305 -0
- data/ext/src/src/allocArray.h +86 -0
- data/ext/src/src/autoOpen.c +107 -0
- data/ext/src/src/autoOpen.h +18 -0
- data/ext/src/src/binarySequences.c +813 -0
- data/ext/src/src/binarySequences.h +125 -0
- data/ext/src/src/concatenatedGraph.c +233 -0
- data/ext/src/src/concatenatedGraph.h +30 -0
- data/ext/src/src/concatenatedPreGraph.c +262 -0
- data/ext/src/src/concatenatedPreGraph.h +29 -0
- data/ext/src/src/correctedGraph.c +2643 -0
- data/ext/src/src/correctedGraph.h +32 -0
- data/ext/src/src/dfib.c +509 -0
- data/ext/src/src/dfib.h +69 -0
- data/ext/src/src/dfibHeap.c +89 -0
- data/ext/src/src/dfibHeap.h +39 -0
- data/ext/src/src/dfibpriv.h +105 -0
- data/ext/src/src/fib.c +628 -0
- data/ext/src/src/fib.h +78 -0
- data/ext/src/src/fibHeap.c +79 -0
- data/ext/src/src/fibHeap.h +41 -0
- data/ext/src/src/fibpriv.h +110 -0
- data/ext/src/src/globals.h +154 -0
- data/ext/src/src/graph.c +3932 -0
- data/ext/src/src/graph.h +233 -0
- data/ext/src/src/graphReConstruction.c +1472 -0
- data/ext/src/src/graphReConstruction.h +30 -0
- data/ext/src/src/graphStats.c +2167 -0
- data/ext/src/src/graphStats.h +72 -0
- data/ext/src/src/graphStructures.h +52 -0
- data/ext/src/src/kmer.c +652 -0
- data/ext/src/src/kmer.h +73 -0
- data/ext/src/src/kmerOccurenceTable.c +236 -0
- data/ext/src/src/kmerOccurenceTable.h +44 -0
- data/ext/src/src/kseq.h +223 -0
- data/ext/src/src/locallyCorrectedGraph.c +557 -0
- data/ext/src/src/locallyCorrectedGraph.h +40 -0
- data/ext/src/src/passageMarker.c +677 -0
- data/ext/src/src/passageMarker.h +137 -0
- data/ext/src/src/preGraph.c +1717 -0
- data/ext/src/src/preGraph.h +106 -0
- data/ext/src/src/preGraphConstruction.c +990 -0
- data/ext/src/src/preGraphConstruction.h +26 -0
- data/ext/src/src/probe_node_finder.c +84 -0
- data/ext/src/src/probe_node_finder.h +6 -0
- data/ext/src/src/readCoherentGraph.c +557 -0
- data/ext/src/src/readCoherentGraph.h +30 -0
- data/ext/src/src/readSet.c +1734 -0
- data/ext/src/src/readSet.h +67 -0
- data/ext/src/src/readToNode.c +218 -0
- data/ext/src/src/readToNode.h +35 -0
- data/ext/src/src/recycleBin.c +199 -0
- data/ext/src/src/recycleBin.h +58 -0
- data/ext/src/src/roadMap.c +342 -0
- data/ext/src/src/roadMap.h +65 -0
- data/ext/src/src/run.c +318 -0
- data/ext/src/src/run.h +52 -0
- data/ext/src/src/run2.c +744 -0
- data/ext/src/src/runReadToNode.c +29 -0
- data/ext/src/src/scaffold.c +1876 -0
- data/ext/src/src/scaffold.h +64 -0
- data/ext/src/src/shortReadPairs.c +1243 -0
- data/ext/src/src/shortReadPairs.h +32 -0
- data/ext/src/src/splay.c +259 -0
- data/ext/src/src/splay.h +43 -0
- data/ext/src/src/splayTable.c +1315 -0
- data/ext/src/src/splayTable.h +31 -0
- data/ext/src/src/tightString.c +362 -0
- data/ext/src/src/tightString.h +82 -0
- data/ext/src/src/utility.c +199 -0
- data/ext/src/src/utility.h +98 -0
- data/ext/src/third-party/zlib-1.2.3/ChangeLog +855 -0
- data/ext/src/third-party/zlib-1.2.3/FAQ +339 -0
- data/ext/src/third-party/zlib-1.2.3/INDEX +51 -0
- data/ext/src/third-party/zlib-1.2.3/Makefile +154 -0
- data/ext/src/third-party/zlib-1.2.3/Makefile.in +154 -0
- data/ext/src/third-party/zlib-1.2.3/README +125 -0
- data/ext/src/third-party/zlib-1.2.3/adler32.c +149 -0
- data/ext/src/third-party/zlib-1.2.3/adler32.o +0 -0
- data/ext/src/third-party/zlib-1.2.3/algorithm.txt +209 -0
- data/ext/src/third-party/zlib-1.2.3/amiga/Makefile.pup +66 -0
- data/ext/src/third-party/zlib-1.2.3/amiga/Makefile.sas +65 -0
- data/ext/src/third-party/zlib-1.2.3/as400/bndsrc +132 -0
- data/ext/src/third-party/zlib-1.2.3/as400/compile.clp +123 -0
- data/ext/src/third-party/zlib-1.2.3/as400/readme.txt +111 -0
- data/ext/src/third-party/zlib-1.2.3/as400/zlib.inc +331 -0
- data/ext/src/third-party/zlib-1.2.3/compress.c +79 -0
- data/ext/src/third-party/zlib-1.2.3/compress.o +0 -0
- data/ext/src/third-party/zlib-1.2.3/configure +459 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/README.contrib +71 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/buffer_demo.adb +106 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/mtest.adb +156 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/read.adb +156 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/readme.txt +65 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/test.adb +463 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/zlib-streams.adb +225 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/zlib-streams.ads +114 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/zlib-thin.adb +141 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/zlib-thin.ads +450 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/zlib.adb +701 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/zlib.ads +328 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/zlib.gpr +20 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/asm586/README.586 +43 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/asm586/match.S +364 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/asm686/README.686 +34 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/asm686/match.S +329 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/blast/Makefile +8 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/blast/README +4 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/blast/blast.c +444 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/blast/blast.h +71 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/blast/test.pk +0 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/blast/test.txt +1 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/delphi/ZLib.pas +557 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/delphi/ZLibConst.pas +11 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/delphi/readme.txt +76 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/delphi/zlibd32.mak +93 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib.build +33 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib.chm +0 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib.sln +21 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/AssemblyInfo.cs +58 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/ChecksumImpl.cs +202 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/CircularBuffer.cs +83 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/CodecBase.cs +198 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/Deflater.cs +106 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/DotZLib.cs +288 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/DotZLib.csproj +141 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/GZipStream.cs +301 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/Inflater.cs +105 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/UnitTests.cs +274 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/LICENSE_1_0.txt +23 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/readme.txt +58 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/infback9/README +1 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/infback9/infback9.c +608 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/infback9/infback9.h +37 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/infback9/inffix9.h +107 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/infback9/inflate9.h +47 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/infback9/inftree9.c +323 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/infback9/inftree9.h +55 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/inflate86/inffas86.c +1157 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/inflate86/inffast.S +1368 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/iostream/test.cpp +24 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/iostream/zfstream.cpp +329 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/iostream/zfstream.h +128 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/iostream2/zstream.h +307 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/iostream2/zstream_test.cpp +25 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/iostream3/README +35 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/iostream3/TODO +17 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/iostream3/test.cc +50 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/iostream3/zfstream.cc +479 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/iostream3/zfstream.h +466 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masm686/match.asm +413 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx64/bld_ml64.bat +2 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx64/gvmat64.asm +513 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx64/gvmat64.obj +0 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx64/inffas8664.c +186 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx64/inffasx64.asm +392 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx64/inffasx64.obj +0 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx64/readme.txt +28 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/bld_ml32.bat +2 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/gvmat32.asm +972 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/gvmat32.obj +0 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/gvmat32c.c +62 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/inffas32.asm +1083 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/inffas32.obj +0 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/mkasm.bat +3 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/readme.txt +21 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/ChangeLogUnzip +67 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/Makefile +25 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/crypt.h +132 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/ioapi.c +177 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/ioapi.h +75 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/iowin32.c +270 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/iowin32.h +21 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/miniunz.c +585 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/minizip.c +420 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/mztools.c +281 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/mztools.h +31 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/unzip.c +1598 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/unzip.h +354 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/zip.c +1219 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/zip.h +235 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/pascal/example.pas +599 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/pascal/readme.txt +76 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/pascal/zlibd32.mak +93 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/pascal/zlibpas.pas +236 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/puff/Makefile +8 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/puff/README +63 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/puff/puff.c +837 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/puff/puff.h +31 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/puff/zeros.raw +0 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/testzlib/testzlib.c +275 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/testzlib/testzlib.txt +10 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/untgz/Makefile +14 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/untgz/Makefile.msc +17 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/untgz/untgz.c +674 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/readme.txt +73 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/miniunz.vcproj +126 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/minizip.vcproj +126 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/testzlib.vcproj +126 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/zlib.rc +32 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/zlibstat.vcproj +246 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/zlibvc.def +92 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/zlibvc.sln +78 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/zlibvc.vcproj +445 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/miniunz.vcproj +566 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/minizip.vcproj +563 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/testzlib.vcproj +948 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/testzlibdll.vcproj +567 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/zlib.rc +32 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/zlibstat.vcproj +870 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/zlibvc.def +92 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/zlibvc.sln +144 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/zlibvc.vcproj +1219 -0
- data/ext/src/third-party/zlib-1.2.3/crc32.c +423 -0
- data/ext/src/third-party/zlib-1.2.3/crc32.h +441 -0
- data/ext/src/third-party/zlib-1.2.3/crc32.o +0 -0
- data/ext/src/third-party/zlib-1.2.3/deflate.c +1736 -0
- data/ext/src/third-party/zlib-1.2.3/deflate.h +331 -0
- data/ext/src/third-party/zlib-1.2.3/deflate.o +0 -0
- data/ext/src/third-party/zlib-1.2.3/example +0 -0
- data/ext/src/third-party/zlib-1.2.3/example.c +565 -0
- data/ext/src/third-party/zlib-1.2.3/examples/README.examples +42 -0
- data/ext/src/third-party/zlib-1.2.3/examples/fitblk.c +233 -0
- data/ext/src/third-party/zlib-1.2.3/examples/gun.c +693 -0
- data/ext/src/third-party/zlib-1.2.3/examples/gzappend.c +500 -0
- data/ext/src/third-party/zlib-1.2.3/examples/gzjoin.c +448 -0
- data/ext/src/third-party/zlib-1.2.3/examples/gzlog.c +413 -0
- data/ext/src/third-party/zlib-1.2.3/examples/gzlog.h +58 -0
- data/ext/src/third-party/zlib-1.2.3/examples/zlib_how.html +523 -0
- data/ext/src/third-party/zlib-1.2.3/examples/zpipe.c +191 -0
- data/ext/src/third-party/zlib-1.2.3/examples/zran.c +404 -0
- data/ext/src/third-party/zlib-1.2.3/gzio.c +1026 -0
- data/ext/src/third-party/zlib-1.2.3/gzio.o +0 -0
- data/ext/src/third-party/zlib-1.2.3/infback.c +623 -0
- data/ext/src/third-party/zlib-1.2.3/infback.o +0 -0
- data/ext/src/third-party/zlib-1.2.3/inffast.c +318 -0
- data/ext/src/third-party/zlib-1.2.3/inffast.h +11 -0
- data/ext/src/third-party/zlib-1.2.3/inffast.o +0 -0
- data/ext/src/third-party/zlib-1.2.3/inffixed.h +94 -0
- data/ext/src/third-party/zlib-1.2.3/inflate.c +1368 -0
- data/ext/src/third-party/zlib-1.2.3/inflate.h +115 -0
- data/ext/src/third-party/zlib-1.2.3/inflate.o +0 -0
- data/ext/src/third-party/zlib-1.2.3/inftrees.c +329 -0
- data/ext/src/third-party/zlib-1.2.3/inftrees.h +55 -0
- data/ext/src/third-party/zlib-1.2.3/inftrees.o +0 -0
- data/ext/src/third-party/zlib-1.2.3/libz.a +0 -0
- data/ext/src/third-party/zlib-1.2.3/make_vms.com +461 -0
- data/ext/src/third-party/zlib-1.2.3/minigzip +0 -0
- data/ext/src/third-party/zlib-1.2.3/minigzip.c +322 -0
- data/ext/src/third-party/zlib-1.2.3/msdos/Makefile.bor +109 -0
- data/ext/src/third-party/zlib-1.2.3/msdos/Makefile.dj2 +104 -0
- data/ext/src/third-party/zlib-1.2.3/msdos/Makefile.emx +69 -0
- data/ext/src/third-party/zlib-1.2.3/msdos/Makefile.msc +106 -0
- data/ext/src/third-party/zlib-1.2.3/msdos/Makefile.tc +94 -0
- data/ext/src/third-party/zlib-1.2.3/old/Makefile.riscos +151 -0
- data/ext/src/third-party/zlib-1.2.3/old/README +3 -0
- data/ext/src/third-party/zlib-1.2.3/old/descrip.mms +48 -0
- data/ext/src/third-party/zlib-1.2.3/old/os2/Makefile.os2 +136 -0
- data/ext/src/third-party/zlib-1.2.3/old/os2/zlib.def +51 -0
- data/ext/src/third-party/zlib-1.2.3/old/visual-basic.txt +160 -0
- data/ext/src/third-party/zlib-1.2.3/old/zlib.html +971 -0
- data/ext/src/third-party/zlib-1.2.3/projects/README.projects +41 -0
- data/ext/src/third-party/zlib-1.2.3/projects/visualc6/README.txt +73 -0
- data/ext/src/third-party/zlib-1.2.3/projects/visualc6/example.dsp +278 -0
- data/ext/src/third-party/zlib-1.2.3/projects/visualc6/minigzip.dsp +278 -0
- data/ext/src/third-party/zlib-1.2.3/projects/visualc6/zlib.dsp +609 -0
- data/ext/src/third-party/zlib-1.2.3/projects/visualc6/zlib.dsw +59 -0
- data/ext/src/third-party/zlib-1.2.3/qnx/package.qpg +141 -0
- data/ext/src/third-party/zlib-1.2.3/trees.c +1219 -0
- data/ext/src/third-party/zlib-1.2.3/trees.h +128 -0
- data/ext/src/third-party/zlib-1.2.3/trees.o +0 -0
- data/ext/src/third-party/zlib-1.2.3/uncompr.c +61 -0
- data/ext/src/third-party/zlib-1.2.3/uncompr.o +0 -0
- data/ext/src/third-party/zlib-1.2.3/win32/DLL_FAQ.txt +397 -0
- data/ext/src/third-party/zlib-1.2.3/win32/Makefile.bor +107 -0
- data/ext/src/third-party/zlib-1.2.3/win32/Makefile.emx +69 -0
- data/ext/src/third-party/zlib-1.2.3/win32/Makefile.gcc +141 -0
- data/ext/src/third-party/zlib-1.2.3/win32/Makefile.msc +126 -0
- data/ext/src/third-party/zlib-1.2.3/win32/VisualC.txt +3 -0
- data/ext/src/third-party/zlib-1.2.3/win32/zlib.def +60 -0
- data/ext/src/third-party/zlib-1.2.3/win32/zlib1.rc +39 -0
- data/ext/src/third-party/zlib-1.2.3/zconf.h +332 -0
- data/ext/src/third-party/zlib-1.2.3/zconf.in.h +332 -0
- data/ext/src/third-party/zlib-1.2.3/zlib.3 +159 -0
- data/ext/src/third-party/zlib-1.2.3/zlib.h +1357 -0
- data/ext/src/third-party/zlib-1.2.3/zutil.c +318 -0
- data/ext/src/third-party/zlib-1.2.3/zutil.h +269 -0
- data/ext/src/third-party/zlib-1.2.3/zutil.o +0 -0
- data/lib/assembly/a_b_visualiser.rb +169 -0
- data/lib/assembly/acyclic_connection_finder.rb +81 -0
- data/lib/assembly/all_orfs.rb +615 -0
- data/lib/assembly/bad_format_writer.rb +46 -0
- data/lib/assembly/bam_probe_read_selector.rb +48 -0
- data/lib/assembly/bubbly_assembler.rb +842 -0
- data/lib/assembly/c_probe_node_finder.rb +38 -0
- data/lib/assembly/connection_interpreter.rb +350 -0
- data/lib/assembly/contig_printer.rb +400 -0
- data/lib/assembly/coverage_based_graph_filter.rb +68 -0
- data/lib/assembly/depth_first_search.rb +63 -0
- data/lib/assembly/dijkstra.rb +216 -0
- data/lib/assembly/fluffer.rb +253 -0
- data/lib/assembly/graph_explorer.rb +85 -0
- data/lib/assembly/graph_generator.rb +315 -0
- data/lib/assembly/height_finder.rb +355 -0
- data/lib/assembly/hybrid_velvet_graph.rb +70 -0
- data/lib/assembly/input_genome.rb +182 -0
- data/lib/assembly/kmer_coverage_based_path_filter.rb +65 -0
- data/lib/assembly/node_finder.rb +171 -0
- data/lib/assembly/oriented_node_trail.rb +507 -0
- data/lib/assembly/paired_end_assembler.rb +53 -0
- data/lib/assembly/paired_end_neighbour_finder.rb +176 -0
- data/lib/assembly/probed_graph.rb +105 -0
- data/lib/assembly/read_input.rb +79 -0
- data/lib/assembly/read_to_node.rb +37 -0
- data/lib/assembly/scaffold_breaker.rb +126 -0
- data/lib/assembly/sequence_hasher.rb +71 -0
- data/lib/assembly/single_coherent_paths_between_nodes.rb +533 -0
- data/lib/assembly/single_coherent_wanderer.rb +261 -0
- data/lib/assembly/single_ended_assembler.rb +441 -0
- data/lib/assembly/velvet_c_binding.rb +54 -0
- data/lib/assembly/velvet_graph_sequence_extractor.rb +123 -0
- data/lib/external/VERSION +1 -0
- data/lib/finishm/assemble.rb +224 -0
- data/lib/finishm/explore.rb +217 -0
- data/lib/finishm/finisher.rb +303 -0
- data/lib/finishm/fluff.rb +122 -0
- data/lib/finishm/gapfiller.rb +325 -0
- data/lib/finishm/orfs_finder.rb +88 -0
- data/lib/finishm/path_counter.rb +90 -0
- data/lib/finishm/primers.rb +425 -0
- data/lib/finishm/primers_check.rb +176 -0
- data/lib/finishm/roundup.rb +344 -0
- data/lib/finishm/sequence.rb +142 -0
- data/lib/finishm/visualise.rb +430 -0
- data/lib/finishm/wander.rb +270 -0
- data/lib/kmer_abundance_pattern.rb +79 -0
- data/lib/kmer_multi_abundance_file.rb +48 -0
- data/lib/oligo_designer.rb +88 -0
- data/lib/priner.rb +66 -0
- data/spec/acyclic_connection_finder_spec.rb +551 -0
- data/spec/all_orfs_spec.rb +443 -0
- data/spec/assemble_spec.rb +186 -0
- data/spec/bubbly_assembler_spec.rb +707 -0
- data/spec/c_node_finder_spec.rb +58 -0
- data/spec/connection_interpreter_spec.rb +284 -0
- data/spec/contig_printer_spec.rb +291 -0
- data/spec/coverage_based_graph_filter_spec.rb +102 -0
- data/spec/data/6_3e4e5e6e.1vANME.bam +0 -0
- data/spec/data/6_3e4e5e6e.1vANME.bam.bai +0 -0
- data/spec/data/acyclic_connection_finder/1/probes.fa +5 -0
- data/spec/data/acyclic_connection_finder/1/random1.fa +2 -0
- data/spec/data/acyclic_connection_finder/1/random1.sammy.fa.gz +0 -0
- data/spec/data/acyclic_connection_finder/1/random2.fa +2 -0
- data/spec/data/acyclic_connection_finder/1/random2.sammy.fa.gz +0 -0
- data/spec/data/assembly/1_simple_bubble_uneven_coverage/random3000.fa +39 -0
- data/spec/data/assembly/1_simple_bubble_uneven_coverage/random3000.slightly_changed.fa +39 -0
- data/spec/data/assembly/1_simple_bubble_uneven_coverage/reads_combined.fa.gz +0 -0
- data/spec/data/assembly_visualiser/Contig_6_1_to_250.fa.kmers31 +220 -0
- data/spec/data/assembly_visualiser/Contig_7_1_to_250.fa.kmers31 +220 -0
- data/spec/data/assembly_visualiser/Graph +46 -0
- data/spec/data/assembly_visualiser/start_kmers1 +2 -0
- data/spec/data/bands.csv +1 -0
- data/spec/data/c_probe_node_finder/1/CnyUnifiedSeq +0 -0
- data/spec/data/c_probe_node_finder/1/CnyUnifiedSeq.names +544 -0
- data/spec/data/c_probe_node_finder/1/Graph2 +668 -0
- data/spec/data/c_probe_node_finder/1/LastGraph +668 -0
- data/spec/data/c_probe_node_finder/1/Log +756 -0
- data/spec/data/c_probe_node_finder/1/PreGraph +11 -0
- data/spec/data/c_probe_node_finder/1/Roadmaps +2009 -0
- data/spec/data/c_probe_node_finder/1/contigs.fa +29 -0
- data/spec/data/c_probe_node_finder/1/stats.txt +6 -0
- data/spec/data/contig_printer/1/HOWTO_RECREATE +17 -0
- data/spec/data/contig_printer/1/contigs.fa +4 -0
- data/spec/data/contig_printer/1/seq.fa +2408 -0
- data/spec/data/contig_printer/1/seq.fa.svg +153 -0
- data/spec/data/contig_printer/1/seq.fa.velvet/Graph2 +2953 -0
- data/spec/data/contig_printer/1/seq.fa.velvet/LastGraph +2953 -0
- data/spec/data/contig_printer/1/seq.fa.velvet/Log +21 -0
- data/spec/data/contig_printer/1/seq.fa.velvet/PreGraph +27 -0
- data/spec/data/contig_printer/1/seq.fa.velvet/Roadmaps +5182 -0
- data/spec/data/contig_printer/1/seq.fa.velvet/Sequences +3612 -0
- data/spec/data/contig_printer/1/seq.fa.velvet/contigs.fa +36 -0
- data/spec/data/contig_printer/1/seq.fa.velvet/stats.txt +14 -0
- data/spec/data/contig_printer/1/seq.faVseq2_1to550.fa.bam +0 -0
- data/spec/data/contig_printer/1/seq.faVseq2_1to550.fa.bam.bai +0 -0
- data/spec/data/contig_printer/1/seq.node12.fa +4 -0
- data/spec/data/contig_printer/1/seq1_1to550.fa +2 -0
- data/spec/data/contig_printer/1/seq2_1to550.fa +2 -0
- data/spec/data/contig_printer/1/seq2_1to550.fa.fai +1 -0
- data/spec/data/explore/1/2seqs.sammy.fa +12004 -0
- data/spec/data/explore/1/HOWTO_RECREATE.txt +6 -0
- data/spec/data/explore/1/a.fa +2 -0
- data/spec/data/explore/1/seq1_and_a.fa +3 -0
- data/spec/data/explore/1/seq2.fa +2 -0
- data/spec/data/fluff/1/2seqs.sammy.fa +12004 -0
- data/spec/data/fluff/1/HOWTO_RECREATE.txt +5 -0
- data/spec/data/fluff/1/seq1.fa +2 -0
- data/spec/data/fluff/1/seq2.fa +2 -0
- data/spec/data/gapfilling/1/reads.fa +171 -0
- data/spec/data/gapfilling/1/trail_with_Ns.fa +5 -0
- data/spec/data/gapfilling/1/velvetAssembly/Graph2 +130 -0
- data/spec/data/gapfilling/1/velvetAssembly/LastGraph +130 -0
- data/spec/data/gapfilling/1/velvetAssembly/Log +199 -0
- data/spec/data/gapfilling/1/velvetAssembly/PreGraph +7 -0
- data/spec/data/gapfilling/1/velvetAssembly/Roadmaps +239 -0
- data/spec/data/gapfilling/1/velvetAssembly/Sequences +281 -0
- data/spec/data/gapfilling/1/velvetAssembly/contigs.fa +12 -0
- data/spec/data/gapfilling/1/velvetAssembly/stats.txt +4 -0
- data/spec/data/gapfilling/2/HOWTO_recreate +17 -0
- data/spec/data/gapfilling/2/reference.fa +2 -0
- data/spec/data/gapfilling/2/reference_part1.fa +4 -0
- data/spec/data/gapfilling/2/reference_part2.fa +4 -0
- data/spec/data/gapfilling/2/sammy_reads.fa.gz +0 -0
- data/spec/data/gapfilling/2/with_gaps.fa +4 -0
- data/spec/data/gapfilling/3/HOWTO_recreate +4 -0
- data/spec/data/gapfilling/3/reads.fa.gz +0 -0
- data/spec/data/gapfilling/3/reference_part1.fa +4 -0
- data/spec/data/gapfilling/3/reference_part2.fa +4 -0
- data/spec/data/gapfilling/3/with_gaps.fa +4 -0
- data/spec/data/gapfilling/4/HOWTO_recreate +1 -0
- data/spec/data/gapfilling/4/reads.fa.gz +0 -0
- data/spec/data/gapfilling/5/HOWTO_RECREATE +7 -0
- data/spec/data/gapfilling/5/answer.fna +2 -0
- data/spec/data/gapfilling/5/gappy.fna +2 -0
- data/spec/data/gapfilling/5/reads.fa +17961 -0
- data/spec/data/gapfilling/5/velvet51_3.5/LastGraph +8337 -0
- data/spec/data/gapfilling/5/velvet51_3.5/Sequences +20921 -0
- data/spec/data/gapfilling/6/random1.fa +28 -0
- data/spec/data/gapfilling/6/random2.fa +28 -0
- data/spec/data/gapfilling/6/random_sequence_length_2000 +0 -0
- data/spec/data/gapfilling/6/reads.random1.fa.gz +0 -0
- data/spec/data/gapfilling/6/reads.random2.fa.gz +0 -0
- data/spec/data/gapfilling/6/to_gapfill.fa +22 -0
- data/spec/data/kmer_profile_to_assembly/multiple_abundance_file1.csv +2 -0
- data/spec/data/kmers_count1.csv +2 -0
- data/spec/data/kmers_count2.csv +3 -0
- data/spec/data/out +3 -0
- data/spec/data/positive_latching_pair.fa +2 -0
- data/spec/data/primers.csv +4 -0
- data/spec/data/read_selection_by_kmer/blacklist1.txt +1 -0
- data/spec/data/read_selection_by_kmer/input.fasta +6 -0
- data/spec/data/read_selection_by_kmer/whitelist1.txt +1 -0
- data/spec/data/read_selection_by_kmer/whitelist2.txt +2 -0
- data/spec/data/read_to_node/1_a_graph/HOWTO_RECREATE.txt +2 -0
- data/spec/data/read_to_node/1_a_graph/LastGraph +6695 -0
- data/spec/data/read_to_node/1_a_graph/ReadToNode.bin +0 -0
- data/spec/data/read_to_node/2_no_read256_or_259/HOWTO_RECREATE.txt +3 -0
- data/spec/data/read_to_node/2_no_read256_or_259/LastGraph +6693 -0
- data/spec/data/read_to_node/2_no_read256_or_259/ReadToNode.bin +0 -0
- data/spec/data/read_to_node/3_no_last_read/LastGraph +6694 -0
- data/spec/data/read_to_node/3_no_last_read/ReadToNode.bin +0 -0
- data/spec/data/t/details.txt +5 -0
- data/spec/data/t/details.txt.srt +5 -0
- data/spec/data/t/location.txt +3 -0
- data/spec/data/t/location.txt.srt +3 -0
- data/spec/data/tweak/1_gap_then_unscaffolded/answer.fa +2 -0
- data/spec/data/tweak/1_gap_then_unscaffolded/reads.fa.gz +0 -0
- data/spec/data/tweak/1_gap_then_unscaffolded/scaffolds.fa +6 -0
- data/spec/data/tweak/2_second_genome/answer2.fa +2 -0
- data/spec/data/tweak/2_second_genome/reads.fa.gz +0 -0
- data/spec/data/tweak/3_variant/answer.fa +2 -0
- data/spec/data/tweak/3_variant/lesser_answer.fa +2 -0
- data/spec/data/tweak/3_variant/reads.fa.gz +0 -0
- data/spec/data/tweak/3_variant/with_gaps.fa +2 -0
- data/spec/data/velvet_test_trails/Assem/Graph +17 -0
- data/spec/data/velvet_test_trails/Assem/Graph2 +40 -0
- data/spec/data/velvet_test_trails/Assem/LastGraph +40 -0
- data/spec/data/velvet_test_trails/Assem/Log +35 -0
- data/spec/data/velvet_test_trails/Assem/PreGraph +9 -0
- data/spec/data/velvet_test_trails/Assem/Roadmaps +89 -0
- data/spec/data/velvet_test_trails/Assem/Sequences +50 -0
- data/spec/data/velvet_test_trails/Assem/a.svg +53 -0
- data/spec/data/velvet_test_trails/Assem/contigs.fa +15 -0
- data/spec/data/velvet_test_trails/Assem/stats.txt +5 -0
- data/spec/data/velvet_test_trails/node_fwds.fa +8 -0
- data/spec/data/velvet_test_trails/node_seqs.fa +9 -0
- data/spec/data/velvet_test_trails/nodes_fwd_rev.fa +16 -0
- data/spec/data/velvet_test_trails/read1.fa +2 -0
- data/spec/data/velvet_test_trails/reads.fa +50 -0
- data/spec/data/velvet_test_trails_reverse/Assem/LastGraph +17 -0
- data/spec/data/velvet_test_trails_reverse/Assem/a.svg +53 -0
- data/spec/data/velvet_test_trails_reverse/reads_reversed.fa +10 -0
- data/spec/data/visualise/1/LastGraph +6695 -0
- data/spec/data/visualise/2_paired_end/HOWTO_RECREATE.txt +10 -0
- data/spec/data/visualise/2_paired_end/rand1.fa +2 -0
- data/spec/data/visualise/2_paired_end/rand2.fa +2 -0
- data/spec/data/visualise/2_paired_end/with_gaps.fa +8 -0
- data/spec/data/visualise/2_paired_end/with_gaps.read_pairs.fa.gz +0 -0
- data/spec/data/wander/1/random1.fa +2 -0
- data/spec/data/wander/1/random1.sammy.fa +804 -0
- data/spec/depth_first_search_spec.rb +190 -0
- data/spec/dijkstra_spec.rb +143 -0
- data/spec/explore_spec.rb +29 -0
- data/spec/fluffer_spec.rb +155 -0
- data/spec/gapfiller_spec.rb +107 -0
- data/spec/graph_explorer_spec.rb +475 -0
- data/spec/graph_generator_spec.rb +99 -0
- data/spec/height_finder_spec.rb +306 -0
- data/spec/kmer_abundance_pattern_spec.rb +56 -0
- data/spec/kmer_coverage_based_path_filter_spec.rb +73 -0
- data/spec/kmer_profile_finder_spec.rb +38 -0
- data/spec/kmers_count_tabulate_spec.rb +120 -0
- data/spec/oriented_node_trail_spec.rb +221 -0
- data/spec/paired_end_neighbours_spec.rb +126 -0
- data/spec/paths_between_nodes_spec.rb +349 -0
- data/spec/priner_spec.rb +7 -0
- data/spec/read_input_spec.rb +23 -0
- data/spec/read_selection_by_kmer_spec.rb +166 -0
- data/spec/read_to_node_spec.rb +35 -0
- data/spec/roundup_spec.rb +366 -0
- data/spec/scaffold_breaker_spec.rb +144 -0
- data/spec/sequence_spec.rb +43 -0
- data/spec/single_coherent_paths_between_nodes_spec.rb +492 -0
- data/spec/single_coherent_wanderer_spec.rb +120 -0
- data/spec/single_ended_assembler_spec.rb +398 -0
- data/spec/spec_helper.rb +310 -0
- data/spec/velvet_graph_sequence_extractor_spec.rb +80 -0
- data/spec/visualise_spec.rb +105 -0
- data/spec/wander_spec.rb +119 -0
- data/spec/watch_for_changes.sh +16 -0
- data/validation/fasta_compare.rb +72 -0
- data/validation/gapfill_simulate_perfect.rb +108 -0
- metadata +899 -0
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
----------------------------------------------------------------
|
|
2
|
+
-- ZLib for Ada thick binding. --
|
|
3
|
+
-- --
|
|
4
|
+
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
|
|
5
|
+
-- --
|
|
6
|
+
-- Open source license information is in the zlib.ads file. --
|
|
7
|
+
----------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
-- $Id: zlib-thin.ads,v 1.11 2004/07/23 06:33:11 vagul Exp $
|
|
10
|
+
|
|
11
|
+
with Interfaces.C.Strings;
|
|
12
|
+
|
|
13
|
+
with System;
|
|
14
|
+
|
|
15
|
+
private package ZLib.Thin is
|
|
16
|
+
|
|
17
|
+
-- From zconf.h
|
|
18
|
+
|
|
19
|
+
MAX_MEM_LEVEL : constant := 9; -- zconf.h:105
|
|
20
|
+
-- zconf.h:105
|
|
21
|
+
MAX_WBITS : constant := 15; -- zconf.h:115
|
|
22
|
+
-- 32K LZ77 window
|
|
23
|
+
-- zconf.h:115
|
|
24
|
+
SEEK_SET : constant := 8#0000#; -- zconf.h:244
|
|
25
|
+
-- Seek from beginning of file.
|
|
26
|
+
-- zconf.h:244
|
|
27
|
+
SEEK_CUR : constant := 1; -- zconf.h:245
|
|
28
|
+
-- Seek from current position.
|
|
29
|
+
-- zconf.h:245
|
|
30
|
+
SEEK_END : constant := 2; -- zconf.h:246
|
|
31
|
+
-- Set file pointer to EOF plus "offset"
|
|
32
|
+
-- zconf.h:246
|
|
33
|
+
|
|
34
|
+
type Byte is new Interfaces.C.unsigned_char; -- 8 bits
|
|
35
|
+
-- zconf.h:214
|
|
36
|
+
type UInt is new Interfaces.C.unsigned; -- 16 bits or more
|
|
37
|
+
-- zconf.h:216
|
|
38
|
+
type Int is new Interfaces.C.int;
|
|
39
|
+
|
|
40
|
+
type ULong is new Interfaces.C.unsigned_long; -- 32 bits or more
|
|
41
|
+
-- zconf.h:217
|
|
42
|
+
subtype Chars_Ptr is Interfaces.C.Strings.chars_ptr;
|
|
43
|
+
|
|
44
|
+
type ULong_Access is access ULong;
|
|
45
|
+
type Int_Access is access Int;
|
|
46
|
+
|
|
47
|
+
subtype Voidp is System.Address; -- zconf.h:232
|
|
48
|
+
|
|
49
|
+
subtype Byte_Access is Voidp;
|
|
50
|
+
|
|
51
|
+
Nul : constant Voidp := System.Null_Address;
|
|
52
|
+
-- end from zconf
|
|
53
|
+
|
|
54
|
+
Z_NO_FLUSH : constant := 8#0000#; -- zlib.h:125
|
|
55
|
+
-- zlib.h:125
|
|
56
|
+
Z_PARTIAL_FLUSH : constant := 1; -- zlib.h:126
|
|
57
|
+
-- will be removed, use
|
|
58
|
+
-- Z_SYNC_FLUSH instead
|
|
59
|
+
-- zlib.h:126
|
|
60
|
+
Z_SYNC_FLUSH : constant := 2; -- zlib.h:127
|
|
61
|
+
-- zlib.h:127
|
|
62
|
+
Z_FULL_FLUSH : constant := 3; -- zlib.h:128
|
|
63
|
+
-- zlib.h:128
|
|
64
|
+
Z_FINISH : constant := 4; -- zlib.h:129
|
|
65
|
+
-- zlib.h:129
|
|
66
|
+
Z_OK : constant := 8#0000#; -- zlib.h:132
|
|
67
|
+
-- zlib.h:132
|
|
68
|
+
Z_STREAM_END : constant := 1; -- zlib.h:133
|
|
69
|
+
-- zlib.h:133
|
|
70
|
+
Z_NEED_DICT : constant := 2; -- zlib.h:134
|
|
71
|
+
-- zlib.h:134
|
|
72
|
+
Z_ERRNO : constant := -1; -- zlib.h:135
|
|
73
|
+
-- zlib.h:135
|
|
74
|
+
Z_STREAM_ERROR : constant := -2; -- zlib.h:136
|
|
75
|
+
-- zlib.h:136
|
|
76
|
+
Z_DATA_ERROR : constant := -3; -- zlib.h:137
|
|
77
|
+
-- zlib.h:137
|
|
78
|
+
Z_MEM_ERROR : constant := -4; -- zlib.h:138
|
|
79
|
+
-- zlib.h:138
|
|
80
|
+
Z_BUF_ERROR : constant := -5; -- zlib.h:139
|
|
81
|
+
-- zlib.h:139
|
|
82
|
+
Z_VERSION_ERROR : constant := -6; -- zlib.h:140
|
|
83
|
+
-- zlib.h:140
|
|
84
|
+
Z_NO_COMPRESSION : constant := 8#0000#; -- zlib.h:145
|
|
85
|
+
-- zlib.h:145
|
|
86
|
+
Z_BEST_SPEED : constant := 1; -- zlib.h:146
|
|
87
|
+
-- zlib.h:146
|
|
88
|
+
Z_BEST_COMPRESSION : constant := 9; -- zlib.h:147
|
|
89
|
+
-- zlib.h:147
|
|
90
|
+
Z_DEFAULT_COMPRESSION : constant := -1; -- zlib.h:148
|
|
91
|
+
-- zlib.h:148
|
|
92
|
+
Z_FILTERED : constant := 1; -- zlib.h:151
|
|
93
|
+
-- zlib.h:151
|
|
94
|
+
Z_HUFFMAN_ONLY : constant := 2; -- zlib.h:152
|
|
95
|
+
-- zlib.h:152
|
|
96
|
+
Z_DEFAULT_STRATEGY : constant := 8#0000#; -- zlib.h:153
|
|
97
|
+
-- zlib.h:153
|
|
98
|
+
Z_BINARY : constant := 8#0000#; -- zlib.h:156
|
|
99
|
+
-- zlib.h:156
|
|
100
|
+
Z_ASCII : constant := 1; -- zlib.h:157
|
|
101
|
+
-- zlib.h:157
|
|
102
|
+
Z_UNKNOWN : constant := 2; -- zlib.h:158
|
|
103
|
+
-- zlib.h:158
|
|
104
|
+
Z_DEFLATED : constant := 8; -- zlib.h:161
|
|
105
|
+
-- zlib.h:161
|
|
106
|
+
Z_NULL : constant := 8#0000#; -- zlib.h:164
|
|
107
|
+
-- for initializing zalloc, zfree, opaque
|
|
108
|
+
-- zlib.h:164
|
|
109
|
+
type gzFile is new Voidp; -- zlib.h:646
|
|
110
|
+
|
|
111
|
+
type Z_Stream is private;
|
|
112
|
+
|
|
113
|
+
type Z_Streamp is access all Z_Stream; -- zlib.h:89
|
|
114
|
+
|
|
115
|
+
type alloc_func is access function
|
|
116
|
+
(Opaque : Voidp;
|
|
117
|
+
Items : UInt;
|
|
118
|
+
Size : UInt)
|
|
119
|
+
return Voidp; -- zlib.h:63
|
|
120
|
+
|
|
121
|
+
type free_func is access procedure (opaque : Voidp; address : Voidp);
|
|
122
|
+
|
|
123
|
+
function zlibVersion return Chars_Ptr;
|
|
124
|
+
|
|
125
|
+
function Deflate (strm : Z_Streamp; flush : Int) return Int;
|
|
126
|
+
|
|
127
|
+
function DeflateEnd (strm : Z_Streamp) return Int;
|
|
128
|
+
|
|
129
|
+
function Inflate (strm : Z_Streamp; flush : Int) return Int;
|
|
130
|
+
|
|
131
|
+
function InflateEnd (strm : Z_Streamp) return Int;
|
|
132
|
+
|
|
133
|
+
function deflateSetDictionary
|
|
134
|
+
(strm : Z_Streamp;
|
|
135
|
+
dictionary : Byte_Access;
|
|
136
|
+
dictLength : UInt)
|
|
137
|
+
return Int;
|
|
138
|
+
|
|
139
|
+
function deflateCopy (dest : Z_Streamp; source : Z_Streamp) return Int;
|
|
140
|
+
-- zlib.h:478
|
|
141
|
+
|
|
142
|
+
function deflateReset (strm : Z_Streamp) return Int; -- zlib.h:495
|
|
143
|
+
|
|
144
|
+
function deflateParams
|
|
145
|
+
(strm : Z_Streamp;
|
|
146
|
+
level : Int;
|
|
147
|
+
strategy : Int)
|
|
148
|
+
return Int; -- zlib.h:506
|
|
149
|
+
|
|
150
|
+
function inflateSetDictionary
|
|
151
|
+
(strm : Z_Streamp;
|
|
152
|
+
dictionary : Byte_Access;
|
|
153
|
+
dictLength : UInt)
|
|
154
|
+
return Int; -- zlib.h:548
|
|
155
|
+
|
|
156
|
+
function inflateSync (strm : Z_Streamp) return Int; -- zlib.h:565
|
|
157
|
+
|
|
158
|
+
function inflateReset (strm : Z_Streamp) return Int; -- zlib.h:580
|
|
159
|
+
|
|
160
|
+
function compress
|
|
161
|
+
(dest : Byte_Access;
|
|
162
|
+
destLen : ULong_Access;
|
|
163
|
+
source : Byte_Access;
|
|
164
|
+
sourceLen : ULong)
|
|
165
|
+
return Int; -- zlib.h:601
|
|
166
|
+
|
|
167
|
+
function compress2
|
|
168
|
+
(dest : Byte_Access;
|
|
169
|
+
destLen : ULong_Access;
|
|
170
|
+
source : Byte_Access;
|
|
171
|
+
sourceLen : ULong;
|
|
172
|
+
level : Int)
|
|
173
|
+
return Int; -- zlib.h:615
|
|
174
|
+
|
|
175
|
+
function uncompress
|
|
176
|
+
(dest : Byte_Access;
|
|
177
|
+
destLen : ULong_Access;
|
|
178
|
+
source : Byte_Access;
|
|
179
|
+
sourceLen : ULong)
|
|
180
|
+
return Int;
|
|
181
|
+
|
|
182
|
+
function gzopen (path : Chars_Ptr; mode : Chars_Ptr) return gzFile;
|
|
183
|
+
|
|
184
|
+
function gzdopen (fd : Int; mode : Chars_Ptr) return gzFile;
|
|
185
|
+
|
|
186
|
+
function gzsetparams
|
|
187
|
+
(file : gzFile;
|
|
188
|
+
level : Int;
|
|
189
|
+
strategy : Int)
|
|
190
|
+
return Int;
|
|
191
|
+
|
|
192
|
+
function gzread
|
|
193
|
+
(file : gzFile;
|
|
194
|
+
buf : Voidp;
|
|
195
|
+
len : UInt)
|
|
196
|
+
return Int;
|
|
197
|
+
|
|
198
|
+
function gzwrite
|
|
199
|
+
(file : in gzFile;
|
|
200
|
+
buf : in Voidp;
|
|
201
|
+
len : in UInt)
|
|
202
|
+
return Int;
|
|
203
|
+
|
|
204
|
+
function gzprintf (file : in gzFile; format : in Chars_Ptr) return Int;
|
|
205
|
+
|
|
206
|
+
function gzputs (file : in gzFile; s : in Chars_Ptr) return Int;
|
|
207
|
+
|
|
208
|
+
function gzgets
|
|
209
|
+
(file : gzFile;
|
|
210
|
+
buf : Chars_Ptr;
|
|
211
|
+
len : Int)
|
|
212
|
+
return Chars_Ptr;
|
|
213
|
+
|
|
214
|
+
function gzputc (file : gzFile; char : Int) return Int;
|
|
215
|
+
|
|
216
|
+
function gzgetc (file : gzFile) return Int;
|
|
217
|
+
|
|
218
|
+
function gzflush (file : gzFile; flush : Int) return Int;
|
|
219
|
+
|
|
220
|
+
function gzseek
|
|
221
|
+
(file : gzFile;
|
|
222
|
+
offset : Int;
|
|
223
|
+
whence : Int)
|
|
224
|
+
return Int;
|
|
225
|
+
|
|
226
|
+
function gzrewind (file : gzFile) return Int;
|
|
227
|
+
|
|
228
|
+
function gztell (file : gzFile) return Int;
|
|
229
|
+
|
|
230
|
+
function gzeof (file : gzFile) return Int;
|
|
231
|
+
|
|
232
|
+
function gzclose (file : gzFile) return Int;
|
|
233
|
+
|
|
234
|
+
function gzerror (file : gzFile; errnum : Int_Access) return Chars_Ptr;
|
|
235
|
+
|
|
236
|
+
function adler32
|
|
237
|
+
(adler : ULong;
|
|
238
|
+
buf : Byte_Access;
|
|
239
|
+
len : UInt)
|
|
240
|
+
return ULong;
|
|
241
|
+
|
|
242
|
+
function crc32
|
|
243
|
+
(crc : ULong;
|
|
244
|
+
buf : Byte_Access;
|
|
245
|
+
len : UInt)
|
|
246
|
+
return ULong;
|
|
247
|
+
|
|
248
|
+
function deflateInit
|
|
249
|
+
(strm : Z_Streamp;
|
|
250
|
+
level : Int;
|
|
251
|
+
version : Chars_Ptr;
|
|
252
|
+
stream_size : Int)
|
|
253
|
+
return Int;
|
|
254
|
+
|
|
255
|
+
function deflateInit2
|
|
256
|
+
(strm : Z_Streamp;
|
|
257
|
+
level : Int;
|
|
258
|
+
method : Int;
|
|
259
|
+
windowBits : Int;
|
|
260
|
+
memLevel : Int;
|
|
261
|
+
strategy : Int;
|
|
262
|
+
version : Chars_Ptr;
|
|
263
|
+
stream_size : Int)
|
|
264
|
+
return Int;
|
|
265
|
+
|
|
266
|
+
function Deflate_Init
|
|
267
|
+
(strm : Z_Streamp;
|
|
268
|
+
level : Int;
|
|
269
|
+
method : Int;
|
|
270
|
+
windowBits : Int;
|
|
271
|
+
memLevel : Int;
|
|
272
|
+
strategy : Int)
|
|
273
|
+
return Int;
|
|
274
|
+
pragma Inline (Deflate_Init);
|
|
275
|
+
|
|
276
|
+
function inflateInit
|
|
277
|
+
(strm : Z_Streamp;
|
|
278
|
+
version : Chars_Ptr;
|
|
279
|
+
stream_size : Int)
|
|
280
|
+
return Int;
|
|
281
|
+
|
|
282
|
+
function inflateInit2
|
|
283
|
+
(strm : in Z_Streamp;
|
|
284
|
+
windowBits : in Int;
|
|
285
|
+
version : in Chars_Ptr;
|
|
286
|
+
stream_size : in Int)
|
|
287
|
+
return Int;
|
|
288
|
+
|
|
289
|
+
function inflateBackInit
|
|
290
|
+
(strm : in Z_Streamp;
|
|
291
|
+
windowBits : in Int;
|
|
292
|
+
window : in Byte_Access;
|
|
293
|
+
version : in Chars_Ptr;
|
|
294
|
+
stream_size : in Int)
|
|
295
|
+
return Int;
|
|
296
|
+
-- Size of window have to be 2**windowBits.
|
|
297
|
+
|
|
298
|
+
function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int;
|
|
299
|
+
pragma Inline (Inflate_Init);
|
|
300
|
+
|
|
301
|
+
function zError (err : Int) return Chars_Ptr;
|
|
302
|
+
|
|
303
|
+
function inflateSyncPoint (z : Z_Streamp) return Int;
|
|
304
|
+
|
|
305
|
+
function get_crc_table return ULong_Access;
|
|
306
|
+
|
|
307
|
+
-- Interface to the available fields of the z_stream structure.
|
|
308
|
+
-- The application must update next_in and avail_in when avail_in has
|
|
309
|
+
-- dropped to zero. It must update next_out and avail_out when avail_out
|
|
310
|
+
-- has dropped to zero. The application must initialize zalloc, zfree and
|
|
311
|
+
-- opaque before calling the init function.
|
|
312
|
+
|
|
313
|
+
procedure Set_In
|
|
314
|
+
(Strm : in out Z_Stream;
|
|
315
|
+
Buffer : in Voidp;
|
|
316
|
+
Size : in UInt);
|
|
317
|
+
pragma Inline (Set_In);
|
|
318
|
+
|
|
319
|
+
procedure Set_Out
|
|
320
|
+
(Strm : in out Z_Stream;
|
|
321
|
+
Buffer : in Voidp;
|
|
322
|
+
Size : in UInt);
|
|
323
|
+
pragma Inline (Set_Out);
|
|
324
|
+
|
|
325
|
+
procedure Set_Mem_Func
|
|
326
|
+
(Strm : in out Z_Stream;
|
|
327
|
+
Opaque : in Voidp;
|
|
328
|
+
Alloc : in alloc_func;
|
|
329
|
+
Free : in free_func);
|
|
330
|
+
pragma Inline (Set_Mem_Func);
|
|
331
|
+
|
|
332
|
+
function Last_Error_Message (Strm : in Z_Stream) return String;
|
|
333
|
+
pragma Inline (Last_Error_Message);
|
|
334
|
+
|
|
335
|
+
function Avail_Out (Strm : in Z_Stream) return UInt;
|
|
336
|
+
pragma Inline (Avail_Out);
|
|
337
|
+
|
|
338
|
+
function Avail_In (Strm : in Z_Stream) return UInt;
|
|
339
|
+
pragma Inline (Avail_In);
|
|
340
|
+
|
|
341
|
+
function Total_In (Strm : in Z_Stream) return ULong;
|
|
342
|
+
pragma Inline (Total_In);
|
|
343
|
+
|
|
344
|
+
function Total_Out (Strm : in Z_Stream) return ULong;
|
|
345
|
+
pragma Inline (Total_Out);
|
|
346
|
+
|
|
347
|
+
function inflateCopy
|
|
348
|
+
(dest : in Z_Streamp;
|
|
349
|
+
Source : in Z_Streamp)
|
|
350
|
+
return Int;
|
|
351
|
+
|
|
352
|
+
function compressBound (Source_Len : in ULong) return ULong;
|
|
353
|
+
|
|
354
|
+
function deflateBound
|
|
355
|
+
(Strm : in Z_Streamp;
|
|
356
|
+
Source_Len : in ULong)
|
|
357
|
+
return ULong;
|
|
358
|
+
|
|
359
|
+
function gzungetc (C : in Int; File : in gzFile) return Int;
|
|
360
|
+
|
|
361
|
+
function zlibCompileFlags return ULong;
|
|
362
|
+
|
|
363
|
+
private
|
|
364
|
+
|
|
365
|
+
type Z_Stream is record -- zlib.h:68
|
|
366
|
+
Next_In : Voidp := Nul; -- next input byte
|
|
367
|
+
Avail_In : UInt := 0; -- number of bytes available at next_in
|
|
368
|
+
Total_In : ULong := 0; -- total nb of input bytes read so far
|
|
369
|
+
Next_Out : Voidp := Nul; -- next output byte should be put there
|
|
370
|
+
Avail_Out : UInt := 0; -- remaining free space at next_out
|
|
371
|
+
Total_Out : ULong := 0; -- total nb of bytes output so far
|
|
372
|
+
msg : Chars_Ptr; -- last error message, NULL if no error
|
|
373
|
+
state : Voidp; -- not visible by applications
|
|
374
|
+
zalloc : alloc_func := null; -- used to allocate the internal state
|
|
375
|
+
zfree : free_func := null; -- used to free the internal state
|
|
376
|
+
opaque : Voidp; -- private data object passed to
|
|
377
|
+
-- zalloc and zfree
|
|
378
|
+
data_type : Int; -- best guess about the data type:
|
|
379
|
+
-- ascii or binary
|
|
380
|
+
adler : ULong; -- adler32 value of the uncompressed
|
|
381
|
+
-- data
|
|
382
|
+
reserved : ULong; -- reserved for future use
|
|
383
|
+
end record;
|
|
384
|
+
|
|
385
|
+
pragma Convention (C, Z_Stream);
|
|
386
|
+
|
|
387
|
+
pragma Import (C, zlibVersion, "zlibVersion");
|
|
388
|
+
pragma Import (C, Deflate, "deflate");
|
|
389
|
+
pragma Import (C, DeflateEnd, "deflateEnd");
|
|
390
|
+
pragma Import (C, Inflate, "inflate");
|
|
391
|
+
pragma Import (C, InflateEnd, "inflateEnd");
|
|
392
|
+
pragma Import (C, deflateSetDictionary, "deflateSetDictionary");
|
|
393
|
+
pragma Import (C, deflateCopy, "deflateCopy");
|
|
394
|
+
pragma Import (C, deflateReset, "deflateReset");
|
|
395
|
+
pragma Import (C, deflateParams, "deflateParams");
|
|
396
|
+
pragma Import (C, inflateSetDictionary, "inflateSetDictionary");
|
|
397
|
+
pragma Import (C, inflateSync, "inflateSync");
|
|
398
|
+
pragma Import (C, inflateReset, "inflateReset");
|
|
399
|
+
pragma Import (C, compress, "compress");
|
|
400
|
+
pragma Import (C, compress2, "compress2");
|
|
401
|
+
pragma Import (C, uncompress, "uncompress");
|
|
402
|
+
pragma Import (C, gzopen, "gzopen");
|
|
403
|
+
pragma Import (C, gzdopen, "gzdopen");
|
|
404
|
+
pragma Import (C, gzsetparams, "gzsetparams");
|
|
405
|
+
pragma Import (C, gzread, "gzread");
|
|
406
|
+
pragma Import (C, gzwrite, "gzwrite");
|
|
407
|
+
pragma Import (C, gzprintf, "gzprintf");
|
|
408
|
+
pragma Import (C, gzputs, "gzputs");
|
|
409
|
+
pragma Import (C, gzgets, "gzgets");
|
|
410
|
+
pragma Import (C, gzputc, "gzputc");
|
|
411
|
+
pragma Import (C, gzgetc, "gzgetc");
|
|
412
|
+
pragma Import (C, gzflush, "gzflush");
|
|
413
|
+
pragma Import (C, gzseek, "gzseek");
|
|
414
|
+
pragma Import (C, gzrewind, "gzrewind");
|
|
415
|
+
pragma Import (C, gztell, "gztell");
|
|
416
|
+
pragma Import (C, gzeof, "gzeof");
|
|
417
|
+
pragma Import (C, gzclose, "gzclose");
|
|
418
|
+
pragma Import (C, gzerror, "gzerror");
|
|
419
|
+
pragma Import (C, adler32, "adler32");
|
|
420
|
+
pragma Import (C, crc32, "crc32");
|
|
421
|
+
pragma Import (C, deflateInit, "deflateInit_");
|
|
422
|
+
pragma Import (C, inflateInit, "inflateInit_");
|
|
423
|
+
pragma Import (C, deflateInit2, "deflateInit2_");
|
|
424
|
+
pragma Import (C, inflateInit2, "inflateInit2_");
|
|
425
|
+
pragma Import (C, zError, "zError");
|
|
426
|
+
pragma Import (C, inflateSyncPoint, "inflateSyncPoint");
|
|
427
|
+
pragma Import (C, get_crc_table, "get_crc_table");
|
|
428
|
+
|
|
429
|
+
-- since zlib 1.2.0:
|
|
430
|
+
|
|
431
|
+
pragma Import (C, inflateCopy, "inflateCopy");
|
|
432
|
+
pragma Import (C, compressBound, "compressBound");
|
|
433
|
+
pragma Import (C, deflateBound, "deflateBound");
|
|
434
|
+
pragma Import (C, gzungetc, "gzungetc");
|
|
435
|
+
pragma Import (C, zlibCompileFlags, "zlibCompileFlags");
|
|
436
|
+
|
|
437
|
+
pragma Import (C, inflateBackInit, "inflateBackInit_");
|
|
438
|
+
|
|
439
|
+
-- I stopped binding the inflateBack routines, becouse realize that
|
|
440
|
+
-- it does not support zlib and gzip headers for now, and have no
|
|
441
|
+
-- symmetric deflateBack routines.
|
|
442
|
+
-- ZLib-Ada is symmetric regarding deflate/inflate data transformation
|
|
443
|
+
-- and has a similar generic callback interface for the
|
|
444
|
+
-- deflate/inflate transformation based on the regular Deflate/Inflate
|
|
445
|
+
-- routines.
|
|
446
|
+
|
|
447
|
+
-- pragma Import (C, inflateBack, "inflateBack");
|
|
448
|
+
-- pragma Import (C, inflateBackEnd, "inflateBackEnd");
|
|
449
|
+
|
|
450
|
+
end ZLib.Thin;
|
|
@@ -0,0 +1,701 @@
|
|
|
1
|
+
----------------------------------------------------------------
|
|
2
|
+
-- ZLib for Ada thick binding. --
|
|
3
|
+
-- --
|
|
4
|
+
-- Copyright (C) 2002-2004 Dmitriy Anisimkov --
|
|
5
|
+
-- --
|
|
6
|
+
-- Open source license information is in the zlib.ads file. --
|
|
7
|
+
----------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
-- $Id: zlib.adb,v 1.31 2004/09/06 06:53:19 vagul Exp $
|
|
10
|
+
|
|
11
|
+
with Ada.Exceptions;
|
|
12
|
+
with Ada.Unchecked_Conversion;
|
|
13
|
+
with Ada.Unchecked_Deallocation;
|
|
14
|
+
|
|
15
|
+
with Interfaces.C.Strings;
|
|
16
|
+
|
|
17
|
+
with ZLib.Thin;
|
|
18
|
+
|
|
19
|
+
package body ZLib is
|
|
20
|
+
|
|
21
|
+
use type Thin.Int;
|
|
22
|
+
|
|
23
|
+
type Z_Stream is new Thin.Z_Stream;
|
|
24
|
+
|
|
25
|
+
type Return_Code_Enum is
|
|
26
|
+
(OK,
|
|
27
|
+
STREAM_END,
|
|
28
|
+
NEED_DICT,
|
|
29
|
+
ERRNO,
|
|
30
|
+
STREAM_ERROR,
|
|
31
|
+
DATA_ERROR,
|
|
32
|
+
MEM_ERROR,
|
|
33
|
+
BUF_ERROR,
|
|
34
|
+
VERSION_ERROR);
|
|
35
|
+
|
|
36
|
+
type Flate_Step_Function is access
|
|
37
|
+
function (Strm : in Thin.Z_Streamp; Flush : in Thin.Int) return Thin.Int;
|
|
38
|
+
pragma Convention (C, Flate_Step_Function);
|
|
39
|
+
|
|
40
|
+
type Flate_End_Function is access
|
|
41
|
+
function (Ctrm : in Thin.Z_Streamp) return Thin.Int;
|
|
42
|
+
pragma Convention (C, Flate_End_Function);
|
|
43
|
+
|
|
44
|
+
type Flate_Type is record
|
|
45
|
+
Step : Flate_Step_Function;
|
|
46
|
+
Done : Flate_End_Function;
|
|
47
|
+
end record;
|
|
48
|
+
|
|
49
|
+
subtype Footer_Array is Stream_Element_Array (1 .. 8);
|
|
50
|
+
|
|
51
|
+
Simple_GZip_Header : constant Stream_Element_Array (1 .. 10)
|
|
52
|
+
:= (16#1f#, 16#8b#, -- Magic header
|
|
53
|
+
16#08#, -- Z_DEFLATED
|
|
54
|
+
16#00#, -- Flags
|
|
55
|
+
16#00#, 16#00#, 16#00#, 16#00#, -- Time
|
|
56
|
+
16#00#, -- XFlags
|
|
57
|
+
16#03# -- OS code
|
|
58
|
+
);
|
|
59
|
+
-- The simplest gzip header is not for informational, but just for
|
|
60
|
+
-- gzip format compatibility.
|
|
61
|
+
-- Note that some code below is using assumption
|
|
62
|
+
-- Simple_GZip_Header'Last > Footer_Array'Last, so do not make
|
|
63
|
+
-- Simple_GZip_Header'Last <= Footer_Array'Last.
|
|
64
|
+
|
|
65
|
+
Return_Code : constant array (Thin.Int range <>) of Return_Code_Enum
|
|
66
|
+
:= (0 => OK,
|
|
67
|
+
1 => STREAM_END,
|
|
68
|
+
2 => NEED_DICT,
|
|
69
|
+
-1 => ERRNO,
|
|
70
|
+
-2 => STREAM_ERROR,
|
|
71
|
+
-3 => DATA_ERROR,
|
|
72
|
+
-4 => MEM_ERROR,
|
|
73
|
+
-5 => BUF_ERROR,
|
|
74
|
+
-6 => VERSION_ERROR);
|
|
75
|
+
|
|
76
|
+
Flate : constant array (Boolean) of Flate_Type
|
|
77
|
+
:= (True => (Step => Thin.Deflate'Access,
|
|
78
|
+
Done => Thin.DeflateEnd'Access),
|
|
79
|
+
False => (Step => Thin.Inflate'Access,
|
|
80
|
+
Done => Thin.InflateEnd'Access));
|
|
81
|
+
|
|
82
|
+
Flush_Finish : constant array (Boolean) of Flush_Mode
|
|
83
|
+
:= (True => Finish, False => No_Flush);
|
|
84
|
+
|
|
85
|
+
procedure Raise_Error (Stream : in Z_Stream);
|
|
86
|
+
pragma Inline (Raise_Error);
|
|
87
|
+
|
|
88
|
+
procedure Raise_Error (Message : in String);
|
|
89
|
+
pragma Inline (Raise_Error);
|
|
90
|
+
|
|
91
|
+
procedure Check_Error (Stream : in Z_Stream; Code : in Thin.Int);
|
|
92
|
+
|
|
93
|
+
procedure Free is new Ada.Unchecked_Deallocation
|
|
94
|
+
(Z_Stream, Z_Stream_Access);
|
|
95
|
+
|
|
96
|
+
function To_Thin_Access is new Ada.Unchecked_Conversion
|
|
97
|
+
(Z_Stream_Access, Thin.Z_Streamp);
|
|
98
|
+
|
|
99
|
+
procedure Translate_GZip
|
|
100
|
+
(Filter : in out Filter_Type;
|
|
101
|
+
In_Data : in Ada.Streams.Stream_Element_Array;
|
|
102
|
+
In_Last : out Ada.Streams.Stream_Element_Offset;
|
|
103
|
+
Out_Data : out Ada.Streams.Stream_Element_Array;
|
|
104
|
+
Out_Last : out Ada.Streams.Stream_Element_Offset;
|
|
105
|
+
Flush : in Flush_Mode);
|
|
106
|
+
-- Separate translate routine for make gzip header.
|
|
107
|
+
|
|
108
|
+
procedure Translate_Auto
|
|
109
|
+
(Filter : in out Filter_Type;
|
|
110
|
+
In_Data : in Ada.Streams.Stream_Element_Array;
|
|
111
|
+
In_Last : out Ada.Streams.Stream_Element_Offset;
|
|
112
|
+
Out_Data : out Ada.Streams.Stream_Element_Array;
|
|
113
|
+
Out_Last : out Ada.Streams.Stream_Element_Offset;
|
|
114
|
+
Flush : in Flush_Mode);
|
|
115
|
+
-- translate routine without additional headers.
|
|
116
|
+
|
|
117
|
+
-----------------
|
|
118
|
+
-- Check_Error --
|
|
119
|
+
-----------------
|
|
120
|
+
|
|
121
|
+
procedure Check_Error (Stream : in Z_Stream; Code : in Thin.Int) is
|
|
122
|
+
use type Thin.Int;
|
|
123
|
+
begin
|
|
124
|
+
if Code /= Thin.Z_OK then
|
|
125
|
+
Raise_Error
|
|
126
|
+
(Return_Code_Enum'Image (Return_Code (Code))
|
|
127
|
+
& ": " & Last_Error_Message (Stream));
|
|
128
|
+
end if;
|
|
129
|
+
end Check_Error;
|
|
130
|
+
|
|
131
|
+
-----------
|
|
132
|
+
-- Close --
|
|
133
|
+
-----------
|
|
134
|
+
|
|
135
|
+
procedure Close
|
|
136
|
+
(Filter : in out Filter_Type;
|
|
137
|
+
Ignore_Error : in Boolean := False)
|
|
138
|
+
is
|
|
139
|
+
Code : Thin.Int;
|
|
140
|
+
begin
|
|
141
|
+
if not Ignore_Error and then not Is_Open (Filter) then
|
|
142
|
+
raise Status_Error;
|
|
143
|
+
end if;
|
|
144
|
+
|
|
145
|
+
Code := Flate (Filter.Compression).Done (To_Thin_Access (Filter.Strm));
|
|
146
|
+
|
|
147
|
+
if Ignore_Error or else Code = Thin.Z_OK then
|
|
148
|
+
Free (Filter.Strm);
|
|
149
|
+
else
|
|
150
|
+
declare
|
|
151
|
+
Error_Message : constant String
|
|
152
|
+
:= Last_Error_Message (Filter.Strm.all);
|
|
153
|
+
begin
|
|
154
|
+
Free (Filter.Strm);
|
|
155
|
+
Ada.Exceptions.Raise_Exception
|
|
156
|
+
(ZLib_Error'Identity,
|
|
157
|
+
Return_Code_Enum'Image (Return_Code (Code))
|
|
158
|
+
& ": " & Error_Message);
|
|
159
|
+
end;
|
|
160
|
+
end if;
|
|
161
|
+
end Close;
|
|
162
|
+
|
|
163
|
+
-----------
|
|
164
|
+
-- CRC32 --
|
|
165
|
+
-----------
|
|
166
|
+
|
|
167
|
+
function CRC32
|
|
168
|
+
(CRC : in Unsigned_32;
|
|
169
|
+
Data : in Ada.Streams.Stream_Element_Array)
|
|
170
|
+
return Unsigned_32
|
|
171
|
+
is
|
|
172
|
+
use Thin;
|
|
173
|
+
begin
|
|
174
|
+
return Unsigned_32 (crc32 (ULong (CRC),
|
|
175
|
+
Data'Address,
|
|
176
|
+
Data'Length));
|
|
177
|
+
end CRC32;
|
|
178
|
+
|
|
179
|
+
procedure CRC32
|
|
180
|
+
(CRC : in out Unsigned_32;
|
|
181
|
+
Data : in Ada.Streams.Stream_Element_Array) is
|
|
182
|
+
begin
|
|
183
|
+
CRC := CRC32 (CRC, Data);
|
|
184
|
+
end CRC32;
|
|
185
|
+
|
|
186
|
+
------------------
|
|
187
|
+
-- Deflate_Init --
|
|
188
|
+
------------------
|
|
189
|
+
|
|
190
|
+
procedure Deflate_Init
|
|
191
|
+
(Filter : in out Filter_Type;
|
|
192
|
+
Level : in Compression_Level := Default_Compression;
|
|
193
|
+
Strategy : in Strategy_Type := Default_Strategy;
|
|
194
|
+
Method : in Compression_Method := Deflated;
|
|
195
|
+
Window_Bits : in Window_Bits_Type := Default_Window_Bits;
|
|
196
|
+
Memory_Level : in Memory_Level_Type := Default_Memory_Level;
|
|
197
|
+
Header : in Header_Type := Default)
|
|
198
|
+
is
|
|
199
|
+
use type Thin.Int;
|
|
200
|
+
Win_Bits : Thin.Int := Thin.Int (Window_Bits);
|
|
201
|
+
begin
|
|
202
|
+
if Is_Open (Filter) then
|
|
203
|
+
raise Status_Error;
|
|
204
|
+
end if;
|
|
205
|
+
|
|
206
|
+
-- We allow ZLib to make header only in case of default header type.
|
|
207
|
+
-- Otherwise we would either do header by ourselfs, or do not do
|
|
208
|
+
-- header at all.
|
|
209
|
+
|
|
210
|
+
if Header = None or else Header = GZip then
|
|
211
|
+
Win_Bits := -Win_Bits;
|
|
212
|
+
end if;
|
|
213
|
+
|
|
214
|
+
-- For the GZip CRC calculation and make headers.
|
|
215
|
+
|
|
216
|
+
if Header = GZip then
|
|
217
|
+
Filter.CRC := 0;
|
|
218
|
+
Filter.Offset := Simple_GZip_Header'First;
|
|
219
|
+
else
|
|
220
|
+
Filter.Offset := Simple_GZip_Header'Last + 1;
|
|
221
|
+
end if;
|
|
222
|
+
|
|
223
|
+
Filter.Strm := new Z_Stream;
|
|
224
|
+
Filter.Compression := True;
|
|
225
|
+
Filter.Stream_End := False;
|
|
226
|
+
Filter.Header := Header;
|
|
227
|
+
|
|
228
|
+
if Thin.Deflate_Init
|
|
229
|
+
(To_Thin_Access (Filter.Strm),
|
|
230
|
+
Level => Thin.Int (Level),
|
|
231
|
+
method => Thin.Int (Method),
|
|
232
|
+
windowBits => Win_Bits,
|
|
233
|
+
memLevel => Thin.Int (Memory_Level),
|
|
234
|
+
strategy => Thin.Int (Strategy)) /= Thin.Z_OK
|
|
235
|
+
then
|
|
236
|
+
Raise_Error (Filter.Strm.all);
|
|
237
|
+
end if;
|
|
238
|
+
end Deflate_Init;
|
|
239
|
+
|
|
240
|
+
-----------
|
|
241
|
+
-- Flush --
|
|
242
|
+
-----------
|
|
243
|
+
|
|
244
|
+
procedure Flush
|
|
245
|
+
(Filter : in out Filter_Type;
|
|
246
|
+
Out_Data : out Ada.Streams.Stream_Element_Array;
|
|
247
|
+
Out_Last : out Ada.Streams.Stream_Element_Offset;
|
|
248
|
+
Flush : in Flush_Mode)
|
|
249
|
+
is
|
|
250
|
+
No_Data : Stream_Element_Array := (1 .. 0 => 0);
|
|
251
|
+
Last : Stream_Element_Offset;
|
|
252
|
+
begin
|
|
253
|
+
Translate (Filter, No_Data, Last, Out_Data, Out_Last, Flush);
|
|
254
|
+
end Flush;
|
|
255
|
+
|
|
256
|
+
-----------------------
|
|
257
|
+
-- Generic_Translate --
|
|
258
|
+
-----------------------
|
|
259
|
+
|
|
260
|
+
procedure Generic_Translate
|
|
261
|
+
(Filter : in out ZLib.Filter_Type;
|
|
262
|
+
In_Buffer_Size : in Integer := Default_Buffer_Size;
|
|
263
|
+
Out_Buffer_Size : in Integer := Default_Buffer_Size)
|
|
264
|
+
is
|
|
265
|
+
In_Buffer : Stream_Element_Array
|
|
266
|
+
(1 .. Stream_Element_Offset (In_Buffer_Size));
|
|
267
|
+
Out_Buffer : Stream_Element_Array
|
|
268
|
+
(1 .. Stream_Element_Offset (Out_Buffer_Size));
|
|
269
|
+
Last : Stream_Element_Offset;
|
|
270
|
+
In_Last : Stream_Element_Offset;
|
|
271
|
+
In_First : Stream_Element_Offset;
|
|
272
|
+
Out_Last : Stream_Element_Offset;
|
|
273
|
+
begin
|
|
274
|
+
Main : loop
|
|
275
|
+
Data_In (In_Buffer, Last);
|
|
276
|
+
|
|
277
|
+
In_First := In_Buffer'First;
|
|
278
|
+
|
|
279
|
+
loop
|
|
280
|
+
Translate
|
|
281
|
+
(Filter => Filter,
|
|
282
|
+
In_Data => In_Buffer (In_First .. Last),
|
|
283
|
+
In_Last => In_Last,
|
|
284
|
+
Out_Data => Out_Buffer,
|
|
285
|
+
Out_Last => Out_Last,
|
|
286
|
+
Flush => Flush_Finish (Last < In_Buffer'First));
|
|
287
|
+
|
|
288
|
+
if Out_Buffer'First <= Out_Last then
|
|
289
|
+
Data_Out (Out_Buffer (Out_Buffer'First .. Out_Last));
|
|
290
|
+
end if;
|
|
291
|
+
|
|
292
|
+
exit Main when Stream_End (Filter);
|
|
293
|
+
|
|
294
|
+
-- The end of in buffer.
|
|
295
|
+
|
|
296
|
+
exit when In_Last = Last;
|
|
297
|
+
|
|
298
|
+
In_First := In_Last + 1;
|
|
299
|
+
end loop;
|
|
300
|
+
end loop Main;
|
|
301
|
+
|
|
302
|
+
end Generic_Translate;
|
|
303
|
+
|
|
304
|
+
------------------
|
|
305
|
+
-- Inflate_Init --
|
|
306
|
+
------------------
|
|
307
|
+
|
|
308
|
+
procedure Inflate_Init
|
|
309
|
+
(Filter : in out Filter_Type;
|
|
310
|
+
Window_Bits : in Window_Bits_Type := Default_Window_Bits;
|
|
311
|
+
Header : in Header_Type := Default)
|
|
312
|
+
is
|
|
313
|
+
use type Thin.Int;
|
|
314
|
+
Win_Bits : Thin.Int := Thin.Int (Window_Bits);
|
|
315
|
+
|
|
316
|
+
procedure Check_Version;
|
|
317
|
+
-- Check the latest header types compatibility.
|
|
318
|
+
|
|
319
|
+
procedure Check_Version is
|
|
320
|
+
begin
|
|
321
|
+
if Version <= "1.1.4" then
|
|
322
|
+
Raise_Error
|
|
323
|
+
("Inflate header type " & Header_Type'Image (Header)
|
|
324
|
+
& " incompatible with ZLib version " & Version);
|
|
325
|
+
end if;
|
|
326
|
+
end Check_Version;
|
|
327
|
+
|
|
328
|
+
begin
|
|
329
|
+
if Is_Open (Filter) then
|
|
330
|
+
raise Status_Error;
|
|
331
|
+
end if;
|
|
332
|
+
|
|
333
|
+
case Header is
|
|
334
|
+
when None =>
|
|
335
|
+
Check_Version;
|
|
336
|
+
|
|
337
|
+
-- Inflate data without headers determined
|
|
338
|
+
-- by negative Win_Bits.
|
|
339
|
+
|
|
340
|
+
Win_Bits := -Win_Bits;
|
|
341
|
+
when GZip =>
|
|
342
|
+
Check_Version;
|
|
343
|
+
|
|
344
|
+
-- Inflate gzip data defined by flag 16.
|
|
345
|
+
|
|
346
|
+
Win_Bits := Win_Bits + 16;
|
|
347
|
+
when Auto =>
|
|
348
|
+
Check_Version;
|
|
349
|
+
|
|
350
|
+
-- Inflate with automatic detection
|
|
351
|
+
-- of gzip or native header defined by flag 32.
|
|
352
|
+
|
|
353
|
+
Win_Bits := Win_Bits + 32;
|
|
354
|
+
when Default => null;
|
|
355
|
+
end case;
|
|
356
|
+
|
|
357
|
+
Filter.Strm := new Z_Stream;
|
|
358
|
+
Filter.Compression := False;
|
|
359
|
+
Filter.Stream_End := False;
|
|
360
|
+
Filter.Header := Header;
|
|
361
|
+
|
|
362
|
+
if Thin.Inflate_Init
|
|
363
|
+
(To_Thin_Access (Filter.Strm), Win_Bits) /= Thin.Z_OK
|
|
364
|
+
then
|
|
365
|
+
Raise_Error (Filter.Strm.all);
|
|
366
|
+
end if;
|
|
367
|
+
end Inflate_Init;
|
|
368
|
+
|
|
369
|
+
-------------
|
|
370
|
+
-- Is_Open --
|
|
371
|
+
-------------
|
|
372
|
+
|
|
373
|
+
function Is_Open (Filter : in Filter_Type) return Boolean is
|
|
374
|
+
begin
|
|
375
|
+
return Filter.Strm /= null;
|
|
376
|
+
end Is_Open;
|
|
377
|
+
|
|
378
|
+
-----------------
|
|
379
|
+
-- Raise_Error --
|
|
380
|
+
-----------------
|
|
381
|
+
|
|
382
|
+
procedure Raise_Error (Message : in String) is
|
|
383
|
+
begin
|
|
384
|
+
Ada.Exceptions.Raise_Exception (ZLib_Error'Identity, Message);
|
|
385
|
+
end Raise_Error;
|
|
386
|
+
|
|
387
|
+
procedure Raise_Error (Stream : in Z_Stream) is
|
|
388
|
+
begin
|
|
389
|
+
Raise_Error (Last_Error_Message (Stream));
|
|
390
|
+
end Raise_Error;
|
|
391
|
+
|
|
392
|
+
----------
|
|
393
|
+
-- Read --
|
|
394
|
+
----------
|
|
395
|
+
|
|
396
|
+
procedure Read
|
|
397
|
+
(Filter : in out Filter_Type;
|
|
398
|
+
Item : out Ada.Streams.Stream_Element_Array;
|
|
399
|
+
Last : out Ada.Streams.Stream_Element_Offset;
|
|
400
|
+
Flush : in Flush_Mode := No_Flush)
|
|
401
|
+
is
|
|
402
|
+
In_Last : Stream_Element_Offset;
|
|
403
|
+
Item_First : Ada.Streams.Stream_Element_Offset := Item'First;
|
|
404
|
+
V_Flush : Flush_Mode := Flush;
|
|
405
|
+
|
|
406
|
+
begin
|
|
407
|
+
pragma Assert (Rest_First in Buffer'First .. Buffer'Last + 1);
|
|
408
|
+
pragma Assert (Rest_Last in Buffer'First - 1 .. Buffer'Last);
|
|
409
|
+
|
|
410
|
+
loop
|
|
411
|
+
if Rest_Last = Buffer'First - 1 then
|
|
412
|
+
V_Flush := Finish;
|
|
413
|
+
|
|
414
|
+
elsif Rest_First > Rest_Last then
|
|
415
|
+
Read (Buffer, Rest_Last);
|
|
416
|
+
Rest_First := Buffer'First;
|
|
417
|
+
|
|
418
|
+
if Rest_Last < Buffer'First then
|
|
419
|
+
V_Flush := Finish;
|
|
420
|
+
end if;
|
|
421
|
+
end if;
|
|
422
|
+
|
|
423
|
+
Translate
|
|
424
|
+
(Filter => Filter,
|
|
425
|
+
In_Data => Buffer (Rest_First .. Rest_Last),
|
|
426
|
+
In_Last => In_Last,
|
|
427
|
+
Out_Data => Item (Item_First .. Item'Last),
|
|
428
|
+
Out_Last => Last,
|
|
429
|
+
Flush => V_Flush);
|
|
430
|
+
|
|
431
|
+
Rest_First := In_Last + 1;
|
|
432
|
+
|
|
433
|
+
exit when Stream_End (Filter)
|
|
434
|
+
or else Last = Item'Last
|
|
435
|
+
or else (Last >= Item'First and then Allow_Read_Some);
|
|
436
|
+
|
|
437
|
+
Item_First := Last + 1;
|
|
438
|
+
end loop;
|
|
439
|
+
end Read;
|
|
440
|
+
|
|
441
|
+
----------------
|
|
442
|
+
-- Stream_End --
|
|
443
|
+
----------------
|
|
444
|
+
|
|
445
|
+
function Stream_End (Filter : in Filter_Type) return Boolean is
|
|
446
|
+
begin
|
|
447
|
+
if Filter.Header = GZip and Filter.Compression then
|
|
448
|
+
return Filter.Stream_End
|
|
449
|
+
and then Filter.Offset = Footer_Array'Last + 1;
|
|
450
|
+
else
|
|
451
|
+
return Filter.Stream_End;
|
|
452
|
+
end if;
|
|
453
|
+
end Stream_End;
|
|
454
|
+
|
|
455
|
+
--------------
|
|
456
|
+
-- Total_In --
|
|
457
|
+
--------------
|
|
458
|
+
|
|
459
|
+
function Total_In (Filter : in Filter_Type) return Count is
|
|
460
|
+
begin
|
|
461
|
+
return Count (Thin.Total_In (To_Thin_Access (Filter.Strm).all));
|
|
462
|
+
end Total_In;
|
|
463
|
+
|
|
464
|
+
---------------
|
|
465
|
+
-- Total_Out --
|
|
466
|
+
---------------
|
|
467
|
+
|
|
468
|
+
function Total_Out (Filter : in Filter_Type) return Count is
|
|
469
|
+
begin
|
|
470
|
+
return Count (Thin.Total_Out (To_Thin_Access (Filter.Strm).all));
|
|
471
|
+
end Total_Out;
|
|
472
|
+
|
|
473
|
+
---------------
|
|
474
|
+
-- Translate --
|
|
475
|
+
---------------
|
|
476
|
+
|
|
477
|
+
procedure Translate
|
|
478
|
+
(Filter : in out Filter_Type;
|
|
479
|
+
In_Data : in Ada.Streams.Stream_Element_Array;
|
|
480
|
+
In_Last : out Ada.Streams.Stream_Element_Offset;
|
|
481
|
+
Out_Data : out Ada.Streams.Stream_Element_Array;
|
|
482
|
+
Out_Last : out Ada.Streams.Stream_Element_Offset;
|
|
483
|
+
Flush : in Flush_Mode) is
|
|
484
|
+
begin
|
|
485
|
+
if Filter.Header = GZip and then Filter.Compression then
|
|
486
|
+
Translate_GZip
|
|
487
|
+
(Filter => Filter,
|
|
488
|
+
In_Data => In_Data,
|
|
489
|
+
In_Last => In_Last,
|
|
490
|
+
Out_Data => Out_Data,
|
|
491
|
+
Out_Last => Out_Last,
|
|
492
|
+
Flush => Flush);
|
|
493
|
+
else
|
|
494
|
+
Translate_Auto
|
|
495
|
+
(Filter => Filter,
|
|
496
|
+
In_Data => In_Data,
|
|
497
|
+
In_Last => In_Last,
|
|
498
|
+
Out_Data => Out_Data,
|
|
499
|
+
Out_Last => Out_Last,
|
|
500
|
+
Flush => Flush);
|
|
501
|
+
end if;
|
|
502
|
+
end Translate;
|
|
503
|
+
|
|
504
|
+
--------------------
|
|
505
|
+
-- Translate_Auto --
|
|
506
|
+
--------------------
|
|
507
|
+
|
|
508
|
+
procedure Translate_Auto
|
|
509
|
+
(Filter : in out Filter_Type;
|
|
510
|
+
In_Data : in Ada.Streams.Stream_Element_Array;
|
|
511
|
+
In_Last : out Ada.Streams.Stream_Element_Offset;
|
|
512
|
+
Out_Data : out Ada.Streams.Stream_Element_Array;
|
|
513
|
+
Out_Last : out Ada.Streams.Stream_Element_Offset;
|
|
514
|
+
Flush : in Flush_Mode)
|
|
515
|
+
is
|
|
516
|
+
use type Thin.Int;
|
|
517
|
+
Code : Thin.Int;
|
|
518
|
+
|
|
519
|
+
begin
|
|
520
|
+
if not Is_Open (Filter) then
|
|
521
|
+
raise Status_Error;
|
|
522
|
+
end if;
|
|
523
|
+
|
|
524
|
+
if Out_Data'Length = 0 and then In_Data'Length = 0 then
|
|
525
|
+
raise Constraint_Error;
|
|
526
|
+
end if;
|
|
527
|
+
|
|
528
|
+
Set_Out (Filter.Strm.all, Out_Data'Address, Out_Data'Length);
|
|
529
|
+
Set_In (Filter.Strm.all, In_Data'Address, In_Data'Length);
|
|
530
|
+
|
|
531
|
+
Code := Flate (Filter.Compression).Step
|
|
532
|
+
(To_Thin_Access (Filter.Strm),
|
|
533
|
+
Thin.Int (Flush));
|
|
534
|
+
|
|
535
|
+
if Code = Thin.Z_STREAM_END then
|
|
536
|
+
Filter.Stream_End := True;
|
|
537
|
+
else
|
|
538
|
+
Check_Error (Filter.Strm.all, Code);
|
|
539
|
+
end if;
|
|
540
|
+
|
|
541
|
+
In_Last := In_Data'Last
|
|
542
|
+
- Stream_Element_Offset (Avail_In (Filter.Strm.all));
|
|
543
|
+
Out_Last := Out_Data'Last
|
|
544
|
+
- Stream_Element_Offset (Avail_Out (Filter.Strm.all));
|
|
545
|
+
end Translate_Auto;
|
|
546
|
+
|
|
547
|
+
--------------------
|
|
548
|
+
-- Translate_GZip --
|
|
549
|
+
--------------------
|
|
550
|
+
|
|
551
|
+
procedure Translate_GZip
|
|
552
|
+
(Filter : in out Filter_Type;
|
|
553
|
+
In_Data : in Ada.Streams.Stream_Element_Array;
|
|
554
|
+
In_Last : out Ada.Streams.Stream_Element_Offset;
|
|
555
|
+
Out_Data : out Ada.Streams.Stream_Element_Array;
|
|
556
|
+
Out_Last : out Ada.Streams.Stream_Element_Offset;
|
|
557
|
+
Flush : in Flush_Mode)
|
|
558
|
+
is
|
|
559
|
+
Out_First : Stream_Element_Offset;
|
|
560
|
+
|
|
561
|
+
procedure Add_Data (Data : in Stream_Element_Array);
|
|
562
|
+
-- Add data to stream from the Filter.Offset till necessary,
|
|
563
|
+
-- used for add gzip headr/footer.
|
|
564
|
+
|
|
565
|
+
procedure Put_32
|
|
566
|
+
(Item : in out Stream_Element_Array;
|
|
567
|
+
Data : in Unsigned_32);
|
|
568
|
+
pragma Inline (Put_32);
|
|
569
|
+
|
|
570
|
+
--------------
|
|
571
|
+
-- Add_Data --
|
|
572
|
+
--------------
|
|
573
|
+
|
|
574
|
+
procedure Add_Data (Data : in Stream_Element_Array) is
|
|
575
|
+
Data_First : Stream_Element_Offset renames Filter.Offset;
|
|
576
|
+
Data_Last : Stream_Element_Offset;
|
|
577
|
+
Data_Len : Stream_Element_Offset; -- -1
|
|
578
|
+
Out_Len : Stream_Element_Offset; -- -1
|
|
579
|
+
begin
|
|
580
|
+
Out_First := Out_Last + 1;
|
|
581
|
+
|
|
582
|
+
if Data_First > Data'Last then
|
|
583
|
+
return;
|
|
584
|
+
end if;
|
|
585
|
+
|
|
586
|
+
Data_Len := Data'Last - Data_First;
|
|
587
|
+
Out_Len := Out_Data'Last - Out_First;
|
|
588
|
+
|
|
589
|
+
if Data_Len <= Out_Len then
|
|
590
|
+
Out_Last := Out_First + Data_Len;
|
|
591
|
+
Data_Last := Data'Last;
|
|
592
|
+
else
|
|
593
|
+
Out_Last := Out_Data'Last;
|
|
594
|
+
Data_Last := Data_First + Out_Len;
|
|
595
|
+
end if;
|
|
596
|
+
|
|
597
|
+
Out_Data (Out_First .. Out_Last) := Data (Data_First .. Data_Last);
|
|
598
|
+
|
|
599
|
+
Data_First := Data_Last + 1;
|
|
600
|
+
Out_First := Out_Last + 1;
|
|
601
|
+
end Add_Data;
|
|
602
|
+
|
|
603
|
+
------------
|
|
604
|
+
-- Put_32 --
|
|
605
|
+
------------
|
|
606
|
+
|
|
607
|
+
procedure Put_32
|
|
608
|
+
(Item : in out Stream_Element_Array;
|
|
609
|
+
Data : in Unsigned_32)
|
|
610
|
+
is
|
|
611
|
+
D : Unsigned_32 := Data;
|
|
612
|
+
begin
|
|
613
|
+
for J in Item'First .. Item'First + 3 loop
|
|
614
|
+
Item (J) := Stream_Element (D and 16#FF#);
|
|
615
|
+
D := Shift_Right (D, 8);
|
|
616
|
+
end loop;
|
|
617
|
+
end Put_32;
|
|
618
|
+
|
|
619
|
+
begin
|
|
620
|
+
Out_Last := Out_Data'First - 1;
|
|
621
|
+
|
|
622
|
+
if not Filter.Stream_End then
|
|
623
|
+
Add_Data (Simple_GZip_Header);
|
|
624
|
+
|
|
625
|
+
Translate_Auto
|
|
626
|
+
(Filter => Filter,
|
|
627
|
+
In_Data => In_Data,
|
|
628
|
+
In_Last => In_Last,
|
|
629
|
+
Out_Data => Out_Data (Out_First .. Out_Data'Last),
|
|
630
|
+
Out_Last => Out_Last,
|
|
631
|
+
Flush => Flush);
|
|
632
|
+
|
|
633
|
+
CRC32 (Filter.CRC, In_Data (In_Data'First .. In_Last));
|
|
634
|
+
end if;
|
|
635
|
+
|
|
636
|
+
if Filter.Stream_End and then Out_Last <= Out_Data'Last then
|
|
637
|
+
-- This detection method would work only when
|
|
638
|
+
-- Simple_GZip_Header'Last > Footer_Array'Last
|
|
639
|
+
|
|
640
|
+
if Filter.Offset = Simple_GZip_Header'Last + 1 then
|
|
641
|
+
Filter.Offset := Footer_Array'First;
|
|
642
|
+
end if;
|
|
643
|
+
|
|
644
|
+
declare
|
|
645
|
+
Footer : Footer_Array;
|
|
646
|
+
begin
|
|
647
|
+
Put_32 (Footer, Filter.CRC);
|
|
648
|
+
Put_32 (Footer (Footer'First + 4 .. Footer'Last),
|
|
649
|
+
Unsigned_32 (Total_In (Filter)));
|
|
650
|
+
Add_Data (Footer);
|
|
651
|
+
end;
|
|
652
|
+
end if;
|
|
653
|
+
end Translate_GZip;
|
|
654
|
+
|
|
655
|
+
-------------
|
|
656
|
+
-- Version --
|
|
657
|
+
-------------
|
|
658
|
+
|
|
659
|
+
function Version return String is
|
|
660
|
+
begin
|
|
661
|
+
return Interfaces.C.Strings.Value (Thin.zlibVersion);
|
|
662
|
+
end Version;
|
|
663
|
+
|
|
664
|
+
-----------
|
|
665
|
+
-- Write --
|
|
666
|
+
-----------
|
|
667
|
+
|
|
668
|
+
procedure Write
|
|
669
|
+
(Filter : in out Filter_Type;
|
|
670
|
+
Item : in Ada.Streams.Stream_Element_Array;
|
|
671
|
+
Flush : in Flush_Mode := No_Flush)
|
|
672
|
+
is
|
|
673
|
+
Buffer : Stream_Element_Array (1 .. Buffer_Size);
|
|
674
|
+
In_Last : Stream_Element_Offset;
|
|
675
|
+
Out_Last : Stream_Element_Offset;
|
|
676
|
+
In_First : Stream_Element_Offset := Item'First;
|
|
677
|
+
begin
|
|
678
|
+
if Item'Length = 0 and Flush = No_Flush then
|
|
679
|
+
return;
|
|
680
|
+
end if;
|
|
681
|
+
|
|
682
|
+
loop
|
|
683
|
+
Translate
|
|
684
|
+
(Filter => Filter,
|
|
685
|
+
In_Data => Item (In_First .. Item'Last),
|
|
686
|
+
In_Last => In_Last,
|
|
687
|
+
Out_Data => Buffer,
|
|
688
|
+
Out_Last => Out_Last,
|
|
689
|
+
Flush => Flush);
|
|
690
|
+
|
|
691
|
+
if Out_Last >= Buffer'First then
|
|
692
|
+
Write (Buffer (1 .. Out_Last));
|
|
693
|
+
end if;
|
|
694
|
+
|
|
695
|
+
exit when In_Last = Item'Last or Stream_End (Filter);
|
|
696
|
+
|
|
697
|
+
In_First := In_Last + 1;
|
|
698
|
+
end loop;
|
|
699
|
+
end Write;
|
|
700
|
+
|
|
701
|
+
end ZLib;
|