bio-velvet_underground 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (286) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.gitmodules +3 -0
  4. data/.travis.yml +13 -0
  5. data/Gemfile +19 -0
  6. data/LICENSE.txt +20 -0
  7. data/README.md +53 -0
  8. data/Rakefile +51 -0
  9. data/VERSION +1 -0
  10. data/ext/bioruby.patch +60 -0
  11. data/ext/mkrf_conf.rb +50 -0
  12. data/ext/src/Makefile +125 -0
  13. data/ext/src/src/allocArray.c +305 -0
  14. data/ext/src/src/allocArray.h +86 -0
  15. data/ext/src/src/autoOpen.c +107 -0
  16. data/ext/src/src/autoOpen.h +18 -0
  17. data/ext/src/src/binarySequences.c +813 -0
  18. data/ext/src/src/binarySequences.h +125 -0
  19. data/ext/src/src/concatenatedGraph.c +233 -0
  20. data/ext/src/src/concatenatedGraph.h +30 -0
  21. data/ext/src/src/concatenatedPreGraph.c +262 -0
  22. data/ext/src/src/concatenatedPreGraph.h +29 -0
  23. data/ext/src/src/correctedGraph.c +2642 -0
  24. data/ext/src/src/correctedGraph.h +32 -0
  25. data/ext/src/src/dfib.c +509 -0
  26. data/ext/src/src/dfib.h +69 -0
  27. data/ext/src/src/dfibHeap.c +89 -0
  28. data/ext/src/src/dfibHeap.h +39 -0
  29. data/ext/src/src/dfibpriv.h +105 -0
  30. data/ext/src/src/fib.c +628 -0
  31. data/ext/src/src/fib.h +78 -0
  32. data/ext/src/src/fibHeap.c +79 -0
  33. data/ext/src/src/fibHeap.h +41 -0
  34. data/ext/src/src/fibpriv.h +110 -0
  35. data/ext/src/src/globals.h +153 -0
  36. data/ext/src/src/graph.c +3983 -0
  37. data/ext/src/src/graph.h +233 -0
  38. data/ext/src/src/graphReConstruction.c +1472 -0
  39. data/ext/src/src/graphReConstruction.h +30 -0
  40. data/ext/src/src/graphStats.c +2167 -0
  41. data/ext/src/src/graphStats.h +72 -0
  42. data/ext/src/src/kmer.c +652 -0
  43. data/ext/src/src/kmer.h +73 -0
  44. data/ext/src/src/kmerOccurenceTable.c +236 -0
  45. data/ext/src/src/kmerOccurenceTable.h +44 -0
  46. data/ext/src/src/kseq.h +223 -0
  47. data/ext/src/src/locallyCorrectedGraph.c +557 -0
  48. data/ext/src/src/locallyCorrectedGraph.h +40 -0
  49. data/ext/src/src/passageMarker.c +677 -0
  50. data/ext/src/src/passageMarker.h +137 -0
  51. data/ext/src/src/preGraph.c +1717 -0
  52. data/ext/src/src/preGraph.h +106 -0
  53. data/ext/src/src/preGraphConstruction.c +990 -0
  54. data/ext/src/src/preGraphConstruction.h +26 -0
  55. data/ext/src/src/readCoherentGraph.c +557 -0
  56. data/ext/src/src/readCoherentGraph.h +30 -0
  57. data/ext/src/src/readSet.c +1734 -0
  58. data/ext/src/src/readSet.h +67 -0
  59. data/ext/src/src/recycleBin.c +199 -0
  60. data/ext/src/src/recycleBin.h +58 -0
  61. data/ext/src/src/roadMap.c +342 -0
  62. data/ext/src/src/roadMap.h +65 -0
  63. data/ext/src/src/run.c +318 -0
  64. data/ext/src/src/run.h +52 -0
  65. data/ext/src/src/run2.c +712 -0
  66. data/ext/src/src/scaffold.c +1876 -0
  67. data/ext/src/src/scaffold.h +64 -0
  68. data/ext/src/src/shortReadPairs.c +1243 -0
  69. data/ext/src/src/shortReadPairs.h +32 -0
  70. data/ext/src/src/splay.c +259 -0
  71. data/ext/src/src/splay.h +43 -0
  72. data/ext/src/src/splayTable.c +1315 -0
  73. data/ext/src/src/splayTable.h +31 -0
  74. data/ext/src/src/tightString.c +362 -0
  75. data/ext/src/src/tightString.h +82 -0
  76. data/ext/src/src/utility.c +199 -0
  77. data/ext/src/src/utility.h +98 -0
  78. data/ext/src/third-party/zlib-1.2.3/ChangeLog +855 -0
  79. data/ext/src/third-party/zlib-1.2.3/FAQ +339 -0
  80. data/ext/src/third-party/zlib-1.2.3/INDEX +51 -0
  81. data/ext/src/third-party/zlib-1.2.3/Makefile +154 -0
  82. data/ext/src/third-party/zlib-1.2.3/Makefile.in +154 -0
  83. data/ext/src/third-party/zlib-1.2.3/README +125 -0
  84. data/ext/src/third-party/zlib-1.2.3/adler32.c +149 -0
  85. data/ext/src/third-party/zlib-1.2.3/algorithm.txt +209 -0
  86. data/ext/src/third-party/zlib-1.2.3/amiga/Makefile.pup +66 -0
  87. data/ext/src/third-party/zlib-1.2.3/amiga/Makefile.sas +65 -0
  88. data/ext/src/third-party/zlib-1.2.3/as400/bndsrc +132 -0
  89. data/ext/src/third-party/zlib-1.2.3/as400/compile.clp +123 -0
  90. data/ext/src/third-party/zlib-1.2.3/as400/readme.txt +111 -0
  91. data/ext/src/third-party/zlib-1.2.3/as400/zlib.inc +331 -0
  92. data/ext/src/third-party/zlib-1.2.3/compress.c +79 -0
  93. data/ext/src/third-party/zlib-1.2.3/configure +459 -0
  94. data/ext/src/third-party/zlib-1.2.3/contrib/README.contrib +71 -0
  95. data/ext/src/third-party/zlib-1.2.3/contrib/ada/buffer_demo.adb +106 -0
  96. data/ext/src/third-party/zlib-1.2.3/contrib/ada/mtest.adb +156 -0
  97. data/ext/src/third-party/zlib-1.2.3/contrib/ada/read.adb +156 -0
  98. data/ext/src/third-party/zlib-1.2.3/contrib/ada/readme.txt +65 -0
  99. data/ext/src/third-party/zlib-1.2.3/contrib/ada/test.adb +463 -0
  100. data/ext/src/third-party/zlib-1.2.3/contrib/ada/zlib-streams.adb +225 -0
  101. data/ext/src/third-party/zlib-1.2.3/contrib/ada/zlib-streams.ads +114 -0
  102. data/ext/src/third-party/zlib-1.2.3/contrib/ada/zlib-thin.adb +141 -0
  103. data/ext/src/third-party/zlib-1.2.3/contrib/ada/zlib-thin.ads +450 -0
  104. data/ext/src/third-party/zlib-1.2.3/contrib/ada/zlib.adb +701 -0
  105. data/ext/src/third-party/zlib-1.2.3/contrib/ada/zlib.ads +328 -0
  106. data/ext/src/third-party/zlib-1.2.3/contrib/ada/zlib.gpr +20 -0
  107. data/ext/src/third-party/zlib-1.2.3/contrib/asm586/README.586 +43 -0
  108. data/ext/src/third-party/zlib-1.2.3/contrib/asm586/match.S +364 -0
  109. data/ext/src/third-party/zlib-1.2.3/contrib/asm686/README.686 +34 -0
  110. data/ext/src/third-party/zlib-1.2.3/contrib/asm686/match.S +329 -0
  111. data/ext/src/third-party/zlib-1.2.3/contrib/blast/Makefile +8 -0
  112. data/ext/src/third-party/zlib-1.2.3/contrib/blast/README +4 -0
  113. data/ext/src/third-party/zlib-1.2.3/contrib/blast/blast.c +444 -0
  114. data/ext/src/third-party/zlib-1.2.3/contrib/blast/blast.h +71 -0
  115. data/ext/src/third-party/zlib-1.2.3/contrib/blast/test.pk +0 -0
  116. data/ext/src/third-party/zlib-1.2.3/contrib/blast/test.txt +1 -0
  117. data/ext/src/third-party/zlib-1.2.3/contrib/delphi/ZLib.pas +557 -0
  118. data/ext/src/third-party/zlib-1.2.3/contrib/delphi/ZLibConst.pas +11 -0
  119. data/ext/src/third-party/zlib-1.2.3/contrib/delphi/readme.txt +76 -0
  120. data/ext/src/third-party/zlib-1.2.3/contrib/delphi/zlibd32.mak +93 -0
  121. data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib.build +33 -0
  122. data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib.chm +0 -0
  123. data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib.sln +21 -0
  124. data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/AssemblyInfo.cs +58 -0
  125. data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/ChecksumImpl.cs +202 -0
  126. data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/CircularBuffer.cs +83 -0
  127. data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/CodecBase.cs +198 -0
  128. data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/Deflater.cs +106 -0
  129. data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/DotZLib.cs +288 -0
  130. data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/DotZLib.csproj +141 -0
  131. data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/GZipStream.cs +301 -0
  132. data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/Inflater.cs +105 -0
  133. data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/UnitTests.cs +274 -0
  134. data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/LICENSE_1_0.txt +23 -0
  135. data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/readme.txt +58 -0
  136. data/ext/src/third-party/zlib-1.2.3/contrib/infback9/README +1 -0
  137. data/ext/src/third-party/zlib-1.2.3/contrib/infback9/infback9.c +608 -0
  138. data/ext/src/third-party/zlib-1.2.3/contrib/infback9/infback9.h +37 -0
  139. data/ext/src/third-party/zlib-1.2.3/contrib/infback9/inffix9.h +107 -0
  140. data/ext/src/third-party/zlib-1.2.3/contrib/infback9/inflate9.h +47 -0
  141. data/ext/src/third-party/zlib-1.2.3/contrib/infback9/inftree9.c +323 -0
  142. data/ext/src/third-party/zlib-1.2.3/contrib/infback9/inftree9.h +55 -0
  143. data/ext/src/third-party/zlib-1.2.3/contrib/inflate86/inffas86.c +1157 -0
  144. data/ext/src/third-party/zlib-1.2.3/contrib/inflate86/inffast.S +1368 -0
  145. data/ext/src/third-party/zlib-1.2.3/contrib/iostream/test.cpp +24 -0
  146. data/ext/src/third-party/zlib-1.2.3/contrib/iostream/zfstream.cpp +329 -0
  147. data/ext/src/third-party/zlib-1.2.3/contrib/iostream/zfstream.h +128 -0
  148. data/ext/src/third-party/zlib-1.2.3/contrib/iostream2/zstream.h +307 -0
  149. data/ext/src/third-party/zlib-1.2.3/contrib/iostream2/zstream_test.cpp +25 -0
  150. data/ext/src/third-party/zlib-1.2.3/contrib/iostream3/README +35 -0
  151. data/ext/src/third-party/zlib-1.2.3/contrib/iostream3/TODO +17 -0
  152. data/ext/src/third-party/zlib-1.2.3/contrib/iostream3/test.cc +50 -0
  153. data/ext/src/third-party/zlib-1.2.3/contrib/iostream3/zfstream.cc +479 -0
  154. data/ext/src/third-party/zlib-1.2.3/contrib/iostream3/zfstream.h +466 -0
  155. data/ext/src/third-party/zlib-1.2.3/contrib/masm686/match.asm +413 -0
  156. data/ext/src/third-party/zlib-1.2.3/contrib/masmx64/bld_ml64.bat +2 -0
  157. data/ext/src/third-party/zlib-1.2.3/contrib/masmx64/gvmat64.asm +513 -0
  158. data/ext/src/third-party/zlib-1.2.3/contrib/masmx64/gvmat64.obj +0 -0
  159. data/ext/src/third-party/zlib-1.2.3/contrib/masmx64/inffas8664.c +186 -0
  160. data/ext/src/third-party/zlib-1.2.3/contrib/masmx64/inffasx64.asm +392 -0
  161. data/ext/src/third-party/zlib-1.2.3/contrib/masmx64/inffasx64.obj +0 -0
  162. data/ext/src/third-party/zlib-1.2.3/contrib/masmx64/readme.txt +28 -0
  163. data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/bld_ml32.bat +2 -0
  164. data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/gvmat32.asm +972 -0
  165. data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/gvmat32.obj +0 -0
  166. data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/gvmat32c.c +62 -0
  167. data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/inffas32.asm +1083 -0
  168. data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/inffas32.obj +0 -0
  169. data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/mkasm.bat +3 -0
  170. data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/readme.txt +21 -0
  171. data/ext/src/third-party/zlib-1.2.3/contrib/minizip/ChangeLogUnzip +67 -0
  172. data/ext/src/third-party/zlib-1.2.3/contrib/minizip/Makefile +25 -0
  173. data/ext/src/third-party/zlib-1.2.3/contrib/minizip/crypt.h +132 -0
  174. data/ext/src/third-party/zlib-1.2.3/contrib/minizip/ioapi.c +177 -0
  175. data/ext/src/third-party/zlib-1.2.3/contrib/minizip/ioapi.h +75 -0
  176. data/ext/src/third-party/zlib-1.2.3/contrib/minizip/iowin32.c +270 -0
  177. data/ext/src/third-party/zlib-1.2.3/contrib/minizip/iowin32.h +21 -0
  178. data/ext/src/third-party/zlib-1.2.3/contrib/minizip/miniunz.c +585 -0
  179. data/ext/src/third-party/zlib-1.2.3/contrib/minizip/minizip.c +420 -0
  180. data/ext/src/third-party/zlib-1.2.3/contrib/minizip/mztools.c +281 -0
  181. data/ext/src/third-party/zlib-1.2.3/contrib/minizip/mztools.h +31 -0
  182. data/ext/src/third-party/zlib-1.2.3/contrib/minizip/unzip.c +1598 -0
  183. data/ext/src/third-party/zlib-1.2.3/contrib/minizip/unzip.h +354 -0
  184. data/ext/src/third-party/zlib-1.2.3/contrib/minizip/zip.c +1219 -0
  185. data/ext/src/third-party/zlib-1.2.3/contrib/minizip/zip.h +235 -0
  186. data/ext/src/third-party/zlib-1.2.3/contrib/pascal/example.pas +599 -0
  187. data/ext/src/third-party/zlib-1.2.3/contrib/pascal/readme.txt +76 -0
  188. data/ext/src/third-party/zlib-1.2.3/contrib/pascal/zlibd32.mak +93 -0
  189. data/ext/src/third-party/zlib-1.2.3/contrib/pascal/zlibpas.pas +236 -0
  190. data/ext/src/third-party/zlib-1.2.3/contrib/puff/Makefile +8 -0
  191. data/ext/src/third-party/zlib-1.2.3/contrib/puff/README +63 -0
  192. data/ext/src/third-party/zlib-1.2.3/contrib/puff/puff.c +837 -0
  193. data/ext/src/third-party/zlib-1.2.3/contrib/puff/puff.h +31 -0
  194. data/ext/src/third-party/zlib-1.2.3/contrib/puff/zeros.raw +0 -0
  195. data/ext/src/third-party/zlib-1.2.3/contrib/testzlib/testzlib.c +275 -0
  196. data/ext/src/third-party/zlib-1.2.3/contrib/testzlib/testzlib.txt +10 -0
  197. data/ext/src/third-party/zlib-1.2.3/contrib/untgz/Makefile +14 -0
  198. data/ext/src/third-party/zlib-1.2.3/contrib/untgz/Makefile.msc +17 -0
  199. data/ext/src/third-party/zlib-1.2.3/contrib/untgz/untgz.c +674 -0
  200. data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/readme.txt +73 -0
  201. data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/miniunz.vcproj +126 -0
  202. data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/minizip.vcproj +126 -0
  203. data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/testzlib.vcproj +126 -0
  204. data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/zlib.rc +32 -0
  205. data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/zlibstat.vcproj +246 -0
  206. data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/zlibvc.def +92 -0
  207. data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/zlibvc.sln +78 -0
  208. data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/zlibvc.vcproj +445 -0
  209. data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/miniunz.vcproj +566 -0
  210. data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/minizip.vcproj +563 -0
  211. data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/testzlib.vcproj +948 -0
  212. data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/testzlibdll.vcproj +567 -0
  213. data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/zlib.rc +32 -0
  214. data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/zlibstat.vcproj +870 -0
  215. data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/zlibvc.def +92 -0
  216. data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/zlibvc.sln +144 -0
  217. data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/zlibvc.vcproj +1219 -0
  218. data/ext/src/third-party/zlib-1.2.3/crc32.c +423 -0
  219. data/ext/src/third-party/zlib-1.2.3/crc32.h +441 -0
  220. data/ext/src/third-party/zlib-1.2.3/deflate.c +1736 -0
  221. data/ext/src/third-party/zlib-1.2.3/deflate.h +331 -0
  222. data/ext/src/third-party/zlib-1.2.3/example.c +565 -0
  223. data/ext/src/third-party/zlib-1.2.3/examples/README.examples +42 -0
  224. data/ext/src/third-party/zlib-1.2.3/examples/fitblk.c +233 -0
  225. data/ext/src/third-party/zlib-1.2.3/examples/gun.c +693 -0
  226. data/ext/src/third-party/zlib-1.2.3/examples/gzappend.c +500 -0
  227. data/ext/src/third-party/zlib-1.2.3/examples/gzjoin.c +448 -0
  228. data/ext/src/third-party/zlib-1.2.3/examples/gzlog.c +413 -0
  229. data/ext/src/third-party/zlib-1.2.3/examples/gzlog.h +58 -0
  230. data/ext/src/third-party/zlib-1.2.3/examples/zlib_how.html +523 -0
  231. data/ext/src/third-party/zlib-1.2.3/examples/zpipe.c +191 -0
  232. data/ext/src/third-party/zlib-1.2.3/examples/zran.c +404 -0
  233. data/ext/src/third-party/zlib-1.2.3/gzio.c +1026 -0
  234. data/ext/src/third-party/zlib-1.2.3/infback.c +623 -0
  235. data/ext/src/third-party/zlib-1.2.3/inffast.c +318 -0
  236. data/ext/src/third-party/zlib-1.2.3/inffast.h +11 -0
  237. data/ext/src/third-party/zlib-1.2.3/inffixed.h +94 -0
  238. data/ext/src/third-party/zlib-1.2.3/inflate.c +1368 -0
  239. data/ext/src/third-party/zlib-1.2.3/inflate.h +115 -0
  240. data/ext/src/third-party/zlib-1.2.3/inftrees.c +329 -0
  241. data/ext/src/third-party/zlib-1.2.3/inftrees.h +55 -0
  242. data/ext/src/third-party/zlib-1.2.3/make_vms.com +461 -0
  243. data/ext/src/third-party/zlib-1.2.3/minigzip.c +322 -0
  244. data/ext/src/third-party/zlib-1.2.3/msdos/Makefile.bor +109 -0
  245. data/ext/src/third-party/zlib-1.2.3/msdos/Makefile.dj2 +104 -0
  246. data/ext/src/third-party/zlib-1.2.3/msdos/Makefile.emx +69 -0
  247. data/ext/src/third-party/zlib-1.2.3/msdos/Makefile.msc +106 -0
  248. data/ext/src/third-party/zlib-1.2.3/msdos/Makefile.tc +94 -0
  249. data/ext/src/third-party/zlib-1.2.3/old/Makefile.riscos +151 -0
  250. data/ext/src/third-party/zlib-1.2.3/old/README +3 -0
  251. data/ext/src/third-party/zlib-1.2.3/old/descrip.mms +48 -0
  252. data/ext/src/third-party/zlib-1.2.3/old/os2/Makefile.os2 +136 -0
  253. data/ext/src/third-party/zlib-1.2.3/old/os2/zlib.def +51 -0
  254. data/ext/src/third-party/zlib-1.2.3/old/visual-basic.txt +160 -0
  255. data/ext/src/third-party/zlib-1.2.3/old/zlib.html +971 -0
  256. data/ext/src/third-party/zlib-1.2.3/projects/README.projects +41 -0
  257. data/ext/src/third-party/zlib-1.2.3/projects/visualc6/README.txt +73 -0
  258. data/ext/src/third-party/zlib-1.2.3/projects/visualc6/example.dsp +278 -0
  259. data/ext/src/third-party/zlib-1.2.3/projects/visualc6/minigzip.dsp +278 -0
  260. data/ext/src/third-party/zlib-1.2.3/projects/visualc6/zlib.dsp +609 -0
  261. data/ext/src/third-party/zlib-1.2.3/projects/visualc6/zlib.dsw +59 -0
  262. data/ext/src/third-party/zlib-1.2.3/qnx/package.qpg +141 -0
  263. data/ext/src/third-party/zlib-1.2.3/trees.c +1219 -0
  264. data/ext/src/third-party/zlib-1.2.3/trees.h +128 -0
  265. data/ext/src/third-party/zlib-1.2.3/uncompr.c +61 -0
  266. data/ext/src/third-party/zlib-1.2.3/win32/DLL_FAQ.txt +397 -0
  267. data/ext/src/third-party/zlib-1.2.3/win32/Makefile.bor +107 -0
  268. data/ext/src/third-party/zlib-1.2.3/win32/Makefile.emx +69 -0
  269. data/ext/src/third-party/zlib-1.2.3/win32/Makefile.gcc +141 -0
  270. data/ext/src/third-party/zlib-1.2.3/win32/Makefile.msc +126 -0
  271. data/ext/src/third-party/zlib-1.2.3/win32/VisualC.txt +3 -0
  272. data/ext/src/third-party/zlib-1.2.3/win32/zlib.def +60 -0
  273. data/ext/src/third-party/zlib-1.2.3/win32/zlib1.rc +39 -0
  274. data/ext/src/third-party/zlib-1.2.3/zconf.h +332 -0
  275. data/ext/src/third-party/zlib-1.2.3/zconf.in.h +332 -0
  276. data/ext/src/third-party/zlib-1.2.3/zlib.3 +159 -0
  277. data/ext/src/third-party/zlib-1.2.3/zlib.h +1357 -0
  278. data/ext/src/third-party/zlib-1.2.3/zutil.c +318 -0
  279. data/ext/src/third-party/zlib-1.2.3/zutil.h +269 -0
  280. data/lib/bio-velvet_underground.rb +12 -0
  281. data/lib/bio-velvet_underground/external/VERSION +1 -0
  282. data/lib/bio-velvet_underground/velvet_underground.rb +72 -0
  283. data/spec/binary_sequence_store_spec.rb +27 -0
  284. data/spec/data/1/CnyUnifiedSeq +0 -0
  285. data/spec/spec_helper.rb +31 -0
  286. metadata +456 -0
@@ -0,0 +1,331 @@
1
+ /* deflate.h -- internal compression state
2
+ * Copyright (C) 1995-2004 Jean-loup Gailly
3
+ * For conditions of distribution and use, see copyright notice in zlib.h
4
+ */
5
+
6
+ /* WARNING: this file should *not* be used by applications. It is
7
+ part of the implementation of the compression library and is
8
+ subject to change. Applications should only use zlib.h.
9
+ */
10
+
11
+ /* @(#) $Id$ */
12
+
13
+ #ifndef DEFLATE_H
14
+ #define DEFLATE_H
15
+
16
+ #include "zutil.h"
17
+
18
+ /* define NO_GZIP when compiling if you want to disable gzip header and
19
+ trailer creation by deflate(). NO_GZIP would be used to avoid linking in
20
+ the crc code when it is not needed. For shared libraries, gzip encoding
21
+ should be left enabled. */
22
+ #ifndef NO_GZIP
23
+ # define GZIP
24
+ #endif
25
+
26
+ /* ===========================================================================
27
+ * Internal compression state.
28
+ */
29
+
30
+ #define LENGTH_CODES 29
31
+ /* number of length codes, not counting the special END_BLOCK code */
32
+
33
+ #define LITERALS 256
34
+ /* number of literal bytes 0..255 */
35
+
36
+ #define L_CODES (LITERALS+1+LENGTH_CODES)
37
+ /* number of Literal or Length codes, including the END_BLOCK code */
38
+
39
+ #define D_CODES 30
40
+ /* number of distance codes */
41
+
42
+ #define BL_CODES 19
43
+ /* number of codes used to transfer the bit lengths */
44
+
45
+ #define HEAP_SIZE (2*L_CODES+1)
46
+ /* maximum heap size */
47
+
48
+ #define MAX_BITS 15
49
+ /* All codes must not exceed MAX_BITS bits */
50
+
51
+ #define INIT_STATE 42
52
+ #define EXTRA_STATE 69
53
+ #define NAME_STATE 73
54
+ #define COMMENT_STATE 91
55
+ #define HCRC_STATE 103
56
+ #define BUSY_STATE 113
57
+ #define FINISH_STATE 666
58
+ /* Stream status */
59
+
60
+
61
+ /* Data structure describing a single value and its code string. */
62
+ typedef struct ct_data_s {
63
+ union {
64
+ ush freq; /* frequency count */
65
+ ush code; /* bit string */
66
+ } fc;
67
+ union {
68
+ ush dad; /* father node in Huffman tree */
69
+ ush len; /* length of bit string */
70
+ } dl;
71
+ } FAR ct_data;
72
+
73
+ #define Freq fc.freq
74
+ #define Code fc.code
75
+ #define Dad dl.dad
76
+ #define Len dl.len
77
+
78
+ typedef struct static_tree_desc_s static_tree_desc;
79
+
80
+ typedef struct tree_desc_s {
81
+ ct_data *dyn_tree; /* the dynamic tree */
82
+ int max_code; /* largest code with non zero frequency */
83
+ static_tree_desc *stat_desc; /* the corresponding static tree */
84
+ } FAR tree_desc;
85
+
86
+ typedef ush Pos;
87
+ typedef Pos FAR Posf;
88
+ typedef unsigned IPos;
89
+
90
+ /* A Pos is an index in the character window. We use short instead of int to
91
+ * save space in the various tables. IPos is used only for parameter passing.
92
+ */
93
+
94
+ typedef struct internal_state {
95
+ z_streamp strm; /* pointer back to this zlib stream */
96
+ int status; /* as the name implies */
97
+ Bytef *pending_buf; /* output still pending */
98
+ ulg pending_buf_size; /* size of pending_buf */
99
+ Bytef *pending_out; /* next pending byte to output to the stream */
100
+ uInt pending; /* nb of bytes in the pending buffer */
101
+ int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
102
+ gz_headerp gzhead; /* gzip header information to write */
103
+ uInt gzindex; /* where in extra, name, or comment */
104
+ Byte method; /* STORED (for zip only) or DEFLATED */
105
+ int last_flush; /* value of flush param for previous deflate call */
106
+
107
+ /* used by deflate.c: */
108
+
109
+ uInt w_size; /* LZ77 window size (32K by default) */
110
+ uInt w_bits; /* log2(w_size) (8..16) */
111
+ uInt w_mask; /* w_size - 1 */
112
+
113
+ Bytef *window;
114
+ /* Sliding window. Input bytes are read into the second half of the window,
115
+ * and move to the first half later to keep a dictionary of at least wSize
116
+ * bytes. With this organization, matches are limited to a distance of
117
+ * wSize-MAX_MATCH bytes, but this ensures that IO is always
118
+ * performed with a length multiple of the block size. Also, it limits
119
+ * the window size to 64K, which is quite useful on MSDOS.
120
+ * To do: use the user input buffer as sliding window.
121
+ */
122
+
123
+ ulg window_size;
124
+ /* Actual size of window: 2*wSize, except when the user input buffer
125
+ * is directly used as sliding window.
126
+ */
127
+
128
+ Posf *prev;
129
+ /* Link to older string with same hash index. To limit the size of this
130
+ * array to 64K, this link is maintained only for the last 32K strings.
131
+ * An index in this array is thus a window index modulo 32K.
132
+ */
133
+
134
+ Posf *head; /* Heads of the hash chains or NIL. */
135
+
136
+ uInt ins_h; /* hash index of string to be inserted */
137
+ uInt hash_size; /* number of elements in hash table */
138
+ uInt hash_bits; /* log2(hash_size) */
139
+ uInt hash_mask; /* hash_size-1 */
140
+
141
+ uInt hash_shift;
142
+ /* Number of bits by which ins_h must be shifted at each input
143
+ * step. It must be such that after MIN_MATCH steps, the oldest
144
+ * byte no longer takes part in the hash key, that is:
145
+ * hash_shift * MIN_MATCH >= hash_bits
146
+ */
147
+
148
+ long block_start;
149
+ /* Window position at the beginning of the current output block. Gets
150
+ * negative when the window is moved backwards.
151
+ */
152
+
153
+ uInt match_length; /* length of best match */
154
+ IPos prev_match; /* previous match */
155
+ int match_available; /* set if previous match exists */
156
+ uInt strstart; /* start of string to insert */
157
+ uInt match_start; /* start of matching string */
158
+ uInt lookahead; /* number of valid bytes ahead in window */
159
+
160
+ uInt prev_length;
161
+ /* Length of the best match at previous step. Matches not greater than this
162
+ * are discarded. This is used in the lazy match evaluation.
163
+ */
164
+
165
+ uInt max_chain_length;
166
+ /* To speed up deflation, hash chains are never searched beyond this
167
+ * length. A higher limit improves compression ratio but degrades the
168
+ * speed.
169
+ */
170
+
171
+ uInt max_lazy_match;
172
+ /* Attempt to find a better match only when the current match is strictly
173
+ * smaller than this value. This mechanism is used only for compression
174
+ * levels >= 4.
175
+ */
176
+ # define max_insert_length max_lazy_match
177
+ /* Insert new strings in the hash table only if the match length is not
178
+ * greater than this length. This saves time but degrades compression.
179
+ * max_insert_length is used only for compression levels <= 3.
180
+ */
181
+
182
+ int level; /* compression level (1..9) */
183
+ int strategy; /* favor or force Huffman coding*/
184
+
185
+ uInt good_match;
186
+ /* Use a faster search when the previous match is longer than this */
187
+
188
+ int nice_match; /* Stop searching when current match exceeds this */
189
+
190
+ /* used by trees.c: */
191
+ /* Didn't use ct_data typedef below to supress compiler warning */
192
+ struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
193
+ struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
194
+ struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
195
+
196
+ struct tree_desc_s l_desc; /* desc. for literal tree */
197
+ struct tree_desc_s d_desc; /* desc. for distance tree */
198
+ struct tree_desc_s bl_desc; /* desc. for bit length tree */
199
+
200
+ ush bl_count[MAX_BITS+1];
201
+ /* number of codes at each bit length for an optimal tree */
202
+
203
+ int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
204
+ int heap_len; /* number of elements in the heap */
205
+ int heap_max; /* element of largest frequency */
206
+ /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
207
+ * The same heap array is used to build all trees.
208
+ */
209
+
210
+ uch depth[2*L_CODES+1];
211
+ /* Depth of each subtree used as tie breaker for trees of equal frequency
212
+ */
213
+
214
+ uchf *l_buf; /* buffer for literals or lengths */
215
+
216
+ uInt lit_bufsize;
217
+ /* Size of match buffer for literals/lengths. There are 4 reasons for
218
+ * limiting lit_bufsize to 64K:
219
+ * - frequencies can be kept in 16 bit counters
220
+ * - if compression is not successful for the first block, all input
221
+ * data is still in the window so we can still emit a stored block even
222
+ * when input comes from standard input. (This can also be done for
223
+ * all blocks if lit_bufsize is not greater than 32K.)
224
+ * - if compression is not successful for a file smaller than 64K, we can
225
+ * even emit a stored file instead of a stored block (saving 5 bytes).
226
+ * This is applicable only for zip (not gzip or zlib).
227
+ * - creating new Huffman trees less frequently may not provide fast
228
+ * adaptation to changes in the input data statistics. (Take for
229
+ * example a binary file with poorly compressible code followed by
230
+ * a highly compressible string table.) Smaller buffer sizes give
231
+ * fast adaptation but have of course the overhead of transmitting
232
+ * trees more frequently.
233
+ * - I can't count above 4
234
+ */
235
+
236
+ uInt last_lit; /* running index in l_buf */
237
+
238
+ ushf *d_buf;
239
+ /* Buffer for distances. To simplify the code, d_buf and l_buf have
240
+ * the same number of elements. To use different lengths, an extra flag
241
+ * array would be necessary.
242
+ */
243
+
244
+ ulg opt_len; /* bit length of current block with optimal trees */
245
+ ulg static_len; /* bit length of current block with static trees */
246
+ uInt matches; /* number of string matches in current block */
247
+ int last_eob_len; /* bit length of EOB code for last block */
248
+
249
+ #ifdef DEBUG
250
+ ulg compressed_len; /* total bit length of compressed file mod 2^32 */
251
+ ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
252
+ #endif
253
+
254
+ ush bi_buf;
255
+ /* Output buffer. bits are inserted starting at the bottom (least
256
+ * significant bits).
257
+ */
258
+ int bi_valid;
259
+ /* Number of valid bits in bi_buf. All bits above the last valid bit
260
+ * are always zero.
261
+ */
262
+
263
+ } FAR deflate_state;
264
+
265
+ /* Output a byte on the stream.
266
+ * IN assertion: there is enough room in pending_buf.
267
+ */
268
+ #define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
269
+
270
+
271
+ #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
272
+ /* Minimum amount of lookahead, except at the end of the input file.
273
+ * See deflate.c for comments about the MIN_MATCH+1.
274
+ */
275
+
276
+ #define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
277
+ /* In order to simplify the code, particularly on 16 bit machines, match
278
+ * distances are limited to MAX_DIST instead of WSIZE.
279
+ */
280
+
281
+ /* in trees.c */
282
+ void _tr_init OF((deflate_state *s));
283
+ int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
284
+ void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
285
+ int eof));
286
+ void _tr_align OF((deflate_state *s));
287
+ void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
288
+ int eof));
289
+
290
+ #define d_code(dist) \
291
+ ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
292
+ /* Mapping from a distance to a distance code. dist is the distance - 1 and
293
+ * must not have side effects. _dist_code[256] and _dist_code[257] are never
294
+ * used.
295
+ */
296
+
297
+ #ifndef DEBUG
298
+ /* Inline versions of _tr_tally for speed: */
299
+
300
+ #if defined(GEN_TREES_H) || !defined(STDC)
301
+ extern uch _length_code[];
302
+ extern uch _dist_code[];
303
+ #else
304
+ extern const uch _length_code[];
305
+ extern const uch _dist_code[];
306
+ #endif
307
+
308
+ # define _tr_tally_lit(s, c, flush) \
309
+ { uch cc = (c); \
310
+ s->d_buf[s->last_lit] = 0; \
311
+ s->l_buf[s->last_lit++] = cc; \
312
+ s->dyn_ltree[cc].Freq++; \
313
+ flush = (s->last_lit == s->lit_bufsize-1); \
314
+ }
315
+ # define _tr_tally_dist(s, distance, length, flush) \
316
+ { uch len = (length); \
317
+ ush dist = (distance); \
318
+ s->d_buf[s->last_lit] = dist; \
319
+ s->l_buf[s->last_lit++] = len; \
320
+ dist--; \
321
+ s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
322
+ s->dyn_dtree[d_code(dist)].Freq++; \
323
+ flush = (s->last_lit == s->lit_bufsize-1); \
324
+ }
325
+ #else
326
+ # define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
327
+ # define _tr_tally_dist(s, distance, length, flush) \
328
+ flush = _tr_tally(s, distance, length)
329
+ #endif
330
+
331
+ #endif /* DEFLATE_H */
@@ -0,0 +1,565 @@
1
+ /* example.c -- usage example of the zlib compression library
2
+ * Copyright (C) 1995-2004 Jean-loup Gailly.
3
+ * For conditions of distribution and use, see copyright notice in zlib.h
4
+ */
5
+
6
+ /* @(#) $Id$ */
7
+
8
+ #include <stdio.h>
9
+ #include "zlib.h"
10
+
11
+ #ifdef STDC
12
+ # include <string.h>
13
+ # include <stdlib.h>
14
+ #endif
15
+
16
+ #if defined(VMS) || defined(RISCOS)
17
+ # define TESTFILE "foo-gz"
18
+ #else
19
+ # define TESTFILE "foo.gz"
20
+ #endif
21
+
22
+ #define CHECK_ERR(err, msg) { \
23
+ if (err != Z_OK) { \
24
+ fprintf(stderr, "%s error: %d\n", msg, err); \
25
+ exit(1); \
26
+ } \
27
+ }
28
+
29
+ const char hello[] = "hello, hello!";
30
+ /* "hello world" would be more standard, but the repeated "hello"
31
+ * stresses the compression code better, sorry...
32
+ */
33
+
34
+ const char dictionary[] = "hello";
35
+ uLong dictId; /* Adler32 value of the dictionary */
36
+
37
+ void test_compress OF((Byte *compr, uLong comprLen,
38
+ Byte *uncompr, uLong uncomprLen));
39
+ void test_gzio OF((const char *fname,
40
+ Byte *uncompr, uLong uncomprLen));
41
+ void test_deflate OF((Byte *compr, uLong comprLen));
42
+ void test_inflate OF((Byte *compr, uLong comprLen,
43
+ Byte *uncompr, uLong uncomprLen));
44
+ void test_large_deflate OF((Byte *compr, uLong comprLen,
45
+ Byte *uncompr, uLong uncomprLen));
46
+ void test_large_inflate OF((Byte *compr, uLong comprLen,
47
+ Byte *uncompr, uLong uncomprLen));
48
+ void test_flush OF((Byte *compr, uLong *comprLen));
49
+ void test_sync OF((Byte *compr, uLong comprLen,
50
+ Byte *uncompr, uLong uncomprLen));
51
+ void test_dict_deflate OF((Byte *compr, uLong comprLen));
52
+ void test_dict_inflate OF((Byte *compr, uLong comprLen,
53
+ Byte *uncompr, uLong uncomprLen));
54
+ int main OF((int argc, char *argv[]));
55
+
56
+ /* ===========================================================================
57
+ * Test compress() and uncompress()
58
+ */
59
+ void test_compress(compr, comprLen, uncompr, uncomprLen)
60
+ Byte *compr, *uncompr;
61
+ uLong comprLen, uncomprLen;
62
+ {
63
+ int err;
64
+ uLong len = (uLong)strlen(hello)+1;
65
+
66
+ err = compress(compr, &comprLen, (const Bytef*)hello, len);
67
+ CHECK_ERR(err, "compress");
68
+
69
+ strcpy((char*)uncompr, "garbage");
70
+
71
+ err = uncompress(uncompr, &uncomprLen, compr, comprLen);
72
+ CHECK_ERR(err, "uncompress");
73
+
74
+ if (strcmp((char*)uncompr, hello)) {
75
+ fprintf(stderr, "bad uncompress\n");
76
+ exit(1);
77
+ } else {
78
+ printf("uncompress(): %s\n", (char *)uncompr);
79
+ }
80
+ }
81
+
82
+ /* ===========================================================================
83
+ * Test read/write of .gz files
84
+ */
85
+ void test_gzio(fname, uncompr, uncomprLen)
86
+ const char *fname; /* compressed file name */
87
+ Byte *uncompr;
88
+ uLong uncomprLen;
89
+ {
90
+ #ifdef NO_GZCOMPRESS
91
+ fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n");
92
+ #else
93
+ int err;
94
+ int len = (int)strlen(hello)+1;
95
+ gzFile file;
96
+ z_off_t pos;
97
+
98
+ file = gzopen(fname, "wb");
99
+ if (file == NULL) {
100
+ fprintf(stderr, "gzopen error\n");
101
+ exit(1);
102
+ }
103
+ gzputc(file, 'h');
104
+ if (gzputs(file, "ello") != 4) {
105
+ fprintf(stderr, "gzputs err: %s\n", gzerror(file, &err));
106
+ exit(1);
107
+ }
108
+ if (gzprintf(file, ", %s!", "hello") != 8) {
109
+ fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err));
110
+ exit(1);
111
+ }
112
+ gzseek(file, 1L, SEEK_CUR); /* add one zero byte */
113
+ gzclose(file);
114
+
115
+ file = gzopen(fname, "rb");
116
+ if (file == NULL) {
117
+ fprintf(stderr, "gzopen error\n");
118
+ exit(1);
119
+ }
120
+ strcpy((char*)uncompr, "garbage");
121
+
122
+ if (gzread(file, uncompr, (unsigned)uncomprLen) != len) {
123
+ fprintf(stderr, "gzread err: %s\n", gzerror(file, &err));
124
+ exit(1);
125
+ }
126
+ if (strcmp((char*)uncompr, hello)) {
127
+ fprintf(stderr, "bad gzread: %s\n", (char*)uncompr);
128
+ exit(1);
129
+ } else {
130
+ printf("gzread(): %s\n", (char*)uncompr);
131
+ }
132
+
133
+ pos = gzseek(file, -8L, SEEK_CUR);
134
+ if (pos != 6 || gztell(file) != pos) {
135
+ fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n",
136
+ (long)pos, (long)gztell(file));
137
+ exit(1);
138
+ }
139
+
140
+ if (gzgetc(file) != ' ') {
141
+ fprintf(stderr, "gzgetc error\n");
142
+ exit(1);
143
+ }
144
+
145
+ if (gzungetc(' ', file) != ' ') {
146
+ fprintf(stderr, "gzungetc error\n");
147
+ exit(1);
148
+ }
149
+
150
+ gzgets(file, (char*)uncompr, (int)uncomprLen);
151
+ if (strlen((char*)uncompr) != 7) { /* " hello!" */
152
+ fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err));
153
+ exit(1);
154
+ }
155
+ if (strcmp((char*)uncompr, hello + 6)) {
156
+ fprintf(stderr, "bad gzgets after gzseek\n");
157
+ exit(1);
158
+ } else {
159
+ printf("gzgets() after gzseek: %s\n", (char*)uncompr);
160
+ }
161
+
162
+ gzclose(file);
163
+ #endif
164
+ }
165
+
166
+ /* ===========================================================================
167
+ * Test deflate() with small buffers
168
+ */
169
+ void test_deflate(compr, comprLen)
170
+ Byte *compr;
171
+ uLong comprLen;
172
+ {
173
+ z_stream c_stream; /* compression stream */
174
+ int err;
175
+ uLong len = (uLong)strlen(hello)+1;
176
+
177
+ c_stream.zalloc = (alloc_func)0;
178
+ c_stream.zfree = (free_func)0;
179
+ c_stream.opaque = (voidpf)0;
180
+
181
+ err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
182
+ CHECK_ERR(err, "deflateInit");
183
+
184
+ c_stream.next_in = (Bytef*)hello;
185
+ c_stream.next_out = compr;
186
+
187
+ while (c_stream.total_in != len && c_stream.total_out < comprLen) {
188
+ c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */
189
+ err = deflate(&c_stream, Z_NO_FLUSH);
190
+ CHECK_ERR(err, "deflate");
191
+ }
192
+ /* Finish the stream, still forcing small buffers: */
193
+ for (;;) {
194
+ c_stream.avail_out = 1;
195
+ err = deflate(&c_stream, Z_FINISH);
196
+ if (err == Z_STREAM_END) break;
197
+ CHECK_ERR(err, "deflate");
198
+ }
199
+
200
+ err = deflateEnd(&c_stream);
201
+ CHECK_ERR(err, "deflateEnd");
202
+ }
203
+
204
+ /* ===========================================================================
205
+ * Test inflate() with small buffers
206
+ */
207
+ void test_inflate(compr, comprLen, uncompr, uncomprLen)
208
+ Byte *compr, *uncompr;
209
+ uLong comprLen, uncomprLen;
210
+ {
211
+ int err;
212
+ z_stream d_stream; /* decompression stream */
213
+
214
+ strcpy((char*)uncompr, "garbage");
215
+
216
+ d_stream.zalloc = (alloc_func)0;
217
+ d_stream.zfree = (free_func)0;
218
+ d_stream.opaque = (voidpf)0;
219
+
220
+ d_stream.next_in = compr;
221
+ d_stream.avail_in = 0;
222
+ d_stream.next_out = uncompr;
223
+
224
+ err = inflateInit(&d_stream);
225
+ CHECK_ERR(err, "inflateInit");
226
+
227
+ while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen) {
228
+ d_stream.avail_in = d_stream.avail_out = 1; /* force small buffers */
229
+ err = inflate(&d_stream, Z_NO_FLUSH);
230
+ if (err == Z_STREAM_END) break;
231
+ CHECK_ERR(err, "inflate");
232
+ }
233
+
234
+ err = inflateEnd(&d_stream);
235
+ CHECK_ERR(err, "inflateEnd");
236
+
237
+ if (strcmp((char*)uncompr, hello)) {
238
+ fprintf(stderr, "bad inflate\n");
239
+ exit(1);
240
+ } else {
241
+ printf("inflate(): %s\n", (char *)uncompr);
242
+ }
243
+ }
244
+
245
+ /* ===========================================================================
246
+ * Test deflate() with large buffers and dynamic change of compression level
247
+ */
248
+ void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
249
+ Byte *compr, *uncompr;
250
+ uLong comprLen, uncomprLen;
251
+ {
252
+ z_stream c_stream; /* compression stream */
253
+ int err;
254
+
255
+ c_stream.zalloc = (alloc_func)0;
256
+ c_stream.zfree = (free_func)0;
257
+ c_stream.opaque = (voidpf)0;
258
+
259
+ err = deflateInit(&c_stream, Z_BEST_SPEED);
260
+ CHECK_ERR(err, "deflateInit");
261
+
262
+ c_stream.next_out = compr;
263
+ c_stream.avail_out = (uInt)comprLen;
264
+
265
+ /* At this point, uncompr is still mostly zeroes, so it should compress
266
+ * very well:
267
+ */
268
+ c_stream.next_in = uncompr;
269
+ c_stream.avail_in = (uInt)uncomprLen;
270
+ err = deflate(&c_stream, Z_NO_FLUSH);
271
+ CHECK_ERR(err, "deflate");
272
+ if (c_stream.avail_in != 0) {
273
+ fprintf(stderr, "deflate not greedy\n");
274
+ exit(1);
275
+ }
276
+
277
+ /* Feed in already compressed data and switch to no compression: */
278
+ deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY);
279
+ c_stream.next_in = compr;
280
+ c_stream.avail_in = (uInt)comprLen/2;
281
+ err = deflate(&c_stream, Z_NO_FLUSH);
282
+ CHECK_ERR(err, "deflate");
283
+
284
+ /* Switch back to compressing mode: */
285
+ deflateParams(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED);
286
+ c_stream.next_in = uncompr;
287
+ c_stream.avail_in = (uInt)uncomprLen;
288
+ err = deflate(&c_stream, Z_NO_FLUSH);
289
+ CHECK_ERR(err, "deflate");
290
+
291
+ err = deflate(&c_stream, Z_FINISH);
292
+ if (err != Z_STREAM_END) {
293
+ fprintf(stderr, "deflate should report Z_STREAM_END\n");
294
+ exit(1);
295
+ }
296
+ err = deflateEnd(&c_stream);
297
+ CHECK_ERR(err, "deflateEnd");
298
+ }
299
+
300
+ /* ===========================================================================
301
+ * Test inflate() with large buffers
302
+ */
303
+ void test_large_inflate(compr, comprLen, uncompr, uncomprLen)
304
+ Byte *compr, *uncompr;
305
+ uLong comprLen, uncomprLen;
306
+ {
307
+ int err;
308
+ z_stream d_stream; /* decompression stream */
309
+
310
+ strcpy((char*)uncompr, "garbage");
311
+
312
+ d_stream.zalloc = (alloc_func)0;
313
+ d_stream.zfree = (free_func)0;
314
+ d_stream.opaque = (voidpf)0;
315
+
316
+ d_stream.next_in = compr;
317
+ d_stream.avail_in = (uInt)comprLen;
318
+
319
+ err = inflateInit(&d_stream);
320
+ CHECK_ERR(err, "inflateInit");
321
+
322
+ for (;;) {
323
+ d_stream.next_out = uncompr; /* discard the output */
324
+ d_stream.avail_out = (uInt)uncomprLen;
325
+ err = inflate(&d_stream, Z_NO_FLUSH);
326
+ if (err == Z_STREAM_END) break;
327
+ CHECK_ERR(err, "large inflate");
328
+ }
329
+
330
+ err = inflateEnd(&d_stream);
331
+ CHECK_ERR(err, "inflateEnd");
332
+
333
+ if (d_stream.total_out != 2*uncomprLen + comprLen/2) {
334
+ fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out);
335
+ exit(1);
336
+ } else {
337
+ printf("large_inflate(): OK\n");
338
+ }
339
+ }
340
+
341
+ /* ===========================================================================
342
+ * Test deflate() with full flush
343
+ */
344
+ void test_flush(compr, comprLen)
345
+ Byte *compr;
346
+ uLong *comprLen;
347
+ {
348
+ z_stream c_stream; /* compression stream */
349
+ int err;
350
+ uInt len = (uInt)strlen(hello)+1;
351
+
352
+ c_stream.zalloc = (alloc_func)0;
353
+ c_stream.zfree = (free_func)0;
354
+ c_stream.opaque = (voidpf)0;
355
+
356
+ err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
357
+ CHECK_ERR(err, "deflateInit");
358
+
359
+ c_stream.next_in = (Bytef*)hello;
360
+ c_stream.next_out = compr;
361
+ c_stream.avail_in = 3;
362
+ c_stream.avail_out = (uInt)*comprLen;
363
+ err = deflate(&c_stream, Z_FULL_FLUSH);
364
+ CHECK_ERR(err, "deflate");
365
+
366
+ compr[3]++; /* force an error in first compressed block */
367
+ c_stream.avail_in = len - 3;
368
+
369
+ err = deflate(&c_stream, Z_FINISH);
370
+ if (err != Z_STREAM_END) {
371
+ CHECK_ERR(err, "deflate");
372
+ }
373
+ err = deflateEnd(&c_stream);
374
+ CHECK_ERR(err, "deflateEnd");
375
+
376
+ *comprLen = c_stream.total_out;
377
+ }
378
+
379
+ /* ===========================================================================
380
+ * Test inflateSync()
381
+ */
382
+ void test_sync(compr, comprLen, uncompr, uncomprLen)
383
+ Byte *compr, *uncompr;
384
+ uLong comprLen, uncomprLen;
385
+ {
386
+ int err;
387
+ z_stream d_stream; /* decompression stream */
388
+
389
+ strcpy((char*)uncompr, "garbage");
390
+
391
+ d_stream.zalloc = (alloc_func)0;
392
+ d_stream.zfree = (free_func)0;
393
+ d_stream.opaque = (voidpf)0;
394
+
395
+ d_stream.next_in = compr;
396
+ d_stream.avail_in = 2; /* just read the zlib header */
397
+
398
+ err = inflateInit(&d_stream);
399
+ CHECK_ERR(err, "inflateInit");
400
+
401
+ d_stream.next_out = uncompr;
402
+ d_stream.avail_out = (uInt)uncomprLen;
403
+
404
+ inflate(&d_stream, Z_NO_FLUSH);
405
+ CHECK_ERR(err, "inflate");
406
+
407
+ d_stream.avail_in = (uInt)comprLen-2; /* read all compressed data */
408
+ err = inflateSync(&d_stream); /* but skip the damaged part */
409
+ CHECK_ERR(err, "inflateSync");
410
+
411
+ err = inflate(&d_stream, Z_FINISH);
412
+ if (err != Z_DATA_ERROR) {
413
+ fprintf(stderr, "inflate should report DATA_ERROR\n");
414
+ /* Because of incorrect adler32 */
415
+ exit(1);
416
+ }
417
+ err = inflateEnd(&d_stream);
418
+ CHECK_ERR(err, "inflateEnd");
419
+
420
+ printf("after inflateSync(): hel%s\n", (char *)uncompr);
421
+ }
422
+
423
+ /* ===========================================================================
424
+ * Test deflate() with preset dictionary
425
+ */
426
+ void test_dict_deflate(compr, comprLen)
427
+ Byte *compr;
428
+ uLong comprLen;
429
+ {
430
+ z_stream c_stream; /* compression stream */
431
+ int err;
432
+
433
+ c_stream.zalloc = (alloc_func)0;
434
+ c_stream.zfree = (free_func)0;
435
+ c_stream.opaque = (voidpf)0;
436
+
437
+ err = deflateInit(&c_stream, Z_BEST_COMPRESSION);
438
+ CHECK_ERR(err, "deflateInit");
439
+
440
+ err = deflateSetDictionary(&c_stream,
441
+ (const Bytef*)dictionary, sizeof(dictionary));
442
+ CHECK_ERR(err, "deflateSetDictionary");
443
+
444
+ dictId = c_stream.adler;
445
+ c_stream.next_out = compr;
446
+ c_stream.avail_out = (uInt)comprLen;
447
+
448
+ c_stream.next_in = (Bytef*)hello;
449
+ c_stream.avail_in = (uInt)strlen(hello)+1;
450
+
451
+ err = deflate(&c_stream, Z_FINISH);
452
+ if (err != Z_STREAM_END) {
453
+ fprintf(stderr, "deflate should report Z_STREAM_END\n");
454
+ exit(1);
455
+ }
456
+ err = deflateEnd(&c_stream);
457
+ CHECK_ERR(err, "deflateEnd");
458
+ }
459
+
460
+ /* ===========================================================================
461
+ * Test inflate() with a preset dictionary
462
+ */
463
+ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
464
+ Byte *compr, *uncompr;
465
+ uLong comprLen, uncomprLen;
466
+ {
467
+ int err;
468
+ z_stream d_stream; /* decompression stream */
469
+
470
+ strcpy((char*)uncompr, "garbage");
471
+
472
+ d_stream.zalloc = (alloc_func)0;
473
+ d_stream.zfree = (free_func)0;
474
+ d_stream.opaque = (voidpf)0;
475
+
476
+ d_stream.next_in = compr;
477
+ d_stream.avail_in = (uInt)comprLen;
478
+
479
+ err = inflateInit(&d_stream);
480
+ CHECK_ERR(err, "inflateInit");
481
+
482
+ d_stream.next_out = uncompr;
483
+ d_stream.avail_out = (uInt)uncomprLen;
484
+
485
+ for (;;) {
486
+ err = inflate(&d_stream, Z_NO_FLUSH);
487
+ if (err == Z_STREAM_END) break;
488
+ if (err == Z_NEED_DICT) {
489
+ if (d_stream.adler != dictId) {
490
+ fprintf(stderr, "unexpected dictionary");
491
+ exit(1);
492
+ }
493
+ err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary,
494
+ sizeof(dictionary));
495
+ }
496
+ CHECK_ERR(err, "inflate with dict");
497
+ }
498
+
499
+ err = inflateEnd(&d_stream);
500
+ CHECK_ERR(err, "inflateEnd");
501
+
502
+ if (strcmp((char*)uncompr, hello)) {
503
+ fprintf(stderr, "bad inflate with dict\n");
504
+ exit(1);
505
+ } else {
506
+ printf("inflate with dictionary: %s\n", (char *)uncompr);
507
+ }
508
+ }
509
+
510
+ /* ===========================================================================
511
+ * Usage: example [output.gz [input.gz]]
512
+ */
513
+
514
+ int main(argc, argv)
515
+ int argc;
516
+ char *argv[];
517
+ {
518
+ Byte *compr, *uncompr;
519
+ uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */
520
+ uLong uncomprLen = comprLen;
521
+ static const char* myVersion = ZLIB_VERSION;
522
+
523
+ if (zlibVersion()[0] != myVersion[0]) {
524
+ fprintf(stderr, "incompatible zlib version\n");
525
+ exit(1);
526
+
527
+ } else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) {
528
+ fprintf(stderr, "warning: different zlib version\n");
529
+ }
530
+
531
+ printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n",
532
+ ZLIB_VERSION, ZLIB_VERNUM, zlibCompileFlags());
533
+
534
+ compr = (Byte*)calloc((uInt)comprLen, 1);
535
+ uncompr = (Byte*)calloc((uInt)uncomprLen, 1);
536
+ /* compr and uncompr are cleared to avoid reading uninitialized
537
+ * data and to ensure that uncompr compresses well.
538
+ */
539
+ if (compr == Z_NULL || uncompr == Z_NULL) {
540
+ printf("out of memory\n");
541
+ exit(1);
542
+ }
543
+ test_compress(compr, comprLen, uncompr, uncomprLen);
544
+
545
+ test_gzio((argc > 1 ? argv[1] : TESTFILE),
546
+ uncompr, uncomprLen);
547
+
548
+ test_deflate(compr, comprLen);
549
+ test_inflate(compr, comprLen, uncompr, uncomprLen);
550
+
551
+ test_large_deflate(compr, comprLen, uncompr, uncomprLen);
552
+ test_large_inflate(compr, comprLen, uncompr, uncomprLen);
553
+
554
+ test_flush(compr, &comprLen);
555
+ test_sync(compr, comprLen, uncompr, uncomprLen);
556
+ comprLen = uncomprLen;
557
+
558
+ test_dict_deflate(compr, comprLen);
559
+ test_dict_inflate(compr, comprLen, uncompr, uncomprLen);
560
+
561
+ free(compr);
562
+ free(uncompr);
563
+
564
+ return 0;
565
+ }