gosu 0.7.10.3 → 0.7.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (545) hide show
  1. data/Gosu/AutoLink.hpp +0 -0
  2. data/Gosu/ButtonsMac.hpp +26 -0
  3. data/Gosu/ButtonsWin.hpp +26 -0
  4. data/Gosu/ButtonsX.hpp +26 -0
  5. data/Gosu/Gosu.hpp +1 -0
  6. data/Gosu/Graphics.hpp +1 -1
  7. data/Gosu/Input.hpp +4 -5
  8. data/Gosu/Math.hpp +11 -0
  9. data/Gosu/Text.hpp +59 -47
  10. data/Gosu/Utility.hpp +6 -5
  11. data/GosuImpl/Graphics/DrawOp.hpp +0 -0
  12. data/GosuImpl/Graphics/Font.cpp +45 -4
  13. data/GosuImpl/Graphics/Graphics.cpp +25 -0
  14. data/GosuImpl/Graphics/TexChunk.cpp +0 -0
  15. data/GosuImpl/Graphics/TexChunk.hpp +0 -0
  16. data/GosuImpl/Graphics/Text.cpp +26 -2
  17. data/GosuImpl/Graphics/TextMac.cpp +8 -2
  18. data/GosuImpl/Graphics/TextPangoFT.cpp +0 -0
  19. data/GosuImpl/Graphics/Texture.cpp +0 -0
  20. data/GosuImpl/Graphics/Texture.hpp +0 -0
  21. data/GosuImpl/Iconv.hpp +62 -0
  22. data/GosuImpl/InputMac.mm +3 -0
  23. data/GosuImpl/InputWin.cpp +5 -1
  24. data/GosuImpl/InputX.cpp +50 -8
  25. data/GosuImpl/Math.cpp +1 -1
  26. data/GosuImpl/RubyGosu.swg +24 -5
  27. data/GosuImpl/RubyGosu_wrap.cxx +181 -10
  28. data/GosuImpl/Utility.cpp +32 -75
  29. data/GosuImpl/Utility.cpp~RF6c566.TMP +95 -0
  30. data/GosuImpl/WindowX.cpp +2 -2
  31. data/Rakefile +57 -10
  32. data/examples/Tutorial.cpp +0 -0
  33. data/examples/media/Beep.wav +0 -0
  34. data/examples/media/CptnRuby Map.txt b/data/examples/media/CptnRuby → Map.txt +0 -0
  35. data/examples/media/Explosion.wav +0 -0
  36. data/examples/media/Space.png +0 -0
  37. data/examples/media/Star.png +0 -0
  38. data/examples/media/Starfighter.bmp +0 -0
  39. data/linux/Makefile.in +0 -0
  40. data/linux/configure +0 -0
  41. data/linux/configure.ac +0 -0
  42. data/mac/Gosu.xcodeproj/jlnr.mode1v3 +1421 -0
  43. data/mac/Gosu.xcodeproj/jlnr.mode2v3 +1464 -0
  44. data/mac/Gosu.xcodeproj/jlnr.pbxuser +733 -0
  45. data/mac/Gosu.xcodeproj/project.pbxproj +4 -2
  46. data/reference/Async_8hpp-source.html +1 -1
  47. data/reference/Audio_8hpp-source.html +1 -1
  48. data/reference/Audio_8hpp.html +1 -1
  49. data/reference/AutoLink_8hpp-source.html +1 -1
  50. data/reference/AutoLink_8hpp.html +1 -1
  51. data/reference/Bitmap_8hpp-source.html +1 -1
  52. data/reference/Bitmap_8hpp.html +1 -1
  53. data/reference/ButtonsMac_8hpp-source.html +107 -81
  54. data/reference/ButtonsWin_8hpp-source.html +84 -58
  55. data/reference/ButtonsX_8hpp-source.html +131 -105
  56. data/reference/Color_8hpp-source.html +1 -1
  57. data/reference/Color_8hpp.html +1 -1
  58. data/reference/Directories_8hpp-source.html +1 -1
  59. data/reference/Directories_8hpp.html +1 -1
  60. data/reference/Font_8hpp-source.html +1 -1
  61. data/reference/Font_8hpp.html +1 -1
  62. data/reference/Fwd_8hpp-source.html +1 -1
  63. data/reference/Fwd_8hpp.html +1 -1
  64. data/reference/Gosu_8hpp-source.html +5 -4
  65. data/reference/Gosu_8hpp.html +1 -1
  66. data/reference/GraphicsBase_8hpp-source.html +1 -1
  67. data/reference/GraphicsBase_8hpp.html +1 -1
  68. data/reference/Graphics_8hpp-source.html +2 -2
  69. data/reference/Graphics_8hpp.html +1 -1
  70. data/reference/IO_8hpp-source.html +1 -1
  71. data/reference/IO_8hpp.html +1 -1
  72. data/reference/ImageData_8hpp-source.html +1 -1
  73. data/reference/ImageData_8hpp.html +1 -1
  74. data/reference/Image_8hpp-source.html +1 -1
  75. data/reference/Image_8hpp.html +1 -1
  76. data/reference/Input_8hpp-source.html +43 -43
  77. data/reference/Input_8hpp.html +2 -2
  78. data/reference/Math_8hpp-source.html +51 -42
  79. data/reference/Math_8hpp.html +5 -1
  80. data/reference/Platform_8hpp-source.html +1 -1
  81. data/reference/Platform_8hpp.html +1 -1
  82. data/reference/RotFlip_8hpp-source.html +1 -1
  83. data/reference/RotFlip_8hpp.html +1 -1
  84. data/reference/Sockets_8hpp-source.html +1 -1
  85. data/reference/Sockets_8hpp.html +1 -1
  86. data/reference/TextInput_8hpp-source.html +1 -1
  87. data/reference/TextInput_8hpp.html +1 -1
  88. data/reference/Text_8hpp-source.html +12 -8
  89. data/reference/Text_8hpp.html +3 -1
  90. data/reference/Timing_8hpp-source.html +1 -1
  91. data/reference/Timing_8hpp.html +1 -1
  92. data/reference/Utility_8hpp-source.html +9 -10
  93. data/reference/Utility_8hpp.html +5 -7
  94. data/reference/WinUtility_8hpp-source.html +1 -1
  95. data/reference/WinUtility_8hpp.html +1 -1
  96. data/reference/Window_8hpp-source.html +3 -3
  97. data/reference/Window_8hpp.html +1 -1
  98. data/reference/annotated.html +2 -2
  99. data/reference/classGosu_1_1Audio-members.html +1 -1
  100. data/reference/classGosu_1_1Audio.html +1 -1
  101. data/reference/classGosu_1_1Bitmap-members.html +1 -1
  102. data/reference/classGosu_1_1Bitmap.html +1 -1
  103. data/reference/classGosu_1_1Buffer-members.html +1 -1
  104. data/reference/classGosu_1_1Buffer.html +1 -1
  105. data/reference/classGosu_1_1Button-members.html +1 -1
  106. data/reference/classGosu_1_1Button.html +1 -1
  107. data/reference/classGosu_1_1Color-members.html +1 -1
  108. data/reference/classGosu_1_1Color.html +1 -1
  109. data/reference/classGosu_1_1File-members.html +1 -1
  110. data/reference/classGosu_1_1File.html +1 -1
  111. data/reference/classGosu_1_1Font-members.html +1 -1
  112. data/reference/classGosu_1_1Font.html +1 -1
  113. data/reference/classGosu_1_1Graphics-members.html +1 -1
  114. data/reference/classGosu_1_1Graphics.html +1 -1
  115. data/reference/classGosu_1_1Image-members.html +1 -1
  116. data/reference/classGosu_1_1Image.html +1 -1
  117. data/reference/classGosu_1_1ImageData-members.html +1 -1
  118. data/reference/classGosu_1_1ImageData.html +1 -1
  119. data/reference/classGosu_1_1Input-members.html +1 -1
  120. data/reference/classGosu_1_1Input.html +4 -4
  121. data/reference/classGosu_1_1MessageSocket-members.html +1 -1
  122. data/reference/classGosu_1_1MessageSocket.html +1 -1
  123. data/reference/classGosu_1_1Resource-members.html +1 -1
  124. data/reference/classGosu_1_1Resource.html +1 -1
  125. data/reference/classGosu_1_1Sample-members.html +1 -1
  126. data/reference/classGosu_1_1Sample.html +1 -1
  127. data/reference/classGosu_1_1SampleInstance-members.html +1 -1
  128. data/reference/classGosu_1_1SampleInstance.html +1 -1
  129. data/reference/classGosu_1_1Song-members.html +1 -1
  130. data/reference/classGosu_1_1Song.html +1 -1
  131. data/reference/classGosu_1_1TextInput-members.html +1 -1
  132. data/reference/classGosu_1_1TextInput.html +1 -1
  133. data/reference/classGosu_1_1Window-members.html +1 -1
  134. data/reference/classGosu_1_1Window.html +1 -1
  135. data/reference/files.html +1 -1
  136. data/reference/functions.html +1 -1
  137. data/reference/functions_enum.html +1 -1
  138. data/reference/functions_func.html +1 -1
  139. data/reference/functions_vars.html +1 -1
  140. data/reference/hierarchy.html +1 -1
  141. data/reference/index.html +1 -1
  142. data/reference/namespaceGosu.html +935 -492
  143. data/reference/namespaceGosu_1_1Colors.html +1 -1
  144. data/reference/namespaceGosu_1_1Win.html +1 -1
  145. data/reference/namespacemembers.html +13 -2
  146. data/reference/namespacemembers_enum.html +1 -1
  147. data/reference/namespacemembers_eval.html +1 -1
  148. data/reference/namespacemembers_func.html +13 -2
  149. data/reference/namespacemembers_type.html +1 -1
  150. data/reference/namespacemembers_vars.html +1 -1
  151. data/reference/namespaces.html +1 -1
  152. data/windows/Gosu.vcproj +4 -4
  153. data/windows/RubyGosu.vcproj +2 -1
  154. data/windows/zlib, libpng/libpng/ANNOUNCE +61 -0
  155. data/windows/zlib, libpng/libpng/CHANGES +2173 -0
  156. data/windows/zlib, libpng/libpng/INSTALL +199 -0
  157. data/windows/zlib, libpng/libpng/KNOWNBUG +22 -0
  158. data/windows/zlib, libpng/libpng/LICENSE +109 -0
  159. data/windows/zlib, libpng/libpng/README +264 -0
  160. data/windows/zlib, libpng/libpng/TODO +24 -0
  161. data/windows/zlib, libpng/libpng/Y2KINFO +55 -0
  162. data/windows/zlib, libpng/libpng/configure +13 -0
  163. data/windows/zlib, libpng/libpng/contrib/gregbook/COPYING +340 -0
  164. data/windows/zlib, libpng/libpng/contrib/gregbook/LICENSE +50 -0
  165. data/windows/zlib, libpng/libpng/contrib/gregbook/Makefile.mingw32 +130 -0
  166. data/windows/zlib, libpng/libpng/contrib/gregbook/Makefile.sgi +104 -0
  167. data/windows/zlib, libpng/libpng/contrib/gregbook/Makefile.unx +132 -0
  168. data/windows/zlib, libpng/libpng/contrib/gregbook/Makefile.w32 +113 -0
  169. data/windows/zlib, libpng/libpng/contrib/gregbook/README +186 -0
  170. data/windows/zlib, libpng/libpng/contrib/gregbook/makevms.com +132 -0
  171. data/windows/zlib, libpng/libpng/contrib/gregbook/readpng.c +304 -0
  172. data/windows/zlib, libpng/libpng/contrib/gregbook/readpng.h +88 -0
  173. data/windows/zlib, libpng/libpng/contrib/gregbook/readpng2.c +645 -0
  174. data/windows/zlib, libpng/libpng/contrib/gregbook/readpng2.h +121 -0
  175. data/windows/zlib, libpng/libpng/contrib/gregbook/readppm.c +179 -0
  176. data/windows/zlib, libpng/libpng/contrib/gregbook/rpng-win.c +684 -0
  177. data/windows/zlib, libpng/libpng/contrib/gregbook/rpng-x.c +904 -0
  178. data/windows/zlib, libpng/libpng/contrib/gregbook/rpng2-win.c +1225 -0
  179. data/windows/zlib, libpng/libpng/contrib/gregbook/rpng2-x.c +2127 -0
  180. data/windows/zlib, libpng/libpng/contrib/gregbook/toucan.png +0 -0
  181. data/windows/zlib, libpng/libpng/contrib/gregbook/wpng.c +853 -0
  182. data/windows/zlib, libpng/libpng/contrib/gregbook/writepng.c +392 -0
  183. data/windows/zlib, libpng/libpng/contrib/gregbook/writepng.h +133 -0
  184. data/windows/zlib, libpng/libpng/contrib/pngminim/decoder/README +6 -0
  185. data/windows/zlib, libpng/libpng/contrib/pngminim/decoder/gather.sh +8 -0
  186. data/windows/zlib, libpng/libpng/contrib/pngminim/decoder/makefile.std +44 -0
  187. data/windows/zlib, libpng/libpng/contrib/pngminim/decoder/pngusr.h +67 -0
  188. data/windows/zlib, libpng/libpng/contrib/pngminim/encoder/README +6 -0
  189. data/windows/zlib, libpng/libpng/contrib/pngminim/encoder/dummy_inflate.c +27 -0
  190. data/windows/zlib, libpng/libpng/contrib/pngminim/encoder/gather.sh +9 -0
  191. data/windows/zlib, libpng/libpng/contrib/pngminim/encoder/makefile.std +43 -0
  192. data/windows/zlib, libpng/libpng/contrib/pngminim/encoder/pngusr.h +66 -0
  193. data/windows/zlib, libpng/libpng/contrib/pngminus/README +153 -0
  194. data/windows/zlib, libpng/libpng/contrib/pngminus/makefile.std +65 -0
  195. data/windows/zlib, libpng/libpng/contrib/pngminus/makefile.tc3 +38 -0
  196. data/windows/zlib, libpng/libpng/contrib/pngminus/makevms.com +92 -0
  197. data/windows/zlib, libpng/libpng/contrib/pngminus/png2pnm.bat +41 -0
  198. data/windows/zlib, libpng/libpng/contrib/pngminus/png2pnm.c +430 -0
  199. data/windows/zlib, libpng/libpng/contrib/pngminus/png2pnm.sh +42 -0
  200. data/windows/zlib, libpng/libpng/contrib/pngminus/pngminus.bat +4 -0
  201. data/windows/zlib, libpng/libpng/contrib/pngminus/pngminus.sh +5 -0
  202. data/windows/zlib, libpng/libpng/contrib/pngminus/pnm2png.bat +41 -0
  203. data/windows/zlib, libpng/libpng/contrib/pngminus/pnm2png.c +533 -0
  204. data/windows/zlib, libpng/libpng/contrib/pngminus/pnm2png.sh +42 -0
  205. data/windows/zlib, libpng/libpng/contrib/pngsuite/basn0g01.png +0 -0
  206. data/windows/zlib, libpng/libpng/contrib/pngsuite/basn0g02.png +0 -0
  207. data/windows/zlib, libpng/libpng/contrib/pngsuite/basn0g04.png +0 -0
  208. data/windows/zlib, libpng/libpng/contrib/pngsuite/basn0g08.png +0 -0
  209. data/windows/zlib, libpng/libpng/contrib/pngsuite/basn0g16.png +0 -0
  210. data/windows/zlib, libpng/libpng/contrib/pngsuite/basn2c08.png +0 -0
  211. data/windows/zlib, libpng/libpng/contrib/pngsuite/basn2c16.png +0 -0
  212. data/windows/zlib, libpng/libpng/contrib/pngsuite/basn3p01.png +0 -0
  213. data/windows/zlib, libpng/libpng/contrib/pngsuite/basn3p02.png +0 -0
  214. data/windows/zlib, libpng/libpng/contrib/pngsuite/basn3p04.png +0 -0
  215. data/windows/zlib, libpng/libpng/contrib/pngsuite/basn3p08.png +0 -0
  216. data/windows/zlib, libpng/libpng/contrib/pngsuite/basn4a08.png +0 -0
  217. data/windows/zlib, libpng/libpng/contrib/pngsuite/basn4a16.png +0 -0
  218. data/windows/zlib, libpng/libpng/contrib/pngsuite/basn6a08.png +0 -0
  219. data/windows/zlib, libpng/libpng/contrib/pngsuite/basn6a16.png +0 -0
  220. data/windows/zlib, libpng/libpng/contrib/visupng/PngFile.c +439 -0
  221. data/windows/zlib, libpng/libpng/contrib/visupng/PngFile.h +27 -0
  222. data/windows/zlib, libpng/libpng/contrib/visupng/README.txt +58 -0
  223. data/windows/zlib, libpng/libpng/contrib/visupng/VisualPng.c +961 -0
  224. data/windows/zlib, libpng/libpng/contrib/visupng/VisualPng.dsp +147 -0
  225. data/windows/zlib, libpng/libpng/contrib/visupng/VisualPng.dsw +29 -0
  226. data/windows/zlib, libpng/libpng/contrib/visupng/VisualPng.ico +0 -0
  227. data/windows/zlib, libpng/libpng/contrib/visupng/VisualPng.png +0 -0
  228. data/windows/zlib, libpng/libpng/contrib/visupng/VisualPng.rc +152 -0
  229. data/windows/zlib, libpng/libpng/contrib/visupng/cexcept.h +243 -0
  230. data/windows/zlib, libpng/libpng/contrib/visupng/resource.h +23 -0
  231. data/windows/zlib, libpng/libpng/example.c +814 -0
  232. data/windows/zlib, libpng/libpng/libpng-1.2.29.txt +2906 -0
  233. data/windows/zlib, libpng/libpng/libpng.3 +3680 -0
  234. data/windows/zlib, libpng/libpng/libpngpf.3 +274 -0
  235. data/windows/zlib, libpng/libpng/png.5 +74 -0
  236. data/windows/zlib, libpng/libpng/png.c +798 -0
  237. data/windows/zlib, libpng/libpng/png.h +3569 -0
  238. data/windows/zlib, libpng/libpng/pngbar.jpg +0 -0
  239. data/windows/zlib, libpng/libpng/pngbar.png +0 -0
  240. data/windows/zlib, libpng/libpng/pngconf.h +1481 -0
  241. data/windows/zlib, libpng/libpng/pngerror.c +343 -0
  242. data/windows/zlib, libpng/libpng/pnggccrd.c +103 -0
  243. data/windows/zlib, libpng/libpng/pngget.c +901 -0
  244. data/windows/zlib, libpng/libpng/pngmem.c +608 -0
  245. data/windows/zlib, libpng/libpng/pngnow.png +0 -0
  246. data/windows/zlib, libpng/libpng/pngpread.c +1598 -0
  247. data/windows/zlib, libpng/libpng/pngread.c +1479 -0
  248. data/windows/zlib, libpng/libpng/pngrio.c +167 -0
  249. data/windows/zlib, libpng/libpng/pngrtran.c +4292 -0
  250. data/windows/zlib, libpng/libpng/pngrutil.c +3183 -0
  251. data/windows/zlib, libpng/libpng/pngset.c +1268 -0
  252. data/windows/zlib, libpng/libpng/pngtest.c +1563 -0
  253. data/windows/zlib, libpng/libpng/pngtest.png +0 -0
  254. data/windows/zlib, libpng/libpng/pngtrans.c +662 -0
  255. data/windows/zlib, libpng/libpng/pngvcrd.c +1 -0
  256. data/windows/zlib, libpng/libpng/pngwio.c +234 -0
  257. data/windows/zlib, libpng/libpng/pngwrite.c +1532 -0
  258. data/windows/zlib, libpng/libpng/pngwtran.c +572 -0
  259. data/windows/zlib, libpng/libpng/pngwutil.c +2802 -0
  260. data/windows/zlib, libpng/libpng/projects/beos/x86-shared.proj +0 -0
  261. data/windows/zlib, libpng/libpng/projects/beos/x86-shared.txt +22 -0
  262. data/windows/zlib, libpng/libpng/projects/beos/x86-static.proj +0 -0
  263. data/windows/zlib, libpng/libpng/projects/beos/x86-static.txt +22 -0
  264. data/windows/zlib, libpng/libpng/projects/cbuilder5/libpng.bpf +22 -0
  265. data/windows/zlib, libpng/libpng/projects/cbuilder5/libpng.bpg +25 -0
  266. data/windows/zlib, libpng/libpng/projects/cbuilder5/libpng.bpr +157 -0
  267. data/windows/zlib, libpng/libpng/projects/cbuilder5/libpng.cpp +29 -0
  268. data/windows/zlib, libpng/libpng/projects/cbuilder5/libpng.readme.txt +25 -0
  269. data/windows/zlib, libpng/libpng/projects/cbuilder5/libpngstat.bpf +22 -0
  270. data/windows/zlib, libpng/libpng/projects/cbuilder5/libpngstat.bpr +109 -0
  271. data/windows/zlib, libpng/libpng/projects/cbuilder5/zlib.readme.txt +14 -0
  272. data/windows/zlib, libpng/libpng/projects/netware.txt +6 -0
  273. data/windows/zlib, libpng/libpng/projects/visualc6/README.txt +57 -0
  274. data/windows/zlib, libpng/libpng/projects/visualc6/libpng.dsp +472 -0
  275. data/windows/zlib, libpng/libpng/projects/visualc6/libpng.dsw +59 -0
  276. data/windows/zlib, libpng/libpng/projects/visualc6/pngtest.dsp +314 -0
  277. data/windows/zlib, libpng/libpng/projects/visualc71/PRJ0041.mak +21 -0
  278. data/windows/zlib, libpng/libpng/projects/visualc71/README.txt +57 -0
  279. data/windows/zlib, libpng/libpng/projects/visualc71/README_zlib.txt +44 -0
  280. data/windows/zlib, libpng/libpng/projects/visualc71/libpng.sln +88 -0
  281. data/windows/zlib, libpng/libpng/projects/visualc71/libpng.vcproj +702 -0
  282. data/windows/zlib, libpng/libpng/projects/visualc71/pngtest.vcproj +459 -0
  283. data/windows/zlib, libpng/libpng/projects/visualc71/zlib.vcproj +670 -0
  284. data/windows/zlib, libpng/libpng/projects/wince.txt +6 -0
  285. data/windows/zlib, libpng/libpng/scripts/CMakeLists.txt +210 -0
  286. data/windows/zlib, libpng/libpng/scripts/SCOPTIONS.ppc +7 -0
  287. data/windows/zlib, libpng/libpng/scripts/descrip.mms +52 -0
  288. data/windows/zlib, libpng/libpng/scripts/libpng-config-body.in +96 -0
  289. data/windows/zlib, libpng/libpng/scripts/libpng-config-head.in +21 -0
  290. data/windows/zlib, libpng/libpng/scripts/libpng-config.in +124 -0
  291. data/windows/zlib, libpng/libpng/scripts/libpng.icc +44 -0
  292. data/windows/zlib, libpng/libpng/scripts/libpng.pc-configure.in +10 -0
  293. data/windows/zlib, libpng/libpng/scripts/libpng.pc.in +10 -0
  294. data/windows/zlib, libpng/libpng/scripts/makefile.32sunu +254 -0
  295. data/windows/zlib, libpng/libpng/scripts/makefile.64sunu +254 -0
  296. data/windows/zlib, libpng/libpng/scripts/makefile.acorn +51 -0
  297. data/windows/zlib, libpng/libpng/scripts/makefile.aix +113 -0
  298. data/windows/zlib, libpng/libpng/scripts/makefile.amiga +48 -0
  299. data/windows/zlib, libpng/libpng/scripts/makefile.atari +51 -0
  300. data/windows/zlib, libpng/libpng/scripts/makefile.bc32 +152 -0
  301. data/windows/zlib, libpng/libpng/scripts/makefile.beos +226 -0
  302. data/windows/zlib, libpng/libpng/scripts/makefile.bor +162 -0
  303. data/windows/zlib, libpng/libpng/scripts/makefile.cygwin +299 -0
  304. data/windows/zlib, libpng/libpng/scripts/makefile.darwin +234 -0
  305. data/windows/zlib, libpng/libpng/scripts/makefile.dec +214 -0
  306. data/windows/zlib, libpng/libpng/scripts/makefile.dj2 +55 -0
  307. data/windows/zlib, libpng/libpng/scripts/makefile.elf +275 -0
  308. data/windows/zlib, libpng/libpng/scripts/makefile.freebsd +48 -0
  309. data/windows/zlib, libpng/libpng/scripts/makefile.gcc +79 -0
  310. data/windows/zlib, libpng/libpng/scripts/makefile.gcmmx +271 -0
  311. data/windows/zlib, libpng/libpng/scripts/makefile.hp64 +235 -0
  312. data/windows/zlib, libpng/libpng/scripts/makefile.hpgcc +245 -0
  313. data/windows/zlib, libpng/libpng/scripts/makefile.hpux +232 -0
  314. data/windows/zlib, libpng/libpng/scripts/makefile.ibmc +71 -0
  315. data/windows/zlib, libpng/libpng/scripts/makefile.intel +102 -0
  316. data/windows/zlib, libpng/libpng/scripts/makefile.knr +99 -0
  317. data/windows/zlib, libpng/libpng/scripts/makefile.linux +249 -0
  318. data/windows/zlib, libpng/libpng/scripts/makefile.mingw +289 -0
  319. data/windows/zlib, libpng/libpng/scripts/makefile.mips +83 -0
  320. data/windows/zlib, libpng/libpng/scripts/makefile.msc +86 -0
  321. data/windows/zlib, libpng/libpng/scripts/makefile.ne12bsd +45 -0
  322. data/windows/zlib, libpng/libpng/scripts/makefile.netbsd +45 -0
  323. data/windows/zlib, libpng/libpng/scripts/makefile.nommx +252 -0
  324. data/windows/zlib, libpng/libpng/scripts/makefile.openbsd +73 -0
  325. data/windows/zlib, libpng/libpng/scripts/makefile.os2 +69 -0
  326. data/windows/zlib, libpng/libpng/scripts/makefile.sco +229 -0
  327. data/windows/zlib, libpng/libpng/scripts/makefile.sggcc +242 -0
  328. data/windows/zlib, libpng/libpng/scripts/makefile.sgi +245 -0
  329. data/windows/zlib, libpng/libpng/scripts/makefile.so9 +251 -0
  330. data/windows/zlib, libpng/libpng/scripts/makefile.solaris +249 -0
  331. data/windows/zlib, libpng/libpng/scripts/makefile.solaris-x86 +248 -0
  332. data/windows/zlib, libpng/libpng/scripts/makefile.std +92 -0
  333. data/windows/zlib, libpng/libpng/scripts/makefile.sunos +97 -0
  334. data/windows/zlib, libpng/libpng/scripts/makefile.tc3 +89 -0
  335. data/windows/zlib, libpng/libpng/scripts/makefile.vcawin32 +99 -0
  336. data/windows/zlib, libpng/libpng/scripts/makefile.vcwin32 +99 -0
  337. data/windows/zlib, libpng/libpng/scripts/makefile.watcom +109 -0
  338. data/windows/zlib, libpng/libpng/scripts/makevms.com +144 -0
  339. data/windows/zlib, libpng/libpng/scripts/pngos2.def +257 -0
  340. data/windows/zlib, libpng/libpng/scripts/pngw32.def +238 -0
  341. data/windows/zlib, libpng/libpng/scripts/pngw32.rc +112 -0
  342. data/windows/zlib, libpng/libpng/scripts/smakefile.ppc +30 -0
  343. data/windows/zlib, libpng/zlib/ChangeLog +855 -0
  344. data/windows/zlib, libpng/zlib/FAQ +339 -0
  345. data/windows/zlib, libpng/zlib/INDEX +51 -0
  346. data/windows/zlib, libpng/zlib/Makefile +154 -0
  347. data/windows/zlib, libpng/zlib/Makefile.in +154 -0
  348. data/windows/zlib, libpng/zlib/README +125 -0
  349. data/windows/zlib, libpng/zlib/adler32.c +149 -0
  350. data/windows/zlib, libpng/zlib/algorithm.txt +209 -0
  351. data/windows/zlib, libpng/zlib/amiga/Makefile.pup +66 -0
  352. data/windows/zlib, libpng/zlib/amiga/Makefile.sas +65 -0
  353. data/windows/zlib, libpng/zlib/as400/bndsrc +132 -0
  354. data/windows/zlib, libpng/zlib/as400/compile.clp +123 -0
  355. data/windows/zlib, libpng/zlib/as400/readme.txt +111 -0
  356. data/windows/zlib, libpng/zlib/as400/zlib.inc +331 -0
  357. data/windows/zlib, libpng/zlib/compress.c +79 -0
  358. data/windows/zlib, libpng/zlib/configure +459 -0
  359. data/windows/zlib, libpng/zlib/contrib/README.contrib +71 -0
  360. data/windows/zlib, libpng/zlib/contrib/ada/buffer_demo.adb +106 -0
  361. data/windows/zlib, libpng/zlib/contrib/ada/mtest.adb +156 -0
  362. data/windows/zlib, libpng/zlib/contrib/ada/read.adb +156 -0
  363. data/windows/zlib, libpng/zlib/contrib/ada/readme.txt +65 -0
  364. data/windows/zlib, libpng/zlib/contrib/ada/test.adb +463 -0
  365. data/windows/zlib, libpng/zlib/contrib/ada/zlib-streams.adb +225 -0
  366. data/windows/zlib, libpng/zlib/contrib/ada/zlib-streams.ads +114 -0
  367. data/windows/zlib, libpng/zlib/contrib/ada/zlib-thin.adb +141 -0
  368. data/windows/zlib, libpng/zlib/contrib/ada/zlib-thin.ads +450 -0
  369. data/windows/zlib, libpng/zlib/contrib/ada/zlib.adb +701 -0
  370. data/windows/zlib, libpng/zlib/contrib/ada/zlib.ads +328 -0
  371. data/windows/zlib, libpng/zlib/contrib/ada/zlib.gpr +20 -0
  372. data/windows/zlib, libpng/zlib/contrib/asm586/README.586 +43 -0
  373. data/windows/zlib, libpng/zlib/contrib/asm586/match.S +364 -0
  374. data/windows/zlib, libpng/zlib/contrib/asm686/README.686 +34 -0
  375. data/windows/zlib, libpng/zlib/contrib/asm686/match.S +329 -0
  376. data/windows/zlib, libpng/zlib/contrib/blast/Makefile +8 -0
  377. data/windows/zlib, libpng/zlib/contrib/blast/README +4 -0
  378. data/windows/zlib, libpng/zlib/contrib/blast/blast.c +444 -0
  379. data/windows/zlib, libpng/zlib/contrib/blast/blast.h +71 -0
  380. data/windows/zlib, libpng/zlib/contrib/blast/test.pk +0 -0
  381. data/windows/zlib, libpng/zlib/contrib/blast/test.txt +1 -0
  382. data/windows/zlib, libpng/zlib/contrib/delphi/ZLib.pas +557 -0
  383. data/windows/zlib, libpng/zlib/contrib/delphi/ZLibConst.pas +11 -0
  384. data/windows/zlib, libpng/zlib/contrib/delphi/readme.txt +76 -0
  385. data/windows/zlib, libpng/zlib/contrib/delphi/zlibd32.mak +93 -0
  386. data/windows/zlib, libpng/zlib/contrib/dotzlib/DotZLib.build +33 -0
  387. data/windows/zlib, libpng/zlib/contrib/dotzlib/DotZLib.chm +0 -0
  388. data/windows/zlib, libpng/zlib/contrib/dotzlib/DotZLib.sln +21 -0
  389. data/windows/zlib, libpng/zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs +58 -0
  390. data/windows/zlib, libpng/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs +202 -0
  391. data/windows/zlib, libpng/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs +83 -0
  392. data/windows/zlib, libpng/zlib/contrib/dotzlib/DotZLib/CodecBase.cs +198 -0
  393. data/windows/zlib, libpng/zlib/contrib/dotzlib/DotZLib/Deflater.cs +106 -0
  394. data/windows/zlib, libpng/zlib/contrib/dotzlib/DotZLib/DotZLib.cs +288 -0
  395. data/windows/zlib, libpng/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj +141 -0
  396. data/windows/zlib, libpng/zlib/contrib/dotzlib/DotZLib/GZipStream.cs +301 -0
  397. data/windows/zlib, libpng/zlib/contrib/dotzlib/DotZLib/Inflater.cs +105 -0
  398. data/windows/zlib, libpng/zlib/contrib/dotzlib/DotZLib/UnitTests.cs +274 -0
  399. data/windows/zlib, libpng/zlib/contrib/dotzlib/LICENSE_1_0.txt +23 -0
  400. data/windows/zlib, libpng/zlib/contrib/dotzlib/readme.txt +58 -0
  401. data/windows/zlib, libpng/zlib/contrib/infback9/README +1 -0
  402. data/windows/zlib, libpng/zlib/contrib/infback9/infback9.c +608 -0
  403. data/windows/zlib, libpng/zlib/contrib/infback9/infback9.h +37 -0
  404. data/windows/zlib, libpng/zlib/contrib/infback9/inffix9.h +107 -0
  405. data/windows/zlib, libpng/zlib/contrib/infback9/inflate9.h +47 -0
  406. data/windows/zlib, libpng/zlib/contrib/infback9/inftree9.c +323 -0
  407. data/windows/zlib, libpng/zlib/contrib/infback9/inftree9.h +55 -0
  408. data/windows/zlib, libpng/zlib/contrib/inflate86/inffas86.c +1157 -0
  409. data/windows/zlib, libpng/zlib/contrib/inflate86/inffast.S +1368 -0
  410. data/windows/zlib, libpng/zlib/contrib/iostream/test.cpp +24 -0
  411. data/windows/zlib, libpng/zlib/contrib/iostream/zfstream.cpp +329 -0
  412. data/windows/zlib, libpng/zlib/contrib/iostream/zfstream.h +128 -0
  413. data/windows/zlib, libpng/zlib/contrib/iostream2/zstream.h +307 -0
  414. data/windows/zlib, libpng/zlib/contrib/iostream2/zstream_test.cpp +25 -0
  415. data/windows/zlib, libpng/zlib/contrib/iostream3/README +35 -0
  416. data/windows/zlib, libpng/zlib/contrib/iostream3/TODO +17 -0
  417. data/windows/zlib, libpng/zlib/contrib/iostream3/test.cc +50 -0
  418. data/windows/zlib, libpng/zlib/contrib/iostream3/zfstream.cc +479 -0
  419. data/windows/zlib, libpng/zlib/contrib/iostream3/zfstream.h +466 -0
  420. data/windows/zlib, libpng/zlib/contrib/masm686/match.asm +413 -0
  421. data/windows/zlib, libpng/zlib/contrib/masmx64/bld_ml64.bat +2 -0
  422. data/windows/zlib, libpng/zlib/contrib/masmx64/gvmat64.asm +513 -0
  423. data/windows/zlib, libpng/zlib/contrib/masmx64/gvmat64.obj +0 -0
  424. data/windows/zlib, libpng/zlib/contrib/masmx64/inffas8664.c +186 -0
  425. data/windows/zlib, libpng/zlib/contrib/masmx64/inffasx64.asm +392 -0
  426. data/windows/zlib, libpng/zlib/contrib/masmx64/inffasx64.obj +0 -0
  427. data/windows/zlib, libpng/zlib/contrib/masmx64/readme.txt +28 -0
  428. data/windows/zlib, libpng/zlib/contrib/masmx86/bld_ml32.bat +2 -0
  429. data/windows/zlib, libpng/zlib/contrib/masmx86/gvmat32.asm +972 -0
  430. data/windows/zlib, libpng/zlib/contrib/masmx86/gvmat32.obj +0 -0
  431. data/windows/zlib, libpng/zlib/contrib/masmx86/gvmat32c.c +62 -0
  432. data/windows/zlib, libpng/zlib/contrib/masmx86/inffas32.asm +1083 -0
  433. data/windows/zlib, libpng/zlib/contrib/masmx86/inffas32.obj +0 -0
  434. data/windows/zlib, libpng/zlib/contrib/masmx86/mkasm.bat +3 -0
  435. data/windows/zlib, libpng/zlib/contrib/masmx86/readme.txt +21 -0
  436. data/windows/zlib, libpng/zlib/contrib/minizip/ChangeLogUnzip +67 -0
  437. data/windows/zlib, libpng/zlib/contrib/minizip/Makefile +25 -0
  438. data/windows/zlib, libpng/zlib/contrib/minizip/crypt.h +132 -0
  439. data/windows/zlib, libpng/zlib/contrib/minizip/ioapi.c +177 -0
  440. data/windows/zlib, libpng/zlib/contrib/minizip/ioapi.h +75 -0
  441. data/windows/zlib, libpng/zlib/contrib/minizip/iowin32.c +270 -0
  442. data/windows/zlib, libpng/zlib/contrib/minizip/iowin32.h +21 -0
  443. data/windows/zlib, libpng/zlib/contrib/minizip/miniunz.c +585 -0
  444. data/windows/zlib, libpng/zlib/contrib/minizip/minizip.c +420 -0
  445. data/windows/zlib, libpng/zlib/contrib/minizip/mztools.c +281 -0
  446. data/windows/zlib, libpng/zlib/contrib/minizip/mztools.h +31 -0
  447. data/windows/zlib, libpng/zlib/contrib/minizip/unzip.c +1598 -0
  448. data/windows/zlib, libpng/zlib/contrib/minizip/unzip.h +354 -0
  449. data/windows/zlib, libpng/zlib/contrib/minizip/zip.c +1219 -0
  450. data/windows/zlib, libpng/zlib/contrib/minizip/zip.h +235 -0
  451. data/windows/zlib, libpng/zlib/contrib/pascal/example.pas +599 -0
  452. data/windows/zlib, libpng/zlib/contrib/pascal/readme.txt +76 -0
  453. data/windows/zlib, libpng/zlib/contrib/pascal/zlibd32.mak +93 -0
  454. data/windows/zlib, libpng/zlib/contrib/pascal/zlibpas.pas +236 -0
  455. data/windows/zlib, libpng/zlib/contrib/puff/Makefile +8 -0
  456. data/windows/zlib, libpng/zlib/contrib/puff/README +63 -0
  457. data/windows/zlib, libpng/zlib/contrib/puff/puff.c +837 -0
  458. data/windows/zlib, libpng/zlib/contrib/puff/puff.h +31 -0
  459. data/windows/zlib, libpng/zlib/contrib/puff/zeros.raw +0 -0
  460. data/windows/zlib, libpng/zlib/contrib/testzlib/testzlib.c +275 -0
  461. data/windows/zlib, libpng/zlib/contrib/testzlib/testzlib.txt +10 -0
  462. data/windows/zlib, libpng/zlib/contrib/untgz/Makefile +14 -0
  463. data/windows/zlib, libpng/zlib/contrib/untgz/Makefile.msc +17 -0
  464. data/windows/zlib, libpng/zlib/contrib/untgz/untgz.c +674 -0
  465. data/windows/zlib, libpng/zlib/contrib/vstudio/readme.txt +73 -0
  466. data/windows/zlib, libpng/zlib/contrib/vstudio/vc7/miniunz.vcproj +126 -0
  467. data/windows/zlib, libpng/zlib/contrib/vstudio/vc7/minizip.vcproj +126 -0
  468. data/windows/zlib, libpng/zlib/contrib/vstudio/vc7/testzlib.vcproj +126 -0
  469. data/windows/zlib, libpng/zlib/contrib/vstudio/vc7/zlib.rc +32 -0
  470. data/windows/zlib, libpng/zlib/contrib/vstudio/vc7/zlibstat.vcproj +246 -0
  471. data/windows/zlib, libpng/zlib/contrib/vstudio/vc7/zlibvc.def +92 -0
  472. data/windows/zlib, libpng/zlib/contrib/vstudio/vc7/zlibvc.sln +78 -0
  473. data/windows/zlib, libpng/zlib/contrib/vstudio/vc7/zlibvc.vcproj +445 -0
  474. data/windows/zlib, libpng/zlib/contrib/vstudio/vc8/miniunz.vcproj +566 -0
  475. data/windows/zlib, libpng/zlib/contrib/vstudio/vc8/minizip.vcproj +563 -0
  476. data/windows/zlib, libpng/zlib/contrib/vstudio/vc8/testzlib.vcproj +948 -0
  477. data/windows/zlib, libpng/zlib/contrib/vstudio/vc8/testzlibdll.vcproj +567 -0
  478. data/windows/zlib, libpng/zlib/contrib/vstudio/vc8/zlib.rc +32 -0
  479. data/windows/zlib, libpng/zlib/contrib/vstudio/vc8/zlibstat.vcproj +870 -0
  480. data/windows/zlib, libpng/zlib/contrib/vstudio/vc8/zlibvc.def +92 -0
  481. data/windows/zlib, libpng/zlib/contrib/vstudio/vc8/zlibvc.sln +144 -0
  482. data/windows/zlib, libpng/zlib/contrib/vstudio/vc8/zlibvc.vcproj +1219 -0
  483. data/windows/zlib, libpng/zlib/crc32.c +423 -0
  484. data/windows/zlib, libpng/zlib/crc32.h +441 -0
  485. data/windows/zlib, libpng/zlib/deflate.c +1736 -0
  486. data/windows/zlib, libpng/zlib/deflate.h +331 -0
  487. data/windows/zlib, libpng/zlib/example.c +565 -0
  488. data/windows/zlib, libpng/zlib/examples/README.examples +42 -0
  489. data/windows/zlib, libpng/zlib/examples/fitblk.c +233 -0
  490. data/windows/zlib, libpng/zlib/examples/gun.c +693 -0
  491. data/windows/zlib, libpng/zlib/examples/gzappend.c +500 -0
  492. data/windows/zlib, libpng/zlib/examples/gzjoin.c +448 -0
  493. data/windows/zlib, libpng/zlib/examples/gzlog.c +413 -0
  494. data/windows/zlib, libpng/zlib/examples/gzlog.h +58 -0
  495. data/windows/zlib, libpng/zlib/examples/zlib_how.html +523 -0
  496. data/windows/zlib, libpng/zlib/examples/zpipe.c +191 -0
  497. data/windows/zlib, libpng/zlib/examples/zran.c +404 -0
  498. data/windows/zlib, libpng/zlib/gzio.c +1026 -0
  499. data/windows/zlib, libpng/zlib/infback.c +623 -0
  500. data/windows/zlib, libpng/zlib/inffast.c +318 -0
  501. data/windows/zlib, libpng/zlib/inffast.h +11 -0
  502. data/windows/zlib, libpng/zlib/inffixed.h +94 -0
  503. data/windows/zlib, libpng/zlib/inflate.c +1368 -0
  504. data/windows/zlib, libpng/zlib/inflate.h +115 -0
  505. data/windows/zlib, libpng/zlib/inftrees.c +329 -0
  506. data/windows/zlib, libpng/zlib/inftrees.h +55 -0
  507. data/windows/zlib, libpng/zlib/make_vms.com +461 -0
  508. data/windows/zlib, libpng/zlib/minigzip.c +322 -0
  509. data/windows/zlib, libpng/zlib/msdos/Makefile.bor +109 -0
  510. data/windows/zlib, libpng/zlib/msdos/Makefile.dj2 +104 -0
  511. data/windows/zlib, libpng/zlib/msdos/Makefile.emx +69 -0
  512. data/windows/zlib, libpng/zlib/msdos/Makefile.msc +106 -0
  513. data/windows/zlib, libpng/zlib/msdos/Makefile.tc +94 -0
  514. data/windows/zlib, libpng/zlib/old/Makefile.riscos +151 -0
  515. data/windows/zlib, libpng/zlib/old/README +3 -0
  516. data/windows/zlib, libpng/zlib/old/descrip.mms +48 -0
  517. data/windows/zlib, libpng/zlib/old/os2/Makefile.os2 +136 -0
  518. data/windows/zlib, libpng/zlib/old/os2/zlib.def +51 -0
  519. data/windows/zlib, libpng/zlib/old/visual-basic.txt +160 -0
  520. data/windows/zlib, libpng/zlib/old/zlib.html +971 -0
  521. data/windows/zlib, libpng/zlib/projects/README.projects +41 -0
  522. data/windows/zlib, libpng/zlib/projects/visualc6/README.txt +73 -0
  523. data/windows/zlib, libpng/zlib/projects/visualc6/example.dsp +278 -0
  524. data/windows/zlib, libpng/zlib/projects/visualc6/minigzip.dsp +278 -0
  525. data/windows/zlib, libpng/zlib/projects/visualc6/zlib.dsp +609 -0
  526. data/windows/zlib, libpng/zlib/projects/visualc6/zlib.dsw +59 -0
  527. data/windows/zlib, libpng/zlib/qnx/package.qpg +141 -0
  528. data/windows/zlib, libpng/zlib/trees.c +1219 -0
  529. data/windows/zlib, libpng/zlib/trees.h +128 -0
  530. data/windows/zlib, libpng/zlib/uncompr.c +61 -0
  531. data/windows/zlib, libpng/zlib/win32/DLL_FAQ.txt +397 -0
  532. data/windows/zlib, libpng/zlib/win32/Makefile.bor +107 -0
  533. data/windows/zlib, libpng/zlib/win32/Makefile.emx +69 -0
  534. data/windows/zlib, libpng/zlib/win32/Makefile.gcc +141 -0
  535. data/windows/zlib, libpng/zlib/win32/Makefile.msc +126 -0
  536. data/windows/zlib, libpng/zlib/win32/VisualC.txt +3 -0
  537. data/windows/zlib, libpng/zlib/win32/zlib.def +60 -0
  538. data/windows/zlib, libpng/zlib/win32/zlib1.rc +39 -0
  539. data/windows/zlib, libpng/zlib/zconf.h +332 -0
  540. data/windows/zlib, libpng/zlib/zconf.in.h +332 -0
  541. data/windows/zlib, libpng/zlib/zlib.3 +159 -0
  542. data/windows/zlib, libpng/zlib/zlib.h +1357 -0
  543. data/windows/zlib, libpng/zlib/zutil.c +318 -0
  544. data/windows/zlib, libpng/zlib/zutil.h +269 -0
  545. metadata +669 -216
@@ -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
+ }